diff --git a/lean/OAI/Combinatorics/Sensitivity/RecursiveJointZero.lean b/lean/OAI/Combinatorics/Sensitivity/RecursiveJointZero.lean new file mode 100644 index 0000000000000000000000000000000000000000..58cbced565921b0a700cb4f1f16aa6ae66325770 --- /dev/null +++ b/lean/OAI/Combinatorics/Sensitivity/RecursiveJointZero.lean @@ -0,0 +1,97 @@ +import OAI.Combinatorics.Sensitivity.RecursiveCandidates + +namespace OAI + +/-! The joint zero recurrence uses the fixed weaker-threshold failure lists. -/ + +noncomputable section +open scoped Classical + +namespace Paper320 + +theorem recursive_joint_zero_at {k r h : ℕ} {I : Type} [Fintype I] + (T : Tournament k) (A : GoodLabeling T r) + (F : Fin (h + 1) → (I → Bool) → Bool) (hF : NestedFamily F) (hr : 0 < r) + (q q' : Fin h) (hqq : q < q') (x : ((Fin k × Fin r) × I) → Bool) + (hx : recursiveFamily T A.label F q x = false) + (hx' : recursiveFamily T A.label F q' x = false) : + jointSensitivityAt (recursiveFamily T A.label F q) (recursiveFamily T A.label F q') x ≤ + 16 * sideSensitivity F false + 3 * jointSensitivity F true := by + let TC := targetCandidates T A.label F q x + let GC := gateCandidates T A.label F q x + let w := gateWitness T A.label F q x + let U := TC.biUnion fun i => childChanges F (Fin.last h) x i (targetWitness F x hr i) + let V := GC.biUnion fun i => childJointChanges F (gateIndex q') (gateIndex q) x (w i) (A.label i (w i)) + have hsub : (Finset.univ.filter fun p => + recursiveFamily T A.label F q (flip x {p}) ≠ recursiveFamily T A.label F q x ∧ + recursiveFamily T A.label F q' (flip x {p}) ≠ recursiveFamily T A.label F q' x) ⊆ U ∪ V := by + rintro ⟨⟨j, c⟩, a⟩ hp + have hchange := (Finset.mem_filter.mp hp).2 + have hon' : recursiveFamily T A.label F q' (flip x {((j, c), a)}) = true := by + cases hy : recursiveFamily T A.label F q' (flip x {((j, c), a)}) + · exact False.elim (hchange.2 (hy.trans hx'.symm)) + · rfl + obtain ⟨i, hi'⟩ := (recursiveFamily_eq_true_iff T A.label F q' _).mp hon' + have hi := rowClause_nested T A.label F hF hqq.le _ i hi' + have hioff := (recursiveFamily_eq_false_iff T A.label F q x).mp hx i + rcases rowClause_repair_cases T A.label F q x i j c a hioff hi with + ⟨hit, hji, htoff, hton⟩ | ⟨hig, hij, rfl, hgon, hgoff⟩ + · subst j + have hc := targetWitness_unique T A.label F q x hr i hit c htoff + apply Finset.mem_union_left + apply Finset.mem_biUnion.mpr + refine ⟨i, hit, ?_⟩ + have hn : F (Fin.last h) (flip (recursiveChild x i c) {a}) ≠ + F (Fin.last h) (recursiveChild x i c) := by simp [hton, htoff] + simpa [childChanges, hc] using hn + · have hj := gateWitness_unique T A.label F q x i hig j hij hgon + have hgon' := hF.accepts_of_le (gateIndex_strictAnti hqq).le hgon + have hgoff' := ((rowClause_eq_true_iff T A.label F q' _ i).mp hi').2 j hij + rw [recursiveChild_flip_same] at hgoff' + apply Finset.mem_union_right + apply Finset.mem_biUnion.mpr + refine ⟨i, hig, ?_⟩ + have hn : + F (gateIndex q') (flip (recursiveChild x j (A.label i j)) {a}) ≠ + F (gateIndex q') (recursiveChild x j (A.label i j)) ∧ + F (gateIndex q) (flip (recursiveChild x j (A.label i j)) {a}) ≠ + F (gateIndex q) (recursiveChild x j (A.label i j)) := by + simp [hgon, hgoff, hgon', hgoff'] + simpa [childJointChanges, w, hj] using hn + have hU : U.card ≤ 16 * sideSensitivity F false := by + calc + U.card ≤ TC.card * sideSensitivity F false := + card_biUnion_le_mul TC _ _ (fun i hi => by + rw [childChanges_card] + exact sensitivityAt_le_sideSensitivity F false _ _ + (targetWitness_false T A.label F q x hr i hi)) + _ ≤ 16 * sideSensitivity F false := Nat.mul_le_mul_right _ + (Nat.le_of_lt (targetCandidates_card T A F hF q x hr)) + have hV : V.card ≤ 3 * jointSensitivity F true := by + calc + V.card ≤ GC.card * jointSensitivity F true := + card_biUnion_le_mul GC _ _ (fun i hi => by + rw [childJointChanges_card] + have hg := (gateWitness_spec T A.label F q x i hi).2 + exact jointSensitivityAt_le_jointSensitivity F true _ _ _ + (gateIndex_strictAnti hqq) (hF.accepts_of_le (gateIndex_strictAnti hqq).le hg) hg) + _ ≤ 3 * jointSensitivity F true := Nat.mul_le_mul_right _ (gateCandidates_card T A.label F hF q x) + calc + jointSensitivityAt (recursiveFamily T A.label F q) (recursiveFamily T A.label F q') x ≤ + (U ∪ V).card := Finset.card_le_card hsub + _ ≤ U.card + V.card := Finset.card_union_le _ _ + _ ≤ _ := Nat.add_le_add hU hV + +theorem recursive_joint_zero {k r h : ℕ} {I : Type} [Fintype I] + (T : Tournament k) (A : GoodLabeling T r) + (F : Fin (h + 1) → (I → Bool) → Bool) (hF : NestedFamily F) (hr : 0 < r) : + jointSensitivity (recursiveFamily T A.label F) false ≤ + 16 * sideSensitivity F false + 3 * jointSensitivity F true := by + apply jointSensitivity_le + exact fun q q' x hqq hx hx' => recursive_joint_zero_at T A F hF hr q q' hqq x hx hx' + +end Paper320 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sensitivity/RecursiveOne.lean b/lean/OAI/Combinatorics/Sensitivity/RecursiveOne.lean new file mode 100644 index 0000000000000000000000000000000000000000..8c7fda8212a2a2940074c844a31e0708d925587d --- /dev/null +++ b/lean/OAI/Combinatorics/Sensitivity/RecursiveOne.lean @@ -0,0 +1,150 @@ +import OAI.Combinatorics.Sensitivity.RecursiveSets + +namespace OAI + +/-! The two recurrences for inputs at which the parent predicates accept. -/ + +noncomputable section +open scoped Classical + +namespace Paper320 + +theorem recursive_sensitivity_one_at {k r h : ℕ} {I : Type} [Fintype I] + (T : Tournament k) (label : Fin k → Fin k → Fin r) + (F : Fin (h + 1) → (I → Bool) → Bool) (o : ℕ) + (ho : ∀ i, (Finset.univ.filter (T.Adj i)).card = o) + (q : Fin h) (x : ((Fin k × Fin r) × I) → Bool) + (hx : recursiveFamily T label F q x = true) : + sensitivityAt (recursiveFamily T label F q) x ≤ + o * sideSensitivity F false + r * sideSensitivity F true := by + obtain ⟨i, hi⟩ := (recursiveFamily_eq_true_iff T label F q x).mp hx + have hcond := (rowClause_eq_true_iff T label F q x i).mp hi + let U := Finset.univ.biUnion fun c => childChanges F (Fin.last h) x i c + let V := (Finset.univ.filter (T.Adj i)).biUnion fun j => + childChanges F (gateIndex q) x j (label i j) + have hsub : (Finset.univ.filter fun p => + recursiveFamily T label F q (flip x {p}) ≠ recursiveFamily T label F q x) ⊆ U ∪ V := by + rintro ⟨⟨j, c⟩, a⟩ hp + have hchange := (Finset.mem_filter.mp hp).2 + have hf : recursiveFamily T label F q (flip x {((j, c), a)}) = false := by + cases hy : recursiveFamily T label F q (flip x {((j, c), a)}) + · rfl + · exact False.elim (hchange (hy.trans hx.symm)) + have hif := (recursiveFamily_eq_false_iff T label F q _).mp hf i + have hic : rowClause T label F q (flip x {((j, c), a)}) i ≠ rowClause T label F q x i := by + simp [hi, hif] + rcases rowClause_flip_change T label F q x i j c a hic with ⟨rfl, ht⟩ | ⟨hij, rfl, hg⟩ + · apply Finset.mem_union_left + apply Finset.mem_biUnion.mpr + exact ⟨c, Finset.mem_univ _, by simpa [childChanges] using ht⟩ + · apply Finset.mem_union_right + apply Finset.mem_biUnion.mpr + exact ⟨j, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hij⟩, + by simpa [childChanges] using hg⟩ + have hU : U.card ≤ r * sideSensitivity F true := by + simpa [U] using card_biUnion_le_mul Finset.univ + (fun c => childChanges F (Fin.last h) x i c) (sideSensitivity F true) + (fun c _ => by + rw [childChanges_card] + exact sensitivityAt_le_sideSensitivity F true _ _ (hcond.1 c)) + have hV : V.card ≤ o * sideSensitivity F false := by + simpa only [V, ho i] using card_biUnion_le_mul (Finset.univ.filter (T.Adj i)) + (fun j => childChanges F (gateIndex q) x j (label i j)) (sideSensitivity F false) + (fun j hj => by + rw [childChanges_card] + exact sensitivityAt_le_sideSensitivity F false _ _ + (hcond.2 j (Finset.mem_filter.mp hj).2)) + calc + sensitivityAt (recursiveFamily T label F q) x ≤ (U ∪ V).card := Finset.card_le_card hsub + _ ≤ U.card + V.card := Finset.card_union_le _ _ + _ ≤ r * sideSensitivity F true + o * sideSensitivity F false := Nat.add_le_add hU hV + _ = _ := Nat.add_comm _ _ + +theorem recursive_side_one {k r h : ℕ} {I : Type} [Fintype I] + (T : Tournament k) (label : Fin k → Fin k → Fin r) + (F : Fin (h + 1) → (I → Bool) → Bool) (o : ℕ) + (ho : ∀ i, (Finset.univ.filter (T.Adj i)).card = o) : + sideSensitivity (recursiveFamily T label F) true ≤ + o * sideSensitivity F false + r * sideSensitivity F true := by + apply sideSensitivity_le + exact fun q x hx => recursive_sensitivity_one_at T label F o ho q x hx + +theorem recursive_joint_one_at {k r h : ℕ} {I : Type} [Fintype I] + (T : Tournament k) (label : Fin k → Fin k → Fin r) + (F : Fin (h + 1) → (I → Bool) → Bool) (hF : NestedFamily F) (o : ℕ) + (ho : ∀ i, (Finset.univ.filter (T.Adj i)).card = o) + (q q' : Fin h) (hqq : q < q') (x : ((Fin k × Fin r) × I) → Bool) + (hx : recursiveFamily T label F q x = true) + (hx' : recursiveFamily T label F q' x = true) : + jointSensitivityAt (recursiveFamily T label F q) (recursiveFamily T label F q') x ≤ + o * jointSensitivity F false + r * sideSensitivity F true := by + obtain ⟨i, hi'⟩ := (recursiveFamily_eq_true_iff T label F q' x).mp hx' + have hi := rowClause_nested T label F hF hqq.le x i hi' + have hcond := (rowClause_eq_true_iff T label F q x i).mp hi + have hcond' := (rowClause_eq_true_iff T label F q' x i).mp hi' + let U := Finset.univ.biUnion fun c => childChanges F (Fin.last h) x i c + let V := (Finset.univ.filter (T.Adj i)).biUnion fun j => + childJointChanges F (gateIndex q') (gateIndex q) x j (label i j) + have hsub : (Finset.univ.filter fun p => + recursiveFamily T label F q (flip x {p}) ≠ recursiveFamily T label F q x ∧ + recursiveFamily T label F q' (flip x {p}) ≠ recursiveFamily T label F q' x) ⊆ U ∪ V := by + rintro ⟨⟨j, c⟩, a⟩ hp + have hchange := (Finset.mem_filter.mp hp).2 + have hf : recursiveFamily T label F q (flip x {((j, c), a)}) = false := by + cases hy : recursiveFamily T label F q (flip x {((j, c), a)}) + · rfl + · exact False.elim (hchange.1 (hy.trans hx.symm)) + have hf' : recursiveFamily T label F q' (flip x {((j, c), a)}) = false := by + cases hy : recursiveFamily T label F q' (flip x {((j, c), a)}) + · rfl + · exact False.elim (hchange.2 (hy.trans hx'.symm)) + have hif := (recursiveFamily_eq_false_iff T label F q _).mp hf i + have hif' := (recursiveFamily_eq_false_iff T label F q' _).mp hf' i + have hic : rowClause T label F q (flip x {((j, c), a)}) i ≠ rowClause T label F q x i := by + simp [hi, hif] + have hic' : rowClause T label F q' (flip x {((j, c), a)}) i ≠ rowClause T label F q' x i := by + simp [hi', hif'] + rcases rowClause_joint_flip_change T label F q q' x i j c a hic hic' with + ⟨rfl, ht⟩ | ⟨hij, rfl, hg, hg'⟩ + · apply Finset.mem_union_left + apply Finset.mem_biUnion.mpr + exact ⟨c, Finset.mem_univ _, by simpa [childChanges] using ht⟩ + · apply Finset.mem_union_right + apply Finset.mem_biUnion.mpr + exact ⟨j, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hij⟩, + by simpa [childJointChanges] using And.intro hg' hg⟩ + have hU : U.card ≤ r * sideSensitivity F true := by + simpa [U] using card_biUnion_le_mul Finset.univ + (fun c => childChanges F (Fin.last h) x i c) (sideSensitivity F true) + (fun c _ => by + rw [childChanges_card] + exact sensitivityAt_le_sideSensitivity F true _ _ (hcond.1 c)) + have hV : V.card ≤ o * jointSensitivity F false := by + simpa only [V, ho i] using card_biUnion_le_mul (Finset.univ.filter (T.Adj i)) + (fun j => childJointChanges F (gateIndex q') (gateIndex q) x j (label i j)) + (jointSensitivity F false) (fun j hj => by + have hij := (Finset.mem_filter.mp hj).2 + rw [childJointChanges_card] + exact jointSensitivityAt_le_jointSensitivity F false _ _ _ + (gateIndex_strictAnti hqq) (hcond'.2 j hij) (hcond.2 j hij)) + calc + jointSensitivityAt (recursiveFamily T label F q) (recursiveFamily T label F q') x ≤ + (U ∪ V).card := Finset.card_le_card hsub + _ ≤ U.card + V.card := Finset.card_union_le _ _ + _ ≤ r * sideSensitivity F true + o * jointSensitivity F false := Nat.add_le_add hU hV + _ = _ := Nat.add_comm _ _ + +theorem recursive_joint_one {k r h : ℕ} {I : Type} [Fintype I] + (T : Tournament k) (label : Fin k → Fin k → Fin r) + (F : Fin (h + 1) → (I → Bool) → Bool) (hF : NestedFamily F) (o : ℕ) + (ho : ∀ i, (Finset.univ.filter (T.Adj i)).card = o) : + jointSensitivity (recursiveFamily T label F) true ≤ + o * jointSensitivity F false + r * sideSensitivity F true := by + apply jointSensitivity_le + exact fun q q' x hqq hx hx' => recursive_joint_one_at T label F hF o ho q q' hqq x hx hx' + +end Paper320 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sensitivity/RecursiveProfiles.lean b/lean/OAI/Combinatorics/Sensitivity/RecursiveProfiles.lean new file mode 100644 index 0000000000000000000000000000000000000000..bffc0203fd8bc5287becabb3654b8b06dfb310f5 --- /dev/null +++ b/lean/OAI/Combinatorics/Sensitivity/RecursiveProfiles.lean @@ -0,0 +1,110 @@ +import OAI.Combinatorics.Sensitivity.Model + +namespace OAI + +/-! The side and joint profiles count literal flips of the same raw input. -/ + +noncomputable section +open scoped Classical + +namespace Paper320 + +/-- Acceptance at a stronger index implies acceptance at every weaker index. -/ +structure NestedFamily {h : ℕ} {I : Type} + (F : Fin h → (I → Bool) → Bool) : Prop where + accepts_of_le : ∀ {q q' : Fin h} {x}, q ≤ q' → F q' x = true → F q x = true + +theorem NestedFamily.rejects_of_le {h : ℕ} {I : Type} + {F : Fin h → (I → Bool) → Bool} (hF : NestedFamily F) + {q q' : Fin h} {x} (hqq : q ≤ q') (hx : F q x = false) : + F q' x = false := by + cases h' : F q' x + · rfl + · have := hF.accepts_of_le hqq h' + simp [hx] at this + +/-- The number of coordinates whose one-bit flip changes both predicates. -/ +def jointSensitivityAt {I : Type} [Fintype I] + (f g : (I → Bool) → Bool) (x : I → Bool) : ℕ := + (Finset.univ.filter fun i => + f (flip x {i}) ≠ f x ∧ g (flip x {i}) ≠ g x).card + +/-- Maximum sensitivity over all indices and inputs with the indicated output. -/ +def sideSensitivity {h : ℕ} {I : Type} [Fintype I] + (F : Fin h → (I → Bool) → Bool) (b : Bool) : ℕ := + Finset.univ.sup fun q => Finset.univ.sup fun x => + if F q x = b then sensitivityAt (F q) x else 0 + +/-- Maximum same-input, same-bit joint sensitivity over two distinct ordered indices. -/ +def jointSensitivity {h : ℕ} {I : Type} [Fintype I] + (F : Fin h → (I → Bool) → Bool) (b : Bool) : ℕ := + Finset.univ.sup fun q => Finset.univ.sup fun q' => Finset.univ.sup fun x => + if q < q' ∧ F q x = b ∧ F q' x = b then + jointSensitivityAt (F q) (F q') x else 0 + +theorem sensitivityAt_le_sideSensitivity {h : ℕ} {I : Type} [Fintype I] + (F : Fin h → (I → Bool) → Bool) (b : Bool) (q : Fin h) (x : I → Bool) + (hx : F q x = b) : sensitivityAt (F q) x ≤ sideSensitivity F b := by + apply Finset.le_sup_of_le (Finset.mem_univ q) + apply Finset.le_sup_of_le (Finset.mem_univ x) + simp [hx] + +theorem sideSensitivity_le {h : ℕ} {I : Type} [Fintype I] + (F : Fin h → (I → Bool) → Bool) (b : Bool) (B : ℕ) + (hB : ∀ q x, F q x = b → sensitivityAt (F q) x ≤ B) : + sideSensitivity F b ≤ B := by + apply Finset.sup_le + intro q _ + apply Finset.sup_le + intro x _ + split_ifs with hx + · exact hB q x hx + · exact Nat.zero_le _ + +theorem jointSensitivityAt_le_jointSensitivity {h : ℕ} {I : Type} [Fintype I] + (F : Fin h → (I → Bool) → Bool) (b : Bool) (q q' : Fin h) (x : I → Bool) + (hqq : q < q') (hx : F q x = b) (hx' : F q' x = b) : + jointSensitivityAt (F q) (F q') x ≤ jointSensitivity F b := by + apply Finset.le_sup_of_le (Finset.mem_univ q) + apply Finset.le_sup_of_le (Finset.mem_univ q') + apply Finset.le_sup_of_le (Finset.mem_univ x) + simp [hqq, hx, hx'] + +theorem jointSensitivity_le {h : ℕ} {I : Type} [Fintype I] + (F : Fin h → (I → Bool) → Bool) (b : Bool) (B : ℕ) + (hB : ∀ q q' x, q < q' → F q x = b → F q' x = b → + jointSensitivityAt (F q) (F q') x ≤ B) : jointSensitivity F b ≤ B := by + apply Finset.sup_le + intro q _ + apply Finset.sup_le + intro q' _ + apply Finset.sup_le + intro x _ + split_ifs with hx + · exact hB q q' x hx.1 hx.2.1 hx.2.2 + · exact Nat.zero_le _ + +theorem jointSensitivityAt_le_left {I : Type} [Fintype I] + (f g : (I → Bool) → Bool) (x : I → Bool) : + jointSensitivityAt f g x ≤ sensitivityAt f x := by + apply Finset.card_le_card + intro i hi + exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, (Finset.mem_filter.mp hi).2.1⟩ + +theorem jointSensitivityAt_comm {I : Type} [Fintype I] + (f g : (I → Bool) → Bool) (x : I → Bool) : + jointSensitivityAt f g x = jointSensitivityAt g f x := by + simp only [jointSensitivityAt, and_comm] + +theorem jointSensitivity_one {I : Type} [Fintype I] + (F : Fin 1 → (I → Bool) → Bool) (b : Bool) : jointSensitivity F b = 0 := by + apply Nat.eq_zero_of_le_zero + apply jointSensitivity_le + intro q q' x hqq _ _ + exact False.elim (by omega) + +end Paper320 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sensitivity/RecursiveRepair.lean b/lean/OAI/Combinatorics/Sensitivity/RecursiveRepair.lean new file mode 100644 index 0000000000000000000000000000000000000000..f89ccf95902184e7c39efae4d05064722b8a4ad9 --- /dev/null +++ b/lean/OAI/Combinatorics/Sensitivity/RecursiveRepair.lean @@ -0,0 +1,103 @@ +import OAI.Combinatorics.Sensitivity.RecursiveFailures + +namespace OAI + +/-! A successful raw-bit flip repairs the unique initial failed condition. -/ + +noncomputable section +open scoped Classical + +namespace Paper320 + +theorem repaired_target_location {k r h : ℕ} {I : Type} (T : Tournament k) + (label : Fin k → Fin k → Fin r) (F : Fin (h + 1) → (I → Bool) → Bool) + (q : Fin h) (x : ((Fin k × Fin r) × I) → Bool) + (i j : Fin k) (c c' : Fin r) (a : I) + (hf : rowClause T label F q (flip x {((j, c), a)}) i = true) + (hz : F (Fin.last h) (recursiveChild x i c') = false) : (i, c') = (j, c) := by + by_contra hne + have ht := ((rowClause_eq_true_iff T label F q _ i).mp hf).1 c' + rw [recursiveChild_flip_other x j i c c' a hne, hz] at ht + exact Bool.false_ne_true ht + +theorem repaired_gate_location {k r h : ℕ} {I : Type} (T : Tournament k) + (label : Fin k → Fin k → Fin r) (F : Fin (h + 1) → (I → Bool) → Bool) + (q : Fin h) (x : ((Fin k × Fin r) × I) → Bool) + (i j j' : Fin k) (c : Fin r) (a : I) + (hf : rowClause T label F q (flip x {((j, c), a)}) i = true) + (hij' : T.Adj i j') (hon : F (gateIndex q) (recursiveChild x j' (label i j')) = true) : + (j', label i j') = (j, c) := by + by_contra hne + have hg := ((rowClause_eq_true_iff T label F q _ i).mp hf).2 j' hij' + rw [recursiveChild_flip_other x j j' c (label i j') a hne, hon] at hg + exact Bool.false_ne_true hg.symm + +theorem rowClause_repair_cases {k r h : ℕ} {I : Type} (T : Tournament k) + (label : Fin k → Fin k → Fin r) (F : Fin (h + 1) → (I → Bool) → Bool) + (q : Fin h) (x : ((Fin k × Fin r) × I) → Bool) + (i j : Fin k) (c : Fin r) (a : I) + (hi : rowClause T label F q x i = false) + (hf : rowClause T label F q (flip x {((j, c), a)}) i = true) : + (i ∈ targetCandidates T label F q x ∧ j = i ∧ + F (Fin.last h) (recursiveChild x j c) = false ∧ + F (Fin.last h) (flip (recursiveChild x j c) {a}) = true) ∨ + (i ∈ gateCandidates T label F q x ∧ T.Adj i j ∧ c = label i j ∧ + F (gateIndex q) (recursiveChild x j c) = true ∧ + F (gateIndex q) (flip (recursiveChild x j c) {a}) = false) := by + have hchange : rowClause T label F q (flip x {((j, c), a)}) i ≠ rowClause T label F q x i := by + simp [hi, hf] + rcases rowClause_flip_change T label F q x i j c a hchange with + ⟨hji, ht⟩ | ⟨hij, rfl, hg⟩ + · subst j + have hton := ((rowClause_eq_true_iff T label F q _ i).mp hf).1 c + rw [recursiveChild_flip_same] at hton + have htoff : F (Fin.last h) (recursiveChild x i c) = false := by + cases hc : F (Fin.last h) (recursiveChild x i c) + · rfl + · exact False.elim (ht (hton.trans hc.symm)) + have htargets : targetFailures F x i = {c} := by + ext c' + simp only [targetFailures, Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_singleton] + constructor + · intro hfalse + exact congrArg Prod.snd (repaired_target_location T label F q x i i c c' a hf hfalse) + · rintro rfl + exact htoff + have hgates : gateFailures T label F q x i = ∅ := by + apply Finset.eq_empty_iff_forall_notMem.mpr + intro j' hj' + have h := (Finset.mem_filter.mp hj').2 + have heq := repaired_gate_location T label F q x i i j' c a hf h.1 h.2 + exact T.ne_of_adj h.1 (congrArg Prod.fst heq).symm + have hmem : i ∈ targetCandidates T label F q x := by + simp [targetCandidates, htargets, hgates] + exact Or.inl ⟨hmem, rfl, htoff, hton⟩ + · have hgoff := ((rowClause_eq_true_iff T label F q _ i).mp hf).2 j hij + rw [recursiveChild_flip_same] at hgoff + have hgon : F (gateIndex q) (recursiveChild x j (label i j)) = true := by + cases hc : F (gateIndex q) (recursiveChild x j (label i j)) + · exact False.elim (hg (hgoff.trans hc.symm)) + · rfl + have htargets : targetFailures F x i = ∅ := by + apply Finset.eq_empty_iff_forall_notMem.mpr + intro c' hc' + have heq := repaired_target_location T label F q x i j (label i j) c' a hf + (Finset.mem_filter.mp hc').2 + exact T.ne_of_adj hij (congrArg Prod.fst heq) + have hgates : gateFailures T label F q x i = {j} := by + ext j' + simp only [gateFailures, Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_singleton] + constructor + · rintro ⟨hij', hon⟩ + exact congrArg Prod.fst (repaired_gate_location T label F q x i j j' (label i j) a hf hij' hon) + · rintro rfl + exact ⟨hij, hgon⟩ + have hmem : i ∈ gateCandidates T label F q x := by + simp [gateCandidates, htargets, hgates] + exact Or.inr ⟨hmem, hij, rfl, hgon, hgoff⟩ + +end Paper320 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sensitivity/RecursiveSets.lean b/lean/OAI/Combinatorics/Sensitivity/RecursiveSets.lean new file mode 100644 index 0000000000000000000000000000000000000000..aa426efb308c0356dfdadd741f376aad94b48052 --- /dev/null +++ b/lean/OAI/Combinatorics/Sensitivity/RecursiveSets.lean @@ -0,0 +1,89 @@ +import OAI.Combinatorics.Sensitivity.RecursiveFlips + +namespace OAI + +/-! Finite sets of changing raw coordinates inside an individual child. -/ + +noncomputable section +open scoped Classical + +namespace Paper320 + +def childLift {J I : Type} (j : J) (A : Finset I) : Finset (J × I) := + A.map ⟨fun a => (j, a), fun _ _ h => congrArg (fun p : J × I => p.2) h⟩ + +@[simp] theorem mem_childLift {J I : Type} (j : J) (A : Finset I) (p : J × I) : + p ∈ childLift j A ↔ p.1 = j ∧ p.2 ∈ A := by + rcases p with ⟨k, a⟩ + unfold childLift + rw [Finset.mem_map] + constructor + · rintro ⟨b, hb, hp⟩ + change (j, b) = (k, a) at hp + cases hp + exact ⟨rfl, hb⟩ + · rintro ⟨rfl, ha⟩ + exact ⟨a, ha, rfl⟩ + +@[simp] theorem childLift_card {J I : Type} (j : J) (A : Finset I) : + (childLift j A).card = A.card := Finset.card_map _ + +def childChanges {k r h : ℕ} {I : Type} [Fintype I] + (F : Fin h → (I → Bool) → Bool) (q : Fin h) + (x : ((Fin k × Fin r) × I) → Bool) (j : Fin k) (c : Fin r) : + Finset ((Fin k × Fin r) × I) := + childLift (j, c) (Finset.univ.filter fun a => + F q (flip (recursiveChild x j c) {a}) ≠ F q (recursiveChild x j c)) + +def childJointChanges {k r h : ℕ} {I : Type} [Fintype I] + (F : Fin h → (I → Bool) → Bool) (q q' : Fin h) + (x : ((Fin k × Fin r) × I) → Bool) (j : Fin k) (c : Fin r) : + Finset ((Fin k × Fin r) × I) := + childLift (j, c) (Finset.univ.filter fun a => + F q (flip (recursiveChild x j c) {a}) ≠ F q (recursiveChild x j c) ∧ + F q' (flip (recursiveChild x j c) {a}) ≠ F q' (recursiveChild x j c)) + +@[simp] theorem childChanges_card {k r h : ℕ} {I : Type} [Fintype I] + (F : Fin h → (I → Bool) → Bool) (q : Fin h) + (x : ((Fin k × Fin r) × I) → Bool) (j : Fin k) (c : Fin r) : + (childChanges F q x j c).card = sensitivityAt (F q) (recursiveChild x j c) := by + simp [childChanges, sensitivityAt] + +@[simp] theorem childJointChanges_card {k r h : ℕ} {I : Type} [Fintype I] + (F : Fin h → (I → Bool) → Bool) (q q' : Fin h) + (x : ((Fin k × Fin r) × I) → Bool) (j : Fin k) (c : Fin r) : + (childJointChanges F q q' x j c).card = + jointSensitivityAt (F q) (F q') (recursiveChild x j c) := by + simp [childJointChanges, jointSensitivityAt] + +theorem card_biUnion_le_mul {J I : Type} [DecidableEq I] (A : Finset J) (B : J → Finset I) (n : ℕ) + (hn : ∀ j ∈ A, (B j).card ≤ n) : (A.biUnion B).card ≤ A.card * n := by + calc + (A.biUnion B).card ≤ ∑ j ∈ A, (B j).card := Finset.card_biUnion_le + _ ≤ ∑ _j ∈ A, n := Finset.sum_le_sum hn + _ = A.card * n := by simp + +theorem rowClause_joint_flip_change {k r h : ℕ} {I : Type} (T : Tournament k) + (label : Fin k → Fin k → Fin r) (F : Fin (h + 1) → (I → Bool) → Bool) + (q q' : Fin h) (x : ((Fin k × Fin r) × I) → Bool) + (i j : Fin k) (c : Fin r) (a : I) + (hc : rowClause T label F q (flip x {((j, c), a)}) i ≠ rowClause T label F q x i) + (hc' : rowClause T label F q' (flip x {((j, c), a)}) i ≠ rowClause T label F q' x i) : + (j = i ∧ F (Fin.last h) (flip (recursiveChild x j c) {a}) ≠ + F (Fin.last h) (recursiveChild x j c)) ∨ + (T.Adj i j ∧ c = label i j ∧ + F (gateIndex q) (flip (recursiveChild x j c) {a}) ≠ + F (gateIndex q) (recursiveChild x j c) ∧ + F (gateIndex q') (flip (recursiveChild x j c) {a}) ≠ + F (gateIndex q') (recursiveChild x j c)) := by + rcases rowClause_flip_change T label F q x i j c a hc with ht | ⟨hij, hcl, hq⟩ + · exact Or.inl ht + · rcases rowClause_flip_change T label F q' x i j c a hc' with ht | hg + · exact False.elim ((T.ne_of_adj hij) ht.1.symm) + · exact Or.inr ⟨hij, hcl, hq, hg.2.2⟩ + +end Paper320 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sensitivity/RecursiveZero.lean b/lean/OAI/Combinatorics/Sensitivity/RecursiveZero.lean new file mode 100644 index 0000000000000000000000000000000000000000..3aeb3148edcdbca24dbf467be4250200d1d003e0 --- /dev/null +++ b/lean/OAI/Combinatorics/Sensitivity/RecursiveZero.lean @@ -0,0 +1,121 @@ +import OAI.Combinatorics.Sensitivity.RecursiveCandidates + +namespace OAI + +/-! The zero-side recurrence separates the unique possible gate-list sink. -/ + +noncomputable section +open scoped Classical + +namespace Paper320 + +theorem recursive_sensitivity_zero_at {k r h : ℕ} {I : Type} [Fintype I] + (T : Tournament k) (A : GoodLabeling T r) + (F : Fin (h + 1) → (I → Bool) → Bool) (hF : NestedFamily F) (hr : 0 < r) + (q : Fin h) (x : ((Fin k × Fin r) × I) → Bool) + (hx : recursiveFamily T A.label F q x = false) : + sensitivityAt (recursiveFamily T A.label F q) x ≤ + 16 * sideSensitivity F false + sideSensitivity F true + 3 * jointSensitivity F true := by + let TC := targetCandidates T A.label F q x + let GC := gateCandidates T A.label F q x + let SC := gateSinks T A.label F q x + let NC := GC \ SC + let w := gateWitness T A.label F q x + let U := TC.biUnion fun i => childChanges F (Fin.last h) x i (targetWitness F x hr i) + let V := NC.biUnion fun i => childJointChanges F (gateIndex q) (Fin.last h) x (w i) (A.label i (w i)) + let W := SC.biUnion fun i => childChanges F (gateIndex q) x (w i) (A.label i (w i)) + have hsub : (Finset.univ.filter fun p => + recursiveFamily T A.label F q (flip x {p}) ≠ recursiveFamily T A.label F q x) ⊆ U ∪ (V ∪ W) := by + rintro ⟨⟨j, c⟩, a⟩ hp + have hchange := (Finset.mem_filter.mp hp).2 + have hon : recursiveFamily T A.label F q (flip x {((j, c), a)}) = true := by + cases hy : recursiveFamily T A.label F q (flip x {((j, c), a)}) + · exact False.elim (hchange (hy.trans hx.symm)) + · rfl + obtain ⟨i, hi⟩ := (recursiveFamily_eq_true_iff T A.label F q _).mp hon + have hioff := (recursiveFamily_eq_false_iff T A.label F q x).mp hx i + rcases rowClause_repair_cases T A.label F q x i j c a hioff hi with + ⟨hit, hji, htoff, hton⟩ | ⟨hig, hij, rfl, hgon, hgoff⟩ + · subst j + have hc := targetWitness_unique T A.label F q x hr i hit c htoff + apply Finset.mem_union_left + apply Finset.mem_biUnion.mpr + refine ⟨i, hit, ?_⟩ + have hn : F (Fin.last h) (flip (recursiveChild x i c) {a}) ≠ + F (Fin.last h) (recursiveChild x i c) := by simp [hton, htoff] + simpa [childChanges, hc] using hn + · have hj := gateWitness_unique T A.label F q x i hig j hij hgon + apply Finset.mem_union_right + by_cases hs : i ∈ SC + · apply Finset.mem_union_right + apply Finset.mem_biUnion.mpr + refine ⟨i, hs, ?_⟩ + have hn : F (gateIndex q) (flip (recursiveChild x j (A.label i j)) {a}) ≠ + F (gateIndex q) (recursiveChild x j (A.label i j)) := by simp [hgon, hgoff] + simpa [childChanges, w, hj] using hn + · have hwg := nonsink_gateWitness_mem T A.label F hF q x i hig hs + have hjg : j ∈ gateCandidates T A.label F q x := by simpa [hj] using hwg + have hton := (targetFailures_empty_iff F x j).mp (Finset.mem_filter.mp hjg).2.1 (A.label i j) + have htoff := hF.rejects_of_le (gateIndex_lt_last q).le hgoff + apply Finset.mem_union_left + apply Finset.mem_biUnion.mpr + refine ⟨i, Finset.mem_sdiff.mpr ⟨hig, hs⟩, ?_⟩ + have hn : + F (gateIndex q) (flip (recursiveChild x j (A.label i j)) {a}) ≠ + F (gateIndex q) (recursiveChild x j (A.label i j)) ∧ + F (Fin.last h) (flip (recursiveChild x j (A.label i j)) {a}) ≠ + F (Fin.last h) (recursiveChild x j (A.label i j)) := by + simp [hgon, hgoff, hton, htoff] + simpa [childJointChanges, w, hj] using hn + have hU : U.card ≤ 16 * sideSensitivity F false := by + calc + U.card ≤ TC.card * sideSensitivity F false := + card_biUnion_le_mul TC _ _ (fun i hi => by + rw [childChanges_card] + exact sensitivityAt_le_sideSensitivity F false _ _ + (targetWitness_false T A.label F q x hr i hi)) + _ ≤ 16 * sideSensitivity F false := Nat.mul_le_mul_right _ + (Nat.le_of_lt (targetCandidates_card T A F hF q x hr)) + have hV : V.card ≤ 3 * jointSensitivity F true := by + calc + V.card ≤ NC.card * jointSensitivity F true := + card_biUnion_le_mul NC _ _ (fun i hi => by + have hg := Finset.mem_sdiff.mp hi + have hw := nonsink_gateWitness_mem T A.label F hF q x i hg.1 hg.2 + have hgate := (gateWitness_spec T A.label F q x i hg.1).2 + have htarget := (targetFailures_empty_iff F x _).mp (Finset.mem_filter.mp hw).2.1 + (A.label i (w i)) + rw [childJointChanges_card] + exact jointSensitivityAt_le_jointSensitivity F true _ _ _ (gateIndex_lt_last q) hgate htarget) + _ ≤ GC.card * jointSensitivity F true := Nat.mul_le_mul_right _ (Finset.card_le_card Finset.sdiff_subset) + _ ≤ 3 * jointSensitivity F true := Nat.mul_le_mul_right _ (gateCandidates_card T A.label F hF q x) + have hW : W.card ≤ sideSensitivity F true := by + calc + W.card ≤ SC.card * sideSensitivity F true := + card_biUnion_le_mul SC _ _ (fun i hi => by + rw [childChanges_card] + exact sensitivityAt_le_sideSensitivity F true _ _ + (gateWitness_spec T A.label F q x i (Finset.mem_filter.mp hi).1).2) + _ ≤ 1 * sideSensitivity F true := Nat.mul_le_mul_right _ (gateSinks_card T A.label F q x) + _ = _ := Nat.one_mul _ + calc + sensitivityAt (recursiveFamily T A.label F q) x ≤ (U ∪ (V ∪ W)).card := Finset.card_le_card hsub + _ ≤ U.card + (V ∪ W).card := Finset.card_union_le _ _ + _ ≤ U.card + (V.card + W.card) := Nat.add_le_add_left (Finset.card_union_le _ _) _ + _ ≤ 16 * sideSensitivity F false + (3 * jointSensitivity F true + sideSensitivity F true) := + Nat.add_le_add hU (Nat.add_le_add hV hW) + _ = _ := by omega + +theorem recursive_side_zero {k r h : ℕ} {I : Type} [Fintype I] + (T : Tournament k) (A : GoodLabeling T r) + (F : Fin (h + 1) → (I → Bool) → Bool) (hF : NestedFamily F) (hr : 0 < r) : + sideSensitivity (recursiveFamily T A.label F) false ≤ + 16 * sideSensitivity F false + sideSensitivity F true + 3 * jointSensitivity F true := by + apply sideSensitivity_le + exact fun q x hx => recursive_sensitivity_zero_at T A F hF hr q x hx + +end Paper320 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sensitivity/Reindex.lean b/lean/OAI/Combinatorics/Sensitivity/Reindex.lean new file mode 100644 index 0000000000000000000000000000000000000000..13789ad9fa27f424ccd525ea44ddc99ff8dd278b --- /dev/null +++ b/lean/OAI/Combinatorics/Sensitivity/Reindex.lean @@ -0,0 +1,106 @@ +import OAI.Combinatorics.Sensitivity.Basic + +namespace OAI + +/-! Coordinate equivalences preserve the two literal Boolean complexity measures. -/ + +noncomputable section +open scoped Classical + +namespace Paper320 + +variable {I J : Type} + +def reindex (e : I ≃ J) (f : (I → Bool) → Bool) : (J → Bool) → Bool := + fun x => f (fun i => x (e i)) + +theorem flip_reindex (e : I ≃ J) (x : J → Bool) (B : Finset I) : + (fun i => flip x (B.map e.toEmbedding) (e i)) = + flip (fun i => x (e i)) B := by + funext i + simp [flip] + +theorem flip_reindex_singleton (e : I ≃ J) (x : J → Bool) (i : I) : + (fun a => flip x {e i} (e a)) = flip (fun a => x (e a)) {i} := by + simpa using flip_reindex e x {i} + +@[simp] theorem reindex_symm (e : I ≃ J) (f : (I → Bool) → Bool) : + reindex e.symm (reindex e f) = f := by + funext x + simp [reindex] + +section Finite +variable [Fintype I] [Fintype J] + +theorem sensitivityAt_reindex (e : I ≃ J) (f : (I → Bool) → Bool) (x : J → Bool) : + sensitivityAt (reindex e f) x = sensitivityAt f (fun i => x (e i)) := by + have hs : (Finset.univ.filter fun j => + reindex e f (flip x {j}) ≠ reindex e f x).map e.symm.toEmbedding = + Finset.univ.filter (fun i => + f (flip (fun a => x (e a)) {i}) ≠ f (fun a => x (e a))) := by + ext i + simp only [Finset.mem_map_equiv, Equiv.symm_symm, Finset.mem_filter, + Finset.mem_univ, true_and] + change f (fun a => flip x {e i} (e a)) ≠ f (fun a => x (e a)) ↔ _ + rw [flip_reindex_singleton] + simpa only [sensitivityAt, Finset.card_map] using congrArg Finset.card hs + +theorem sensitivity_reindex (e : I ≃ J) (f : (I → Bool) → Bool) : + sensitivity (reindex e f) = sensitivity f := by + apply Nat.le_antisymm + · apply sensitivity_le + intro x + rw [sensitivityAt_reindex] + exact sensitivityAt_le_sensitivity f _ + · apply sensitivity_le + intro x + have h := sensitivityAt_le_sensitivity (reindex e f) (fun j => x (e.symm j)) + rw [sensitivityAt_reindex] at h + simpa only [Equiv.symm_apply_apply] using h + +theorem blockSensitivityAt_le_reindex (e : I ≃ J) (f : (I → Bool) → Bool) + (x : J → Bool) : + blockSensitivityAt f (fun i => x (e i)) ≤ blockSensitivityAt (reindex e f) x := by + apply blockSensitivityAt_le + intro blocks hd hb + have h := le_blockSensitivityAt_of_family (reindex e f) x + (fun B : blocks => B.val.map e.toEmbedding) + (fun B => (hb B.val B.property).1.map (f := e.toEmbedding)) + (by + intro A B hAB + apply (Finset.disjoint_map e.toEmbedding).mpr + exact hd A.val A.property B.val B.property (fun h => hAB (Subtype.ext h))) + (by + intro B + change f (fun i => flip x (B.val.map e.toEmbedding) (e i)) ≠ _ + rw [flip_reindex] + exact (hb B.val B.property).2) + simpa only [Fintype.card_coe] using h + +theorem blockSensitivityAt_reindex (e : I ≃ J) (f : (I → Bool) → Bool) + (x : J → Bool) : + blockSensitivityAt (reindex e f) x = blockSensitivityAt f (fun i => x (e i)) := by + apply Nat.le_antisymm + · have h := blockSensitivityAt_le_reindex e.symm (reindex e f) (fun i => x (e i)) + simpa only [Equiv.apply_symm_apply, reindex_symm] using h + · exact blockSensitivityAt_le_reindex e f x + +theorem blockSensitivity_reindex (e : I ≃ J) (f : (I → Bool) → Bool) : + blockSensitivity (reindex e f) = blockSensitivity f := by + apply Nat.le_antisymm + · apply blockSensitivity_le + intro x + rw [blockSensitivityAt_reindex] + exact blockSensitivityAt_le_blockSensitivity f _ + · apply blockSensitivity_le + intro x + have h := blockSensitivityAt_le_blockSensitivity (reindex e f) (fun j => x (e.symm j)) + rw [blockSensitivityAt_reindex] at h + simpa only [Equiv.symm_apply_apply] using h + +end Finite +end Paper320 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sensitivity/ScalarBounds.lean b/lean/OAI/Combinatorics/Sensitivity/ScalarBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..22626ba28313ddf8f10bc03628d92982f9c7a086 --- /dev/null +++ b/lean/OAI/Combinatorics/Sensitivity/ScalarBounds.lean @@ -0,0 +1,54 @@ +import Mathlib + +namespace OAI + +/-! Scalar bounds for the two coupled sensitivity profiles. -/ + +namespace Paper320 + +theorem geometric_error_le {d n : ℕ} (hn : n ≤ d) {ε L : ℝ} + (hε : 0 ≤ ε) (hL : 0 ≤ L) (hbudget : ε * 3 ^ (d + 1) ≤ 2) : + (3 / 2 : ℝ) * ε * L * (3 ^ n - 1) ≤ L := by + have hp : (3 : ℝ) ^ (n + 1) ≤ 3 ^ (d + 1) := + pow_le_pow_right₀ (by norm_num) (Nat.succ_le_succ hn) + have hb := (mul_le_mul_of_nonneg_left hp hε).trans hbudget + have hm := mul_le_mul_of_nonneg_right hb hL + rw [pow_succ] at hm + nlinarith [mul_nonneg hε hL] + +theorem coupled_profiles_bound (d : ℕ) (u v : ℕ → ℝ) (ε L : ℝ) + (hε : 0 ≤ ε) (hL : 0 ≤ L) (hbudget : ε * 3 ^ (d + 1) ≤ 2) + (hu0 : u 0 ≤ L) (hv0 : v 0 ≤ 0) + (hu : ∀ n < d, u (n + 1) ≤ (1 + ε) * u n + 3 * v n) + (hv : ∀ n < d, v (n + 1) ≤ ε * u n + 3 * v n) : + ∀ n ≤ d, u n ≤ 2 * L ∧ v n ≤ ε * L * (3 ^ n - 1) := by + have strong : ∀ n ≤ d, + u n ≤ L + (3 / 2 : ℝ) * ε * L * (3 ^ n - 1) ∧ + v n ≤ ε * L * (3 ^ n - 1) := by + intro n + induction n with + | zero => + intro _ + simpa using And.intro hu0 hv0 + | succ n ih => + intro hn + have hnd : n ≤ d := by omega + obtain ⟨hun, hvn⟩ := ih hnd + have he := geometric_error_le hnd hε hL hbudget + have hun' : u n ≤ 2 * L := by linarith + have heu := mul_le_mul_of_nonneg_left hun' hε + have hnu := hu n (by omega) + have hnv := hv n (by omega) + constructor + · rw [pow_succ] + nlinarith [mul_nonneg hε hL] + · rw [pow_succ] + nlinarith + intro n hn + obtain ⟨hun, hvn⟩ := strong n hn + have he := geometric_error_le hn hε hL hbudget + exact ⟨by linarith, hvn⟩ + +end Paper320 + +end OAI diff --git a/lean/OAI/Combinatorics/Sensitivity/SeedAmplification.lean b/lean/OAI/Combinatorics/Sensitivity/SeedAmplification.lean new file mode 100644 index 0000000000000000000000000000000000000000..d6df8eff5e7efa09586edb83101ffc19a78974b2 --- /dev/null +++ b/lean/OAI/Combinatorics/Sensitivity/SeedAmplification.lean @@ -0,0 +1,47 @@ +import OAI.Combinatorics.Sensitivity.ConstructedSeed +import OAI.Combinatorics.Sensitivity.PowerAmplification +import OAI.Combinatorics.Sensitivity.SeparationArithmetic + +namespace OAI + +/-! The depth-nine seed gives a fixed exponent and explicit ratios. -/ + +noncomputable section +open scoped Classical + +namespace Paper320 + +theorem constructed_power_family : + ∃ α : ℝ, 2 < α ∧ + ∃ (n : ℕ → ℕ) (F : ∀ m : ℕ, (Fin (n m) → Bool) → Bool), + (∀ m : ℕ, + 0 < n m ∧ F m (fun _ => false) = false ∧ + (∃ x y, F m x ≠ F m y) ∧ + (sensitivity (F m) : ℝ) ^ α ≤ (blockSensitivityAt (F m) (fun _ => false) : ℝ) ∧ + ((128 : ℝ) / 121) ^ m ≤ + (blockSensitivity (F m) : ℝ) / (sensitivity (F m) : ℝ) ^ 2) ∧ + Filter.Tendsto + (fun m : ℕ => (blockSensitivityAt (F m) (fun _ => false) : ℝ)) + Filter.atTop Filter.atTop := by + let M : ℕ := 9 ^ 10 + have hM : 0 < M := by dsimp [M]; positivity + obtain ⟨f, _, hf, _, hs, hb⟩ := exists_constructed_seed 9 M (by norm_num) (by rfl) + change sensitivity f ≤ 22 * M ^ 10 at hs + obtain ⟨hA, hB⟩ := depth_nine_seed_gap M hM + obtain ⟨hα, hall, hlim⟩ := power_amplification f hf (22 * M ^ 10) + (M ^ 2 * (2 * M ^ 2 + 1) ^ 9) hs hb hA hB + refine ⟨_, hα, _, (fun m => iterateFin f m), ?_, hlim⟩ + intro m + obtain ⟨hn, hzero, hnc, hpow, hratio⟩ := hall m + refine ⟨hn, hzero, hnc, hpow, ?_⟩ + apply le_trans _ hratio + apply pow_le_pow_left₀ (by norm_num) + have hMr : (0 : ℝ) < M := by exact_mod_cast hM + simpa only [Nat.cast_mul, Nat.cast_pow, Nat.cast_add, Nat.cast_ofNat, Nat.cast_one] + using depth_nine_seed_ratio hMr + +end Paper320 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sensitivity/Separation.lean b/lean/OAI/Combinatorics/Sensitivity/Separation.lean new file mode 100644 index 0000000000000000000000000000000000000000..d72f424a9e90900da6e5f35ba4f486287eadf342 --- /dev/null +++ b/lean/OAI/Combinatorics/Sensitivity/Separation.lean @@ -0,0 +1,57 @@ +import OAI.Combinatorics.Sensitivity.SeedAmplification + +namespace OAI + +/-! Quantitative, unbounded quadratic, and fixed-power separations of sensitivity. -/ + +noncomputable section +open scoped Classical + +namespace Paper320 + +theorem quantitative_separation (d : ℕ) (hd : 1 ≤ d) : + ∃ (n : ℕ) (f : (Fin n → Bool) → Bool), + 0 < n ∧ f (fun _ => false) = false ∧ + (∃ x y : Fin n → Bool, f x ≠ f y) ∧ + (2 : ℝ) ^ d / (4 * ((d : ℝ) + 2) ^ 2) ≤ + (blockSensitivity f : ℝ) / (sensitivity f : ℝ) ^ 2 := by + let M : ℕ := 9 ^ (d + 1) + have hM : 0 < M := by dsimp [M]; positivity + obtain ⟨f, hn, hf, hnc, hs, hb⟩ := exists_constructed_seed d M hd (by rfl) + exact ⟨_, f, hn, hf, hnc, quantitative_ratio_of_bounds f d M hM hnc hs hb⟩ + +theorem unbounded_quadratic_separation (C : ℝ) (hC : 0 < C) : + ∃ (n : ℕ) (f : (Fin n → Bool) → Bool), + 0 < n ∧ f (fun _ => false) = false ∧ + (∃ x y : Fin n → Bool, f x ≠ f y) ∧ + C * (sensitivity f : ℝ) ^ 2 < (blockSensitivity f : ℝ) := by + obtain ⟨d, hd, hlarge⟩ := ((Filter.eventually_ge_atTop (1 : ℕ)).and + (quantitative_ratio_tendsto.eventually_gt_atTop (max C 0))).exists + rw [max_eq_left hC.le] at hlarge + obtain ⟨n, f, hn, hf, hnc, hratio⟩ := quantitative_separation d hd + have hs : (0 : ℝ) < sensitivity f := by + exact_mod_cast sensitivity_pos_of_nonconstant f hnc + exact ⟨n, f, hn, hf, hnc, (lt_div_iff₀ (pow_pos hs 2)).mp (hlarge.trans_le hratio)⟩ + +theorem fixed_power_separation : + ∃ α : ℝ, 2 < α ∧ + ∃ (n : ℕ → ℕ) (F : ∀ m : ℕ, (Fin (n m) → Bool) → Bool), + (∀ m : ℕ, 1 ≤ m → + 0 < n m ∧ F m (fun _ => false) = false ∧ + (∃ x y : Fin (n m) → Bool, F m x ≠ F m y) ∧ + (sensitivity (F m) : ℝ) ^ α ≤ + (blockSensitivityAt (F m) (fun _ => false) : ℝ)) ∧ + Filter.Tendsto + (fun m : ℕ => (blockSensitivityAt (F m) (fun _ => false) : ℝ)) + Filter.atTop Filter.atTop := by + obtain ⟨α, hα, n, F, hall, hlim⟩ := constructed_power_family + refine ⟨α, hα, n, F, ?_, hlim⟩ + intro m _ + obtain ⟨hn, hf, hnc, hpow, _⟩ := hall m + exact ⟨hn, hf, hnc, hpow⟩ + +end Paper320 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sensitivity/SeparationArithmetic.lean b/lean/OAI/Combinatorics/Sensitivity/SeparationArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..5a0b95e3f5dfef8bb2bca1b91cf00797b6fd64ac --- /dev/null +++ b/lean/OAI/Combinatorics/Sensitivity/SeparationArithmetic.lean @@ -0,0 +1,116 @@ +import OAI.Combinatorics.Sensitivity.Basic + +namespace OAI + +/-! The exact final ratio, the depth-nine seed gap, and exponential divergence. -/ + +noncomputable section +open Filter +open scoped Topology + +namespace Paper320 + +theorem seed_ratio_identity (d : ℕ) {L M k : ℝ} (hL : L ≠ 0) (hM : M ≠ 0) : + (M ^ 2 * k ^ d) / (2 * L * M ^ (d + 1)) ^ 2 = + (k / M ^ 2) ^ d / (4 * L ^ 2) := by + have hp : (M ^ 2) ^ d = (M ^ d) ^ 2 := by + rw [← pow_mul, ← pow_mul, Nat.mul_comm 2 d] + rw [div_pow, hp, pow_succ] + field_simp + ring + +theorem seed_ratio_lower (d : ℕ) {M : ℝ} (hM : 0 < M) : + (2 : ℝ) ^ d / (4 * ((d : ℝ) + 2) ^ 2) ≤ + (M ^ 2 * (2 * M ^ 2 + 1) ^ d) / + (2 * ((d : ℝ) + 2) * M ^ (d + 1)) ^ 2 := by + rw [seed_ratio_identity d (by positivity) (ne_of_gt hM)] + have hk : 2 ≤ (2 * M ^ 2 + 1) / M ^ 2 := by + apply (le_div_iff₀ (pow_pos hM 2)).mpr + linarith + exact div_le_div_of_nonneg_right (pow_le_pow_left₀ (by norm_num) hk d) (by positivity) + +theorem ratio_of_bounds {I : Type} [Fintype I] (f : (I → Bool) → Bool) + (s b : ℝ) (hpos : 0 < (sensitivity f : ℝ)) + (hs : (sensitivity f : ℝ) ≤ s) (hb : b ≤ (blockSensitivityAt f (fun _ => false) : ℝ)) + (hb0 : 0 ≤ b) : + b / s ^ 2 ≤ (blockSensitivity f : ℝ) / (sensitivity f : ℝ) ^ 2 := by + have hsp : 0 < s := lt_of_lt_of_le hpos hs + apply (le_div_iff₀ (pow_pos hpos 2)).mpr + calc + _ ≤ (b / s ^ 2) * s ^ 2 := + mul_le_mul_of_nonneg_left (pow_le_pow_left₀ hpos.le hs 2) (div_nonneg hb0 (sq_nonneg s)) + _ = b := div_mul_cancel₀ _ (ne_of_gt (pow_pos hsp 2)) + _ ≤ (blockSensitivityAt f (fun _ => false) : ℝ) := hb + _ ≤ (blockSensitivity f : ℝ) := by + exact_mod_cast blockSensitivityAt_le_blockSensitivity f (fun _ => false) + +theorem quantitative_ratio_of_bounds {I : Type} [Fintype I] + (f : (I → Bool) → Bool) (d M : ℕ) (hM : 0 < M) + (hnc : ∃ x y, f x ≠ f y) + (hs : sensitivity f ≤ 2 * (d + 2) * M ^ (d + 1)) + (hb : M ^ 2 * (2 * M ^ 2 + 1) ^ d ≤ blockSensitivityAt f (fun _ => false)) : + (2 : ℝ) ^ d / (4 * ((d : ℝ) + 2) ^ 2) ≤ + (blockSensitivity f : ℝ) / (sensitivity f : ℝ) ^ 2 := by + have hMr : 0 < (M : ℝ) := by exact_mod_cast hM + apply (seed_ratio_lower d hMr).trans + apply ratio_of_bounds + · exact_mod_cast sensitivity_pos_of_nonconstant f hnc + · exact_mod_cast hs + · exact_mod_cast hb + · positivity + +theorem depth_nine_ratio : + (2 : ℝ) ^ 9 / (4 * ((9 : ℝ) + 2) ^ 2) = 128 / 121 := by norm_num + +theorem depth_nine_ratio_gt_one : (1 : ℝ) < 128 / 121 := by norm_num + +theorem depth_nine_seed_ratio {M : ℝ} (hM : 0 < M) : + (128 : ℝ) / 121 ≤ M ^ 2 * (2 * M ^ 2 + 1) ^ 9 / (22 * M ^ 10) ^ 2 := by + have h := seed_ratio_lower 9 hM + norm_num at h ⊢ + exact h + +theorem depth_nine_seed_gap (M : ℕ) (hM : 0 < M) : + 1 < 22 * M ^ 10 ∧ (22 * M ^ 10) ^ 2 < M ^ 2 * (2 * M ^ 2 + 1) ^ 9 := by + constructor + · have hp := pow_pos hM 10 + omega + · have hp := pow_pos hM 20 + have hmono : M ^ 2 * (2 * M ^ 2) ^ 9 ≤ M ^ 2 * (2 * M ^ 2 + 1) ^ 9 := by + gcongr + omega + calc + _ = 484 * M ^ 20 := by ring + _ < 512 * M ^ 20 := by omega + _ = M ^ 2 * (2 * M ^ 2) ^ 9 := by ring + _ ≤ _ := hmono + +theorem quantitative_ratio_tendsto : + Tendsto (fun d : ℕ => (2 : ℝ) ^ d / (4 * ((d : ℝ) + 2) ^ 2)) atTop atTop := by + have hb := (tendsto_pow_const_div_const_pow_of_one_lt 2 (by norm_num : (1 : ℝ) < 2)).comp + (tendsto_add_atTop_nat 2) + have hz : Tendsto (fun d : ℕ => 4 * ((d : ℝ) + 2) ^ 2 / (2 : ℝ) ^ d) + atTop (𝓝 0) := by + have h := hb.const_mul (16 : ℝ) + convert h using 1 + · funext d + simp only [Function.comp_apply] + push_cast + rw [pow_add] + norm_num + ring + · simp + have hr : Tendsto (fun d : ℕ => 4 * ((d : ℝ) + 2) ^ 2 / (2 : ℝ) ^ d) + atTop (𝓝[>] (0 : ℝ)) := by + apply tendsto_nhdsWithin_iff.mpr + refine ⟨hz, Filter.Eventually.of_forall ?_⟩ + intro d + change 0 < 4 * ((d : ℝ) + 2) ^ 2 / (2 : ℝ) ^ d + positivity + simpa only [Function.comp_def, inv_div] using tendsto_inv_nhdsGT_zero.comp hr + +end Paper320 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sensitivity/Tournament.lean b/lean/OAI/Combinatorics/Sensitivity/Tournament.lean new file mode 100644 index 0000000000000000000000000000000000000000..127b498081e049ae2f92859d693d939f428dc12f --- /dev/null +++ b/lean/OAI/Combinatorics/Sensitivity/Tournament.lean @@ -0,0 +1,68 @@ +import Mathlib.Combinatorics.Digraph.Basic +import Mathlib.Data.Finset.Card +import Mathlib.Data.Finset.Prod +import Mathlib.Data.Finset.Powerset +import Mathlib.Data.Fintype.BigOperators + +namespace OAI + +/-! Finite tournaments and the target-constant labeling condition. -/ + +noncomputable section +open scoped Classical + +namespace Paper320 + +structure Tournament (k : ℕ) extends Digraph (Fin k) where + loopless : ∀ i, ¬ Adj i i + edge_compl : ∀ {i j}, i ≠ j → (Adj i j ↔ ¬ Adj j i) + +structure RegularTournament (M : ℕ) extends Tournament (2 * M^2 + 1) where + outdegree : ∀ i, (Finset.univ.filter (Adj i)).card = M^2 + +structure GoodLabeling {k : ℕ} (T : Tournament k) (r : ℕ) where + label : Fin k → Fin k → Fin r + good : ∀ I : Finset (Fin k), I.card = 16 → ∀ m : Fin k → Fin r, + ∃ i ∈ I, ∃ j ∈ I, T.Adj i j ∧ label i j ≠ m j + +namespace Tournament +variable {k : ℕ} (T : Tournament k) + +theorem ne_of_adj {i j : Fin k} (h : T.Adj i j) : i ≠ j := by + rintro rfl + exact T.loopless i h + +theorem not_adj_reverse {i j : Fin k} (h : T.Adj i j) : ¬ T.Adj j i := + (T.edge_compl (T.ne_of_adj h)).mp h + +theorem adj_or_reverse {i j : Fin k} (h : i ≠ j) : T.Adj i j ∨ T.Adj j i := by + by_cases hh : T.Adj j i + · exact Or.inr hh + · exact Or.inl ((T.edge_compl h).mpr hh) + +theorem internal_sink_unique {I : Finset (Fin k)} {i j : Fin k} + (hi : i ∈ I) (hj : j ∈ I) + (hsi : ∀ v ∈ I, ¬ T.Adj i v) (hsj : ∀ v ∈ I, ¬ T.Adj j v) : i = j := by + by_contra h + rcases T.adj_or_reverse h with hh | hh + · exact hsi j hj hh + · exact hsj i hi hh + +end Tournament + +namespace GoodLabeling +variable {k r : ℕ} {T : Tournament k} (A : GoodLabeling T r) + +theorem good_implies_card_lt_sixteen (I : Finset (Fin k)) (m : Fin k → Fin r) + (h : ∀ i ∈ I, ∀ j ∈ I, T.Adj i j → A.label i j = m j) : I.card < 16 := by + by_contra hn + obtain ⟨J, hJI, hJ⟩ := Finset.exists_subset_card_eq (show 16 ≤ I.card by omega) + obtain ⟨i, hi, j, hj, hij, hne⟩ := A.good J hJ m + exact hne (h i (hJI hi) j (hJI hj) hij) + +end GoodLabeling +end Paper320 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sensitivity/TournamentCounts.lean b/lean/OAI/Combinatorics/Sensitivity/TournamentCounts.lean new file mode 100644 index 0000000000000000000000000000000000000000..3268c320a7d52461834c92cc533e8a49bec5fa58 --- /dev/null +++ b/lean/OAI/Combinatorics/Sensitivity/TournamentCounts.lean @@ -0,0 +1,69 @@ +import OAI.Combinatorics.Sensitivity.Tournament +import Mathlib.Algebra.BigOperators.Group.Finset.Basic +import Mathlib.Algebra.Order.BigOperators.Group.Finset +import Mathlib.Tactic.Linarith + +namespace OAI + +/-! The exact internal edge count and the small gate-candidate bound. -/ + +noncomputable section +open scoped Classical BigOperators + +namespace Paper320.Tournament +variable {k : ℕ} (T : Tournament k) + +def internalEdges (I : Finset (Fin k)) : Finset (Fin k × Fin k) := + (I ×ˢ I).filter fun p => T.Adj p.1 p.2 + +theorem card_internalEdges (I : Finset (Fin k)) : + (T.internalEdges I).card = I.card.choose 2 := by + let U := T.internalEdges I + let V := (I ×ˢ I).filter fun p => T.Adj p.2 p.1 + have hd : Disjoint U V := by + apply Finset.disjoint_left.mpr + intro p hp hq + exact T.not_adj_reverse (Finset.mem_filter.mp hp).2 (Finset.mem_filter.mp hq).2 + have hu : U.disjUnion V hd = I.offDiag := by + ext ⟨i,j⟩ + simp only [Finset.mem_disjUnion, U, V, internalEdges, Finset.mem_filter, + Finset.mem_product, Finset.mem_offDiag] + constructor + · rintro (⟨⟨hi,hj⟩,h⟩ | ⟨⟨hi,hj⟩,h⟩) + · exact ⟨hi,hj,T.ne_of_adj h⟩ + · exact ⟨hi,hj,(T.ne_of_adj h).symm⟩ + · rintro ⟨hi,hj,hne⟩ + exact (T.adj_or_reverse hne).imp (fun h => ⟨⟨hi,hj⟩,h⟩) (fun h => ⟨⟨hi,hj⟩,h⟩) + have hs : U.card = V.card := Finset.card_equiv (Equiv.prodComm (Fin k) (Fin k)) (by + intro p + simp only [U,V,internalEdges,Finset.mem_filter,Finset.mem_product,Equiv.prodComm_apply] + tauto) + have hc := congrArg Finset.card hu + rw [Finset.card_disjUnion, ← hs, Finset.offDiag_card] at hc + rw [Nat.choose_two_right, Nat.mul_sub_one] + change U.card = _ + omega + +theorem sum_outdegree_eq (I : Finset (Fin k)) : + ∑ i ∈ I, (I.filter (T.Adj i)).card = (T.internalEdges I).card := by + simp only [internalEdges, Finset.card_eq_sum_ones, Finset.sum_filter, Finset.sum_product] + +theorem card_le_three_of_outdegree_le_one (I : Finset (Fin k)) + (h : ∀ i ∈ I, (I.filter (T.Adj i)).card ≤ 1) : I.card ≤ 3 := by + have hsum := Finset.sum_le_sum h + have hc : I.card.choose 2 ≤ I.card := by + rw [← T.card_internalEdges, ← T.sum_outdegree_eq] + simpa only [Finset.sum_const_nat, mul_one] using hsum + have hdouble : I.card * (I.card - 1) ≤ 2 * I.card + 1 := by + rw [Nat.choose_two_right] at hc + omega + by_contra hn + have h4 : 4 ≤ I.card := by omega + have ht : I.card - 1 + 1 = I.card := by omega + nlinarith + +end Paper320.Tournament + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sensitivity/TournamentCyclic.lean b/lean/OAI/Combinatorics/Sensitivity/TournamentCyclic.lean new file mode 100644 index 0000000000000000000000000000000000000000..1f323199fa5c2665dae956b0563032c0e31a4430 --- /dev/null +++ b/lean/OAI/Combinatorics/Sensitivity/TournamentCyclic.lean @@ -0,0 +1,53 @@ +import OAI.Combinatorics.Sensitivity.Tournament +import Mathlib.Algebra.Group.Fin.Basic +import Mathlib.Algebra.Group.Units.Equiv +import Mathlib.Order.Interval.Finset.Fin + +namespace OAI + +/-! The literal regular tournament on an odd cyclic set. -/ + +noncomputable section +open scoped Classical + +namespace Paper320 + +def cyclicTournament (a : ℕ) : Tournament (2*a+1) where + Adj i j := 0 < (j-i).val ∧ (j-i).val ≤ a + loopless i := by simp + edge_compl := by + intro i j hij + have hδ : j-i ≠ 0 := sub_ne_zero.mpr hij.symm + have hp : 0 < (j-i).val := Nat.pos_of_ne_zero (Fin.val_ne_zero_iff.mpr hδ) + have hb := (j-i).isLt + have hn : (i-j).val = 2*a+1-(j-i).val := by + rw [← neg_sub j i, Fin.val_neg, ite_eq_right hδ] + change (0 < (j-i).val ∧ (j-i).val ≤ a) ↔ ¬ (0 < (i-j).val ∧ (i-j).val ≤ a) + rw [hn] + omega + +theorem cyclicTournament_outdegree (a : ℕ) (i : Fin (2*a+1)) : + (Finset.univ.filter ((cyclicTournament a).Adj i)).card = a := by + let z : Fin (2*a+1) := 0 + let b : Fin (2*a+1) := ⟨a, by omega⟩ + have he : (Finset.Ioc z b).card = + (Finset.univ.filter ((cyclicTournament a).Adj i)).card := + Finset.card_equiv (Equiv.addLeft i) (by + intro x + simp only [Finset.mem_Ioc, Finset.mem_filter, Finset.mem_univ, true_and] + change (0 < x.val ∧ x.val ≤ a) ↔ + (0 < ((i+x)-i).val ∧ ((i+x)-i).val ≤ a) + rw [add_sub_cancel_left]) + rw [← he, Fin.card_Ioc] + change a - 0 = a + exact Nat.sub_zero a + +def regularCyclicTournament (M : ℕ) : RegularTournament M where + toTournament := cyclicTournament (M^2) + outdegree := cyclicTournament_outdegree (M^2) + +end Paper320 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sensitivity/Tower.lean b/lean/OAI/Combinatorics/Sensitivity/Tower.lean new file mode 100644 index 0000000000000000000000000000000000000000..8ca29ff24ae9491cf36b0448139da55c6cd70e83 --- /dev/null +++ b/lean/OAI/Combinatorics/Sensitivity/Tower.lean @@ -0,0 +1,161 @@ +import OAI.Combinatorics.Sensitivity.Recursive + +namespace OAI + +/-! An indexed tower of the literal recursive construction and its common blocks. -/ + +noncomputable section +open scoped Classical + +namespace Paper320 + +def TowerCoordinates (k r : ℕ) (I : Type) : ℕ → Type + | 0 => I + | n + 1 => (Fin k × Fin r) × TowerCoordinates k r I n + +instance towerCoordinatesFintype (k r : ℕ) (I : Type) [Fintype I] : + (n : ℕ) → Fintype (TowerCoordinates k r I n) + | 0 => inferInstanceAs (Fintype I) + | n + 1 => by + letI := towerCoordinatesFintype k r I n + exact inferInstanceAs (Fintype ((Fin k × Fin r) × TowerCoordinates k r I n)) + +def TowerBlockIndex (k : ℕ) (K : Type) : ℕ → Type + | 0 => K + | n + 1 => Fin k × TowerBlockIndex k K n + +instance towerBlockIndexFintype (k : ℕ) (K : Type) [Fintype K] : + (n : ℕ) → Fintype (TowerBlockIndex k K n) + | 0 => inferInstanceAs (Fintype K) + | n + 1 => by + letI := towerBlockIndexFintype k K n + exact inferInstanceAs (Fintype (Fin k × TowerBlockIndex k K n)) + +def towerFamily {k r : ℕ} {I : Type} (T : Tournament k) + (label : Fin k → Fin k → Fin r) (base : (h : ℕ) → Fin h → (I → Bool) → Bool) : + (n h : ℕ) → Fin h → (TowerCoordinates k r I n → Bool) → Bool + | 0, h => base h + | n + 1, h => recursiveFamily T label (towerFamily T label base n (h + 1)) + +def towerBlocks {k r : ℕ} {I K : Type} (blocks : K → Finset I) : + (n : ℕ) → TowerBlockIndex k K n → Finset (TowerCoordinates k r I n) + | 0, b => blocks b + | n + 1, b => rowLift b.1 (towerBlocks blocks n b.2) + +/-- Extend a prescribed initial family to unused index counts without adding assumptions. -/ +def baseExtension {I : Type} (D : ℕ) (F : Fin D → (I → Bool) → Bool) + (h : ℕ) (q : Fin h) (x : I → Bool) : Bool := + if he : h = D then F (Fin.cast he q) x else false + +@[simp] theorem baseExtension_same {I : Type} (D : ℕ) (F : Fin D → (I → Bool) → Bool) : + baseExtension D F D = F := by + funext q x + simp [baseExtension] + +theorem tower_coordinates_card {k r : ℕ} {I : Type} [Fintype I] (n : ℕ) : + Fintype.card (TowerCoordinates k r I n) = (k * r) ^ n * Fintype.card I := by + induction n with + | zero => + change Fintype.card I = (k * r) ^ 0 * Fintype.card I + simp + | succ n ih => + change Fintype.card ((Fin k × Fin r) × TowerCoordinates k r I n) = _ + simp only [Fintype.card_prod, Fintype.card_fin, ih, pow_succ] + ring + +theorem tower_block_index_card {k : ℕ} {K : Type} [Fintype K] (n : ℕ) : + Fintype.card (TowerBlockIndex k K n) = k ^ n * Fintype.card K := by + induction n with + | zero => + change Fintype.card K = k ^ 0 * Fintype.card K + simp + | succ n ih => + change Fintype.card (Fin k × TowerBlockIndex k K n) = _ + simp only [Fintype.card_prod, Fintype.card_fin, ih, pow_succ] + ring + +theorem towerBlocks_card {k r : ℕ} {I K : Type} (blocks : K → Finset I) + (L : ℕ) (hL : ∀ b, (blocks b).card = L) (n : ℕ) (b : TowerBlockIndex k K n) : + (towerBlocks (r := r) blocks n b).card = r ^ n * L := by + induction n with + | zero => + change (blocks b).card = r ^ 0 * L + simpa only [pow_zero, one_mul] using hL b + | succ n ih => + change (rowLift b.1 (towerBlocks blocks n b.2)).card = _ + rw [rowLift_card, ih] + ring + +theorem towerBlocks_nonempty {k r : ℕ} {I K : Type} (blocks : K → Finset I) + (hr : 0 < r) (hne : ∀ b, (blocks b).Nonempty) (n : ℕ) (b : TowerBlockIndex k K n) : + (towerBlocks (r := r) blocks n b).Nonempty := by + induction n with + | zero => exact hne b + | succ n ih => exact rowLift_nonempty b.1 _ hr (ih b.2) + +theorem towerBlocks_pairwise {k r : ℕ} {I K : Type} (blocks : K → Finset I) + (hd : Pairwise fun a b => Disjoint (blocks a) (blocks b)) (n : ℕ) : + Pairwise fun a b => Disjoint (towerBlocks (k := k) (r := r) blocks n a) (towerBlocks blocks n b) := by + induction n with + | zero => exact hd + | succ n ih => exact rowLift_family_disjoint (towerBlocks blocks n) ih + +theorem towerFamily_nested {k r : ℕ} {I : Type} (T : Tournament k) + (label : Fin k → Fin k → Fin r) (base : (h : ℕ) → Fin h → (I → Bool) → Bool) + (n h : ℕ) (hbase : NestedFamily (base (h + n))) : + NestedFamily (towerFamily T label base n h) := by + induction n generalizing h with + | zero => + change NestedFamily (base h) + simpa only [Nat.add_zero] using hbase + | succ n ih => + apply recursiveFamily_nested + apply ih + have he : (h + 1) + n = h + (n + 1) := by omega + rw [he] + exact hbase + +theorem towerFamily_zero {k r : ℕ} {I : Type} (T : Tournament k) + (label : Fin k → Fin k → Fin r) (base : (h : ℕ) → Fin h → (I → Bool) → Bool) + (hr : 0 < r) (n h : ℕ) (hbase : ∀ q, base (h + n) q (fun _ => false) = false) : + ∀ q, towerFamily T label base n h q (fun _ => false) = false := by + induction n generalizing h with + | zero => + change ∀ q, base h q (fun _ => false) = false + simpa only [Nat.add_zero] using hbase + | succ n ih => + apply recursiveFamily_zero T label _ hr + apply ih + have he : (h + 1) + n = h + (n + 1) := by omega + rw [he] + exact hbase + +theorem towerFamily_blocks {k r : ℕ} {I K : Type} (T : Tournament k) + (label : Fin k → Fin k → Fin r) (base : (h : ℕ) → Fin h → (I → Bool) → Bool) + (blocks : K → Finset I) (hr : 0 < r) (n h : ℕ) + (hzero : ∀ q, base (h + n) q (fun _ => false) = false) + (hblocks : ∀ b q, base (h + n) q (flip (fun _ => false) (blocks b)) = true) : + ∀ b q, towerFamily T label base n h q + (flip (fun _ => false) (towerBlocks blocks n b)) = true := by + induction n generalizing h with + | zero => + change ∀ b q, base h q (flip (fun _ => false) (blocks b)) = true + simpa only [Nat.add_zero] using hblocks + | succ n ih => + intro b q + have he : (h + 1) + n = h + (n + 1) := by omega + have hz : ∀ q, base ((h + 1) + n) q (fun _ => false) = false := by + rw [he] + exact hzero + have hb : ∀ b q, base ((h + 1) + n) q (flip (fun _ => false) (blocks b)) = true := by + rw [he] + exact hblocks + exact recursiveFamily_rowLift T label _ + (towerFamily_zero T label base hr n (h + 1) hz) + (towerBlocks blocks n b.2) (ih (h + 1) hz hb b.2) b.1 q + +end Paper320 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sensitivity/TowerProfiles.lean b/lean/OAI/Combinatorics/Sensitivity/TowerProfiles.lean new file mode 100644 index 0000000000000000000000000000000000000000..368697db3ebb97850c0a215a20a27125bbe27558 --- /dev/null +++ b/lean/OAI/Combinatorics/Sensitivity/TowerProfiles.lean @@ -0,0 +1,80 @@ +import OAI.Combinatorics.Sensitivity.Tower +import OAI.Combinatorics.Sensitivity.RecursiveChildren + +namespace OAI + +/-! The fixed-initial-height profiles and their exact four recurrences. -/ + +noncomputable section +open scoped Classical + +namespace Paper320 + +def towerSide {k r : ℕ} {I : Type} [Fintype I] (T : Tournament k) + (label : Fin k → Fin k → Fin r) (base : (h : ℕ) → Fin h → (I → Bool) → Bool) + (D n : ℕ) (b : Bool) : ℕ := + sideSensitivity (towerFamily T label base n (D - n)) b + +def towerJoint {k r : ℕ} {I : Type} [Fintype I] (T : Tournament k) + (label : Fin k → Fin k → Fin r) (base : (h : ℕ) → Fin h → (I → Bool) → Bool) + (D n : ℕ) (b : Bool) : ℕ := + jointSensitivity (towerFamily T label base n (D - n)) b + +@[simp] theorem towerSide_zero {k r : ℕ} {I : Type} [Fintype I] (T : Tournament k) + (label : Fin k → Fin k → Fin r) (base : (h : ℕ) → Fin h → (I → Bool) → Bool) + (D : ℕ) (b : Bool) : towerSide T label base D 0 b = sideSensitivity (base D) b := by + rfl + +@[simp] theorem towerJoint_zero {k r : ℕ} {I : Type} [Fintype I] (T : Tournament k) + (label : Fin k → Fin k → Fin r) (base : (h : ℕ) → Fin h → (I → Bool) → Bool) + (D : ℕ) (b : Bool) : towerJoint T label base D 0 b = jointSensitivity (base D) b := by + rfl + +theorem tower_four_recurrences {M r : ℕ} {I : Type} [Fintype I] + (T : RegularTournament M) (A : GoodLabeling T.toTournament r) + (base : (h : ℕ) → Fin h → (I → Bool) → Bool) + (D n : ℕ) (hn : n < D) (hr : 0 < r) (hbase : NestedFamily (base D)) : + (towerSide T.toTournament A.label base D (n + 1) true ≤ + M ^ 2 * towerSide T.toTournament A.label base D n false + + r * towerSide T.toTournament A.label base D n true) ∧ + (towerJoint T.toTournament A.label base D (n + 1) true ≤ + M ^ 2 * towerJoint T.toTournament A.label base D n false + + r * towerSide T.toTournament A.label base D n true) ∧ + (towerSide T.toTournament A.label base D (n + 1) false ≤ + 16 * towerSide T.toTournament A.label base D n false + + towerSide T.toTournament A.label base D n true + + 3 * towerJoint T.toTournament A.label base D n true) ∧ + (towerJoint T.toTournament A.label base D (n + 1) false ≤ + 16 * towerSide T.toTournament A.label base D n false + + 3 * towerJoint T.toTournament A.label base D n true) := by + have he : (D - (n + 1) + 1) + n = D := by omega + have hf : NestedFamily (towerFamily T.toTournament A.label base n (D - (n + 1) + 1)) := by + apply towerFamily_nested + rwa [he] + have H := recursive_four_recurrences T A + (towerFamily T.toTournament A.label base n (D - (n + 1) + 1)) hf hr + dsimp only at H + change (sideSensitivity (towerFamily T.toTournament A.label base (n + 1) (D - (n + 1))) true ≤ _) ∧ + (jointSensitivity (towerFamily T.toTournament A.label base (n + 1) (D - (n + 1))) true ≤ _) ∧ + (sideSensitivity (towerFamily T.toTournament A.label base (n + 1) (D - (n + 1))) false ≤ _) ∧ + (jointSensitivity (towerFamily T.toTournament A.label base (n + 1) (D - (n + 1))) false ≤ _) at H + have hcount : D - (n + 1) + 1 = D - n := by omega + rw [hcount] at H + exact H + +theorem towerBlocks_family_card {k r : ℕ} {I K : Type} [Fintype K] + (blocks : K → Finset I) (hr : 0 < r) (hne : ∀ b, (blocks b).Nonempty) + (hd : Pairwise fun a b => Disjoint (blocks a) (blocks b)) (n : ℕ) : + (Finset.univ.image (towerBlocks (k := k) (r := r) blocks n)).card = k ^ n * Fintype.card K := by + have hinj : Function.Injective (towerBlocks (k := k) (r := r) blocks n) := by + intro a b hab + by_contra hneab + obtain ⟨i, hi⟩ := towerBlocks_nonempty blocks hr hne n a + exact Finset.disjoint_left.mp (towerBlocks_pairwise blocks hd n hneab) hi (by simpa [← hab] using hi) + rw [Finset.card_image_of_injective _ hinj, Finset.card_univ, tower_block_index_card] + +end Paper320 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sensitivity/UniformCoordinates.lean b/lean/OAI/Combinatorics/Sensitivity/UniformCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..77ce3f76c4ad57b9bf651ffe5b4a4ef3e9b6aede --- /dev/null +++ b/lean/OAI/Combinatorics/Sensitivity/UniformCoordinates.lean @@ -0,0 +1,31 @@ +import OAI.Combinatorics.Sensitivity.FixedCoordinates +import Mathlib.Probability.Distributions.Uniform + +namespace OAI + +/-! The exact probability of prescribed values under uniform independent labels. -/ + +noncomputable section +open scoped Classical + +namespace Paper320 + +theorem uniform_fixedCoordinates_probability {α β : Type} [Fintype α] [Fintype β] + [DecidableEq α] [Nonempty β] (s : Finset α) (v : α → β) : + ((PMF.uniformOfFintype (α → β)).toOuterMeasure + {f | ∀ i ∈ s, f i = v i}).toReal = 1 / (Fintype.card β : ℝ)^s.card := by + rw [PMF.toOuterMeasure_uniformOfFintype_apply] + simp only [ENNReal.toReal_div, ENNReal.toReal_natCast] + rw [Fintype.card_subtype] + simp only [Set.mem_ofPred_eq] + rw [card_fixedCoordinates, Fintype.card_fun] + simp only [Nat.cast_pow] + have hp : (Fintype.card β : ℝ) ≠ 0 := by exact_mod_cast Fintype.card_ne_zero (α := β) + rw [div_eq_div_iff (pow_ne_zero _ hp) (pow_ne_zero _ hp), one_mul, + ← pow_add, Nat.sub_add_cancel (Finset.card_le_univ s)] + +end Paper320 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Bounds/FromConstruction.lean b/lean/OAI/Combinatorics/SharpRamsey/Bounds/FromConstruction.lean new file mode 100644 index 0000000000000000000000000000000000000000..aa7a08a7265d9215b84b113893db13735fde9bca --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Bounds/FromConstruction.lean @@ -0,0 +1,79 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Bounds.Lower + +namespace OAI + +/-! Two-sided Ramsey bounds and the logarithmic limit from a prime-field construction. -/ + +section +namespace SharpLogRamsey + +theorem mainLimit_of_mainBounds (s : ℕ) (h : MainBounds s) : MainLimit s := by + obtain ⟨C,hC,h⟩ := h + have hlog : Filter.Tendsto (fun t : ℕ => Real.log (t:ℝ)) Filter.atTop Filter.atTop := + Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop + have hloglog : Filter.Tendsto (fun t : ℕ => Real.log (Real.log (t:ℝ))) + Filter.atTop Filter.atTop := Real.tendsto_log_atTop.comp hlog + apply Metric.tendsto_atTop.mpr + intro ε hε + obtain ⟨t₀,ht₀⟩ := h (ε/2) (by positivity) + obtain ⟨t₁,ht₁⟩ := Filter.eventually_atTop.mp + (hloglog.eventually (Filter.eventually_gt_atTop (max 0 (2*|Real.log C|/ε)))) + refine ⟨max (max t₀ t₁) 2, fun t ht => ?_⟩ + have htl : t₀≤t := (le_max_left t₀ t₁).trans ((le_max_left _ _).trans ht) + have htll : t₁≤t := (le_max_right t₀ t₁).trans ((le_max_left _ _).trans ht) + have ht2 : 2≤t := (le_max_right _ _).trans ht + have htp : (0:ℝ) linarith +end SharpLogRamsey + +namespace SharpLogRamsey + +theorem main_of_primeConstruction (s : ℕ) (hs : 6 ≤ s) + (hprime : LowerTransfer.PrimeConstruction (s-1)) : MainBounds s ∧ MainLimit s := by + have hb : MainBounds s := by + obtain ⟨C,hC,t₀,ht₀⟩ := Upper.ramsey_upper (by omega : 3 ≤ s) + refine ⟨C,hC,fun ε hε => ?_⟩ + have hl := LowerTransfer.all_epsilon_lower (s-1) (by omega) hprime ε hε + have he : s-1+1=s := by omega + have he' : s-1-1=s-2 := by omega + rw [he,he'] at hl + obtain ⟨t₁,ht₁⟩ := Filter.eventually_atTop.mp hl + exact ⟨max t₀ t₁,fun t ht => ⟨ht₁ t ((le_max_right _ _).trans ht), + ht₀ t ((le_max_left _ _).trans ht)⟩⟩ + exact ⟨hb,mainLimit_of_mainBounds s hb⟩ +end SharpLogRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Bounds/Lower.lean b/lean/OAI/Combinatorics/SharpRamsey/Bounds/Lower.lean new file mode 100644 index 0000000000000000000000000000000000000000..c784c4a885f43cb9383a6672813c06ecad889b02 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Bounds/Lower.lean @@ -0,0 +1,186 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Bounds.SamplingParameter + +namespace OAI + +/-! Transfer of finite prime-field graph constructions to all sufficiently large orders. -/ + +section +namespace SharpLogRamsey.LowerTransfer +open Filter Real +open scoped Topology +noncomputable section + +def PrimeConstruction (d : ℕ) : Prop := + ∀ η : ℝ, 0 < η → η < 1/10 → ∀ᶠ q : ℕ in atTop, + q.Prime → ∃ G : SimpleGraph (Fin ⌊(q:ℝ)^d * Real.log q⌋₊), + G.CliqueFree (d+1) ∧ G.indepNum < ⌊(q:ℝ) * (Real.log q)^(1+η)⌋₊ + +theorem prime_interval (x : ℝ) (hx : 4 ≤ x) : + ∃ q : ℕ, q.Prime ∧ x/4 ≤ q ∧ (q:ℝ) ≤ x := by + let n := ⌊x/2⌋₊ + have hn : 1 ≤ n := (Nat.one_le_floor_iff _).mpr (by linarith) + obtain ⟨q,hq,hnq,hqn⟩ := Nat.exists_prime_lt_and_le_two_mul n (by omega) + refine ⟨q,hq,?_,?_⟩ + · have hnf := Nat.lt_floor_add_one (x/2) + have hnqr : (n:ℝ)+1 ≤ q := by exact_mod_cast hnq + dsimp [n] at hnqr + linarith + · have hnf := Nat.floor_le (show 0≤x/2 by linarith) + have hqn' : (q:ℝ) ≤ 2*n := by exact_mod_cast hqn + dsimp [n] at hqn' + linarith + +theorem witness_bound (d q t : ℕ) (η : ℝ) (hd : 1≤d) (ht : 1≤t) + (G : SimpleGraph (Fin ⌊(q:ℝ)^d * Real.log q⌋₊)) + (hG : G.CliqueFree (d+1)) + (hI : G.indepNum < ⌊(q:ℝ)*(Real.log q)^(1+η)⌋₊) + (hqt : (q:ℝ)*(Real.log q)^(1+η) ≤ t) : + (q:ℝ)^d * Real.log q < (ramsey (d+1) t : ℝ) := by + have hk : ⌊(q:ℝ)*(Real.log q)^(1+η)⌋₊ ≤ t := Nat.floor_le_of_le hqt + have hf : Gᶜ.CliqueFree t := by + intro A hA + have hi := G.isNClique_compl.mp hA + have hle := hi.isIndepSet.card_le_indepNum + have hc := hi.card_eq + omega + have hr := Foundation.order_lt_ramsey G (by omega) ht hG hf + simp only [Fintype.card_fin] at hr + have hr' : (⌊(q:ℝ)^d * Real.log q⌋₊ :ℝ)+1 ≤ ramsey (d+1) t := by + exact_mod_cast hr + exact (Nat.lt_floor_add_one _).trans_le hr' + +theorem eventual_scale (η : ℝ) : ∀ᶠ t : ℝ in atTop, + 1 < t ∧ 1 ≤ Real.log t ∧ + 4*t^((1:ℝ)/2) ≤ t/(Real.log t)^(1+η) := by + have h := (isLittleO_log_rpow_rpow_atTop (1+η) (show 0<(1:ℝ)/2 by norm_num)).bound + (show 0<(1:ℝ)/4 by norm_num) + filter_upwards [h,eventually_gt_atTop (1:ℝ),Real.tendsto_log_atTop.eventually_ge_atTop 1] + with t ht ht1 hl + refine ⟨ht1,hl,?_⟩ + have ht0 : 0 by exact_mod_cast hdeg x) + _ = n*h := by simp [n] + have htri : ((G.cliqueFinset 3).card : ℝ) ≤ n*h*m := by + dsimp [n] + exact_mod_cast triangle_count_le G hdeg hcommon + have hloss : p^2 * (∑ x : V, (G.degree x : ℝ)) / (12*p*h) ≤ n*p/12 := by + apply (div_le_iff₀ hD).mpr + calc + _ ≤ p^2*(n*h) := mul_le_mul_of_nonneg_left hsum (sq_nonneg _) + _ = n*p/12*(12*p*h) := by ring + have htri' : p^3 * ((G.cliqueFinset 3).card : ℝ) ≤ n*p/8 := by + calc + _ ≤ p^3*(n*h*m) := mul_le_mul_of_nonneg_left htri (by positivity) + _ = n*p*(p^2*h*m) := by ring + _ ≤ n*p*(1/8) := mul_le_mul_of_nonneg_left hmoment (by positivity) + _ = n*p/8 := by ring + have hUsize : 3/4*n*p ≤ (U.card : ℝ) := by dsimp [n] at *; linarith + have hlog : 0 ≤ Real.log (p*h) := Real.log_nonneg hph + by_cases hn0 : n = 0 + · change n * _ ≤ _ + rw [hn0, zero_mul] + positivity + have hnpos : 0 < n := lt_of_le_of_ne hn (Ne.symm hn0) + have hUpos : 0 < U.card := by + have hu : (0:ℝ) < U.card := lt_of_lt_of_le (by positivity) hUsize + exact_mod_cast hu + obtain ⟨x,hx⟩ := card_pos.mp hUpos + let : Nonempty (U : Set V) := ⟨⟨x,hx⟩⟩ + have ha := TriangleFree.indepNum_lower_bound (G.induce (U : Set V)) hUt + (by nlinarith : (1:ℝ) ≤ 12*p*h) hUd + have hat : ((G.induce (U : Set V)).indepNum : ℝ) < t := by + exact_mod_cast indepNum_lt_of_cliqueFree_compl (G.induce (U : Set V)) + (compl_cliqueFree_induce G hG _) + have ha' : (U.card : ℝ) * Real.log (12*p*h+1) < t*(8*(12*p*h+1)) := by + have H := ha.trans_lt hat + rw [div_lt_iff₀ (by positivity)] at H + have hc : Fintype.card (U : Set V) = U.card := Fintype.card_coe U + simpa only [hc] using H + have hl : Real.log (p*h) ≤ Real.log (12*p*h+1) := + Real.log_le_log (by positivity) (by nlinarith) + have hu : (3/4*n*p) * Real.log (p*h) ≤ + (U.card : ℝ) * Real.log (12*p*h+1) := + mul_le_mul hUsize hl hlog (Nat.cast_nonneg _) + have hd : t*(8*(12*p*h+1)) ≤ 104*t*p*h := by + have ht0 : (0:ℝ) ≤ t := Nat.cast_nonneg _ + nlinarith [mul_le_mul_of_nonneg_left hph ht0] + have H := (hu.trans_lt ha').trans_le hd + have ht0 : (0:ℝ) ≤ t := Nat.cast_nonneg _ + change n*Real.log (p*h) ≤ _ + have : p*(n*Real.log (p*h)) ≤ p*(256*t*h) := by nlinarith + exact (mul_le_mul_iff_right₀ hp).mp this + +theorem graph_recurrence (j : ℕ) {t : ℕ} (ht : 65536 ≤ t) + (hs : G.CliqueFree (j+4)) (hi : Gᶜ.CliqueFree t) : + (Fintype.card V : ℝ) ≤ + t*((t:ℝ)^(j+1)*Real.sqrt t+1) + + 2048*t*(ramsey (j+3) t)/Real.log t := by + let h := G.maxDegree + let m := ramsey (j+2) t + have ht1 : 1 ≤ t := by omega + have ht0 : (0:ℝ) < t := by exact_mod_cast (show 0 < t by omega) + have hlog : 0 < Real.log t := Real.log_pos (by exact_mod_cast (show 1 < t by omega)) + have hm1 : 1 ≤ m := ht1.trans (le_ramsey (by omega) ht1) + have hmb : (m : ℝ) ≤ (t:ℝ)^(j+1) := by + have H := ramsey_le_pow (s := j+2) (by omega) ht1 + norm_num at H + exact_mod_cast H + have hcommon : ∀ x y, G.Adj x y → Fintype.card (G.commonNeighbors x y) ≤ m := by + intro x y hxy + exact (order_lt_ramsey (G.induce (G.commonNeighbors x y)) (by omega) ht1 + (cliqueFree_common G hs hxy) (compl_cliqueFree_induce G hi _)).le + have hdeg : ∀ x, G.degree x ≤ h := G.degree_le_maxDegree + have hhr : h ≤ ramsey (j+3) t := by + apply G.maxDegree_le_of_forall_degree_le + intro x + have H := order_lt_ramsey (G.induce (G.neighborSet x)) (by omega) ht1 + (cliqueFree_neighbor G hs x) (compl_cliqueFree_induce G hi _) + rw [G.card_neighborSet_eq_degree] at H + exact H.le + have hright : 0 ≤ 2048*(t:ℝ)*(ramsey (j+3) t)/Real.log t := by positivity + by_cases hsmall : (h:ℝ) ≤ m*Real.sqrt t + · have hn := card_le_mul_indepNum G (B := h+1) (by intro x; exact Nat.add_le_add_right (hdeg x) 1) + have hia := indepNum_lt_of_cliqueFree_compl G hi + have Hnat : Fintype.card V ≤ (h+1)*t := hn.trans (Nat.mul_le_mul_left _ hia.le) + have H : (Fintype.card V : ℝ) ≤ ((h:ℝ)+1)*t := by exact_mod_cast Hnat + have hm' := mul_le_mul_of_nonneg_right hmb (Real.sqrt_nonneg (t:ℝ)) + have H' := mul_le_mul_of_nonneg_right (add_le_add_right (hsmall.trans hm') 1) ht0.le + nlinarith + · have hh : (1:ℝ) ≤ h := by + have hsqrt : 1 ≤ Real.sqrt (t:ℝ) := by + rw [Real.le_sqrt (by norm_num) ht0.le] + exact_mod_cast ht1 + have hm1' : (1:ℝ) ≤ m := by exact_mod_cast hm1 + nlinarith + obtain ⟨p,hp,hp1,hph,hpm,hl⟩ := sampling_parameter hh (by exact_mod_cast hm1) + (by exact_mod_cast ht) (le_of_not_ge hsmall) + have hab := alteration_bound G ht1 hi hdeg hcommon hp hp1 hph hpm + have hn0 : (0:ℝ) ≤ Fintype.card V := Nat.cast_nonneg _ + have H : (Fintype.card V : ℝ)*Real.log t ≤ 2048*t*h := by + nlinarith [mul_le_mul_of_nonneg_left hl hn0] + have H' : (Fintype.card V : ℝ) ≤ 2048*t*h/Real.log t := + (le_div_iff₀ hlog).mpr H + have H'' : 2048*(t:ℝ)*h/Real.log t ≤ 2048*t*(ramsey (j+3) t)/Real.log t := by + apply div_le_div_of_nonneg_right _ hlog.le + exact mul_le_mul_of_nonneg_left (by exact_mod_cast hhr) (by positivity) + have hleft : 0 ≤ (t:ℝ)*((t:ℝ)^(j+1)*Real.sqrt t+1) := by positivity + linarith + +theorem ramsey_recurrence (j : ℕ) {t : ℕ} (ht : 65536 ≤ t) : + (ramsey (j+4) t : ℝ) ≤ + t*((t:ℝ)^(j+1)*Real.sqrt t+1) + + 2048*t*(ramsey (j+3) t)/Real.log t + 1 := by + classical + obtain ⟨G,hG,hGi⟩ := exists_avoiding_pred (s := j+4) (by omega) (by omega : 2 ≤ t) + have H := graph_recurrence G j ht hG hGi + simp only [Fintype.card_fin] at H + have hr : 1 ≤ ramsey (j+4) t := + (by omega : 1 ≤ t).trans (le_ramsey (by omega) (by omega)) + rw [Nat.cast_sub hr, Nat.cast_one] at H + linarith + +theorem ramsey_three {t : ℕ} (ht : 2 ≤ t) : + (ramsey 3 t : ℝ)*Real.log t ≤ 17*(t:ℝ)^2 := by + classical + obtain ⟨G,hG,hGi⟩ := exists_avoiding_pred (s := 3) (by omega) ht + have hr : 2 ≤ ramsey 3 t := ht.trans (le_ramsey (by omega) (by omega)) + have hnon : 0 < ramsey 3 t - 1 := by omega + let : Nonempty (Fin (ramsey 3 t - 1)) := Fin.pos_iff_nonempty.mp hnon + have hd : ∀ x, (G.degree x : ℝ) ≤ t := by + intro x + have H := order_lt_ramsey (G.induce (G.neighborSet x)) (by omega : 2 ≤ 2) + (by omega : 1 ≤ t) (cliqueFree_neighbor G hG x) (compl_cliqueFree_induce G hGi _) + rw [G.card_neighborSet_eq_degree, ramsey_two (by omega)] at H + exact_mod_cast H.le + have ht0 : (0:ℝ) < t := by exact_mod_cast (show 0 < t by omega) + have ht1 : (1:ℝ) ≤ t := by exact_mod_cast (show 1 ≤ t by omega) + have hl : 0 ≤ Real.log (t:ℝ) := Real.log_nonneg ht1 + have H := TriangleFree.indepNum_lower_bound G hG ht1 hd + have hi : (G.indepNum : ℝ) < t := by + exact_mod_cast indepNum_lt_of_cliqueFree_compl G hGi + have H' := H.trans_lt hi + rw [div_lt_iff₀ (by positivity)] at H' + have hc : (Fintype.card (Fin (ramsey 3 t - 1)) : ℝ) = (ramsey 3 t : ℝ)-1 := by + rw [Fintype.card_fin, Nat.cast_sub (by omega), Nat.cast_one] + rw [hc] at H' + have hl' : Real.log (t:ℝ) ≤ Real.log ((t:ℝ)+1) := Real.log_le_log ht0 (by linarith) + have hn : 0 ≤ (ramsey 3 t : ℝ)-1 := by + have H : (2:ℝ) ≤ ramsey 3 t := by exact_mod_cast hr + linarith + have hh := mul_le_mul_of_nonneg_left hl' hn + have hlt := Real.log_le_self ht0.le + nlinarith [sq_nonneg ((t:ℝ)-1)] + +open Filter in + theorem eventually_log_pow_le_sqrt (j : ℕ) : + ∀ᶠ t : ℕ in atTop, (Real.log (t:ℝ))^j ≤ Real.sqrt t := by + have H := (isLittleO_log_rpow_rpow_atTop (j:ℝ) (by norm_num : (0:ℝ)<1/2)).bound + (by norm_num : (0:ℝ)<1) + have Hn := tendsto_natCast_atTop_atTop.eventually H + filter_upwards [Hn, eventually_ge_atTop (1:ℕ)] with t ht ht1 + have hlog := Real.log_nonneg (show (1:ℝ) ≤ t by exact_mod_cast ht1) + simpa only [Real.rpow_natCast, Real.norm_eq_abs, abs_of_nonneg (pow_nonneg hlog _), + ← Real.sqrt_eq_rpow, abs_of_nonneg (Real.sqrt_nonneg _), one_mul] using ht + +open Filter in + + theorem ramsey_upper_scaled (j : ℕ) : + ∃ C : ℝ, 0 < C ∧ ∀ᶠ t : ℕ in atTop, + (ramsey (j+3) t : ℝ)*(Real.log (t:ℝ))^(j+1) ≤ C*(t:ℝ)^(j+2) := by + induction j with + | zero => + refine ⟨17, by norm_num, ?_⟩ + filter_upwards [eventually_ge_atTop (2:ℕ)] with t ht + simpa using ramsey_three ht + | succ j ih => + obtain ⟨C,hC,hCb⟩ := ih + refine ⟨3+2048*C, by positivity, ?_⟩ + filter_upwards [hCb, eventually_log_pow_le_sqrt (j+2), + eventually_ge_atTop (65536:ℕ)] with t hCt hL ht + have ht1 : (1:ℝ) ≤ t := by exact_mod_cast (show 1 ≤ t by omega) + have ht0 : (0:ℝ) < t := by exact_mod_cast (show 0 < t by omega) + have hl : 0 < Real.log (t:ℝ) := Real.log_pos (by exact_mod_cast (show 1 < t by omega)) + have hs := Real.sqrt_nonneg (t:ℝ) + have hs2 := Real.sq_sqrt ht0.le + have hst : Real.sqrt (t:ℝ) ≤ t := by + rw [Real.sqrt_le_iff] + exact ⟨ht0.le, by nlinarith⟩ + have hpow : (t:ℝ)^2 ≤ (t:ℝ)^(j+3) := pow_le_pow_right₀ ht1 (by omega) + have hsmall : (t*((t:ℝ)^(j+1)*Real.sqrt t+1)+1)*(Real.log (t:ℝ))^(j+2) ≤ + 3*(t:ℝ)^(j+3) := by + calc + _ ≤ (t*((t:ℝ)^(j+1)*Real.sqrt t+1)+1)*Real.sqrt t := + mul_le_mul_of_nonneg_left hL (by positivity) + _ = (t:ℝ)^(j+1)*t*(Real.sqrt t)^2+(t+1)*Real.sqrt t := by ring + _ = (t:ℝ)^(j+3)+(t+1)*Real.sqrt t := by + rw [hs2] + simp only [pow_succ] + _ ≤ (t:ℝ)^(j+3)+2*(t:ℝ)^2 := by + have H := mul_le_mul_of_nonneg_left hst (by positivity : (0:ℝ) ≤ t+1) + nlinarith + _ ≤ 3*(t:ℝ)^(j+3) := by linarith + have hmain : (2048*t*(ramsey (j+3) t)/Real.log t)*(Real.log (t:ℝ))^(j+2) ≤ + (2048*C)*(t:ℝ)^(j+3) := by + calc + _ = 2048*t*((ramsey (j+3) t : ℝ)*(Real.log (t:ℝ))^(j+1)) := by + rw [show j+2 = (j+1)+1 from by omega, pow_succ] + field_simp + _ ≤ 2048*t*(C*(t:ℝ)^(j+2)) := + mul_le_mul_of_nonneg_left hCt (by positivity) + _ = (2048*C)*(t:ℝ)^(j+3) := by + rw [show j+3 = (j+2)+1 from by omega, pow_succ]; ring + have H := mul_le_mul_of_nonneg_right (ramsey_recurrence j ht) + (pow_nonneg hl.le (j+2)) + linear_combination H + hsmall + hmain + +open Filter in + theorem ramsey_upper {s : ℕ} (hs : 3 ≤ s) : + ∃ C : ℝ, 0 < C ∧ ∃ t₀ : ℕ, ∀ t : ℕ, t₀ ≤ t → + (ramsey s t : ℝ) ≤ C*(t:ℝ)^(s-1)/(Real.log (t:ℝ))^(s-2) := by + obtain ⟨j,rfl⟩ := Nat.exists_eq_add_of_le hs + obtain ⟨C,hC,hCb⟩ := ramsey_upper_scaled j + refine ⟨C,hC,?_⟩ + have H : ∀ᶠ t : ℕ in atTop, + (ramsey (3+j) t : ℝ) ≤ C*(t:ℝ)^(3+j-1)/(Real.log (t:ℝ))^(3+j-2) := by + filter_upwards [hCb, eventually_ge_atTop (2:ℕ)] with t ht ht2 + have hl : 0 < Real.log (t:ℝ) := Real.log_pos (by exact_mod_cast (show 1 < t by omega)) + apply (le_div_iff₀ (pow_pos hl _)).mpr + simpa [show 3+j = j+3 from by omega] using ht + exact eventually_atTop.mp H + +end SharpLogRamsey.Upper + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Bounds/SumFiberCenter.lean b/lean/OAI/Combinatorics/SharpRamsey/Bounds/SumFiberCenter.lean new file mode 100644 index 0000000000000000000000000000000000000000..e2e056b8e075986e00578d60d394fea3687ef77b --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Bounds/SumFiberCenter.lean @@ -0,0 +1,461 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Construction.FiniteStreamTail +import OAI.Combinatorics.SharpRamsey.Bounds.Upper + +namespace OAI + +/-! The off-diagonal Ramsey upper bound. -/ + +section +open scoped BigOperators Classical +open Finset +open scoped BigOperators Classical +open Finset +namespace SharpLogRamsey.TriangleFree +variable {V : Type*} [Fintype V] [DecidableEq V] +variable (G : SimpleGraph V) +theorem sum_fiber_center (htri : G.CliqueFree 3) {x : V} {J : Finset V} + (hJ : Admissible G x J) : ∑ S ∈ fiber G x J, (if x ∈ S then (1:ℝ) else 0) = 1 := by + rw [sum_fiber G htri hJ] + simp only [mem_insert_self, ite_true] + have hx : ∀ K ∈ (available G x J).powerset, x ∉ J ∪ K := by + intro K hK h + rcases mem_union.mp h with hx | hx + · exact admissible_not_center G hJ hx + · exact center_not_available G x J (mem_powerset.mp hK hx) + rw [sum_eq_zero (fun K hK => ite_eq_right (hx K hK)), add_zero] + +theorem twice_sum_fiber_neighbors (htri : G.CliqueFree 3) {x : V} {J : Finset V} + (hJ : Admissible G x J) : + 2 * (∑ S ∈ fiber G x J, ((S ∩ G.neighborFinset x).card : ℝ)) = + (available G x J).card * (2:ℝ)^(available G x J).card := by + rw [sum_fiber G htri hJ, center_neighbor_inter G hJ, card_empty, Nat.cast_zero, + zero_add] + have he : ∑ K ∈ (available G x J).powerset, + (((J ∪ K) ∩ G.neighborFinset x).card : ℝ) = + ∑ K ∈ (available G x J).powerset, (K.card : ℝ) := by + apply sum_congr rfl + intro K hK + rw [extend_neighbor_inter G hJ (mem_powerset.mp hK)] + rw [he] + exact twice_sum_powerset_card (available G x J) + +noncomputable def Z (x : V) (S : Finset V) : ℕ := + (available G x (outside G x S)).card + +theorem fiber_empty_of_not_admissible {x : V} {J : Finset V} + (hJ : ¬Admissible G x J) : fiber G x J = ∅ := by + apply eq_empty_iff_forall_notMem.mpr + intro S hS + obtain ⟨hS, hout⟩ := mem_filter.mp hS + exact hJ (hout ▸ admissible_outside G x hS) + +theorem sum_fiber_Z (x : V) (J : Finset V) (f : ℕ → ℝ) : + ∑ S ∈ fiber G x J, f (Z G x S) = (fiber G x J).card * f (available G x J).card := by + calc + _ = ∑ _S ∈ fiber G x J, f (available G x J).card := by + apply sum_congr rfl + intro S hS + simp only [Z, (mem_filter.mp hS).2] + _ = _ := by simp + +theorem exp_neg_log_two_mul (z : ℕ) : + Real.exp (-(Real.log 2) * z) = ((2:ℝ)^z)⁻¹ := by + rw [show -(Real.log 2) * z = -((z:ℝ) * Real.log 2) by ring, + Real.exp_neg, Real.exp_nat_mul, Real.exp_log (by norm_num)] + +theorem half_sum_exp_le_center (htri : G.CliqueFree 3) (x : V) : + (∑ S ∈ independentSets G, Real.exp (-Real.log 2 * Z G x S)) / 2 ≤ + ∑ S ∈ independentSets G, (if x ∈ S then (1:ℝ) else 0) := by + rw [← Finset.sum_fiberwise (independentSets G) (outside G x) + (fun S => Real.exp (-Real.log 2 * Z G x S)), + ← Finset.sum_fiberwise (independentSets G) (outside G x) + (fun S => if x ∈ S then (1:ℝ) else 0), sum_div] + apply sum_le_sum + intro J _ + change (∑ S ∈ fiber G x J, _) / 2 ≤ ∑ S ∈ fiber G x J, _ + by_cases hJ : Admissible G x J + · rw [sum_fiber_Z G x J (fun z => Real.exp (-Real.log 2 * z)), + card_fiber G htri hJ, sum_fiber_center G htri hJ, exp_neg_log_two_mul] + push_cast + have hp : (1:ℝ) ≤ 2^(available G x J).card := one_le_pow₀ (by norm_num) + have hpp : (0:ℝ) < 2^(available G x J).card := by positivity + field_simp + nlinarith + · rw [fiber_empty_of_not_admissible G hJ] + simp + +theorem sum_Z_le_four_neighbors (htri : G.CliqueFree 3) (x : V) : + (∑ S ∈ independentSets G, (Z G x S : ℝ)) ≤ + 4 * ∑ S ∈ independentSets G, ((S ∩ G.neighborFinset x).card : ℝ) := by + rw [← Finset.sum_fiberwise (independentSets G) (outside G x) + (fun S => (Z G x S : ℝ)), + ← Finset.sum_fiberwise (independentSets G) (outside G x) + (fun S => ((S ∩ G.neighborFinset x).card : ℝ)), mul_sum] + apply sum_le_sum + intro J _ + change (∑ S ∈ fiber G x J, _) ≤ 4 * ∑ S ∈ fiber G x J, _ + by_cases hJ : Admissible G x J + · rw [sum_fiber_Z G x J (fun z => (z:ℝ)), card_fiber G htri hJ] + have hn := twice_sum_fiber_neighbors G htri hJ + have hp : (1:ℝ) ≤ 2^(available G x J).card := one_le_pow₀ (by norm_num) + have hz : (0:ℝ) ≤ (available G x J).card := by positivity + push_cast + nlinarith + · rw [fiber_empty_of_not_admissible G hJ] + simp + +theorem sum_center (S : Finset V) : + (∑ x : V, if x ∈ S then (1:ℝ) else 0) = S.card := by + simp + +theorem sum_neighbors (S : Finset V) : + (∑ x : V, ((S ∩ G.neighborFinset x).card : ℝ)) = + ∑ v ∈ S, (G.degree v : ℝ) := by + calc + _ = ∑ x : V, ∑ v ∈ S, (if G.Adj x v then (1:ℝ) else 0) := by + apply sum_congr rfl + intro x _ + rw [← sum_filter] + simp only [sum_const, nsmul_eq_mul, mul_one] + congr 2 + ext v + simp [] + _ = ∑ v ∈ S, ∑ x : V, (if G.Adj x v then (1:ℝ) else 0) := sum_comm + _ = _ := by + apply sum_congr rfl + intro v _ + simp_rw [G.adj_comm] + rw [← sum_filter] + have he : univ.filter (G.Adj v) = G.neighborFinset v := by ext x; simp + rw [he] + simp + +theorem exp_mean_le {α : Type*} (A : Finset α) (hA : A.Nonempty) (f : α → ℝ) : + Real.exp ((∑ i ∈ A, f i) / A.card) ≤ (∑ i ∈ A, Real.exp (f i)) / A.card := by + have hc : (0:ℝ) < A.card := by exact_mod_cast hA.card_pos + have hsum : ∑ _i ∈ A, ((A.card:ℝ)⁻¹) = 1 := by + simp [hc.ne'] + have hj := convexOn_exp.map_sum_le (t := A) (w := fun _ => (A.card:ℝ)⁻¹) + (p := f) (fun _ _ => inv_nonneg.mpr hc.le) hsum (fun _ _ => Set.mem_univ _) + simp only [smul_eq_mul, ← mul_sum] at hj + simpa only [div_eq_mul_inv, mul_comm] using hj + +theorem occupation_lower_bound {D μ : ℝ} (hD : 1 ≤ D) (hμ : 0 ≤ μ) + (hkey : Real.exp (-4 * D * μ * Real.log 2) ≤ 2 * μ) : + Real.log (D+1) / (8 * (D+1)) ≤ μ := by + by_contra! hbad + have hu : 0 < D + 1 := by linarith + have hlog : 0 < Real.log (D+1) := Real.log_pos (by linarith) + have hl2 : 0 < Real.log 2 := Real.log_pos (by norm_num) + have hl2' : Real.log 2 < 1 := by + convert Real.log_lt_sub_one_of_pos (x := (2:ℝ)) (by norm_num) (by norm_num) using 1 ; norm_num + have hb : 8 * (D+1) * μ < Real.log (D+1) := by + have := (lt_div_iff₀ (show 0 < 8*(D+1) by positivity)).mp hbad + nlinarith + have hDμ : 0 ≤ D * μ := mul_nonneg (by linarith) hμ + have he : -Real.log (D+1)/2 < -4 * D * μ * Real.log 2 := by + have hh := mul_le_mul_of_nonneg_left hl2'.le hDμ + nlinarith + have hlow : Real.exp (-Real.log (D+1)/2) < 2 * μ := + (Real.exp_lt_exp.mpr he).trans_le hkey + have hid : (D+1) * Real.exp (-Real.log (D+1)/2) = + Real.exp (Real.log (D+1)/2) := by + conv_lhs => lhs; rw [← Real.exp_log hu] + rw [← Real.exp_add] + congr 1 + ring + have hupper := Real.add_one_le_exp (Real.log (D+1)/2) + have hmul := mul_lt_mul_of_pos_left hlow (show 0 < 4*(D+1) by positivity) + nlinarith + +theorem exists_occupation (htri : G.CliqueFree 3) [Nonempty V] + {D : ℝ} (hD : ∀ x, (G.degree x : ℝ) ≤ D) : + ∃ μ : ℝ, 0 ≤ μ ∧ (Fintype.card V : ℝ) * μ ≤ G.indepNum ∧ + Real.exp (-4 * D * μ * Real.log 2) ≤ 2 * μ := by + let A := independentSets G + let Ω := (univ : Finset V) ×ˢ A + let M : ℝ := ∑ S ∈ A, (S.card : ℝ) + let m : ℝ := (Fintype.card V : ℝ) * A.card + have hn : (0:ℝ) < Fintype.card V := by exact_mod_cast Fintype.card_pos + have ha : (0:ℝ) < A.card := by exact_mod_cast (independentSets_nonempty G).card_pos + have hm : 0 < m := mul_pos hn ha + have hmcard : (Ω.card:ℝ) = m := by simp [Ω, m] + have hM : 0 ≤ M := sum_nonneg (fun _ _ => Nat.cast_nonneg _) + have he : (∑ a ∈ Ω, Real.exp (-Real.log 2 * Z G a.1 a.2)) ≤ 2*M := by + have hh := sum_le_sum (s := (univ : Finset V)) + (fun x _ => half_sum_exp_le_center G htri x) + rw [← sum_div] at hh + have hcenter : (∑ x : V, ∑ S ∈ independentSets G, + (if x ∈ S then (1:ℝ) else 0)) = M := by + rw [sum_comm] + simp only [sum_center] + rfl + rw [hcenter] at hh + unfold Ω + rw [sum_product] + dsimp only + change (∑ x : V, ∑ S ∈ independentSets G, _) ≤ 2*M + linarith + have hz : (∑ a ∈ Ω, (Z G a.1 a.2 : ℝ)) ≤ 4*D*M := by + have hh := sum_le_sum (s := (univ : Finset V)) + (fun x _ => sum_Z_le_four_neighbors G htri x) + rw [← mul_sum] at hh + have hneigh : (∑ x : V, ∑ S ∈ independentSets G, + ((S ∩ G.neighborFinset x).card:ℝ)) = + ∑ S ∈ independentSets G, ∑ v ∈ S, (G.degree v:ℝ) := by + rw [sum_comm] + simp_rw [sum_neighbors] + rw [hneigh] at hh + have hd : (∑ S ∈ independentSets G, ∑ v ∈ S, (G.degree v : ℝ)) ≤ D*M := by + calc + _ ≤ ∑ S ∈ independentSets G, ∑ _v ∈ S, D := by + apply sum_le_sum + intro S _ + exact sum_le_sum (fun v _ => hD v) + _ = D*M := by simp [M, A, mul_sum, mul_comm] + unfold Ω + rw [sum_product] + dsimp only + change (∑ x : V, ∑ S ∈ independentSets G, _) ≤ 4*D*M + linarith + have hind : M ≤ (A.card:ℝ) * G.indepNum := by + calc + M ≤ ∑ _S ∈ A, (G.indepNum : ℝ) := by + apply sum_le_sum + intro S hS + exact_mod_cast (mem_independentSets G S |>.mp hS).card_le_indepNum + _ = _ := by simp + refine ⟨M/m, div_nonneg hM hm.le, ?_, ?_⟩ + · rw [← mul_div_assoc] + apply (div_le_iff₀ hm).mpr + dsimp only [m] + nlinarith [mul_le_mul_of_nonneg_left hind hn.le] + · have hΩ : Ω.Nonempty := nonempty_product.mpr ⟨univ_nonempty, independentSets_nonempty G⟩ + have hj := exp_mean_le Ω hΩ (fun a => -Real.log 2 * Z G a.1 a.2) + rw [hmcard, ← mul_sum] at hj + have hl : 0 ≤ Real.log 2 := (Real.log_pos (by norm_num : (1:ℝ)<2)).le + have hexp : Real.exp (-4*D*(M/m)*Real.log 2) ≤ + Real.exp (-Real.log 2 * (∑ a ∈ Ω, (Z G a.1 a.2:ℝ)) / m) := by + apply Real.exp_le_exp.mpr + rw [show -4*D*(M/m)*Real.log 2 = (-4*D*M*Real.log 2)/m by ring] + apply (div_le_div_iff_of_pos_right hm).mpr + have hh := mul_le_mul_of_nonpos_left hz (neg_nonpos.mpr hl) + convert hh using 1 ; ring + have hfinal := hexp.trans hj + have hdiv := div_le_div_of_nonneg_right he hm.le + calc + _ ≤ (∑ a ∈ Ω, Real.exp (-Real.log 2 * Z G a.1 a.2))/m := hfinal + _ ≤ 2*M/m := hdiv + _ = 2*(M/m) := by ring + +theorem indepNum_lower_bound (htri : G.CliqueFree 3) [Nonempty V] + {D : ℝ} (hD : 1 ≤ D) (hdeg : ∀ x, (G.degree x : ℝ) ≤ D) : + (Fintype.card V : ℝ) * Real.log (D+1) / (8*(D+1)) ≤ G.indepNum := by + obtain ⟨μ, hμ, hind, hkey⟩ := exists_occupation G htri hdeg + have hb := occupation_lower_bound hD hμ hkey + have hh := mul_le_mul_of_nonneg_left hb + (show (0:ℝ) ≤ Fintype.card V by positivity) + rw [← mul_div_assoc] at hh + exact hh.trans hind + +end SharpLogRamsey.TriangleFree + +open scoped BigOperators Classical +open Finset +namespace SharpLogRamsey.Sampling +variable {V : Type*} [Fintype V] [DecidableEq V] + +variable (G : SimpleGraph V) + +noncomputable def internalDegree (S : Finset V) (x : V) : ℕ := + (S.filter (G.Adj x)).card + +noncomputable def degreeMass (S : Finset V) : ℕ := ∑ x ∈ S, internalDegree G S x + +theorem degreeMass_pair_sum (S : Finset V) : + (degreeMass G S : ℝ) = ∑ x : V, ∑ y : V, + if G.Adj x y then (if ({x,y} : Finset V) ⊆ S then 1 else 0) else 0 := by + have hi (x : V) : (∑ y : V, + if G.Adj x y then (if ({x,y} : Finset V) ⊆ S then (1:ℝ) else 0) else 0) = + if x ∈ S then (internalDegree G S x : ℝ) else 0 := by + by_cases hx : x ∈ S + · rw [ite_eq_left hx] + have he : S = univ.filter (· ∈ S) := by simp + change _ = ((S.filter (G.Adj x)).card : ℝ) + conv_rhs => rw [he] + rw [filter_filter, ← sum_boole] + apply sum_congr rfl + intro y _ + simp only [insert_subset_iff, singleton_subset_iff, hx, true_and] + by_cases h : G.Adj x y <;> by_cases hy : y ∈ S <;> simp [h, hy] + · simp [insert_subset_iff, singleton_subset_iff, hx] + simp_rw [hi] + rw [← sum_filter] + simp [degreeMass, Nat.cast_sum] + +theorem degreeMass_moment (p : ℝ) : + (∑ f : V → Bool, weight p f * degreeMass G (selected f)) = + p^2 * ∑ x : V, (G.degree x : ℝ) := by + simp_rw [degreeMass_pair_sum, mul_sum] + rw [sum_comm] + calc + _ = ∑ x : V, ∑ y : V, if G.Adj x y then p^2 else 0 := by + apply sum_congr rfl + intro x _ + rw [sum_comm] + apply sum_congr rfl + intro y _ + by_cases h : G.Adj x y + · simp only [ite_eq_left h] + rw [containment_moment] + simp [h.ne] + · simp [h] + _ = p^2 * ∑ x : V, (G.degree x : ℝ) := by + rw [mul_sum] + apply sum_congr rfl + intro x _ + rw [← sum_filter] + simp [← G.card_neighborFinset_eq_degree, SimpleGraph.neighborFinset_def, + mul_comm] + _ = _ := by simp [mul_sum] + +omit [Fintype V] in + +theorem exists_avoid_family (F : Finset (Finset V)) + (hF : ∀ A ∈ F, A.Nonempty) (S : Finset V) : + ∃ U ⊆ S, S.card ≤ U.card + F.card ∧ ∀ A ∈ F, ¬ A ⊆ U := by + induction F using Finset.induction_on generalizing S with + | empty => exact ⟨S, Subset.rfl, by simp, by simp⟩ + | @insert A F hAF ih => + obtain ⟨U, hUS, hUcard, hU⟩ := ih (fun B hB => hF B (mem_insert_of_mem hB)) S + by_cases hAU : A ⊆ U + · obtain ⟨x, hx⟩ := hF A (mem_insert_self A F) + refine ⟨U.erase x, (erase_subset x U).trans hUS, ?_, ?_⟩ + · have he := card_erase_of_mem (hAU hx) + rw [card_insert_of_notMem hAF] + omega + · intro B hB hBU + rcases mem_insert.mp hB with rfl | hB + · exact (notMem_erase x U) (hBU hx) + · exact hU B hB (hBU.trans (erase_subset x U)) + · refine ⟨U, hUS, ?_, ?_⟩ + · rw [card_insert_of_notMem hAF] + omega + · intro B hB hBU + rcases mem_insert.mp hB with rfl | hB + · exact hAU hBU + · exact hU B hB hBU + +theorem prune (S : Finset V) {D : ℝ} (hD : 0 < D) : + ∃ U ⊆ S, + (S.card : ℝ) - degreeMass G S / D - count (G.cliqueFinset 3) S ≤ U.card ∧ + (∀ x ∈ U, (internalDegree G U x : ℝ) ≤ D) ∧ + (G.induce (U : Set V)).CliqueFree 3 := by + let bad := S.filter (fun x => D < (internalDegree G S x : ℝ)) + have hbad : (bad.card : ℝ) ≤ degreeMass G S / D := by + apply (le_div_iff₀ hD).mpr + calc + (bad.card : ℝ) * D = ∑ _x ∈ bad, D := by simp + _ ≤ ∑ x ∈ bad, (internalDegree G S x : ℝ) := by + exact sum_le_sum (fun x hx => (mem_filter.mp hx).2.le) + _ ≤ ∑ x ∈ S, (internalDegree G S x : ℝ) := + sum_le_sum_of_subset_of_nonneg (filter_subset _ _) (by intros; positivity) + _ = degreeMass G S := by simp [degreeMass, Nat.cast_sum] + let T := S \ bad + let F := (G.cliqueFinset 3).filter (· ⊆ S) + have hF : ∀ A ∈ F, A.Nonempty := by + intro A hA + have ha := (SimpleGraph.mem_cliqueFinset_iff.mp (mem_filter.mp hA).1).2 + exact card_pos.mp (by omega) + obtain ⟨U, hUT, hcard, havoid⟩ := exists_avoid_family F hF T + have hUS : U ⊆ S := hUT.trans sdiff_subset + refine ⟨U, hUS, ?_, ?_, ?_⟩ + · have hc : (S.card : ℝ) ≤ T.card + bad.card := by + exact_mod_cast card_le_card_sdiff_add_card + have hu : (T.card : ℝ) ≤ U.card + F.card := by exact_mod_cast hcard + change (S.card : ℝ) - degreeMass G S / D - F.card ≤ _ + linarith + · intro x hx + have hxT := mem_sdiff.mp (hUT hx) + have hd : (internalDegree G S x : ℝ) ≤ D := by + by_contra! hh + exact hxT.2 (mem_filter.mpr ⟨hxT.1, hh⟩) + exact (Nat.cast_le.mpr (card_le_card (filter_subset_filter _ hUS))).trans hd + · rw [G.cliqueFree_induce_iff] + intro A hAU hA + have hAF : A ∈ F := mem_filter.mpr + ⟨SimpleGraph.mem_cliqueFinset_iff.mpr hA, (show A ⊆ U from hAU).trans hUS⟩ + exact havoid A hAF hAU + +omit [Fintype V] [DecidableEq V] in +theorem induced_degree (U : Finset V) (x : (U : Set V)) : + (G.induce (U : Set V)).degree x = internalDegree G U x := by + rw [← SimpleGraph.card_neighborSet_eq_degree] + let e : ((G.induce (U : Set V)).neighborSet x) ≃ + {y : V // y ∈ U.filter (G.Adj x)} := + { toFun := fun y => ⟨y.1, mem_filter.mpr ⟨y.1.2, y.2⟩⟩ + invFun := fun y => ⟨⟨y.1, (mem_filter.mp y.2).1⟩, (mem_filter.mp y.2).2⟩ + left_inv := by intro y; rfl + right_inv := by intro y; rfl } + exact (Fintype.card_congr e).trans (Fintype.card_coe (U.filter (G.Adj x))) + +theorem sample_prune {p D : ℝ} (hp : 0 ≤ p) (hp1 : p ≤ 1) (hD : 0 < D) : + ∃ U : Finset V, + p * Fintype.card V - p^2 * (∑ x, (G.degree x : ℝ)) / D - + p^3 * (G.cliqueFinset 3).card ≤ U.card ∧ + (∀ x : (U : Set V), ((G.induce (U : Set V)).degree x : ℝ) ≤ D) ∧ + (G.induce (U : Set V)).CliqueFree 3 := by + let X (f : V → Bool) : ℝ := (selected f).card - + degreeMass G (selected f) / D - count (G.cliqueFinset 3) (selected f) + have hmean : (∑ f, weight p f * X f) = + p * Fintype.card V - p^2 * (∑ x, (G.degree x : ℝ)) / D - + p^3 * (G.cliqueFinset 3).card := by + simp only [X, mul_sub, ← mul_div_assoc, sum_sub_distrib, ← sum_div] + rw [size_moment, degreeMass_moment, family_moment] + intro A hA + exact (SimpleGraph.mem_cliqueFinset_iff.mp hA).2 + obtain ⟨f, hf⟩ := exists_ge_mean hp hp1 X + rw [hmean] at hf + obtain ⟨U, _hUS, hU, hdeg, htri⟩ := prune G (selected f) hD + refine ⟨U, hf.trans hU, ?_, htri⟩ + intro x + rw [induced_degree] + exact hdeg x x.2 + +theorem triangle_count_le {h m : ℕ} (hdeg : ∀ x, G.degree x ≤ h) + (hcommon : ∀ x y, G.Adj x y → Fintype.card (G.commonNeighbors x y) ≤ m) : + (G.cliqueFinset 3).card ≤ Fintype.card V * h * m := by + let T := Σ x : V, Σ y : G.neighborSet x, G.commonNeighbors x y + have hex (A : {A // A ∈ G.cliqueFinset 3}) : + ∃ t : T, A.1 = {t.1, t.2.1.1, t.2.2.1} := by + obtain ⟨x,y,z,hxy,hxz,hyz,hA⟩ := SimpleGraph.is3Clique_iff.mp + (SimpleGraph.mem_cliqueFinset_iff.mp A.2) + exact ⟨⟨x, ⟨y,hxy⟩, ⟨z,hxz,hyz⟩⟩, hA⟩ + choose f hf using hex + have hinj : Function.Injective f := by + intro A B hAB + apply Subtype.ext + rw [hf A, hf B, hAB] + calc + (G.cliqueFinset 3).card = Fintype.card {A // A ∈ G.cliqueFinset 3} := (Fintype.card_coe _).symm + _ ≤ Fintype.card T := Fintype.card_le_of_injective f hinj + _ = ∑ x : V, ∑ y : G.neighborSet x, Fintype.card (G.commonNeighbors x y) := by + simp [T, Fintype.card_sigma] + _ ≤ ∑ x : V, ∑ _y : G.neighborSet x, m := by + exact sum_le_sum (fun x _ => sum_le_sum (fun y _ => hcommon x y y.2)) + _ ≤ ∑ _x : V, h*m := by + apply sum_le_sum + intro x _ + simpa [G.card_neighborSet_eq_degree] using Nat.mul_le_mul_right m (hdeg x) + _ = Fintype.card V * h * m := by simp [mul_assoc] + +end SharpLogRamsey.Sampling + +open scoped BigOperators +namespace SharpLogRamsey.Upper + +end SharpLogRamsey.Upper +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Bounds/Upper.lean b/lean/OAI/Combinatorics/SharpRamsey/Bounds/Upper.lean new file mode 100644 index 0000000000000000000000000000000000000000..3710c67b2efb0e0822bc858ef4ee9ce8c8e4e788 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Bounds/Upper.lean @@ -0,0 +1,452 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Model +import OAI.Combinatorics.SharpRamsey.Geometry.SpanPairLine + +namespace OAI + +/-! The off-diagonal Ramsey upper bound. -/ + +section +open scoped BigOperators Classical +open Finset +namespace SharpLogRamsey + +namespace Foundation +variable {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V) + +omit [Fintype V] [DecidableEq V] in +theorem indepNum_lt_of_cliqueFree_compl {t : ℕ} (ht : Gᶜ.CliqueFree t) : + G.indepNum < t := by + by_contra! h + obtain ⟨A, hA⟩ := G.exists_isNIndepSet_indepNum + exact (ht.mono h) A (G.isNClique_compl.mpr hA) + +omit [DecidableEq V] in +theorem maximum_indep_dominates {A : Finset V} (hA : G.IsMaximumIndepSet A) + (x : V) : x ∈ A ∨ ∃ y ∈ A, G.Adj x y := by + by_contra! hn + have hi : G.IsIndepSet ((insert x A : Finset V) : Set V) := by + intro u hu v hv huv + simp only [mem_coe, mem_insert] at hu hv + rcases hu with rfl | hu <;> rcases hv with rfl | hv + · simp + · exact hn.2 v hv + · exact fun h => hn.2 u hu h.symm + · exact hA.1 hu hv huv + have hc := hA.2 (insert x A) hi + rw [card_insert_of_notMem hn.1] at hc + omega + +theorem card_le_mul_indepNum {B : ℕ} (hdeg : ∀ x, G.degree x + 1 ≤ B) : + Fintype.card V ≤ B * G.indepNum := by + obtain ⟨A, hA⟩ := G.maximumIndepSet_exists + have hcover : (univ : Finset V) ⊆ A.biUnion (fun x => insert x (G.neighborFinset x)) := by + intro v _ + obtain hv | ⟨x, hx, hadj⟩ := maximum_indep_dominates G hA v + · exact mem_biUnion.mpr ⟨v, hv, by simp⟩ + · exact mem_biUnion.mpr ⟨x, hx, by simp [hadj.symm]⟩ + calc + Fintype.card V = (univ : Finset V).card := (card_univ).symm + _ ≤ (A.biUnion (fun x => insert x (G.neighborFinset x))).card := card_le_card hcover + _ ≤ ∑ x ∈ A, (insert x (G.neighborFinset x)).card := card_biUnion_le + _ ≤ ∑ _x ∈ A, B := by + apply sum_le_sum + intro x _ + simpa using hdeg x + _ = B * G.indepNum := by + simp [G.maximumIndepSet_card_eq_indepNum A hA, mul_comm] + +omit [Fintype V] [DecidableEq V] in +theorem cliqueFree_neighbor {s : ℕ} (hs : G.CliqueFree (s+1)) (x : V) : + (G.induce (G.neighborSet x)).CliqueFree s := by + rw [G.cliqueFree_induce_iff] + have hc : G.CliqueFreeOn Set.univ (s+1) := (G.cliqueFreeOn_univ).mpr hs + simpa using SimpleGraph.CliqueFreeOn.of_succ G hc (a := x) (Set.mem_univ x) + +omit [Fintype V] [DecidableEq V] in +theorem cliqueFree_induce {s : ℕ} (hs : G.CliqueFree s) (U : Set V) : + (G.induce U).CliqueFree s := by + rw [G.cliqueFree_induce_iff] + intro A _ hA + exact hs A hA +omit [Fintype V] [DecidableEq V] in + +theorem compl_cliqueFree_induce {t : ℕ} (ht : Gᶜ.CliqueFree t) (U : Set V) : + (G.induce U)ᶜ.CliqueFree t := by + have he : (G.induce U)ᶜ = Gᶜ.induce U := by ext u v; simp [Subtype.val_inj] + rw [he] + exact cliqueFree_induce Gᶜ ht U + +theorem order_avoiding_lt_pow (n : ℕ) {t : ℕ} (ht : 1 ≤ t) : + ∀ {V : Type*} [Fintype V] [DecidableEq V] (G : SimpleGraph V), + G.CliqueFree (n+2) → Gᶜ.CliqueFree t → Fintype.card V < t^(n+1) := by + induction n with + | zero => + intro V _ _ G hs hi + have hg : G = ⊥ := G.cliqueFree_two.mp hs + have hn := card_le_mul_indepNum G (B := 1) (by intro x; simp [hg]) + have hh := indepNum_lt_of_cliqueFree_compl G hi + simpa using hn.trans_lt (by simpa using hh) + | succ n ih => + intro V _ _ G hs hi + have hd : ∀ x, G.degree x + 1 ≤ t^(n+1) := by + intro x + have hc := cliqueFree_neighbor G (s := n+2) (by simpa [Nat.add_assoc] using hs) x + have hci := compl_cliqueFree_induce G hi (G.neighborSet x) + have hh := ih (G.induce (G.neighborSet x)) hc hci + rw [G.card_neighborSet_eq_degree] at hh + omega + have hn := card_le_mul_indepNum G hd + have hi' := indepNum_lt_of_cliqueFree_compl G hi + have hp : 0 < t^(n+1) := pow_pos (by omega) _ + have hm := Nat.mul_lt_mul_of_pos_left hi' hp + calc + Fintype.card V ≤ t^(n+1) * G.indepNum := hn + _ < t^(n+1) * t := hm + _ = t^(n+1+1) := (pow_succ _ _).symm + +theorem ramseyProperty_pow (n : ℕ) {t : ℕ} (ht : 1 ≤ t) : + RamseyProperty (n+2) t (t^(n+1)) := by + intro G + by_cases hs : G.CliqueFree (n+2) + · right + by_contra! hi + have hh := order_avoiding_lt_pow n ht G hs hi + simp at hh + · left + simpa only [SimpleGraph.CliqueFree, not_forall, not_not] using hs + +theorem ramseyProperty_nonempty {s t : ℕ} (hs : 2 ≤ s) (ht : 1 ≤ t) : + {N | RamseyProperty s t N}.Nonempty := by + obtain ⟨n, rfl⟩ := Nat.exists_eq_add_of_le hs + exact ⟨t^(n+1), by simpa [Nat.add_comm] using ramseyProperty_pow n ht⟩ + +theorem ramsey_has_property {s t : ℕ} (hs : 2 ≤ s) (ht : 1 ≤ t) : + RamseyProperty s t (ramsey s t) := Nat.sInf_mem (ramseyProperty_nonempty hs ht) + +omit [Fintype V] [DecidableEq V] in + theorem clique_map_embedding {U : Type*} (f : U ↪ V) {n : ℕ} {A : Finset U} + (hA : (G.comap f).IsNClique n A) : G.IsNClique n (A.map f) := by + constructor + · intro u hu v hv huv + obtain ⟨a, ha, rfl⟩ := mem_map.mp hu + obtain ⟨b, hb, rfl⟩ := mem_map.mp hv + exact hA.1 ha hb (fun h => huv (congrArg f h)) + · simpa using hA.2 + +omit [Fintype V] [DecidableEq V] in + theorem compl_comap_embedding {U : Type*} (f : U ↪ V) : + (G.comap f)ᶜ = Gᶜ.comap f := by + ext u v + simp [SimpleGraph.comap_adj, f.injective.eq_iff] + +omit [DecidableEq V] in +theorem property_for_finite_type {s t N : ℕ} (hN : RamseyProperty s t N) + (hcard : N ≤ Fintype.card V) : + (∃ A, G.IsNClique s A) ∨ (∃ B, Gᶜ.IsNClique t B) := by + obtain ⟨f⟩ := Function.Embedding.nonempty_of_card_le + (α := Fin N) (β := V) (by simpa using hcard) + obtain ⟨A, hA⟩ | ⟨B, hB⟩ := hN (G.comap f) + · exact Or.inl ⟨A.map f, clique_map_embedding G f hA⟩ + · rw [compl_comap_embedding G f] at hB + exact Or.inr ⟨B.map f, clique_map_embedding Gᶜ f hB⟩ +omit [DecidableEq V] in + +theorem order_lt_ramsey {s t : ℕ} (hs : 2 ≤ s) (ht : 1 ≤ t) + (hGs : G.CliqueFree s) (hGt : Gᶜ.CliqueFree t) : + Fintype.card V < ramsey s t := by + by_contra! h + obtain ⟨A, hA⟩ | ⟨B, hB⟩ := property_for_finite_type G (ramsey_has_property hs ht) h + · exact hGs A hA + · exact hGt B hB + +theorem ramsey_le_of_property {s t N : ℕ} (hN : RamseyProperty s t N) : + ramsey s t ≤ N := Nat.sInf_le hN + +theorem property_mono {s t N M : ℕ} (hN : RamseyProperty s t N) (hNM : N ≤ M) : + RamseyProperty s t M := by + intro G + exact property_for_finite_type G hN (by simpa using hNM) + +theorem ramsey_le_pow {s t : ℕ} (hs : 2 ≤ s) (ht : 1 ≤ t) : + ramsey s t ≤ t^(s-1) := by + obtain ⟨n, rfl⟩ := Nat.exists_eq_add_of_le hs + have hh := ramsey_le_of_property (ramseyProperty_pow n ht) + simpa [Nat.add_comm] using hh + +theorem le_ramsey {s t : ℕ} (hs : 2 ≤ s) (ht : 1 ≤ t) : t ≤ ramsey s t := by + obtain ⟨A,hA⟩ | ⟨B,hB⟩ := ramsey_has_property hs ht (⊥ : SimpleGraph (Fin (ramsey s t))) + · exact False.elim ((SimpleGraph.cliqueFree_bot (by omega : 1 < s)) A hA) + · have hb := card_le_card (subset_univ B) + simpa [hB.2] using hb + +theorem ramsey_two {t : ℕ} (ht : 1 ≤ t) : ramsey 2 t = t := by + apply Nat.le_antisymm + · simpa using ramsey_le_pow (s := 2) (by omega) ht + · exact le_ramsey (by omega) ht + +omit [Fintype V] [DecidableEq V] in +theorem cliqueFree_common {s : ℕ} (hs : G.CliqueFree (s+2)) + {x y : V} (hxy : G.Adj x y) : + (G.induce (G.commonNeighbors x y)).CliqueFree s := by + rw [G.cliqueFree_induce_iff] + have hc : G.CliqueFreeOn Set.univ (s+2) := (G.cliqueFreeOn_univ).mpr hs + have hn : G.CliqueFreeOn (G.neighborSet x) (s+1) := by + simpa using SimpleGraph.CliqueFreeOn.of_succ G hc (a := x) (Set.mem_univ x) + exact SimpleGraph.CliqueFreeOn.of_succ G hn hxy + +theorem exists_avoiding_pred {s t : ℕ} (hs : 2 ≤ s) (ht : 2 ≤ t) : + ∃ G : SimpleGraph (Fin (ramsey s t - 1)), G.CliqueFree s ∧ Gᶜ.CliqueFree t := by + have hr : 2 ≤ ramsey s t := ht.trans (le_ramsey hs (by omega)) + have hn : ¬ RamseyProperty s t (ramsey s t - 1) := by + intro h + have hh := ramsey_le_of_property h + omega + simp only [RamseyProperty, not_forall, not_or, not_exists] at hn + exact hn + +end Foundation +end SharpLogRamsey + +open scoped BigOperators Classical +open Finset +namespace SharpLogRamsey.TriangleFree +variable {V : Type*} [Fintype V] [DecidableEq V] +variable (G : SimpleGraph V) + +noncomputable def independentSets : Finset (Finset V) := + univ.filter (fun S => G.IsIndepSet (S : Set V)) + +@[simp] theorem mem_independentSets (S : Finset V) : + S ∈ independentSets G ↔ G.IsIndepSet (S : Set V) := by + simp [independentSets] + +theorem independentSets_nonempty : (independentSets G).Nonempty := by + refine ⟨∅, ?_⟩ + simp [SimpleGraph.IsIndepSet] + +noncomputable def closed (x : V) : Finset V := insert x (G.neighborFinset x) +noncomputable def outside (x : V) (S : Finset V) : Finset V := S \ closed G x +noncomputable def available (x : V) (J : Finset V) : Finset V := + (G.neighborFinset x).filter (fun u => ∀ v ∈ J, ¬G.Adj u v) +noncomputable def fiber (x : V) (J : Finset V) : Finset (Finset V) := + (independentSets G).filter (fun S => outside G x S = J) + +def Admissible (x : V) (J : Finset V) : Prop := + G.IsIndepSet (J : Set V) ∧ Disjoint J (closed G x) + +@[simp] theorem mem_closed (x u : V) : u ∈ closed G x ↔ u = x ∨ G.Adj x u := by + simp [closed] +@[simp] theorem mem_outside (x u : V) (S : Finset V) : + u ∈ outside G x S ↔ u ∈ S ∧ u ≠ x ∧ ¬G.Adj x u := by + simp [outside] +@[simp] theorem mem_available (x u : V) (J : Finset V) : + u ∈ available G x J ↔ G.Adj x u ∧ ∀ v ∈ J, ¬G.Adj u v := by + simp [available] + +@[simp] theorem center_not_available (x : V) (J : Finset V) : x ∉ available G x J := by + simp + +theorem admissible_outside (x : V) {S : Finset V} + (hS : S ∈ independentSets G) : Admissible G x (outside G x S) := by + constructor + · exact (mem_independentSets G S |>.mp hS).mono (by + intro u hu; exact (mem_outside G x u S |>.mp hu).1) + · exact disjoint_left.mpr (fun u hu hc => (Finset.mem_sdiff.mp hu).2 hc) + +theorem admissible_not_center {x : V} {J : Finset V} + (hJ : Admissible G x J) : x ∉ J := by + intro hx + exact disjoint_left.mp hJ.2 hx (by simp) + +theorem admissible_not_adj {x u : V} {J : Finset V} + (hJ : Admissible G x J) (hu : u ∈ J) : ¬G.Adj x u := by + intro h + exact disjoint_left.mp hJ.2 hu (by simp [h]) + +theorem available_disjoint {x : V} {J : Finset V} + (hJ : Admissible G x J) : Disjoint J (available G x J) := by + apply disjoint_left.mpr + intro u hJ' hu + exact admissible_not_adj G hJ hJ' (mem_available G x u J |>.mp hu).1 + +theorem independent_insert_center {x : V} {J : Finset V} + (hJ : Admissible G x J) : G.IsIndepSet ((insert x J : Finset V) : Set V) := by + intro u hu v hv huv + simp only [mem_coe, mem_insert] at hu hv + rcases hu with rfl | hu + · rcases hv with rfl | hv + · simp + · exact admissible_not_adj G hJ hv + · rcases hv with rfl | hv + · exact fun h => admissible_not_adj G hJ hu h.symm + · exact hJ.1 hu hv huv + +theorem independent_extend (htri : G.CliqueFree 3) {x : V} {J K : Finset V} + (hJ : Admissible G x J) (hK : K ⊆ available G x J) : + G.IsIndepSet ((J ∪ K : Finset V) : Set V) := by + intro u hu v hv huv + simp only [mem_coe, mem_union] at hu hv + rcases hu with hu | hu <;> rcases hv with hv | hv + · exact hJ.1 hu hv huv + · exact fun h => (mem_available G x v J |>.mp (hK hv)).2 u hu h.symm + · exact (mem_available G x u J |>.mp (hK hu)).2 v hv + · exact (G.isIndepSet_neighborSet_of_triangleFree htri x) + (mem_available G x u J |>.mp (hK hu)).1 + (mem_available G x v J |>.mp (hK hv)).1 huv + +theorem outside_insert_center {x : V} {J : Finset V} + (hJ : Admissible G x J) : outside G x (insert x J) = J := by + ext u + simp only [mem_outside, mem_insert] + constructor + · rintro ⟨h, hne, _⟩ + exact h.resolve_left hne + · intro hu + exact ⟨Or.inr hu, fun h => admissible_not_center G hJ (h ▸ hu), + admissible_not_adj G hJ hu⟩ + +theorem outside_extend {x : V} {J K : Finset V} + (hJ : Admissible G x J) (hK : K ⊆ available G x J) : + outside G x (J ∪ K) = J := by + ext u + simp only [mem_outside, mem_union] + constructor + · rintro ⟨hu | hu, _, hna⟩ + · exact hu + · exact False.elim (hna (mem_available G x u J |>.mp (hK hu)).1) + · intro hu + exact ⟨Or.inl hu, fun h => admissible_not_center G hJ (h ▸ hu), + admissible_not_adj G hJ hu⟩ + +theorem fiber_eq (htri : G.CliqueFree 3) {x : V} {J : Finset V} + (hJ : Admissible G x J) : + fiber G x J = insert (insert x J) + ((available G x J).powerset.image (fun K => J ∪ K)) := by + ext S + simp only [fiber, mem_filter, mem_independentSets, mem_insert, mem_image, + mem_powerset] + constructor + · rintro ⟨hS, hout⟩ + by_cases hx : x ∈ S + · left + ext u + simp only [mem_insert] + constructor + · intro hu + by_cases hux : u = x + · exact Or.inl hux + · right + rw [← hout, mem_outside] + exact ⟨hu, hux, hS hx hu (Ne.symm hux)⟩ + · rintro (rfl | hu) + · exact hx + · rw [← hout, mem_outside] at hu + exact hu.1 + · right + refine ⟨S ∩ G.neighborFinset x, ?_, ?_⟩ + · intro u hu + simp only [mem_inter, SimpleGraph.mem_neighborFinset] at hu + apply (mem_available G x u J).mpr + refine ⟨hu.2, ?_⟩ + intro v hv hadj + have hvS : v ∈ S := by rw [← hout, mem_outside] at hv; exact hv.1 + exact hS hu.1 hvS hadj.ne hadj + · ext u + simp only [mem_union, mem_inter, SimpleGraph.mem_neighborFinset] + constructor + · rintro (hu | hu) + · rw [← hout, mem_outside] at hu; exact hu.1 + · exact hu.1 + · intro hu + by_cases hax : G.Adj x u + · exact Or.inr ⟨hu, hax⟩ + · left + rw [← hout, mem_outside] + exact ⟨hu, fun h => hx (h ▸ hu), hax⟩ + · rintro (rfl | ⟨K, hK, rfl⟩) + · exact ⟨independent_insert_center G hJ, outside_insert_center G hJ⟩ + · exact ⟨independent_extend G htri hJ hK, outside_extend G hJ hK⟩ + +theorem extend_injective {x : V} {J : Finset V} (hJ : Admissible G x J) : + Set.InjOn (fun K => J ∪ K) ((available G x J).powerset : Set (Finset V)) := by + intro K hK L hL heq + have hdK : Disjoint J K := (available_disjoint G hJ).mono_right (mem_powerset.mp hK) + have hdL : Disjoint J L := (available_disjoint G hJ).mono_right (mem_powerset.mp hL) + simpa [union_sdiff_cancel_left hdK, union_sdiff_cancel_left hdL] using + congrArg (fun S => S \ J) heq + +theorem center_choice_not_image {x : V} {J : Finset V} (hJ : Admissible G x J) : + insert x J ∉ (available G x J).powerset.image (fun K => J ∪ K) := by + rintro h + obtain ⟨K, hK, heq⟩ := mem_image.mp h + have hx : x ∈ J ∪ K := heq ▸ mem_insert_self x J + rcases mem_union.mp hx with hx | hx + · exact admissible_not_center G hJ hx + · exact center_not_available G x J (mem_powerset.mp hK hx) + +theorem card_fiber (htri : G.CliqueFree 3) {x : V} {J : Finset V} + (hJ : Admissible G x J) : (fiber G x J).card = 1 + 2^(available G x J).card := by + rw [fiber_eq G htri hJ, card_insert_of_notMem (center_choice_not_image G hJ), + card_image_of_injOn (extend_injective G hJ), card_powerset] + omega + +theorem sum_fiber (htri : G.CliqueFree 3) {x : V} {J : Finset V} + (hJ : Admissible G x J) (f : Finset V → ℝ) : + ∑ S ∈ fiber G x J, f S = f (insert x J) + + ∑ K ∈ (available G x J).powerset, f (J ∪ K) := by + rw [fiber_eq G htri hJ, sum_insert (center_choice_not_image G hJ), + sum_image (extend_injective G hJ)] + +omit [Fintype V] in + +theorem twice_sum_powerset_card (A : Finset V) : + 2 * (∑ K ∈ A.powerset, (K.card : ℝ)) = A.card * (2:ℝ)^A.card := by + have hc : ∑ K ∈ A.powerset, ((A \ K).card : ℝ) = + ∑ K ∈ A.powerset, (K.card : ℝ) := by + apply sum_bij (fun K _ => A \ K) + · intro K _; exact mem_powerset.mpr sdiff_subset + · intro K hK L hL heq + have := congrArg (fun X => A \ X) heq + simpa [Finset.sdiff_sdiff_eq_self (mem_powerset.mp hK), + Finset.sdiff_sdiff_eq_self (mem_powerset.mp hL)] using this + · intro K hK + exact ⟨A \ K, mem_powerset.mpr sdiff_subset, + Finset.sdiff_sdiff_eq_self (mem_powerset.mp hK)⟩ + · intro K _; rfl + have hsum : ∑ K ∈ A.powerset, (((A \ K).card : ℝ) + K.card) = + A.card * (2:ℝ)^A.card := by + calc + _ = ∑ _K ∈ A.powerset, (A.card : ℝ) := by + apply sum_congr rfl + intro K hK + exact_mod_cast card_sdiff_add_card_eq_card (mem_powerset.mp hK) + _ = _ := by simp [card_powerset]; ring + rw [sum_add_distrib, hc] at hsum + linarith + +theorem center_neighbor_inter {x : V} {J : Finset V} + (hJ : Admissible G x J) : insert x J ∩ G.neighborFinset x = ∅ := by + apply eq_empty_iff_forall_notMem.mpr + intro u hu + simp only [mem_inter, mem_insert, SimpleGraph.mem_neighborFinset] at hu + rcases hu.1 with rfl | huJ + · exact G.irrefl hu.2 + · exact admissible_not_adj G hJ huJ hu.2 + +theorem extend_neighbor_inter {x : V} {J K : Finset V} + (hJ : Admissible G x J) (hK : K ⊆ available G x J) : + (J ∪ K) ∩ G.neighborFinset x = K := by + ext u + simp only [mem_inter, mem_union, SimpleGraph.mem_neighborFinset] + constructor + · rintro ⟨hu | hu, hadj⟩ + · exact False.elim (admissible_not_adj G hJ hu hadj) + · exact hu + · intro hu + exact ⟨Or.inr hu, (mem_available G x u J |>.mp (hK hu)).1⟩ + +end SharpLogRamsey.TriangleFree +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Construction/FiniteStreamTail.lean b/lean/OAI/Combinatorics/SharpRamsey/Construction/FiniteStreamTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..1996e991a9740f7c4b1dd83b5d3612fc3720fec4 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Construction/FiniteStreamTail.lean @@ -0,0 +1,124 @@ +import Mathlib + +namespace OAI + +section +namespace SharpLogRamsey.FiniteStreamTail +open Finset Real +open scoped Classical BigOperators +noncomputable section +variable {α : Type*} [Fintype α] + +def hits {N : ℕ} (S : Finset α) (z : Fin N→α) : ℕ := + (univ.filter (fun i=>z i∈S)).card + +def probability (S : Finset α) : ℝ := (S.card:ℝ)/(Fintype.card α:ℝ) + +lemma moment (S : Finset α) (N : ℕ) : + (∑ z : Fin N→α,(2:ℝ)^hits S z)= + ((Fintype.card α:ℝ)+(S.card:ℝ))^N := by + have hp (z : Fin N→α) : + (2:ℝ)^hits S z=∏ i,if z i∈S then (2:ℝ) else 1 := by + simp only [prod_ite,hits,prod_const,one_pow,mul_one] + have hs : (∑ a : α,if a∈S then (2:ℝ) else 1)=(Fintype.card α:ℝ)+(S.card:ℝ) := by + have he (a : α) : (if a∈S then (2:ℝ) else 1)=1+(if a∈S then 1 else 0) := by + split_ifs <;> norm_num + simp only [he,sum_add_distrib,sum_const,card_univ,nsmul_eq_mul,mul_one, + Fintype.sum_ite_mem,sum_const] + simp_rw [hp] + rw [←Fintype.prod_sum (fun (_ : Fin N) (a : α)=>if a∈S then (2:ℝ) else 1)] + simp only [hs,prod_const,card_univ,Fintype.card_fin] + +variable [Nonempty α] + +lemma card_pos : (0:ℝ)t≤hits S z)) ≤ + exp (N*probability S-t*log 2) := by + let B := univ.filter (fun z : Fin N→α=>t≤hits S z) + have hsum : (B.card:ℝ)*exp (t*log 2)≤∑ z : Fin N→α,(2:ℝ)^hits S z := by + calc + _ = ∑ _z∈B,exp (t*log 2) := by simp + _ ≤ ∑ z∈B,(2:ℝ)^hits S z := by + apply sum_le_sum + intro z hz + have ht := (mem_filter.mp hz).2 + have he : exp ((hits S z:ℝ)*log 2)=(2:ℝ)^hits S z := by + rw [exp_nat_mul,exp_log (by norm_num)] + rw [←he] + apply exp_le_exp.mpr + exact mul_le_mul_of_nonneg_right ht (log_nonneg (by norm_num)) + _ ≤ _ := sum_le_sum_of_subset_of_nonneg (subset_univ _) (fun _ _ _=>by positivity) + have hdiv := div_le_div_of_nonneg_right hsum (Nat.cast_nonneg (Fintype.card (Fin N→α))) + have hm := average_moment_le S N + have hb : probability B*exp (t*log 2)≤exp (N*probability S) := by + unfold probability + calc + _ = (B.card*exp (t*log 2))/(Fintype.card (Fin N→α):ℝ) := by ring + _ ≤ _ := hdiv.trans hm + have hh := (le_div_iff₀ (exp_pos (t*log 2))).mpr hb + simpa only [exp_sub] using hh + +lemma probability_univ : probability (univ : Finset α)=1 := by + simp only [probability,card_univ] + exact div_self (ne_of_gt (card_pos (α:=α))) + +lemma probability_compl (S : Finset α) : probability Sᶜ=1-probability S := by + simp only [probability,Finset.card_compl,Nat.cast_sub (card_le_univ S),sub_div, + div_self (ne_of_gt (card_pos (α:=α)))] + +omit [Nonempty α] [Fintype α] in +lemma hits_embedding {N n : ℕ} (S : Finset α) (z : Fin N→α) (e : Fin n↪Fin N) : + hits S (z∘e)≤hits S z := by + let A := univ.filter (fun i : Fin n=>z (e i)∈S) + have he : A.map e⊆univ.filter (fun i : Fin N=>z i∈S) := by + intro i hi + obtain ⟨j,hj,rfl⟩ := mem_map.mp hi + exact mem_filter.mpr ⟨mem_univ _,(mem_filter.mp hj).2⟩ + simpa only [card_map,A,hits,Function.comp_def] using card_le_card he + +variable {J : Type*} [Fintype J] + +theorem simultaneous_tail (R : J→Finset α) (N : ℕ) (t μ : ℝ) + (hμ : ∀ j,(N:ℝ)*probability (R j)≤μ) : + probability (univ.filter (fun z : Fin N→α=>∃ j,t≤hits (R j) z)) ≤ + (Fintype.card J:ℝ)*exp (μ-t*log 2) := by + let B := fun j=>univ.filter (fun z : Fin N→α=>t≤hits (R j) z) + have he : (univ.filter (fun z : Fin N→α=>∃ j,t≤hits (R j) z))= + univ.biUnion B := by ext z; simp [B] + rw [he] + have hc : ((univ.biUnion B).card:ℝ)≤∑ j,((B j).card:ℝ) := by + exact_mod_cast (card_biUnion_le (s:=univ) (t:=B)) + calc + _ ≤ (∑ j,((B j).card:ℝ))/(Fintype.card (Fin N→α):ℝ) := + div_le_div_of_nonneg_right hc (by positivity) + _ = ∑ j,probability (B j) := by rw [sum_div]; rfl + _ ≤ ∑ _j : J,exp (μ-t*log 2) := by + apply sum_le_sum + intro j _ + exact (single_tail (R j) N t).trans (exp_le_exp.mpr (sub_le_sub_right (hμ j) _)) + _ = _ := by simp + +end +end SharpLogRamsey.FiniteStreamTail + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Construction/FlagConstruction.lean b/lean/OAI/Combinatorics/SharpRamsey/Construction/FlagConstruction.lean new file mode 100644 index 0000000000000000000000000000000000000000..185af8d5912d2672f37059f5e9c45c87822dbaf6 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Construction/FlagConstruction.lean @@ -0,0 +1,217 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.Popular + +namespace OAI + +section +namespace SharpLogRamsey + +section LinearAlgebra +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + +theorem flag_vectors_independent {m : ℕ} (a : Fin m → V) + (b : Fin m → Module.Dual K V) + (ha : ∀ i, a i ≠ 0) + (hz : ∀ i j, i ≤ j → b j (a i) = 0) + (hn : ∀ i j, i < j → b i (a j) ≠ 0) : + LinearIndependent K a := by + induction m with + | zero => exact linearIndependent_empty_type + | succ m ih => + apply linearIndependent_finSucc'.mpr + refine ⟨ih (Fin.init a) (Fin.init b) (fun i => ha i.castSucc) + (fun i j h => hz i.castSucc j.castSucc h) + (fun i j h => hn i.castSucc j.castSucc h), ?_⟩ + cases m with + | zero => simpa using ha (Fin.last 0) + | succ n => + intro hmem + let j : Fin (n + 1 + 1) := (Fin.last n).castSucc + have hspan : Submodule.span K (Set.range (Fin.init a)) ≤ + LinearMap.ker (b j) := by + apply Submodule.span_le.mpr + rintro _ ⟨i, rfl⟩ + exact hz i.castSucc j (by simpa [j] using Fin.le_last i) + have hzero : b j (a (Fin.last (n + 1))) = 0 := hspan hmem + exact hn j (Fin.last (n + 1)) (by simp [j]) hzero + +theorem flag_length_lt_finrank [FiniteDimensional K V] {m : ℕ} + (a : Fin (m+1) → V) (b : Fin (m+1) → Module.Dual K V) + (ha : ∀ i, a i ≠ 0) (hb : b (Fin.last m) ≠ 0) + (hz : ∀ i j, i ≤ j → b j (a i) = 0) + (hn : ∀ i j, i < j → b i (a j) ≠ 0) : + m + 1 < Module.finrank K V := by + let W := LinearMap.ker (b (Fin.last m)) + let a' : Fin (m+1) → W := fun i => ⟨a i, hz i (Fin.last m) (Fin.le_last i)⟩ + have hli : LinearIndependent K a' := + LinearIndependent.of_comp W.subtype (flag_vectors_independent a b ha hz hn) + have hle : m + 1 ≤ Module.finrank K W := by + simpa using hli.fintype_card_le_finrank + have hproper : W ≠ ⊤ := by + exact fun h => hb (LinearMap.ker_eq_top.mp h) + exact hle.trans_lt (Submodule.finrank_lt hproper) + +end LinearAlgebra + +section Flags +variable (K V : Type*) [Field K] [AddCommGroup V] [Module K V] + +theorem incident_iff_submodule (a : Projectivization K V) + (b : Projectivization K (Module.Dual K V)) : + Incident K V a b ↔ a.submodule ≤ LinearMap.ker b.rep := by + rw [Projectivization.submodule_eq, Submodule.span_singleton_le_iff_mem] + rfl + +def flagGraph {N : ℕ} (F : Fin N → Flag K V) : SimpleGraph (Fin N) where + Adj i j := + (i < j ∧ Incident K V (F i).point (F j).dualPoint ∧ + ¬ Incident K V (F j).point (F i).dualPoint) ∨ + (j < i ∧ Incident K V (F j).point (F i).dualPoint ∧ + ¬ Incident K V (F i).point (F j).dualPoint) + symm := ⟨fun _ _ h => h.symm⟩ + loopless := ⟨fun i => by simp⟩ + +variable {K V} + +theorem flagGraph_adj_of_lt {N : ℕ} (F : Fin N → Flag K V) + {i j : Fin N} (hij : i < j) : + (flagGraph K V F).Adj i j ↔ + Incident K V (F i).point (F j).dualPoint ∧ + ¬ Incident K V (F j).point (F i).dualPoint := by + simp only [flagGraph, hij, true_and, not_lt_of_ge hij.le, false_and, or_false] + +theorem flagGraph_cliqueFree [FiniteDimensional K V] {d N : ℕ} + (hdim : Module.finrank K V = d+1) (F : Fin N → Flag K V) : + (flagGraph K V F).CliqueFree (d+1) := by + intro S hS + let e := S.orderEmbOfFin hS.card_eq + let a : Fin (d+1) → V := fun i => (F (e i)).point.rep + let b : Fin (d+1) → Module.Dual K V := fun i => (F (e i)).dualPoint.rep + have hedge (i j : Fin (d+1)) (h : i < j) : + Incident K V (F (e i)).point (F (e j)).dualPoint ∧ + ¬ Incident K V (F (e j)).point (F (e i)).dualPoint := by + apply (flagGraph_adj_of_lt F (e.strictMono h)).mp + exact hS.isClique (S.orderEmbOfFin_mem hS.card_eq i) + (S.orderEmbOfFin_mem hS.card_eq j) (ne_of_lt (e.strictMono h)) + have hz : ∀ i j, i ≤ j → b j (a i) = 0 := by + intro i j h + rcases lt_or_eq_of_le h with hlt | rfl + · exact (hedge i j hlt).1 + · exact (F (e i)).incident + have hn : ∀ i j, i < j → b i (a j) ≠ 0 := by + intro i j h + exact (hedge i j h).2 + have hlt := flag_length_lt_finrank a b (fun i => (F (e i)).point.rep_nonzero) + (F (e (Fin.last d))).dualPoint.rep_nonzero hz hn + omega + +theorem consistent_iff_no_edges {N : ℕ} (F : Fin N → Flag K V) : + Consistent F ↔ ∀ i j, ¬ (flagGraph K V F).Adj i j := by + constructor + · intro h i j hadj + rcases hadj with ⟨hij, hinc, hnot⟩ | ⟨hji, hinc, hnot⟩ + · exact hnot (h i j hij hinc) + · exact hnot (h j i hji hinc) + · intro h i j hij hinc + by_contra hnot + exact h i j ((flagGraph_adj_of_lt F hij).mpr ⟨hinc, hnot⟩) + +def ConsistentOn {N : ℕ} (F : Fin N → Flag K V) (S : Finset (Fin N)) : Prop := + ∀ i ∈ S, ∀ j ∈ S, i < j → Incident K V (F i).point (F j).dualPoint → + Incident K V (F j).point (F i).dualPoint + +theorem consistentOn_iff_compl_isClique {N : ℕ} (F : Fin N → Flag K V) + (S : Finset (Fin N)) : + ConsistentOn F S ↔ (flagGraph K V F)ᶜ.IsClique S := by + constructor + · intro h i hi j hj hne + rw [SimpleGraph.compl_adj] + refine ⟨hne, ?_⟩ + rintro (⟨hij, hinc, hnot⟩ | ⟨hji, hinc, hnot⟩) + · exact hnot (h i hi j hj hij hinc) + · exact hnot (h j hj i hi hji hinc) + · intro h i hi j hj hij hinc + have hnot := ((flagGraph K V F).compl_adj i j).mp (h hi hj (ne_of_lt hij)) + by_contra hrev + exact hnot.2 ((flagGraph_adj_of_lt F hij).mpr ⟨hinc, hrev⟩) + +noncomputable def projectiveSubmoduleEquiv (W : Submodule K V) : + Projectivization K W ≃ {a : Projectivization K V // a.submodule ≤ W} := by + let f : Projectivization K W → {a : Projectivization K V // a.submodule ≤ W} := + fun a => ⟨Projectivization.map W.subtype W.injective_subtype a, by + induction a using Projectivization.ind with + | h v hv => + rw [Projectivization.map_mk, Projectivization.submodule_mk, + Submodule.span_singleton_le_iff_mem] + exact v.property⟩ + apply Equiv.ofBijective f + constructor + · intro a b h + exact Projectivization.map_injective W.subtype W.injective_subtype + (congrArg Subtype.val h) + · rintro ⟨a, ha⟩ + have hmem : a.rep ∈ W := ha (by + rw [Projectivization.submodule_eq] + exact Submodule.mem_span_singleton_self _) + let v : W := ⟨a.rep, hmem⟩ + have hv : v ≠ 0 := fun h => a.rep_nonzero (congrArg Subtype.val h) + refine ⟨Projectivization.mk K v hv, ?_⟩ + apply Subtype.ext + exact a.mk_rep + +theorem card_incident_points [Finite K] [FiniteDimensional K V] {d : ℕ} + (hdim : Module.finrank K V = d+1) + (b : Projectivization K (Module.Dual K V)) : + Nat.card {a : Projectivization K V // Incident K V a b} = + ∑ i ∈ Finset.range d, Nat.card K ^ i := by + let e : {a : Projectivization K V // Incident K V a b} ≃ + {a : Projectivization K V // a.submodule ≤ LinearMap.ker b.rep} := + Equiv.subtypeEquivRight (fun a => incident_iff_submodule K V a b) + rw [Nat.card_congr e, ← Nat.card_congr (projectiveSubmoduleEquiv (LinearMap.ker b.rep))] + apply Projectivization.card_of_finrank + have h := Module.Dual.finrank_ker_add_one_of_ne_zero b.rep_nonzero + omega + +theorem card_flags [Finite K] [FiniteDimensional K V] {d : ℕ} + (hdim : Module.finrank K V = d+1) : + Nat.card (Flag K V) = + (∑ i ∈ Finset.range (d+1), Nat.card K ^ i) * + (∑ i ∈ Finset.range d, Nat.card K ^ i) := by + classical + let : Finite V := Finite.of_injective (Module.finBasis K V).equivFun + (Module.finBasis K V).equivFun.injective + let : Finite (Module.Dual K V) := + Finite.of_injective (Module.finBasis K (Module.Dual K V)).equivFun + (Module.finBasis K (Module.Dual K V)).equivFun.injective + let : Finite (Projectivization K V) := + Finite.of_injective Projectivization.rep (fun a b h => by + rw [← a.mk_rep, ← b.mk_rep]; congr 1) + let : Finite (Projectivization K (Module.Dual K V)) := + Finite.of_injective Projectivization.rep (fun a b h => by + rw [← a.mk_rep, ← b.mk_rep]; congr 1) + let := Fintype.ofFinite (Projectivization K (Module.Dual K V)) + let e : Flag K V ≃ Σ b : Projectivization K (Module.Dual K V), + {a : Projectivization K V // Incident K V a b} := + { toFun := fun f => ⟨f.dualPoint, f.point, f.incident⟩ + invFun := fun f => ⟨f.2.1, f.1, f.2.2⟩ + left_inv := fun f => by cases f; rfl + right_inv := fun f => by cases f; rfl } + rw [Nat.card_congr e, Nat.card_sigma] + simp_rw [card_incident_points hdim] + simp only [Finset.sum_const, Finset.card_univ, smul_eq_mul] + rw [← Nat.card_eq_fintype_card] + rw [Projectivization.card_of_finrank K (Module.Dual K V) + (Subspace.dual_finrank_eq.trans hdim)] + +theorem prime_flagGraph_cliqueFree (q d N : ℕ) [Fact q.Prime] + (F : Fin N → Flag (ZMod q) (Fin (d+1) → ZMod q)) : + (flagGraph (ZMod q) (Fin (d+1) → ZMod q) F).CliqueFree (d+1) := by + apply flagGraph_cliqueFree + simp + +end Flags +end SharpLogRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Construction/GraphWitness.lean b/lean/OAI/Combinatorics/SharpRamsey/Construction/GraphWitness.lean new file mode 100644 index 0000000000000000000000000000000000000000..f61d1a8f5c7d51a7758d1358f089d789b5db80ec --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Construction/GraphWitness.lean @@ -0,0 +1,73 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Parameters.FiniteIteration +import OAI.Combinatorics.SharpRamsey.Parameters.NoContext +import OAI.Combinatorics.SharpRamsey.Construction.InitialLaw + +namespace OAI + +section +namespace SharpLogRamsey.Marking +open Finset Real Filter Selection Selection.Windows ActualHighRank SourceScales +open scoped Classical BigOperators Topology +noncomputable section +local instance witnessFiniteDual {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Fin (d+1)→K)) := + Finite.of_injective ((↑) : Module.Dual K (Fin (d+1)→K)→((Fin (d+1)→K)→K)) DFunLike.coe_injective +local instance witnessFiniteDouble {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Module.Dual K (Fin (d+1)→K))) := + Finite.of_injective ((↑) : Module.Dual K (Module.Dual K (Fin (d+1)→K))→(Module.Dual K (Fin (d+1)→K)→K)) DFunLike.coe_injective +local instance witnessProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Fin (d+1)→K)) := Fintype.ofFinite _ +local instance witnessDualProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Fin (d+1)→K))) := Fintype.ofFinite _ +local instance witnessDoubleProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Module.Dual K (Fin (d+1)→K)))) := Fintype.ofFinite _ + +theorem eventually_graph_witness (i : ℕ) (η : ℝ) (hη : 0 < η) (hηu : η ≤ 1) : + ∀ᶠ σ : ℝ in atTop, ∀ (q : ℕ) [Fact q.Prime], 3 ≤ q → exp σ=(q:ℝ) → + ∀ N k : ℕ, 0 < k → k ≤ N → (k:ℝ) ≤ (q:ℝ)*σ^(1+η) → + ((q:ℝ)*σ^(1+η))/2 ≤ k → (N:ℝ) ≤ (q:ℝ)^(i+3)*σ → + ∃ G : SimpleGraph (Fin N),G.CliqueFree (i+4) ∧ G.indepNum < k := by + let P:=max 4 (stepPrefactor (i+3)) + let T:=⌈8/η⌉₊+1 + let Lstar:ℝ:=(4*classCount i)^T + let c:ℝ:=(1/2)/(256*classCount i)^T + have hP4 : 4 ≤ P:=le_max_left _ _ + have hP1 : 1 ≤ P:=by linarith + have hPs : stepPrefactor (i+3) ≤ P:=le_max_right _ _ + have hK : 0 < classCount i:=classCount_pos i + have hLs : 0 < Lstar:=by dsimp [Lstar];positivity + have hc : 0 < c:=by dsimp [c];positivity + filter_upwards [eventually_iterated_context i η P (InitialExperiment.occupancyConstant i) + hη hηu hP1 hPs (InitialExperiment.occupancyConstant_pos i).le, + eventually_no_small_context i η c Lstar P hη hc hLs hP1] with σ hiter hnone + intro q _ hq he N k hk hkn hku hklo hN + by_contra! hbad + have h : ∀ z : Fin N→Flag (ZMod q) (Fin (i+4)→ZMod q), + k ≤ (flagGraph (ZMod q) (Fin (i+4)→ZMod q) z).indepNum:=by + intro z + exact hbad _ (prime_flagGraph_cliqueFree q (i+3) N z) + have hlog : log (q:ℝ)=σ:=by rw [←he,log_exp] + have hNlog : (N:ℝ) ≤ (q:ℝ)^(i+3)*log (q:ℝ):=by simpa only [hlog] using hN + let Ω:=InitialExperiment.goodEvent i q N + let p:=InitialExperiment.law i q N hNlog + let stream : Ω→Fin N→Flag (ZMod q) (Fin (i+4)→ZMod q):=Subtype.val + let F : Ω→Fin k→Flag (ZMod q) (Fin (i+4)→ZMod q):=InitialExperiment.tuple i q N k h + have hdom : ∀ g,(p.map stream).mass g ≤ 2/(Fintype.card (Flag (ZMod q) (Fin (i+4)→ZMod q)):ℝ)^N:= + InitialExperiment.law_dom i q N hNlog + have hsel : ∀ x,p.mass x≠0→Occurs (F x) (stream x) ∨ Occurs (reverseTuple (F x)) (stream x):=by + intro x _ + exact Or.inr (InitialExperiment.tuple_occurs i q N k h x) + have hcon : ∀ x,p.mass x≠0→ScanConsistent ((List.ofFn (fun j=>flagPair (F x j))).map toScan):=by + intro x _ + exact InitialExperiment.tuple_consistent i q N k h x + have hocc : ∀ x,p.mass x≠0→∀ W : Submodule (ZMod q) (Fin (i+4)→ZMod q), + ((univ.filter (fun j : Fin k=>(flagPair (F x j)).swap∈ + orthogonalRectangle Projectivization.rep Projectivization.rep W)).card:ℝ) ≤ + InitialExperiment.occupancyConstant i*σ:=by + intro x _ W + simpa only [hlog] using InitialExperiment.tuple_occupancy i q N k h x W + let e0:=initial_context p F _ (InitialExperiment.alphabet_cap i q hP4 σ he) + obtain ⟨m,hm,⟨e⟩⟩:=hiter q hq he Ω N k p stream F hk hkn hku hklo hdom hsel hN hcon hocc e0 + exact hnone q he Ω N k m p stream F hkn hku hdom hsel hN hcon hm ⟨e⟩ +end +end SharpLogRamsey.Marking + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Construction/InitialLaw.lean b/lean/OAI/Combinatorics/SharpRamsey/Construction/InitialLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..bf879b4f590b11750a4a55c62090ec42eb503308 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Construction/InitialLaw.lean @@ -0,0 +1,121 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Construction.InitialTools + +namespace OAI + +section +namespace SharpLogRamsey.InitialExperiment +open Finset Real Filter Selection Marking FiniteStreamTail RectangleStreamEvent +open scoped Classical BigOperators Topology +noncomputable section +local instance initLawFiniteDual {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Fin (d+1)→K)) := + Finite.of_injective ((↑) : Module.Dual K (Fin (d+1)→K)→((Fin (d+1)→K)→K)) DFunLike.coe_injective +local instance initLawFiniteDouble {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Module.Dual K (Fin (d+1)→K))) := + Finite.of_injective ((↑) : Module.Dual K (Module.Dual K (Fin (d+1)→K))→(Module.Dual K (Fin (d+1)→K)→K)) DFunLike.coe_injective +local instance initLawProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Fin (d+1)→K)) := Fintype.ofFinite _ +local instance initLawDualProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Fin (d+1)→K))) := Fintype.ofFinite _ +local instance initLawDoubleProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Module.Dual K (Fin (d+1)→K)))) := Fintype.ofFinite _ + +def occupancyConstant (i : ℕ) : ℝ := (((i+4)^2:ℕ)+5:ℝ)/log 2 + +lemma occupancyConstant_pos (i : ℕ) : 0 < occupancyConstant i:=by + unfold occupancyConstant + exact div_pos (by positivity) (log_pos (by norm_num)) + +variable (i q : ℕ) [Fact q.Prime] (N k : ℕ) + +local instance initLawFlagNonempty : Nonempty (Flag (ZMod q) (Fin (i+4)→ZMod q)):= + Fintype.card_pos_iff.mp (by + have hh:=flags_card_pos (K:=ZMod q) (V:=Fin (i+4)→ZMod q) (d:=i+3) (by omega) (by simp) + simpa only [←Nat.card_eq_fintype_card] using hh) + +def goodEvent : Finset (Fin N→Flag (ZMod q) (Fin (i+4)→ZMod q)):= + univ.filter (fun z=>∀ W : Submodule (ZMod q) (Fin (i+4)→ZMod q), + (hits (rectangle W) z:ℝ) simp only [law,Fintype.card_fun,Fintype.card_fin,Nat.cast_pow] + +variable (h : ∀ z : Fin N→Flag (ZMod q) (Fin (i+4)→ZMod q), + k ≤ (flagGraph (ZMod q) (Fin (i+4)→ZMod q) z).indepNum) + +def chosen (z : Fin N→Flag (ZMod q) (Fin (i+4)→ZMod q)) : Fin k↪o Fin N:= + Classical.choose (independent_selected z (h z)) + +lemma chosen_consistent (z : Fin N→Flag (ZMod q) (Fin (i+4)→ZMod q)) : + Consistent (fun j=>z (chosen i q N k h z j)):=Classical.choose_spec (independent_selected z (h z)) + +def tuple (z : goodEvent i q N) : Fin k→Flag (ZMod q) (Fin (i+4)→ZMod q):= + fun j=>z.val (chosen i q N k h z.val j.rev) + +lemma tuple_occurs (z : goodEvent i q N) : Occurs (reverseTuple (tuple i q N k h z)) z.val := by + apply (occurs_iff_orderEmbedding _ _).mpr + refine ⟨chosen i q N k h z.val,?_⟩ + intro j + simp only [reverseTuple,tuple,Fin.rev_rev] + +lemma tuple_consistent (z : goodEvent i q N) : + ScanConsistent ((List.ofFn (fun j=>flagPair (tuple i q N k h z j))).map toScan) := + selected_reverse_consistent z.val (chosen i q N k h z.val) (chosen_consistent i q N k h z.val) + +lemma tuple_occupancy (z : goodEvent i q N) : + ∀ W : Submodule (ZMod q) (Fin (i+4)→ZMod q), + ((univ.filter (fun j : Fin k=>(flagPair (tuple i q N k h z j)).swap∈ + orthogonalRectangle Projectivization.rep Projectivization.rep W)).card:ℝ) ≤ + occupancyConstant i*log (q:ℝ) := by + intro W + let e : Fin k↪Fin N:= (Equiv.toEmbedding (Equiv.ofBijective Fin.rev (by + constructor + · intro a b hab;simpa using congrArg Fin.rev hab + · intro a;exact ⟨a.rev,by simp⟩))).trans (chosen i q N k h z.val).toEmbedding + have hh:=hits_embedding (rectangle W) z.val e + have hz : (hits (rectangle W) z.val:ℝ) by + rw [←a.mk_rep,←b.mk_rep]; congr 1) +local instance flat_JoinedInitialRectangles_3 : Finite (Projectivization K (Module.Dual K V)) := + Finite.of_injective Projectivization.rep (fun a b h => by + rw [←a.mk_rep,←b.mk_rep]; congr 1) +local instance flat_JoinedInitialRectangles_4 : Finite (Flag K V) := + Finite.of_injective (fun f : Flag K V => (f.point,f.dualPoint)) (by + intro a b h + cases a; cases b + cases h + rfl) +local instance flat_JoinedInitialRectangles_5 : Finite (Submodule K V) := by + let : Finite V := Module.finite_of_finite K + exact Finite.of_injective (fun W : Submodule K V => (W : Set V)) SetLike.coe_injective + +def IsRectangle (W : Submodule K V) (f : Flag K V) : Prop := + f.point.submodule≤W ∧ f.dualPoint.submodule≤W.dualAnnihilator + +omit [FiniteDimensional K V] in +lemma card_points (W : Submodule K V) : + Nat.card {a : Projectivization K V // a.submodule≤W} = + ∑ i∈range (Module.finrank K W),(Nat.card K)^i := by + rw [←Nat.card_congr (projectiveSubmoduleEquiv W)] + exact Projectivization.card_of_finrank K W rfl + +lemma card_rectangle_le (W : Submodule K V) : + Nat.card {f : Flag K V // IsRectangle W f} ≤ + (∑ i∈range (Module.finrank K W),(Nat.card K)^i)* + (∑ i∈range (Module.finrank K W.dualAnnihilator),(Nat.card K)^i) := by + let f : {f : Flag K V // IsRectangle W f} → + {a : Projectivization K V // a.submodule≤W} × + {b : Projectivization K (Module.Dual K V) // b.submodule≤W.dualAnnihilator} := + fun z => (⟨z.1.point,z.2.1⟩,⟨z.1.dualPoint,z.2.2⟩) + have hi : Function.Injective f := by + intro a b h + apply Subtype.ext + have hp := congrArg (fun z => z.1.val) h + have hd := congrArg (fun z => z.2.val) h + cases a with | mk a ha => + cases b with | mk b hb => + cases a; cases b + simp only [f] at hp hd + cases hp; cases hd; rfl + exact (Nat.card_le_card_of_injective f hi).trans_eq (by + rw [Nat.card_prod,card_points,card_points]) + +lemma card_subspaces_le : + Nat.card (Submodule K V)≤(Nat.card K)^(Module.finrank K V)^2 := by + let : Finite V := Module.finite_of_finite K + let : Finite (V→ₗ[K]V) := Finite.of_injective DFunLike.coe DFunLike.coe_injective + have hs : Function.Surjective (LinearMap.range : (V→ₗ[K]V)→Submodule K V) := by + intro W + obtain ⟨Q,hQ⟩ := W.exists_isCompl + exact ⟨W.projection Q hQ,W.range_projection hQ⟩ + apply (Nat.card_le_card_of_surjective _ hs).trans_eq + let : Fintype K := Fintype.ofFinite K + let : Fintype (V→ₗ[K]V) := Fintype.ofFinite _ + simpa only [Nat.card_eq_fintype_card,Module.finrank_linearMap,pow_two] using + (Module.card_eq_pow_finrank (K:=K) (V:=V→ₗ[K]V)) + +omit [Field K] [Finite K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] in +lemma sum_powers_le_two {q n : ℕ} (hq : 2≤q) (hn : 0 simp + | succ m ih => + rw [sum_range_succ] + simp only [Nat.succ_eq_add_one,Nat.add_sub_cancel] at * + have hm : 2*q^m≤q^(m+1) := by + rw [pow_succ] + simpa only [mul_comm] using Nat.mul_le_mul_left (q^m) hq + omega + +lemma card_rectangle_bound {d : ℕ} (hd : 1≤d) + (hdim : Module.finrank K V=d+1) (W : Submodule K V) : + Nat.card {f : Flag K V // IsRectangle W f} ≤ 4*(Nat.card K)^(d-1) := by + have hq : 2≤Nat.card K := Finite.one_lt_card (α:=K) + have hs := Subspace.finrank_add_finrank_dualAnnihilator_eq W + rw [hdim] at hs + let r := Module.finrank K W + let s := Module.finrank K W.dualAnnihilator + by_cases hr : r=0 + · apply (card_rectangle_le W).trans + change (∑ i∈range r,(Nat.card K)^i)*_≤_ + simp [hr] + by_cases ht : s=0 + · apply (card_rectangle_le W).trans + change _*(∑ i∈range s,(Nat.card K)^i)≤_ + simp [ht] + have he : (r-1)+(s-1)=d-1 := by dsimp [r,s] at *; omega + calc + _ ≤ (∑ i∈range r,(Nat.card K)^i)*(∑ i∈range s,(Nat.card K)^i) := card_rectangle_le W + _ ≤ (2*(Nat.card K)^(r-1))*(2*(Nat.card K)^(s-1)) := + Nat.mul_le_mul (sum_powers_le_two hq (Nat.pos_of_ne_zero hr)) + (sum_powers_le_two hq (Nat.pos_of_ne_zero ht)) + _ = _ := by rw [show (2*(Nat.card K)^(r-1))*(2*(Nat.card K)^(s-1))= + 4*((Nat.card K)^(r-1)*(Nat.card K)^(s-1)) by ring,←pow_add,he] + +lemma card_flags_lower {d : ℕ} (hd : 1≤d) (hdim : Module.finrank K V=d+1) : + (Nat.card K)^(2*d-1)≤Nat.card (Flag K V) := by + rw [card_flags hdim] + have h1 : (Nat.card K)^d≤∑ i∈range (d+1),(Nat.card K)^i := + single_le_sum (fun _ _ => Nat.zero_le _) (mem_range.mpr (by omega)) + have h2 : (Nat.card K)^(d-1)≤∑ i∈range d,(Nat.card K)^i := + single_le_sum (fun _ _ => Nat.zero_le _) (mem_range.mpr (by omega)) + have he : 2*d-1=d+(d-1) := by omega + rw [he,pow_add] + exact Nat.mul_le_mul h1 h2 + +lemma finite_flags : Finite (Flag K V) := inferInstance + +lemma finite_subspaces : Finite (Submodule K V) := inferInstance + +end +end SharpLogRamsey.InitialRectangles + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Construction/InitialTools.lean b/lean/OAI/Combinatorics/SharpRamsey/Construction/InitialTools.lean new file mode 100644 index 0000000000000000000000000000000000000000..5d73089df840b828cbcbd173ac9c774106052480 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Construction/InitialTools.lean @@ -0,0 +1,96 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.TrackedGeometry +import OAI.Combinatorics.SharpRamsey.Construction.RectangleStreamEvent + +namespace OAI + +section +namespace SharpLogRamsey +open Finset Real Selection Marking +open scoped Classical BigOperators +noncomputable section + +namespace Selection +variable {α : Type} [Fintype α] [Nonempty α] +def uniformLaw : Law α where + mass _:=1/(Fintype.card α:ℝ) + nonneg _:=by positivity + total:=by simp [Fintype.card_ne_zero] + +lemma uniformLaw_event (E : Finset α) : uniformLaw.event E=FiniteStreamTail.probability E:=by + simp only [Law.event,uniformLaw,sum_const,nsmul_eq_mul,FiniteStreamTail.probability] + ring + +lemma uniformLaw_conditioned {E : Finset α} (hE : (1:ℝ)/2 ≤ FiniteStreamTail.probability E) : + ∀ a,((uniformLaw.onEvent E (by rw [uniformLaw_event];linarith)).map (Subtype.val : E→α)).mass a ≤ + 2/(Fintype.card α:ℝ) := by + intro a + have hh:=uniformLaw.onEvent_map_le_two E (by rwa [uniformLaw_event]) id a + rw [Law.map_id] at hh + convert hh using 1 <;> simp [uniformLaw] + ring +end Selection + +variable {K V : Type} [Field K] [AddCommGroup V] [Module K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + +lemma rectangle_pair_iff [Finite K] [FiniteDimensional K V] (W : Submodule K V) (f : Flag K V) : + (flagPair f).swap∈orthogonalRectangle Projectivization.rep Projectivization.rep W ↔ + f∈RectangleStreamEvent.rectangle W := by + simp only [orthogonalRectangle,mem_filter,mem_univ,true_and,RectangleStreamEvent.rectangle, + InitialRectangles.IsRectangle,Projectivization.submodule_eq,Submodule.span_singleton_le_iff_mem] + rfl + +def initial_context {Ω : Type} [Fintype Ω] {k : ℕ} (p : Law Ω) + (F : Ω→Fin k→Flag K V) (B : ℝ) (hB : (Fintype.card (Flag K V):ℝ) ≤ B) : + ContextOutput p (fun x j=>flagPair (F x j)) k B 0 1 where + X:={x // p.mass x≠0} + Γ:=Unit + finiteX:=inferInstance + finiteΓ:=inferInstance + μ:=p.nullFree + source:=Subtype.val + msg:=fun _=>() + chosen:=fun _=>OrderEmbedding.ofStrictMono id (fun _ _ h=>h) + domains:=fun _ _=>univ.map ⟨flagPair,flagPair_injective⟩ + supported:=fun x=>x.property + hit:=fun x j=>mem_map.mpr ⟨F x.val j,mem_univ _,rfl⟩ + size:=by intro _ _;simpa only [card_map,card_univ] using hB + dominated:=by + intro x + have hh:=p.nullFree_map id + rw [Law.map_id] at hh + have he : p.nullFree.map (Subtype.val : {x // p.mass x≠0}→Ω)=p:=by + convert hh using 1 + congr! + rw [he,one_mul] + cost:=by + have hh:=entropy_le_log_card (p.nullFree.map (fun _=>())) univ (by simp) + simpa using hh + +omit [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] in +lemma independent_selected {N k : ℕ} (z : Fin N→Flag K V) + (h : k ≤ (flagGraph K V z).indepNum) : + ∃ e : Fin k↪o Fin N,Consistent (fun j=>z (e j)) := by + obtain ⟨S,hS⟩:=(flagGraph K V z).exists_isNIndepSet_indepNum + obtain ⟨T,hTS,hTk⟩:=exists_subset_card_eq (s:=S) (n:=k) (by rwa [hS.card_eq]) + let e:=T.orderEmbOfFin hTk + refine ⟨e,?_⟩ + have hc : ConsistentOn z T:=(consistentOn_iff_compl_isClique _ _).mpr (by + rw [SimpleGraph.isClique_compl] + exact hS.isIndepSet.mono (by exact_mod_cast hTS)) + intro a b hab hi + exact hc (e a) (T.orderEmbOfFin_mem hTk a) (e b) (T.orderEmbOfFin_mem hTk b) (e.strictMono hab) hi + +omit [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] in +lemma selected_reverse_consistent {N k : ℕ} (z : Fin N→Flag K V) + (e : Fin k↪o Fin N) (hc : Consistent (fun j=>z (e j))) : + ScanConsistent ((List.ofFn (fun j=>flagPair (z (e j.rev)))).map toScan) := by + have hh:=backwardScan_consistent (fun j=>z (e j)) hc + simpa only [backwardScan,List.map_ofFn,Function.comp_def,flagPair,toScan] using hh +end +end SharpLogRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Construction/PrimeConstruction.lean b/lean/OAI/Combinatorics/SharpRamsey/Construction/PrimeConstruction.lean new file mode 100644 index 0000000000000000000000000000000000000000..2aba4f85976fab4454446f392f205c152acf6d42 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Construction/PrimeConstruction.lean @@ -0,0 +1,35 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Construction.GraphWitness +import OAI.Combinatorics.SharpRamsey.Construction.SourceSizes +import OAI.Combinatorics.SharpRamsey.Bounds.Lower + +namespace OAI + +section +namespace SharpLogRamsey.LowerTransfer +open Real Filter +open scoped Topology +noncomputable section + +theorem actual_prime_construction (i : ℕ) : PrimeConstruction (i+3) := by + intro η hη hηu + have hσ:=Marking.eventually_graph_witness i η hη (by linarith : η ≤ 1) + have ht : Tendsto (fun q : ℕ=>log (q:ℝ)) atTop atTop:= + tendsto_log_atTop.comp tendsto_natCast_atTop_atTop + filter_upwards [ht.eventually hσ,InitialExperiment.eventually_source_sizes i η hη.le] + with q hgraph hsize + intro hq + have : Fact q.Prime:=⟨hq⟩ + have hq0 : (0:ℝ) < q:=by exact_mod_cast hq.pos + exact hgraph q hsize.1 (exp_log hq0) _ _ hsize.2.2.1 hsize.2.2.2.1 + hsize.2.2.2.2.1 hsize.2.2.2.2.2.1 hsize.2.2.2.2.2.2 + +theorem prime_construction (d : ℕ) (hd : 5 ≤ d) : PrimeConstruction d := by + have he : d-3+3=d:=by omega + simpa only [he] using actual_prime_construction (d-3) +end +end SharpLogRamsey.LowerTransfer + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Construction/RectangleStreamEvent.lean b/lean/OAI/Combinatorics/SharpRamsey/Construction/RectangleStreamEvent.lean new file mode 100644 index 0000000000000000000000000000000000000000..4e555886d7e23cd894382dbbaf686b3f969e6c1c --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Construction/RectangleStreamEvent.lean @@ -0,0 +1,157 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Construction.InitialRectangles +import OAI.Combinatorics.SharpRamsey.Construction.FiniteStreamTail + +namespace OAI + +section +namespace SharpLogRamsey.RectangleStreamEvent +open Finset Real InitialRectangles FiniteStreamTail +open scoped Classical BigOperators +noncomputable section +variable {K V : Type*} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedRectangleStreamEvent_1 : Fintype (Flag K V) := @Fintype.ofFinite _ (finite_flags (K:=K) (V:=V)) +local instance flat_JoinedRectangleStreamEvent_2 : Fintype (Submodule K V) := @Fintype.ofFinite _ (finite_subspaces (K:=K) (V:=V)) + +def rectangle (W : Submodule K V) : Finset (Flag K V) := + univ.filter (IsRectangle W) + +lemma rectangle_card {d : ℕ} (hd : 1≤d) (hdim : Module.finrank K V=d+1) + (W : Submodule K V) : (rectangle W).card≤4*(Nat.card K)^(d-1) := by + convert card_rectangle_bound hd hdim W using 1 + rw [Nat.card_eq_fintype_card,Fintype.card_subtype] + rfl + +lemma flags_card_pos {d : ℕ} (hd : 1≤d) (hdim : Module.finrank K V=d+1) : + 0∃ W : Submodule K V, + (((d+1)^2:ℕ)+5:ℝ)/log 2*log (Nat.card K)≤hits (rectangle W) z)) ≤ + 1/(Nat.card K:ℝ) := by + have hf := flags_card_pos hd hdim + let : Nonempty (Flag K V) := Fintype.card_pos_iff.mp hf + let t : ℝ := (((d+1)^2:ℕ)+5:ℝ)/log 2*log (Nat.card K) + have hs := simultaneous_tail (rectangle (K:=K) (V:=V)) N t (4*log (Nat.card K)) + (rectangle_mean hd hdim hN) + have hc : (Fintype.card (Submodule K V):ℝ)≤(Nat.card K:ℝ)^((d+1)^2) := by + have h := card_subspaces_le (K:=K) (V:=V) + rw [hdim,Nat.card_eq_fintype_card] at h + exact_mod_cast h + calc + _ ≤ (Fintype.card (Submodule K V):ℝ)*exp (4*log (Nat.card K)-t*log 2) := hs + _ ≤ (Nat.card K:ℝ)^((d+1)^2)*exp (4*log (Nat.card K)-t*log 2) := + mul_le_mul_of_nonneg_right hc (le_of_lt (exp_pos _)) + _ = _ := union_exponent _ (by exact_mod_cast (show 0 + ∃ W : Submodule K V, + (((d+1)^2:ℕ)+5:ℝ)/log 2*log (Nat.card K)≤hits (rectangle W) z)) ≤ + 1/(Nat.card K:ℝ) := by + apply simultaneous_rectangle_tail hd hdim + apply Nat.floor_le + apply mul_nonneg (by positivity) + apply log_nonneg + exact_mod_cast (Nat.le_of_lt (Finite.one_lt_card (α:=K))) + +omit [Finite K] in + +lemma dual_rectangle (U : Submodule K (Module.Dual K V)) (f : Flag K V) : + IsRectangle U.dualCoannihilator f ↔ + f.dualPoint.submodule≤U ∧ f.point.submodule≤U.dualCoannihilator := by + simp only [IsRectangle,Subspace.dualCoannihilator_dualAnnihilator_eq,and_comm] + +lemma inherited_occupancy {N n : ℕ} (z : Fin N→Flag K V) (e : Fin n↪Fin N) + (M : ℝ) (h : ∀ W : Submodule K V,(hits (rectangle W) z:ℝ)∀ W : Submodule K V, + (hits (rectangle W) z:ℝ)<(((d+1)^2:ℕ)+5:ℝ)/log 2*log (Nat.card K))) := by + let : Nonempty (Flag K V) := Fintype.card_pos_iff.mp (flags_card_pos hd hdim) + let B := univ.filter (fun z : Fin N→Flag K V=>∃ W : Submodule K V, + (((d+1)^2:ℕ)+5:ℝ)/log 2*log (Nat.card K)≤hits (rectangle W) z) + have he : Bᶜ=univ.filter (fun z : Fin N→Flag K V=>∀ W : Submodule K V, + (hits (rectangle W) z:ℝ)<(((d+1)^2:ℕ)+5:ℝ)/log 2*log (Nat.card K)) := by + ext z + simp only [B,mem_compl,mem_filter,mem_univ,true_and,not_exists,not_le] + rw [←he] + have hc : probability Bᶜ=1-probability B := by + convert probability_compl B using 1 + congr 1 + ext z + simp + rw [hc] + exact sub_le_sub_left (simultaneous_rectangle_tail hd hdim hN) 1 + +theorem source_good_probability {d : ℕ} (hd : 1≤d) (hdim : Module.finrank K V=d+1) : + (1:ℝ)/2 ≤ + probability (univ.filter (fun z : Fin ⌊(Nat.card K:ℝ)^d*log (Nat.card K)⌋₊→Flag K V=> + ∀ W : Submodule K V, + (hits (rectangle W) z:ℝ)<(((d+1)^2:ℕ)+5:ℝ)/log 2*log (Nat.card K))) := by + have hq : 2≤(Nat.card K:ℝ) := by exact_mod_cast (Finite.one_lt_card (α:=K)) + have hp : 0<(Nat.card K:ℝ) := by linarith + have hh : 1/(Nat.card K:ℝ)≤1/2 := (div_le_iff₀ hp).mpr (by linarith) + apply (show (1:ℝ)/2≤1-1/(Nat.card K:ℝ) by linarith).trans + apply simultaneous_good_probability hd hdim + exact Nat.floor_le (mul_nonneg (by positivity) (log_nonneg (by linarith))) + +end +end SharpLogRamsey.RectangleStreamEvent + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Construction/SourceSizes.lean b/lean/OAI/Combinatorics/SharpRamsey/Construction/SourceSizes.lean new file mode 100644 index 0000000000000000000000000000000000000000..d7c89ef4ca8092f426261d8429840f27db5c3470 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Construction/SourceSizes.lean @@ -0,0 +1,47 @@ +import Mathlib + +namespace OAI + +section +namespace SharpLogRamsey.InitialExperiment +open Real Filter +open scoped Topology +noncomputable section + +lemma eventually_source_sizes (i : ℕ) (η : ℝ) (hη : 0 ≤ η) : + ∀ᶠ q : ℕ in atTop, + 3 ≤ q ∧ 1 ≤ log (q:ℝ) ∧ + 0 < ⌊(q:ℝ)*(log (q:ℝ))^(1+η)⌋₊ ∧ + ⌊(q:ℝ)*(log (q:ℝ))^(1+η)⌋₊ ≤ ⌊(q:ℝ)^(i+3)*log (q:ℝ)⌋₊ ∧ + (⌊(q:ℝ)*(log (q:ℝ))^(1+η)⌋₊:ℝ) ≤ (q:ℝ)*(log (q:ℝ))^(1+η) ∧ + ((q:ℝ)*(log (q:ℝ))^(1+η))/2 ≤ (⌊(q:ℝ)*(log (q:ℝ))^(1+η)⌋₊:ℝ) ∧ + (⌊(q:ℝ)^(i+3)*log (q:ℝ)⌋₊:ℝ) ≤ (q:ℝ)^(i+3)*log (q:ℝ) := by + have hsmall := (isLittleO_log_rpow_rpow_atTop η (by norm_num : (0:ℝ)<1)).bound (by norm_num : (0:ℝ)<1) + filter_upwards [tendsto_natCast_atTop_atTop.eventually hsmall, + (tendsto_log_atTop.comp tendsto_natCast_atTop_atTop).eventually_ge_atTop 1, + eventually_ge_atTop (3:ℕ)] with q hsmall hl hq + change 1 ≤ log (q:ℝ) at hl + have hq1 : (1:ℝ) ≤ q:=by exact_mod_cast (show 1 ≤ q by omega) + have hq2 : (2:ℝ) ≤ q:=by exact_mod_cast (show 2 ≤ q by omega) + have hq0 : (0:ℝ) < q:=by linarith + have hl0 : 0 < log (q:ℝ):=by linarith + simp only [Real.norm_eq_abs,abs_of_pos (rpow_pos_of_pos hl0 _), + rpow_one,abs_of_pos hq0,one_mul] at hsmall + have hpow : 1 ≤ (log (q:ℝ))^(1+η):=one_le_rpow hl (by linarith) + have hQ : 2 ≤ (q:ℝ)*(log (q:ℝ))^(1+η):=by nlinarith only [hpow,hq2] + have hf : (⌊(q:ℝ)*(log (q:ℝ))^(1+η)⌋₊:ℝ)+1 > (q:ℝ)*(log (q:ℝ))^(1+η):=Nat.lt_floor_add_one _ + have hlower : ((q:ℝ)*(log (q:ℝ))^(1+η))/2 ≤ (⌊(q:ℝ)*(log (q:ℝ))^(1+η)⌋₊:ℝ):=by linarith + refine ⟨hq,hl,?_,?_,Nat.floor_le (by positivity),hlower,Nat.floor_le (by positivity)⟩ + · exact (Nat.one_le_floor_iff _).mpr (by linarith) + · apply Nat.floor_mono + calc + _ = (q:ℝ)*log (q:ℝ)*(log (q:ℝ))^η:=by rw [rpow_add hl0,rpow_one];ring + _ ≤ (q:ℝ)*log (q:ℝ)*(q:ℝ):=mul_le_mul_of_nonneg_left hsmall (by positivity) + _ = (q:ℝ)^2*log (q:ℝ):=by ring + _ ≤ _:=mul_le_mul_of_nonneg_right (pow_le_pow_right₀ hq1 (by omega : 2 ≤ i+3)) hl0.le +end +end SharpLogRamsey.InitialExperiment + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Entropy/AnchorEventsRealized.lean b/lean/OAI/Combinatorics/SharpRamsey/Entropy/AnchorEventsRealized.lean new file mode 100644 index 0000000000000000000000000000000000000000..587e6771ef476b6a265d0bcc5ce1f7d8d0f1af24 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Entropy/AnchorEventsRealized.lean @@ -0,0 +1,478 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Entropy.WitnessList + +namespace OAI + +/-! High moments, finite-field subspaces, and incidence bounds. -/ + +section +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open scoped BigOperators +open MeasureTheory ProbabilityTheory +open scoped BigOperators ENNReal NNReal +namespace SharpRamseyFive.ResidualCertificate +variable {V : Type*} [Fintype V] [DecidableEq V] +section SharedHitGeometry +open scoped Classical +variable {D B : Type*} [Fintype D] [DecidableEq D] [Fintype B] [DecidableEq B] +omit [Fintype D] [Fintype B] in +lemma anchorEvents_realized (hit : B → D → Prop) (C : Finset (B × D)) + (A : Finset D) (r : A → B) (h : ∀ d : A, hit (r d) d.val) : + Realized hit (anchorEvents C A r) := by + intro p hp + obtain ⟨d, _, rfl⟩ := Finset.mem_image.mp hp + exact h d + +omit [Fintype V] [Fintype D] in + +theorem anchor_step_witnesses (s : V → Finset D) (hit : B → D → Prop) + (E : Finset V) (C : Finset (B × D)) (v : V) (a : ℕ) + (hC : DictionaryInvariant s E C) (hreal : Realized hit C) + (ha : a ≤ (touchedToEncoded s hit E v).card) : + ∃ (A : Finset D) (r : A → B), A.card = a ∧ + A ⊆ s v ∧ A ⊆ encodedDirections s E ∧ + (∀ d : A, hit (r d) d.val) ∧ + Disjoint C (anchorEvents C A r) ∧ + Realized hit (C ∪ anchorEvents C A r) ∧ + DictionaryInvariant s (insert v E) (C ∪ anchorEvents C A r) ∧ + (C ∪ anchorEvents C A r).card ≤ C.card + a := by + classical + obtain ⟨A, hA, hAc⟩ := Finset.exists_subset_card_eq ha + have hh (d : A) : ∃ r, hit r d.val := (Finset.mem_filter.mp (hA d.property)).2 + choose r hr using hh + have hAs : A ⊆ s v := fun d hd => (Finset.mem_inter.mp + (Finset.mem_filter.mp (hA hd)).1).1 + have hAE : A ⊆ encodedDirections s E := fun d hd => (Finset.mem_inter.mp + (Finset.mem_filter.mp (hA hd)).1).2 + refine ⟨A, r, hAc, hAs, hAE, hr, anchorEvents_fresh C A r, + realized_union hit hreal (anchorEvents_realized hit C A r hr), ?_, ?_⟩ + · unfold DictionaryInvariant + rw [paidDirections_union] + apply Finset.union_subset + · exact hC.trans (encodedDirections_mono s (Finset.subset_insert _ _)) + · exact (anchorEvents_directions C A r).trans + (hAE.trans (encodedDirections_mono s (Finset.subset_insert _ _))) + · exact (Finset.card_union_le _ _).trans (Nat.add_le_add_left + ((anchorEvents_card C A r).trans_eq hAc) _) + +noncomputable def pairEvents (T : Finset B) (d : T → D) : Finset (B × D) := + T.attach.image (fun r => (r.val, d r)) + +omit [Fintype D] [Fintype B] in +lemma pairEvents_card (T : Finset B) (d : T → D) : + (pairEvents T d).card = T.card := by + rw [pairEvents, Finset.card_image_of_injective] + · exact Finset.card_attach + · intro r r' he + exact Subtype.ext (congrArg Prod.fst he) + +omit [Fintype D] [Fintype B] in +lemma pairEvents_realized (hit : B → D → Prop) (T : Finset B) (d : T → D) + (h : ∀ r : T, hit r.val (d r)) : Realized hit (pairEvents T d) := by + intro p hp + obtain ⟨r, _, rfl⟩ := Finset.mem_image.mp hp + exact h r + +omit [Fintype V] [Fintype D] in + +theorem pair_step_witnesses (s : V → Finset D) (hit : B → D → Prop) + (E : Finset V) (C : Finset (B × D)) (v u : V) (K : ℕ) + (hC : DictionaryInvariant s E C) (hreal : Realized hit C) + (hp : K ≤ (sharedBatches (outsideDirections s E) hit v u).card) : + ∃ (T : Finset B) (d : T → D), T.card = K ∧ + (∀ r : T, d r ∈ s v ∩ s u ∧ d r ∉ encodedDirections s E ∧ hit r.val (d r)) ∧ + Disjoint C (pairEvents T d) ∧ Realized hit (C ∪ pairEvents T d) ∧ + DictionaryInvariant s (insert v (insert u E)) (C ∪ pairEvents T d) ∧ + (C ∪ pairEvents T d).card = C.card + K := by + classical + obtain ⟨T, hT, hTc⟩ := Finset.exists_subset_card_eq hp + have hh (r : T) : ∃ d, d ∈ s v ∩ s u ∧ d ∉ encodedDirections s E ∧ hit r.val d := by + obtain ⟨d, hd, hr⟩ := (Finset.mem_filter.mp (hT r.property)).2 + obtain ⟨hdv, hdu⟩ := Finset.mem_inter.mp hd + exact ⟨d, Finset.mem_inter.mpr ⟨(Finset.mem_sdiff.mp hdv).1, + (Finset.mem_sdiff.mp hdu).1⟩, (Finset.mem_sdiff.mp hdv).2, hr⟩ + choose d hd using hh + have hfresh : Disjoint C (pairEvents T d) := by + apply Finset.disjoint_left.mpr + intro p hp he + obtain ⟨r, _, rfl⟩ := Finset.mem_image.mp he + exact (hd r).2.1 (hC (Finset.mem_image_of_mem Prod.snd hp)) + refine ⟨T, d, hTc, hd, hfresh, + realized_union hit hreal (pairEvents_realized hit T d (fun r => (hd r).2.2)), ?_, ?_⟩ + · unfold DictionaryInvariant + rw [paidDirections_union] + apply Finset.union_subset + · exact hC.trans (encodedDirections_mono s ((Finset.subset_insert _ _).trans + (Finset.subset_insert _ _))) + · intro z hz + obtain ⟨p, hp, rfl⟩ := Finset.mem_image.mp hz + obtain ⟨r, _, rfl⟩ := Finset.mem_image.mp hp + exact Finset.mem_biUnion.mpr ⟨v, Finset.mem_insert_self _ _, + (Finset.mem_inter.mp (hd r).1).1⟩ + · rw [Finset.card_union_of_disjoint hfresh, pairEvents_card, hTc] + +inductive PaidStep (s : V → Finset D) (hit : B → D → Prop) (a K : ℕ) : + (Finset V × Finset (B × D)) → (Finset V × Finset (B × D)) → Prop + | anchor (E : Finset V) (C : Finset (B × D)) (v : V) (hv : v ∉ E) + (A : Finset D) (hA : A.card = a) (hAs : A ⊆ s v) + (hAE : A ⊆ encodedDirections s E) (r : A → B) (hr : ∀ d : A, hit (r d) d.val) : + PaidStep s hit a K (E, C) (insert v E, C ∪ anchorEvents C A r) + | pair (E : Finset V) (C : Finset (B × D)) (v u : V) + (hv : v ∉ E) (hu : u ∉ E) (hne : v ≠ u) + (T : Finset B) (hT : T.card = K) (d : T → D) + (hd : ∀ r : T, d r ∈ s v ∩ s u ∧ d r ∉ encodedDirections s E ∧ hit r.val (d r)) : + PaidStep s hit a K (E, C) (insert v (insert u E), C ∪ pairEvents T d) + +omit [Fintype V] in +omit [Fintype D] [Fintype B] in +lemma paidStep_realized (s : V → Finset D) (hit : B → D → Prop) (a K : ℕ) + {Z Z' : Finset V × Finset (B × D)} (h : PaidStep s hit a K Z Z') + (hreal : Realized hit Z.2) : Realized hit Z'.2 := by + cases h with + | anchor E C v hv A hA hAs hAE r hr => + exact realized_union hit hreal (anchorEvents_realized hit C A r hr) + | pair E C v u hv hu hne T hT d hd => + exact realized_union hit hreal (pairEvents_realized hit T d (fun r => (hd r).2.2)) +omit [Fintype V] [Fintype D] [Fintype B] in + +lemma paidStep_dictionary (s : V → Finset D) (hit : B → D → Prop) (a K : ℕ) + {Z Z' : Finset V × Finset (B × D)} (h : PaidStep s hit a K Z Z') + (hC : DictionaryInvariant s Z.1 Z.2) : DictionaryInvariant s Z'.1 Z'.2 := by + cases h with + | anchor E C v hv A hA hAs hAE r hr => + unfold DictionaryInvariant + rw [paidDirections_union] + exact Finset.union_subset + (hC.trans (encodedDirections_mono s (Finset.subset_insert _ _))) + ((anchorEvents_directions C A r).trans + (hAE.trans (encodedDirections_mono s (Finset.subset_insert _ _)))) + | pair E C v u hv hu hne T hT d hd => + unfold DictionaryInvariant + rw [paidDirections_union] + refine Finset.union_subset + (hC.trans (encodedDirections_mono s ((Finset.subset_insert _ _).trans + (Finset.subset_insert _ _)))) ?_ + intro z hz + obtain ⟨p, hp, rfl⟩ := Finset.mem_image.mp hz + obtain ⟨r, _, rfl⟩ := Finset.mem_image.mp hp + exact Finset.mem_biUnion.mpr ⟨v, Finset.mem_insert_self _ _, + (Finset.mem_inter.mp (hd r).1).1⟩ + +omit [Fintype V] in +omit [Fintype D] [Fintype B] in +lemma paidStep_cost (s : V → Finset D) (hit : B → D → Prop) (a K : ℕ) (haK : a ≤ K) + {Z Z' : Finset V × Finset (B × D)} (h : PaidStep s hit a K Z Z') : + Z'.2.card + K * Z.1.card ≤ Z.2.card + K * Z'.1.card := by + cases h with + | anchor E C v hv A hA hAs hAE r hr => + simp only [Finset.card_insert_of_notMem hv, Nat.mul_add, Nat.mul_one] + have hc := (Finset.card_union_le C (anchorEvents C A r)).trans + (Nat.add_le_add_left ((anchorEvents_card C A r).trans_eq hA) C.card) + omega + | pair E C v u hv hu hne T hT d hd => + have hv' : v ∉ insert u E := by simp [hne, hv] + simp only [Finset.card_insert_of_notMem hv', Finset.card_insert_of_notMem hu, + Nat.mul_add, Nat.mul_one] + have hc := Finset.card_union_le C (pairEvents T d) + rw [pairEvents_card, hT] at hc + omega + +omit [Fintype V] [Fintype D] in + +lemma encodingStep_lift (s : V → Finset D) (hit : B → D → Prop) (a K : ℕ) + {E F : Finset V} (h : EncodingStep s hit a K E F) + (C : Finset (B × D)) (hC : DictionaryInvariant s E C) (hreal : Realized hit C) : + ∃ C', PaidStep s hit a K (E, C) (F, C') ∧ + DictionaryInvariant s F C' ∧ Realized hit C' := by + cases h with + | anchor v hv ha => + obtain ⟨A, r, hAc, hAs, hAE, hr, _, hh, hdict, _⟩ := + anchor_step_witnesses s hit E C v a hC hreal ha + exact ⟨_, .anchor E C v hv A hAc hAs hAE r hr, hdict, hh⟩ + | pair v u hv hu hne hp => + obtain ⟨T, d, hTc, hd, _, hh, hdict, _⟩ := + pair_step_witnesses s hit E C v u K hC hreal hp + exact ⟨_, .pair E C v u hv hu hne T hTc d hd, hdict, hh⟩ +omit [Fintype V] [Fintype D] in + +lemma encoding_path_lift (s : V → Finset D) (hit : B → D → Prop) (a K : ℕ) + {E F : Finset V} (h : Relation.ReflTransGen (EncodingStep s hit a K) E F) + (C : Finset (B × D)) (hC : DictionaryInvariant s E C) (hreal : Realized hit C) : + ∃ C', Relation.ReflTransGen (PaidStep s hit a K) (E, C) (F, C') ∧ + DictionaryInvariant s F C' ∧ Realized hit C' := by + induction h with + | refl => exact ⟨C, .refl, hC, hreal⟩ + | @tail F G h hFG ih => + obtain ⟨C', hpath, hc', hr'⟩ := ih + obtain ⟨C'', hstep, hc'', hr''⟩ := encodingStep_lift s hit a K hFG C' hc' hr' + exact ⟨C'', hpath.tail hstep, hc'', hr''⟩ + +omit [Fintype V] in +omit [Fintype D] [Fintype B] in + +lemma paid_path_cost (s : V → Finset D) (hit : B → D → Prop) (a K : ℕ) (haK : a ≤ K) + {Z Z' : Finset V × Finset (B × D)} + (h : Relation.ReflTransGen (PaidStep s hit a K) Z Z') : + Z'.2.card + K * Z.1.card ≤ Z.2.card + K * Z'.1.card := by + induction h with + | refl => omega + | @tail F G h hFG ih => + have hc := paidStep_cost s hit a K haK hFG + omega + +omit [Fintype D] in + +theorem terminal_paid_certificate (s : V → Finset D) (hit : B → D → Prop) + (a K : ℕ) (haK : a ≤ K) (E : Finset V) : + ∃ F C, Relation.ReflTransGen (PaidStep s hit a K) (E, ∅) (F, C) ∧ + DictionaryInvariant s F C ∧ Realized hit C ∧ + C.card ≤ K * Fintype.card V ∧ (paidDirections C).card ≤ K * Fintype.card V ∧ + (∀ v ∉ F, (touchedToEncoded s hit F v).card < a) ∧ + ∀ v ∉ F, ∀ u ∉ F, v ≠ u → + (sharedBatches (outsideDirections s F) hit v u).card < K := by + classical + obtain ⟨F, hF, ha, hp⟩ := exists_terminal_encoding s hit a K E + have hc : DictionaryInvariant s E (∅ : Finset (B × D)) := by + simp [DictionaryInvariant, paidDirections] + have hr : Realized hit (∅ : Finset (B × D)) := by simp [Realized] + obtain ⟨C, hpath, hC, hreal⟩ := encoding_path_lift s hit a K hF ∅ hc hr + have hcost := paid_path_cost s hit a K haK hpath + simp only [Finset.card_empty, zero_add] at hcost + have hbound : C.card ≤ K * Fintype.card V := by + have hcard := Nat.mul_le_mul_left K (Finset.card_le_univ F) + omega + exact ⟨F, C, hpath, hC, hreal, hbound, + Finset.card_image_le.trans hbound, ha, hp⟩ + +end SharedHitGeometry + +end SharpRamseyFive.ResidualCertificate + +namespace SharpRamseyFive.CertificateCover +open SharpRamseyFive.StaticCertificates +open SharpRamseyFive.CertificateEnumeration +open SharpRamseyFive.WeightedPrograms +open SharpRamseyFive.ResidualCertificate +open scoped BigOperators + +variable {V H D B : Type*} [Fintype V] [DecidableEq V] + [Fintype H] [DecidableEq H] [Fintype D] [DecidableEq D] + [Fintype B] [DecidableEq B] +variable (lines : H → Finset D) + + def Agrees (f : V → H) (E : Finset V) (s : State V H D B) : Prop := + ∀ v ∈ E, s.1 v = f v + +omit [Fintype V] [Fintype H] [DecidableEq H] [Fintype D] [DecidableEq D] [Fintype B] [DecidableEq B] in +lemma agrees_update (f : V → H) (E : Finset V) (s : State V H D B) + (hs : Agrees f E s) (v : V) (C : Finset (B × D)) : + Agrees f (insert v E) (Function.update s.1 v (f v), C) := by + intro u hu + rcases Finset.mem_insert.mp hu with rfl | hu + · simp + · by_cases he : u = v + · subst u; simp + · simpa [Function.update_of_ne he] using hs u hu + +noncomputable def anchorName (C : Finset (B × D)) (S : Finset D) + (d : D) (hd : d ∈ S) (r : B) : AnchorChoice C S := + if he : d ∈ dictionary C then .inl ⟨d, Finset.mem_inter.mpr ⟨hd, he⟩⟩ + else .inr (r, ⟨d, Finset.mem_sdiff.mpr ⟨hd, he⟩⟩) + +omit [Fintype D] [Fintype B] [DecidableEq B] in +lemma anchorName_direction (C : Finset (B × D)) (S : Finset D) + (d : D) (hd : d ∈ S) (r : B) : (anchorName C S d hd r).direction = d := by + unfold anchorName + split_ifs <;> rfl + +omit [Fintype D] [Fintype B] [DecidableEq B] in +lemma anchorName_realized (hit : B → D → Prop) (C : Finset (B × D)) + (S : Finset D) (d : D) (hd : d ∈ S) (r : B) (hr : hit r d) : + Realized hit (anchorName C S d hd r).requirements := by + unfold anchorName + split_ifs <;> simp_all [AnchorChoice.requirements, Realized] + +omit [Fintype D] [Fintype B] [DecidableEq B] in +lemma anchor_req_card {C : Finset (B × D)} {S : Finset D} (a : AnchorChoice C S) : + a.requirements.card ≤ 1 := by + cases a <;> simp [AnchorChoice.requirements] + +omit [Fintype D] [Fintype B] [DecidableEq B] in +lemma anchor_req_directions {C : Finset (B × D)} {S : Finset D} + (a : AnchorChoice C S) : paidDirections a.requirements ⊆ {a.direction} := by + cases a <;> simp [AnchorChoice.requirements, AnchorChoice.direction, paidDirections] +omit [Fintype D] [Fintype B] [DecidableEq B] in + +lemma anchor_req_disjoint {C : Finset (B × D)} {S T : Finset D} + (a : AnchorChoice C S) (b : AnchorChoice C T) (hne : a.direction ≠ b.direction) : + Disjoint a.requirements b.requirements := by + apply Finset.disjoint_left.mpr + intro p ha hb + have ha' := anchor_req_directions a (Finset.mem_image_of_mem Prod.snd ha) + have hb' := anchor_req_directions b (Finset.mem_image_of_mem Prod.snd hb) + exact hne ((Finset.mem_singleton.mp ha').symm.trans (Finset.mem_singleton.mp hb')) + +omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in +omit [Fintype D] in +lemma rawCost_eq_weight (rate : D → ℝ≥0) (denom : ℝ) (K : ℕ) (low : Bool) + (s : State V H D B) (a : Action lines K s) + (henabled : ∀ c : OneChoice lines s, a = .inr (.inl c) → low = true) : + rawCost lines rate denom K low s a = + weight (fun p : B × D => rate p.2) (newEvents lines K s a) / + denom ^ degree lines K s a := by + rcases a with a | a + · simp [rawCost, newEvents, degree, weight] + rcases a with a | a + · rw [henabled a rfl] + simp [rawCost, newEvents, degree, oneCost, AnchorChoice.weight] + rcases a with a | a + · simp only [rawCost, newEvents, degree, twoCost, pow_one] + rw [weight_union_fresh _ _ _ (anchor_req_disjoint _ _ a.2.2.2.2.2.property.1), + AnchorChoice.weight, AnchorChoice.weight] + · rfl + +omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in +omit [Fintype D] in +lemma newEvents_card (K : ℕ) (hK : 2 ≤ K) (s : State V H D B) (a : Action lines K s) : + (newEvents lines K s a).card ≤ K * degree lines K s a := by + rcases a with a | a + · simp [newEvents, degree] + rcases a with a | a + · simpa [newEvents, degree] using (anchor_req_card a.2.2.1).trans (by omega : 1 ≤ K) + rcases a with a | a + · change (a.2.2.2.1.requirements ∪ a.2.2.2.2.1.requirements).card ≤ K * 1 + have hc := Finset.card_union_le a.2.2.2.1.requirements a.2.2.2.2.1.requirements + have h1 := anchor_req_card a.2.2.2.1 + have h2 := anchor_req_card a.2.2.2.2.1 + omega + · simp only [newEvents, degree, witnessRequirements_card] + have ht := (Finset.mem_powersetCard.mp a.2.2.2.2.1.property).2 + omega + + def Enabled (K : ℕ) (low : Bool) (s : State V H D B) (a : Action lines K s) : Prop := + ∀ c : OneChoice lines s, a = .inr (.inl c) → low = true + +omit [Fintype H] [DecidableEq H] in +omit [Fintype D] in + +lemma step_weight (rate : D → ℝ≥0) (denom : ℝ) (hdenom : denom ≠ 0) + (K : ℕ) (low : Bool) (s : State V H D B) (a : Action lines K s) + (he : Enabled lines K low s a) (hs : s.2.card ≤ K * Fintype.card V) : + weight (fun p : B × D => rate p.2) (advance lines K s a).2 = + weight (fun p : B × D => rate p.2) s.2 * + programCost lines rate denom K low s a * denom ^ degree lines K s a := by + rw [programCost, ite_eq_left hs, rawCost_eq_weight lines rate denom K low s a he] + rw [advance, weight_union_fresh _ _ _ (newEvents_fresh lines K s a)] + field_simp + + def Coherent (f : V → H) (hit : B → D → Prop) (K : ℕ) + (E : Finset V) (s : State V H D B) : Prop := + Agrees f E s ∧ DictionaryInvariant (fun v => lines (f v)) E s.2 ∧ + Realized hit s.2 ∧ s.2.card ≤ K * E.card +omit [Fintype V] [Fintype H] [DecidableEq H] in +omit [Fintype D] in + +lemma coherent_step (f : V → H) (hit : B → D → Prop) (K : ℕ) (hK : 2 ≤ K) + (E F : Finset V) (s : State V H D B) (hs : Coherent lines f hit K E s) + (a : Action lines K s) (hEF : E ⊆ F) + (hag : Agrees f F (advance lines K s a)) + (hdict : paidDirections (newEvents lines K s a) ⊆ encodedDirections (fun v => lines (f v)) F) + (hreal : Realized hit (newEvents lines K s a)) + (hcard : F.card = E.card + degree lines K s a) : + Coherent lines f hit K F (advance lines K s a) := by + refine ⟨hag, ?_, realized_union hit hs.2.2.1 hreal, ?_⟩ + · change paidDirections (s.2 ∪ newEvents lines K s a) ⊆ _ + rw [paidDirections_union] + exact Finset.union_subset + (hs.2.1.trans (encodedDirections_mono _ hEF)) hdict + · change (s.2 ∪ newEvents lines K s a).card ≤ _ + apply (Finset.card_union_le _ _).trans + calc + _ ≤ K * E.card + K * degree lines K s a := + Nat.add_le_add hs.2.2.2 (newEvents_card lines K hK s a) + _ = _ := by rw [hcard, Nat.mul_add] + +omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in +omit [Fintype D] [DecidableEq B] in +lemma touched_anchor (f : V → H) (hit : B → D → Prop) + (E : Finset V) (s : State V H D B) (hs : Agrees f E s) (v : V) (d : D) + (hd : d ∈ touchedToEncoded (fun v => lines (f v)) hit E v) : + ∃ u ∈ E, ∃ x : AnchorChoice s.2 (lines (s.1 u)), + x.direction = d ∧ d ∈ lines (f v) ∧ Realized hit x.requirements := by + classical + obtain ⟨hgeom, r, hr⟩ := Finset.mem_filter.mp hd + obtain ⟨hv, henc⟩ := Finset.mem_inter.mp hgeom + obtain ⟨u, hu, hdu⟩ := Finset.mem_biUnion.mp henc + have hdu' : d ∈ lines (s.1 u) := by rw [hs u hu]; exact hdu + exact ⟨u, hu, anchorName s.2 _ d hdu' r, + anchorName_direction _ _ _ _ _, hv, anchorName_realized hit _ _ _ _ _ hr⟩ + +omit [Fintype V] [Fintype H] [DecidableEq H] in +omit [Fintype D] in + +lemma make_one (f : V → H) (hit : B → D → Prop) (K : ℕ) (hK : 2 ≤ K) + (E : Finset V) (s : State V H D B) (hs : Coherent lines f hit K E s) + (v : V) (hv : v ∉ E) + (ha : 1 ≤ (touchedToEncoded (fun v => lines (f v)) hit E v).card) : + ∃ a : Action lines K s, Coherent lines f hit K (insert v E) (advance lines K s a) ∧ + (insert v E).card = E.card + degree lines K s a ∧ + Enabled lines K true s a ∧ actionCharge lines K s a = 0 := by + classical + obtain ⟨d, hd⟩ := Finset.card_pos.mp (by omega : 0 < (touchedToEncoded (fun v => lines (f v)) hit E v).card) + obtain ⟨u, hu, x, hxd, hdv, hxreal⟩ := touched_anchor lines f hit E s hs.1 v d hd + let c : OneChoice lines s := ⟨v, u, x, f v, hxd ▸ hdv⟩ + let a : Action lines K s := .inr (.inl c) + have hc : (insert v E).card = E.card + degree lines K s a := by + simp [a, degree, Finset.card_insert_of_notMem hv] + refine ⟨a, ?_, hc, fun _ _ => rfl, rfl⟩ + apply coherent_step lines f hit K hK E (insert v E) s hs a (Finset.subset_insert _ _) _ _ hxreal hc + · exact agrees_update f E s hs.1 v _ + · apply (anchor_req_directions x).trans + intro z hz + have hz' : z = x.direction := Finset.mem_singleton.mp hz + apply Finset.mem_biUnion.mpr + exact ⟨v, Finset.mem_insert_self _ _, hz' ▸ (hxd ▸ hdv)⟩ +omit [Fintype V] [Fintype H] [DecidableEq H] in +omit [Fintype D] in + +lemma make_two (f : V → H) (hit : B → D → Prop) (K : ℕ) (hK : 2 ≤ K) + (low : Bool) (E : Finset V) (s : State V H D B) (hs : Coherent lines f hit K E s) + (v : V) (hv : v ∉ E) + (ha : 2 ≤ (touchedToEncoded (fun v => lines (f v)) hit E v).card) : + ∃ a : Action lines K s, Coherent lines f hit K (insert v E) (advance lines K s a) ∧ + (insert v E).card = E.card + degree lines K s a ∧ + Enabled lines K low s a ∧ actionCharge lines K s a = 1 := by + classical + obtain ⟨d, hd, e, he, hde⟩ := Finset.one_lt_card.mp (by omega : + 1 < (touchedToEncoded (fun v => lines (f v)) hit E v).card) + obtain ⟨u, hu, x, hxd, hdv, hxreal⟩ := touched_anchor lines f hit E s hs.1 v d hd + obtain ⟨w, hw, y, hye, hev, hyreal⟩ := touched_anchor lines f hit E s hs.1 v e he + let c : TwoChoice lines s := ⟨v, u, w, x, y, f v, + by simpa only [hxd, hye] using And.intro hde (And.intro hdv hev)⟩ + let a : Action lines K s := .inr (.inr (.inl c)) + have hc : (insert v E).card = E.card + degree lines K s a := by + simp [a, degree, Finset.card_insert_of_notMem hv] + refine ⟨a, ?_, hc, ?_, rfl⟩ + · apply coherent_step lines f hit K hK E (insert v E) s hs a (Finset.subset_insert _ _) _ _ + (realized_union hit hxreal hyreal) hc + · exact agrees_update f E s hs.1 v _ + · change paidDirections (x.requirements ∪ y.requirements) ⊆ _ + rw [paidDirections_union] + apply Finset.union_subset + · apply (anchor_req_directions x).trans + intro z hz + have hz' := Finset.mem_singleton.mp hz + exact Finset.mem_biUnion.mpr ⟨v, Finset.mem_insert_self _ _, hz' ▸ (hxd ▸ hdv)⟩ + · apply (anchor_req_directions y).trans + intro z hz + have hz' := Finset.mem_singleton.mp hz + exact Finset.mem_biUnion.mpr ⟨v, Finset.mem_insert_self _ _, hz' ▸ (hye ▸ hev)⟩ + · intro c' he + simp [a] at he +end SharpRamseyFive.CertificateCover +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Entropy/CompleteProgramWeight.lean b/lean/OAI/Combinatorics/SharpRamsey/Entropy/CompleteProgramWeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..186cedf8025f44fe281142df6980b22e8a4e206a --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Entropy/CompleteProgramWeight.lean @@ -0,0 +1,463 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Entropy.TruncatedTupleIntegrable +import OAI.Combinatorics.SharpRamsey.Entropy.MakePair + +namespace OAI + +/-! High moments, finite-field subspaces, and incidence bounds. -/ + +section +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open scoped BigOperators +open MeasureTheory ProbabilityTheory +open scoped BigOperators ENNReal NNReal +namespace SharpRamseyFive.CertificateCover +open SharpRamseyFive.StaticCertificates +open SharpRamseyFive.CertificateEnumeration +open SharpRamseyFive.WeightedPrograms +open SharpRamseyFive.ResidualCertificate +open scoped BigOperators +variable {V H D B : Type*} [Fintype V] [DecidableEq V] + [Fintype H] [DecidableEq H] [Fintype D] [DecidableEq D] + [Fintype B] [DecidableEq B] +variable (lines : H → Finset D) +omit [Fintype H] [DecidableEq H] [Fintype D] in +lemma complete_program_weight (rate : D → ℝ≥0) (denom : ℝ) (hd : denom ≠ 0) + (K : ℕ) (low : Bool) (E : Finset V) (s : State V H D B) + (c : completePrograms lines K low E s) : + weight (fun p : B × D => rate p.2) (finish lines K s c.val.2).2 = + (weight (fun p : B × D => rate p.2) s.2 * denom ^ (Fintype.card V - E.card)) * + dWeight (Action lines K) (advance lines K) (programCost lines rate denom K low) s c.val.2 := by + rw [trace_weight lines rate denom hd K low s c.val.2 c.property.1, + c.property.2.2] + ring +omit [Fintype D] in + +lemma complete_program_sum (rate : D → ℝ≥0) (denom b mass : ℝ) + (hd : 0 < denom) (hb : 1 ≤ b) (hm : 0 ≤ mass) + (hmass : ∀ h, ∑ d ∈ lines h, (rate d : ℝ) ≤ mass) + (K N₁ N₂ : ℕ) (low : Bool) + (hN₁ : ∀ d, (Finset.univ.filter (fun h => d ∈ lines h)).card ≤ N₁) + (hN₂ : ∀ d e, d ≠ e → + (Finset.univ.filter (fun h => d ∈ lines h ∧ e ∈ lines h)).card ≤ N₂) + (E : Finset V) (s : State V H D B) : + (∑ c : completePrograms lines K low E s, + weight (fun p : B × D => rate p.2) (finish lines K s c.val.2).2) ≤ + (weight (fun p : B × D => rate p.2) s.2 * denom ^ (Fintype.card V - E.card)) * + ∑ n : Fin (Fintype.card V - E.card + 1), + branchingBound (V := V) (B := B) lines rate denom b mass K N₁ N₂ low ^ n.val := by + classical + simp_rw [complete_program_weight lines rate denom hd.ne' K low E s] + rw [← Finset.mul_sum] + apply mul_le_mul_of_nonneg_left _ + (mul_nonneg (weight_nonneg _ _) (pow_nonneg hd.le _)) + change (∑ c : {c : AllPrograms lines K E s // CompleteProgram lines K low E s c}, + dWeight (Action lines K) (advance lines K) (programCost lines rate denom K low) s c.val.2) ≤ _ + have hsub := Finset.sum_subtype (p := CompleteProgram lines K low E s) + (F := completePrograms_fintype lines K low E s) + (Finset.univ.filter (CompleteProgram lines K low E s)) (fun _ => by simp) + (fun c : AllPrograms lines K E s => dWeight (Action lines K) (advance lines K) + (programCost lines rate denom K low) s c.2) + rw [← hsub, Finset.sum_filter] + change (∑ c : AllPrograms lines K E s, + if CompleteProgram lines K low E s c then + dWeight (Action lines K) (advance lines K) (programCost lines rate denom K low) s c.2 + else 0) ≤ _ + rw [Fintype.sum_sigma] + apply Finset.sum_le_sum + intro n _ + apply le_trans _ (program_enumeration lines rate denom b mass hd.le hb hm hmass + K N₁ N₂ low hN₁ hN₂ n.val s) + apply Finset.sum_le_sum + intro w _ + by_cases hc : CompleteProgram lines K low E s ⟨n, w⟩ + · simp only [ite_eq_left hc, ite_eq_left hc.2.1] + exact le_rfl + · simp only [ite_eq_right hc] + split_ifs + · exact dWeight_nonneg (Action lines K) (advance lines K) _ + (programCost_nonneg lines rate denom hd.le K low) s w + · exact le_rfl + +def badEvent (K J : ℕ) (low : Bool) (E : Finset V) (s : State V H D B) + (f : V → H) : Set ((B × D) → ℕ) := + {ω | Function.Injective f ∧ Coherent lines f (fun r d => ω (r, d) ≠ 0) K E s ∧ + (∀ v ∉ E, Fintype.card B / 2 ≤ + (touchedBatches (fun v => lines (f v)) (fun r d => ω (r, d) ≠ 0) v).card) ∧ + (low = false → ∀ d, (Finset.univ.filter (fun r => ω (r, d) ≠ 0)).card ≤ J)} +omit [Fintype H] [DecidableEq H] in +omit [Fintype D] in + +lemma bad_event_cover (K J h : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (low : Bool) + (hsize : h ≤ (Fintype.card B / 2 - if low then 0 else J) / (2 * K)) + (herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) + (E : Finset V) (s : State V H D B) (f : V → H) (ω : (B × D) → ℕ) + (hω : ω ∈ badEvent lines K J low E s f) : + ∃ c : completePrograms lines K low E s, + (finish lines K s c.val.2).1 = f ∧ ω ∈ positiveEvent (finish lines K s c.val.2).2 := by + classical + have hex : ∃ n, ∃ w : Word lines K n s, + Segment lines f (fun r d => ω (r, d) ≠ 0) K low E Finset.univ s w ∧ + 0 ≤ charge lines K s w ∧ n ≤ Fintype.card V - E.card := by + cases low with + | false => + exact bad_program_high lines f hω.1 (fun r d => ω (r, d) ≠ 0) K J h hK hh + hsize E s hω.2.1 hω.2.2.1 (hω.2.2.2 rfl) herr + | true => + apply bad_program_low lines f hω.1 (fun r d => ω (r, d) ≠ 0) K h hK hh + _ E s hω.2.1 hω.2.2.1 herr + simpa using hsize + obtain ⟨n, w, hw, hq, hn⟩ := hex + have hc : CompleteProgram lines K low E s ⟨⟨n, by omega⟩, w⟩ := by + refine ⟨hw.2.2, hq, ?_⟩ + change degreeSum lines K s w = Fintype.card V - E.card + have he := hw.2.1 + simp only [Finset.card_univ] at he + omega + refine ⟨⟨⟨⟨n, by omega⟩, w⟩, hc⟩, ?_, ?_⟩ + · funext v + exact hw.1.1 v (Finset.mem_univ _) + · intro p hp + exact hw.1.2.2.1 p hp + +theorem bad_completion_bound (rate : D → ℝ≥0) (denom b mass : ℝ) + (hd : 0 < denom) (hb : 1 ≤ b) (hm : 0 ≤ mass) + (hmass : ∀ h, ∑ d ∈ lines h, (rate d : ℝ) ≤ mass) + (K J h N₁ N₂ : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (low : Bool) + (hsize : h ≤ (Fintype.card B / 2 - if low then 0 else J) / (2 * K)) + (herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) + (hN₁ : ∀ d, (Finset.univ.filter (fun h => d ∈ lines h)).card ≤ N₁) + (hN₂ : ∀ d e, d ≠ e → + (Finset.univ.filter (fun h => d ∈ lines h ∧ e ∈ lines h)).card ≤ N₂) + (E : Finset V) (s : State V H D B) : + (∑ f : V → H, (poissonLaw (fun p : B × D => rate p.2)).real + (badEvent lines K J low E s f)) ≤ + (weight (fun p : B × D => rate p.2) s.2 * denom ^ (Fintype.card V - E.card)) * + ∑ n : Fin (Fintype.card V - E.card + 1), + branchingBound (V := V) (B := B) lines rate denom b mass K N₁ N₂ low ^ n.val := by + classical + apply le_trans _ (complete_program_sum lines rate denom b mass hd hb hm hmass + K N₁ N₂ low hN₁ hN₂ E s) + apply decoded_static_union_bound rate + (fun c : completePrograms lines K low E s => (finish lines K s c.val.2).2) + (fun c => (finish lines K s c.val.2).1) (badEvent lines K J low E s) + · intro f + exact (Set.to_countable _).measurableSet + · intro f ω hω + exact bad_event_cover lines K J h hK hh low hsize herr E s f ω hω + +def selectedBadEvent (K J : ℕ) (low : Bool) (E : Finset V) (s : State V H D B) + (f : V → H) : Set ((B × D) → ℕ) := by + classical + exact {ω | Function.Injective f ∧ ∃ hit : B → D → Prop, + (∀ r d, hit r d → ω (r, d) ≠ 0) ∧ Coherent lines f hit K E s ∧ + (∀ v ∉ E, Fintype.card B / 2 ≤ (touchedBatches (fun v => lines (f v)) hit v).card) ∧ + (low = false → ∀ d, (Finset.univ.filter (fun r => hit r d)).card ≤ J)} +omit [Fintype H] [DecidableEq H] in +omit [Fintype D] in + +lemma selected_bad_event_cover (K J h : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (low : Bool) + (hsize : h ≤ (Fintype.card B / 2 - if low then 0 else J) / (2 * K)) + (herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) + (E : Finset V) (s : State V H D B) (f : V → H) (ω : (B × D) → ℕ) + (hω : ω ∈ selectedBadEvent lines K J low E s f) : + ∃ c : completePrograms lines K low E s, + (finish lines K s c.val.2).1 = f ∧ ω ∈ positiveEvent (finish lines K s c.val.2).2 := by + classical + obtain ⟨hfi, hit, hpos, hco, hbad, htr⟩ := hω + have hex : ∃ n, ∃ w : Word lines K n s, + Segment lines f hit K low E Finset.univ s w ∧ + 0 ≤ charge lines K s w ∧ n ≤ Fintype.card V - E.card := by + cases low with + | false => + exact bad_program_high lines f hfi hit K J h hK hh + hsize E s hco hbad (htr rfl) herr + | true => + apply bad_program_low lines f hfi hit K h hK hh _ E s hco hbad herr + simpa using hsize + obtain ⟨n, w, hw, hq, hn⟩ := hex + have hc : CompleteProgram lines K low E s ⟨⟨n, by omega⟩, w⟩ := by + refine ⟨hw.2.2, hq, ?_⟩ + change degreeSum lines K s w = Fintype.card V - E.card + have he := hw.2.1 + simp only [Finset.card_univ] at he + omega + refine ⟨⟨⟨⟨n, by omega⟩, w⟩, hc⟩, ?_, ?_⟩ + · funext v + exact hw.1.1 v (Finset.mem_univ _) + · intro p hp + exact hpos p.1 p.2 (hw.1.2.2.1 p hp) + +theorem selected_bad_completion_bound (rate : D → ℝ≥0) (denom b mass : ℝ) + (hd : 0 < denom) (hb : 1 ≤ b) (hm : 0 ≤ mass) + (hmass : ∀ h, ∑ d ∈ lines h, (rate d : ℝ) ≤ mass) + (K J h N₁ N₂ : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (low : Bool) + (hsize : h ≤ (Fintype.card B / 2 - if low then 0 else J) / (2 * K)) + (herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) + (hN₁ : ∀ d, (Finset.univ.filter (fun h => d ∈ lines h)).card ≤ N₁) + (hN₂ : ∀ d e, d ≠ e → + (Finset.univ.filter (fun h => d ∈ lines h ∧ e ∈ lines h)).card ≤ N₂) + (E : Finset V) (s : State V H D B) : + (∑ f : V → H, (poissonLaw (fun p : B × D => rate p.2)).real + (selectedBadEvent lines K J low E s f)) ≤ + (weight (fun p : B × D => rate p.2) s.2 * denom ^ (Fintype.card V - E.card)) * + ∑ n : Fin (Fintype.card V - E.card + 1), + branchingBound (V := V) (B := B) lines rate denom b mass K N₁ N₂ low ^ n.val := by + classical + apply le_trans _ (complete_program_sum lines rate denom b mass hd hb hm hmass + K N₁ N₂ low hN₁ hN₂ E s) + apply decoded_static_union_bound rate + (fun c : completePrograms lines K low E s => (finish lines K s c.val.2).2) + (fun c => (finish lines K s c.val.2).1) (selectedBadEvent lines K J low E s) + · intro f + exact (Set.to_countable _).measurableSet + · intro f ω hω + exact selected_bad_event_cover lines K J h hK hh low hsize herr E s f ω hω + +end SharpRamseyFive.CertificateCover + +namespace SharpRamseyFive.SelectionBridge +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponents +open SharpRamseyFive.Designations SharpRamseyFive.AmbientDesignations +open SharpRamseyFive.CertificateCover SharpRamseyFive.WeightedPrograms +open Classical +variable {D V H C : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V] + [Fintype H] [DecidableEq H] [Fintype C] [DecidableEq C] +omit [DecidableEq D] in + +lemma restriction_preserving (rate : D → ℝ≥0) (lab : D → Option C) (R : ℕ) : + MeasurePreserving (fun ω : Fin R × D → ℕ => fun i : Block lab R none => ω i) + (batchMeasure (fun i : Fin R × D => rate i.2)) + (batchMeasure (fun i : Block lab R none => rate i.1.2)) := by + exact (measurePreserving_eval (fun c : Option C => batchMeasure + (fun i : Block lab R c => rate i.1.2)) none).comp + (measurePreserving_partition (fun i : Fin R × D => rate i.2) (fun i => lab i.2)) +omit [DecidableEq D] in + +lemma integral_restriction (rate : D → ℝ≥0) (lab : D → Option C) (R : ℕ) + (F : (Block lab R none → ℕ) → ℝ) : + (∫ z, F z ∂batchMeasure (fun i : Block lab R none => rate i.1.2)) = + ∫ ω, F (fun i => ω i) ∂batchMeasure (fun i : Fin R × D => rate i.2) := by + have h := restriction_preserving rate lab R + rw [← h.map_eq] + exact integral_map h.measurable.aemeasurable (measurable_of_countable F).aestronglyMeasurable +omit [Fintype D] [DecidableEq V] in + +lemma label_none_external (weight : D → ℝ≥0) (s : V → Finset D) (t : ℝ) + {v : V} {d : D} (hd : d ∈ s v) (he : componentLabel weight s t d = none) : + External weight s t d := by + by_contra hn + have hi := componentLabel_internal weight s t (Finset.mem_filter.mpr ⟨hd,hn⟩) + rw [he] at hi + cases hi + +noncomputable def selectedHit (weight : D → ℝ≥0) (s : V → Finset D) (t : ℝ) + {R : ℕ} (ω : Fin R × D → ℕ) (r : Fin R) (d : D) : Prop := + componentLabel weight s t d = none ∧ ω (r,d) ≠ 0 + +lemma touched_equals_shared (weight : D → ℝ≥0) (s : V → Finset D) (t : ℝ) + (R : ℕ) (ω : Fin R × D → ℕ) (v : V) : + TupleComponents.hitBatches (touched (componentLabel weight s t) R + ((strongGraph weight s t).connectedComponentMk v) (s v) (fun i => ω i)) = + ResidualCertificate.touchedBatches s (selectedHit weight s t ω) v := by + ext r + simp only [TupleComponents.hitBatches, touched, Finset.mem_filter, Finset.mem_univ, true_and, + decide_eq_true_eq, ResidualCertificate.touchedBatches, + ResidualCertificate.sharedBatches, Finset.mem_inter] + constructor + · rintro ⟨d,hd,hpos⟩ + obtain ⟨u,hu,hdiff⟩ := (external_iff_other weight s t hd).mp + (label_none_external weight s t hd d.property) + refine ⟨u, ?_, d, ⟨hd,hu⟩, d.property,hpos⟩ + intro he + subst u + exact hdiff rfl + · rintro ⟨u,_,d,⟨hd,_⟩,he,hpos⟩ + exact ⟨⟨d,he⟩,hd,hpos⟩ + +omit [DecidableEq V] in +lemma selected_trunc (weight : D → ℝ≥0) (s : V → Finset D) (t : ℝ) + (R J : ℕ) (ω : Fin R × D → ℕ) + (htr : blockTrunc (componentLabel weight s t) R J none (fun i => ω i) ≠ 0) : + ∀ d, (Finset.univ.filter (fun r => selectedHit weight s t ω r d)).card ≤ J := by + intro d + by_cases hd : componentLabel weight s t d = none + · have hp : lineTrunc R J (fun r => ω (r,d)) ≠ 0 := + Finset.prod_ne_zero_iff.mp htr ⟨d,hd⟩ (Finset.mem_univ _) + have hh : (Finset.univ.filter (fun r => ω (r,d) ≠ 0)).card < J := by + by_contra hn + exact hp (ite_eq_right hn) + simpa only [selectedHit, hd, true_and] using hh.le + · simp only [selectedHit, hd, false_and, Finset.filter_false, Finset.card_empty] + exact Nat.zero_le _ + +noncomputable def vertexBadMass (weight rate : D → ℝ≥0) (s : V → Finset D) (t : ℝ) + (R J : ℕ) (A : Finset V) : ℝ := + badMass (batchMeasure (fun i : Block (componentLabel weight s t) R none => rate i.1.2)) + (blockTrunc (componentLabel weight s t) R J none) + (fun v z => BAD (touched (componentLabel weight s t) R + ((strongGraph weight s t).connectedComponentMk v) (s v) z)) A + +omit [Fintype D] [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in +lemma empty_coherent (lines : H → Finset D) (f g : V → H) (R K : ℕ) + (E : Finset V) (hit : Fin R → D → Prop) (he : ∀ v ∈ E, g v = f v) : + Coherent lines f hit K E (g,∅) := by + refine ⟨he, ?_, ?_, ?_⟩ + · simp [ResidualCertificate.DictionaryInvariant, ResidualCertificate.paidDirections] + · intro p hp + exact False.elim (Finset.notMem_empty p hp) + · simp +omit [Fintype H] [DecidableEq H] in + +lemma bad_mass_le_selected_event (weight rate : D → ℝ≥0) (lines : H → Finset D) + (f g : V → H) (hf : Function.Injective f) (R J K : ℕ) (t : ℝ) (low : Bool) + (A : Finset V) (he : ∀ v ∈ Finset.univ \ A, g v = f v) : + vertexBadMass weight rate (lines ∘ f) t R J A ≤ + (StaticCertificates.poissonLaw (fun i : Fin R × D => rate i.2)).real + (selectedBadEvent lines K J low (Finset.univ \ A) (g,∅) f) := by + let lab := componentLabel weight (lines ∘ f) t + let bad := fun v z => BAD (touched lab R + ((strongGraph weight (lines ∘ f) t).connectedComponentMk v) (lines (f v)) z) + let T := blockTrunc lab R J none + let E : Set ((Fin R × D) → ℕ) := selectedBadEvent lines K J low (Finset.univ \ A) (g,∅) f + have hE : MeasurableSet E := (Set.to_countable _).measurableSet + change (∫ z, T z * ∏ v ∈ A, badIndicator bad v z + ∂batchMeasure (fun i : Block lab R none => rate i.1.2)) ≤ _ + rw [integral_restriction rate lab R] + have hi : Integrable (fun ω : Fin R × D → ℕ => + T (fun i => ω i) * ∏ v ∈ A, badIndicator bad v (fun i => ω i)) + (batchMeasure (fun i : Fin R × D => rate i.2)) := by + apply Integrable.of_bound (measurable_of_countable _).aestronglyMeasurable 1 + apply Filter.Eventually.of_forall + intro ω + rw [Real.norm_eq_abs, abs_of_nonneg (badTerm_range T (blockTrunc_range lab R J none) + bad A (fun i => ω i)).1] + exact (badTerm_range T (blockTrunc_range lab R J none) bad A (fun i => ω i)).2 + change _ ≤ (batchMeasure (fun i : Fin R × D => rate i.2)).real E + rw [← integral_indicator_one hE] + apply integral_mono hi ((integrable_const (1 : ℝ)).indicator hE) + intro ω + dsimp only + by_cases hz : T (fun i => ω i) * ∏ v ∈ A, badIndicator bad v (fun i => ω i) = 0 + · rw [hz] + exact Set.indicator_nonneg (fun _ _ => zero_le_one) ω + · have ht : T (fun i => ω i) ≠ 0 := (mul_ne_zero_iff.mp hz).1 + have hb : ∀ v ∈ A, bad v (fun i => ω i) := by + intro v hv + have hn := Finset.prod_ne_zero_iff.mp (mul_ne_zero_iff.mp hz).2 v hv + by_contra hn' + exact hn (ite_eq_right hn') + have hmem : ω ∈ E := by + refine ⟨hf, selectedHit weight (lines ∘ f) t ω, ?_, ?_, ?_, ?_⟩ + · intro r d hd + exact hd.2 + · exact empty_coherent lines f g R K (Finset.univ \ A) _ he + · intro v hv + have hvA : v ∈ A := by simpa using hv + have hvb := hb v hvA + change R / 2 ≤ (TupleComponents.hitBatches (touched lab R + ((strongGraph weight (lines ∘ f) t).connectedComponentMk v) (lines (f v)) + (fun i => ω i))).card at hvb + change R / 2 ≤ (TupleComponents.hitBatches (touched + (componentLabel weight (lines ∘ f) t) R + ((strongGraph weight (lines ∘ f) t).connectedComponentMk v) + ((lines ∘ f) v) (fun i => ω i))).card at hvb + rw [touched_equals_shared weight (lines ∘ f) t R ω v] at hvb + simpa only [Fintype.card_fin, Function.comp_def] using hvb + · intro _ + exact selected_trunc weight (lines ∘ f) t R J ω ht + rw [Set.indicator_of_mem hmem] + exact (badTerm_range T (blockTrunc_range lab R J none) bad A (fun i => ω i)).2 +omit [Fintype D] [Fintype V] [DecidableEq V] in + +lemma vertex_injective (weight : D → ℝ≥0) (s : V → Finset D) (t : ℝ) : Function.Injective (vertex weight s t) := by + intro c d he + have h := congrArg (strongGraph weight s t).connectedComponentMk he + simpa only [vertex_color] using h + +lemma component_bad_mass_eq_vertex (weight rate : D → ℝ≥0) (s : V → Finset D) + (t : ℝ) (R J : ℕ) (U : Finset (Components weight s t)) : + badMass (batchMeasure (fun i : Block (componentLabel weight s t) R none => rate i.1.2)) + (blockTrunc (componentLabel weight s t) R J none) + (isBad weight s t R) U = + vertexBadMass weight rate s t R J (U.image (vertex weight s t)) := by + unfold badMass vertexBadMass + congr 1 + funext z + congr 1 + rw [Finset.prod_image (fun _ _ _ _ he => vertex_injective weight s t he)] + apply Finset.prod_congr rfl + intro c hc + simp only [badIndicator, isBad, vertex_color] + split_ifs with h <;> simp only [h, ite_true, ite_false] + +theorem bad_residual_sum_le (weight rate : D → ℝ≥0) (lines : H → Finset D) + (t : ℝ) (R : ℕ) (denom b mass : ℝ) + (hd : 0 < denom) (hb : 1 ≤ b) (hm : 0 ≤ mass) + (hmass : ∀ u, ∑ d ∈ lines u, (rate d : ℝ) ≤ mass) + (K J h N₁ N₂ : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (low : Bool) + (hsize : h ≤ (R / 2 - if low then 0 else J) / (2 * K)) + (herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) + (hN₁ : ∀ d, (Finset.univ.filter (fun u => d ∈ lines u)).card ≤ N₁) + (hN₂ : ∀ d e, d ≠ e → + (Finset.univ.filter (fun u => d ∈ lines u ∧ e ∈ lines u)).card ≤ N₂) + (A : Finset V) (g : V → H) : + (∑ f : V → H, if Function.Injective f ∧ (∀ v ∉ A, g v = f v) then + vertexBadMass weight rate (lines ∘ f) t R J A else 0) ≤ + denom ^ A.card * ∑ n : Fin (A.card + 1), + branchingBound (V := V) (B := Fin R) lines rate denom b mass K N₁ N₂ low ^ n.val := by + have hbnd := selected_bad_completion_bound (V := V) (B := Fin R) + lines rate denom b mass hd hb hm hmass K J h N₁ N₂ hK hh low + (by simpa only [Fintype.card_fin] using hsize) herr hN₁ hN₂ + (Finset.univ \ A) (g,∅) + have heq : Fintype.card V - (Finset.univ \ A).card = A.card := by + rw [Finset.card_sdiff_of_subset (Finset.subset_univ A)] + simp only [Finset.card_univ] + have := Finset.card_le_card (Finset.subset_univ A) + simp only [Finset.card_univ] at this + omega + rw [Fin.sum_univ_eq_sum_range] at hbnd ⊢ + simp only [heq, StaticCertificates.weight, Finset.prod_empty, one_mul] at hbnd + apply le_trans _ hbnd + apply Finset.sum_le_sum + intro f hf + split_ifs with hfi + · apply bad_mass_le_selected_event weight rate lines f g hfi.1 R J K t low A + intro v hv + exact hfi.2 v (Finset.mem_sdiff.mp hv).2 + · exact ENNReal.toReal_nonneg + +end SharpRamseyFive.SelectionBridge + +namespace SharpRamseyFive.SelectionBridge +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponents +open SharpRamseyFive.Designations SharpRamseyFive.AmbientDesignations +open SharpRamseyFive.CertificateCover SharpRamseyFive.WeightedPrograms +open Classical +variable {D V H : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V] + [Fintype H] [DecidableEq H] + +def labelled (f : V → H) (v : V) : H × V := (f v, v) + +omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in +lemma labelled_injective (f : V → H) : Function.Injective (labelled f) := by + intro u v h + exact congrArg Prod.snd h + +omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in +lemma labelled_map_injective : Function.Injective (labelled : (V → H) → (V → H × V)) := by + intro f g h + funext v + exact congrArg Prod.fst (congrFun h v) + +end SharpRamseyFive.SelectionBridge +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Entropy/ComponentLabelWitness.lean b/lean/OAI/Combinatorics/SharpRamsey/Entropy/ComponentLabelWitness.lean new file mode 100644 index 0000000000000000000000000000000000000000..4c4b6769a8aebd91402e695c11f5eccc7be5e287 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Entropy/ComponentLabelWitness.lean @@ -0,0 +1,460 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Entropy.ExternalMass + +namespace OAI + +/-! High moments, finite-field subspaces, and incidence bounds. -/ + +section +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +namespace SharpRamseyFive.TupleComponents +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open SharpRamseyFive.PoissonScore +open Classical +variable {D V C : Type} [Fintype D] [DecidableEq D] + [Fintype V] [DecidableEq V] [Fintype C] [DecidableEq C] +variable (label : D → Option C) (R : ℕ) +variable (color : V → C) (s : V → Finset D) (b : ℝ) (own : V → Fin R → Bool) +omit [Fintype D] [DecidableEq V] in +lemma componentLabel_witness (weight : D → ℝ≥0) (t : ℝ) (d : D) + (c : (strongGraph weight s t).ConnectedComponent) + (hc : componentLabel weight s t d = some c) : + ∃ v, d ∈ s v ∧ (strongGraph weight s t).connectedComponentMk v = c := by + unfold componentLabel at hc + split_ifs at hc with h h' + exact ⟨h.choose, h.choose_spec, Option.some.inj hc⟩ +omit [DecidableEq V] in + +lemma simple_inside_univ (weight : D → ℝ≥0) (t : ℝ) (v : V) + (hsingle : ∀ u, (strongGraph weight s t).connectedComponentMk u = + (strongGraph weight s t).connectedComponentMk v → u = v) : + inside (componentLabel weight s t) ((strongGraph weight s t).connectedComponentMk v) + (s v) = Finset.univ := by + apply Finset.eq_univ_of_forall + intro d + obtain ⟨u, hu, hc⟩ := componentLabel_witness s weight t d.val _ d.property + have he := hsingle u hc + simpa [inside, he] using hu + +omit [DecidableEq D] [Fintype C] in +lemma blockTrunc_eq_indicator (J : ℕ) (c : C) (x : Block label R (some c) → ℕ) : + blockTrunc label R J (some c) x = + (overloaded Finset.univ J)ᶜ.indicator (fun _ => (1 : ℝ)) (unblock label R c x) := by + by_cases he : unblock label R c x ∈ overloaded Finset.univ J + · simp only [Set.indicator_of_notMem (show unblock label R c x ∉ + (overloaded Finset.univ J)ᶜ by simpa using he)] + obtain ⟨d, _, hd⟩ := he + apply Finset.prod_eq_zero (Finset.mem_univ d) + change lineTrunc R J (fun r => x ⟨(r,d), d.property⟩) = 0 + have hn : ¬ (Finset.univ.filter (fun r => x ⟨(r,d), d.property⟩ ≠ 0)).card < J := by + exact not_lt.mpr hd + simp only [lineTrunc, ite_eq_right hn] + · rw [Set.indicator_of_mem (show unblock label R c x ∈ + (overloaded Finset.univ J)ᶜ by simpa using he)] + apply Finset.prod_eq_one + intro d _ + change lineTrunc R J (fun r => x ⟨(r,d), d.property⟩) = 1 + have hd : (Finset.univ.filter (fun r => x ⟨(r,d), d.property⟩ ≠ 0)).card < J := by + by_contra hn + exact he ⟨d, Finset.mem_univ _, not_lt.mp hn⟩ + simp only [lineTrunc, ite_eq_left hd] + +omit [DecidableEq V] in +omit [Fintype C] in +lemma componentFactor_eq_single (J : ℕ) (c : C) (v : {v : V // color v = c}) + (hsingle : ∀ u, color u = c → u = v.val) + (hcompat : ∀ d ∈ s v, label d = none ∨ label d = some c) + (hin : inside label c (s v) = Finset.univ) + (z : Block label R none → ℕ) (x : Block label R (some c) → ℕ) : + componentFactor label R color s b own J c z x = + (overloaded (inside label c (s v)) J)ᶜ.indicator + (maskedTerm (inside label c (s v)) b (own v) (touched label R c (s v) z)) + (unblock label R c x) := by + have hp : (∏ u : {v : V // color v = c}, scoreTerm (s u) b (own u) (fill label R c z x)) = + scoreTerm (s v) b (own v) (fill label R c z x) := by + apply Finset.prod_eq_single v + · intro u _ huv + exfalso + exact huv (Subtype.ext (hsingle u u.property)) + · simp + rw [componentFactor, hp, scoreTerm_eq_masked label R c (s v) b (own v) hcompat, + blockTrunc_eq_indicator label R J c, hin] + by_cases he : unblock label R c x ∈ (overloaded Finset.univ J)ᶜ <;> simp [he] +omit [DecidableEq V] in +omit [Fintype C] in + +lemma simple_component_integral (rate : D → ℝ≥0) (J : ℕ) + (c : C) (v : {v : V // color v = c}) + (hsingle : ∀ u, color u = c → u = v.val) + (hcompat : ∀ d ∈ s v, label d = none ∨ label d = some c) + (hin : inside label c (s v) = Finset.univ) (z : Block label R none → ℕ) : + (∫ x, componentFactor label R color s b own J c z x + ∂batchMeasure (fun i : Block label R (some c) => rate i.1.2)) = + ∫ w, (overloaded (inside label c (s v)) J)ᶜ.indicator + (maskedTerm (inside label c (s v)) b (own v) (touched label R c (s v) z)) w + ∂scheduleMeasure (fun d : IntDir label c => rate d) R := by + simp_rw [componentFactor_eq_single label R color s b own J c v hsingle hcompat hin] + exact (measurePreserving_unblock label R rate c).integral_comp + (unblockEquiv label R c).measurableEmbedding _ +omit [DecidableEq V] in +omit [Fintype C] in + +lemma simple_component_attenuation (rate : D → ℝ≥0) (J : ℕ) + (c : C) (v : {v : V // color v = c}) + (hsingle : ∀ u, color u = c → u = v.val) + (hcompat : ∀ d ∈ s v, label d = none ∨ label d = some c) + (hin : inside label c (s v) = Finset.univ) (z : Block label R none → ℕ) + {L base delta alpha : ℝ} (hL : 10000 ≤ L) + (hmass : mass (fun d : IntDir label c => rate d) (inside label c (s v)) = + L * (base + delta - alpha)) + (hint : (37 / 50 : ℝ) ≤ base + delta - alpha) (hbase : (37 / 50 : ℝ) ≤ base) + (ha : 0 ≤ alpha) (hd : |delta| + alpha ≤ 1) {N K : ℕ} + (hN : N ≤ (untouchedBatches (touched label R c (s v) z)).card) (hK : K ≤ N) : + |∫ x, componentFactor label R color s (Real.exp (-L * base)) own J c z x + ∂batchMeasure (fun i : Block label R (some c) => rate i.1.2)| ≤ + Real.exp (-(17 / 25 : ℝ) * (L * R)) * + (|delta| ^ N + alpha ^ K + + ∑ d ∈ inside label c (s v), ((R : ℝ) * (rate d : ℝ)) ^ J) := by + rw [simple_component_integral label R color s _ own rate J c v hsingle hcompat hin z] + exact simple_singleton_truncated _ _ J (own v) (touched label R c (s v) z) + hL hmass hint hbase ha hd hN hK +omit [Fintype C] in + +lemma nonsimple_component_attenuation (rate : D → ℝ≥0) (J : ℕ) + (c : C) (v : {v : V // color v = c}) (z : Block label R none → ℕ) + (hcompat : ∀ d ∈ s v, label d = none ∨ label d = some c) + {L lam base : ℝ} (hL : 10000 ≤ L) + (hmass : mass (fun d : IntDir label c => rate d) (inside label c (s v)) = L * lam) + (hlam : (37 / 50 : ℝ) ≤ lam) (hbase : (37 / 50 : ℝ) ≤ base) : + (∫ x, |componentFactor label R color s (Real.exp (-L * base)) own J c z x| + ∂batchMeasure (fun i : Block label R (some c) => rate i.1.2)) ≤ + Real.exp (-(7 / 10 : ℝ) * (L * R)) := by + apply (component_integral_abs_le label R color s own rate J c v z hcompat + (show 0 ≤ L by linarith) (by norm_num : (0 : ℝ) ≤ 37 / 50) hmass hlam hbase).trans + have he : (2 : ℝ) ≤ Real.exp ((1 / 25 : ℝ) * L) := by + have := Real.add_one_le_exp ((1 / 25 : ℝ) * L) + linarith + have hmul := mul_le_mul_of_nonneg_right he (Real.exp_pos (-L * (37 / 50 : ℝ))).le + rw [← Real.exp_add] at hmul + have hpow := pow_le_pow_left₀ (by positivity : (0 : ℝ) ≤ 2 * Real.exp (-L * (37 / 50 : ℝ))) hmul R + rw [← Real.exp_nat_mul] at hpow + convert hpow using 1 ; congr 1 ; ring + +end SharpRamseyFive.TupleComponents + +namespace SharpRamseyFive.TupleMultiplicity +open scoped BigOperators +open Classical +variable {V H : Type*} [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] + +abbrev RepresentativeMap (V : Type*) := {r : V → V // ∀ v, r (r v) = r v} +abbrev Representatives (r : RepresentativeMap V) := {v : V // r.val v = v} + +noncomputable def chosen (f : V → H) (v : V) : V := + Classical.choose (show ∃ w, f w = f v from ⟨v, rfl⟩) + +omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in +lemma chosen_spec (f : V → H) (v : V) : f (chosen f v) = f v := + Classical.choose_spec (show ∃ w, f w = f v from ⟨v, rfl⟩) + +omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in +lemma chosen_eq (f : V → H) {v w : V} (h : f v = f w) : + chosen f v = chosen f w := by + unfold chosen + congr 1 + funext x + rw [h] +omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in + +lemma chosen_idempotent (f : V → H) : ∀ v, chosen f (chosen f v) = chosen f v := by + intro v + exact chosen_eq f (chosen_spec f v) + +noncomputable def representatives (f : V → H) : RepresentativeMap V := + ⟨chosen f, chosen_idempotent f⟩ + +noncomputable def assignment (f : V → H) : Representatives (representatives f) ↪ H where + toFun v := f v + inj' := by + intro v w h + apply Subtype.ext + have := chosen_eq f h + change chosen f v.val = chosen f w.val at this + simpa only [show chosen f v.val = v.val from v.property, + show chosen f w.val = w.val from w.property] using this + +noncomputable def decode (r : RepresentativeMap V) (h : Representatives r ↪ H) : V → H := + fun v => h ⟨r.val v, r.property v⟩ +omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in + +lemma decode_assignment (f : V → H) : + decode (representatives f) (assignment f) = f := by + funext v + exact chosen_spec f v + +noncomputable def encode (f : V → H) : + (r : RepresentativeMap V) × (Representatives r ↪ H) := + ⟨representatives f, assignment f⟩ +omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in + +lemma encode_injective : Function.Injective (encode (V := V) (H := H)) := by + intro f g h + have := congrArg (fun z : (r : RepresentativeMap V) × (Representatives r ↪ H) => + decode z.1 z.2) h + simpa only [encode, decode_assignment] using this + +lemma representativeMap_card_le : + Fintype.card (RepresentativeMap V) ≤ Fintype.card V ^ Fintype.card V := by + calc + _ ≤ Fintype.card (V → V) := Fintype.card_subtype_le _ + _ = _ := by simp + +lemma representatives_card_le (r : RepresentativeMap V) : + Fintype.card (Representatives r) ≤ Fintype.card V := Fintype.card_subtype_le _ + +theorem sum_tuples_le_representative_assignments (F : (V → H) → ℝ) + (hF : ∀ f, 0 ≤ F f) : + (∑ f : V → H, F f) ≤ + ∑ r : RepresentativeMap V, ∑ h : Representatives r ↪ H, F (decode r h) := by + rw [← Fintype.sum_sigma (fun z : (r : RepresentativeMap V) × (Representatives r ↪ H) => + F (decode z.1 z.2))] + let e := encode (V := V) (H := H) + let G := fun z : (r : RepresentativeMap V) × (Representatives r ↪ H) => F (decode z.1 z.2) + have he : (∑ f : V → H, F f) = ∑ z ∈ Finset.univ.image e, G z := by + rw [Finset.sum_image (fun _ _ _ _ h => encode_injective h)] + apply Finset.sum_congr rfl + intro f _ + simp only [G, encode, decode_assignment] + rw [he] + exact Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) (fun z _ _ => hF _) + +omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in + +lemma range_decode (r : RepresentativeMap V) (h : Representatives r ↪ H) : + Set.range (decode r h) = Set.range h := by + ext a + constructor + · rintro ⟨v,rfl⟩ + exact ⟨⟨r.val v,r.property v⟩,rfl⟩ + · rintro ⟨v,rfl⟩ + refine ⟨v, ?_⟩ + apply congrArg h + exact Subtype.ext v.property + +omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in +lemma fiber_decode (r : RepresentativeMap V) (h : Representatives r ↪ H) + (v : V) (w : Representatives r) : decode r h v = h w ↔ r.val v = w.val := by + constructor + · intro he + exact congrArg Subtype.val (h.injective he) + · intro he + exact congrArg h (Subtype.ext he) +end SharpRamseyFive.TupleMultiplicity + +namespace SharpRamseyFive.TupleComponents +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open SharpRamseyFive.PoissonScore +open Classical +variable {D V C : Type} [Fintype D] [DecidableEq D] + [Fintype V] [DecidableEq V] [Fintype C] [DecidableEq C] +omit [DecidableEq V] in + +lemma mass_inside_eq (weight rate : D → ℝ≥0) (s : V → Finset D) (t : ℝ) (v : V) : + mass (fun d : IntDir (componentLabel weight s t) + ((strongGraph weight s t).connectedComponentMk v) => rate d) + (inside (componentLabel weight s t) _ (s v)) = + mass rate (internalPart weight s t v) := by + unfold mass + apply Finset.sum_bij (fun d _ => d.val) + · intro d hd + exact (internalPart_iff_label weight s t v d.val).mpr + ⟨(Finset.mem_filter.mp hd).2, d.property⟩ + · intro a _ b _ hab + exact Subtype.ext hab + · intro d hd + obtain ⟨hm, hl⟩ := (internalPart_iff_label weight s t v d).mp hd + exact ⟨⟨d,hl⟩, Finset.mem_filter.mpr ⟨Finset.mem_univ _,hm⟩,rfl⟩ + · intro d _ + rfl + +omit [Fintype D] [DecidableEq D] in +lemma mass_scaled (L : ℝ≥0) (weight : D → ℝ≥0) (S : Finset D) : + mass (fun d => L * weight d) S = (L : ℝ) * mass weight S := by + simp only [mass, NNReal.coe_mul, Finset.mul_sum] + +lemma source_inside_mass_lower (weight : D → ℝ≥0) (s : V → Finset D) + {p : ℕ} (hp : 0 < p) (hc : Fintype.card V ≤ p) + (hs : ∀ v, (3 / 4 : ℝ) ≤ mass weight (s v)) (v : V) : + (37 / 50 : ℝ) ≤ mass (fun d : IntDir (componentLabel weight s (1 / (100 * p))) + ((strongGraph weight s (1 / (100 * p))).connectedComponentMk v) => weight d) + (inside (componentLabel weight s (1 / (100 * p))) _ (s v)) := by + rw [mass_inside_eq] + exact source_internal_mass_lower weight s hp hc hs v + +omit [Fintype D] [Fintype V] in + +lemma repeats_same_component (weight : D → ℝ≥0) (s : V → Finset D) (t : ℝ) + {v w : V} (he : s v = s w) (hm : t < mass weight (s v)) : + (strongGraph weight s t).connectedComponentMk v = + (strongGraph weight s t).connectedComponentMk w := by + by_cases hvw : v = w + · exact congrArg _ hvw + · apply SimpleGraph.ConnectedComponent.connectedComponentMk_eq_of_adj + exact ⟨hvw, by simpa only [← he, Finset.inter_self] using hm⟩ + +variable (label : D → Option C) (R : ℕ) (color : V → C) + (s : V → Finset D) (own : V → Fin R → Bool) + +def hitBatches {R : ℕ} (mask : Fin R → Bool) : Finset (Fin R) := + Finset.univ.filter (fun r => mask r = true) + +def BAD {R : ℕ} (mask : Fin R → Bool) : Prop := R / 2 ≤ (hitBatches mask).card + +lemma batches_partition {R : ℕ} (mask : Fin R → Bool) : + (hitBatches mask).card + (untouchedBatches mask).card = R := by + have h := Finset.card_filter_add_card_filter_not (s := Finset.univ) (fun r : Fin R => mask r = true) + simpa only [hitBatches, untouchedBatches, Bool.not_eq_true, Finset.card_univ, Fintype.card_fin] using h + +lemma untouched_of_not_bad {R : ℕ} (mask : Fin R → Bool) (h : ¬ BAD mask) : + R / 2 ≤ (untouchedBatches mask).card := by + have hp := batches_partition mask + simp only [BAD, not_le] at h + omega + +omit [Fintype C] in + +theorem simple_component_designations_raw (rate : D → ℝ≥0) (J : ℕ) + (c : C) (v : {v : V // color v = c}) + (hsingle : ∀ u, color u = c → u = v.val) + (hcompat : ∀ d ∈ s v, label d = none ∨ label d = some c) + (hin : inside label c (s v) = Finset.univ) (z : Block label R none → ℕ) + {L base delta alpha : ℝ} (hL : 10000 ≤ L) + (hmass : mass (fun d : IntDir label c => rate d) (inside label c (s v)) = + L * (base + delta - alpha)) + (hint : (37 / 50 : ℝ) ≤ base + delta - alpha) (hbase : (37 / 50 : ℝ) ≤ base) + (ha : 0 ≤ alpha) (hd : |delta| + alpha ≤ 1) {K : ℕ} (hK : K ≤ R / 2) : + |∫ x, componentFactor label R color s (Real.exp (-L * base)) own J c z x + ∂batchMeasure (fun i : Block label R (some c) => rate i.1.2)| ≤ + Real.exp (-(17 / 25 : ℝ) * (L * R)) * + (|delta| ^ (R / 2) + alpha ^ K + + ∑ d ∈ inside label c (s v), ((R : ℝ) * (rate d : ℝ)) ^ J + + if BAD (touched label R c (s v) z) then 1 else 0) := by + by_cases hg : ¬ BAD (touched label R c (s v) z) + · simp only [ite_eq_right hg, add_zero] + exact simple_component_attenuation label R color s own rate J c v hsingle hcompat hin z + hL hmass hint hbase ha hd (untouched_of_not_bad _ hg) hK + · simp only [not_not] at hg + simp only [ite_eq_left hg] + have hn := nonsimple_component_attenuation label R color s own rate J c v z + hcompat hL hmass hint hbase + have hat : Real.exp (-(7 / 10 : ℝ) * (L * R)) ≤ + Real.exp (-(17 / 25 : ℝ) * (L * R)) := by + apply Real.exp_le_exp.mpr + have hLR : 0 ≤ L * (R : ℝ) := mul_nonneg (by linarith) (by positivity) + nlinarith + calc + _ ≤ ∫ x, |componentFactor label R color s (Real.exp (-L * base)) own J c z x| + ∂batchMeasure (fun i : Block label R (some c) => rate i.1.2) := abs_integral_le_integral_abs + _ ≤ _ := hn + _ ≤ Real.exp (-(17 / 25 : ℝ) * (L * R)) := hat + _ ≤ _ := by + apply le_mul_of_one_le_right (Real.exp_pos _).le + have he : 0 ≤ ∑ d ∈ inside label c (s v), ((R : ℝ) * (rate d : ℝ)) ^ J := by positivity + have haK : 0 ≤ alpha ^ K := pow_nonneg ha K + have hdN : 0 ≤ |delta| ^ (R / 2) := by positivity + linarith +omit [Fintype C] in + +theorem simple_component_designations (rate : D → ℝ≥0) (J : ℕ) + (c : C) (v : {v : V // color v = c}) + (hsingle : ∀ u, color u = c → u = v.val) + (hcompat : ∀ d ∈ s v, label d = none ∨ label d = some c) + (hin : inside label c (s v) = Finset.univ) (z : Block label R none → ℕ) + {L base delta alpha : ℝ} (hL : 10000 ≤ L) + (hmass : mass (fun d : IntDir label c => rate d) (inside label c (s v)) = + L * (base + delta - alpha)) + (hint : (37 / 50 : ℝ) ≤ base + delta - alpha) (hbase : (37 / 50 : ℝ) ≤ base) + (ha : 0 ≤ alpha) (hd : |delta| + alpha ≤ 1) {K : ℕ} (hK : K ≤ R / 2) : + |∫ x, componentFactor label R color s (Real.exp (-L * base)) own J c z x + ∂batchMeasure (fun i : Block label R (some c) => rate i.1.2)| ≤ + Real.exp (-(17 / 25 : ℝ) * (L * R)) * + (|delta| ^ (R / 2) + alpha ^ K + + (if R < J then 0 else + ∑ d ∈ inside label c (s v), ((R : ℝ) * (rate d : ℝ)) ^ J) + + if BAD (touched label R c (s v) z) then 1 else 0) := by + by_cases hRJ : R < J + · simp only [ite_eq_left hRJ, add_zero] + by_cases hg : ¬ BAD (touched label R c (s v) z) + · simp only [ite_eq_right hg, add_zero] + rw [simple_component_integral label R color s _ own rate J c v hsingle hcompat hin z] + simp_rw [overloaded_eq_empty _ hRJ, Set.compl_empty, Set.indicator_univ] + exact simple_singleton_attenuation _ _ (own v) (touched label R c (s v) z) + hL hmass hint hbase ha hd (untouched_of_not_bad _ hg) hK + · simp only [not_not] at hg + simp only [ite_eq_left hg] + have hn := nonsimple_component_attenuation label R color s own rate J c v z + hcompat hL hmass hint hbase + have hat : Real.exp (-(7 / 10 : ℝ) * (L * R)) ≤ + Real.exp (-(17 / 25 : ℝ) * (L * R)) := by + apply Real.exp_le_exp.mpr + have hLR : 0 ≤ L * (R : ℝ) := mul_nonneg (by linarith) (by positivity) + nlinarith + calc + _ ≤ ∫ x, |componentFactor label R color s (Real.exp (-L * base)) own J c z x| + ∂batchMeasure (fun i : Block label R (some c) => rate i.1.2) := abs_integral_le_integral_abs + _ ≤ _ := hn + _ ≤ Real.exp (-(17 / 25 : ℝ) * (L * R)) := hat + _ ≤ _ := by + apply le_mul_of_one_le_right (Real.exp_pos _).le + have haK : 0 ≤ alpha ^ K := pow_nonneg ha K + have hdN : 0 ≤ |delta| ^ (R / 2) := by positivity + linarith + · simpa only [ite_eq_right hRJ] using + simple_component_designations_raw label R color s own rate J c v hsingle + hcompat hin z hL hmass hint hbase ha hd hK + +end SharpRamseyFive.TupleComponents + +namespace SharpRamseyFive.HighMoment +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponents +open Classical +variable {D H : Type} [Fintype D] [DecidableEq D] [Fintype H] [DecidableEq H] +variable (R : ℕ) (s : H → Finset D) (b : ℝ) (own : H → Fin R → Bool) + +noncomputable def allTrunc (J : ℕ) (ω : Fin R × D → ℕ) : ℝ := + ∏ d : D, lineTrunc R J (fun r => ω (r,d)) + +omit [DecidableEq D] in +lemma allTrunc_range (J : ℕ) (ω : Fin R × D → ℕ) : + allTrunc R J ω ∈ Set.Icc (0 : ℝ) 1 := by + constructor + · exact Finset.prod_nonneg (fun _ _ => (lineTrunc_range R J _).1) + · exact Finset.prod_le_one₀ (fun _ _ => (lineTrunc_range R J _).1) + (fun _ _ => (lineTrunc_range R J _).2) + +omit [Fintype H] [DecidableEq H] in +omit [Fintype D] [DecidableEq D] in +lemma scoreTerm_abs_le (hb : b ∈ Set.Icc (0 : ℝ) 1) (h : H) (ω : Fin R × D → ℕ) : + |scoreTerm (s h) b (own h) (fun r d => ω (r,d))| ≤ 1 := by + simpa only [maskedTerm, maskedFactor, Bool.false_eq_true, ↓reduceIte, scoreTerm] + using abs_maskedTerm_le_one (s h) hb (own h) (fun _ => false) (fun r d => ω (r,d)) +omit [Fintype H] [DecidableEq H] in +omit [DecidableEq D] in + +lemma truncated_tuple_abs_le (J : ℕ) (hb : b ∈ Set.Icc (0 : ℝ) 1) + {V : Type} [Fintype V] (f : V → H) (ω : Fin R × D → ℕ) : + |allTrunc R J ω * ∏ v, scoreTerm (s (f v)) b (own (f v)) (fun r d => ω (r,d))| ≤ 1 := by + rw [abs_mul, abs_of_nonneg (allTrunc_range R J ω).1, Finset.abs_prod] + exact (mul_le_of_le_one_left (by positivity) (allTrunc_range R J ω).2).trans + (Finset.prod_le_one₀ (fun _ _ => abs_nonneg _) + (fun _ _ => scoreTerm_abs_le R s b own hb _ ω)) + +end SharpRamseyFive.HighMoment +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Entropy/ExternalMass.lean b/lean/OAI/Combinatorics/SharpRamsey/Entropy/ExternalMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..ccce687ff26fffdb7394bd54cfa7271ba057b39e --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Entropy/ExternalMass.lean @@ -0,0 +1,478 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Entropy.ForcedHits + +namespace OAI + +/-! High moments, finite-field subspaces, and incidence bounds. -/ + +section +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +namespace SharpRamseyFive.PoissonScore +variable {ι : Type*} [Fintype ι] [DecidableEq ι] +variable {κ : Type*} +variable {κ : Type*} [Fintype κ] [DecidableEq κ] +section ComponentGeometry +variable {H : Type*} [Fintype H] [DecidableEq H] +omit [Fintype ι] in +lemma external_mass_le (rate : ι → ℝ≥0) (s : H → Finset ι) + {t : ℝ} (ht : 0 ≤ t) (h : H) : + mass rate (externalPart rate s t h) ≤ (Fintype.card H - 1 : ℕ) * t := by + classical + let K := otherComponents rate s t h + have hK : K ⊆ Finset.univ.erase h := by + intro k hk + simp only [K, otherComponents, Finset.mem_filter, Finset.mem_univ, true_and] at hk + simp only [Finset.mem_erase, Finset.mem_univ, and_true] + intro he + subst k + exact hk rfl + have hc : K.card ≤ Fintype.card H - 1 := by + simpa only [Finset.card_erase_of_mem (Finset.mem_univ h), Finset.card_univ] using + Finset.card_le_card hK + calc + _ ≤ ∑ k ∈ K, mass rate (s h ∩ s k) := external_mass_le_sum rate s t h + _ ≤ K.card * t := by + simpa only [nsmul_eq_mul] using Finset.sum_le_card_nsmul K + (fun k => mass rate (s h ∩ s k)) t (by + intro k hk + apply cross_component_overlap rate s t + simpa only [K, otherComponents, Finset.mem_filter, Finset.mem_univ, true_and] using hk) + _ ≤ _ := mul_le_mul_of_nonneg_right (by exact_mod_cast hc) ht + +omit [Fintype ι] in + +lemma internal_mass_lower (rate : ι → ℝ≥0) (s : H → Finset ι) + {t c : ℝ} (ht : 0 ≤ t) (hs : ∀ h, c ≤ mass rate (s h)) (h : H) : + c - (Fintype.card H - 1 : ℕ) * t ≤ mass rate (internalPart rate s t h) := by + have := external_mass_le rate s ht h + have := internal_external_mass rate s t h + have := hs h + linarith + +omit [Fintype ι] [Fintype H] [DecidableEq H] in +lemma internal_parts_disjoint (rate : ι → ℝ≥0) (s : H → Finset ι) + (t : ℝ) {h k : H} (hc : (strongGraph rate s t).connectedComponentMk h ≠ + (strongGraph rate s t).connectedComponentMk k) : + Disjoint (internalPart rate s t h) (internalPart rate s t k) := by + classical + apply Finset.disjoint_left.mpr + intro i hi hk + simp only [internalPart, Finset.mem_filter] at hi hk + exact hi.2 ⟨h, k, hi.1, hk.1, hc⟩ + +noncomputable def componentLabel (rate : ι → ℝ≥0) (s : H → Finset ι) + (t : ℝ) (i : ι) : Option (strongGraph rate s t).ConnectedComponent := by + classical + exact if hi : ∃ h, i ∈ s h then + if External rate s t i then none else + some ((strongGraph rate s t).connectedComponentMk hi.choose) + else none + +omit [Fintype ι] [DecidableEq H] in +lemma componentLabel_external (rate : ι → ℝ≥0) (s : H → Finset ι) + (t : ℝ) {i : ι} (hi : External rate s t i) : + componentLabel rate s t i = none := by + classical + simp only [componentLabel, hi, ↓reduceIte] + split_ifs <;> rfl + +omit [Fintype ι] [DecidableEq H] in +lemma componentLabel_internal (rate : ι → ℝ≥0) (s : H → Finset ι) + (t : ℝ) {h : H} {i : ι} (hi : i ∈ internalPart rate s t h) : + componentLabel rate s t i = some ((strongGraph rate s t).connectedComponentMk h) := by + classical + simp only [internalPart, Finset.mem_filter] at hi + have hex : ∃ k, i ∈ s k := ⟨h, hi.1⟩ + have he := hex.choose_spec + have hc : (strongGraph rate s t).connectedComponentMk hex.choose = + (strongGraph rate s t).connectedComponentMk h := by + by_contra hn + exact hi.2 ⟨hex.choose, h, he, hi.1, hn⟩ + simp only [componentLabel, dite_eq_left hex, ite_eq_right hi.2, hc] +omit [Fintype ι] [DecidableEq H] in + +lemma internalPart_iff_label (rate : ι → ℝ≥0) (s : H → Finset ι) + (t : ℝ) (h : H) (i : ι) : + i ∈ internalPart rate s t h ↔ i ∈ s h ∧ + componentLabel rate s t i = some ((strongGraph rate s t).connectedComponentMk h) := by + classical + constructor + · intro hi + exact ⟨(Finset.mem_filter.mp hi).1, componentLabel_internal rate s t hi⟩ + · rintro ⟨hi, he⟩ + apply Finset.mem_filter.mpr + refine ⟨hi, ?_⟩ + intro hn + rw [componentLabel_external rate s t hn] at he + cases he + +omit [Fintype ι] [DecidableEq H] in + +lemma direction_internal_or_external (rate : ι → ℝ≥0) (s : H → Finset ι) + (t : ℝ) {h : H} {i : ι} (hi : i ∈ s h) : + componentLabel rate s t i = none ∨ + componentLabel rate s t i = some ((strongGraph rate s t).connectedComponentMk h) := by + classical + by_cases he : External rate s t i + · exact Or.inl (componentLabel_external rate s t he) + · exact Or.inr (componentLabel_internal rate s t (Finset.mem_filter.mpr ⟨hi, he⟩)) +omit [Fintype ι] in + +lemma source_internal_mass_lower (rate : ι → ℝ≥0) (s : H → Finset ι) + {p : ℕ} (hp : 0 < p) (hc : Fintype.card H ≤ p) + (hs : ∀ h, (3 / 4 : ℝ) ≤ mass rate (s h)) (h : H) : + (37 / 50 : ℝ) ≤ mass rate (internalPart rate s (1 / (100 * p)) h) := by + have ht : (0 : ℝ) ≤ 1 / (100 * p : ℝ) := by positivity + have hl := internal_mass_lower rate s ht hs h + have hh : (0 : ℝ) < p := by exact_mod_cast hp + have hcard : ((Fintype.card H - 1 : ℕ) : ℝ) ≤ (p : ℝ) := by + exact_mod_cast ((Nat.sub_le (Fintype.card H) 1).trans hc) + have hm : ((Fintype.card H - 1 : ℕ) : ℝ) * (1 / (100 * p)) ≤ (1 / 100 : ℝ) := by + calc + _ ≤ (p : ℝ) * (1 / (100 * p)) := mul_le_mul_of_nonneg_right hcard ht + _ = _ := by field_simp + linarith + +end ComponentGeometry + +end SharpRamseyFive.PoissonScore + +namespace SharpRamseyFive.TupleComponents +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open SharpRamseyFive.PoissonScore +open Classical +variable {D V C : Type} [Fintype D] [DecidableEq D] + [Fintype V] [DecidableEq V] [Fintype C] [DecidableEq C] +variable (label : D → Option C) (R : ℕ) + +abbrev Block (c : Option C) := {i : Fin R × D // label i.2 = c} +noncomputable def fill (c : C) (z : Block label R none → ℕ) + (x : Block label R (some c) → ℕ) (r : Fin R) (d : D) : ℕ := + if he : label d = none then z ⟨(r,d), he⟩ else + if hi : label d = some c then x ⟨(r,d), hi⟩ else 0 + +omit [Fintype D] [DecidableEq D] [Fintype C] in +lemma fill_restrict (c : C) (ω : Fin R × D → ℕ) {d : D} + (hd : label d = none ∨ label d = some c) (r : Fin R) : + fill label R c (fun i => ω i) (fun i => ω i) r d = ω (r,d) := by + rcases hd with hd | hd <;> simp [fill, hd] + +noncomputable def lineTrunc (J : ℕ) (ω : Fin R → ℕ) : ℝ := + if (Finset.univ.filter (fun r => ω r ≠ 0)).card < J then 1 else 0 + +noncomputable def blockTrunc (J : ℕ) (c : Option C) (ω : Block label R c → ℕ) : ℝ := + ∏ d : {d : D // label d = c}, lineTrunc R J (fun r => ω ⟨(r,d), d.property⟩) + +lemma lineTrunc_range (J : ℕ) (ω : Fin R → ℕ) : + lineTrunc R J ω ∈ Set.Icc (0 : ℝ) 1 := by unfold lineTrunc; split_ifs <;> norm_num + +omit [DecidableEq D] [Fintype C] in +lemma blockTrunc_range (J : ℕ) (c : Option C) (ω : Block label R c → ℕ) : + blockTrunc label R J c ω ∈ Set.Icc (0 : ℝ) 1 := by + constructor + · exact Finset.prod_nonneg (fun _ _ => (lineTrunc_range R J _).1) + · exact Finset.prod_le_one₀ (fun _ _ => (lineTrunc_range R J _).1) + (fun _ _ => (lineTrunc_range R J _).2) + +lemma prod_fibers {A K : Type} [Fintype A] [Fintype K] [DecidableEq K] + (col : A → K) (f : A → ℝ) : + (∏ c : K, ∏ a : {a : A // col a = c}, f a) = ∏ a, f a := by + classical + calc + _ = ∏ c : K, ∏ a ∈ Finset.univ.filter (fun a => col a = c), f a := by + apply Finset.prod_congr rfl + intro c _ + symm + exact Finset.prod_subtype _ (by simp) f + _ = _ := by + simpa using Finset.prod_fiberwise Finset.univ col f + +omit [DecidableEq D] in +lemma trunc_split (J : ℕ) (ω : Fin R × D → ℕ) : + (∏ d : D, lineTrunc R J (fun r => ω (r,d))) = + blockTrunc label R J none (fun i => ω i) * + ∏ c : C, blockTrunc label R J (some c) (fun i => ω i) := by + rw [← Fintype.prod_option (fun c => blockTrunc label R J c (fun i => ω i))] + exact (prod_fibers label (fun d => lineTrunc R J (fun r => ω (r,d)))).symm + +omit [Fintype D] [DecidableEq D] in +lemma emptyIndicator_congr (s : Finset D) (ω ν : D → ℕ) + (he : ∀ d ∈ s, ω d = ν d) : emptyIndicator s ω = emptyIndicator s ν := by + have h : ω ∈ emptyEvent s ↔ ν ∈ emptyEvent s := by + simp only [emptyEvent, Set.mem_pi, Set.mem_singleton_iff, Finset.mem_coe] + exact forall₂_congr (fun d hd => by rw [he d hd]) + by_cases hω : ω ∈ emptyEvent s + · simp [emptyIndicator, hω, h.mp hω] + · simp [emptyIndicator, hω, (not_congr h).mp hω] +omit [Fintype D] [DecidableEq D] in + +lemma scoreTerm_congr (s : Finset D) (b : ℝ) (own : Fin R → Bool) + (ω ν : Fin R → D → ℕ) (he : ∀ r d, d ∈ s → ω r d = ν r d) : + scoreTerm s b own ω = scoreTerm s b own ν := by + unfold scoreTerm + apply Finset.prod_congr rfl + intro r _ + simp only [centeredFactor, emptyIndicator_congr s (ω r) (ν r) (he r)] + +variable (color : V → C) (s : V → Finset D) (b : ℝ) (own : V → Fin R → Bool) + +noncomputable def componentFactor (J : ℕ) (c : C) + (z : Block label R none → ℕ) (x : Block label R (some c) → ℕ) : ℝ := + blockTrunc label R J (some c) x * + ∏ v : {v : V // color v = c}, scoreTerm (s v) b (own v) (fill label R c z x) + +omit [DecidableEq V] in +omit [Fintype C] in +omit [DecidableEq D] in +lemma componentFactor_bound (J : ℕ) (hb : b ∈ Set.Icc (0 : ℝ) 1) (c : C) + (z : Block label R none → ℕ) (x : Block label R (some c) → ℕ) : + |componentFactor label R color s b own J c z x| ≤ 1 := by + rw [componentFactor, abs_mul, Finset.abs_prod] + have htrunc : |blockTrunc label R J (some c) x| ≤ 1 := by + rw [abs_of_nonneg (blockTrunc_range label R J (some c) x).1] + exact (blockTrunc_range label R J (some c) x).2 + refine (mul_le_of_le_one_left (Finset.prod_nonneg (fun _ _ => abs_nonneg _)) + htrunc).trans ?_ + apply Finset.prod_le_one₀ (fun _ _ => abs_nonneg _) + intro vertex _ + simpa only [maskedTerm, maskedFactor, Bool.false_eq_true, ↓reduceIte, scoreTerm] + using abs_maskedTerm_le_one (s vertex) hb (own vertex) (fun _ => false) + (fill label R c z x) + +omit [DecidableEq V] in +omit [DecidableEq D] in +lemma tuple_pointwise_split (J : ℕ) + (hcompat : ∀ v d, d ∈ s v → label d = none ∨ label d = some (color v)) + (ω : Fin R × D → ℕ) : + (∏ d : D, lineTrunc R J (fun r => ω (r,d))) * + (∏ v : V, scoreTerm (s v) b (own v) (fun r d => ω (r,d))) = + blockTrunc label R J none (fun i => ω i) * + ∏ c : C, componentFactor label R color s b own J c + (fun i => ω i) (fun i => ω i) := by + have he (c : C) (v : {v : V // color v = c}) : + scoreTerm (s v) b (own v) + (fill label R c (fun i => ω i) (fun i => ω i)) = + scoreTerm (s v) b (own v) (fun r d => ω (r,d)) := by + apply scoreTerm_congr R + intro r d hd + apply fill_restrict label R c ω _ r + simpa only [v.property] using hcompat v d hd + simp_rw [componentFactor, he] + rw [Finset.prod_mul_distrib, prod_fibers color (fun v => scoreTerm (s v) b (own v) (fun r d => ω (r,d)))] + rw [trunc_split label R J ω] + ring + +omit [DecidableEq V] in +omit [DecidableEq D] in + +theorem tuple_integral_split (rate : D → ℝ≥0) (J : ℕ) + (hb : b ∈ Set.Icc (0 : ℝ) 1) + (hcompat : ∀ v d, d ∈ s v → label d = none ∨ label d = some (color v)) : + (∫ ω, (∏ d : D, lineTrunc R J (fun r => ω (r,d))) * + (∏ v : V, scoreTerm (s v) b (own v) (fun r d => ω (r,d))) + ∂batchMeasure (fun i : Fin R × D => rate i.2)) = + ∫ z, blockTrunc label R J none z * ∏ c : C, + ∫ x, componentFactor label R color s b own J c z x + ∂batchMeasure (fun i : Block label R (some c) => rate i.1.2) + ∂batchMeasure (fun i : Block label R none => rate i.1.2) := by + have he := integral_external_components (fun i : Fin R × D => rate i.2) + (fun i => label i.2) (blockTrunc label R J none) + (componentFactor label R color s b own J) + (fun z => by rw [abs_of_nonneg (blockTrunc_range label R J none z).1]; + exact (blockTrunc_range label R J none z).2) + (componentFactor_bound label R color s b own J hb) + rw [← he] + apply integral_congr_ae + exact Filter.Eventually.of_forall (tuple_pointwise_split label R color s b own J hcompat) + +noncomputable def strongSplit (weight rate : D → ℝ≥0) (t : ℝ) (J : ℕ) : ℝ := by + classical + let G := strongGraph weight s t + let label := componentLabel weight s t + exact ∫ z, blockTrunc label R J none z * ∏ c : G.ConnectedComponent, + ∫ x, componentFactor label R G.connectedComponentMk s b own J c z x + ∂batchMeasure (fun i : Block label R (some c) => rate i.1.2) + ∂batchMeasure (fun i : Block label R none => rate i.1.2) + +lemma strong_tuple_integral_split (weight rate : D → ℝ≥0) (t : ℝ) (J : ℕ) + (hb : b ∈ Set.Icc (0 : ℝ) 1) : + (∫ ω, (∏ d : D, lineTrunc R J (fun r => ω (r,d))) * + (∏ v : V, scoreTerm (s v) b (own v) (fun r d => ω (r,d))) + ∂batchMeasure (fun i : Fin R × D => rate i.2)) = + strongSplit R s b own weight rate t J := by + classical + unfold strongSplit + apply tuple_integral_split _ R _ s b own rate J hb + intro v d hd + exact direction_internal_or_external weight s t hd + +abbrev IntDir (c : C) := {d : D // label d = some c} + +noncomputable def inside (c : C) (S : Finset D) : Finset (IntDir label c) := + Finset.univ.filter (fun d => d.val ∈ S) + +noncomputable def touched (_c : C) (S : Finset D) (z : Block label R none → ℕ) + (r : Fin R) : Bool := + decide (∃ d : {d : D // label d = none}, d.val ∈ S ∧ z ⟨(r,d), d.property⟩ ≠ 0) + +noncomputable def unblock (c : C) (x : Block label R (some c) → ℕ) : + Fin R → IntDir label c → ℕ := fun r d => x ⟨(r,d), d.property⟩ + +omit [Fintype C] in +lemma fill_empty_iff (c : C) (S : Finset D) + (hc : ∀ d ∈ S, label d = none ∨ label d = some c) + (z : Block label R none → ℕ) (x : Block label R (some c) → ℕ) (r : Fin R) : + fill label R c z x r ∈ emptyEvent S ↔ + touched label R c S z r = false ∧ + unblock label R c x r ∈ emptyEvent (inside label c S) := by + simp only [emptyEvent, Set.mem_pi, Set.mem_singleton_iff, Finset.mem_coe] + constructor + · intro h + constructor + · simp only [touched, decide_eq_false_iff_not, not_exists, not_and] + intro d hd + have := h d hd + simpa [fill, d.property] using this + · intro d hd + have := h d (Finset.mem_filter.mp hd).2 + simpa [fill, d.property, unblock] using this + · rintro ⟨he, hi⟩ d hd + rcases hc d hd with hd0 | hdc + · have hz : z ⟨(r,d), hd0⟩ = 0 := by + have he' : ¬ ∃ d : {d : D // label d = none}, + d.val ∈ S ∧ z ⟨(r,d), d.property⟩ ≠ 0 := by + simpa only [touched, decide_eq_false_iff_not] using he + by_contra hn + exact he' ⟨⟨d,hd0⟩, hd, hn⟩ + simpa [fill, hd0] using hz + · have hz := hi ⟨d,hdc⟩ (by simp [inside, hd]) + simpa [fill, hdc, unblock] using hz +omit [Fintype C] in + +lemma scoreTerm_eq_masked (c : C) (S : Finset D) (B : ℝ) (o : Fin R → Bool) + (hc : ∀ d ∈ S, label d = none ∨ label d = some c) + (z : Block label R none → ℕ) (x : Block label R (some c) → ℕ) : + scoreTerm S B o (fill label R c z x) = + maskedTerm (inside label c S) B o (touched label R c S z) (unblock label R c x) := by + apply Finset.prod_congr rfl + intro r _ + have hh := fill_empty_iff label R c S hc z x r + cases ho : o r <;> simp only [maskedFactor, Bool.false_eq_true, ↓reduceIte] + by_cases he : touched label R c S z r = true + · have hn : fill label R c z x r ∉ emptyEvent S := by simpa [he] using hh + simp [he, centeredFactor, emptyIndicator, hn] + · have ht : touched label R c S z r = false := Bool.eq_false_of_not_eq_true he + simp only [ht, true_and] at hh + by_cases hi : unblock label R c x r ∈ emptyEvent (inside label c S) + · simp [ht, centeredFactor, emptyIndicator, hi, hh.mpr hi] + · simp [ht, centeredFactor, emptyIndicator, hi, (not_congr hh).mpr hi] + +noncomputable def blockCoords (c : C) : (Fin R × IntDir label c) ≃ Block label R (some c) where + toFun i := ⟨(i.1,i.2), i.2.property⟩ + invFun i := (i.1.1, ⟨i.1.2, i.property⟩) + left_inv _ := rfl + right_inv _ := rfl + +noncomputable def unblockEquiv (c : C) : + (Block label R (some c) → ℕ) ≃ᵐ (Fin R → IntDir label c → ℕ) := + (MeasurableEquiv.piCongrLeft (fun _ : Block label R (some c) => ℕ) + (blockCoords label R c)).symm.trans (MeasurableEquiv.curry (Fin R) (IntDir label c) ℕ) + +omit [Fintype D] [DecidableEq D] [Fintype C] [DecidableEq C] in +@[simp] lemma unblockEquiv_apply (c : C) (x : Block label R (some c) → ℕ) : + unblockEquiv label R c x = unblock label R c x := rfl + +omit [Fintype C] in +omit [DecidableEq D] in +lemma measurePreserving_unblock (rate : D → ℝ≥0) (c : C) : + MeasurePreserving (unblockEquiv label R c) + (batchMeasure (fun i : Block label R (some c) => rate i.1.2)) + (scheduleMeasure (fun d : IntDir label c => rate d) R) := by + exact (measurePreserving_uncurry_schedule (fun d : IntDir label c => rate d) R).symm.comp + (measurePreserving_piCongrLeft + (fun i : Block label R (some c) => poissonMeasure (rate i.1.2)) + (blockCoords label R c)).symm + +omit [DecidableEq D] [Fintype C] in +lemma integrable_block_bounded (rate : D → ℝ≥0) (c : Option C) + (f : (Block label R c → ℕ) → ℝ) (h : ∀ x, |f x| ≤ 1) : + Integrable f (batchMeasure (fun i : Block label R c => rate i.1.2)) := by + apply Integrable.of_bound (measurable_of_countable f).aestronglyMeasurable 1 + exact Filter.Eventually.of_forall (fun x => by simpa only [Real.norm_eq_abs] using h x) +omit [Fintype C] in +omit [DecidableEq D] in + +lemma componentFactor_abs_le_term (J : ℕ) (hb : b ∈ Set.Icc (0 : ℝ) 1) + (c : C) (z : Block label R none → ℕ) (x : Block label R (some c) → ℕ) + (v : {v : V // color v = c}) : + |componentFactor label R color s b own J c z x| ≤ + |scoreTerm (s v) b (own v) (fill label R c z x)| := by + have hterm (u : V) : |scoreTerm (s u) b (own u) (fill label R c z x)| ≤ 1 := by + simpa only [maskedTerm, maskedFactor, Bool.false_eq_true, ↓reduceIte, scoreTerm] + using abs_maskedTerm_le_one (s u) hb (own u) (fun _ => false) (fill label R c z x) + rw [componentFactor, abs_mul, Finset.abs_prod] + have hp : (∏ u : {v : V // color v = c}, + |scoreTerm (s u) b (own u) (fill label R c z x)|) ≤ + |scoreTerm (s v) b (own v) (fill label R c z x)| := by + rw [← Finset.prod_erase_mul _ _ (Finset.mem_univ v)] + have he : (∏ u ∈ Finset.univ.erase v, + |scoreTerm (s u) b (own u) (fill label R c z x)|) ≤ 1 := + Finset.prod_le_one₀ (fun _ _ => abs_nonneg _) (fun u _ => hterm u) + simpa using mul_le_mul_of_nonneg_right he (abs_nonneg + (scoreTerm (s v) b (own v) (fill label R c z x))) + calc + _ ≤ ∏ u : {v : V // color v = c}, + |scoreTerm (s u) b (own u) (fill label R c z x)| := by + apply mul_le_of_le_one_left (Finset.prod_nonneg (fun _ _ => abs_nonneg _)) + rw [abs_of_nonneg (blockTrunc_range label R J (some c) x).1] + exact (blockTrunc_range label R J (some c) x).2 + _ ≤ _ := hp + +omit [Fintype C] in + +lemma component_integral_abs_le (rate : D → ℝ≥0) (J : ℕ) + (c : C) (v : {v : V // color v = c}) (z : Block label R none → ℕ) + (hcompat : ∀ d ∈ s v, label d = none ∨ label d = some c) + {L lam base a : ℝ} (hL : 0 ≤ L) (ha : 0 ≤ a) + (hmass : mass (fun d : IntDir label c => rate d) (inside label c (s v)) = L * lam) + (hlam : a ≤ lam) (hbase : a ≤ base) : + (∫ x, |componentFactor label R color s (Real.exp (-L * base)) own J c z x| + ∂batchMeasure (fun i : Block label R (some c) => rate i.1.2)) ≤ + (2 * Real.exp (-L * a)) ^ R := by + have hb : Real.exp (-L * base) ∈ Set.Icc (0 : ℝ) 1 := + ⟨(Real.exp_pos _).le, Real.exp_le_one_iff.mpr (by nlinarith)⟩ + let f := fun w => |maskedTerm (inside label c (s v)) (Real.exp (-L * base)) + (own v) (touched label R c (s v) z) w| + have he (x : Block label R (some c) → ℕ) : + |scoreTerm (s v) (Real.exp (-L * base)) (own v) (fill label R c z x)| = + f (unblockEquiv label R c x) := by + rw [scoreTerm_eq_masked label R c (s v) _ _ hcompat] + rfl + calc + _ ≤ ∫ x, f (unblockEquiv label R c x) + ∂batchMeasure (fun i : Block label R (some c) => rate i.1.2) := by + apply integral_mono + · apply integrable_block_bounded label R rate (some c) + intro x + rw [abs_abs] + exact componentFactor_bound label R color s _ own J hb c z x + · apply integrable_block_bounded label R rate (some c) + intro x + dsimp only [f] + rw [abs_abs] + exact abs_maskedTerm_le_one _ hb _ _ _ + · intro x + dsimp only + rw [← he x] + exact componentFactor_abs_le_term label R color s _ own J hb c z x v + _ = ∫ w, f w ∂scheduleMeasure (fun d : IntDir label c => rate d) R := + (measurePreserving_unblock label R rate c).integral_comp + (unblockEquiv label R c).measurableEmbedding f + _ ≤ _ := integral_abs_maskedTerm_exp_le _ _ _ _ hL hmass hlam hbase + +end SharpRamseyFive.TupleComponents +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Entropy/ForcedHits.lean b/lean/OAI/Combinatorics/SharpRamsey/Entropy/ForcedHits.lean new file mode 100644 index 0000000000000000000000000000000000000000..49cc29b05d63ebe275ef7ff7f527589a618dfa64 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Entropy/ForcedHits.lean @@ -0,0 +1,467 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Entropy.IntegralTypicalScoreSq + +namespace OAI + +/-! High moments, finite-field subspaces, and incidence bounds. -/ + +section +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +namespace SharpRamseyFive.PoissonScore +variable {ι : Type*} [Fintype ι] [DecidableEq ι] +variable {κ : Type*} +omit [Fintype ι] [DecidableEq ι] in +lemma forcedHits_le_one {R : ℕ} (i : ι) (T : Finset (Fin R)) (ω : Fin R → ι → ℕ) : + forcedHits i T ω ≤ 1 := Finset.prod_le_one₀ (fun _ _ => hitIndicator_nonneg _ _) + (fun _ _ => hitIndicator_le_one _ _) + +omit [Fintype ι] [DecidableEq ι] in +lemma abs_maskedTerm_mul_forcedHits {R : ℕ} (s : Finset ι) (i : ι) + (T : Finset (Fin R)) (b : ℝ) (own touched : Fin R → Bool) (ω : Fin R → ι → ℕ) : + |maskedTerm s b own touched ω| * forcedHits i T ω = + ∏ r, (|maskedFactor s b (own r) (touched r) (ω r)| * + if r ∈ T then hitIndicator i (ω r) else 1) := by + simp only [maskedTerm, Finset.abs_prod, Finset.prod_mul_distrib, + Finset.prod_ite_mem, Finset.univ_inter, forcedHits] +omit [DecidableEq ι] in + +lemma integral_abs_maskedTerm_forcedHits_le (rate : ι → ℝ≥0) {R : ℕ} + (s : Finset ι) (i : ι) (hi : i ∈ s) (T : Finset (Fin R)) + (own touched : Fin R → Bool) {L lam base c : ℝ} (hL : 0 ≤ L) + (hmass : mass rate s = L * lam) (hlam : c ≤ lam) (hbase : c ≤ base) : + (∫ ω, |maskedTerm s (Real.exp (-L * base)) own touched ω| * forcedHits i T ω + ∂scheduleMeasure rate R) ≤ + (2 * Real.exp (-L * c)) ^ R * (rate i : ℝ) ^ T.card := by + simp_rw [abs_maskedTerm_mul_forcedHits] + unfold scheduleMeasure + rw [integral_fintype_prod_eq_prod (f := fun r ω => + |maskedFactor s (Real.exp (-L * base)) (own r) (touched r) ω| * + if r ∈ T then hitIndicator i ω else 1)] + calc + _ ≤ ∏ r, (2 * Real.exp (-L * c)) * (if r ∈ T then (rate i : ℝ) else 1) := by + apply Finset.prod_le_prod₀ + · intro r _ + apply integral_nonneg + intro ω + apply mul_nonneg (abs_nonneg _) + split + · exact hitIndicator_nonneg _ _ + · norm_num + · intro r _ + by_cases hr : r ∈ T + · simp only [hr, ↓reduceIte] + have h := integral_abs_maskedFactor_hit_le rate s i hi (own r) (touched r) hL hbase + have he := Real.exp_pos (-L * c) + have hi0 : 0 ≤ (rate i : ℝ) := (rate i).coe_nonneg + nlinarith + · simp only [hr, ↓reduceIte, mul_one] + exact integral_abs_maskedFactor_exp_le rate s _ _ hL hmass hlam hbase + _ = _ := by rw [Finset.prod_mul_distrib]; simp [Finset.prod_ite_mem] + +def hitBatches {R : ℕ} (i : ι) (ω : Fin R → ι → ℕ) : Finset (Fin R) := + Finset.univ.filter (fun r => ω r i ≠ 0) + +def overloaded {R : ℕ} (s : Finset ι) (J : ℕ) : Set (Fin R → ι → ℕ) := + {ω | ∃ i ∈ s, J ≤ (hitBatches i ω).card} + +omit [Fintype ι] [DecidableEq ι] in + +lemma overloaded_eq_empty {R J : ℕ} (s : Finset ι) (h : R < J) : + (overloaded s J : Set (Fin R → ι → ℕ)) = ∅ := by + apply Set.eq_empty_iff_forall_notMem.mpr + intro ω he + obtain ⟨i, hi, hJ⟩ := he + have hc : (hitBatches i ω).card ≤ R := by + simpa only [hitBatches, Finset.card_univ, Fintype.card_fin] using + Finset.card_le_card (Finset.filter_subset (fun r : Fin R => ω r i ≠ 0) Finset.univ) + omega +omit [Fintype ι] [DecidableEq ι] in + +lemma forcedHits_eq_one_of_subset {R : ℕ} (i : ι) (T : Finset (Fin R)) + (ω : Fin R → ι → ℕ) (h : T ⊆ hitBatches i ω) : forcedHits i T ω = 1 := by + apply Finset.prod_eq_one + intro r hr + rw [hitIndicator_eq] + have hz : ω r i ≠ 0 := (Finset.mem_filter.mp (h hr)).2 + simp [hz] +omit [Fintype ι] [DecidableEq ι] in + +lemma overload_indicator_le_certificates {R : ℕ} (s : Finset ι) (J : ℕ) + (ω : Fin R → ι → ℕ) : + (overloaded s J).indicator (fun _ => (1 : ℝ)) ω ≤ + ∑ i ∈ s, ∑ T ∈ (Finset.univ : Finset (Fin R)).powersetCard J, forcedHits i T ω := by + have hnonneg : ∀ i, 0 ≤ ∑ T ∈ (Finset.univ : Finset (Fin R)).powersetCard J, forcedHits i T ω := by + intro i + exact Finset.sum_nonneg (fun T _ => forcedHits_nonneg i T ω) + by_cases h : ω ∈ overloaded s J + · rw [Set.indicator_of_mem h] + obtain ⟨i, hi, hcard⟩ := h + obtain ⟨T, hT, hTc⟩ := Finset.exists_subset_card_eq hcard + have hTm : T ∈ (Finset.univ : Finset (Fin R)).powersetCard J := by + simp only [Finset.mem_powersetCard] + exact ⟨Finset.subset_univ _, hTc⟩ + calc + 1 = forcedHits i T ω := (forcedHits_eq_one_of_subset i T ω hT).symm + _ ≤ ∑ U ∈ (Finset.univ : Finset (Fin R)).powersetCard J, forcedHits i U ω := + Finset.single_le_sum (fun U _ => forcedHits_nonneg i U ω) hTm + _ ≤ _ := Finset.single_le_sum (fun i _ => hnonneg i) hi + · rw [Set.indicator_of_notMem h] + exact Finset.sum_nonneg (fun i _ => hnonneg i) +omit [DecidableEq ι] in + +lemma integrable_abs_maskedTerm_forcedHits (rate : ι → ℝ≥0) {R : ℕ} + (s : Finset ι) {b : ℝ} (hb : b ∈ Set.Icc 0 1) (own touched : Fin R → Bool) + (i : ι) (T : Finset (Fin R)) : + Integrable (fun ω => |maskedTerm s b own touched ω| * forcedHits i T ω) + (scheduleMeasure rate R) := by + apply integrable_schedule_of_abs_le rate _ 1 + intro ω + rw [abs_mul, abs_abs, abs_of_nonneg (forcedHits_nonneg i T ω)] + exact (mul_le_of_le_one_left (forcedHits_nonneg i T ω) + (abs_maskedTerm_le_one s hb own touched ω)).trans (forcedHits_le_one i T ω) + +omit [DecidableEq ι] in + +lemma truncation_error_raw (rate : ι → ℝ≥0) {R : ℕ} (s : Finset ι) (J : ℕ) + (own touched : Fin R → Bool) {L lam base c : ℝ} (hL : 0 ≤ L) (hc : 0 ≤ c) + (hmass : mass rate s = L * lam) (hlam : c ≤ lam) (hbase : c ≤ base) : + (∫ ω, (overloaded s J).indicator (fun ω => + |maskedTerm s (Real.exp (-L * base)) own touched ω|) ω ∂scheduleMeasure rate R) ≤ + (2 * Real.exp (-L * c)) ^ R * ∑ i ∈ s, ((R : ℝ) * (rate i : ℝ)) ^ J := by + have hb : Real.exp (-L * base) ∈ Set.Icc 0 1 := + ⟨(Real.exp_pos _).le, Real.exp_le_one_iff.mpr (by nlinarith)⟩ + let f := fun ω => |maskedTerm s (Real.exp (-L * base)) own touched ω| + have hf (i : ι) (T : Finset (Fin R)) := integrable_abs_maskedTerm_forcedHits rate s hb own touched i T + have hpoint (ω) : (overloaded s J).indicator f ω ≤ + ∑ i ∈ s, ∑ T ∈ (Finset.univ : Finset (Fin R)).powersetCard J, f ω * forcedHits i T ω := by + have hh := mul_le_mul_of_nonneg_left (overload_indicator_le_certificates s J ω) (abs_nonneg + (maskedTerm s (Real.exp (-L * base)) own touched ω)) + by_cases he : ω ∈ overloaded s J + · simpa [he, f, Finset.mul_sum] using hh + · simpa [he, f, Finset.mul_sum] using hh + calc + _ ≤ ∫ ω, ∑ i ∈ s, ∑ T ∈ (Finset.univ : Finset (Fin R)).powersetCard J, + f ω * forcedHits i T ω ∂scheduleMeasure rate R := by + apply integral_mono + · apply integrable_schedule_of_abs_le rate _ 1 + intro ω + by_cases h : ω ∈ overloaded s J + · simpa [h] using abs_maskedTerm_le_one s hb own touched ω + · simp [h] + · exact integrable_finsetSum _ (fun i _ => integrable_finsetSum _ (fun T _ => hf i T)) + · exact hpoint + _ = ∑ i ∈ s, ∑ T ∈ (Finset.univ : Finset (Fin R)).powersetCard J, + ∫ ω, f ω * forcedHits i T ω ∂scheduleMeasure rate R := by + rw [integral_finsetSum _ (fun i _ => integrable_finsetSum _ (fun T _ => hf i T))] + apply Finset.sum_congr rfl + intro i hi + rw [integral_finsetSum _ (fun T _ => hf i T)] + _ ≤ ∑ i ∈ s, (2 * Real.exp (-L * c)) ^ R * ((R : ℝ) * (rate i : ℝ)) ^ J := by + apply Finset.sum_le_sum + intro i hi + calc + _ ≤ ∑ T ∈ (Finset.univ : Finset (Fin R)).powersetCard J, + (2 * Real.exp (-L * c)) ^ R * (rate i : ℝ) ^ J := by + apply Finset.sum_le_sum + intro T hT + have hTJ := (Finset.mem_powersetCard.mp hT).2 + simpa only [hTJ] using integral_abs_maskedTerm_forcedHits_le rate s i hi T + own touched hL hmass hlam hbase + _ = (R.choose J : ℝ) * ((2 * Real.exp (-L * c)) ^ R * (rate i : ℝ) ^ J) := by simp + _ ≤ _ := by + have hchoose : (R.choose J : ℝ) ≤ (R : ℝ) ^ J := by exact_mod_cast Nat.choose_le_pow R J + calc + _ ≤ (R : ℝ) ^ J * ((2 * Real.exp (-L * c)) ^ R * (rate i : ℝ) ^ J) := + mul_le_mul_of_nonneg_right hchoose (by positivity) + _ = _ := by rw [mul_pow]; ring + _ = _ := (Finset.mul_sum _ _ _).symm +omit [DecidableEq ι] in + +lemma truncation_error (rate : ι → ℝ≥0) {R : ℕ} (s : Finset ι) (J : ℕ) + (own touched : Fin R → Bool) {L lam base : ℝ} (hL : 10000 ≤ L) + (hmass : mass rate s = L * lam) (hlam : (37 / 50 : ℝ) ≤ lam) + (hbase : (37 / 50 : ℝ) ≤ base) : + (∫ ω, (overloaded s J).indicator (fun ω => + |maskedTerm s (Real.exp (-L * base)) own touched ω|) ω ∂scheduleMeasure rate R) ≤ + Real.exp (-(17 / 25 : ℝ) * (L * R)) * + ∑ i ∈ s, ((R : ℝ) * (rate i : ℝ)) ^ J := by + have hraw := truncation_error_raw rate s J own touched (show 0 ≤ L by linarith) + (show (0 : ℝ) ≤ 37 / 50 by norm_num) hmass hlam hbase + apply hraw.trans + apply mul_le_mul_of_nonneg_right _ (Finset.sum_nonneg (fun _ _ => by positivity)) + calc + (2 * Real.exp (-L * (37 / 50 : ℝ))) ^ R ≤ + (2 * L * Real.exp (-L * (37 / 50 : ℝ))) ^ R := by + apply pow_le_pow_left₀ (by positivity) + have := Real.exp_pos (-L * (37 / 50 : ℝ)) + nlinarith + _ ≤ _ := by simpa only [neg_mul, mul_comm L (37 / 50 : ℝ)] using two_mul_score_attenuation hL R +omit [DecidableEq ι] in + +lemma abs_integral_compl_indicator_le (rate : ι → ℝ≥0) {R : ℕ} + (s : Finset ι) {b : ℝ} (hb : b ∈ Set.Icc 0 1) (own touched : Fin R → Bool) + (E : Set (Fin R → ι → ℕ)) : + |∫ ω, Eᶜ.indicator (maskedTerm s b own touched) ω ∂scheduleMeasure rate R| ≤ + |∫ ω, maskedTerm s b own touched ω ∂scheduleMeasure rate R| + + ∫ ω, E.indicator (fun ω => |maskedTerm s b own touched ω|) ω ∂scheduleMeasure rate R := by + have hf := integrable_schedule_of_abs_le rate _ 1 (abs_maskedTerm_le_one s hb own touched) + have hEf : Integrable (E.indicator (maskedTerm s b own touched)) (scheduleMeasure rate R) := by + apply integrable_schedule_of_abs_le rate _ 1 + intro ω + by_cases h : ω ∈ E + · simpa [h] using abs_maskedTerm_le_one s hb own touched ω + · simp [h] + have heq : Eᶜ.indicator (maskedTerm s b own touched) = + fun ω => maskedTerm s b own touched ω - E.indicator (maskedTerm s b own touched) ω := by + funext ω + by_cases h : ω ∈ E <;> simp [h] + rw [heq, integral_sub hf hEf] + apply (abs_sub _ _).trans + apply add_le_add le_rfl + have habs : (fun ω => |E.indicator (maskedTerm s b own touched) ω|) = + (E.indicator (fun ω => |maskedTerm s b own touched ω|)) := by + funext ω + by_cases h : ω ∈ E <;> simp [h] + rw [← habs] + exact abs_integral_le_integral_abs + +omit [DecidableEq ι] in + +lemma simple_singleton_truncated (rate : ι → ℝ≥0) {R : ℕ} + (s : Finset ι) (J : ℕ) (own touched : Fin R → Bool) {L base delta alpha : ℝ} + (hL : 10000 ≤ L) (hmass : mass rate s = L * (base + delta - alpha)) + (hinternal : (37 / 50 : ℝ) ≤ base + delta - alpha) (hbase : (37 / 50 : ℝ) ≤ base) + (ha : 0 ≤ alpha) (hd : |delta| + alpha ≤ 1) {N K : ℕ} + (hN : N ≤ (untouchedBatches touched).card) (hK : K ≤ N) : + |∫ ω, (overloaded s J)ᶜ.indicator + (maskedTerm s (Real.exp (-L * base)) own touched) ω ∂scheduleMeasure rate R| ≤ + Real.exp (-(17 / 25 : ℝ) * (L * R)) * + (|delta| ^ N + alpha ^ K + ∑ i ∈ s, ((R : ℝ) * (rate i : ℝ)) ^ J) := by + have hb : Real.exp (-L * base) ∈ Set.Icc 0 1 := + ⟨(Real.exp_pos _).le, Real.exp_le_one_iff.mpr (by nlinarith)⟩ + calc + _ ≤ _ := abs_integral_compl_indicator_le rate s hb own touched (overloaded s J) + _ ≤ Real.exp (-(17 / 25 : ℝ) * (L * R)) * (|delta| ^ N + alpha ^ K) + + Real.exp (-(17 / 25 : ℝ) * (L * R)) * ∑ i ∈ s, ((R : ℝ) * (rate i : ℝ)) ^ J := + add_le_add (simple_singleton_attenuation rate s own touched hL hmass hinternal hbase ha hd hN hK) + (truncation_error rate s J own touched hL hmass hinternal hbase) + _ = _ := by ring + +omit [DecidableEq ι] in +lemma measurePreserving_uncurry_schedule (rate : ι → ℝ≥0) (R : ℕ) : + MeasurePreserving (MeasurableEquiv.curry (Fin R) ι ℕ).symm + (scheduleMeasure rate R) (batchMeasure (fun p : Fin R × ι => rate p.2)) := by + refine ⟨(MeasurableEquiv.curry (Fin R) ι ℕ).symm.measurable, ?_⟩ + simpa only [Measure.infinitePi_eq_pi, scheduleMeasure, batchMeasure] using + Measure.infinitePi_map_curry_symm (fun (_ : Fin R) i => poissonMeasure (rate i)) + +variable {κ : Type*} [Fintype κ] [DecidableEq κ] + +noncomputable def partitionEquiv (label : ι → κ) : + (ι → ℕ) ≃ᵐ (∀ c : κ, {i : ι // label i = c} → ℕ) := + (MeasurableEquiv.piCongrLeft (fun _ : ι => ℕ) (Equiv.sigmaFiberEquiv label)).symm.trans + (MeasurableEquiv.piCurry (fun (c : κ) (_ : {i : ι // label i = c}) => ℕ)) + +omit [Fintype ι] [DecidableEq ι] [Fintype κ] [DecidableEq κ] in +@[simp] lemma partitionEquiv_apply (label : ι → κ) (ω : ι → ℕ) (c : κ) + (i : {i : ι // label i = c}) : partitionEquiv label ω c i = ω i := rfl + +omit [DecidableEq ι] in +lemma measurePreserving_partition (rate : ι → ℝ≥0) (label : ι → κ) : + MeasurePreserving (partitionEquiv label) (batchMeasure rate) + (Measure.pi (fun c : κ => batchMeasure (fun i : {i : ι // label i = c} => rate i))) := by + have hc : MeasurePreserving + (MeasurableEquiv.piCurry (fun (c : κ) (_ : {i : ι // label i = c}) => ℕ)) + (Measure.pi (fun p : (c : κ) × {i : ι // label i = c} => poissonMeasure (rate p.2))) + (Measure.pi (fun c : κ => batchMeasure (fun i : {i : ι // label i = c} => rate i))) := by + refine ⟨(MeasurableEquiv.piCurry _).measurable, ?_⟩ + simpa only [Measure.infinitePi_eq_pi, batchMeasure] using + Measure.infinitePi_map_piCurry (fun (c : κ) (i : {i : ι // label i = c}) => + poissonMeasure (rate i)) + exact hc.comp ((measurePreserving_piCongrLeft (fun i => poissonMeasure (rate i)) + (Equiv.sigmaFiberEquiv label)).symm) + +omit [DecidableEq ι] in + +lemma integral_partition_prod (rate : ι → ℝ≥0) (label : ι → κ) + (f : ∀ c : κ, ({i : ι // label i = c} → ℕ) → ℝ) : + (∫ ω, ∏ c, f c (fun i => ω i) ∂batchMeasure rate) = + ∏ c, ∫ ω, f c ω ∂batchMeasure (fun i : {i : ι // label i = c} => rate i) := by + calc + _ = ∫ ω, ∏ c, f c (ω c) ∂Measure.pi + (fun c : κ => batchMeasure (fun i : {i : ι // label i = c} => rate i)) := + (measurePreserving_partition rate label).integral_comp + (partitionEquiv label).measurableEmbedding _ + _ = _ := integral_fintype_prod_eq_prod _ + +noncomputable def externalEquiv (label : ι → Option κ) : + (ι → ℕ) ≃ᵐ ((∀ c : κ, {i : ι // label i = some c} → ℕ) × + ({i : ι // label i = none} → ℕ)) := + (partitionEquiv label).trans (MeasurableEquiv.piOptionEquivProd + (fun c : Option κ => {i : ι // label i = c} → ℕ)) +omit [DecidableEq ι] in + +lemma measurePreserving_external (rate : ι → ℝ≥0) (label : ι → Option κ) : + MeasurePreserving (externalEquiv label) (batchMeasure rate) + ((Measure.pi (fun c : κ => batchMeasure + (fun i : {i : ι // label i = some c} => rate i))).prod + (batchMeasure (fun i : {i : ι // label i = none} => rate i))) := by + have h : MeasurePreserving + (MeasurableEquiv.piOptionEquivProd + (fun c : Option κ => {i : ι // label i = c} → ℕ)).symm + ((Measure.pi (fun c : κ => batchMeasure + (fun i : {i : ι // label i = some c} => rate i))).prod + (batchMeasure (fun i : {i : ι // label i = none} => rate i))) + (Measure.pi (fun c : Option κ => batchMeasure + (fun i : {i : ι // label i = c} => rate i))) := + ⟨(MeasurableEquiv.piOptionEquivProd _).symm.measurable, + Measure.pi_map_piOptionEquivProd (fun c : Option κ => + batchMeasure (fun i : {i : ι // label i = c} => rate i))⟩ + exact h.symm.comp (measurePreserving_partition rate label) + +omit [DecidableEq ι] in + +lemma integral_external_components (rate : ι → ℝ≥0) (label : ι → Option κ) + (weight : ({i : ι // label i = none} → ℕ) → ℝ) + (f : ∀ c : κ, ({i : ι // label i = none} → ℕ) → + ({i : ι // label i = some c} → ℕ) → ℝ) + (hw : ∀ z, |weight z| ≤ 1) (hf : ∀ c z x, |f c z x| ≤ 1) : + (∫ ω, weight (fun i => ω i) * ∏ c, f c (fun i => ω i) (fun i => ω i) + ∂batchMeasure rate) = + ∫ z, weight z * ∏ c, ∫ x, f c z x + ∂batchMeasure (fun i : {i : ι // label i = some c} => rate i) + ∂batchMeasure (fun i : {i : ι // label i = none} => rate i) := by + let μ := Measure.pi (fun c : κ => batchMeasure + (fun i : {i : ι // label i = some c} => rate i)) + let ν := batchMeasure (fun i : {i : ι // label i = none} => rate i) + let F : (∀ c : κ, {i : ι // label i = some c} → ℕ) × + ({i : ι // label i = none} → ℕ) → ℝ := + fun p => weight p.2 * ∏ c, f c p.2 (p.1 c) + have hF : Integrable F (μ.prod ν) := by + apply Integrable.of_bound (measurable_of_countable F).aestronglyMeasurable 1 + apply Filter.Eventually.of_forall + intro p + simp only [F, Real.norm_eq_abs, abs_mul, Finset.abs_prod] + exact (mul_le_of_le_one_left (by positivity) (hw _)).trans + (Finset.prod_le_one₀ (fun _ _ => abs_nonneg _) (fun _ _ => hf _ _ _)) + calc + _ = ∫ p, F p ∂μ.prod ν := (measurePreserving_external rate label).integral_comp + (externalEquiv label).measurableEmbedding F + _ = ∫ z, ∫ x, weight z * ∏ c, f c z (x c) ∂μ ∂ν := + integral_prod_symm F hF + _ = _ := by + apply integral_congr_ae + apply Filter.Eventually.of_forall + intro z + dsimp only + rw [integral_const_mul] + congr 1 + exact integral_fintype_prod_eq_prod _ + +section ComponentGeometry + +variable {H : Type*} [Fintype H] [DecidableEq H] + +noncomputable def strongGraph (rate : ι → ℝ≥0) (s : H → Finset ι) (t : ℝ) : + SimpleGraph H where + Adj h k := h ≠ k ∧ t < mass rate (s h ∩ s k) + symm := ⟨by + intro h k hk + exact ⟨hk.1.symm, by simpa only [Finset.inter_comm] using hk.2⟩⟩ + loopless := ⟨by intro h hh; exact hh.1 rfl⟩ + +omit [Fintype ι] [Fintype H] [DecidableEq H] in +lemma cross_component_overlap (rate : ι → ℝ≥0) (s : H → Finset ι) (t : ℝ) + {h k : H} (hd : (strongGraph rate s t).connectedComponentMk h ≠ + (strongGraph rate s t).connectedComponentMk k) : + mass rate (s h ∩ s k) ≤ t := by + by_contra hn + have hk : h ≠ k := by intro e; exact hd (congrArg _ e) + exact hd (SimpleGraph.ConnectedComponent.connectedComponentMk_eq_of_adj + (G := strongGraph rate s t) ⟨hk, lt_of_not_ge hn⟩) + +def External (rate : ι → ℝ≥0) (s : H → Finset ι) (t : ℝ) (i : ι) : Prop := + ∃ h k : H, i ∈ s h ∧ i ∈ s k ∧ + (strongGraph rate s t).connectedComponentMk h ≠ + (strongGraph rate s t).connectedComponentMk k + +omit [Fintype ι] [Fintype H] [DecidableEq H] in +lemma external_iff_other (rate : ι → ℝ≥0) (s : H → Finset ι) (t : ℝ) + {h : H} {i : ι} (hi : i ∈ s h) : + External rate s t i ↔ ∃ k : H, i ∈ s k ∧ + (strongGraph rate s t).connectedComponentMk h ≠ + (strongGraph rate s t).connectedComponentMk k := by + classical + constructor + · rintro ⟨u, v, hu, hv, huv⟩ + by_cases e : (strongGraph rate s t).connectedComponentMk h = + (strongGraph rate s t).connectedComponentMk u + · exact ⟨v, hv, by simpa only [e] using huv⟩ + · exact ⟨u, hu, e⟩ + · rintro ⟨k, hk, hd⟩ + exact ⟨h, k, hi, hk, hd⟩ + +noncomputable def externalPart (rate : ι → ℝ≥0) (s : H → Finset ι) + (t : ℝ) (h : H) : Finset ι := by + classical + exact (s h).filter (External rate s t) + +noncomputable def internalPart (rate : ι → ℝ≥0) (s : H → Finset ι) + (t : ℝ) (h : H) : Finset ι := by + classical + exact (s h).filter (fun i => ¬ External rate s t i) + +omit [Fintype ι] [Fintype H] [DecidableEq H] in +lemma internal_external_mass (rate : ι → ℝ≥0) (s : H → Finset ι) + (t : ℝ) (h : H) : + mass rate (externalPart rate s t h) + mass rate (internalPart rate s t h) = + mass rate (s h) := by + classical + exact Finset.sum_filter_add_sum_filter_not _ _ _ + +noncomputable def otherComponents (rate : ι → ℝ≥0) (s : H → Finset ι) + (t : ℝ) (h : H) : Finset H := by + classical + exact Finset.univ.filter (fun k => + (strongGraph rate s t).connectedComponentMk h ≠ + (strongGraph rate s t).connectedComponentMk k) + +omit [Fintype ι] [DecidableEq H] in + +lemma external_mass_le_sum (rate : ι → ℝ≥0) (s : H → Finset ι) + (t : ℝ) (h : H) : + mass rate (externalPart rate s t h) ≤ + ∑ k ∈ otherComponents rate s t h, mass rate (s h ∩ s k) := by + classical + let K := otherComponents rate s t h + have hp (i : ι) (hi : i ∈ s h) : + (if External rate s t i then (rate i : ℝ) else 0) ≤ + ∑ k ∈ K, if i ∈ s k then (rate i : ℝ) else 0 := by + split_ifs with he + · obtain ⟨k, hk, hd⟩ := (external_iff_other rate s t hi).mp he + have hkK : k ∈ K := by + simpa only [K, otherComponents, Finset.mem_filter, Finset.mem_univ, true_and] using hd + simpa only [ite_eq_left hk] using + (Finset.single_le_sum (f := fun j : H => if i ∈ s j then (rate i : ℝ) else 0) + (fun j (_ : j ∈ K) => by split_ifs <;> positivity) hkK : + (if i ∈ s k then (rate i : ℝ) else 0) ≤ + ∑ j ∈ K, if i ∈ s j then (rate i : ℝ) else 0) + · exact Finset.sum_nonneg (by intro k hk; split_ifs <;> positivity) + calc + _ = ∑ i ∈ s h, if External rate s t i then (rate i : ℝ) else 0 := by + simp only [externalPart, mass, Finset.sum_filter] + _ ≤ ∑ i ∈ s h, ∑ k ∈ K, if i ∈ s k then (rate i : ℝ) else 0 := + Finset.sum_le_sum hp + _ = ∑ k ∈ K, mass rate (s h ∩ s k) := by + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro k hk + rw [mass, ← Finset.filter_mem_eq_inter, Finset.sum_filter] + _ = _ := rfl + +end ComponentGeometry +end SharpRamseyFive.PoissonScore +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Entropy/HighMoments.lean b/lean/OAI/Combinatorics/SharpRamsey/Entropy/HighMoments.lean new file mode 100644 index 0000000000000000000000000000000000000000..b3bd53c0555716dd63b83947c3db207cd2679e8f --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Entropy/HighMoments.lean @@ -0,0 +1,423 @@ +import Mathlib + +namespace OAI + +/-! High moments, finite-field subspaces, and incidence bounds. -/ + +section +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal + +namespace SharpRamseyFive.PoissonScore + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +noncomputable def batchMeasure (rate : ι → ℝ≥0) : Measure (ι → ℕ) := + Measure.pi (fun i => poissonMeasure (rate i)) + +instance flat_HighMomentRecovered_1 (rate : ι → ℝ≥0) : IsProbabilityMeasure (batchMeasure rate) := by + unfold batchMeasure + infer_instance + +def emptyEvent (s : Finset ι) : Set (ι → ℕ) := + (s : Set ι).pi (fun _ => {0}) + +noncomputable def emptyIndicator (s : Finset ι) (ω : ι → ℕ) : ℝ := + (emptyEvent s).indicator (fun _ => 1) ω + +noncomputable def mass (rate : ι → ℝ≥0) (s : Finset ι) : ℝ := + ∑ i ∈ s, (rate i : ℝ) + +omit [Fintype ι] [DecidableEq ι] in +lemma measurableSet_emptyEvent (s : Finset ι) : MeasurableSet (emptyEvent s) := by + exact MeasurableSet.pi (s.finite_toSet.countable) (fun _ _ => measurableSet_singleton 0) + +omit [DecidableEq ι] in +lemma measure_emptyEvent (rate : ι → ℝ≥0) (s : Finset ι) : + batchMeasure rate (emptyEvent s) = ENNReal.ofReal (Real.exp (-mass rate s)) := by + rw [batchMeasure, emptyEvent, Measure.pi_pi_finset] + simp_rw [poissonMeasure_singleton, pow_zero, Nat.factorial_zero, Nat.cast_one, + mul_one, div_one] + rw [← ENNReal.ofReal_prod_of_nonneg (fun _ _ => (Real.exp_pos _).le), + ← Real.exp_sum, Finset.sum_neg_distrib] + rfl +omit [DecidableEq ι] in + +lemma integral_emptyIndicator (rate : ι → ℝ≥0) (s : Finset ι) : + ∫ ω, emptyIndicator s ω ∂batchMeasure rate = Real.exp (-mass rate s) := by + simp only [emptyIndicator] + rw [integral_indicator_const _ (measurableSet_emptyEvent s), + Measure.real, measure_emptyEvent, ENNReal.toReal_ofReal (Real.exp_pos _).le] + simp +omit [DecidableEq ι] in + +lemma integrable_emptyIndicator (rate : ι → ℝ≥0) (s : Finset ι) : + Integrable (emptyIndicator s) (batchMeasure rate) := + (integrable_const (1 : ℝ)).indicator (measurableSet_emptyEvent s) + +omit [Fintype ι] in +lemma emptyIndicator_mul (s t : Finset ι) (ω : ι → ℕ) : + emptyIndicator s ω * emptyIndicator t ω = emptyIndicator (s ∪ t) ω := by + have hu : emptyEvent (s ∪ t) = emptyEvent s ∩ emptyEvent t := by + ext x + simp [emptyEvent, Set.mem_pi, or_imp, forall_and] + rw [emptyIndicator, emptyIndicator, emptyIndicator, hu] + by_cases hs : ω ∈ emptyEvent s <;> by_cases ht : ω ∈ emptyEvent t <;> + simp [hs, ht] + +omit [Fintype ι] in +lemma mass_union_inter (rate : ι → ℝ≥0) (s t : Finset ι) : + mass rate (s ∪ t) + mass rate (s ∩ t) = mass rate s + mass rate t := by + exact Finset.sum_union_inter + +noncomputable def centeredFactor (s : Finset ι) (b : ℝ) (ω : ι → ℕ) : ℝ := + emptyIndicator s ω - b +omit [DecidableEq ι] in + +lemma integrable_centeredFactor (rate : ι → ℝ≥0) (s : Finset ι) (b : ℝ) : + Integrable (centeredFactor s b) (batchMeasure rate) := + (integrable_emptyIndicator rate s).sub (integrable_const b) +omit [DecidableEq ι] in + +lemma integral_centeredFactor (rate : ι → ℝ≥0) (s : Finset ι) (b : ℝ) : + ∫ ω, centeredFactor s b ω ∂batchMeasure rate = Real.exp (-mass rate s) - b := by + simp only [centeredFactor] + rw [integral_sub (integrable_emptyIndicator rate s) + (integrable_const b), integral_emptyIndicator] + simp + +lemma integral_centeredFactor_mul (rate : ι → ℝ≥0) (s t : Finset ι) (b : ℝ) : + (∫ ω, centeredFactor s b ω * centeredFactor t b ω ∂batchMeasure rate) = + (Real.exp (-mass rate s) - b) * (Real.exp (-mass rate t) - b) + + Real.exp (-(mass rate s + mass rate t)) * + (Real.exp (mass rate (s ∩ t)) - 1) := by + have he : (fun ω => centeredFactor s b ω * centeredFactor t b ω) = + fun ω => emptyIndicator (s ∪ t) ω - b * emptyIndicator s ω - + b * emptyIndicator t ω + b ^ 2 := by + funext ω + rw [centeredFactor, centeredFactor] + have := emptyIndicator_mul s t ω + nlinarith [this] + rw [he] + have hs := integrable_emptyIndicator rate s + have ht := integrable_emptyIndicator rate t + have hu := integrable_emptyIndicator rate (s ∪ t) + have h1 := integral_sub hu (hs.const_mul b) + have h2 := integral_sub (hu.sub (hs.const_mul b)) (ht.const_mul b) + have h3 := integral_add ((hu.sub (hs.const_mul b)).sub (ht.const_mul b)) + (integrable_const (b ^ 2)) + simp only [Pi.sub_apply] at h1 h2 h3 + rw [h3, h2, h1] + simp only [integral_const_mul, integral_emptyIndicator, integral_const, + probReal_univ, one_smul] + have hmass := mass_union_inter rate s t + have hu : Real.exp (-mass rate (s ∪ t)) = + Real.exp (-(mass rate s + mass rate t)) * Real.exp (mass rate (s ∩ t)) := by + rw [← Real.exp_add] + congr 1 + linarith + have hp : Real.exp (-mass rate s) * Real.exp (-mass rate t) = + Real.exp (-(mass rate s + mass rate t)) := by + rw [← Real.exp_add] + congr 1 + ring + rw [hu] + nlinarith [hp] + +omit [Fintype ι] [DecidableEq ι] in +lemma emptyIndicator_nonneg (s : Finset ι) (ω : ι → ℕ) : 0 ≤ emptyIndicator s ω := by + unfold emptyIndicator + apply Set.indicator_nonneg + intro _ _ + norm_num + +omit [Fintype ι] [DecidableEq ι] in +lemma abs_centeredFactor_le_one (s : Finset ι) (b : ℝ) (hb : b ∈ Set.Icc 0 1) + (ω : ι → ℕ) : |centeredFactor s b ω| ≤ 1 := by + unfold centeredFactor emptyIndicator + by_cases h : ω ∈ emptyEvent s <;> simp [h, abs_le] <;> constructor <;> linarith [hb.1, hb.2] + +omit [Fintype ι] [DecidableEq ι] in +lemma centeredFactor_of_hit (s : Finset ι) (b : ℝ) (ω : ι → ℕ) + {i : ι} (hi : i ∈ s) (hhit : ω i ≠ 0) : centeredFactor s b ω = -b := by + have h : ω ∉ emptyEvent s := by + intro he + exact hhit (he i hi) + simp [centeredFactor, emptyIndicator, h] +omit [DecidableEq ι] in + +lemma integral_abs_centeredFactor_le (rate : ι → ℝ≥0) (s : Finset ι) (b : ℝ) : + (∫ ω, |centeredFactor s b ω| ∂batchMeasure rate) ≤ Real.exp (-mass rate s) + |b| := by + calc + _ ≤ ∫ ω, emptyIndicator s ω + |b| ∂batchMeasure rate := by + apply integral_mono (integrable_centeredFactor rate s b).abs + ((integrable_emptyIndicator rate s).add (integrable_const |b|)) + intro ω + dsimp [centeredFactor] + exact (abs_sub _ _).trans (by rw [abs_of_nonneg (emptyIndicator_nonneg s ω)]) + _ = _ := by + rw [integral_add (integrable_emptyIndicator rate s) (integrable_const |b|), + integral_emptyIndicator] + simp + +lemma abs_exp_neg_sub_exp_neg_le {a b c : ℝ} (ha : c ≤ a) (hb : c ≤ b) : + |Real.exp (-a) - Real.exp (-b)| ≤ Real.exp (-c) * |a - b| := by + have ordered : ∀ {a b : ℝ}, c ≤ a → a ≤ b → + Real.exp (-a) - Real.exp (-b) ≤ Real.exp (-c) * (b - a) := by + intro a b hca hab + have he := Real.add_one_le_exp (a - b) + have hm := mul_le_mul_of_nonneg_left he (Real.exp_pos (-a)).le + have hprod : Real.exp (-a) * Real.exp (a - b) = Real.exp (-b) := by + rw [← Real.exp_add] + congr 1 + ring + rw [hprod] at hm + have hec : Real.exp (-a) ≤ Real.exp (-c) := Real.exp_le_exp.mpr (neg_le_neg hca) + have hd := mul_le_mul_of_nonneg_right hec (sub_nonneg.mpr hab) + nlinarith + rcases le_total a b with hab | hba + · rw [abs_of_nonneg (sub_nonneg.mpr (Real.exp_le_exp.mpr (neg_le_neg hab))), + abs_of_nonpos (sub_nonpos.mpr hab)] + simpa only [neg_sub] using ordered ha hab + · rw [abs_of_nonpos (sub_nonpos.mpr (Real.exp_le_exp.mpr (neg_le_neg hba))), + abs_of_nonneg (sub_nonneg.mpr hba)] + simpa only [neg_sub] using ordered hb hba + +omit [DecidableEq ι] in + +lemma abs_integral_centeredFactor_le (rate : ι → ℝ≥0) (s : Finset ι) + {L lam base c : ℝ} (hL : 0 ≤ L) (hmass : mass rate s = L * lam) + (hlam : c ≤ lam) (hbase : c ≤ base) : + |∫ ω, centeredFactor s (Real.exp (-L * base)) ω ∂batchMeasure rate| ≤ + L * Real.exp (-L * c) * |lam - base| := by + rw [integral_centeredFactor, hmass] + have he := abs_exp_neg_sub_exp_neg_le + (mul_le_mul_of_nonneg_left hlam hL) (mul_le_mul_of_nonneg_left hbase hL) + simpa only [neg_mul, mul_neg, ← mul_sub, abs_mul, abs_of_nonneg hL, mul_comm, + mul_left_comm, mul_assoc] using he + +omit [DecidableEq ι] in + +lemma integral_abs_centeredFactor_exp_le (rate : ι → ℝ≥0) (s : Finset ι) + {L lam base c : ℝ} (hL : 0 ≤ L) (hmass : mass rate s = L * lam) + (hlam : c ≤ lam) (hbase : c ≤ base) : + (∫ ω, |centeredFactor s (Real.exp (-L * base)) ω| ∂batchMeasure rate) ≤ + 2 * Real.exp (-L * c) := by + have h1 := integral_abs_centeredFactor_le rate s (Real.exp (-L * base)) + rw [hmass, abs_of_pos (Real.exp_pos _)] at h1 + have h2 : Real.exp (-(L * lam)) ≤ Real.exp (-L * c) := + Real.exp_le_exp.mpr (by nlinarith) + have h3 : Real.exp (-L * base) ≤ Real.exp (-L * c) := + Real.exp_le_exp.mpr (by nlinarith) + linarith + +lemma integrable_centeredFactor_mul (rate : ι → ℝ≥0) (s t : Finset ι) (b : ℝ) : + Integrable (fun ω => centeredFactor s b ω * centeredFactor t b ω) (batchMeasure rate) := by + have he : (fun ω => centeredFactor s b ω * centeredFactor t b ω) = + fun ω => emptyIndicator (s ∪ t) ω - b * emptyIndicator s ω - + b * emptyIndicator t ω + b ^ 2 := by + funext ω + rw [centeredFactor, centeredFactor] + nlinarith [emptyIndicator_mul s t ω] + rw [he] + exact (((integrable_emptyIndicator rate (s ∪ t)).sub + ((integrable_emptyIndicator rate s).const_mul b)).sub + ((integrable_emptyIndicator rate t).const_mul b)).add (integrable_const (b^2)) + +omit [Fintype ι] [DecidableEq ι] in +lemma mass_nonneg (rate : ι → ℝ≥0) (s : Finset ι) : 0 ≤ mass rate s := by + exact Finset.sum_nonneg (fun i _ => (rate i).coe_nonneg) + +omit [Fintype ι] [DecidableEq ι] in +lemma mass_mono (rate : ι → ℝ≥0) {s t : Finset ι} (hst : s ⊆ t) : + mass rate s ≤ mass rate t := by + exact Finset.sum_le_sum_of_subset_of_nonneg hst (fun i _ _ => (rate i).coe_nonneg) + +lemma one_sub_exp_neg_le (a : ℝ) : 1 - Real.exp (-a) ≤ a := by + have := Real.add_one_le_exp (-a) + linarith + +omit [Fintype ι] in + +lemma covariance_le (rate : ι → ℝ≥0) (s t : Finset ι) : + Real.exp (-(mass rate s + mass rate t)) * + (Real.exp (mass rate (s ∩ t)) - 1) ≤ + mass rate (s ∩ t) * Real.exp (-mass rate (s ∪ t)) := by + have hu := mass_union_inter rate s t + have he : Real.exp (-(mass rate s + mass rate t)) = + Real.exp (-mass rate (s ∪ t)) * Real.exp (-mass rate (s ∩ t)) := by + rw [← Real.exp_add] + congr 1 + linarith + rw [he] + have hh : Real.exp (-mass rate (s ∩ t)) * Real.exp (mass rate (s ∩ t)) = 1 := by + rw [← Real.exp_add] + simp + have hb := mul_le_mul_of_nonneg_left (one_sub_exp_neg_le (mass rate (s ∩ t))) + (Real.exp_pos (-mass rate (s ∪ t))).le + calc + _ = Real.exp (-mass rate (s ∪ t)) * (1 - Real.exp (-mass rate (s ∩ t))) := by + rw [mul_assoc, mul_sub, hh, mul_one] + _ ≤ _ := by simpa only [mul_comm] using hb +omit [Fintype ι] in + +lemma covariance_nonneg (rate : ι → ℝ≥0) (s t : Finset ι) : + 0 ≤ Real.exp (-(mass rate s + mass rate t)) * + (Real.exp (mass rate (s ∩ t)) - 1) := by + apply mul_nonneg (Real.exp_pos _).le + exact sub_nonneg.mpr (Real.one_le_exp_iff.mpr (mass_nonneg rate _)) + +lemma abs_integral_centeredFactor_mul_le_mass (rate : ι → ℝ≥0) + (s t : Finset ι) (b : ℝ) : + |∫ ω, centeredFactor s b ω * centeredFactor t b ω ∂batchMeasure rate| ≤ + |Real.exp (-mass rate s) - b| * |Real.exp (-mass rate t) - b| + + mass rate (s ∩ t) * Real.exp (-mass rate (s ∪ t)) := by + rw [integral_centeredFactor_mul] + calc + _ ≤ |(Real.exp (-mass rate s) - b) * (Real.exp (-mass rate t) - b)| + + |Real.exp (-(mass rate s + mass rate t)) * + (Real.exp (mass rate (s ∩ t)) - 1)| := abs_add_le _ _ + _ ≤ _ := by + rw [abs_mul, abs_of_nonneg (covariance_nonneg rate s t)] + exact add_le_add le_rfl (covariance_le rate s t) + +lemma abs_integral_centeredFactor_mul_exp_le (rate : ι → ℝ≥0) + (s t : Finset ι) {L lam₁ lam₂ base c θ : ℝ} + (hL : 1 ≤ L) (hc : 0 ≤ c) + (hs : mass rate s = L * lam₁) (ht : mass rate t = L * lam₂) + (hi : mass rate (s ∩ t) = L * θ) + (h₁ : c ≤ lam₁) (h₂ : c ≤ lam₂) (hbase : c ≤ base) : + |∫ ω, centeredFactor s (Real.exp (-L * base)) ω * + centeredFactor t (Real.exp (-L * base)) ω ∂batchMeasure rate| ≤ + L ^ 2 * Real.exp (-L * c) * (|lam₁ - base| * |lam₂ - base| + θ) := by + have hL0 : 0 ≤ L := le_trans (by norm_num) hL + have hi0 := mass_nonneg rate (s ∩ t) + have hθ : 0 ≤ θ := by rw [hi] at hi0; nlinarith + have hu : L * c ≤ mass rate (s ∪ t) := by + calc + _ ≤ L * lam₁ := mul_le_mul_of_nonneg_left h₁ hL0 + _ = mass rate s := hs.symm + _ ≤ mass rate (s ∪ t) := mass_mono rate Finset.subset_union_left + have huse : Real.exp (-mass rate (s ∪ t)) ≤ Real.exp (-L * c) := + Real.exp_le_exp.mpr (by linarith) + have hepos := Real.exp_pos (-L * c) + have hele : Real.exp (-L * c) ≤ 1 := Real.exp_le_one_iff.mpr (by nlinarith) + have e₁ := abs_integral_centeredFactor_le rate s hL0 hs h₁ hbase + have e₂ := abs_integral_centeredFactor_le rate t hL0 ht h₂ hbase + rw [integral_centeredFactor] at e₁ e₂ + have hmul := mul_le_mul e₁ e₂ (abs_nonneg _) + (mul_nonneg (mul_nonneg hL0 hepos.le) (abs_nonneg _)) + have hab := mul_nonneg (abs_nonneg (lam₁ - base)) (abs_nonneg (lam₂ - base)) + have hpow : Real.exp (-L * c) ^ 2 ≤ Real.exp (-L * c) := by nlinarith + have hbound := mul_le_mul_of_nonneg_left hpow + (mul_nonneg (sq_nonneg L) hab) + have hcov := mul_le_mul_of_nonneg_left huse hi0 + rw [hi] at hcov + have hLsq : L ≤ L ^ 2 := by nlinarith + have hcov' := mul_le_mul_of_nonneg_right hLsq (mul_nonneg hθ hepos.le) + have hfinal := abs_integral_centeredFactor_mul_le_mass rate s t (Real.exp (-L * base)) + nlinarith + +noncomputable def scheduleMeasure (rate : ι → ℝ≥0) (R : ℕ) : + Measure (Fin R → ι → ℕ) := + Measure.pi (fun _ : Fin R => batchMeasure rate) + +instance flat_HighMomentRecovered_2 (rate : ι → ℝ≥0) (R : ℕ) : IsProbabilityMeasure (scheduleMeasure rate R) := by + unfold scheduleMeasure + infer_instance + +noncomputable def scoreTerm {R : ℕ} (s : Finset ι) (b : ℝ) (own : Fin R → Bool) + (ω : Fin R → ι → ℕ) : ℝ := + ∏ r, if own r then centeredFactor s b (ω r) else 0 +omit [DecidableEq ι] in + +lemma integrable_scoreTerm (rate : ι → ℝ≥0) {R : ℕ} (s : Finset ι) (b : ℝ) + (own : Fin R → Bool) : Integrable (scoreTerm s b own) (scheduleMeasure rate R) := by + apply Integrable.fintype_prod (f := fun r ω => if own r then centeredFactor s b ω else 0) + intro r + cases h : own r <;> simp only [Bool.false_eq_true, ↓reduceIte] + · exact integrable_const 0 + · exact integrable_centeredFactor rate s b +omit [DecidableEq ι] in + +lemma integral_scoreTerm (rate : ι → ℝ≥0) {R : ℕ} (s : Finset ι) (b : ℝ) + (own : Fin R → Bool) : + (∫ ω, scoreTerm s b own ω ∂scheduleMeasure rate R) = + ∏ r, if own r then Real.exp (-mass rate s) - b else 0 := by + unfold scoreTerm scheduleMeasure + rw [integral_fintype_prod_eq_prod (f := fun r ω => if own r then centeredFactor s b ω else 0)] + congr 1 + funext r + cases h : own r <;> simp [integral_centeredFactor] + +noncomputable def pairMean (rate : ι → ℝ≥0) (s t : Finset ι) (b : ℝ) : ℝ := + (Real.exp (-mass rate s) - b) * (Real.exp (-mass rate t) - b) + + Real.exp (-(mass rate s + mass rate t)) * + (Real.exp (mass rate (s ∩ t)) - 1) + +lemma integrable_scoreTerm_mul (rate : ι → ℝ≥0) {R : ℕ} (s t : Finset ι) (b : ℝ) + (ownS ownT : Fin R → Bool) : + Integrable (fun ω => scoreTerm s b ownS ω * scoreTerm t b ownT ω) + (scheduleMeasure rate R) := by + simp only [scoreTerm, ← Finset.prod_mul_distrib] + apply Integrable.fintype_prod (f := fun r ω => (if ownS r then centeredFactor s b ω else 0) * (if ownT r then centeredFactor t b ω else 0)) + intro r + cases hs : ownS r <;> cases ht : ownT r <;> + simp only [Bool.false_eq_true, ↓reduceIte, zero_mul, mul_zero] + · exact integrable_const 0 + · exact integrable_const 0 + · exact integrable_const 0 + · exact integrable_centeredFactor_mul rate s t b + +lemma integral_scoreTerm_mul (rate : ι → ℝ≥0) {R : ℕ} (s t : Finset ι) (b : ℝ) + (ownS ownT : Fin R → Bool) : + (∫ ω, scoreTerm s b ownS ω * scoreTerm t b ownT ω ∂scheduleMeasure rate R) = + ∏ r, if ownS r && ownT r then pairMean rate s t b else 0 := by + simp only [scoreTerm, ← Finset.prod_mul_distrib, scheduleMeasure] + rw [integral_fintype_prod_eq_prod (f := fun r ω => (if ownS r then centeredFactor s b ω else 0) * (if ownT r then centeredFactor t b ω else 0))] + congr 1 + funext r + cases hs : ownS r <;> cases ht : ownT r <;> + simp [integral_centeredFactor_mul, pairMean] + +lemma abs_integral_scoreTerm_mul_le (rate : ι → ℝ≥0) {R : ℕ} (s t : Finset ι) (b : ℝ) + (ownS ownT : Fin R → Bool) : + |∫ ω, scoreTerm s b ownS ω * scoreTerm t b ownT ω ∂scheduleMeasure rate R| ≤ + |pairMean rate s t b| ^ R := by + rw [integral_scoreTerm_mul, Finset.abs_prod] + calc + _ ≤ ∏ _ : Fin R, |pairMean rate s t b| := by + apply Finset.prod_le_prod₀ (fun _ _ => abs_nonneg _) + intro r _ + split_ifs <;> simp + _ = _ := by simp + +variable {κ : Type*} + +noncomputable def typicalScore {R : ℕ} (H : Finset κ) (directions : κ → Finset ι) + (b : ℝ) (own : κ → Fin R → Bool) (ω : Fin R → ι → ℕ) : ℝ := + ∑ h ∈ H, scoreTerm (directions h) b (own h) ω + +lemma integral_typicalScore_sq (rate : ι → ℝ≥0) {R : ℕ} (H : Finset κ) + (directions : κ → Finset ι) (b : ℝ) (own : κ → Fin R → Bool) : + (∫ ω, (typicalScore H directions b own ω)^2 ∂scheduleMeasure rate R) = + ∑ h ∈ H, ∑ k ∈ H, + ∏ r, if own h r && own k r then pairMean rate (directions h) (directions k) b else 0 := by + simp only [typicalScore, pow_two] + simp_rw [Finset.sum_mul] + simp_rw [Finset.mul_sum] + rw [integral_finsetSum H (fun h _ => + integrable_finsetSum H (fun k _ => + integrable_scoreTerm_mul rate (directions h) (directions k) b (own h) (own k)))] + apply Finset.sum_congr rfl + intro h _ + rw [integral_finsetSum H (fun k _ => + integrable_scoreTerm_mul rate (directions h) (directions k) b (own h) (own k))] + apply Finset.sum_congr rfl + intro k _ + exact integral_scoreTerm_mul rate (directions h) (directions k) b (own h) (own k) + +end SharpRamseyFive.PoissonScore +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Entropy/HighRankEntropy.lean b/lean/OAI/Combinatorics/SharpRamsey/Entropy/HighRankEntropy.lean new file mode 100644 index 0000000000000000000000000000000000000000..311d93837578a7f4855222aac78ed6757e558b3f --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Entropy/HighRankEntropy.lean @@ -0,0 +1,63 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.HighRankContext + +namespace OAI + +section +namespace SharpLogRamsey.ActualHighRank +open Finset Real Selection +open scoped Classical BigOperators +noncomputable section +variable {K V Ω : Type*} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] [Fintype Ω] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + +omit [FiniteDimensional K V] + [Fintype (Projectivization K (Module.Dual K V))] in +lemma projective_card_bound {d : ℕ} (hdim : Module.finrank K V=d+1) : + (Fintype.card (Projectivization K V):ℝ)≤2*(Nat.card K:ℝ)^d := by + rw [←Nat.card_eq_fintype_card,Projectivization.card_of_finrank K V hdim,Nat.cast_sum] + simp only [Nat.cast_pow] + exact HighRankExcess.geom_sum_le_twice (by exact_mod_cast (Finite.one_lt_card : 1Nat.cast_nonneg _) (mem_range.mpr (by omega)) + +omit [FiniteDimensional K V] in +lemma flag_card_log {d : ℕ} (hdim : Module.finrank K V=d+1) : + log (Fintype.card (Projectivization K (Module.Dual K V)×Projectivization K V))≤ + 2*(log 2+(d:ℝ)*log (Nat.card K)) := by + have hdual : Module.finrank K (Module.Dual K V)=d+1 := by rw [Subspace.dual_finrank_eq,hdim] + have ha:=projective_card_bound hdual + have hb:=projective_card_bound hdim + have hap:=projective_card_positive hdual + have hbp:=projective_card_positive hdim + have hq : (0:ℝ) simp [emptyIndicator, emptyEvent] + | @insert h I hh ih => + rw [Finset.prod_insert hh, Finset.biUnion_insert, ih, emptyIndicator_mul] +omit [Fintype ι] in + +lemma prod_centeredFactor (I : Finset ν) (directions : ν → Finset ι) (b : ℝ) + (ω : ι → ℕ) : + (∏ h ∈ I, centeredFactor (directions h) b ω) = + ∑ J ∈ I.powerset, (-b) ^ (I \ J).card * emptyIndicator (J.biUnion directions) ω := by + simp only [centeredFactor, sub_eq_add_neg] + rw [Finset.prod_add] + apply Finset.sum_congr rfl + intro J _ + rw [prod_emptyIndicator, Finset.prod_const] + ring + +lemma integrable_prod_centeredFactor (rate : ι → ℝ≥0) (I : Finset ν) + (directions : ν → Finset ι) (b : ℝ) : + Integrable (fun ω => ∏ h ∈ I, centeredFactor (directions h) b ω) (batchMeasure rate) := by + simp_rw [prod_centeredFactor] + exact integrable_finsetSum _ (fun J _ => + (integrable_emptyIndicator rate _).const_mul _) + +noncomputable def tupleMean (rate : ι → ℝ≥0) (I : Finset ν) + (directions : ν → Finset ι) (b : ℝ) : ℝ := + ∑ J ∈ I.powerset, (-b) ^ (I \ J).card * Real.exp (-mass rate (J.biUnion directions)) + +lemma integral_prod_centeredFactor (rate : ι → ℝ≥0) (I : Finset ν) + (directions : ν → Finset ι) (b : ℝ) : + (∫ ω, ∏ h ∈ I, centeredFactor (directions h) b ω ∂batchMeasure rate) = + tupleMean rate I directions b := by + simp_rw [prod_centeredFactor] + rw [integral_finsetSum _ (fun J _ => + (integrable_emptyIndicator rate _).const_mul _)] + simp only [integral_const_mul, integral_emptyIndicator, tupleMean] + +omit [Fintype ι] [DecidableEq ι] [DecidableEq ν] in +lemma prod_scoreTerm (I : Finset ν) (directions : ν → Finset ι) (b : ℝ) + {R : ℕ} (own : ν → Fin R → Bool) (ω : Fin R → ι → ℕ) : + (∏ h ∈ I, scoreTerm (directions h) b (own h) ω) = + ∏ r, if ∀ h ∈ I, own h r then ∏ h ∈ I, centeredFactor (directions h) b (ω r) else 0 := by + simp only [scoreTerm] + rw [Finset.prod_comm] + apply Finset.prod_congr rfl + intro r _ + exact Finset.prod_ite_zero + +lemma integrable_prod_scoreTerm (rate : ι → ℝ≥0) (I : Finset ν) + (directions : ν → Finset ι) (b : ℝ) {R : ℕ} (own : ν → Fin R → Bool) : + Integrable (fun ω => ∏ h ∈ I, scoreTerm (directions h) b (own h) ω) + (scheduleMeasure rate R) := by + simp_rw [prod_scoreTerm] + apply Integrable.fintype_prod (f := fun r ω => if ∀ h ∈ I, own h r then + ∏ h ∈ I, centeredFactor (directions h) b ω else 0) + intro r + split_ifs + · exact integrable_prod_centeredFactor rate I directions b + · exact integrable_const 0 + +lemma integral_prod_scoreTerm (rate : ι → ℝ≥0) (I : Finset ν) + (directions : ν → Finset ι) (b : ℝ) {R : ℕ} (own : ν → Fin R → Bool) : + (∫ ω, ∏ h ∈ I, scoreTerm (directions h) b (own h) ω ∂scheduleMeasure rate R) = + ∏ r, if ∀ h ∈ I, own h r then tupleMean rate I directions b else 0 := by + simp_rw [prod_scoreTerm] + unfold scheduleMeasure + rw [integral_fintype_prod_eq_prod (f := fun r ω => if ∀ h ∈ I, own h r then + ∏ h ∈ I, centeredFactor (directions h) b ω else 0)] + apply Finset.prod_congr rfl + intro r _ + split_ifs <;> simp [integral_prod_centeredFactor] + +lemma abs_integral_prod_scoreTerm_le (rate : ι → ℝ≥0) (I : Finset ν) + (directions : ν → Finset ι) (b : ℝ) {R : ℕ} (own : ν → Fin R → Bool) : + |∫ ω, ∏ h ∈ I, scoreTerm (directions h) b (own h) ω ∂scheduleMeasure rate R| ≤ + |tupleMean rate I directions b| ^ R := by + rw [integral_prod_scoreTerm, Finset.abs_prod] + calc + _ ≤ ∏ _ : Fin R, |tupleMean rate I directions b| := by + apply Finset.prod_le_prod₀ (fun _ _ => abs_nonneg _) + intro r _ + split_ifs <;> simp + _ = _ := by simp + +end TupleCalculation + +lemma integral_typicalScore_pow (rate : ι → ℝ≥0) {R : ℕ} (H : Finset κ) + (directions : κ → Finset ι) (b : ℝ) (own : κ → Fin R → Bool) (p : ℕ) : + (∫ ω, (typicalScore H directions b own ω)^p ∂scheduleMeasure rate R) = + ∑ hs ∈ Fintype.piFinset (fun _ : Fin p => H), + ∏ r, if ∀ i : Fin p, own (hs i) r then + tupleMean rate Finset.univ (fun i => directions (hs i)) b else 0 := by + classical + simp only [typicalScore] + simp_rw [Finset.sum_pow'] + rw [integral_finsetSum _ (fun hs _ => + integrable_prod_scoreTerm rate Finset.univ (fun i => directions (hs i)) b (fun i => own (hs i)))] + apply Finset.sum_congr rfl + intro hs _ + simpa using integral_prod_scoreTerm rate Finset.univ (fun i => directions (hs i)) b (fun i => own (hs i)) + +noncomputable def maskedFactor (s : Finset ι) (b : ℝ) (own touched : Bool) + (ω : ι → ℕ) : ℝ := + if own then (if touched then -b else centeredFactor s b ω) else 0 + +noncomputable def maskedTerm {R : ℕ} (s : Finset ι) (b : ℝ) + (own touched : Fin R → Bool) (ω : Fin R → ι → ℕ) : ℝ := + ∏ r, maskedFactor s b (own r) (touched r) (ω r) +omit [Fintype ι] [DecidableEq ι] in + +lemma abs_maskedFactor_le_one (s : Finset ι) {b : ℝ} (hb : b ∈ Set.Icc 0 1) + (own touched : Bool) (ω : ι → ℕ) : |maskedFactor s b own touched ω| ≤ 1 := by + cases own <;> cases touched <;> simp [maskedFactor, abs_centeredFactor_le_one s b hb ω, + abs_of_nonneg hb.1, hb.2] +omit [Fintype ι] [DecidableEq ι] in + +lemma abs_maskedTerm_le_one {R : ℕ} (s : Finset ι) {b : ℝ} (hb : b ∈ Set.Icc 0 1) + (own touched : Fin R → Bool) (ω : Fin R → ι → ℕ) : + |maskedTerm s b own touched ω| ≤ 1 := by + rw [maskedTerm, Finset.abs_prod] + exact Finset.prod_le_one₀ (fun _ _ => abs_nonneg _) (fun _ _ => abs_maskedFactor_le_one s hb _ _ _) + +omit [DecidableEq ι] in +lemma integrable_schedule_of_abs_le (rate : ι → ℝ≥0) {R : ℕ} + (f : (Fin R → ι → ℕ) → ℝ) (C : ℝ) (h : ∀ ω, |f ω| ≤ C) : + Integrable f (scheduleMeasure rate R) := by + apply Integrable.of_bound (measurable_of_countable f).aestronglyMeasurable C + exact Filter.Eventually.of_forall (fun ω => by simpa only [Real.norm_eq_abs] using h ω) +omit [DecidableEq ι] in + +lemma integrable_maskedFactor (rate : ι → ℝ≥0) (s : Finset ι) (b : ℝ) + (own touched : Bool) : Integrable (maskedFactor s b own touched) (batchMeasure rate) := by + cases own <;> cases touched + · exact integrable_const 0 + · exact integrable_const 0 + · exact integrable_centeredFactor rate s b + · exact integrable_const (-b) +omit [DecidableEq ι] in + +lemma integral_maskedFactor (rate : ι → ℝ≥0) (s : Finset ι) (b : ℝ) + (own touched : Bool) : + (∫ ω, maskedFactor s b own touched ω ∂batchMeasure rate) = + if own then (if touched then -b else Real.exp (-mass rate s) - b) else 0 := by + cases own <;> cases touched <;> simp [maskedFactor, integral_centeredFactor] +omit [DecidableEq ι] in + +lemma integral_maskedTerm (rate : ι → ℝ≥0) {R : ℕ} (s : Finset ι) (b : ℝ) + (own touched : Fin R → Bool) : + (∫ ω, maskedTerm s b own touched ω ∂scheduleMeasure rate R) = + ∏ r, if own r then (if touched r then -b else Real.exp (-mass rate s) - b) else 0 := by + unfold maskedTerm scheduleMeasure + rw [integral_fintype_prod_eq_prod] + simp only [integral_maskedFactor] +omit [DecidableEq ι] in + +lemma integral_abs_maskedFactor_exp_le (rate : ι → ℝ≥0) (s : Finset ι) + (own touched : Bool) {L lam base c : ℝ} (hL : 0 ≤ L) + (hmass : mass rate s = L * lam) (hlam : c ≤ lam) (hbase : c ≤ base) : + (∫ ω, |maskedFactor s (Real.exp (-L * base)) own touched ω| ∂batchMeasure rate) ≤ + 2 * Real.exp (-L * c) := by + have he := Real.exp_pos (-L * c) + have hb : Real.exp (-L * base) ≤ Real.exp (-L * c) := + Real.exp_le_exp.mpr (by nlinarith) + cases own <;> cases touched <;> simp only [maskedFactor, Bool.false_eq_true, ↓reduceIte] + · simp only [abs_zero, integral_zero]; positivity + · simp only [abs_zero, integral_zero]; positivity + · exact integral_abs_centeredFactor_exp_le rate s hL hmass hlam hbase + · simp only [abs_neg, abs_of_pos (Real.exp_pos _), integral_const, probReal_univ, + smul_eq_mul, one_mul] + linarith +omit [DecidableEq ι] in + +lemma integral_abs_maskedTerm_exp_le (rate : ι → ℝ≥0) {R : ℕ} (s : Finset ι) + (own touched : Fin R → Bool) {L lam base c : ℝ} (hL : 0 ≤ L) + (hmass : mass rate s = L * lam) (hlam : c ≤ lam) (hbase : c ≤ base) : + (∫ ω, |maskedTerm s (Real.exp (-L * base)) own touched ω| ∂scheduleMeasure rate R) ≤ + (2 * Real.exp (-L * c)) ^ R := by + simp only [maskedTerm, Finset.abs_prod, scheduleMeasure] + rw [integral_fintype_prod_eq_prod (f := fun r ω => + |maskedFactor s (Real.exp (-L * base)) (own r) (touched r) ω|)] + calc + _ ≤ ∏ _ : Fin R, 2 * Real.exp (-L * c) := by + apply Finset.prod_le_prod₀ (fun _ _ => integral_nonneg (fun _ => abs_nonneg _)) + intro r _ + exact integral_abs_maskedFactor_exp_le rate s (own r) (touched r) hL hmass hlam hbase + _ = _ := by simp +omit [Fintype ι] [DecidableEq ι] in + +lemma abs_prod_maskedTerm_le {ν : Type*} [DecidableEq ν] {R : ℕ} + (I : Finset ν) (directions : ν → Finset ι) {b : ℝ} (hb : b ∈ Set.Icc 0 1) + (own touched : ν → Fin R → Bool) {h : ν} (hh : h ∈ I) (ω : Fin R → ι → ℕ) : + |∏ i ∈ I, maskedTerm (directions i) b (own i) (touched i) ω| ≤ + |maskedTerm (directions h) b (own h) (touched h) ω| := by + rw [Finset.abs_prod, ← Finset.prod_erase_mul _ _ hh] + have hp : (∏ i ∈ I.erase h, |maskedTerm (directions i) b (own i) (touched i) ω|) ≤ 1 := + Finset.prod_le_one₀ (fun _ _ => abs_nonneg _) (fun _ _ => abs_maskedTerm_le_one _ hb _ _ _) + simpa using mul_le_mul_of_nonneg_right hp + (abs_nonneg (maskedTerm (directions h) b (own h) (touched h) ω)) + +omit [DecidableEq ι] in + +lemma integral_abs_component_indicator_le (rate : ι → ℝ≥0) + {ν : Type*} [DecidableEq ν] {R : ℕ} (I : Finset ν) (directions : ν → Finset ι) + (own touched : ν → Fin R → Bool) (E : Set (Fin R → ι → ℕ)) + {h : ν} (hh : h ∈ I) {L lam base c : ℝ} (hL : 0 ≤ L) (hc : 0 ≤ c) + (hmass : mass rate (directions h) = L * lam) (hlam : c ≤ lam) (hbase : c ≤ base) : + (∫ ω, |E.indicator (fun ω => ∏ i ∈ I, + maskedTerm (directions i) (Real.exp (-L * base)) (own i) (touched i) ω) ω| + ∂scheduleMeasure rate R) ≤ (2 * Real.exp (-L * c)) ^ R := by + have hb : Real.exp (-L * base) ∈ Set.Icc 0 1 := + ⟨(Real.exp_pos _).le, Real.exp_le_one_iff.mpr (by nlinarith)⟩ + have hpoint : ∀ ω, |E.indicator (fun ω => ∏ i ∈ I, + maskedTerm (directions i) (Real.exp (-L * base)) (own i) (touched i) ω) ω| ≤ + |maskedTerm (directions h) (Real.exp (-L * base)) (own h) (touched h) ω| := by + intro ω + by_cases he : ω ∈ E + · simpa only [Set.indicator_of_mem he] using abs_prod_maskedTerm_le I directions hb own touched hh ω + · simp only [Set.indicator_of_notMem he, abs_zero]; exact abs_nonneg _ + calc + _ ≤ ∫ ω, |maskedTerm (directions h) (Real.exp (-L * base)) (own h) (touched h) ω| + ∂scheduleMeasure rate R := by + apply integral_mono + · apply integrable_schedule_of_abs_le rate _ 1 + intro ω + rw [abs_abs] + exact (hpoint ω).trans (abs_maskedTerm_le_one _ hb _ _ _) + · exact (integrable_schedule_of_abs_le rate _ 1 (abs_maskedTerm_le_one _ hb _ _)).abs + · exact hpoint + _ ≤ _ := integral_abs_maskedTerm_exp_le rate _ _ _ hL hmass hlam hbase + +def untouchedBatches {R : ℕ} (touched : Fin R → Bool) : Finset (Fin R) := + Finset.univ.filter (fun r => touched r = false) + +omit [DecidableEq ι] in + +lemma abs_integral_maskedTerm_le_untouched (rate : ι → ℝ≥0) {R : ℕ} + (s : Finset ι) (own touched : Fin R → Bool) {L base c delta alpha : ℝ} + (hL : 1 ≤ L) (hmass : mass rate s = L * (base + delta - alpha)) + (hinternal : c ≤ base + delta - alpha) (hbase : c ≤ base) (ha : 0 ≤ alpha) : + |∫ ω, maskedTerm s (Real.exp (-L * base)) own touched ω ∂scheduleMeasure rate R| ≤ + (L * Real.exp (-L * c)) ^ R * (|delta| + alpha) ^ (untouchedBatches touched).card := by + have hL0 : 0 ≤ L := by linarith + have he := (Real.exp_pos (-L * c)).le + have hd : 0 ≤ |delta| + alpha := add_nonneg (abs_nonneg _) ha + have hu := abs_integral_centeredFactor_le rate s hL0 hmass hinternal hbase + rw [integral_centeredFactor] at hu + have hdif : |base + delta - alpha - base| ≤ |delta| + alpha := by + calc + |base + delta - alpha - base| = |delta - alpha| := by congr 1; ring + _ ≤ |delta| + |alpha| := abs_sub _ _ + _ = _ := by rw [abs_of_nonneg ha] + have hu' := hu.trans (mul_le_mul_of_nonneg_left hdif (mul_nonneg hL0 he)) + have hb : Real.exp (-L * base) ≤ L * Real.exp (-L * c) := by + have h₁ : Real.exp (-L * base) ≤ Real.exp (-L * c) := + Real.exp_le_exp.mpr (by nlinarith) + have h₂ := mul_le_mul_of_nonneg_right hL he + nlinarith + rw [integral_maskedTerm, Finset.abs_prod] + calc + _ ≤ ∏ r, (L * Real.exp (-L * c)) * (if touched r then 1 else |delta| + alpha) := by + apply Finset.prod_le_prod₀ (fun _ _ => abs_nonneg _) + intro r _ + cases ho : own r <;> cases ht : touched r <;> + simp only [Bool.false_eq_true, ↓reduceIte, abs_neg, abs_zero, mul_one] + · exact mul_nonneg (mul_nonneg hL0 he) hd + · exact mul_nonneg hL0 he + · exact hu' + · simpa only [abs_of_pos (Real.exp_pos _)] using hb + _ = _ := by + rw [Finset.prod_mul_distrib] + simp [Finset.prod_ite, untouchedBatches] +omit [DecidableEq ι] in + +lemma abs_integral_maskedTerm_le_designations (rate : ι → ℝ≥0) {R : ℕ} + (s : Finset ι) (own touched : Fin R → Bool) {L base c delta alpha : ℝ} + (hL : 1 ≤ L) (hmass : mass rate s = L * (base + delta - alpha)) + (hinternal : c ≤ base + delta - alpha) (hbase : c ≤ base) + (ha : 0 ≤ alpha) (hd : |delta| + alpha ≤ 1) {N K : ℕ} + (hN : N ≤ (untouchedBatches touched).card) (hK : K ≤ N) : + |∫ ω, maskedTerm s (Real.exp (-L * base)) own touched ω ∂scheduleMeasure rate R| ≤ + (2 * L * Real.exp (-L * c)) ^ R * (|delta| ^ N + alpha ^ K) := by + have hNR : N ≤ R := hN.trans (by simpa using Finset.card_le_univ (untouchedBatches touched)) + have hKpow : alpha ^ N ≤ alpha ^ K := + pow_le_pow_of_le_one ha (by linarith [abs_nonneg delta]) hK + have h2pow : (2 : ℝ) ^ (N - 1) ≤ 2 ^ R := + pow_le_pow_right₀ (by norm_num) ((Nat.sub_le N 1).trans hNR) + have hsplit : (|delta| + alpha) ^ (untouchedBatches touched).card ≤ + 2 ^ R * (|delta| ^ N + alpha ^ K) := calc + _ ≤ (|delta| + alpha) ^ N := pow_le_pow_of_le_one (by positivity) hd hN + _ ≤ 2 ^ (N - 1) * (|delta| ^ N + alpha ^ N) := add_pow_le (abs_nonneg _) ha N + _ ≤ _ := mul_le_mul h2pow (add_le_add le_rfl hKpow) (by positivity) (by positivity) + calc + _ ≤ (L * Real.exp (-L * c)) ^ R * (|delta| + alpha) ^ (untouchedBatches touched).card := + abs_integral_maskedTerm_le_untouched rate s own touched hL hmass hinternal hbase ha + _ ≤ (L * Real.exp (-L * c)) ^ R * (2 ^ R * (|delta| ^ N + alpha ^ K)) := + mul_le_mul_of_nonneg_left hsplit (by positivity) + _ = _ := by rw [← mul_assoc, ← mul_pow]; congr 2; ring + +lemma two_mul_le_exp_small {L : ℝ} (hL : 10000 ≤ L) : + 2 * L ≤ Real.exp ((3 / 50 : ℝ) * L) := by + have hL0 : 0 ≤ L := by linarith + have he := Real.quadratic_le_exp_of_nonneg (show 0 ≤ (3 / 50 : ℝ) * L by positivity) + have hs : 10000 * L ≤ L ^ 2 := by nlinarith [mul_nonneg (sub_nonneg.mpr hL) hL0] + nlinarith + +lemma two_mul_score_attenuation {L : ℝ} (hL : 10000 ≤ L) (R : ℕ) : + (2 * L * Real.exp (-(37 / 50 : ℝ) * L)) ^ R ≤ + Real.exp (-(17 / 25 : ℝ) * (L * R)) := by + have h := mul_le_mul_of_nonneg_right (two_mul_le_exp_small hL) + (Real.exp_pos (-(37 / 50 : ℝ) * L)).le + rw [← Real.exp_add] at h + have heq : (3 / 50 : ℝ) * L + -(37 / 50 : ℝ) * L = -(17 / 25 : ℝ) * L := by ring + rw [heq] at h + have hp := pow_le_pow_left₀ (show 0 ≤ 2 * L * Real.exp (-(37 / 50 : ℝ) * L) by + have : 0 ≤ L := by linarith + positivity) h R + rw [← Real.exp_nat_mul] at hp + convert hp using 1 + congr 1 + ring + +omit [DecidableEq ι] in + +lemma simple_singleton_attenuation (rate : ι → ℝ≥0) {R : ℕ} + (s : Finset ι) (own touched : Fin R → Bool) {L base delta alpha : ℝ} + (hL : 10000 ≤ L) (hmass : mass rate s = L * (base + delta - alpha)) + (hinternal : (37 / 50 : ℝ) ≤ base + delta - alpha) (hbase : (37 / 50 : ℝ) ≤ base) + (ha : 0 ≤ alpha) (hd : |delta| + alpha ≤ 1) {N K : ℕ} + (hN : N ≤ (untouchedBatches touched).card) (hK : K ≤ N) : + |∫ ω, maskedTerm s (Real.exp (-L * base)) own touched ω ∂scheduleMeasure rate R| ≤ + Real.exp (-(17 / 25 : ℝ) * (L * R)) * (|delta| ^ N + alpha ^ K) := by + have h := abs_integral_maskedTerm_le_designations rate s own touched + (show 1 ≤ L by linarith) hmass hinternal hbase ha hd hN hK + apply h.trans + simpa only [neg_mul, mul_comm L (37 / 50 : ℝ)] using + mul_le_mul_of_nonneg_right (two_mul_score_attenuation hL R) + (show 0 ≤ |delta| ^ N + alpha ^ K by positivity) + +noncomputable def hitIndicator (i : ι) (ω : ι → ℕ) : ℝ := + 1 - emptyIndicator {i} ω + +omit [Fintype ι] [DecidableEq ι] in +lemma hitIndicator_eq (i : ι) (ω : ι → ℕ) : + hitIndicator i ω = if ω i = 0 then 0 else 1 := by + simp only [hitIndicator, emptyIndicator, emptyEvent + ] + by_cases h : ω i = 0 <;> simp [h] +omit [Fintype ι] [DecidableEq ι] in + +lemma hitIndicator_nonneg (i : ι) (ω : ι → ℕ) : 0 ≤ hitIndicator i ω := by + rw [hitIndicator_eq]; split <;> norm_num +omit [Fintype ι] [DecidableEq ι] in + +lemma hitIndicator_le_one (i : ι) (ω : ι → ℕ) : hitIndicator i ω ≤ 1 := by + rw [hitIndicator_eq]; split <;> norm_num +omit [DecidableEq ι] in + +lemma integrable_hitIndicator (rate : ι → ℝ≥0) (i : ι) : + Integrable (hitIndicator i) (batchMeasure rate) := + (integrable_const 1).sub (integrable_emptyIndicator rate {i}) +omit [DecidableEq ι] in + +lemma integral_hitIndicator (rate : ι → ℝ≥0) (i : ι) : + (∫ ω, hitIndicator i ω ∂batchMeasure rate) = 1 - Real.exp (-(rate i : ℝ)) := by + unfold hitIndicator + rw [integral_sub (integrable_const 1) (integrable_emptyIndicator rate {i}), + integral_emptyIndicator] + simp [mass] +omit [Fintype ι] [DecidableEq ι] in + +lemma maskedFactor_mul_hit (s : Finset ι) (i : ι) (hi : i ∈ s) (b : ℝ) + (own touched : Bool) (ω : ι → ℕ) : + maskedFactor s b own touched ω * hitIndicator i ω = + (if own then -b else 0) * hitIndicator i ω := by + rw [hitIndicator_eq] + by_cases hz : ω i = 0 + · simp [hz] + · simp only [hz, ↓reduceIte, mul_one] + have hh : ω ∉ emptyEvent s := by + intro h + exact hz (h i hi) + cases own <;> cases touched <;> simp [maskedFactor, centeredFactor_of_hit s b ω hi hz] +omit [DecidableEq ι] in + +lemma integral_abs_maskedFactor_hit_le (rate : ι → ℝ≥0) + (s : Finset ι) (i : ι) (hi : i ∈ s) (own touched : Bool) + {L base c : ℝ} (hL : 0 ≤ L) (hbase : c ≤ base) : + (∫ ω, |maskedFactor s (Real.exp (-L * base)) own touched ω| * hitIndicator i ω + ∂batchMeasure rate) ≤ Real.exp (-L * c) * (rate i : ℝ) := by + have heq : (fun ω => |maskedFactor s (Real.exp (-L * base)) own touched ω| * hitIndicator i ω) = + fun ω => (if own then Real.exp (-L * base) else 0) * hitIndicator i ω := by + funext ω + rw [← abs_of_nonneg (hitIndicator_nonneg i ω), ← abs_mul, maskedFactor_mul_hit s i hi] + cases own <;> + simp [abs_mul, abs_of_nonneg (hitIndicator_nonneg i ω), abs_of_pos (Real.exp_pos _)] + rw [heq, integral_const_mul, integral_hitIndicator] + have hnonneg : 0 ≤ 1 - Real.exp (-(rate i : ℝ)) := by + have : Real.exp (-(rate i : ℝ)) ≤ 1 := Real.exp_le_one_iff.mpr (neg_nonpos.mpr (rate i).coe_nonneg) + linarith + have hb : Real.exp (-L * base) ≤ Real.exp (-L * c) := Real.exp_le_exp.mpr (by nlinarith) + cases own + · simp only [Bool.false_eq_true, ↓reduceIte, zero_mul]; positivity + · simp only [↓reduceIte] + exact mul_le_mul hb (one_sub_exp_neg_le (rate i : ℝ)) hnonneg (Real.exp_pos _).le + +noncomputable def forcedHits {R : ℕ} (i : ι) (T : Finset (Fin R)) + (ω : Fin R → ι → ℕ) : ℝ := ∏ r ∈ T, hitIndicator i (ω r) +omit [Fintype ι] [DecidableEq ι] in + +lemma forcedHits_nonneg {R : ℕ} (i : ι) (T : Finset (Fin R)) (ω : Fin R → ι → ℕ) : + 0 ≤ forcedHits i T ω := Finset.prod_nonneg (fun _ _ => hitIndicator_nonneg _ _) + +end SharpRamseyFive.PoissonScore +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Entropy/LabelledFilterCard.lean b/lean/OAI/Combinatorics/SharpRamsey/Entropy/LabelledFilterCard.lean new file mode 100644 index 0000000000000000000000000000000000000000..91d159823f83a3f4ac0c1c68eae5814f687a0a60 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Entropy/LabelledFilterCard.lean @@ -0,0 +1,469 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Entropy.CompleteProgramWeight + +namespace OAI + +/-! High moments, finite-field subspaces, and incidence bounds. -/ + +section +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open scoped BigOperators +open MeasureTheory ProbabilityTheory +open scoped BigOperators ENNReal NNReal +namespace SharpRamseyFive.SelectionBridge +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponents +open SharpRamseyFive.Designations SharpRamseyFive.AmbientDesignations +open SharpRamseyFive.CertificateCover SharpRamseyFive.WeightedPrograms +open Classical +variable {D V H : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V] + [Fintype H] [DecidableEq H] +omit [DecidableEq V] [DecidableEq H] in +lemma labelled_filter_card (P : H → Prop) [DecidablePred P] : + (Finset.univ.filter (fun x : H × V => P x.1)).card = + (Finset.univ.filter P).card * Fintype.card V := by + have he : Finset.univ.filter (fun x : H × V => P x.1) = + (Finset.univ.filter P) ×ˢ (Finset.univ : Finset V) := by + ext z + simp + rw [he, Finset.card_product, Finset.card_univ] +omit [DecidableEq V] in + +lemma vertexBadMass_nonneg (weight rate : D → ℝ≥0) (s : V → Finset D) + (t : ℝ) (R J : ℕ) (A : Finset V) : 0 ≤ vertexBadMass weight rate s t R J A := by + unfold vertexBadMass + exact badMass_nonneg _ _ (blockTrunc_range _ R J none) _ A + +theorem all_bad_residual_sum_le (weight rate : D → ℝ≥0) (lines : H → Finset D) + (t : ℝ) (R : ℕ) (denom b mass : ℝ) + (hd : 0 < denom) (hb : 1 ≤ b) (hm : 0 ≤ mass) + (hmass : ∀ u, ∑ d ∈ lines u, (rate d : ℝ) ≤ mass) + (K J h N₁ N₂ : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (low : Bool) + (hsize : h ≤ (R / 2 - if low then 0 else J) / (2 * K)) + (herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) + (hN₁ : ∀ d, (Finset.univ.filter (fun u => d ∈ lines u)).card ≤ N₁) + (hN₂ : ∀ d e, d ≠ e → + (Finset.univ.filter (fun u => d ∈ lines u ∧ e ∈ lines u)).card ≤ N₂) + (A : Finset V) (g : V → H) : + (∑ f : V → H, if (∀ v ∉ A, g v = f v) then + vertexBadMass weight rate (lines ∘ f) t R J A else 0) ≤ + denom ^ A.card * ∑ n : Fin (A.card + 1), + branchingBound (V := V) (B := Fin R) (fun z : H × V => lines z.1) + rate denom b mass K (N₁ * Fintype.card V) (N₂ * Fintype.card V) low ^ n.val := by + let F : (V → H × V) → ℝ := fun f => + if Function.Injective f ∧ (∀ v ∉ A, labelled g v = f v) then + vertexBadMass weight rate ((fun z : H × V => lines z.1) ∘ f) t R J A else 0 + have hF (f : V → H × V) : 0 ≤ F f := by + dsimp [F] + split_ifs + · exact vertexBadMass_nonneg weight rate _ t R J A + · exact le_rfl + have he (f : V → H) : F (labelled f) = + if (∀ v ∉ A, g v = f v) then vertexBadMass weight rate (lines ∘ f) t R J A else 0 := by + have ha : (∀ v ∉ A, labelled g v = labelled f v) ↔ (∀ v ∉ A, g v = f v) := by + simp only [labelled, Prod.mk.injEq, and_true] + simp only [F, labelled_injective, true_and, ha] + rfl + calc + _ = ∑ f : V → H, F (labelled f) := by simp only [he] + _ = ∑ f ∈ Finset.univ.image (labelled : (V → H) → (V → H × V)), F f := by + rw [Finset.sum_image (fun _ _ _ _ h => labelled_map_injective h)] + _ ≤ ∑ f : V → H × V, F f := + Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) (fun f _ _ => hF f) + _ ≤ _ := by + apply bad_residual_sum_le weight rate (fun z : H × V => lines z.1) t R + denom b mass hd hb hm (fun u => hmass u.1) K J h + (N₁ * Fintype.card V) (N₂ * Fintype.card V) hK hh low hsize herr + · intro d + exact (labelled_filter_card (V := V) (H := H) (fun u => d ∈ lines u)).le.trans + (Nat.mul_le_mul_right _ (hN₁ d)) + · intro d e hde + exact (labelled_filter_card (V := V) (H := H) (fun u => d ∈ lines u ∧ e ∈ lines u)).le.trans + (Nat.mul_le_mul_right _ (hN₂ d e hde)) + +end SharpRamseyFive.SelectionBridge + +namespace SharpRamseyFive.ResidualElimination +open scoped BigOperators +open Classical +variable {V H : Type} [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] + +def Agrees (E : Finset V) (g f : V → H) : Prop := ∀ v ∉ E, f v = g v + +noncomputable def completionSum (E : Finset V) (g : V → H) (F : (V → H) → ℝ) : ℝ := + ∑ f : V → H, if Agrees E g f then F f else 0 + +omit [DecidableEq H] in +lemma completionSum_nonneg (E : Finset V) (g : V → H) (F : (V → H) → ℝ) + (hF : ∀ f, 0 ≤ F f) : 0 ≤ completionSum E g F := by + apply Finset.sum_nonneg + intro f _ + split_ifs + · exact hF f + · exact le_rfl + +omit [DecidableEq H] in +lemma completionSum_mono (E : Finset V) (g : V → H) (F G : (V → H) → ℝ) + (h : ∀ f, Agrees E g f → F f ≤ G f) : + completionSum E g F ≤ completionSum E g G := by + apply Finset.sum_le_sum + intro f _ + split_ifs with hf + · exact h f hf + · exact le_rfl +omit [DecidableEq H] in + +lemma completionSum_congr (E : Finset V) (g : V → H) (F G : (V → H) → ℝ) + (h : ∀ f, Agrees E g f → F f = G f) : + completionSum E g F = completionSum E g G := by + apply le_antisymm <;> apply completionSum_mono + · exact fun f hf => le_of_eq (h f hf) + · exact fun f hf => le_of_eq (h f hf).symm + +omit [DecidableEq H] in +lemma completionSum_mul (E : Finset V) (g : V → H) (c : ℝ) (F : (V → H) → ℝ) : + completionSum E g (fun f => c * F f) = c * completionSum E g F := by + simp only [completionSum, Finset.mul_sum, mul_ite, mul_zero] + +omit [DecidableEq H] in +lemma completionSum_sum {ι : Type} (T : Finset ι) (E : Finset V) (g : V → H) + (F : ι → (V → H) → ℝ) : + completionSum E g (fun f => ∑ i ∈ T, F i f) = + ∑ i ∈ T, completionSum E g (F i) := by + unfold completionSum + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro f _ + by_cases h : Agrees E g f <;> simp [h] + +omit [Fintype V] [Fintype H] [DecidableEq H] in +lemma agrees_erase_iff (E : Finset V) (g f : V → H) {u : V} (hu : u ∈ E) (x : H) : + Agrees (E.erase u) (Function.update g u x) f ↔ Agrees E g f ∧ f u = x := by + constructor + · intro h + constructor + · intro v hv + have hvu : v ≠ u := by intro he; exact hv (he ▸ hu) + simpa only [Function.update_of_ne hvu] using h v (by simp [hv]) + · simpa using h u (Finset.notMem_erase u E) + · rintro ⟨h, hx⟩ v hv + by_cases hvu : v = u + · subst v; simpa using hx + · rw [Function.update_of_ne hvu] + exact h v (by simpa [hvu] using hv) + +lemma completionSum_expose (E : Finset V) (g : V → H) {u : V} (hu : u ∈ E) + (F : (V → H) → ℝ) : + completionSum E g F = ∑ x : H, completionSum (E.erase u) (Function.update g u x) F := by + unfold completionSum + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro f _ + simp only [agrees_erase_iff E g f hu] + by_cases h : Agrees E g f + · simp [h, eq_comm] + · simp [h] + +lemma completionSum_empty (g : V → H) (F : (V → H) → ℝ) : + completionSum ∅ g F = F g := by + have he (f : V → H) : Agrees ∅ g f ↔ f = g := by + constructor + · intro h + funext v + exact h v (Finset.notMem_empty v) + · rintro rfl v _ + rfl + simp [completionSum, he] + +noncomputable def term (a : V → (V → H) → ℝ) (B : Finset V → (V → H) → ℝ) + (E S : Finset V) (f : V → H) : ℝ := (∏ u ∈ S, a u f) * B (E \ S) f + +omit [Fintype V] [Fintype H] [DecidableEq H] in +lemma term_nonneg (a : V → (V → H) → ℝ) (B : Finset V → (V → H) → ℝ) + (ha : ∀ u f, 0 ≤ a u f) (hB : ∀ A f, 0 ≤ B A f) + (E S : Finset V) (f : V → H) : 0 ≤ term a B E S f := + mul_nonneg (Finset.prod_nonneg (fun u _ => ha u f)) (hB _ f) + +omit [Fintype V] in +lemma prod_erase_le (a : V → ℝ) (ha : ∀ u, a u ∈ Set.Icc (0 : ℝ) 1) + (S : Finset V) (v : V) : (∏ u ∈ S, a u) ≤ ∏ u ∈ S.erase v, a u := by + by_cases hv : v ∈ S + · rw [← Finset.mul_prod_erase S a hv] + exact mul_le_of_le_one_left (Finset.prod_nonneg (fun u _ => (ha u).1)) (ha v).2 + · rw [Finset.erase_eq_of_notMem hv] + +omit [Fintype V] in +lemma erase_sdiff (E S : Finset V) (u _v : V) (hu : u ∈ S) : + E.erase u \ S.erase u = E \ S := by + ext w + by_cases hw : w = u <;> simp [hw, hu] + +omit [Fintype V] in +lemma double_erase_sdiff (E S : Finset V) (u v : V) (hu : u ∈ S) : + (E.erase u).erase v \ (S.erase u).erase v = (E \ S).erase v := by + ext w + by_cases hwu : w = u <;> by_cases hwv : w = v <;> simp [hwu, hwv, hu] + +omit [Fintype H] [DecidableEq H] in +lemma term_shift_step (a : V → (V → H) → ℝ) (B : Finset V → (V → H) → ℝ) + (W : H → H → ℝ) (ha : ∀ u f, a u f ∈ Set.Icc (0 : ℝ) 1) + (hW : ∀ x y, 0 ≤ W x y) (hB : ∀ A f, 0 ≤ B A f) + (hmono : ∀ A A', A' ⊆ A → ∀ f, B A f ≤ B A' f) + (hshift : ∀ u f, a u f ≤ ∑ v ∈ Finset.univ.erase u, W (f u) (f v)) + (E S : Finset V) {u : V} (hu : u ∈ S) (f : V → H) : + term a B E S f ≤ ∑ v ∈ Finset.univ.erase u, + W (f u) (f v) * term a B ((E.erase u).erase v) ((S.erase u).erase v) f := by + have hp : 0 ≤ (∏ w ∈ S.erase u, a w f) * B (E \ S) f := + mul_nonneg (Finset.prod_nonneg (fun w _ => (ha w f).1)) (hB _ f) + calc + term a B E S f = a u f * ((∏ w ∈ S.erase u, a w f) * B (E \ S) f) := by + rw [term, ← Finset.mul_prod_erase S (fun w => a w f) hu, mul_assoc] + _ ≤ (∑ v ∈ Finset.univ.erase u, W (f u) (f v)) * + ((∏ w ∈ S.erase u, a w f) * B (E \ S) f) := + mul_le_mul_of_nonneg_right (hshift u f) hp + _ = ∑ v ∈ Finset.univ.erase u, W (f u) (f v) * + ((∏ w ∈ S.erase u, a w f) * B (E \ S) f) := by rw [Finset.sum_mul] + _ ≤ _ := by + apply Finset.sum_le_sum + intro v hv + apply mul_le_mul_of_nonneg_left _ (hW _ _) + unfold term + rw [double_erase_sdiff E S u v hu] + apply mul_le_mul (prod_erase_le (fun w => a w f) (fun w => ha w f) _ v) + (hmono _ _ (Finset.erase_subset v _) f) (hB _ f) + exact Finset.prod_nonneg (fun w _ => (ha w f).1) + +lemma sum_known_partner (E : Finset V) (g : V → H) {u v : V} (hu : u ∈ E) (hv : v ∉ E) + (W : H → H → ℝ) (F : (V → H) → ℝ) (X C : ℝ) + (hW : ∀ x y, 0 ≤ W x y) (hX : 0 ≤ X) + (hrow : ∑ x : H, W x (g v) ≤ C) + (hF : ∀ x : H, completionSum (E.erase u) (Function.update g u x) F ≤ X) : + completionSum E g (fun f => W (f u) (f v) * F f) ≤ C * X := by + rw [completionSum_expose E g hu] + calc + _ ≤ ∑ x : H, W x (g v) * X := by + apply Finset.sum_le_sum + intro x _ + have he : completionSum (E.erase u) (Function.update g u x) + (fun f => W (f u) (f v) * F f) = W x (g v) * + completionSum (E.erase u) (Function.update g u x) F := by + rw [← completionSum_mul] + apply completionSum_congr + intro f hf + have hfu : f u = x := by simpa using hf u (Finset.notMem_erase u E) + have hvu : v ≠ u := by intro he; exact hv (he ▸ hu) + have hfv : f v = g v := by + simpa only [Function.update_of_ne hvu] using hf v (by simp [hv]) + rw [hfu, hfv] + rw [he] + exact mul_le_mul_of_nonneg_left (hF x) (hW _ _) + _ = (∑ x : H, W x (g v)) * X := by rw [Finset.sum_mul] + _ ≤ _ := mul_le_mul_of_nonneg_right hrow hX + +lemma sum_new_partner (E : Finset V) (g : V → H) {u v : V} + (hu : u ∈ E) (hv : v ∈ E) (hne : v ≠ u) + (W : H → H → ℝ) (F : (V → H) → ℝ) (X C : ℝ) + (hW : ∀ x y, 0 ≤ W x y) (hX : 0 ≤ X) + (hpair : (∑ x : H, ∑ y : H, W x y) ≤ C) + (hF : ∀ x y : H, completionSum ((E.erase u).erase v) + (Function.update (Function.update g u x) v y) F ≤ X) : + completionSum E g (fun f => W (f u) (f v) * F f) ≤ C * X := by + rw [completionSum_expose E g hu] + have hv' : v ∈ E.erase u := Finset.mem_erase.mpr ⟨hne,hv⟩ + calc + _ ≤ ∑ x : H, ∑ y : H, W x y * X := by + apply Finset.sum_le_sum + intro x _ + rw [completionSum_expose _ _ hv'] + apply Finset.sum_le_sum + intro y _ + have he : completionSum ((E.erase u).erase v) + (Function.update (Function.update g u x) v y) + (fun f => W (f u) (f v) * F f) = W x y * + completionSum ((E.erase u).erase v) + (Function.update (Function.update g u x) v y) F := by + rw [← completionSum_mul] + apply completionSum_congr + intro f hf + have hfu : f u = x := by + simpa only [Function.update_of_ne hne.symm, Function.update_self] using + hf u (by simp) + have hfv : f v = y := by simpa using hf v (by simp) + rw [hfu, hfv] + rw [he] + exact mul_le_mul_of_nonneg_left (hF x y) (hW _ _) + _ = (∑ x : H, ∑ y : H, W x y) * X := by simp only [Finset.sum_mul] + _ ≤ _ := mul_le_mul_of_nonneg_right hpair hX + +theorem shift_bad_enumeration (a : V → (V → H) → ℝ) (B : Finset V → (V → H) → ℝ) + (W : H → H → ℝ) (C : ℝ) (hC : 0 ≤ C) + (ha : ∀ u f, a u f ∈ Set.Icc (0 : ℝ) 1) + (hW : ∀ x y, 0 ≤ W x y) (hB : ∀ A f, 0 ≤ B A f) + (hmono : ∀ A A', A' ⊆ A → ∀ f, B A f ≤ B A' f) + (hshift : ∀ u f, a u f ≤ ∑ v ∈ Finset.univ.erase u, W (f u) (f v)) + (hrow : ∀ y, (∑ x : H, W x y) ≤ C) + (hpair : (∑ x : H, ∑ y : H, W x y) ≤ C ^ 2) + (hbad : ∀ A g, completionSum A g (B A) ≤ C ^ A.card) + (E S : Finset V) (hS : S ⊆ E) (g : V → H) : + completionSum E g (term a B E S) ≤ ((Fintype.card V + 1 : ℝ) * C) ^ E.card := by + let M : ℝ := (Fintype.card V + 1) * C + have hCM : C ≤ M := by dsimp [M]; nlinarith [Nat.cast_nonneg (α := ℝ) (Fintype.card V)] + have hM : 0 ≤ M := hC.trans hCM + suffices hall : ∀ E : Finset V, ∀ S, S ⊆ E → ∀ g : V → H, + completionSum E g (term a B E S) ≤ M ^ E.card from hall E S hS g + intro E + refine Finset.strongInductionOn E ?_ + intro E ih S hS g + by_cases hs : S = ∅ + · subst S + have he : term a B E ∅ = B E := by + funext f + simp [term] + rw [he] + exact (hbad E g).trans (pow_le_pow_left₀ hC hCM _) + obtain ⟨u,hu⟩ := Finset.nonempty_iff_ne_empty.mpr hs + have huE := hS hu + have hsub := Finset.erase_ssubset huE + have hS' : S.erase u ⊆ E.erase u := Finset.erase_subset_erase u hS + have hcard : E.card = (E.erase u).card + 1 := (Finset.card_erase_add_one huE).symm + calc + _ ≤ completionSum E g (fun f => ∑ v ∈ Finset.univ.erase u, + W (f u) (f v) * term a B ((E.erase u).erase v) ((S.erase u).erase v) f) := by + apply completionSum_mono + intro f _ + exact term_shift_step a B W ha hW hB hmono hshift E S hu f + _ = ∑ v ∈ Finset.univ.erase u, completionSum E g + (fun f => W (f u) (f v) * term a B ((E.erase u).erase v) ((S.erase u).erase v) f) := + completionSum_sum _ E g _ + _ ≤ ∑ _v ∈ Finset.univ.erase u, C * M ^ (E.erase u).card := by + apply Finset.sum_le_sum + intro v hv + have hne : v ≠ u := (Finset.mem_erase.mp hv).1 + by_cases hvE : v ∈ E + · have hv' : v ∈ E.erase u := Finset.mem_erase.mpr ⟨hne,hvE⟩ + have hsmall : (E.erase u).erase v ⊂ E := + Finset.ssubset_of_subset_of_ssubset (Finset.erase_subset _ _) hsub + have hSt : (S.erase u).erase v ⊆ (E.erase u).erase v := + Finset.erase_subset_erase v hS' + have hbnd := sum_new_partner E g huE hvE hne W + (term a B ((E.erase u).erase v) ((S.erase u).erase v)) + (M ^ ((E.erase u).erase v).card) (C ^ 2) hW (pow_nonneg hM _) hpair + (fun x y => ih _ hsmall _ hSt _) + apply hbnd.trans + rw [show (E.erase u).card = ((E.erase u).erase v).card + 1 from + (Finset.card_erase_add_one hv').symm, pow_succ M] + calc + _ = (C * C) * M ^ ((E.erase u).erase v).card := by ring + _ ≤ (C * M) * M ^ ((E.erase u).erase v).card := + mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hCM hC) (pow_nonneg hM _) + _ = _ := by ring + · have hvS : v ∉ S := fun h => hvE (hS h) + rw [Finset.erase_eq_of_notMem (fun h => hvE (Finset.erase_subset u E h)), + Finset.erase_eq_of_notMem (fun h => hvS (Finset.erase_subset u S h))] + exact sum_known_partner E g huE hvE W (term a B (E.erase u) (S.erase u)) + (M ^ (E.erase u).card) C hW (pow_nonneg hM _) (hrow (g v)) + (fun x => ih _ hsub _ hS' _) + _ ≤ M * M ^ (E.erase u).card := by + simp only [Finset.sum_const, nsmul_eq_mul] + rw [← mul_assoc] + apply mul_le_mul_of_nonneg_right _ (pow_nonneg hM _) + change ((Finset.univ.erase u).card : ℝ) * C ≤ M + have hc : ((Finset.univ.erase u).card : ℝ) ≤ (Fintype.card V : ℝ) := by + exact_mod_cast Finset.card_le_card (Finset.erase_subset u (Finset.univ : Finset V)) + dsimp [M] + nlinarith + _ = _ := by rw [hcard, pow_succ]; ring + +end SharpRamseyFive.ResidualElimination + +namespace SharpRamseyFive.SingletonEnumeration +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponents +open SharpRamseyFive.Designations SharpRamseyFive.AmbientDesignations +open SharpRamseyFive.SelectionBridge SharpRamseyFive.WeightedPrograms +open SharpRamseyFive.ResidualElimination +open Classical +variable {D V H : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V] + [Fintype H] [DecidableEq H] +omit [DecidableEq V] in + +lemma vertexBadMass_antitone (weight rate : D → ℝ≥0) (s : V → Finset D) + (t : ℝ) (R J : ℕ) {A A' : Finset V} (hA : A' ⊆ A) : + vertexBadMass weight rate s t R J A ≤ vertexBadMass weight rate s t R J A' := by + unfold vertexBadMass badMass + apply integral_mono + (badTerm_integrable _ _ (blockTrunc_range _ R J none) _ A) + (badTerm_integrable _ _ (blockTrunc_range _ R J none) _ A') + intro z + apply mul_le_mul_of_nonneg_left _ (blockTrunc_range _ R J none z).1 + exact Finset.prod_le_prod_of_subset_of_le_one₀ hA + (fun v _ => (badIndicator_range _ v z).1) + (fun v _ _ => (badIndicator_range _ v z).2) + +lemma sum_powers_le (x : ℝ) (hx : 0 ≤ x) (n : ℕ) : + (∑ i ∈ Finset.range (n + 1), x ^ i) ≤ (1 + x) ^ n := by + induction n with + | zero => simp + | succ n ih => + rw [Finset.sum_range_succ] + calc + _ ≤ (1 + x) ^ n + x ^ (n + 1) := add_le_add ih le_rfl + _ ≤ (1 + x) ^ n + x * (1 + x) ^ n := by + rw [pow_succ'] + exact add_le_add le_rfl (mul_le_mul_of_nonneg_left + (pow_le_pow_left₀ hx (by linarith : x ≤ 1 + x) n) hx) + _ = _ := by rw [pow_succ]; ring + +lemma actual_bad_completion (weight rate : D → ℝ≥0) (lines : H → Finset D) + (t : ℝ) (R : ℕ) (denom b mass : ℝ) + (hd : 0 < denom) (hb : 1 ≤ b) (hm : 0 ≤ mass) + (hmass : ∀ u, ∑ d ∈ lines u, (rate d : ℝ) ≤ mass) + (K J h N₁ N₂ : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (low : Bool) + (hsize : h ≤ (R / 2 - if low then 0 else J) / (2 * K)) + (herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) + (hN₁ : ∀ d, (Finset.univ.filter (fun u => d ∈ lines u)).card ≤ N₁) + (hN₂ : ∀ d e, d ≠ e → + (Finset.univ.filter (fun u => d ∈ lines u ∧ e ∈ lines u)).card ≤ N₂) + (A : Finset V) (g : V → H) : + completionSum A g (fun f => vertexBadMass weight rate (lines ∘ f) t R J A) ≤ + (denom * (1 + branchingBound (V := V) (B := Fin R) + (fun z : H × V => lines z.1) rate denom b mass K + (N₁ * Fintype.card V) (N₂ * Fintype.card V) low)) ^ A.card := by + have he : completionSum A g (fun f => vertexBadMass weight rate (lines ∘ f) t R J A) = + ∑ f : V → H, if (∀ v ∉ A, g v = f v) then + vertexBadMass weight rate (lines ∘ f) t R J A else 0 := by + unfold completionSum + apply Finset.sum_congr rfl + intro f _ + have : Agrees A g f ↔ (∀ v ∉ A, g v = f v) := by + simp only [Agrees, eq_comm] + simp only [this] + rw [he] + apply (all_bad_residual_sum_le weight rate lines t R denom b mass hd hb hm hmass + K J h N₁ N₂ hK hh low hsize herr hN₁ hN₂ A g).trans + rw [mul_pow] + apply mul_le_mul_of_nonneg_left _ (pow_nonneg hd.le _) + rw [Fin.sum_univ_eq_sum_range] + apply sum_powers_le + exact branchingBound_nonneg _ _ _ _ _ hd.le (by linarith) hm _ _ _ _ + +noncomputable def shiftKernel (weight : D → ℝ≥0) (lines : H → Finset D) (p K : ℕ) + (x y : H) : ℝ := min 1 (((p : ℝ) * mass weight (lines x ∩ lines y)) ^ K) + +omit [Fintype H] [DecidableEq H] in +omit [Fintype D] in +lemma shiftKernel_range (weight : D → ℝ≥0) (lines : H → Finset D) (p K : ℕ) + (x y : H) : shiftKernel weight lines p K x y ∈ Set.Icc (0 : ℝ) 1 := by + unfold shiftKernel + exact ⟨le_min zero_le_one (pow_nonneg (mul_nonneg (Nat.cast_nonneg _) (mass_nonneg _ _)) _), + min_le_left _ _⟩ + +end SharpRamseyFive.SingletonEnumeration +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Entropy/LargeCard.lean b/lean/OAI/Combinatorics/SharpRamsey/Entropy/LargeCard.lean new file mode 100644 index 0000000000000000000000000000000000000000..197391d4928f0491d32e90d7c60d09d2755c0dd2 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Entropy/LargeCard.lean @@ -0,0 +1,448 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Entropy.SinglesUnique + +namespace OAI + +/-! High moments, finite-field subspaces, and incidence bounds. -/ + +section +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open scoped BigOperators +open MeasureTheory ProbabilityTheory +open scoped BigOperators ENNReal NNReal +namespace SharpRamseyFive.AmbientEnumeration +open scoped BigOperators NNReal +open Classical +open SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponents +open SharpRamseyFive.AmbientDesignations SharpRamseyFive.ComponentPartition +open SharpRamseyFive.ComponentEnumeration SharpRamseyFive.ResidualElimination +open SharpRamseyFive.SingletonEnumeration SharpRamseyFive.SelectionBridge +variable {D V H : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V] + [Fintype H] [DecidableEq H] +omit [Fintype D] in +lemma large_card (weight : D → ℝ≥0) (s : V → Finset D) (t : ℝ) : + Fintype.card (Components weight s t) - (simpleSet weight s t).card = + (largeLabels (componentMap (strongGraph weight s t))).card := by + rw [← large_image, Finset.card_image_of_injective _ (vertex_injective weight s t), + Finset.card_sdiff_of_subset (Finset.subset_univ _), Finset.card_univ] + +end SharpRamseyFive.AmbientEnumeration + +namespace SharpRamseyFive.AmbientEnumeration +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open Classical +open SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponents +open SharpRamseyFive.AmbientDesignations SharpRamseyFive.ComponentPartition +open SharpRamseyFive.ComponentEnumeration SharpRamseyFive.ResidualElimination +open SharpRamseyFive.SingletonEnumeration SharpRamseyFive.SelectionBridge +open SharpRamseyFive.WeightedPrograms +variable {D V H : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V] + [Fintype H] [DecidableEq H] + +noncomputable def vertexExpansion (weight : D → ℝ≥0) (lines : H → Finset D) + (t : ℝ) (R J K : ℕ) (L : ℝ≥0) (base : ℝ) (E : Finset V) (f : V → H) : ℝ := + badExpansion + (fun u f => independentWeight weight (fun d => L * weight d) lines R J base (f u) + + alpha weight (lines ∘ f) t u ^ K) + (fun A f => vertexBadMass weight (fun d => L * weight d) (lines ∘ f) t R J A) E f +omit [Fintype H] [DecidableEq H] in + +lemma vertexExpansion_nonneg (weight : D → ℝ≥0) (lines : H → Finset D) + (t : ℝ) (R J K : ℕ) (L : ℝ≥0) (base : ℝ) (E : Finset V) (f : V → H) : + 0 ≤ vertexExpansion weight lines t R J K L base E f := by + apply Finset.sum_nonneg + intro U _ + apply mul_nonneg + · apply Finset.prod_nonneg + intro u _ + exact add_nonneg (independentWeight_nonneg _ _ _ _ _ _ _) (pow_nonneg (alpha_nonneg _ _ _ _) _) + · exact vertexBadMass_nonneg _ _ _ _ _ _ _ +omit [Fintype H] [DecidableEq H] in + +lemma designated_le_partition (weight : D → ℝ≥0) (lines : H → Finset D) + (t : ℝ) (R J K : ℕ) (L : ℝ≥0) (base : ℝ) (f : V → H) : + designatedBound weight (lines ∘ f) t R J K L base ≤ + Real.exp (-(7 / 10 : ℝ) * ((L : ℝ) * R)) ^ + (largeLabels (componentMap (strongGraph weight (lines ∘ f) t))).card * + (Real.exp (-(17 / 25 : ℝ) * ((L : ℝ) * R)) ^ + (singles (componentMap (strongGraph weight (lines ∘ f) t))).card * + vertexExpansion weight lines t R J K L base + (singles (componentMap (strongGraph weight (lines ∘ f) t))) f) := by + have ht := mul_le_mul_of_nonneg_left + (designation_sum_le_vertex weight lines f t R J K L base) + (show 0 ≤ Real.exp (-(17 / 25 : ℝ) * ((L : ℝ) * R)) ^ (simpleSet weight (lines ∘ f) t).card * + Real.exp (-(7 / 10 : ℝ) * ((L : ℝ) * R)) ^ + (Fintype.card (Components weight (lines ∘ f) t) - (simpleSet weight (lines ∘ f) t).card) by positivity) + change designatedBound weight (lines ∘ f) t R J K L base ≤ _ at ht + rw [large_card, simple_card, simple_image] at ht + exact ht.trans_eq (by unfold vertexExpansion; ring) + +theorem designation_sum_enumerated (weight : D → ℝ≥0) (lines : H → Finset D) + {p : ℕ} (hp : 0 < p) (hc : Fintype.card V ≤ p) + (R : ℕ) (L : ℝ≥0) (denom rootB mass C D₀ base A : ℝ) + (hd : 0 < denom) (hb : 1 ≤ rootB) (hm : 0 ≤ mass) (hC : 0 ≤ C) + (hD : 0 ≤ D₀) (hA : 0 ≤ A) + (hmass : ∀ u, ∑ d ∈ lines u, ((L * weight d : ℝ≥0) : ℝ) ≤ mass) + (K J h N₁ N₂ : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (low : Bool) + (hsize : h ≤ (R / 2 - if low then 0 else J) / (2 * K)) + (herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) + (hN₁ : ∀ d, (Finset.univ.filter (fun u => d ∈ lines u)).card ≤ N₁) + (hN₂ : ∀ d e, d ≠ e → + (Finset.univ.filter (fun u => d ∈ lines u ∧ e ∈ lines u)).card ≤ N₂) + (hBC : denom * (1 + branchingBound (V := V) (B := Fin R) + (fun z : H × V => lines z.1) (fun d => L * weight d) denom rootB mass K + (N₁ * Fintype.card V) (N₂ * Fintype.card V) low) ≤ C) + (hrow : ∀ y, (∑ x : H, shiftKernel weight lines p K x y) ≤ C) + (hpair : (∑ x : H, ∑ y : H, shiftKernel weight lines p K x y) ≤ C ^ 2) + (hDsum : (∑ x : H, independentWeight weight (fun d => L * weight d) lines R J base x) ≤ D₀) + (hsingle : Real.exp (-(17 / 25 : ℝ) * ((L : ℝ) * R)) * + (D₀ + 2 * ((Fintype.card V + 1 : ℝ) * C)) ≤ A) + (Δ : ℕ) (hΔ : ∀ k, Fintype.card {k' : H // overlapRelation weight lines (1 / (100 * p)) k k'} ≤ Δ) + (hnum : ∀ m : ℕ, 2 ≤ m → m ≤ Fintype.card V → + Real.exp (-(7 / 10 : ℝ) * ((L : ℝ) * R)) * + ((m : ℝ) ^ 2 * Fintype.card (RelatedPair (overlapRelation weight lines (1 / (100 * p)))) * + ((m : ℝ) ^ 2 * Δ) ^ (m - 2)) ≤ A ^ m) : + (∑ f : V → H, designatedBound weight (lines ∘ f) (1 / (100 * p)) R J K L base) ≤ + (Fintype.card V : ℝ) ^ Fintype.card V * A ^ Fintype.card V := by + let t : ℝ := 1 / (100 * p) + let a := Real.exp (-(17 / 25 : ℝ) * ((L : ℝ) * R)) + let b := Real.exp (-(7 / 10 : ℝ) * ((L : ℝ) * R)) + let F (E : Finset V) (f : V → H) := a ^ E.card * vertexExpansion weight lines t R J K L base E f + have hres (r : V → V) (g : V → H) : + completionSum (singles r) g (F (singles r)) ≤ A ^ (singles r).card := by + change completionSum (singles r) g (fun f => a ^ (singles r).card * + vertexExpansion weight lines t R J K L base (singles r) f) ≤ _ + rw [completionSum_mul] + apply (mul_le_mul_of_nonneg_left (actual_all_singleton_enumeration weight + (fun d => L * weight d) lines hp hc R denom rootB mass C D₀ base hd hb hm hC hD + hmass K J h N₁ N₂ hK hh low hsize herr hN₁ hN₂ hBC hrow hpair hDsum (singles r) g) + (show 0 ≤ a ^ (singles r).card by dsimp [a]; positivity)).trans + rw [← mul_pow] + exact pow_le_pow_left₀ (by positivity) hsingle _ + apply (Finset.sum_le_sum (fun f _ => designated_le_partition weight lines t R J K L base f)).trans + have ht := graph_partition_sum (V := V) (overlapRelation weight lines t) + (overlapRelation_symm weight lines t) b A (Real.exp_pos _).le hA Δ hΔ hnum F + (fun E f => mul_nonneg (pow_nonneg (Real.exp_pos _).le _) (vertexExpansion_nonneg _ _ _ _ _ _ _ _ _ _)) hres + simpa only [relation_graph_eq] using ht + +end SharpRamseyFive.AmbientEnumeration + +namespace SharpRamseyFive.MomentBudgets +open scoped BigOperators + +lemma block_cost (P B E Δ : ℝ) (p m : ℕ) (hP : 0 ≤ P) (hB : 0 ≤ B) + (hE : 0 ≤ E) (hΔ : 0 ≤ Δ) (hm : 2 ≤ m) (hmp : m ≤ p) + (hp : (p : ℝ) ^ 2 ≤ Real.exp (P / 10)) + (hpair : E ≤ B ^ 2 * Real.exp (P / 10)) + (hdeg : Δ ≤ B * Real.exp (-P)) : + Real.exp (-(7 / 10 : ℝ) * P) * + ((m : ℝ) ^ 2 * E * ((m : ℝ) ^ 2 * Δ) ^ (m - 2)) ≤ + (B * Real.exp (-(1 / 5 : ℝ) * P)) ^ m := by + let A := B * Real.exp (-(1 / 5 : ℝ) * P) + have hA : 0 ≤ A := mul_nonneg hB (Real.exp_pos _).le + have hm2 : (m : ℝ) ^ 2 ≤ Real.exp (P / 10) := by + apply (pow_le_pow_left₀ (by positivity) (show (m : ℝ) ≤ p by exact_mod_cast hmp) 2).trans hp + have hfirst : Real.exp (-(7 / 10 : ℝ) * P) * ((m : ℝ) ^ 2 * E) ≤ A ^ 2 := by + calc + _ ≤ Real.exp (-(7 / 10 : ℝ) * P) * (Real.exp (P / 10) * (B ^ 2 * Real.exp (P / 10))) := by + exact mul_le_mul_of_nonneg_left (mul_le_mul hm2 hpair hE (Real.exp_pos _).le) (Real.exp_pos _).le + _ = B ^ 2 * Real.exp (-(1 / 2 : ℝ) * P) := by + rw [show Real.exp (-(7 / 10 : ℝ) * P) * (Real.exp (P / 10) * (B ^ 2 * Real.exp (P / 10))) = + B ^ 2 * (Real.exp (-(7 / 10 : ℝ) * P) * Real.exp (P / 10) * Real.exp (P / 10)) by ring] + rw [← Real.exp_add, ← Real.exp_add] + congr 2 + ring + _ ≤ B ^ 2 * Real.exp (-(2 / 5 : ℝ) * P) := by + exact mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (by linarith)) (sq_nonneg B) + _ = A ^ 2 := by + dsimp [A] + rw [mul_pow, ← Real.exp_nat_mul] + congr 2 + ring + have hstep : (m : ℝ) ^ 2 * Δ ≤ A := by + calc + _ ≤ Real.exp (P / 10) * (B * Real.exp (-P)) := + mul_le_mul hm2 hdeg hΔ (Real.exp_pos _).le + _ = B * Real.exp (-(9 / 10 : ℝ) * P) := by + rw [show Real.exp (P / 10) * (B * Real.exp (-P)) = B * (Real.exp (P / 10) * Real.exp (-P)) by ring, + ← Real.exp_add] + congr 2 + ring + _ ≤ A := mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (by linarith)) hB + calc + _ = (Real.exp (-(7 / 10 : ℝ) * P) * ((m : ℝ) ^ 2 * E)) * + ((m : ℝ) ^ 2 * Δ) ^ (m - 2) := by ring + _ ≤ A ^ 2 * A ^ (m - 2) := mul_le_mul hfirst + (pow_le_pow_left₀ (mul_nonneg (sq_nonneg _) hΔ) hstep _) (by positivity) (pow_nonneg hA _) + _ = A ^ m := by rw [← pow_add, Nat.add_sub_of_le hm] + +lemma singleton_cost (P B M : ℝ) (hP : 0 ≤ P) (hB : 0 ≤ B) + (hM : M ≤ B * Real.exp (P / 5)) : + Real.exp (-(17 / 25 : ℝ) * P) * M ≤ B * Real.exp (-(1 / 5 : ℝ) * P) := by + calc + _ ≤ Real.exp (-(17 / 25 : ℝ) * P) * (B * Real.exp (P / 5)) := + mul_le_mul_of_nonneg_left hM (Real.exp_pos _).le + _ = B * Real.exp (-(12 / 25 : ℝ) * P) := by + rw [show Real.exp (-(17 / 25 : ℝ) * P) * (B * Real.exp (P / 5)) = + B * (Real.exp (-(17 / 25 : ℝ) * P) * Real.exp (P / 5)) by ring, ← Real.exp_add] + congr 2 + ring + _ ≤ _ := mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (by linarith)) hB + +lemma partition_cost (P B : ℝ) (p : ℕ) (hB : 0 ≤ B) + (hp : (p : ℝ) ≤ Real.exp (P / 10)) : + (p : ℝ) ^ p * (B * Real.exp (-(1 / 5 : ℝ) * P)) ^ p ≤ + B ^ p * Real.exp (-(1 / 10 : ℝ) * (p * P)) := by + calc + _ ≤ Real.exp (P / 10) ^ p * (B * Real.exp (-(1 / 5 : ℝ) * P)) ^ p := + mul_le_mul_of_nonneg_right (pow_le_pow_left₀ (by positivity) hp _) (by positivity) + _ = _ := by + rw [← mul_pow, show Real.exp (P / 10) * (B * Real.exp (-(1 / 5 : ℝ) * P)) = + B * (Real.exp (P / 10) * Real.exp (-(1 / 5 : ℝ) * P)) by ring, ← Real.exp_add, + mul_pow, ← Real.exp_nat_mul] + congr 2 + ring + +end SharpRamseyFive.MomentBudgets + +namespace SharpRamseyFive.AmbientEnumeration +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open Classical +open SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponents +open SharpRamseyFive.AmbientDesignations SharpRamseyFive.ComponentPartition +open SharpRamseyFive.ComponentEnumeration SharpRamseyFive.ResidualElimination +open SharpRamseyFive.SingletonEnumeration SharpRamseyFive.SelectionBridge +open SharpRamseyFive.WeightedPrograms +variable {D H : Type} [Fintype D] [DecidableEq D] [Fintype H] [DecidableEq H] + +theorem ambient_refined_truncated_moment (weight : D → ℝ≥0) (lines : H → Finset D) + {p : ℕ} (hp : 0 < p) (R : ℕ) (own : H → Fin R → Bool) + (L : ℝ≥0) (denom rootB mass C D₀ base B : ℝ) + (hL : 10000 ≤ (L : ℝ)) (hbase : (23 / 25 : ℝ) ≤ base) + (hlower : ∀ k, (3 / 4 : ℝ) ≤ PoissonScore.mass weight (lines k)) + (hdelta : ∀ k, |PoissonScore.mass weight (lines k) - base| ≤ (17 / 100 : ℝ)) + (hd : 0 < denom) (hb : 1 ≤ rootB) (hm : 0 ≤ mass) (hC : 0 ≤ C) + (hD : 0 ≤ D₀) (hB : 0 ≤ B) + (hmass : ∀ u, ∑ d ∈ lines u, ((L * weight d : ℝ≥0) : ℝ) ≤ mass) + (K J h N₁ N₂ : ℕ) (hK : 2 ≤ K) (hKR : K ≤ R / 2) (hh : 0 < h) (low : Bool) + (hsize : h ≤ (R / 2 - if low then 0 else J) / (2 * K)) + (herr : (p : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) + (hN₁ : ∀ d, (Finset.univ.filter (fun u => d ∈ lines u)).card ≤ N₁) + (hN₂ : ∀ d e, d ≠ e → + (Finset.univ.filter (fun u => d ∈ lines u ∧ e ∈ lines u)).card ≤ N₂) + (hBC : denom * (1 + branchingBound (V := Fin p) (B := Fin R) + (fun z : H × Fin p => lines z.1) (fun d => L * weight d) denom rootB mass K + (N₁ * p) (N₂ * p) low) ≤ C) + (hrow : ∀ y, (∑ x : H, shiftKernel weight lines p K x y) ≤ C) + (hpair : (∑ x : H, ∑ y : H, shiftKernel weight lines p K x y) ≤ C ^ 2) + (hDsum : (∑ x : H, independentWeight weight (fun d => L * weight d) lines R J base x) ≤ D₀) + (hcost : D₀ + 2 * ((p + 1 : ℝ) * C) ≤ B * Real.exp (((L : ℝ) * R) / 5)) + (hp2 : (p : ℝ) ^ 2 ≤ Real.exp (((L : ℝ) * R) / 10)) + (Δ : ℕ) (hΔ : ∀ k, Fintype.card {k' : H // overlapRelation weight lines (1 / (100 * p)) k k'} ≤ Δ) + (hdeg : (Δ : ℝ) ≤ B * Real.exp (-((L : ℝ) * R))) + (hRelPairs : (Fintype.card (RelatedPair (overlapRelation weight lines (1 / (100 * p)))) : ℝ) ≤ + B ^ 2 * Real.exp (((L : ℝ) * R) / 10)) : + (∫ ω, HighMoment.allTrunc R J ω * + (∑ k : H, scoreTerm (lines k) (Real.exp (-(L : ℝ) * base)) (own k) + (fun r d => ω (r,d))) ^ p + ∂batchMeasure (fun i : Fin R × D => L * weight i.2)) ≤ + B ^ p * Real.exp (-(1 / 10 : ℝ) * (p * ((L : ℝ) * R))) := by + have hP : 0 ≤ (L : ℝ) * R := by positivity + apply (truncated_power_designated weight R J K L base lines own hp hL hbase hlower hdelta hKR).trans + have hs := designation_sum_enumerated (V := Fin p) weight lines hp (by simp) + R L denom rootB mass C D₀ base (B * Real.exp (-(1 / 5 : ℝ) * ((L : ℝ) * R))) hd hb hm hC hD + (by positivity) hmass K J h N₁ N₂ hK hh low hsize + (by simpa only [Fintype.card_fin] using herr) hN₁ hN₂ + (by simpa only [Fintype.card_fin] using hBC) hrow hpair hDsum + (by simpa only [Fintype.card_fin] using MomentBudgets.singleton_cost _ B _ hP hB hcost) + Δ hΔ (fun m hm hmp => MomentBudgets.block_cost _ B _ _ p m hP hB + (by positivity) (by positivity) hm (by simpa only [Fintype.card_fin] using hmp) hp2 hRelPairs hdeg) + apply hs.trans + simp only [Fintype.card_fin] + apply MomentBudgets.partition_cost _ B p hB + have hpr : (1 : ℝ) ≤ p := by exact_mod_cast hp + exact (show (p : ℝ) ≤ (p : ℝ) ^ 2 by nlinarith).trans hp2 + +omit [DecidableEq D] in + +lemma allTrunc_eq_one {R J : ℕ} (h : R < J) (ω : Fin R × D → ℕ) : + HighMoment.allTrunc R J ω = 1 := by + apply Finset.prod_eq_one + intro d _ + unfold lineTrunc + apply ite_eq_left + exact (show (Finset.univ.filter (fun r => ω (r,d) ≠ 0)).card ≤ R by + simpa only [Finset.card_univ, Fintype.card_fin] using + Finset.card_le_card (Finset.filter_subset (fun r : Fin R => ω (r,d) ≠ 0) Finset.univ)).trans_lt h + +theorem ambient_untruncated_moment (weight : D → ℝ≥0) (lines : H → Finset D) + {p : ℕ} (hp : 0 < p) (R : ℕ) (own : H → Fin R → Bool) + (L : ℝ≥0) (denom rootB mass C D₀ base B : ℝ) + (hL : 10000 ≤ (L : ℝ)) (hbase : (23 / 25 : ℝ) ≤ base) + (hlower : ∀ k, (3 / 4 : ℝ) ≤ PoissonScore.mass weight (lines k)) + (hdelta : ∀ k, |PoissonScore.mass weight (lines k) - base| ≤ (17 / 100 : ℝ)) + (hd : 0 < denom) (hb : 1 ≤ rootB) (hm : 0 ≤ mass) (hC : 0 ≤ C) + (hD : 0 ≤ D₀) (hB : 0 ≤ B) + (hmass : ∀ u, ∑ d ∈ lines u, ((L * weight d : ℝ≥0) : ℝ) ≤ mass) + (K h N₁ N₂ : ℕ) (hK : 2 ≤ K) (hKR : K ≤ R / 2) (hh : 0 < h) + (hsize : h ≤ (R / 2) / (2 * K)) + (herr : (p : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) + (hN₁ : ∀ d, (Finset.univ.filter (fun u => d ∈ lines u)).card ≤ N₁) + (hN₂ : ∀ d e, d ≠ e → + (Finset.univ.filter (fun u => d ∈ lines u ∧ e ∈ lines u)).card ≤ N₂) + (hBC : denom * (1 + branchingBound (V := Fin p) (B := Fin R) + (fun z : H × Fin p => lines z.1) (fun d => L * weight d) denom rootB mass K + (N₁ * p) (N₂ * p) true) ≤ C) + (hrow : ∀ y, (∑ x : H, shiftKernel weight lines p K x y) ≤ C) + (hpair : (∑ x : H, ∑ y : H, shiftKernel weight lines p K x y) ≤ C ^ 2) + (hDsum : (∑ x : H, |PoissonScore.mass weight (lines x) - base| ^ (R / 2)) ≤ D₀) + (hcost : D₀ + 2 * ((p + 1 : ℝ) * C) ≤ B * Real.exp (((L : ℝ) * R) / 5)) + (hp2 : (p : ℝ) ^ 2 ≤ Real.exp (((L : ℝ) * R) / 10)) + (Δ : ℕ) (hΔ : ∀ k, Fintype.card {k' : H // overlapRelation weight lines (1 / (100 * p)) k k'} ≤ Δ) + (hdeg : (Δ : ℝ) ≤ B * Real.exp (-((L : ℝ) * R))) + (hRelPairs : (Fintype.card (RelatedPair (overlapRelation weight lines (1 / (100 * p)))) : ℝ) ≤ + B ^ 2 * Real.exp (((L : ℝ) * R) / 10)) : + (∫ ω, (∑ k : H, scoreTerm (lines k) (Real.exp (-(L : ℝ) * base)) (own k) + (fun r d => ω (r,d))) ^ p + ∂batchMeasure (fun i : Fin R × D => L * weight i.2)) ≤ + B ^ p * Real.exp (-(1 / 10 : ℝ) * (p * ((L : ℝ) * R))) := by + have hs := ambient_refined_truncated_moment weight lines hp R own L denom rootB mass C D₀ base B + hL hbase hlower hdelta hd hb hm hC hD hB hmass K (R+1) h N₁ N₂ hK hKR hh true + (by simpa using hsize) herr hN₁ hN₂ hBC hrow hpair + (by simpa only [independentWeight, Nat.lt_succ_self, ite_true, add_zero] using hDsum) + hcost hp2 Δ hΔ hdeg hRelPairs + simpa only [allTrunc_eq_one (Nat.lt_succ_self R), one_mul] using hs + +end SharpRamseyFive.AmbientEnumeration + +namespace SharpLogRamsey.MomentBudgetBridge + +def anchorBudget (p : ℕ) (P : ℝ) : ℝ := 200 * (p : ℝ) + 2 * P + +def certificateOverhead (p D : ℕ) (P : ℝ) : ℝ := + 1 + 4 * (p : ℝ)^2 + 4 * (p : ℝ)^3 * anchorBudget p P + + (p : ℝ)^4 * (anchorBudget p P)^2 + + (p : ℝ)^4 * ((D : ℝ)+4) * (2*P)^200 + +lemma anchorBudget_nonneg (p : ℕ) {P : ℝ} (hP : 0 ≤ P) : + 0 ≤ anchorBudget p P := by + unfold anchorBudget + positivity + +lemma certificateOverhead_nonneg (p D : ℕ) {P : ℝ} (hP : 0 ≤ P) : + 0 ≤ certificateOverhead p D P := by + have hA := anchorBudget_nonneg p hP + unfold certificateOverhead + positivity + +theorem labelled_branching_bound (p D : ℕ) (P B H N M : ℝ) + (hP : 0 ≤ P) (hB : 1 ≤ B) (hH : H ≤ 4*B^2) (hN : N ≤ 4*B) + (hM : M ≤ (p : ℝ)^2 * (B^2 * Real.exp (P/50) * ((D : ℝ)+4) * (2*P)^200)) : + 1 + (((p : ℝ)*(H*p)/B)/B^8 + + (p : ℝ)^2*(N*p)*anchorBudget p P/B + + ((p : ℝ)^3*p*(anchorBudget p P)^2/B)*B + + (p : ℝ)^2*M/B^2) ≤ Real.exp (P/50)*certificateOverhead p D P := by + have hB0 : 0 < B := lt_of_lt_of_le zero_lt_one hB + have hp : (0 : ℝ) ≤ p := Nat.cast_nonneg p + have hA := anchorBudget_nonneg p hP + have he : 1 ≤ Real.exp (P/50) := Real.one_le_exp_iff.mpr (by positivity) + have hroot : ((p : ℝ)*(H*p)/B)/B^8 ≤ 4*(p : ℝ)^2 := by + apply (div_le_iff₀ (pow_pos hB0 8)).mpr + apply (div_le_iff₀ hB0).mpr + have hpow : B^2 ≤ B^9 := pow_le_pow_right₀ hB (by decide) + calc + (p : ℝ)*(H*p) ≤ (p : ℝ)*(4*B^2*p) := + mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right hH hp) hp + _ = 4*(p : ℝ)^2*B^2 := by ring + _ ≤ 4*(p : ℝ)^2*B^9 := mul_le_mul_of_nonneg_left hpow (by positivity) + _ = 4*(p : ℝ)^2*B^8*B := by ring + have hanchor : (p : ℝ)^2*(N*p)*anchorBudget p P/B ≤ + 4*(p : ℝ)^3*anchorBudget p P := by + apply (div_le_iff₀ hB0).mpr + calc + _ ≤ (p : ℝ)^2*(4*B*p)*anchorBudget p P := by + exact mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right hN hp) (by positivity)) hA + _ = _ := by ring + have htwo : ((p : ℝ)^3*p*(anchorBudget p P)^2/B)*B = + (p : ℝ)^4*(anchorBudget p P)^2 := by + rw [div_mul_cancel₀ _ hB0.ne'] + ring + have hpair : (p : ℝ)^2*M/B^2 ≤ + Real.exp (P/50)*((p : ℝ)^4*((D : ℝ)+4)*(2*P)^200) := by + apply (div_le_iff₀ (pow_pos hB0 2)).mpr + calc + _ ≤ (p : ℝ)^2*((p : ℝ)^2*(B^2*Real.exp (P/50)*((D : ℝ)+4)*(2*P)^200)) := + mul_le_mul_of_nonneg_left hM (by positivity) + _ = _ := by ring + have hplain : 1 + 4*(p : ℝ)^2 + 4*(p : ℝ)^3*anchorBudget p P + + (p : ℝ)^4*(anchorBudget p P)^2 ≤ + Real.exp (P/50)*(1 + 4*(p : ℝ)^2 + 4*(p : ℝ)^3*anchorBudget p P + + (p : ℝ)^4*(anchorBudget p P)^2) := by + exact le_mul_of_one_le_left (by positivity) he + unfold certificateOverhead + rw [htwo] + nlinarith only [hroot, hanchor, hpair, hplain] + +theorem absorb_certificate (p D : ℕ) (P : ℝ) + (h : certificateOverhead p D P ≤ Real.exp (2*P/25)) : + Real.exp (P/50)*certificateOverhead p D P ≤ Real.exp (P/10) := by + calc + _ ≤ Real.exp (P/50)*Real.exp (2*P/25) := + mul_le_mul_of_nonneg_left h (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +theorem singleton_budget (p : ℕ) (B P : ℝ) (hB : 0 ≤ B) (hP : 0 ≤ P) + (hp : 2*(p : ℝ)+3 ≤ Real.exp (P/10)) : + B*Real.exp (P/100) + 2*((p+1 : ℝ)*(B*Real.exp (P/10))) ≤ + B*Real.exp (P/5) := by + have he : Real.exp (P/100) ≤ Real.exp (P/10) := Real.exp_le_exp.mpr (by linarith) + calc + _ ≤ B*Real.exp (P/10)+2*((p+1 : ℝ)*(B*Real.exp (P/10))) := by + linarith only [mul_le_mul_of_nonneg_left he hB] + _ = (B*Real.exp (P/10))*(2*(p : ℝ)+3) := by ring + _ ≤ (B*Real.exp (P/10))*Real.exp (P/10) := + mul_le_mul_of_nonneg_left hp (mul_nonneg hB (Real.exp_pos _).le) + _ = _ := by rw [mul_assoc, ← Real.exp_add]; congr 2; ring + +def shiftOverhead (p D : ℕ) : ℝ := 4+(D : ℝ)*(200*(p : ℝ))^200 + +lemma shifted_dyadic_budget (p D : ℕ) (P C : ℝ) (hP : 0 ≤ P) (hC : 0 ≤ C) + (hpoly : shiftOverhead p D ≤ Real.exp (2*P/25)) : + 4*C+(D : ℝ)*C*Real.exp (P/50)*(2*(p : ℝ))^200 ≤ C*Real.exp (P/10) := by + have he : 1 ≤ Real.exp (P/50) := Real.one_le_exp_iff.mpr (by positivity) + have hp : (2*(p : ℝ))^200 ≤ (200*(p : ℝ))^200 := + pow_le_pow_left₀ (by positivity) (by have := (Nat.cast_nonneg p : (0 : ℝ) ≤ p); linarith) _ + have heC : 4*C ≤ 4*C*Real.exp (P/50) := le_mul_of_one_le_right (by positivity) he + have hpow := mul_le_mul_of_nonneg_left hp + (show 0 ≤ (D : ℝ)*C*Real.exp (P/50) by positivity) + calc + _ ≤ C*Real.exp (P/50)*shiftOverhead p D := by + unfold shiftOverhead + nlinarith only [heC, hpow] + _ ≤ C*Real.exp (P/50)*Real.exp (2*P/25) := + mul_le_mul_of_nonneg_left hpoly (by positivity) + _ = _ := by rw [mul_assoc, ← Real.exp_add]; congr 2; ring + +lemma strong_dyadic_budget (p D : ℕ) (P C : ℝ) (hP : 0 ≤ P) (hC : 0 ≤ C) + (hpoly : shiftOverhead p D ≤ Real.exp (2*P/25)) : + 4*C+(D : ℝ)*C*Real.exp (P/50)*(200*(p : ℝ))^200 ≤ C*Real.exp (P/10) := by + have he : 1 ≤ Real.exp (P/50) := Real.one_le_exp_iff.mpr (by positivity) + have heC : 4*C ≤ 4*C*Real.exp (P/50) := le_mul_of_one_le_right (by positivity) he + calc + _ ≤ C*Real.exp (P/50)*shiftOverhead p D := by + unfold shiftOverhead + nlinarith only [heC] + _ ≤ C*Real.exp (P/50)*Real.exp (2*P/25) := + mul_le_mul_of_nonneg_left hpoly (by positivity) + _ = _ := by rw [mul_assoc, ← Real.exp_add]; congr 2; ring + +end SharpLogRamsey.MomentBudgetBridge +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Entropy/MakePair.lean b/lean/OAI/Combinatorics/SharpRamsey/Entropy/MakePair.lean new file mode 100644 index 0000000000000000000000000000000000000000..eb4d2855c7f3af7821c8d75565d4d43376eb21ab --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Entropy/MakePair.lean @@ -0,0 +1,470 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Entropy.AnchorEventsRealized + +namespace OAI + +/-! High moments, finite-field subspaces, and incidence bounds. -/ + +section +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open scoped BigOperators +open MeasureTheory ProbabilityTheory +open scoped BigOperators ENNReal NNReal +namespace SharpRamseyFive.CertificateCover +open SharpRamseyFive.StaticCertificates +open SharpRamseyFive.CertificateEnumeration +open SharpRamseyFive.WeightedPrograms +open SharpRamseyFive.ResidualCertificate +open scoped BigOperators +variable {V H D B : Type*} [Fintype V] [DecidableEq V] + [Fintype H] [DecidableEq H] [Fintype D] [DecidableEq D] + [Fintype B] [DecidableEq B] +variable (lines : H → Finset D) +omit [Fintype V] [Fintype H] [DecidableEq H] [Fintype D] in +lemma make_pair (f : V → H) (hf : Function.Injective f) (hit : B → D → Prop) + (K : ℕ) (hK : 2 ≤ K) (low : Bool) (E : Finset V) (s : State V H D B) + (hs : Coherent lines f hit K E s) (v u : V) (hv : v ∉ E) (hu : u ∉ E) (hne : v ≠ u) + (hp : K ≤ (sharedBatches (outsideDirections (fun v => lines (f v)) E) hit v u).card) : + ∃ a : Action lines K s, + Coherent lines f hit K (insert v (insert u E)) (advance lines K s a) ∧ + (insert v (insert u E)).card = E.card + degree lines K s a ∧ + Enabled lines K low s a ∧ actionCharge lines K s a = 0 := by + classical + obtain ⟨T, d, hT, hd, _, _, _, _⟩ := + pair_step_witnesses (fun v => lines (f v)) hit E s.2 v u K hs.2.1 hs.2.2.1 hp + have hmem (r : T) : d r ∈ PairDirections lines s (f v) (f u) := by + apply Finset.mem_sdiff.mpr + refine ⟨(hd r).1, ?_⟩ + intro hc + exact (hd r).2.1 (hs.2.1 hc) + let c : PairChoice lines K s := ⟨v, u, f v, ⟨f u, fun he => hne (hf he.symm)⟩, + ⟨T, Finset.mem_powersetCard.mpr ⟨Finset.subset_univ _, hT⟩⟩, fun r => ⟨d r, hmem r⟩⟩ + let a : Action lines K s := .inr (.inr (.inr c)) + have hv' : v ∉ insert u E := by simp [hne, hv] + have hc : (insert v (insert u E)).card = E.card + degree lines K s a := by + simp [a, degree, Finset.card_insert_of_notMem hv', Finset.card_insert_of_notMem hu, + Nat.add_assoc] + refine ⟨a, ?_, hc, ?_, rfl⟩ + · apply coherent_step lines f hit K hK E (insert v (insert u E)) s hs a + ((Finset.subset_insert _ _).trans (Finset.subset_insert _ _)) _ _ _ hc + · have hu' := agrees_update f (insert v E) + (Function.update s.1 v (f v), s.2) (agrees_update f E s hs.1 v s.2) u + (advance lines K s a).2 + simpa only [a, c, advance, newValues, Finset.insert_comm] using hu' + · intro z hz + obtain ⟨p, hp, rfl⟩ := Finset.mem_image.mp hz + obtain ⟨r, _, rfl⟩ := Finset.mem_image.mp hp + exact Finset.mem_biUnion.mpr ⟨v, Finset.mem_insert_self _ _, (Finset.mem_inter.mp (hd r).1).1⟩ + · intro p hp + obtain ⟨r, _, rfl⟩ := Finset.mem_image.mp hp + exact (hd r).2.2 + · intro c' he + simp [a] at he +omit [Fintype V] [Fintype H] [DecidableEq H] in +omit [Fintype D] in + +lemma make_root (f : V → H) (hit : B → D → Prop) (K : ℕ) (hK : 2 ≤ K) + (low : Bool) (E : Finset V) (s : State V H D B) (hs : Coherent lines f hit K E s) + (v : V) (hv : v ∉ E) : + ∃ a : Action lines K s, Coherent lines f hit K (insert v E) (advance lines K s a) ∧ + (insert v E).card = E.card + degree lines K s a ∧ + Enabled lines K low s a ∧ actionCharge lines K s a = -8 := by + let a : Action lines K s := .inl (v, f v) + have hc : (insert v E).card = E.card + degree lines K s a := by + simp [a, degree, Finset.card_insert_of_notMem hv] + refine ⟨a, ?_, hc, ?_, rfl⟩ + · apply coherent_step lines f hit K hK E (insert v E) s hs a + (Finset.subset_insert _ _) (agrees_update f E s hs.1 v _) _ _ hc + · simp [a, newEvents, paidDirections] + · simp [a, newEvents, Realized] + · intro c' he + simp [a] at he + +abbrev Word (K : ℕ) := DWord (Action (V := V) (B := B) lines K) (advance lines K) +abbrev finish (K : ℕ) {n : ℕ} (s : State V H D B) (w : Word lines K n s) := + dFinish (Action lines K) (advance lines K) s w +abbrev charge (K : ℕ) {n : ℕ} (s : State V H D B) (w : Word lines K n s) := + dCharge (Action lines K) (advance lines K) (actionCharge lines K) s w + + def degreeSum (K : ℕ) : {n : ℕ} → (s : State V H D B) → Word lines K n s → ℕ + | 0, _, _ => 0 + | _ + 1, s, w => degree lines K s w.1 + degreeSum K (advance lines K s w.1) w.2 + + def TraceOK (K : ℕ) (low : Bool) : + {n : ℕ} → (s : State V H D B) → Word lines K n s → Prop + | 0, _, _ => True + | _ + 1, s, w => s.2.card ≤ K * Fintype.card V ∧ + Enabled lines K low s w.1 ∧ TraceOK K low (advance lines K s w.1) w.2 + + def append (K : ℕ) {m : ℕ} : {n : ℕ} → (s : State V H D B) → + (w : Word lines K n s) → Word lines K m (finish lines K s w) → Word lines K (m + n) s + | 0, _, _, w' => w' + | _ + 1, s, w, w' => ⟨w.1, append K (advance lines K s w.1) w.2 w'⟩ + +omit [Fintype V] [Fintype H] [DecidableEq H] [Fintype D] in +lemma finish_append (K : ℕ) {m n : ℕ} (s : State V H D B) + (w : Word lines K n s) (w' : Word lines K m (finish lines K s w)) : + finish lines K s (append lines K s w w') = finish lines K (finish lines K s w) w' := by + induction n generalizing s with + | zero => rfl + | succ n ih => exact ih _ w.2 w' + +omit [Fintype V] [Fintype H] [DecidableEq H] [Fintype D] in +lemma degreeSum_append (K : ℕ) {m n : ℕ} (s : State V H D B) + (w : Word lines K n s) (w' : Word lines K m (finish lines K s w)) : + degreeSum lines K s (append lines K s w w') = + degreeSum lines K s w + degreeSum lines K (finish lines K s w) w' := by + induction n generalizing s with + | zero => simp only [append, degreeSum, finish, dFinish, Nat.zero_add] + | succ n ih => + simpa only [append, degreeSum, finish, dFinish, Nat.add_assoc] using + congrArg (fun t => degree lines K s w.1 + t) (ih (advance lines K s w.1) w.2 w') + +omit [Fintype V] [Fintype H] [DecidableEq H] [Fintype D] in +lemma charge_append (K : ℕ) {m n : ℕ} (s : State V H D B) + (w : Word lines K n s) (w' : Word lines K m (finish lines K s w)) : + charge lines K s (append lines K s w w') = + charge lines K s w + charge lines K (finish lines K s w) w' := by + induction n generalizing s with + | zero => simp only [append, charge, dCharge, finish, dFinish, zero_add] + | succ n ih => + simpa only [append, charge, dCharge, finish, dFinish, add_assoc] using + congrArg (fun t => actionCharge lines K s w.1 + t) (ih (advance lines K s w.1) w.2 w') + +omit [Fintype H] [DecidableEq H] [Fintype D] in +lemma traceOK_append (K : ℕ) (low : Bool) {m n : ℕ} (s : State V H D B) + (w : Word lines K n s) (w' : Word lines K m (finish lines K s w)) + (h : TraceOK lines K low s w) (h' : TraceOK lines K low (finish lines K s w) w') : + TraceOK lines K low s (append lines K s w w') := by + induction n generalizing s with + | zero => exact h' + | succ n ih => exact ⟨h.1, h.2.1, ih _ w.2 w' h.2.2 h'⟩ + +omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] [Fintype D] [DecidableEq B] in +lemma one_le_degree (K : ℕ) (s : State V H D B) (a : Action lines K s) : + 1 ≤ degree lines K s a := by + rcases a with a | a + · exact le_rfl + rcases a with a | a + · exact le_rfl + rcases a with a | a + · exact le_rfl + · norm_num [degree] +omit [Fintype V] [Fintype H] [DecidableEq H] [Fintype D] in + +lemma length_le_degreeSum (K : ℕ) {n : ℕ} (s : State V H D B) (w : Word lines K n s) : + n ≤ degreeSum lines K s w := by + induction n generalizing s with + | zero => exact le_rfl + | succ n ih => + have h1 := one_le_degree lines K s w.1 + have h2 := ih _ w.2 + change n + 1 ≤ _ + _ + omega +omit [Fintype H] [DecidableEq H] in +omit [Fintype D] in + +lemma trace_weight (rate : D → ℝ≥0) (denom : ℝ) (hd : denom ≠ 0) + (K : ℕ) (low : Bool) {n : ℕ} (s : State V H D B) (w : Word lines K n s) + (hw : TraceOK lines K low s w) : + weight (fun p : B × D => rate p.2) (finish lines K s w).2 = + weight (fun p : B × D => rate p.2) s.2 * + dWeight (Action lines K) (advance lines K) (programCost lines rate denom K low) s w * + denom ^ degreeSum lines K s w := by + induction n generalizing s with + | zero => simp [finish, dFinish, dWeight, degreeSum] + | succ n ih => + change weight _ (finish lines K (advance lines K s w.1) w.2).2 = _ + rw [ih _ w.2 hw.2.2, step_weight lines rate denom hd K low s w.1 hw.2.1 hw.1] + simp only [dWeight, degreeSum, pow_add] + ring + + def Segment (f : V → H) (hit : B → D → Prop) (K : ℕ) (low : Bool) + (E F : Finset V) (s : State V H D B) {n : ℕ} (w : Word lines K n s) : Prop := + Coherent lines f hit K F (finish lines K s w) ∧ + F.card = E.card + degreeSum lines K s w ∧ TraceOK lines K low s w + +omit [Fintype H] [DecidableEq H] [Fintype D] in +lemma segment_empty (f : V → H) (hit : B → D → Prop) (K : ℕ) (low : Bool) + (E : Finset V) (s : State V H D B) (hs : Coherent lines f hit K E s) : + Segment lines f hit K low E E s (n := 0) (PUnit.unit : Word lines K 0 s) := by + exact ⟨hs, by simp [degreeSum], trivial⟩ + +omit [Fintype H] [DecidableEq H] [Fintype D] in +lemma segment_single (f : V → H) (hit : B → D → Prop) (K : ℕ) (low : Bool) + (E F : Finset V) (s : State V H D B) (hs : Coherent lines f hit K E s) + (a : Action lines K s) (hf : Coherent lines f hit K F (advance lines K s a)) + (hc : F.card = E.card + degree lines K s a) (he : Enabled lines K low s a) : + Segment lines f hit K low E F s (n := 1) (⟨a, PUnit.unit⟩ : Word lines K 1 s) := by + refine ⟨hf, ?_, ?_⟩ + · simpa [degreeSum] using hc + · exact ⟨hs.2.2.2.trans (Nat.mul_le_mul_left K (Finset.card_le_univ E)), he, trivial⟩ +omit [Fintype H] [DecidableEq H] [Fintype D] in + +lemma segment_append (f : V → H) (hit : B → D → Prop) (K : ℕ) (low : Bool) + (E F G : Finset V) {m n : ℕ} (s : State V H D B) + (w : Word lines K n s) (w' : Word lines K m (finish lines K s w)) + (h : Segment lines f hit K low E F s w) + (h' : Segment lines f hit K low F G (finish lines K s w) w') : + Segment lines f hit K low E G s (append lines K s w w') := by + refine ⟨?_, ?_, traceOK_append lines K low s w w' h.2.2 h'.2.2⟩ + · rw [finish_append]; exact h'.1 + · rw [degreeSum_append, ← Nat.add_assoc, ← h.2.1] + exact h'.2.1 +omit [Fintype V] [Fintype H] [DecidableEq H] in +omit [Fintype D] in + +lemma make_encoding (f : V → H) (hf : Function.Injective f) (hit : B → D → Prop) + (K : ℕ) (hK : 2 ≤ K) (low : Bool) {E F : Finset V} + (h : EncodingStep (fun v => lines (f v)) hit (if low then 1 else 2) K E F) + (s : State V H D B) (hs : Coherent lines f hit K E s) : + ∃ a : Action lines K s, Coherent lines f hit K F (advance lines K s a) ∧ + F.card = E.card + degree lines K s a ∧ Enabled lines K low s a ∧ + 0 ≤ actionCharge lines K s a := by + cases h with + | anchor v hv ha => + cases low with + | false => + obtain ⟨a, hh, hc, he, hq⟩ := make_two lines f hit K hK false E s hs v hv ha + exact ⟨a, hh, hc, he, by omega⟩ + | true => + obtain ⟨a, hh, hc, he, hq⟩ := make_one lines f hit K hK E s hs v hv ha + exact ⟨a, hh, hc, he, by omega⟩ + | pair v u hv hu hne hp => + obtain ⟨a, hh, hc, he, hq⟩ := make_pair lines f hf hit K hK low E s hs v u hv hu hne hp + exact ⟨a, hh, hc, he, by omega⟩ + +omit [Fintype H] [DecidableEq H] in +omit [Fintype D] in + +theorem encoding_path_program (f : V → H) (hf : Function.Injective f) + (hit : B → D → Prop) (K : ℕ) (hK : 2 ≤ K) (low : Bool) {E F : Finset V} + (h : Relation.ReflTransGen (EncodingStep (fun v => lines (f v)) hit + (if low then 1 else 2) K) E F) + (s : State V H D B) (hs : Coherent lines f hit K E s) : + ∃ n, ∃ w : Word lines K n s, Segment lines f hit K low E F s w ∧ + 0 ≤ charge lines K s w := by + induction h with + | refl => exact ⟨0, PUnit.unit, segment_empty lines f hit K low E s hs, le_rfl⟩ + | @tail F G h hFG ih => + obtain ⟨n, w, hw, hq⟩ := ih + obtain ⟨a, ha, hc, he, hqa⟩ := make_encoding lines f hf hit K hK low hFG + (finish lines K s w) hw.1 + let w' : Word lines K 1 (finish lines K s w) := ⟨a, PUnit.unit⟩ + refine ⟨1 + n, append lines K s w w', ?_, ?_⟩ + · exact segment_append lines f hit K low E F G s w w' hw + (segment_single lines f hit K low F G _ hw.1 a ha hc he) + · rw [charge_append] + exact add_nonneg hq (by simpa [w', charge, dCharge] using hqa) + +omit [Fintype H] [DecidableEq H] [Fintype D] in + +lemma encode_set (f : V → H) (hit : B → D → Prop) (K : ℕ) (low : Bool) + (E R : Finset V) (s : State V H D B) (hs : Coherent lines f hit K E s) (c : ℤ) + (hdis : Disjoint E R) + (hmake : ∀ F : Finset V, E ⊆ F → ∀ s' : State V H D B, + Coherent lines f hit K F s' → ∀ v ∈ R, v ∉ F → + ∃ a : Action lines K s', Coherent lines f hit K (insert v F) (advance lines K s' a) ∧ + (insert v F).card = F.card + degree lines K s' a ∧ + Enabled lines K low s' a ∧ actionCharge lines K s' a = c) : + ∃ n, ∃ w : Word lines K n s, Segment lines f hit K low E (E ∪ R) s w ∧ + charge lines K s w = c * R.card := by + classical + induction R using Finset.induction with + | empty => + refine ⟨0, PUnit.unit, ?_, ?_⟩ + · simpa using segment_empty lines f hit K low E s hs + · simp [charge, dCharge] + | @insert v R hvR ih => + have hdis' : Disjoint E R := hdis.mono_right (Finset.subset_insert _ _) + obtain ⟨n, w, hw, hq⟩ := ih hdis' (by + intro F hEF s' hs' u hu hfu + exact hmake F hEF s' hs' u (Finset.mem_insert_of_mem hu) hfu) + have hvE : v ∉ E := fun hvE => Finset.disjoint_left.mp hdis hvE (Finset.mem_insert_self _ _) + have hvF : v ∉ E ∪ R := by simp [hvE, hvR] + obtain ⟨a, ha, hc, he, hqa⟩ := hmake (E ∪ R) Finset.subset_union_left + (finish lines K s w) hw.1 v (Finset.mem_insert_self _ _) hvF + let w' : Word lines K 1 (finish lines K s w) := ⟨a, PUnit.unit⟩ + refine ⟨1 + n, append lines K s w w', ?_, ?_⟩ + · have hh := segment_append lines f hit K low E (E ∪ R) (insert v (E ∪ R)) s w w' hw + (segment_single lines f hit K low (E ∪ R) _ _ hw.1 a ha hc he) + simpa only [Finset.union_insert] using hh + · rw [charge_append, hq] + change c * (R.card : ℤ) + (actionCharge lines K _ a + 0) = _ + rw [hqa, Finset.card_insert_of_notMem hvR, Nat.cast_add, Nat.cast_one] + ring +omit [Fintype H] [DecidableEq H] in +omit [Fintype D] in + +lemma residual_program (f : V → H) (hit : B → D → Prop) (K : ℕ) (hK : 2 ≤ K) + (low : Bool) (F : Finset V) (s : State V H D B) (hs : Coherent lines f hit K F s) + (roots : Finset {v // v ∉ F}) + (hsize : 10 * roots.card ≤ Fintype.card {v // v ∉ F}) + (hroot : ∀ v, ∃ u ∈ roots, ∃ w ∈ roots, u ≠ w ∧ u ≠ v ∧ w ≠ v ∧ + ∃ d ∈ survivingDirections (fun v => lines (f v)) F v ∩ + survivingDirections (fun v => lines (f v)) F u, + ∃ e ∈ survivingDirections (fun v => lines (f v)) F v ∩ + survivingDirections (fun v => lines (f v)) F w, + d ≠ e ∧ (∃ r, hit r d) ∧ (∃ r, hit r e)) : + ∃ n, ∃ w : Word lines K n s, Segment lines f hit K low F Finset.univ s w ∧ + 0 ≤ charge lines K s w := by + classical + let R : Finset V := roots.image Subtype.val + have hRc : R.card = roots.card := by + dsimp [R] + apply Finset.card_image_of_injective + exact Subtype.val_injective + have hdis : Disjoint F R := by + apply Finset.disjoint_left.mpr + intro v hv hR + obtain ⟨u, _, rfl⟩ := Finset.mem_image.mp hR + exact u.property hv + obtain ⟨n, w, hw, hq⟩ := encode_set lines f hit K low F R s hs (-8) hdis (by + intro G hFG s' hs' v hv hvg + exact make_root lines f hit K hK low G s' hs' v hvg) + let NR : Finset V := Finset.univ \ (F ∪ R) + have hdisNR : Disjoint (F ∪ R) NR := Finset.disjoint_sdiff + have hmake : ∀ G : Finset V, F ∪ R ⊆ G → ∀ s' : State V H D B, + Coherent lines f hit K G s' → ∀ v ∈ NR, v ∉ G → + ∃ a : Action lines K s', Coherent lines f hit K (insert v G) (advance lines K s' a) ∧ + (insert v G).card = G.card + degree lines K s' a ∧ + Enabled lines K low s' a ∧ actionCharge lines K s' a = 1 := by + intro G hFG s' hs' v hv hvg + have hvF : v ∉ F := fun hvF => (Finset.mem_sdiff.mp hv).2 (Finset.mem_union_left R hvF) + obtain ⟨u, hu, u', hu', _, _, _, d, hd, e, he, hde, hdp, hep⟩ := hroot ⟨v, hvF⟩ + have hdv : d ∈ lines (f v) := (Finset.mem_sdiff.mp (Finset.mem_inter.mp hd).1).1 + have hdu : d ∈ lines (f u.val) := (Finset.mem_sdiff.mp (Finset.mem_inter.mp hd).2).1 + have hev : e ∈ lines (f v) := (Finset.mem_sdiff.mp (Finset.mem_inter.mp he).1).1 + have heu : e ∈ lines (f u'.val) := (Finset.mem_sdiff.mp (Finset.mem_inter.mp he).2).1 + have hdE : d ∈ encodedDirections (fun v => lines (f v)) G := + Finset.mem_biUnion.mpr ⟨u.val, hFG (Finset.mem_union_right F + (Finset.mem_image_of_mem Subtype.val hu)), hdu⟩ + have heE : e ∈ encodedDirections (fun v => lines (f v)) G := + Finset.mem_biUnion.mpr ⟨u'.val, hFG (Finset.mem_union_right F + (Finset.mem_image_of_mem Subtype.val hu')), heu⟩ + apply make_two lines f hit K hK low G s' hs' v hvg + apply Finset.one_lt_card.mpr + exact ⟨d, Finset.mem_filter.mpr ⟨Finset.mem_inter.mpr ⟨hdv, hdE⟩, hdp⟩, + e, Finset.mem_filter.mpr ⟨Finset.mem_inter.mpr ⟨hev, heE⟩, hep⟩, hde⟩ + obtain ⟨m, w', hw', hq'⟩ := encode_set lines f hit K low (F ∪ R) NR + (finish lines K s w) hw.1 1 hdisNR hmake + have hfull : (F ∪ R) ∪ NR = Finset.univ := by + ext v + simp only [NR, Finset.mem_union, Finset.mem_sdiff, Finset.mem_univ, true_and] + tauto + refine ⟨m + n, append lines K s w w', ?_, ?_⟩ + · simpa only [hfull] using segment_append lines f hit K low F (F ∪ R) _ s w w' hw hw' + · rw [charge_append, hq, hq', one_mul] + have hr : Fintype.card {v // v ∉ F} = Fintype.card V - F.card := by + rw [Fintype.card_subtype_compl] + simp + have hc : NR.card + (F.card + R.card) = Fintype.card V := by + have hh := Finset.card_sdiff_add_card_eq_card (Finset.subset_univ (F ∪ R)) + simpa only [NR, Finset.card_univ, Finset.card_union_of_disjoint hdis] using hh + rw [← hRc, hr] at hsize + omega + +omit [Fintype H] [DecidableEq H] in +omit [Fintype D] in + +theorem bad_program_high (f : V → H) (hf : Function.Injective f) + (hit : B → D → Prop) [∀ r d, Decidable (hit r d)] (K J h : ℕ) (hK : 2 ≤ K) (hh : 0 < h) + (hsize : h ≤ (Fintype.card B / 2 - J) / (2 * K)) + (E : Finset V) (s : State V H D B) (hs : Coherent lines f hit K E s) + (hbad : ∀ v ∉ E, Fintype.card B / 2 ≤ + (touchedBatches (fun v => lines (f v)) hit v).card) + (htrunc : ∀ d, (Finset.univ.filter (fun r => hit r d)).card ≤ J) + (herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) : + ∃ n, ∃ w : Word lines K n s, Segment lines f hit K false E Finset.univ s w ∧ + 0 ≤ charge lines K s w ∧ n ≤ Fintype.card V - E.card := by + classical + obtain ⟨F, hpath, roots, hr, hroot⟩ := high_case_certificate_geometry + (fun v => lines (f v)) hit E K J h hh hsize hbad + (by + intro d + apply le_trans _ (htrunc d) + apply Finset.card_le_card + intro r hr + simpa only [Finset.mem_filter, Finset.mem_univ, true_and] using hr) herr + obtain ⟨n, w, hw, hq⟩ := encoding_path_program lines f hf hit K hK false hpath s hs + obtain ⟨m, w', hw', hq'⟩ := residual_program lines f hit K hK false F + (finish lines K s w) hw.1 roots hr hroot + refine ⟨m + n, append lines K s w w', segment_append lines f hit K false E F _ s w w' hw hw', ?_, ?_⟩ + · rw [charge_append]; exact add_nonneg hq hq' + · have hl := length_le_degreeSum lines K s (append lines K s w w') + have hc := (segment_append lines f hit K false E F _ s w w' hw hw').2.1 + simp only [Finset.card_univ] at hc + omega +omit [Fintype H] [DecidableEq H] in +omit [Fintype D] in + + theorem bad_program_low (f : V → H) (hf : Function.Injective f) + (hit : B → D → Prop) (K h : ℕ) (hK : 2 ≤ K) (hh : 0 < h) + (hsize : h ≤ (Fintype.card B / 2) / (2 * K)) + (E : Finset V) (s : State V H D B) (hs : Coherent lines f hit K E s) + (hbad : ∀ v ∉ E, Fintype.card B / 2 ≤ + (touchedBatches (fun v => lines (f v)) hit v).card) + (herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) : + ∃ n, ∃ w : Word lines K n s, Segment lines f hit K true E Finset.univ s w ∧ + 0 ≤ charge lines K s w ∧ n ≤ Fintype.card V - E.card := by + obtain ⟨F, hpath, roots, hr, hroot⟩ := low_case_certificate_geometry + (fun v => lines (f v)) hit E K h hh hsize hbad herr + obtain ⟨n, w, hw, hq⟩ := encoding_path_program lines f hf hit K hK true hpath s hs + obtain ⟨m, w', hw', hq'⟩ := residual_program lines f hit K hK true F + (finish lines K s w) hw.1 roots hr hroot + refine ⟨m + n, append lines K s w w', segment_append lines f hit K true E F _ s w w' hw hw', ?_, ?_⟩ + · rw [charge_append]; exact add_nonneg hq hq' + · have hl := length_le_degreeSum lines K s (append lines K s w w') + have hc := (segment_append lines f hit K true E F _ s w w' hw hw').2.1 + simp only [Finset.card_univ] at hc + omega + +omit [DecidableEq D] [DecidableEq B] in +lemma decoded_static_union_bound {F C : Type*} [Fintype F] [DecidableEq F] + [Fintype C] [DecidableEq C] + (rate : D → ℝ≥0) (requirements : C → Finset (B × D)) (decode : C → F) + (events : F → Set ((B × D) → ℕ)) + (hm : ∀ f, MeasurableSet (events f)) + (hc : ∀ f ω, ω ∈ events f → ∃ c, decode c = f ∧ ω ∈ positiveEvent (requirements c)) : + (∑ f, (poissonLaw (fun p : B × D => rate p.2)).real (events f)) ≤ + ∑ c, weight (fun p : B × D => rate p.2) (requirements c) := by + classical + calc + _ ≤ ∑ f, ∑ c ∈ Finset.univ.filter (fun c => decode c = f), + weight (fun p : B × D => rate p.2) (requirements c) := by + apply Finset.sum_le_sum + intro f _ + apply static_union_bound _ requirements _ (events f) (hm f) + intro ω hω + obtain ⟨c, hd, he⟩ := hc f ω hω + exact ⟨c, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hd⟩, he⟩ + _ = _ := by + simp only [Finset.sum_filter] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro c _ + simp + +abbrev AllPrograms (K : ℕ) (E : Finset V) (s : State V H D B) := + (n : Fin (Fintype.card V - E.card + 1)) × Word lines K n.val s + + def CompleteProgram (K : ℕ) (low : Bool) (E : Finset V) (s : State V H D B) + (c : AllPrograms lines K E s) : Prop := + TraceOK lines K low s c.2 ∧ 0 ≤ charge lines K s c.2 ∧ + degreeSum lines K s c.2 = Fintype.card V - E.card + +noncomputable def completePrograms (K : ℕ) (low : Bool) (E : Finset V) (s : State V H D B) := + {c : AllPrograms lines K E s // CompleteProgram lines K low E s c} + +noncomputable instance completePrograms_fintype (K : ℕ) (low : Bool) (E : Finset V) + (s : State V H D B) : Fintype (completePrograms lines K low E s) := by + classical + unfold completePrograms + infer_instance +end SharpRamseyFive.CertificateCover +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Entropy/MarkingTwoEntropy.lean b/lean/OAI/Combinatorics/SharpRamsey/Entropy/MarkingTwoEntropy.lean new file mode 100644 index 0000000000000000000000000000000000000000..6440daa60859a0bb84ee4345286649ecdfe34da0 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Entropy/MarkingTwoEntropy.lean @@ -0,0 +1,66 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.MarkingTwoScans + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open scoped BigOperators Classical +noncomputable section +variable {Ω Γ α ι : Type*} [Fintype Ω] [Fintype Γ] [Fintype α] [Fintype ι] + +def selectedDeficit (p : Law Ω) (θ : Ω → Γ) (F : Ω → ι → α) + (S : Γ → Finset ι) (J : ℝ) : ℝ := + ∑ z, (p.map θ).mass z*((S z).card*J-entropy (((p.cond θ z).map F).restrict (S z))) +end +end SharpLogRamsey.Selection + +namespace SharpLogRamsey.Marking +open scoped BigOperators Classical +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] [Finite K] + +abbrev jointJ (K : Type*) (d : ℕ) : ℝ := Real.log (64*(Nat.card K:ℝ)^d) + +def sourceMessage {Ω Γ : Type*} {N : ℕ} (C : Ω → Γ) + (F : Ω → Fin N → ProjectivePair (K:=K) (V:=V)) : + Ω → TwoMessage (K:=K) (V:=V) Γ N := + Selection.markingMessage C (fun x => twoMask (Nat.card K) (F x)) bothExpensive F + +variable {Ω Γ : Type*} [Fintype Ω] [Fintype Γ] + +def excessCost {N : ℕ} (p : Selection.Law Ω) (C : Ω → Γ) + (F : Ω → Fin N → ProjectivePair (K:=K) (V:=V)) (Jprev J₀ : ℝ) : ℝ := + Selection.entropy (p.map C)+Real.log (Fintype.card (TwoMask (K:=K) (V:=V) N))+ + N*J₀-Selection.entropy (p.map F)+ + (∑ x, p.mass x*((bothExpensive (twoMask (Nat.card K) (F x))).card:ℝ))*(Jprev-J₀) + +theorem twoScan_subset_deficit {N n : ℕ} (hdim : Module.finrank K V=n+3) + (p : Selection.Law Ω) (C : Ω → Γ) (F : Ω → Fin N → ProjectivePair (K:=K) (V:=V)) + (D : Γ → Fin N → Finset (ProjectivePair (K:=K) (V:=V))) (Jprev : ℝ) + (hcons : ∀ x, p.mass x≠0 → ScanConsistent ((List.ofFn (F x)).map toScan)) + (hinc : ∀ x, p.mass x≠0 → ∀ i, Incidence.Incident (F x i).1 (F x i).2) + (hD : ∀ x, p.mass x≠0 → ∀ i, F x i∈D (C x) i) + (hprev : ∀ c i, Real.log (D c i).card≤Jprev) + (S : TwoMessage (K:=K) (V:=V) Γ N → Finset (Fin N)) + (hS : ∀ z, Disjoint (S z) (bothExpensive z.2.2)) : + 0 ≤ Selection.selectedDeficit p (sourceMessage C F) F S (jointJ K (n+2)) ∧ + Selection.selectedDeficit p (sourceMessage C F) F S (jointJ K (n+2)) ≤ + excessCost p C F Jprev (jointJ K (n+2)) := by + have hh := Selection.marking_subset_deficit p C (fun x => twoMask (Nat.card K) (F x)) + bothExpensive F D cheapBoth Jprev (jointJ K (n+2)) hD hprev + (fun x hx i hi => cheapBoth_mem C F x (hcons x hx) (hinc x hx) i hi) + (fun z i _ => cheapBoth_log_card hdim z i) S hS + change 0≤_ ∧ _≤_ at hh + convert hh using 1 <;> simp only [Selection.selectedDeficit,sourceMessage,excessCost,Fintype.card_fin] + all_goals congr! + +end +end SharpLogRamsey.Marking + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Entropy/NewEvents.lean b/lean/OAI/Combinatorics/SharpRamsey/Entropy/NewEvents.lean new file mode 100644 index 0000000000000000000000000000000000000000..f6497346d1b5dd356b79bed8940e80158ecac302 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Entropy/NewEvents.lean @@ -0,0 +1,487 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Entropy.TwoAnchorCrossCost + +namespace OAI + +/-! High moments, finite-field subspaces, and incidence bounds. -/ + +section +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open scoped BigOperators +namespace SharpRamseyFive.WeightedPrograms +open SharpRamseyFive.StaticCertificates +open SharpRamseyFive.CertificateEnumeration +open scoped BigOperators NNReal +variable {V H D B : Type*} [Fintype V] [DecidableEq V] + [Fintype H] [DecidableEq H] [Fintype D] [DecidableEq D] + [Fintype B] [DecidableEq B] +variable (lines : H → Finset D) +def newEvents (K : ℕ) (s : State V H D B) : Action lines K s → Finset (B × D) + | .inl _ => ∅ + | .inr (.inl c) => c.2.2.1.requirements + | .inr (.inr (.inl c)) => c.2.2.2.1.requirements ∪ c.2.2.2.2.1.requirements + | .inr (.inr (.inr c)) => witnessRequirements c.2.2.2.2.1.val + (PairDirections lines s c.2.2.1 c.2.2.2.1.val) c.2.2.2.2.2 + +def newValues (K : ℕ) (s : State V H D B) : Action lines K s → V → H + | .inl c => Function.update s.1 c.1 c.2 + | .inr (.inl c) => Function.update s.1 c.1 c.2.2.2.val + | .inr (.inr (.inl c)) => Function.update s.1 c.1 c.2.2.2.2.2.val + | .inr (.inr (.inr c)) => + Function.update (Function.update s.1 c.1 c.2.2.1) c.2.1 c.2.2.2.1.val + +def advance (K : ℕ) (s : State V H D B) (a : Action lines K s) : State V H D B := + (newValues lines K s a, s.2 ∪ newEvents lines K s a) + +def degree (K : ℕ) (s : State V H D B) : Action lines K s → ℕ + | .inr (.inr (.inr _)) => 2 + | _ => 1 + +def actionCharge (K : ℕ) (s : State V H D B) : Action lines K s → ℤ + | .inl _ => -8 + | .inr (.inr (.inl _)) => 1 + | _ => 0 + +noncomputable def rawCost (rate : D → ℝ≥0) (denom : ℝ) (K : ℕ) (low : Bool) + (s : State V H D B) : Action lines K s → ℝ + | .inl _ => 1 / denom + | .inr (.inl c) => if low then oneCost lines rate denom s c else 0 + | .inr (.inr (.inl c)) => twoCost lines rate denom s c + | .inr (.inr (.inr c)) => pairCost lines rate denom K s c + +noncomputable def programCost (rate : D → ℝ≥0) (denom : ℝ) (K : ℕ) (low : Bool) + (s : State V H D B) (a : Action lines K s) : ℝ := + if s.2.card ≤ K * Fintype.card V then rawCost lines rate denom K low s a else 0 + +omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in +omit [Fintype D] in +lemma newEvents_fresh (K : ℕ) (s : State V H D B) (a : Action lines K s) : + Disjoint s.2 (newEvents lines K s a) := by + rcases a with a | a + · exact Finset.disjoint_empty_right _ + rcases a with a | a + · exact a.2.2.1.fresh + rcases a with a | a + · exact Finset.disjoint_union_right.mpr ⟨a.2.2.2.1.fresh, a.2.2.2.2.1.fresh⟩ + · apply witnessRequirements_disjoint + apply Finset.disjoint_left.mpr + intro d hd hdC + exact (Finset.mem_sdiff.mp hd).2 hdC + +omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in +omit [Fintype D] in +lemma rawCost_nonneg (rate : D → ℝ≥0) (denom : ℝ) (hd : 0 ≤ denom) + (K : ℕ) (low : Bool) (s : State V H D B) (a : Action lines K s) : + 0 ≤ rawCost lines rate denom K low s a := by + rcases a with a | a + · exact div_nonneg zero_le_one hd + rcases a with a | a + · change 0 ≤ if low then _ else 0 + split_ifs + · exact div_nonneg (a.2.2.1.cost_nonneg rate) hd + · exact le_rfl + rcases a with a | a + · exact div_nonneg (mul_nonneg (a.2.2.2.1.cost_nonneg rate) + (a.2.2.2.2.1.cost_nonneg rate)) hd + · exact div_nonneg (weight_nonneg _ _) (sq_nonneg _) +omit [DecidableEq V] [Fintype H] [DecidableEq H] in +omit [Fintype D] in + +lemma programCost_nonneg (rate : D → ℝ≥0) (denom : ℝ) (hd : 0 ≤ denom) + (K : ℕ) (low : Bool) (s : State V H D B) (a : Action lines K s) : + 0 ≤ programCost lines rate denom K low s a := by + unfold programCost + split_ifs + · exact rawCost_nonneg lines rate denom hd K low s a + · exact le_rfl + +noncomputable def uniformAnchorBudget (K : ℕ) (mass : ℝ) : ℝ := + K * Fintype.card V + Fintype.card B * mass + +noncomputable def branchingBound (rate : D → ℝ≥0) (denom b mass : ℝ) + (K N₁ N₂ : ℕ) (low : Bool) : ℝ := + ((Fintype.card V : ℝ) * Fintype.card H / denom) / b ^ 8 + + (if low then Fintype.card V ^ 2 * (N₁ : ℝ) * + uniformAnchorBudget (V := V) (B := B) K mass / denom else 0) + + (Fintype.card V ^ 3 * (N₂ : ℝ) * + uniformAnchorBudget (V := V) (B := B) K mass ^ 2 / denom) * b + + Fintype.card V ^ 2 * pairMoment (B := B) lines rate K / denom ^ 2 + +omit [DecidableEq V] in +omit [Fintype D] [DecidableEq B] in +lemma branchingBound_nonneg (rate : D → ℝ≥0) (denom b mass : ℝ) + (hd : 0 ≤ denom) (hb : 0 ≤ b) (hm : 0 ≤ mass) + (K N₁ N₂ : ℕ) (low : Bool) : + 0 ≤ branchingBound (V := V) (B := B) lines rate denom b mass K N₁ N₂ low := by + unfold branchingBound uniformAnchorBudget + have hp := pairMoment_nonneg (B := B) lines rate K + split_ifs <;> positivity + +omit [DecidableEq V] [Fintype D] in +lemma discounted_raw_sum (rate : D → ℝ≥0) (denom b : ℝ) + (K : ℕ) (low : Bool) (s : State V H D B) : + (∑ a : Action lines K s, rawCost lines rate denom K low s a * b ^ actionCharge lines K s a) = + ((Fintype.card V : ℝ) * Fintype.card H / denom) / b ^ 8 + + (if low then ∑ c : OneChoice lines s, oneCost lines rate denom s c else 0) + + (∑ c : TwoChoice lines s, twoCost lines rate denom s c) * b + + ∑ c : PairChoice lines K s, pairCost lines rate denom K s c := by + classical + change (∑ a : RootChoice (V := V) (H := H) ⊕ + OneChoice lines s ⊕ TwoChoice lines s ⊕ PairChoice lines K s, _) = _ + simp only [Fintype.sum_sum_type, rawCost, actionCharge] + cases low <;> + simp only [Bool.false_eq_true, ↓reduceIte, + zpow_neg, zpow_ofNat, ← Finset.sum_mul, Finset.sum_const, + Finset.card_univ, Fintype.card_prod, nsmul_eq_mul, RootChoice, Nat.cast_mul] <;> ring + +omit [DecidableEq V] in +omit [Fintype D] in + +theorem discounted_row_bound (rate : D → ℝ≥0) (denom b mass : ℝ) + (hd : 0 ≤ denom) (hb : 0 ≤ b) (hm : 0 ≤ mass) + (hmass : ∀ h, ∑ d ∈ lines h, (rate d : ℝ) ≤ mass) + (K N₁ N₂ : ℕ) (low : Bool) + (hN₁ : ∀ d, (Finset.univ.filter (fun h => d ∈ lines h)).card ≤ N₁) + (hN₂ : ∀ d e, d ≠ e → + (Finset.univ.filter (fun h => d ∈ lines h ∧ e ∈ lines h)).card ≤ N₂) + (s : State V H D B) : + (∑ a : Action lines K s, + programCost lines rate denom K low s a * b ^ actionCharge lines K s a) ≤ + branchingBound (V := V) (B := B) lines rate denom b mass K N₁ N₂ low := by + classical + by_cases hs : s.2.card ≤ K * Fintype.card V + · simp only [programCost, ite_eq_left hs] + rw [discounted_raw_sum] + have hA : anchorBudget rate s mass ≤ uniformAnchorBudget (V := V) (B := B) K mass := by + unfold anchorBudget uniformAnchorBudget + apply add_le_add _ le_rfl + exact_mod_cast hs + have h1 := sum_oneCost_le lines rate denom hd s mass hmass N₁ hN₁ + have h2 := sum_twoCost_le lines rate denom hd s mass hm hmass N₂ hN₂ + have h3 := sum_pairCost_le lines rate denom K s + unfold branchingBound + apply add_le_add + · apply add_le_add + · apply add_le_add le_rfl + split_ifs with hl + · apply h1.trans + apply div_le_div_of_nonneg_right _ hd + exact mul_le_mul_of_nonneg_left hA (by positivity) + · exact le_rfl + · apply mul_le_mul_of_nonneg_right _ hb + apply h2.trans + apply div_le_div_of_nonneg_right _ hd + apply mul_le_mul_of_nonneg_left _ (by positivity) + exact pow_le_pow_left₀ (anchorBudget_nonneg rate s mass hm) hA 2 + · exact h3 + · simp only [programCost, ite_eq_right hs, zero_mul, Finset.sum_const_zero] + exact branchingBound_nonneg (V := V) lines rate denom b mass hd hb hm K N₁ N₂ low + +omit [Fintype D] in + +theorem program_enumeration (rate : D → ℝ≥0) (denom b mass : ℝ) + (hd : 0 ≤ denom) (hb : 1 ≤ b) (hm : 0 ≤ mass) + (hmass : ∀ h, ∑ d ∈ lines h, (rate d : ℝ) ≤ mass) + (K N₁ N₂ : ℕ) (low : Bool) + (hN₁ : ∀ d, (Finset.univ.filter (fun h => d ∈ lines h)).card ≤ N₁) + (hN₂ : ∀ d e, d ≠ e → + (Finset.univ.filter (fun h => d ∈ lines h ∧ e ∈ lines h)).card ≤ N₂) + (n : ℕ) (s : State V H D B) : + (∑ w : DWord (Action lines K) (advance lines K) n s, + if 0 ≤ dCharge (Action lines K) (advance lines K) (actionCharge lines K) s w + then dWeight (Action lines K) (advance lines K) (programCost lines rate denom K low) s w + else 0) ≤ + branchingBound (V := V) (B := B) lines rate denom b mass K N₁ N₂ low ^ n := by + classical + exact constrained_dSum_le (Action lines K) (advance lines K) + (programCost lines rate denom K low) (programCost_nonneg lines rate denom hd K low) + (actionCharge lines K) b _ hb + (branchingBound_nonneg (V := V) lines rate denom b mass hd (by linarith) hm K N₁ N₂ low) + (discounted_row_bound lines rate denom b mass hd (by linarith) hm hmass K N₁ N₂ low hN₁ hN₂) + n s _ (fun _ h => h) + +end SharpRamseyFive.WeightedPrograms + +open MeasureTheory ProbabilityTheory +open scoped BigOperators ENNReal NNReal + +namespace SharpRamseyFive.ResidualCertificate + +variable {V : Type*} [Fintype V] [DecidableEq V] + +noncomputable def rootProbability : unitInterval := ⟨1 / 20, by norm_num⟩ + +noncomputable def rootMeasure : Measure (V → Bool) := + Measure.pi (fun _ => bernoulliMeasure true false rootProbability) + +instance flat_HighMomentRecovered_6 : IsProbabilityMeasure (rootMeasure (V := V)) := by + unfold rootMeasure + infer_instance + +noncomputable def selected (ω : V → Bool) : Finset V := + Finset.univ.filter (fun v => ω v = true) + +def voidEvent (W : Finset V) : Set (V → Bool) := + (W : Set V).pi (fun _ => {false}) + +noncomputable def voidIndicator (W : Finset V) (ω : V → Bool) : ℝ := + (voidEvent W).indicator (fun _ => 1) ω + +noncomputable def badIndicator (W : Finset V) (ω : V → Bool) : ℝ := + if (W ∩ selected ω).card < 2 then 1 else 0 + +omit [DecidableEq V] in +lemma integrable_bounded (f : (V → Bool) → ℝ) (C : ℝ) (hf : ∀ ω, |f ω| ≤ C) : + Integrable f rootMeasure := by + apply Integrable.of_bound (measurable_of_countable f).aestronglyMeasurable C + exact Filter.Eventually.of_forall (by intro ω; simpa only [Real.norm_eq_abs] using hf ω) +omit [DecidableEq V] in + +lemma integrable_voidIndicator (W : Finset V) : Integrable (voidIndicator W) rootMeasure := by + apply integrable_bounded _ 1 + intro ω + by_cases h : ω ∈ voidEvent W <;> simp [voidIndicator, h] + +lemma integrable_badIndicator (W : Finset V) : Integrable (badIndicator W) rootMeasure := by + apply integrable_bounded _ 1 + intro ω + simp only [badIndicator] + split_ifs <;> norm_num + +omit [Fintype V] [DecidableEq V] in +lemma voidIndicator_nonneg (W : Finset V) (ω : V → Bool) : 0 ≤ voidIndicator W ω := by + by_cases h : ω ∈ voidEvent W <;> simp [voidIndicator, h] + +lemma badIndicator_nonneg (W : Finset V) (ω : V → Bool) : 0 ≤ badIndicator W ω := by + simp only [badIndicator] + split_ifs <;> norm_num + +omit [DecidableEq V] in +lemma integral_voidIndicator (W : Finset V) : + ∫ ω, voidIndicator W ω ∂rootMeasure = (19 / 20 : ℝ) ^ W.card := by + have hm : MeasurableSet (voidEvent W) := MeasurableSet.pi W.finite_toSet.countable + (fun _ _ => measurableSet_singleton false) + have hprob : rootMeasure (voidEvent W) = ENNReal.ofReal ((19 / 20 : ℝ) ^ W.card) := by + rw [rootMeasure, voidEvent, Measure.pi_pi_finset] + simp only [bernoulliMeasure_apply rootProbability (measurableSet_singleton false)] + norm_num [rootProbability, unitInterval.toNNReal, unitInterval.symm] + congr 1 + exact ENNReal.ofReal_coe_nnreal.symm + simp only [voidIndicator] + rw [ integral_indicator_const _ hm, Measure.real, hprob, + ENNReal.toReal_ofReal (by positivity)] + simp + +lemma erase_void_witness (W : Finset V) (hW : W.Nonempty) (ω : V → Bool) + (hbad : (W ∩ selected ω).card < 2) : + ∃ j ∈ W, ω ∈ voidEvent (W.erase j) := by + have hsmall : (W ∩ selected ω).card ≤ 1 := by omega + have hc := Finset.card_le_one.mp hsmall + by_cases he : (W ∩ selected ω).Nonempty + · obtain ⟨j, hj⟩ := he + refine ⟨j, (Finset.mem_inter.mp hj).1, ?_⟩ + intro k hk + apply Set.mem_singleton_iff.mpr + apply Bool.eq_false_of_not_eq_true + intro hkt + have hkm : k ∈ W ∩ selected ω := by + simp only [Finset.mem_inter, selected, Finset.mem_filter, Finset.mem_univ, true_and] + exact ⟨(Finset.mem_erase.mp hk).2, hkt⟩ + exact (Finset.mem_erase.mp hk).1 (hc k hkm j hj) + · obtain ⟨j, hj⟩ := hW + refine ⟨j, hj, ?_⟩ + intro k hk + apply Set.mem_singleton_iff.mpr + apply Bool.eq_false_of_not_eq_true + intro hkt + apply he + refine ⟨k, ?_⟩ + simp only [Finset.mem_inter, selected, Finset.mem_filter, Finset.mem_univ, true_and] + exact ⟨(Finset.mem_erase.mp hk).2, hkt⟩ + +lemma badIndicator_le_erase_void (W : Finset V) (hW : W.Nonempty) (ω : V → Bool) : + badIndicator W ω ≤ ∑ j ∈ W, voidIndicator (W.erase j) ω := by + unfold badIndicator + split_ifs with hb + · obtain ⟨j, hj, hv⟩ := erase_void_witness W hW ω hb + have hle := Finset.single_le_sum (f := fun j => voidIndicator (W.erase j) ω) + (fun j _ => voidIndicator_nonneg _ _) hj + simpa only [voidIndicator, Set.indicator_of_mem hv] using hle + · exact Finset.sum_nonneg (fun j _ => voidIndicator_nonneg _ _) + +lemma integral_badIndicator_le (W : Finset V) (hW : W.Nonempty) : + ∫ ω, badIndicator W ω ∂rootMeasure ≤ + W.card * (19 / 20 : ℝ) ^ (W.card - 1) := by + calc + _ ≤ ∫ ω, ∑ j ∈ W, voidIndicator (W.erase j) ω ∂rootMeasure := + integral_mono (integrable_badIndicator W) + (integrable_finsetSum _ (fun j _ => integrable_voidIndicator _)) + (badIndicator_le_erase_void W hW) + _ = ∑ j ∈ W, (19 / 20 : ℝ) ^ (W.card - 1) := by + rw [integral_finsetSum _ (fun j _ => integrable_voidIndicator _)] + apply Finset.sum_congr rfl + intro j hj + rw [integral_voidIndicator, Finset.card_erase_of_mem hj] + _ = _ := by simp + +omit [DecidableEq V] in +lemma indicator_selected (ω : V → Bool) : + ((selected ω).card : ℝ) = ∑ v : V, if ω v = true then (1 : ℝ) else 0 := by + symm + exact Finset.sum_boole _ _ +omit [DecidableEq V] in + +lemma integrable_selected_card : + Integrable (fun ω : V → Bool => ((selected ω).card : ℝ)) rootMeasure := by + simp_rw [indicator_selected] + apply integrable_finsetSum + intro v hv + apply integrable_bounded _ 1 + intro ω + split_ifs <;> norm_num +omit [DecidableEq V] in + +lemma integral_selected_card : + ∫ ω : V → Bool, ((selected ω).card : ℝ) ∂rootMeasure = (Fintype.card V : ℝ) / 20 := by + simp_rw [indicator_selected] + rw [integral_finsetSum] + · have hv (v : V) : + (∫ ω : V → Bool, if ω v = true then (1 : ℝ) else 0 ∂rootMeasure) = 1 / 20 := by + rw [rootMeasure, integral_comp_eval (μ := fun _ : V => bernoulliMeasure true false rootProbability) (i := v) (f := fun a : Bool => if a = true then (1 : ℝ) else 0) + (measurable_of_countable _).aestronglyMeasurable, + integral_bernoulliMeasure] + norm_num [rootProbability] + simp_rw [hv] + simp [div_eq_mul_inv] + · intro v hv + apply integrable_bounded _ 1 + intro ω + split_ifs <;> norm_num + +theorem exists_small_root_set (W : V → Finset V) {k : ℕ} (hk : 0 < k) + (hW : ∀ v, (W v).card = k) + (herr : (Fintype.card V : ℝ) * k * (19 / 20 : ℝ) ^ (k - 1) < 1 / 2) : + ∃ roots : Finset V, 10 * roots.card ≤ Fintype.card V ∧ + ∀ v, 2 ≤ (W v ∩ roots).card := by + classical + by_cases hn : Fintype.card V = 0 + · have : IsEmpty V := Fintype.card_eq_zero_iff.mp hn + exact ⟨∅, by simp [], fun v => isEmptyElim v⟩ + have hnpos : (0 : ℝ) < Fintype.card V := by exact_mod_cast (Nat.pos_of_ne_zero hn) + let F : (V → Bool) → ℝ := fun ω => + (10 / Fintype.card V : ℝ) * (selected ω).card + ∑ v, badIndicator (W v) ω + have hFi : Integrable F rootMeasure := + (integrable_selected_card.const_mul _).add + (integrable_finsetSum _ (fun v _ => integrable_badIndicator (W v))) + have hFint : ∫ ω, F ω ∂rootMeasure < 1 := by + have he (v : V) : ∫ ω, badIndicator (W v) ω ∂rootMeasure ≤ + k * (19 / 20 : ℝ) ^ (k - 1) := by + simpa only [hW] using integral_badIndicator_le (W v) (Finset.card_pos.mp (by rw [hW v]; exact hk)) + have sumle : ∑ v : V, (∫ ω, badIndicator (W v) ω ∂rootMeasure) ≤ + (Fintype.card V : ℝ) * k * (19 / 20 : ℝ) ^ (k - 1) := by + calc + _ ≤ ∑ _v : V, (k : ℝ) * (19 / 20 : ℝ) ^ (k - 1) := Finset.sum_le_sum (fun v _ => he v) + _ = _ := by simp; ring + have hc : (10 / Fintype.card V : ℝ) * ((Fintype.card V : ℝ) / 20) = 1 / 2 := by + field_simp + ; ring + dsimp [F] + rw [integral_add (integrable_selected_card.const_mul _) + (integrable_finsetSum _ (fun v _ => integrable_badIndicator (W v))), + integral_const_mul, integral_selected_card, integral_finsetSum _ + (fun v _ => integrable_badIndicator (W v)), hc] + linarith + have hex : ∃ ω, F ω < 1 := by + by_contra h + push Not at h + have hle := integral_mono (integrable_const (1 : ℝ)) hFi h + simp only [integral_const] at hle + simp at hle + linarith + obtain ⟨ω, hω⟩ := hex + have hsum : 0 ≤ ∑ v : V, badIndicator (W v) ω := + Finset.sum_nonneg (fun v _ => badIndicator_nonneg _ _) + have hcost : 0 ≤ (10 / Fintype.card V : ℝ) * (selected ω).card := by positivity + refine ⟨selected ω, ?_, ?_⟩ + · have ht : (10 / Fintype.card V : ℝ) * (selected ω).card < 1 := by dsimp [F] at hω; linarith + have hcard : (10 : ℝ) * (selected ω).card ≤ Fintype.card V := by + have := (mul_lt_mul_iff_right₀ hnpos).mpr ht + field_simp at this + nlinarith + exact_mod_cast hcard + · intro v + by_contra hv + have hbad : badIndicator (W v) ω = 1 := by simp [badIndicator, show (W v ∩ selected ω).card < 2 by omega] + have hle := Finset.single_le_sum (f := fun v => badIndicator (W v) ω) + (fun v _ => badIndicator_nonneg _ _) (Finset.mem_univ v) + rw [hbad] at hle + dsimp [F] at hω + linarith + +section WitnessMatching + +variable {E N D : Type*} [DecidableEq E] [DecidableEq N] [DecidableEq D] + +theorem exists_distinct_witnesses (s : Finset E) (neighbor : E → N) (direction : E → D) + (K : ℕ) (hn : ∀ n, (s.filter (fun e => neighbor e = n)).card ≤ K) + (hd : ∀ d, (s.filter (fun e => direction e = d)).card ≤ K) : + ∃ t ⊆ s, Set.InjOn neighbor (t : Set E) ∧ Set.InjOn direction (t : Set E) ∧ + s.card ≤ 2 * K * t.card := by + classical + let family : Finset (Finset E) := s.powerset.filter (fun t => + Set.InjOn neighbor (t : Set E) ∧ Set.InjOn direction (t : Set E)) + have hempty : ∅ ∈ family := by simp [family, Set.injOn_empty] + obtain ⟨t, htf, hmax⟩ := Finset.exists_max_image family Finset.card ⟨∅, hempty⟩ + have ht : t ⊆ s := Finset.mem_powerset.mp (Finset.mem_filter.mp htf).1 + have hinj := (Finset.mem_filter.mp htf).2 + have hcover (e : E) (he : e ∈ s) : + ∃ a ∈ t, neighbor e = neighbor a ∨ direction e = direction a := by + by_contra h + push Not at h + have hen : e ∉ t := by + intro het + exact (h e het).1 rfl + have hnnew : Set.InjOn neighbor (↑(insert e t) : Set E) := by + rw [Finset.coe_insert, Set.injOn_insert hen] + refine ⟨hinj.1, ?_⟩ + rintro ⟨a, ha, hea⟩ + exact (h a ha).1 hea.symm + have hdnew : Set.InjOn direction (↑(insert e t) : Set E) := by + rw [Finset.coe_insert, Set.injOn_insert hen] + refine ⟨hinj.2, ?_⟩ + rintro ⟨a, ha, hea⟩ + exact (h a ha).2 hea.symm + have hnew : insert e t ∈ family := by + simp only [family, Finset.mem_filter, Finset.mem_powerset] + exact ⟨Finset.insert_subset he ht, hnnew, hdnew⟩ + have := hmax _ hnew + rw [Finset.card_insert_of_notMem hen] at this + omega + refine ⟨t, ht, hinj.1, hinj.2, ?_⟩ + have hsub : s ⊆ t.biUnion (fun a => + (s.filter (fun e => neighbor e = neighbor a)) ∪ + (s.filter (fun e => direction e = direction a))) := by + intro e he + obtain ⟨a, ha, hor⟩ := hcover e he + apply Finset.mem_biUnion.mpr + refine ⟨a, ha, ?_⟩ + simpa only [Finset.mem_union, Finset.mem_filter, and_or_left] using + And.intro he hor + calc + s.card ≤ _ := Finset.card_le_card hsub + _ ≤ ∑ a ∈ t, ((s.filter (fun e => neighbor e = neighbor a)) ∪ + (s.filter (fun e => direction e = direction a))).card := Finset.card_biUnion_le + _ ≤ ∑ _a ∈ t, 2 * K := by + apply Finset.sum_le_sum + intro a ha + exact (Finset.card_union_le _ _).trans (by have := hn (neighbor a); have := hd (direction a); omega) + _ = 2 * K * t.card := by simp [Nat.mul_comm] + +end WitnessMatching +end SharpRamseyFive.ResidualCertificate +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Entropy/PatchNotMem.lean b/lean/OAI/Combinatorics/SharpRamsey/Entropy/PatchNotMem.lean new file mode 100644 index 0000000000000000000000000000000000000000..96145c804fdfb976554008c95dab2ba8b0aa95a6 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Entropy/PatchNotMem.lean @@ -0,0 +1,454 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Entropy.ShiftKernelSum + +namespace OAI + +/-! High moments, finite-field subspaces, and incidence bounds. -/ + +section +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open scoped BigOperators +open MeasureTheory ProbabilityTheory +open scoped BigOperators ENNReal NNReal +namespace SharpRamseyFive.ResidualElimination +open scoped BigOperators +open Classical +variable {V H : Type} [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] +omit [Fintype V] [Fintype H] [DecidableEq H] in +lemma patch_notMem (g : V → H) (T : Finset V) (x : T → H) (u : V) (hu : u ∉ T) : + patch g T x u = g u := by simp [patch, hu] +omit [Fintype V] [Fintype H] [DecidableEq H] in + +lemma agrees_sdiff_patch (E T : Finset V) (hT : T ⊆ E) (g f : V → H) (x : T → H) : + Agrees (E \ T) (patch g T x) f ↔ Agrees E g f ∧ x = fun u : T => f u := by + constructor + · intro h + constructor + · intro u hu + have hnu : u ∉ T := fun hh => hu (hT hh) + simpa only [patch_notMem g T x u hnu] using h u (by simp [hu]) + · funext u + have hu := h u (by simp) + simpa only [patch_mem] using hu.symm + · rintro ⟨h,rfl⟩ u hu + by_cases hnu : u ∈ T + · simp [patch, hnu] + · rw [patch_notMem g T _ u hnu] + exact h u (by simpa [hnu] using hu) + +lemma completionSum_split (E T : Finset V) (hT : T ⊆ E) (g : V → H) + (F : (V → H) → ℝ) : + completionSum E g F = ∑ x : T → H, completionSum (E \ T) (patch g T x) F := by + unfold completionSum + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro f _ + simp only [agrees_sdiff_patch E T hT] + by_cases hf : Agrees E g f <;> simp [hf] + +theorem weighted_block_exposure (E T : Finset V) (hT : T ⊆ E) (g : V → H) + (w : (T → H) → ℝ) (hw : ∀ x, 0 ≤ w x) (F : (V → H) → ℝ) + (C : ℝ) (hF : ∀ g, completionSum (E \ T) g F ≤ C) : + completionSum E g (fun f => w (fun u : T => f u) * F f) ≤ + (∑ x : T → H, w x) * C := by + rw [completionSum_split E T hT, Finset.sum_mul] + apply Finset.sum_le_sum + intro x _ + calc + _ = completionSum (E \ T) (patch g T x) (fun f => w x * F f) := by + apply completionSum_congr + intro f hf + have hx := (agrees_sdiff_patch E T hT g f x).mp hf + rw [← hx.2] + _ = w x * completionSum (E \ T) (patch g T x) F := completionSum_mul .. + _ ≤ _ := mul_le_mul_of_nonneg_left (hF _) (hw x) + +theorem independent_positions_exposure (E T : Finset V) (hT : T ⊆ E) (g : V → H) + (w : V → H → ℝ) (hw : ∀ u h, 0 ≤ w u h) (F : (V → H) → ℝ) + (C : ℝ) (hF : ∀ g, completionSum (E \ T) g F ≤ C) : + completionSum E g (fun f => (∏ u ∈ T, w u (f u)) * F f) ≤ + (∏ u ∈ T, ∑ h : H, w u h) * C := by + let W : (T → H) → ℝ := fun x => ∏ u : T, w u (x u) + have hW : ∀ x, 0 ≤ W x := by + intro x + exact Finset.prod_nonneg (fun u _ => hw _ _) + have he (f : V → H) : (∏ u ∈ T, w u (f u)) = W (fun u : T => f u) := by + exact (Finset.prod_coe_sort T (fun u => w u (f u))).symm + simp_rw [he] + apply (weighted_block_exposure E T hT g W hW F C hF).trans_eq + have hs : (∑ x : T → H, W x) = ∏ u ∈ T, ∑ h : H, w u h := by + rw [show (∑ x : T → H, W x) = ∏ u : T, ∑ h : H, w u h from + (Fintype.prod_sum (fun u : T => w u)).symm] + exact Finset.prod_coe_sort T (fun u => ∑ h : H, w u h) + rw [hs] + +end SharpRamseyFive.ResidualElimination + +namespace SharpRamseyFive.ResidualElimination +open scoped BigOperators +open Classical +variable {V H : Type} [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] + +omit [Fintype V] in +lemma powerset_sdiff (E U : Finset V) : + (E \ U).powerset = E.powerset.filter (fun S => Disjoint S U) := by + ext S + simp only [Finset.mem_powerset, Finset.mem_filter] + constructor + · intro h + refine ⟨h.trans Finset.sdiff_subset, Finset.disjoint_left.mpr ?_⟩ + intro u hu hU + exact (Finset.mem_sdiff.mp (h hu)).2 hU + · rintro ⟨h,hD⟩ u hu + exact Finset.mem_sdiff.mpr ⟨h hu, fun hU => Finset.disjoint_left.mp hD hu hU⟩ +omit [Fintype V] in + +lemma sum_disjoint_swap (E : Finset V) (F : Finset V → Finset V → ℝ) : + (∑ U ∈ E.powerset, ∑ S ∈ (E \ U).powerset, F U S) = + ∑ S ∈ E.powerset, ∑ U ∈ (E \ S).powerset, F U S := by + simp_rw [powerset_sdiff, Finset.sum_filter] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro S hS + apply Finset.sum_congr rfl + intro U hU + simp only [disjoint_comm] + +noncomputable def badExpansion (a : V → (V → H) → ℝ) + (B : Finset V → (V → H) → ℝ) (E : Finset V) (f : V → H) : ℝ := + ∑ U ∈ E.powerset, (∏ u ∈ E \ U, a u f) * B U f + +omit [Fintype V] [Fintype H] [DecidableEq H] in +lemma badExpansion_nonneg (a : V → (V → H) → ℝ) + (B : Finset V → (V → H) → ℝ) (ha : ∀ u f, 0 ≤ a u f) + (hB : ∀ E f, 0 ≤ B E f) (E : Finset V) (f : V → H) : + 0 ≤ badExpansion a B E f := by + apply Finset.sum_nonneg + intro U hU + exact mul_nonneg (Finset.prod_nonneg (fun u _ => ha u f)) (hB U f) + +omit [Fintype H] [DecidableEq H] in +omit [Fintype V] in +lemma badExpansion_add (a d : V → (V → H) → ℝ) + (B : Finset V → (V → H) → ℝ) (E : Finset V) (f : V → H) : + badExpansion (fun u f => d u f + a u f) B E f = + ∑ S ∈ E.powerset, (∏ u ∈ S, d u f) * badExpansion a B (E \ S) f := by + unfold badExpansion + simp_rw [Finset.prod_add, Finset.sum_mul] + rw [sum_disjoint_swap] + apply Finset.sum_congr rfl + intro S hS + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro U hU + have he : (E \ U) \ S = (E \ S) \ U := sdiff_sdiff_comm + rw [he, mul_assoc] +omit [DecidableEq H] in + +lemma badExpansion_sum_le (a : V → (V → H) → ℝ) + (B : Finset V → (V → H) → ℝ) (E : Finset V) (g : V → H) + (M : ℝ) (_hM : 0 ≤ M) + (hterm : ∀ S, S ⊆ E → completionSum E g (term a B E S) ≤ M ^ E.card) : + completionSum E g (badExpansion a B E) ≤ (2 * M) ^ E.card := by + rw [show badExpansion a B E = (fun f => ∑ U ∈ E.powerset, + (∏ u ∈ E \ U, a u f) * B U f) from rfl, completionSum_sum] + calc + _ ≤ ∑ _U ∈ E.powerset, M ^ E.card := by + apply Finset.sum_le_sum + intro U hU + have hU : U ⊆ E := Finset.mem_powerset.mp hU + have he : E \ (E \ U) = U := Finset.sdiff_sdiff_eq_self hU + have ht := hterm (E \ U) Finset.sdiff_subset + change completionSum E g (fun f => (∏ u ∈ E \ U, a u f) * + B (E \ (E \ U)) f) ≤ M ^ E.card at ht + simpa only [he] using ht + _ = _ := by simp [mul_pow] + +theorem all_singleton_enumeration + (a : V → (V → H) → ℝ) (d : V → H → ℝ) (B : Finset V → (V → H) → ℝ) + (W : H → H → ℝ) (C D : ℝ) (hC : 0 ≤ C) (_hD : 0 ≤ D) + (ha : ∀ u f, a u f ∈ Set.Icc (0 : ℝ) 1) + (hd : ∀ u x, 0 ≤ d u x) (hsum : ∀ u, (∑ x : H, d u x) ≤ D) + (hW : ∀ x y, 0 ≤ W x y) (hB : ∀ A f, 0 ≤ B A f) + (hmono : ∀ A A', A' ⊆ A → ∀ f, B A f ≤ B A' f) + (hshift : ∀ u f, a u f ≤ ∑ v ∈ Finset.univ.erase u, W (f u) (f v)) + (hrow : ∀ y, (∑ x : H, W x y) ≤ C) + (hpair : (∑ x : H, ∑ y : H, W x y) ≤ C ^ 2) + (hbad : ∀ A g, completionSum A g (B A) ≤ C ^ A.card) + (E : Finset V) (g : V → H) : + completionSum E g (badExpansion (fun u f => d u (f u) + a u f) B E) ≤ + (D + 2 * ((Fintype.card V + 1 : ℝ) * C)) ^ E.card := by + let M : ℝ := (Fintype.card V + 1) * C + have hM : 0 ≤ M := by dsimp [M]; positivity + have hbnd (A : Finset V) (g : V → H) : + completionSum A g (badExpansion a B A) ≤ (2 * M) ^ A.card := by + apply badExpansion_sum_le a B A g M hM + intro S hS + exact shift_bad_enumeration a B W C hC ha hW hB hmono hshift hrow hpair hbad A S hS g + have he : badExpansion (fun u f => d u (f u) + a u f) B E = + fun f => ∑ S ∈ E.powerset, (∏ u ∈ S, d u (f u)) * badExpansion a B (E \ S) f := by + funext f + exact badExpansion_add a (fun u f => d u (f u)) B E f + rw [he, completionSum_sum] + calc + _ ≤ ∑ S ∈ E.powerset, D ^ S.card * (2 * M) ^ (E \ S).card := by + apply Finset.sum_le_sum + intro S hS + apply (independent_positions_exposure E S (Finset.mem_powerset.mp hS) g d hd + (badExpansion a B (E \ S)) ((2 * M) ^ (E \ S).card) (hbnd (E \ S))).trans + apply mul_le_mul_of_nonneg_right _ (pow_nonneg (by positivity) _) + calc + (∏ u ∈ S, ∑ x : H, d u x) ≤ ∏ _u ∈ S, D := + Finset.prod_le_prod₀ (fun u _ => Finset.sum_nonneg (fun x _ => hd u x)) + (fun u _ => hsum u) + _ = _ := Finset.prod_const _ + _ = (D + 2 * M) ^ E.card := by + have := Finset.prod_add (fun _ : V => D) (fun _ => 2 * M) E + simpa only [Finset.prod_const] using this.symm + +end SharpRamseyFive.ResidualElimination + +namespace SharpRamseyFive.SingletonEnumeration +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponents +open SharpRamseyFive.Designations SharpRamseyFive.AmbientDesignations +open SharpRamseyFive.SelectionBridge SharpRamseyFive.WeightedPrograms +open SharpRamseyFive.ResidualElimination +open Classical +variable {D V H : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V] + [Fintype H] [DecidableEq H] + +noncomputable def independentWeight (weight rate : D → ℝ≥0) (lines : H → Finset D) + (R J : ℕ) (base : ℝ) (h : H) : ℝ := + |mass weight (lines h) - base| ^ (R / 2) + + (if R < J then 0 else ∑ d ∈ lines h, ((R : ℝ) * (rate d : ℝ)) ^ J) + +omit [Fintype D] [DecidableEq D] [Fintype H] [DecidableEq H] in +lemma independentWeight_nonneg (weight rate : D → ℝ≥0) (lines : H → Finset D) + (R J : ℕ) (base : ℝ) (h : H) : 0 ≤ independentWeight weight rate lines R J base h := by + unfold independentWeight + split_ifs <;> positivity + +theorem actual_all_singleton_enumeration (weight rate : D → ℝ≥0) (lines : H → Finset D) + {p : ℕ} (hp : 0 < p) (hc : Fintype.card V ≤ p) + (R : ℕ) (denom b mass C D₀ base : ℝ) + (hd : 0 < denom) (hb : 1 ≤ b) (hm : 0 ≤ mass) (hC : 0 ≤ C) (hD : 0 ≤ D₀) + (hmass : ∀ u, ∑ d ∈ lines u, (rate d : ℝ) ≤ mass) + (K J h N₁ N₂ : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (low : Bool) + (hsize : h ≤ (R / 2 - if low then 0 else J) / (2 * K)) + (herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) + (hN₁ : ∀ d, (Finset.univ.filter (fun u => d ∈ lines u)).card ≤ N₁) + (hN₂ : ∀ d e, d ≠ e → + (Finset.univ.filter (fun u => d ∈ lines u ∧ e ∈ lines u)).card ≤ N₂) + (hBC : denom * (1 + branchingBound (V := V) (B := Fin R) + (fun z : H × V => lines z.1) rate denom b mass K + (N₁ * Fintype.card V) (N₂ * Fintype.card V) low) ≤ C) + (hrow : ∀ y, (∑ x : H, shiftKernel weight lines p K x y) ≤ C) + (hpair : (∑ x : H, ∑ y : H, shiftKernel weight lines p K x y) ≤ C ^ 2) + (hDsum : (∑ x : H, independentWeight weight rate lines R J base x) ≤ D₀) + (E : Finset V) (g : V → H) : + completionSum E g (badExpansion + (fun u f => independentWeight weight rate lines R J base (f u) + + alpha weight (lines ∘ f) (1 / (100 * p)) u ^ K) + (fun A f => vertexBadMass weight rate (lines ∘ f) (1 / (100 * p)) R J A) E) ≤ + (D₀ + 2 * ((Fintype.card V + 1 : ℝ) * C)) ^ E.card := by + apply all_singleton_enumeration + (fun u f => alpha weight (lines ∘ f) (1 / (100 * p)) u ^ K) + (fun _ x => independentWeight weight rate lines R J base x) + (fun A f => vertexBadMass weight rate (lines ∘ f) (1 / (100 * p)) R J A) + (shiftKernel weight lines p K) C D₀ hC hD + · intro u f + exact ⟨pow_nonneg (alpha_nonneg _ _ _ _) _, + pow_le_one₀ (alpha_nonneg _ _ _ _) (by + have := source_alpha_le weight (lines ∘ f) hp hc u + linarith)⟩ + · exact fun _ x => independentWeight_nonneg weight rate lines R J base x + · exact fun _ => hDsum + · exact fun x y => (shiftKernel_range weight lines p K x y).1 + · exact fun A f => vertexBadMass_nonneg _ _ _ _ _ _ _ + · exact fun A A' hh f => vertexBadMass_antitone _ _ _ _ _ _ hh + · exact fun u f => shift_le_kernel_sum weight lines hp hc (by omega) u f + · exact hrow + · exact hpair + · intro A g + apply (actual_bad_completion weight rate lines (1 / (100 * p)) R denom b mass + hd hb hm hmass K J h N₁ N₂ hK hh low hsize herr hN₁ hN₂ A g).trans + apply pow_le_pow_left₀ _ hBC + apply mul_nonneg hd.le + have hn := branchingBound_nonneg (V := V) (B := Fin R) + (fun z : H × V => lines z.1) rate denom b mass hd.le (by linarith) hm K + (N₁ * Fintype.card V) (N₂ * Fintype.card V) low + linarith + +end SharpRamseyFive.SingletonEnumeration + +namespace SharpRamseyFive.SingletonEnumeration +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponents +open SharpRamseyFive.Designations SharpRamseyFive.AmbientDesignations +open SharpRamseyFive.SelectionBridge SharpRamseyFive.WeightedPrograms +open SharpRamseyFive.ResidualElimination +open Classical +variable {D V H : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V] + [Fintype H] [DecidableEq H] + +lemma inside_sum_le {C : Type} [Fintype C] [DecidableEq C] + (label : D → Option C) (c : C) (S : Finset D) (F : D → ℝ) (hF : ∀ d, 0 ≤ F d) : + (∑ d ∈ inside label c S, F d) ≤ ∑ d ∈ S, F d := by + have hi : Function.Injective (Subtype.val : IntDir label c → D) := Subtype.val_injective + rw [← Finset.sum_image (hi.injOn)] + apply Finset.sum_le_sum_of_subset_of_nonneg + · intro d hd + rcases Finset.mem_image.mp hd with ⟨e,he,rfl⟩ + exact (Finset.mem_filter.mp he).2 + · exact fun d _ _ => hF d + +omit [Fintype H] [DecidableEq H] in +lemma extraWeight_le_independent (weight : D → ℝ≥0) (lines : H → Finset D) + (f : V → H) (t : ℝ) (R J K : ℕ) (L : ℝ≥0) (base : ℝ) + (c : Components weight (lines ∘ f) t) : + extraWeight weight (lines ∘ f) t R J K L base c ≤ + independentWeight weight (fun d => L * weight d) lines R J base + (f (vertex weight (lines ∘ f) t c)) + + alpha weight (lines ∘ f) t (vertex weight (lines ∘ f) t c) ^ K := by + unfold extraWeight independentWeight delta + have h := inside_sum_le (componentLabel weight (lines ∘ f) t) c + ((lines ∘ f) (vertex weight (lines ∘ f) t c)) + (fun d => ((R : ℝ) * ((L * weight d : ℝ≥0) : ℝ)) ^ J) (fun _ => by positivity) + dsimp only [Function.comp_def] at * + split_ifs <;> linarith + +omit [Fintype H] [DecidableEq H] in + +theorem designation_sum_le_vertex (weight : D → ℝ≥0) (lines : H → Finset D) + (f : V → H) (t : ℝ) (R J K : ℕ) (L : ℝ≥0) (base : ℝ) : + let s := lines ∘ f + let S := simpleSet weight s t + let E := S.image (vertex weight s t) + (∑ U ∈ S.powerset, (∏ c ∈ S \ U, extraWeight weight s t R J K L base c) * + badMass (batchMeasure (fun i : Block (componentLabel weight s t) R none => L * weight i.1.2)) + (blockTrunc (componentLabel weight s t) R J none) (isBad weight s t R) U) ≤ + badExpansion + (fun u f => independentWeight weight (fun d => L * weight d) lines R J base (f u) + + alpha weight (lines ∘ f) t u ^ K) + (fun A f => vertexBadMass weight (fun d => L * weight d) (lines ∘ f) t R J A) E f := by + dsimp only + unfold badExpansion + rw [Finset.powerset_image, Finset.sum_image + (Finset.image_injective (vertex_injective weight (lines ∘ f) t)).injOn] + apply Finset.sum_le_sum + intro U hU + rw [← Finset.image_sdiff _ _ (vertex_injective weight (lines ∘ f) t), + Finset.prod_image (vertex_injective weight (lines ∘ f) t).injOn, + component_bad_mass_eq_vertex weight (fun d => L * weight d) (lines ∘ f) t R J U] + apply mul_le_mul_of_nonneg_right _ (vertexBadMass_nonneg _ _ _ _ _ _ _) + apply Finset.prod_le_prod₀ + · exact fun c _ => extraWeight_nonneg _ _ _ _ _ _ _ _ c + · exact fun c _ => extraWeight_le_independent weight lines f t R J K L base c + +end SharpRamseyFive.SingletonEnumeration + +namespace SharpRamseyFive.ResidualElimination +open scoped BigOperators +open Classical +variable {V H C : Type} [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] + [DecidableEq C] + +theorem disjoint_blocks_exposure (E : Finset V) (I : Finset C) (T : C → Finset V) + (Win : (c : C) → (T c → H) → ℝ) (M : C → ℝ) + (hw : ∀ c x, 0 ≤ Win c x) (hM : ∀ c, 0 ≤ M c) + (hwithin : ∀ c ∈ I, T c ⊆ E) + (hdisj : ∀ c ∈ I, ∀ d ∈ I, c ≠ d → Disjoint (T c) (T d)) + (hsum : ∀ c ∈ I, (∑ x : T c → H, Win c x) ≤ M c) + (F : (V → H) → ℝ) (K : ℝ) (hK : 0 ≤ K) + (hres : ∀ g, completionSum (E \ I.biUnion T) g F ≤ K) (g : V → H) : + completionSum E g (fun f => (∏ c ∈ I, Win c (fun v => f v)) * F f) ≤ + (∏ c ∈ I, M c) * K := by + induction I using Finset.induction generalizing E g with + | empty => simpa using hres g + | @insert c I hc ih => + have hwi : T c ⊆ E := hwithin c (Finset.mem_insert_self c I) + have hrwithin : ∀ d ∈ I, T d ⊆ E \ T c := by + intro d hd v hv + refine Finset.mem_sdiff.mpr ⟨hwithin d (Finset.mem_insert_of_mem hd) hv, ?_⟩ + intro hvc + exact Finset.disjoint_left.mp + (hdisj d (Finset.mem_insert_of_mem hd) c (Finset.mem_insert_self _ _) + (by intro he; subst d; exact hc hd)) hv hvc + have he : (E \ T c) \ I.biUnion T = E \ (insert c I).biUnion T := by + ext v + simp only [Finset.mem_sdiff, Finset.biUnion_insert, Finset.mem_union] + tauto + have hr (g : V → H) : + completionSum (E \ T c) g + (fun f => (∏ d ∈ I, Win d (fun v => f v)) * F f) ≤ (∏ d ∈ I, M d) * K := by + apply ih (E \ T c) hrwithin + (fun d hd e he hne => hdisj d (Finset.mem_insert_of_mem hd) + e (Finset.mem_insert_of_mem he) hne) + (fun d hd => hsum d (Finset.mem_insert_of_mem hd)) + intro g + rw [he] + exact hres g + simp_rw [Finset.prod_insert hc, mul_assoc] + apply (weighted_block_exposure E (T c) hwi g (Win c) (hw c) + (fun f => (∏ d ∈ I, Win d (fun v => f v)) * F f) + ((∏ d ∈ I, M d) * K) hr).trans + exact mul_le_mul_of_nonneg_right (hsum c (Finset.mem_insert_self _ _)) + (mul_nonneg (Finset.prod_nonneg (fun d _ => hM d)) hK) + +end SharpRamseyFive.ResidualElimination + +namespace SharpRamseyFive.ComponentPartition +open scoped BigOperators +open Classical +variable {V C : Type} [Fintype V] [DecidableEq V] [Fintype C] [DecidableEq C] + +noncomputable def fiber (r : V → C) (c : C) : Finset V := + Finset.univ.filter (fun v => r v = c) +noncomputable def singles (r : V → C) : Finset V := + Finset.univ.filter (fun v => (fiber r (r v)).card = 1) +noncomputable def largeLabels (r : V → C) : Finset C := + Finset.univ.filter (fun c => 2 ≤ (fiber r c).card) + +omit [DecidableEq V] [Fintype C] in +@[simp] lemma mem_fiber (r : V → C) (c : C) (v : V) : v ∈ fiber r c ↔ r v = c := by + simp [fiber] +omit [DecidableEq V] [Fintype C] in +@[simp] lemma mem_singles (r : V → C) (v : V) : + v ∈ singles r ↔ (fiber r (r v)).card = 1 := by simp [singles] +omit [DecidableEq V] in +@[simp] lemma mem_largeLabels (r : V → C) (c : C) : + c ∈ largeLabels r ↔ 2 ≤ (fiber r c).card := by simp [largeLabels] +omit [DecidableEq V] [Fintype C] in + +lemma self_mem_fiber (r : V → C) (v : V) : v ∈ fiber r (r v) := by simp +omit [DecidableEq V] [Fintype C] in +lemma fiber_card_pos (r : V → C) (v : V) : 0 < (fiber r (r v)).card := + Finset.card_pos.mpr ⟨v,self_mem_fiber r v⟩ +omit [DecidableEq V] [Fintype C] in + +lemma fiber_disjoint (r : V → C) {c d : C} (hne : c ≠ d) : + Disjoint (fiber r c) (fiber r d) := by + apply Finset.disjoint_left.mpr + intro v hc hd + exact hne ((mem_fiber r c v).mp hc |>.symm.trans ((mem_fiber r d v).mp hd)) + +lemma large_union (r : V → C) : (largeLabels r).biUnion (fiber r) = Finset.univ \ singles r := by + ext v + simp only [Finset.mem_biUnion, mem_largeLabels, mem_fiber, Finset.mem_sdiff, + Finset.mem_univ, true_and, mem_singles] + constructor + · rintro ⟨c,hc,he⟩ + rw [he] + omega + · intro hv + exact ⟨r v,by have := fiber_card_pos r v; omega,rfl⟩ +end SharpRamseyFive.ComponentPartition +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Entropy/PoissonLaw.lean b/lean/OAI/Combinatorics/SharpRamsey/Entropy/PoissonLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..cd80b715a68f0117da4d190ac1b2229eb717c7b3 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Entropy/PoissonLaw.lean @@ -0,0 +1,465 @@ +import Mathlib + +namespace OAI + +/-! High moments, finite-field subspaces, and incidence bounds. -/ + +section +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +namespace SharpRamseyFive.StaticCertificates +variable {ι : Type*} [Fintype ι] [DecidableEq ι] +noncomputable def poissonLaw (rate : ι → ℝ≥0) : Measure (ι → ℕ) := + Measure.pi (fun i => poissonMeasure (rate i)) + +instance flat_HighMomentRecovered_3 (rate : ι → ℝ≥0) : IsProbabilityMeasure (poissonLaw rate) := by + unfold poissonLaw + infer_instance + +def positiveEvent (C : Finset ι) : Set (ι → ℕ) := + (C : Set ι).pi (fun _ => ({0} : Set ℕ)ᶜ) + +noncomputable def certificateIndicator (C : Finset ι) (ω : ι → ℕ) : ℝ := + (positiveEvent C).indicator (fun _ => 1) ω + +noncomputable def weight (rate : ι → ℝ≥0) (C : Finset ι) : ℝ := + ∏ i ∈ C, (rate i : ℝ) + +omit [Fintype ι] [DecidableEq ι] in +lemma measurableSet_positiveEvent (C : Finset ι) : MeasurableSet (positiveEvent C) := + MeasurableSet.pi C.finite_toSet.countable (fun _ _ => (measurableSet_singleton 0).compl) +omit [DecidableEq ι] in + +lemma integrable_certificateIndicator (rate : ι → ℝ≥0) (C : Finset ι) : + Integrable (certificateIndicator C) (poissonLaw rate) := + (integrable_const (1 : ℝ)).indicator (measurableSet_positiveEvent C) + +omit [Fintype ι] [DecidableEq ι] in +lemma indicator_nonneg (C : Finset ι) (ω : ι → ℕ) : + 0 ≤ certificateIndicator C ω := by + exact Set.indicator_nonneg (fun _ _ => zero_le_one) _ +omit [DecidableEq ι] in + +lemma integral_certificateIndicator (rate : ι → ℝ≥0) (C : Finset ι) : + (∫ ω, certificateIndicator C ω ∂poissonLaw rate) = + ∏ i ∈ C, (1 - Real.exp (-(rate i : ℝ))) := by + unfold certificateIndicator + rw [integral_indicator_const _ (measurableSet_positiveEvent C)] + simp only [smul_eq_mul, mul_one] + rw [Measure.real, poissonLaw, positiveEvent, Measure.pi_pi_finset, + ENNReal.toReal_prod] + apply Finset.prod_congr rfl + intro i _ + rw [← Measure.real, measureReal_compl (measurableSet_singleton 0), + probReal_univ, Measure.real, poissonMeasure_singleton] + simp only [pow_zero, Nat.factorial_zero, Nat.cast_one, mul_one, div_one] + rw [ENNReal.toReal_ofReal (Real.exp_pos _).le] +omit [DecidableEq ι] in + +lemma integral_certificateIndicator_le (rate : ι → ℝ≥0) (C : Finset ι) : + (∫ ω, certificateIndicator C ω ∂poissonLaw rate) ≤ weight rate C := by + rw [integral_certificateIndicator] + apply Finset.prod_le_prod₀ + · intro i _ + have he := Real.exp_le_one_iff.mpr (neg_nonpos.mpr (rate i).coe_nonneg) + linarith + · intro i _ + have he := Real.add_one_le_exp (-(rate i : ℝ)) + linarith + +omit [Fintype ι] [DecidableEq ι] in +lemma weight_nonneg (rate : ι → ℝ≥0) (C : Finset ι) : 0 ≤ weight rate C := by + exact Finset.prod_nonneg (fun i _ => (rate i).coe_nonneg) + +omit [Fintype ι] in + +lemma weight_union (rate : ι → ℝ≥0) (C D : Finset ι) : + weight rate (C ∪ D) = weight rate C * weight rate (D \ C) := by + unfold weight + rw [← Finset.prod_union (Finset.disjoint_sdiff)] + congr 1 + ext i + simp only [Finset.mem_union, Finset.mem_sdiff] + tauto + +omit [Fintype ι] in +lemma positiveEvent_union (C D : Finset ι) : + positiveEvent (C ∪ D) = positiveEvent C ∩ positiveEvent D := by + ext ω + simp [positiveEvent, Set.mem_pi, or_imp, forall_and] + +omit [DecidableEq ι] in + +theorem static_union_bound {κ : Type*} (D : Finset κ) (requirements : κ → Finset ι) + (rate : ι → ℝ≥0) (E : Set (ι → ℕ)) (hE : MeasurableSet E) + (hcover : ∀ ω ∈ E, ∃ c ∈ D, ω ∈ positiveEvent (requirements c)) : + (poissonLaw rate).real E ≤ ∑ c ∈ D, weight rate (requirements c) := by + have hp (ω : ι → ℕ) : E.indicator (fun _ => (1 : ℝ)) ω ≤ + ∑ c ∈ D, certificateIndicator (requirements c) ω := by + by_cases hω : ω ∈ E + · obtain ⟨c, hc, he⟩ := hcover ω hω + have := Finset.single_le_sum (f := fun c => certificateIndicator (requirements c) ω) + (fun c _ => indicator_nonneg _ _) hc + simpa [certificateIndicator, he, hω] using this + · simp only [Set.indicator_of_notMem hω] + exact Finset.sum_nonneg (fun c _ => indicator_nonneg _ _) + calc + _ = ∫ ω, E.indicator (fun _ => (1 : ℝ)) ω ∂poissonLaw rate := by + rw [integral_indicator_const _ hE] + simp + _ ≤ ∫ ω, ∑ c ∈ D, certificateIndicator (requirements c) ω ∂poissonLaw rate := + integral_mono ((integrable_const (1 : ℝ)).indicator hE) + (integrable_finsetSum _ (fun c _ => integrable_certificateIndicator _ _)) hp + _ = ∑ c ∈ D, ∫ ω, certificateIndicator (requirements c) ω ∂poissonLaw rate := + integral_finsetSum _ (fun c _ => integrable_certificateIndicator _ _) + _ ≤ _ := Finset.sum_le_sum (fun c _ => integral_certificateIndicator_le _ _) + +section PairWitnesses + +variable {κ : Type*} [Fintype κ] [DecidableEq κ] + +def witnessRequirements (T : Finset κ) (S : Finset ι) (f : T → S) : Finset (κ × ι) := + T.attach.image (fun r => (r.val, (f r).val)) + +omit [Fintype ι] [Fintype κ] in +lemma witnessRequirements_card (T : Finset κ) (S : Finset ι) (f : T → S) : + (witnessRequirements T S f).card = T.card := by + rw [witnessRequirements, Finset.card_image_of_injective] + · exact Finset.card_attach + · intro a b h + exact Subtype.ext (congrArg Prod.fst h) + +omit [Fintype ι] [Fintype κ] in +lemma witness_weight (rate : ι → ℝ≥0) (T : Finset κ) (S : Finset ι) (f : T → S) : + weight (fun p : κ × ι => rate p.2) (witnessRequirements T S f) = + ∏ r : T, (rate (f r) : ℝ) := by + unfold weight witnessRequirements + rw [Finset.prod_image] + · rw [Finset.univ_eq_attach T] + · intro a _ b _ h + exact Subtype.ext (congrArg Prod.fst h) +omit [Fintype ι] [Fintype κ] in + +lemma sum_witness_weight (rate : ι → ℝ≥0) (T : Finset κ) (S : Finset ι) : + (∑ f : T → S, weight (fun p : κ × ι => rate p.2) (witnessRequirements T S f)) = + (∑ i ∈ S, (rate i : ℝ)) ^ T.card := by + simp_rw [witness_weight] + rw [← Fintype.prod_sum (fun (_r : T) (i : S) => (rate i : ℝ))] + rw [Finset.sum_coe_sort S (fun i => (rate i : ℝ))] + simp + +omit [Fintype ι] in + +theorem pair_certificate_weight (rate : ι → ℝ≥0) (S : Finset ι) (K : ℕ) : + (∑ T ∈ (Finset.univ : Finset κ).powersetCard K, + ∑ f : T → S, weight (fun p : κ × ι => rate p.2) (witnessRequirements T S f)) = + (Fintype.card κ).choose K * (∑ i ∈ S, (rate i : ℝ)) ^ K := by + simp_rw [sum_witness_weight] + calc + _ = ∑ _T ∈ (Finset.univ : Finset κ).powersetCard K, + (∑ i ∈ S, (rate i : ℝ)) ^ K := by + apply Finset.sum_congr rfl + intro T hT + rw [(Finset.mem_powersetCard.mp hT).2] + _ = _ := by simp + +omit [Fintype ι] in + +theorem pair_certificate_weight_le (rate : ι → ℝ≥0) (S : Finset ι) (K : ℕ) : + (∑ T ∈ (Finset.univ : Finset κ).powersetCard K, + ∑ f : T → S, weight (fun p : κ × ι => rate p.2) (witnessRequirements T S f)) ≤ + ((Fintype.card κ : ℝ) * ∑ i ∈ S, (rate i : ℝ)) ^ K := by + rw [pair_certificate_weight, mul_pow] + apply mul_le_mul_of_nonneg_right + · exact_mod_cast Nat.choose_le_pow (Fintype.card κ) K + · positivity + +omit [Fintype ι] [Fintype κ] in + +theorem pair_witness_exists (S : Finset ι) (T : Finset κ) (ω : κ × ι → ℕ) + (hT : ∀ r ∈ T, ∃ i ∈ S, ω (r, i) ≠ 0) : + ∃ f : T → S, ω ∈ positiveEvent (witnessRequirements T S f) := by + classical + have h (r : T) : ∃ i : S, ω (r.val, i.val) ≠ 0 := by + obtain ⟨i, hi, he⟩ := hT r r.property + exact ⟨⟨i, hi⟩, he⟩ + choose f hf using h + refine ⟨f, ?_⟩ + intro p hp + obtain ⟨r, _, rfl⟩ := Finset.mem_image.mp hp + exact hf r + +def dictionary (C : Finset (κ × ι)) : Finset ι := C.image Prod.snd + +omit [Fintype ι] [Fintype κ] [DecidableEq κ] in +lemma direction_mem_dictionary {C : Finset (κ × ι)} {r : κ} {i : ι} + (h : (r, i) ∈ C) : i ∈ dictionary C := Finset.mem_image_of_mem _ h +omit [Fintype ι] [Fintype κ] in + +lemma witnessRequirements_disjoint {C : Finset (κ × ι)} (T : Finset κ) (S : Finset ι) + (f : T → S) (hnew : Disjoint S (dictionary C)) : + Disjoint C (witnessRequirements T S f) := by + apply Finset.disjoint_left.mpr + intro p hp hp' + obtain ⟨r, _, hr⟩ := Finset.mem_image.mp hp' + have he := congrArg Prod.snd hr + have hf : p.2 ∈ S := he ▸ (f r).property + exact Finset.disjoint_left.mp hnew hf (direction_mem_dictionary hp) + +omit [Fintype ι] [Fintype κ] in +lemma weight_union_fresh (rate : κ × ι → ℝ≥0) (C D : Finset (κ × ι)) + (hfresh : Disjoint C D) : weight rate (C ∪ D) = weight rate C * weight rate D := by + exact Finset.prod_union hfresh + +omit [Fintype ι] [Fintype κ] in + +theorem pair_dictionary_extension (rate : ι → ℝ≥0) (C : Finset (κ × ι)) + (T : Finset κ) (S : Finset ι) (f : T → S) (hnew : Disjoint S (dictionary C)) : + weight (fun p : κ × ι => rate p.2) (C ∪ witnessRequirements T S f) = + weight (fun p : κ × ι => rate p.2) C * ∏ r : T, (rate (f r) : ℝ) := by + rw [weight_union_fresh _ _ _ (witnessRequirements_disjoint T S f hnew), witness_weight] + +def anchorRequirements (C : Finset (κ × ι)) (r : κ) (i : ι) : Finset (κ × ι) := + if i ∈ dictionary C then ∅ else {(r, i)} +omit [Fintype ι] [Fintype κ] [DecidableEq κ] in + +lemma anchorRequirements_disjoint (C : Finset (κ × ι)) (r : κ) (i : ι) : + Disjoint C (anchorRequirements C r i) := by + unfold anchorRequirements + split_ifs with h + · exact Finset.disjoint_empty_right _ + · simp only [Finset.disjoint_singleton_right] + exact fun hi => h (direction_mem_dictionary hi) + +omit [Fintype ι] [Fintype κ] [DecidableEq κ] in +lemma anchorRequirements_weight (rate : ι → ℝ≥0) (C : Finset (κ × ι)) + (r : κ) (i : ι) : + weight (fun p : κ × ι => rate p.2) (anchorRequirements C r i) = + if i ∈ dictionary C then 1 else (rate i : ℝ) := by + unfold anchorRequirements weight + split_ifs <;> simp +omit [Fintype ι] [Fintype κ] in + +lemma anchor_dictionary_extension (rate : ι → ℝ≥0) (C : Finset (κ × ι)) + (r : κ) (i : ι) : + weight (fun p : κ × ι => rate p.2) (C ∪ anchorRequirements C r i) = + weight (fun p : κ × ι => rate p.2) C * + (if i ∈ dictionary C then 1 else (rate i : ℝ)) := by + rw [weight_union_fresh _ _ _ (anchorRequirements_disjoint C r i), anchorRequirements_weight] +omit [Fintype ι] [Fintype κ] in + +lemma anchor_dictionary_subset (C : Finset (κ × ι)) (r : κ) (i : ι) : + dictionary (C ∪ anchorRequirements C r i) ⊆ insert i (dictionary C) := by + intro d hd + obtain ⟨p, hp, rfl⟩ := Finset.mem_image.mp hd + rcases Finset.mem_union.mp hp with hp | hp + · exact Finset.mem_insert_of_mem (direction_mem_dictionary hp) + · unfold anchorRequirements at hp + split_ifs at hp with h + · simp at hp + · have he := Finset.mem_singleton.mp hp + rw [he] + exact Finset.mem_insert_self _ _ + +omit [Fintype ι] [Fintype κ] [DecidableEq κ] in + +lemma old_reference_has_hit (C : Finset (κ × ι)) (i : ι) (hi : i ∈ dictionary C) + (ω : (κ × ι) → ℕ) (hω : ω ∈ positiveEvent C) : ∃ r, ω (r, i) ≠ 0 := by + obtain ⟨p, hp, hpi⟩ := Finset.mem_image.mp hi + refine ⟨p.1, ?_⟩ + have hh := hω p hp + simpa [← hpi] using hh + +omit [Fintype ι] [DecidableEq κ] in + +theorem anchor_choice_weight_le (rate : ι → ℝ≥0) (C : Finset (κ × ι)) (S : Finset ι) : + (∑ _i ∈ S ∩ dictionary C, (1 : ℝ)) + + (∑ _r : κ, ∑ i ∈ S \ dictionary C, (rate i : ℝ)) ≤ + (dictionary C).card + Fintype.card κ * ∑ i ∈ S, (rate i : ℝ) := by + apply add_le_add + · simp only [Finset.sum_const, nsmul_eq_mul, mul_one] + exact_mod_cast Finset.card_le_card (Finset.inter_subset_right (s₁ := S)) + · simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] + apply mul_le_mul_of_nonneg_left _ (Nat.cast_nonneg _) + exact Finset.sum_le_sum_of_subset_of_nonneg (Finset.sdiff_subset) + (by intro i _ _; exact (rate i).coe_nonneg) + +omit [Fintype ι] [Fintype κ] [DecidableEq κ] in +lemma dictionary_card_le (C : Finset (κ × ι)) : (dictionary C).card ≤ C.card := + Finset.card_image_le + +omit [Fintype ι] [Fintype κ] [DecidableEq κ] in +lemma anchorRequirements_card_le (C : Finset (κ × ι)) (r : κ) (i : ι) : + (anchorRequirements C r i).card ≤ 1 := by + unfold anchorRequirements + split_ifs <;> simp +omit [Fintype ι] [Fintype κ] in + +lemma anchor_extension_card (C : Finset (κ × ι)) (r : κ) (i : ι) : + (C ∪ anchorRequirements C r i).card ≤ C.card + 1 := + (Finset.card_union_le _ _).trans (Nat.add_le_add_left (anchorRequirements_card_le C r i) _) +omit [Fintype ι] [Fintype κ] in + +lemma pair_extension_card (C : Finset (κ × ι)) (T : Finset κ) (S : Finset ι) (f : T → S) : + (C ∪ witnessRequirements T S f).card ≤ C.card + T.card := by + simpa only [witnessRequirements_card] using Finset.card_union_le C (witnessRequirements T S f) + +abbrev AnchorChoice (C : Finset (κ × ι)) (S : Finset ι) := + {i // i ∈ S ∩ dictionary C} ⊕ (κ × {i // i ∈ S \ dictionary C}) + +def AnchorChoice.direction {C : Finset (κ × ι)} {S : Finset ι} : AnchorChoice C S → ι + | .inl d => d.val + | .inr rd => rd.2.val + +def AnchorChoice.requirements {C : Finset (κ × ι)} {S : Finset ι} : + AnchorChoice C S → Finset (κ × ι) + | .inl _ => ∅ + | .inr rd => {(rd.1, rd.2.val)} + +noncomputable def AnchorChoice.cost (rate : ι → ℝ≥0) + {C : Finset (κ × ι)} {S : Finset ι} : AnchorChoice C S → ℝ + | .inl _ => 1 + | .inr rd => rate rd.2.val + +omit [Fintype ι] [Fintype κ] [DecidableEq κ] in +lemma AnchorChoice.cost_nonneg (rate : ι → ℝ≥0) + {C : Finset (κ × ι)} {S : Finset ι} (x : AnchorChoice C S) : 0 ≤ x.cost rate := by + cases x <;> simp [AnchorChoice.cost] + +omit [Fintype ι] [Fintype κ] [DecidableEq κ] in +lemma AnchorChoice.direction_mem {C : Finset (κ × ι)} {S : Finset ι} + (x : AnchorChoice C S) : x.direction ∈ S := by + cases x with + | inl d => exact (Finset.mem_inter.mp d.property).1 + | inr rd => exact (Finset.mem_sdiff.mp rd.2.property).1 +omit [Fintype ι] [Fintype κ] [DecidableEq κ] in + +lemma AnchorChoice.fresh {C : Finset (κ × ι)} {S : Finset ι} + (x : AnchorChoice C S) : Disjoint C x.requirements := by + cases x with + | inl d => exact Finset.disjoint_empty_right _ + | inr rd => + apply Finset.disjoint_singleton_right.mpr + intro he + exact (Finset.mem_sdiff.mp rd.2.property).2 (direction_mem_dictionary he) + +omit [Fintype ι] [Fintype κ] [DecidableEq κ] in +lemma AnchorChoice.weight (rate : ι → ℝ≥0) + {C : Finset (κ × ι)} {S : Finset ι} (x : AnchorChoice C S) : + weight (fun p : κ × ι => rate p.2) x.requirements = x.cost rate := by + cases x <;> simp [AnchorChoice.requirements, StaticCertificates.weight, AnchorChoice.cost] + +omit [Fintype ι] [Fintype κ] [DecidableEq κ] in +lemma AnchorChoice.distinct_events {C : Finset (κ × ι)} {S : Finset ι} + (x y : AnchorChoice C S) (hne : x.direction ≠ y.direction) : + Disjoint x.requirements y.requirements := by + cases x with + | inl d => exact Finset.disjoint_empty_left _ + | inr rd => + cases y with + | inl d => exact Finset.disjoint_empty_right _ + | inr re => + apply Finset.disjoint_singleton_left.mpr + simp only [AnchorChoice.requirements, Finset.mem_singleton] + intro he + exact hne (congrArg Prod.snd he) + +omit [Fintype ι] [Fintype κ] in + +lemma two_anchor_extension_weight (rate : ι → ℝ≥0) + {C : Finset (κ × ι)} {S : Finset ι} (x y : AnchorChoice C S) + (hne : x.direction ≠ y.direction) : + weight (fun p : κ × ι => rate p.2) (C ∪ (x.requirements ∪ y.requirements)) = + weight (fun p : κ × ι => rate p.2) C * (x.cost rate * y.cost rate) := by + rw [weight_union_fresh _ _ _ (Finset.disjoint_union_right.mpr ⟨x.fresh, y.fresh⟩), + weight_union_fresh _ _ _ (x.distinct_events y hne), x.weight rate, y.weight rate] + +omit [Fintype ι] [DecidableEq κ] in +lemma sum_anchor_cost (rate : ι → ℝ≥0) (C : Finset (κ × ι)) (S : Finset ι) : + (∑ x : AnchorChoice C S, x.cost rate) = + (S ∩ dictionary C).card + Fintype.card κ * ∑ i ∈ S \ dictionary C, (rate i : ℝ) := by + rw [Fintype.sum_sum_type] + simp only [AnchorChoice.cost, Finset.sum_const, Finset.card_univ, + Fintype.card_coe, nsmul_eq_mul, mul_one, Fintype.sum_prod_type] + rw [Finset.sum_coe_sort (S \ dictionary C) (fun i => (rate i : ℝ))] + +omit [Fintype ι] [DecidableEq κ] in + +theorem sum_anchor_cost_le (rate : ι → ℝ≥0) (C : Finset (κ × ι)) (S : Finset ι) : + (∑ x : AnchorChoice C S, x.cost rate) ≤ + C.card + Fintype.card κ * ∑ i ∈ S, (rate i : ℝ) := by + rw [sum_anchor_cost] + apply add_le_add + · exact_mod_cast (Finset.card_le_card (Finset.inter_subset_right (s₁ := S))).trans + (dictionary_card_le C) + · apply mul_le_mul_of_nonneg_left _ (Nat.cast_nonneg _) + exact Finset.sum_le_sum_of_subset_of_nonneg Finset.sdiff_subset + (by intro i _ _; exact (rate i).coe_nonneg) + +section AnchorGeometry +variable {H : Type*} [Fintype H] [DecidableEq H] + +omit [DecidableEq H] in +omit [Fintype ι] [DecidableEq κ] in + +theorem one_anchor_geometric_cost (rate : ι → ℝ≥0) (C : Finset (κ × ι)) + (S : Finset ι) (lineSet : H → Finset ι) (N₁ : ℕ) + (hN : ∀ d, (Finset.univ.filter (fun H => d ∈ lineSet H)).card ≤ N₁) : + (∑ x : AnchorChoice C S, x.cost rate * + (Finset.univ.filter (fun H => x.direction ∈ lineSet H)).card) ≤ + (N₁ : ℝ) * (C.card + Fintype.card κ * ∑ i ∈ S, (rate i : ℝ)) := by + calc + _ ≤ ∑ x : AnchorChoice C S, x.cost rate * N₁ := by + apply Finset.sum_le_sum + intro x _ + apply mul_le_mul_of_nonneg_left _ (x.cost_nonneg rate) + exact_mod_cast hN x.direction + _ = (N₁ : ℝ) * ∑ x : AnchorChoice C S, x.cost rate := by + rw [← Finset.sum_mul, mul_comm] + _ ≤ _ := mul_le_mul_of_nonneg_left (sum_anchor_cost_le rate C S) (Nat.cast_nonneg _) + +omit [DecidableEq H] in +omit [Fintype ι] [DecidableEq κ] in + +theorem two_anchor_geometric_cost (rate : ι → ℝ≥0) (C : Finset (κ × ι)) + (S : Finset ι) (lineSet : H → Finset ι) (N₂ : ℕ) + (hN : ∀ d e, d ≠ e → + (Finset.univ.filter (fun H => d ∈ lineSet H ∧ e ∈ lineSet H)).card ≤ N₂) : + (∑ x : AnchorChoice C S, ∑ y : AnchorChoice C S, + if x.direction ≠ y.direction then x.cost rate * y.cost rate * + (Finset.univ.filter (fun H => x.direction ∈ lineSet H ∧ y.direction ∈ lineSet H)).card + else 0) ≤ + (N₂ : ℝ) * (C.card + Fintype.card κ * ∑ i ∈ S, (rate i : ℝ)) ^ 2 := by + classical + let A : ℝ := ∑ x : AnchorChoice C S, x.cost rate + have hA : 0 ≤ A := Finset.sum_nonneg (fun x _ => x.cost_nonneg rate) + calc + _ ≤ ∑ x : AnchorChoice C S, ∑ y : AnchorChoice C S, + x.cost rate * y.cost rate * N₂ := by + apply Finset.sum_le_sum + intro x _ + apply Finset.sum_le_sum + intro y _ + split_ifs with hxy + · apply mul_le_mul_of_nonneg_left _ (mul_nonneg (x.cost_nonneg rate) (y.cost_nonneg rate)) + exact_mod_cast hN x.direction y.direction hxy + · exact mul_nonneg (mul_nonneg (x.cost_nonneg rate) (y.cost_nonneg rate)) (Nat.cast_nonneg _) + _ = (N₂ : ℝ) * A ^ 2 := by + simp only [Finset.sum_mul, Finset.mul_sum, A, pow_two] + apply Finset.sum_congr rfl + intro x _ + apply Finset.sum_congr rfl + intro y _ + ring + _ ≤ _ := by + apply mul_le_mul_of_nonneg_left _ (Nat.cast_nonneg _) + exact pow_le_pow_left₀ hA (sum_anchor_cost_le rate C S) 2 + +end AnchorGeometry +end PairWitnesses +end SharpRamseyFive.StaticCertificates +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Entropy/ProtocolEntropy.lean b/lean/OAI/Combinatorics/SharpRamsey/Entropy/ProtocolEntropy.lean new file mode 100644 index 0000000000000000000000000000000000000000..59e6e160e7ebb6cbd08cb9e2d4baac4d4edd84af --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Entropy/ProtocolEntropy.lean @@ -0,0 +1,90 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.MarkingDeficit + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset Real +open scoped Classical +noncomputable section +variable {Ω α Γ : Type*} [Fintype Ω] [Fintype α] [Fintype Γ] + +theorem entropy_append_alphabet (p : Law Ω) (C : Ω→Γ) (F : Ω→α) + (D : Γ→Finset α) (hD : ∀ x,p.mass x≠0→F x∈D (C x)) : + entropy (p.map (fun x=>(F x,C x))) ≤ entropy (p.map C)+ + ∑ x,p.mass x*log (D (C x)).card := by + rw [entropy_cond_chain,←p.sum_map C (fun c=>log (D c).card)] + apply add_le_add le_rfl + apply sum_le_sum + intro c _ + by_cases hc : (p.map C).mass c=0 + · simp [hc] + · apply mul_le_mul_of_nonneg_left _ ((p.map C).nonneg c) + apply entropy_mapped_support + intro x hx + obtain ⟨hp,he⟩ := p.cond_support C c hc x hx + simpa only [←he] using hD x hp + +def ProtocolValid (D : ∀ n:ℕ,(Fin n→α)→Finset α) : + ∀ n:ℕ,(Fin n→α)→Prop + | 0,_ => True + | n+1,x => ProtocolValid D n (Fin.init x) ∧ x (Fin.last n)∈D n (Fin.init x) + +noncomputable def protocolCost (D : ∀ n:ℕ,(Fin n→α)→Finset α) : + ∀ n:ℕ,(Fin n→α)→ℝ + | 0,_ => 0 + | n+1,x => protocolCost D n (Fin.init x)+log (D n (Fin.init x)).card + +omit [Fintype Γ] in + +theorem protocol_entropy (p : Law Ω) (D : ∀ n:ℕ,(Fin n→α)→Finset α) + (n : ℕ) (F : Ω→Fin n→α) (hF : ∀ x,p.mass x≠0→ProtocolValid D n (F x)) : + entropy (p.map F)≤∑ x,p.mass x*protocolCost D n (F x) := by + induction n with + | zero => + have h := entropy_le_log_card (p.map F) univ (fun x hx=>False.elim (hx (mem_univ x))) + simpa only [card_univ,Fintype.card_fun,Fintype.card_fin,pow_zero, + Nat.cast_one,log_one,protocolCost,mul_zero,sum_const_zero] using h + | succ n ih => + let C := fun x=>Fin.init (F x) + let a := fun x=>F x (Fin.last n) + have hi := ih C (fun x hx=>(hF x hx).1) + have ha := entropy_append_alphabet p C a (D n) (fun x hx=>(hF x hx).2) + have he : entropy (p.map (fun x=>(a x,C x)))=entropy (p.map F) := by + have h := entropy_map_eq_of_leftInverse (p.map F) + (fun y:Fin (n+1)→α=>(y (Fin.last n),Fin.init y)) + (fun z:α×(Fin n→α)=>Fin.snoc z.2 z.1) (fun y=>Fin.snoc_init_self y) + rw [Law.map_map] at h + exact h + rw [he] at ha + have hs : (∑ x,p.mass x*protocolCost D n (C x))+ + (∑ x,p.mass x*log (D n (C x)).card)= + ∑ x,p.mass x*protocolCost D (n+1) (F x) := by + simp only [protocolCost,mul_add,sum_add_distrib,C] + rw [←hs] + linarith + +omit [Fintype Γ] in + +theorem protocol_entropy_maximum (p : Law Ω) + (D : ∀ n:ℕ,(Fin n→α)→Finset α) (n : ℕ) (F : Ω→Fin n→α) (K : ℝ) + (hF : ∀ x,p.mass x≠0→ProtocolValid D n (F x)) + (hK : ∀ x,p.mass x≠0→protocolCost D n (F x)≤K) : + entropy (p.map F)≤K := by + apply (protocol_entropy p D n F hF).trans + calc + _ ≤ ∑ x,p.mass x*K := by + apply sum_le_sum + intro x _ + by_cases hx : p.mass x=0 + · simp [hx] + · exact mul_le_mul_of_nonneg_left (hK x hx) (p.nonneg x) + _ = K := by rw [←sum_mul,p.total,one_mul] + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Entropy/ReciprocalEntropy.lean b/lean/OAI/Combinatorics/SharpRamsey/Entropy/ReciprocalEntropy.lean new file mode 100644 index 0000000000000000000000000000000000000000..5a4ca9b8990c35435b288143b164e6a1748dcc32 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Entropy/ReciprocalEntropy.lean @@ -0,0 +1,114 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Trees.PivotAlphabetCost +import OAI.Combinatorics.SharpRamsey.Trees.ChronologicalExecution +import OAI.Combinatorics.SharpRamsey.Execution.ExecutedOverhead + +namespace OAI + +section +namespace SharpLogRamsey.ActualPivot +open Finset Real Incidence Validation ScheduledBanks PublicTables ReadyTests + PivotGeometry ProjectiveDuality TreeDecoder FreshExecution ExecutedPotential +open scoped Classical BigOperators +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] + {I Ω : Type*} [Fintype I] [Fintype Ω] + {n : ℕ} {b τ P H : ℝ} + +def Book.publicAlphabet (book : Book (K:=K) (V:=V) (Nat.card K) b τ P H (n+3)) + (z : I→Banks (K:=K) (V:=V) b) (U : ChronoDomains (K:=K) (V:=V)) : + Finset (I×Code (K:=K) (V:=V) b) := + univ.biUnion (fun i=>(book.allowed (z i).1 U.swap).image (fun c=>(i,c))) + +variable (book : Book (K:=K) (V:=V) (Nat.card K) b τ P H (n+3)) + +omit [Finite K] in +lemma Book.mem_publicAlphabet (z : I→Banks (K:=K) (V:=V) b) + (U : ChronoDomains (K:=K) (V:=V)) (i : I) (c : Code (K:=K) (V:=V) b) + (hc : c∈book.allowed (z i).1 U.swap) : (i,c)∈book.publicAlphabet z U := by + exact mem_biUnion.mpr ⟨i,mem_univ _,mem_image.mpr ⟨c,hc,rfl⟩⟩ + +omit [Finite K] in +lemma Book.publicAlphabet_card (z : I→Banks (K:=K) (V:=V) b) + (U : ChronoDomains (K:=K) (V:=V)) : + (book.publicAlphabet z U).card≤∑ i,(book.allowed (z i).1 U.swap).card := by + apply (card_biUnion_le).trans + exact sum_le_sum (fun i _=>card_image_le) + +variable (hb : 0≤b) (hH : 0≤H) (hP : 4≤P) (haP : b+log 1000000≤P) +include hb hH hP haP + +lemma Book.publicAlphabet_log (z : I→Banks (K:=K) (V:=V) b) + (U : ChronoDomains (K:=K) (V:=V)) : + log ((book.publicAlphabet z U).card:ℝ)≤ + log ((Fintype.card I:ℝ)+1)+headerCost (K:=K) (V:=V)+ + (2*(H+22)*(Nat.card K:ℝ)*P)*(potential ((Nat.card K:ℝ)^(n+3)) U+P) := by + let L := headerCost (K:=K) (V:=V)+ + (2*(H+22)*(Nat.card K:ℝ)*P)*(potential ((Nat.card K:ℝ)^(n+3)) U+P) + have hL : 0≤L := add_nonneg headerCost_nonneg + (mul_nonneg (by positivity) (add_nonneg (potential_nonneg _ _) (by linarith))) + have hs : potential ((Nat.card K:ℝ)^(n+3)) U.swap=potential ((Nat.card K:ℝ)^(n+3)) U := by + dsimp only [potential,Prod.swap]; rw [mul_comm] + have hc : ((book.publicAlphabet z U).card:ℝ)≤((Fintype.card I:ℝ)+1)*exp L := by + calc + _ ≤ ∑ i,((book.allowed (z i).1 U.swap).card:ℝ) := by exact_mod_cast book.publicAlphabet_card z U + _ ≤ ∑ _i : I,exp L := by + apply sum_le_sum + intro i _ + simpa only [hs] using book.allowed_card_exp hb hH hP haP (z i).1 U.swap + _ = (Fintype.card I:ℝ)*exp L := by simp only [sum_const,card_univ,nsmul_eq_mul] + _ ≤ _ := mul_le_mul_of_nonneg_right (by linarith) (exp_pos L).le + by_cases hz : (book.publicAlphabet z U).card=0 + · rw [hz,Nat.cast_zero,log_zero,add_assoc] + exact add_nonneg (log_nonneg (by have := Nat.cast_nonneg (α:=ℝ) (Fintype.card I); linarith)) hL + · apply (log_le_iff_le_exp (by exact_mod_cast Nat.pos_of_ne_zero hz)).mpr + rw [add_assoc,exp_add,exp_log (by positivity)] + exact hc + +local instance publicCodeDecidableEq : DecidableEq (I×Code (K:=K) (V:=V) b) := Classical.decEq _ + +variable (hdim : Module.finrank K V=n+3) (hτ : 0≤τ) (hτsmall : τ≤1/40000) + +theorem Book.actual_full_entropy (p : Selection.Law Ω) + (s : Ω→I→Original (K:=K) (V:=V) n b) (z : I→Banks (K:=K) (V:=V) b) + (t : Ω→BinaryTree I) (U : ChronoDomains (K:=K) (V:=V)) + (N ht m : ℕ) (targets : Ω→I→List (Projectivization K (Module.Dual K V)×Projectivization K V)) + (counts : Ω→I→ℕ) (hcounts : ∀ ω i,counts ω i ≤ m) + (hN : ∀ ω,(t ω).numNodes≤N) (hht : ∀ ω,(t ω).height≤ht) : + let rd := fixedRead (fun _i : I=>chronoRead (K:=K) (V:=V) b) z + let ch := fun ω=>fixedChoose (fun i=>book.chronoChoose hdim hτ hτsmall (s ω i)) z + let M := fun ω=>codeTree (countReader rd) + (countChoose (fun y x=>SharpLogRamsey.Incidence.Incident x y) rd (ch ω) (targets ω) (counts ω)) (t ω) U + let S := univ.image M + let msg : Ω→S := fun ω=>⟨M ω,mem_image.mpr ⟨ω,mem_univ _,rfl⟩⟩ + Selection.entropy (p.map msg)≤((2*N+1:ℕ):ℝ)*log 2+ + (N:ℝ)*(log ((Fintype.card I:ℝ)+1)+headerCost (K:=K) (V:=V)+log (m+1:ℕ))+ + (2*(H+22)*(Nat.card K:ℝ)*P)* + ((ht:ℝ)*(potential ((Nat.card K:ℝ)^(n+3)) U+(N:ℝ)*(b+log 4+2*log 2000))+(N:ℝ)*P) := by + apply full_execution_entropy_overhead p ((Nat.card K:ℝ)^(n+3)) 2000 b + (2*(H+22)*(Nat.card K:ℝ)*P) P (log ((Fintype.card I:ℝ)+1)+headerCost (K:=K) (V:=V)) + (by have : 0 (stream x,F x)) + have hfst : P.fst = p.map stream := by + rw [←Law.map_fst] + dsimp only [P] + rw [Law.map_map] + rfl + have hsnd : P.snd = p.map F := by + rw [←Law.map_snd] + dsimp only [P] + rw [Law.map_map] + rfl + have hh := selected_entropy_source_scales hd hℓ hN P reverse hC hq hσ hc + (by simpa only [hfst] using hdom) (by + intro g f hgf + obtain ⟨x,hx,he⟩ := p.map_support (fun x => (stream x,F x)) (g,f) hgf + have hh := hselect x hx + have he1 : stream x = g := congrArg Prod.fst he + have he2 : F x = f := congrArg Prod.snd he + simpa only [he1,he2] using hh) hsize hlength halphabet + rwa [hsnd] at hh + +theorem selected_map_linear_deficit {N ℓ d : ℕ} (hd : 1 ≤ d) (hℓ : 0 < ℓ) (hN : ℓ ≤ N) + (p : Law Ω) (stream : Ω → Fin N → α) (F : Ω → Fin ℓ → α) + (reverse : (Fin ℓ → α) → (Fin ℓ → α)) + {C q σ η c : ℝ} (hC : 0 < C) (hq : 0 < q) (hσ : 1 ≤ σ) (hη : 0 ≤ η) (hc : 0 < c) + (hdom : ∀ g, (p.map stream).mass g ≤ C/(Fintype.card α:ℝ)^N) + (hselect : ∀ x, p.mass x ≠ 0 → Occurs (F x) (stream x) ∨ Occurs (reverse (F x)) (stream x)) + (hsize : (N:ℝ) ≤ q^d*σ) (hlength : c*q*σ^(1+η) ≤ (ℓ:ℝ)) + (halphabet : q^(2*d-1) ≤ (Fintype.card α:ℝ)) : + (ℓ:ℝ)*((d:ℝ)*log q)-(1+|log c|+|log (2*C)|)*ℓ ≤ entropy (p.map F) := by + have hh := selected_map_entropy hd hℓ hN p stream F reverse hC hq (by linarith) hc + hdom hselect hsize hlength halphabet + have hpos : (1:ℝ) ≤ ℓ := by exact_mod_cast hℓ + have hl : 0 ≤ log σ := log_nonneg hσ + have hgain : 0 ≤ (ℓ:ℝ)*(η*log σ) := mul_nonneg (Nat.cast_nonneg _) (mul_nonneg hη hl) + have hc' : -|log c| ≤ log c := neg_abs_le _ + have hm : log (2*C) ≤ |log (2*C)| := le_abs_self _ + have hm' : |log (2*C)| ≤ (ℓ:ℝ)*|log (2*C)| := le_mul_of_one_le_left (abs_nonneg _) hpos + have hc'' := mul_le_mul_of_nonneg_left hc' (Nat.cast_nonneg ℓ) + nlinarith only [hh,hgain,hm,hm',hc''] +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Entropy/ShiftKernelSum.lean b/lean/OAI/Combinatorics/SharpRamsey/Entropy/ShiftKernelSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..d8d527494ea548fbbc924402ac6d139d7cf5021d --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Entropy/ShiftKernelSum.lean @@ -0,0 +1,464 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Entropy.LabelledFilterCard + +namespace OAI + +/-! High moments, finite-field subspaces, and incidence bounds. -/ + +section +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open scoped BigOperators +open MeasureTheory ProbabilityTheory +open scoped BigOperators ENNReal NNReal +namespace SharpRamseyFive.SingletonEnumeration +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponents +open SharpRamseyFive.Designations SharpRamseyFive.AmbientDesignations +open SharpRamseyFive.SelectionBridge SharpRamseyFive.WeightedPrograms +open SharpRamseyFive.ResidualElimination +open Classical +variable {D V H : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V] + [Fintype H] [DecidableEq H] +omit [Fintype D] [Fintype H] [DecidableEq H] in +lemma shift_le_kernel_sum (weight : D → ℝ≥0) (lines : H → Finset D) + {p K : ℕ} (hp : 0 < p) (hc : Fintype.card V ≤ p) (hK : K ≠ 0) + (u : V) (f : V → H) : + alpha weight (lines ∘ f) (1 / (100 * p)) u ^ K ≤ + ∑ v ∈ Finset.univ.erase u, shiftKernel weight lines p K (f u) (f v) := by + let s := lines ∘ f + let T := otherComponents weight s (1 / (100 * p)) u + have hsub : T ⊆ Finset.univ.erase u := by + intro v hv + simp only [T, otherComponents, Finset.mem_filter, Finset.mem_univ, true_and] at hv + exact Finset.mem_erase.mpr ⟨by intro he; subst v; exact hv rfl, Finset.mem_univ _⟩ + have hmass := external_mass_le_sum weight s (1 / (100 * p)) u + have hα := source_alpha_le weight s hp hc u + have hα0 := alpha_nonneg weight s (1 / (100 * p)) u + have hone : alpha weight s (1 / (100 * p)) u ^ K ≤ 1 := + pow_le_one₀ hα0 (by linarith) + by_cases hT : T.Nonempty + · obtain ⟨v,hv,hmax⟩ := Finset.exists_max_image T + (fun v => mass weight (s u ∩ s v)) hT + have hcard : (T.card : ℝ) ≤ p := by + exact_mod_cast (Finset.card_le_card (Finset.subset_univ T)).trans + (by simpa only [Finset.card_univ] using hc) + have hle : alpha weight s (1 / (100 * p)) u ≤ p * mass weight (s u ∩ s v) := calc + _ ≤ ∑ w ∈ T, mass weight (s u ∩ s w) := hmass + _ ≤ T.card * mass weight (s u ∩ s v) := by + simpa only [nsmul_eq_mul] using Finset.sum_le_card_nsmul T + (fun w => mass weight (s u ∩ s w)) (mass weight (s u ∩ s v)) hmax + _ ≤ _ := mul_le_mul_of_nonneg_right hcard (mass_nonneg _ _) + apply (le_min hone (pow_le_pow_left₀ hα0 hle K)).trans + exact Finset.single_le_sum + (fun w _ => (shiftKernel_range weight lines p K (f u) (f w)).1) (hsub hv) + · have he : T = ∅ := Finset.not_nonempty_iff_eq_empty.mp hT + have hzero : alpha weight s (1 / (100 * p)) u = 0 := by + apply le_antisymm _ hα0 + change mass weight (externalPart weight s (1 / (100 * p)) u) ≤ 0 + simpa only [show otherComponents weight s (1 / (100 * p)) u = ∅ from he, + Finset.sum_empty] using hmass + change alpha weight s (1 / (100 * p)) u ^ K ≤ _ + rw [hzero, zero_pow hK] + exact Finset.sum_nonneg (fun w _ => (shiftKernel_range weight lines p K (f u) (f w)).1) + +end SharpRamseyFive.SingletonEnumeration + +namespace SharpRamseyFive.SingletonEnumeration +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponents +open SharpRamseyFive.Designations SharpRamseyFive.AmbientDesignations +open SharpRamseyFive.SelectionBridge SharpRamseyFive.WeightedPrograms +open SharpRamseyFive.ResidualElimination +open Classical +variable {D V H : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V] + [Fintype H] [DecidableEq H] + +theorem actual_shift_bad_enumeration (weight rate : D → ℝ≥0) (lines : H → Finset D) + {p : ℕ} (hp : 0 < p) (hc : Fintype.card V ≤ p) + (R : ℕ) (denom b mass C : ℝ) + (hd : 0 < denom) (hb : 1 ≤ b) (hm : 0 ≤ mass) (hC : 0 ≤ C) + (hmass : ∀ u, ∑ d ∈ lines u, (rate d : ℝ) ≤ mass) + (K J h N₁ N₂ : ℕ) (hK : 2 ≤ K) (hh : 0 < h) (low : Bool) + (hsize : h ≤ (R / 2 - if low then 0 else J) / (2 * K)) + (herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) + (hN₁ : ∀ d, (Finset.univ.filter (fun u => d ∈ lines u)).card ≤ N₁) + (hN₂ : ∀ d e, d ≠ e → + (Finset.univ.filter (fun u => d ∈ lines u ∧ e ∈ lines u)).card ≤ N₂) + (hBC : denom * (1 + branchingBound (V := V) (B := Fin R) + (fun z : H × V => lines z.1) rate denom b mass K + (N₁ * Fintype.card V) (N₂ * Fintype.card V) low) ≤ C) + (hrow : ∀ y, (∑ x : H, shiftKernel weight lines p K x y) ≤ C) + (hpair : (∑ x : H, ∑ y : H, shiftKernel weight lines p K x y) ≤ C ^ 2) + (E S : Finset V) (hS : S ⊆ E) (g : V → H) : + completionSum E g (fun f => + (∏ u ∈ S, alpha weight (lines ∘ f) (1 / (100 * p)) u ^ K) * + vertexBadMass weight rate (lines ∘ f) (1 / (100 * p)) R J (E \ S)) ≤ + ((Fintype.card V + 1 : ℝ) * C) ^ E.card := by + apply shift_bad_enumeration + (fun u f => alpha weight (lines ∘ f) (1 / (100 * p)) u ^ K) + (fun A f => vertexBadMass weight rate (lines ∘ f) (1 / (100 * p)) R J A) + (shiftKernel weight lines p K) C hC + · intro u f + exact ⟨pow_nonneg (alpha_nonneg _ _ _ _) _, + pow_le_one₀ (alpha_nonneg _ _ _ _) (by + have := source_alpha_le weight (lines ∘ f) hp hc u + linarith)⟩ + · exact fun x y => (shiftKernel_range weight lines p K x y).1 + · exact fun A f => vertexBadMass_nonneg _ _ _ _ _ _ _ + · exact fun A A' hh f => vertexBadMass_antitone _ _ _ _ _ _ hh + · exact fun u f => shift_le_kernel_sum weight lines hp hc (by omega) u f + · exact hrow + · exact hpair + · intro A g + apply (actual_bad_completion weight rate lines (1 / (100 * p)) R denom b mass + hd hb hm hmass K J h N₁ N₂ hK hh low hsize herr hN₁ hN₂ A g).trans + apply pow_le_pow_left₀ _ hBC + apply mul_nonneg hd.le + have hn := branchingBound_nonneg (V := V) (B := Fin R) + (fun z : H × V => lines z.1) rate denom b mass hd.le (by linarith) hm K + (N₁ * Fintype.card V) (N₂ * Fintype.card V) low + linarith + · exact hS + +end SharpRamseyFive.SingletonEnumeration + +namespace SharpRamseyFive.DyadicMoments + +open scoped BigOperators + +lemma dyadic_cover (δ x : ℝ) (hδ : 0 ≤ δ) (hx : δ ≤ x) (N : ℕ) + (hN : x ≤ δ * 2 ^ N) : + ∃ i ∈ Finset.range (N + 1), δ * 2 ^ i ≤ x ∧ x ≤ 2 * (δ * 2 ^ i) := by + induction N with + | zero => + refine ⟨0, by simp, ?_, ?_⟩ + · simpa using hx + · simp only [pow_zero, mul_one] at hN ⊢ + linarith + | succ N ih => + by_cases hh : x ≤ δ * 2 ^ N + · obtain ⟨i, hi, hix, hxi⟩ := ih hh + exact ⟨i, Finset.mem_range.mpr (by have := Finset.mem_range.mp hi; omega), hix, hxi⟩ + · refine ⟨N, Finset.mem_range.mpr (by omega), le_of_lt (lt_of_not_ge hh), ?_⟩ + rw [pow_succ] at hN + nlinarith + +section Finite +variable {α β : Type*} [Fintype α] [DecidableEq α] [DecidableEq β] + +omit [DecidableEq α] [DecidableEq β] in + +theorem moment_le_of_cover (x : α → ℝ) (a : β → ℝ) (T : Finset β) + (K : ℕ) (hK : K ≠ 0) (C : ℝ) (_hC : 0 ≤ C) + (hx : ∀ v, 0 ≤ x v) (ha : ∀ i ∈ T, 0 ≤ a i) + (hcover : ∀ v, 0 < x v → ∃ i ∈ T, a i ≤ x v ∧ x v ≤ 2 * a i) + (hcount : ∀ i ∈ T, + ((Finset.univ.filter (fun v => a i ≤ x v)).card : ℝ) * a i ^ K ≤ C) : + (∑ v, x v ^ K) ≤ (T.card : ℝ) * (2 : ℝ) ^ K * C := by + classical + have hp (v : α) : x v ^ K ≤ + ∑ i ∈ T, if a i ≤ x v then (2 * a i) ^ K else 0 := by + by_cases hv : 0 < x v + · obtain ⟨i, hi, hain, hle⟩ := hcover v hv + apply (pow_le_pow_left₀ (hx v) hle K).trans + have hs := Finset.single_le_sum (f := fun j => + if a j ≤ x v then (2 * a j) ^ K else 0) + (fun j hj => by split_ifs <;> positivity [ha j hj]) hi + simpa [hain] using hs + · have hz : x v = 0 := le_antisymm (le_of_not_gt hv) (hx v) + simp only [hz, zero_pow hK] + apply Finset.sum_nonneg + intro i hi + split_ifs <;> positivity [ha i hi] + calc + (∑ v, x v ^ K) ≤ ∑ v, ∑ i ∈ T, if a i ≤ x v then (2 * a i) ^ K else 0 := + Finset.sum_le_sum (fun v _ => hp v) + _ = ∑ i ∈ T, (2 : ℝ) ^ K * + (((Finset.univ.filter (fun v => a i ≤ x v)).card : ℝ) * a i ^ K) := by + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro i hi + rw [← Finset.sum_filter] + simp only [Finset.sum_const, nsmul_eq_mul, mul_pow] + ring + _ ≤ ∑ _i ∈ T, (2 : ℝ) ^ K * C := by + apply Finset.sum_le_sum + intro i hi + exact mul_le_mul_of_nonneg_left (hcount i hi) (by positivity) + _ = _ := by simp; ring + +omit [DecidableEq α] [DecidableEq β] in + +theorem higher_moment_le_of_cover (x : α → ℝ) (a : β → ℝ) (T : Finset β) + (K J : ℕ) (hK : K ≠ 0) (hKJ : K ≤ J) (C M : ℝ) + (hC : 0 ≤ C) (hM : 0 ≤ M) (hx : ∀ v, 0 ≤ x v) + (hmax : ∀ v, x v ≤ M) (ha : ∀ i ∈ T, 0 ≤ a i) + (hcover : ∀ v, 0 < x v → ∃ i ∈ T, a i ≤ x v ∧ x v ≤ 2 * a i) + (hcount : ∀ i ∈ T, + ((Finset.univ.filter (fun v => a i ≤ x v)).card : ℝ) * a i ^ K ≤ C) : + (∑ v, x v ^ J) ≤ (T.card : ℝ) * (2 : ℝ) ^ K * C * M ^ (J - K) := by + have hp (v : α) : x v ^ J ≤ x v ^ K * M ^ (J - K) := by + calc + x v ^ J = x v ^ K * x v ^ (J - K) := by + rw [← pow_add, Nat.add_sub_of_le hKJ] + _ ≤ _ := mul_le_mul_of_nonneg_left + (pow_le_pow_left₀ (hx v) (hmax v) _) (by positivity [hx v]) + calc + _ ≤ ∑ v, x v ^ K * M ^ (J - K) := Finset.sum_le_sum (fun v _ => hp v) + _ = (∑ v, x v ^ K) * M ^ (J - K) := (Finset.sum_mul ..).symm + _ ≤ _ := mul_le_mul_of_nonneg_right + (moment_le_of_cover x a T K hK C hC hx ha hcover hcount) (by positivity) + +omit [DecidableEq α] in + +theorem integer_strength_moment (m : α → ℕ) (δ : ℝ) (hδ : 0 < δ) + (N K : ℕ) (hK : K ≠ 0) (hm : ∀ v, (m v : ℝ) ≤ 2 ^ N) + (C : ℝ) (hC : 0 ≤ C) + (hcount : ∀ i ∈ Finset.range (N + 1), + ((Finset.univ.filter (fun v => δ * 2 ^ i ≤ δ * m v)).card : ℝ) * + (δ * 2 ^ i) ^ K ≤ C) : + (∑ v, (δ * m v) ^ K) ≤ (N + 1 : ℝ) * 2 ^ K * C := by + apply (moment_le_of_cover (fun v => δ * m v) (fun i => δ * 2 ^ i) + (Finset.range (N + 1)) K hK C hC (by intro v; positivity) + (by intro i hi; positivity) ?_ hcount).trans_eq + · simp + · intro v hv + have hm0 : 0 < m v := by + by_contra hn + have hz : m v = 0 := by omega + simp [hz] at hv + apply dyadic_cover δ (δ * m v) hδ.le + · exact le_mul_of_one_le_right hδ.le (by exact_mod_cast hm0) + · exact mul_le_mul_of_nonneg_left (hm v) hδ.le + +end Finite +end SharpRamseyFive.DyadicMoments + +namespace SharpRamseyFive.WeightedPrograms + +open scoped BigOperators +open SharpRamseyFive.DyadicMoments + +variable {V H D B I : Type*} [Fintype V] [DecidableEq V] + [Fintype H] [DecidableEq H] [Fintype D] [DecidableEq D] + [Fintype B] [DecidableEq B] [DecidableEq I] + +variable (lines : H → Finset D) + +def DistinctPairs (H : Type*) := Σ h : H, {h' : H // h' ≠ h} + +instance flat_HighMomentRecovered_7 : Fintype (DistinctPairs H) := by unfold DistinctPairs; infer_instance + +noncomputable def strength (a : D → ℝ≥0) (p : DistinctPairs H) : ℝ := + ∑ d ∈ lines p.1 ∩ lines p.2.val, (a d : ℝ) + +omit [Fintype H] [DecidableEq H] [Fintype D] in +lemma strength_nonneg (a : D → ℝ≥0) (p : DistinctPairs H) : + 0 ≤ strength lines a p := by unfold strength; positivity + +omit [DecidableEq B] in +omit [Fintype D] [DecidableEq I] in + +theorem pairMoment_dyadic (a : D → ℝ≥0) (L : ℝ≥0) (K : ℕ) (hK : K ≠ 0) + (T : Finset I) (threshold : I → ℝ) (ht : ∀ i ∈ T, 0 ≤ threshold i) + (hcover : ∀ p, 0 < strength lines a p → + ∃ i ∈ T, threshold i ≤ strength lines a p ∧ strength lines a p ≤ 2 * threshold i) + (C : ℝ) (hC : 0 ≤ C) + (hcount : ∀ i ∈ T, + ((Finset.univ.filter (fun p : DistinctPairs H => threshold i ≤ strength lines a p)).card : ℝ) * + threshold i ^ K ≤ C) : + pairMoment (B := B) lines (fun d => L * a d) K ≤ + (T.card : ℝ) * C * (2 * Fintype.card B * (L : ℝ)) ^ K := by + classical + have h := moment_le_of_cover (strength lines a) threshold T K hK C hC + (strength_nonneg lines a) ht hcover hcount + have he : pairMoment (B := B) lines (fun d => L * a d) K = + ((Fintype.card B : ℝ) * (L : ℝ)) ^ K * + ∑ p : DistinctPairs H, strength lines a p ^ K := by + unfold pairMoment + change _ = _ * ∑ p : (Σ h : H, {h' : H // h' ≠ h}), _ + rw [Fintype.sum_sigma, Finset.mul_sum] + apply Finset.sum_congr rfl + intro h _ + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro h' _ + simp only [NNReal.coe_mul, ← Finset.mul_sum, strength] + rw [← mul_assoc, mul_pow] + rw [he] + apply (mul_le_mul_of_nonneg_left h (by positivity)).trans_eq + rw [mul_pow, mul_pow] + ring + +omit [DecidableEq V] in +omit [DecidableEq B] in +omit [Fintype D] [DecidableEq I] in + +theorem branchingBound_dyadic (a : D → ℝ≥0) (L : ℝ≥0) + (denom b mass : ℝ) (_hd : 0 ≤ denom) (K N₁ N₂ : ℕ) (low : Bool) + (hK : K ≠ 0) (T : Finset I) (threshold : I → ℝ) + (ht : ∀ i ∈ T, 0 ≤ threshold i) + (hcover : ∀ p, 0 < strength lines a p → + ∃ i ∈ T, threshold i ≤ strength lines a p ∧ strength lines a p ≤ 2 * threshold i) + (C : ℝ) (hC : 0 ≤ C) + (hcount : ∀ i ∈ T, + ((Finset.univ.filter (fun p : DistinctPairs H => threshold i ≤ strength lines a p)).card : ℝ) * + threshold i ^ K ≤ C) : + branchingBound (V := V) (B := B) lines (fun d => L * a d) denom b mass K N₁ N₂ low ≤ + ((Fintype.card V : ℝ) * Fintype.card H / denom) / b ^ 8 + + (if low then Fintype.card V ^ 2 * (N₁ : ℝ) * + uniformAnchorBudget (V := V) (B := B) K mass / denom else 0) + + (Fintype.card V ^ 3 * (N₂ : ℝ) * + uniformAnchorBudget (V := V) (B := B) K mass ^ 2 / denom) * b + + Fintype.card V ^ 2 * ((T.card : ℝ) * C * (2 * Fintype.card B * (L : ℝ)) ^ K) / denom ^ 2 := by + unfold branchingBound + apply add_le_add le_rfl + exact div_le_div_of_nonneg_right + (mul_le_mul_of_nonneg_left (pairMoment_dyadic (B := B) lines a L K hK T threshold + ht hcover C hC hcount) (by positivity)) (by positivity) + +end SharpRamseyFive.WeightedPrograms + +namespace SharpRamseyFive.SingletonEnumeration +open scoped BigOperators NNReal +open SharpRamseyFive.PoissonScore SharpRamseyFive.DyadicMoments +open SharpRamseyFive.WeightedPrograms +open Classical +variable {D H V I B : Type} [Fintype D] [DecidableEq D] + [Fintype H] [DecidableEq H] [Fintype V] [DecidableEq V] + [Fintype B] [DecidableEq B] [DecidableEq I] + +lemma sum_split_diagonal (F : H → ℝ) (y : H) : + (∑ x : H, F x) = F y + ∑ x : {x : H // x ≠ y}, F x := by + rw [← Finset.sum_erase_add _ F (Finset.mem_univ y), add_comm] + congr 1 + exact Finset.sum_subtype _ (by intro x; simp) F + +lemma sum_pairs_split_diagonal (F : H → H → ℝ) : + (∑ x : H, ∑ y : H, F x y) = + (∑ x : H, F x x) + ∑ z : DistinctPairs H, F z.1 z.2 := by + change _ = _ + ∑ z : (Σ x : H, {y : H // y ≠ x}), F z.1 z.2 + rw [Fintype.sum_sigma, ← Finset.sum_add_distrib] + exact Finset.sum_congr rfl (fun x _ => sum_split_diagonal (F x) x) + +omit [DecidableEq I] in +omit [Fintype D] in + +theorem shift_row_dyadic (weight : D → ℝ≥0) (lines : H → Finset D) + (p K : ℕ) (hK : K ≠ 0) (y : H) + (T : Finset I) (a : I → ℝ) (C : ℝ) (hC : 0 ≤ C) + (ha : ∀ i ∈ T, 0 ≤ a i) + (hcover : ∀ x : {x : H // x ≠ y}, 0 < mass weight (lines x ∩ lines y) → + ∃ i ∈ T, a i ≤ mass weight (lines x ∩ lines y) ∧ + mass weight (lines x ∩ lines y) ≤ 2 * a i) + (hcount : ∀ i ∈ T, + ((Finset.univ.filter (fun x : {x : H // x ≠ y} => + a i ≤ mass weight (lines x ∩ lines y))).card : ℝ) * a i ^ K ≤ C) : + (∑ x : H, shiftKernel weight lines p K x y) ≤ + 1 + (T.card : ℝ) * C * (2 * p) ^ K := by + rw [sum_split_diagonal _ y] + apply add_le_add (shiftKernel_range weight lines p K y y).2 + calc + (∑ x : {x : H // x ≠ y}, shiftKernel weight lines p K x y) ≤ + ∑ x : {x : H // x ≠ y}, ((p : ℝ) * mass weight (lines x ∩ lines y)) ^ K := by + exact Finset.sum_le_sum (fun x _ => min_le_right _ _) + _ = (p : ℝ) ^ K * ∑ x : {x : H // x ≠ y}, mass weight (lines x ∩ lines y) ^ K := by + simp only [mul_pow, Finset.mul_sum] + _ ≤ (p : ℝ) ^ K * ((T.card : ℝ) * 2 ^ K * C) := by + apply mul_le_mul_of_nonneg_left _ (by positivity) + exact moment_le_of_cover _ a T K hK C hC + (fun x => mass_nonneg _ _) ha hcover hcount + _ = _ := by rw [mul_pow]; ring + +omit [DecidableEq I] in +omit [Fintype D] in + +theorem shift_pairs_dyadic (weight : D → ℝ≥0) (lines : H → Finset D) + (p K : ℕ) (hK : K ≠ 0) (T : Finset I) (a : I → ℝ) (C : ℝ) (hC : 0 ≤ C) + (ha : ∀ i ∈ T, 0 ≤ a i) + (hcover : ∀ z : DistinctPairs H, 0 < strength lines weight z → + ∃ i ∈ T, a i ≤ strength lines weight z ∧ strength lines weight z ≤ 2 * a i) + (hcount : ∀ i ∈ T, + ((Finset.univ.filter (fun z : DistinctPairs H => a i ≤ strength lines weight z)).card : ℝ) + * a i ^ K ≤ C) : + (∑ x : H, ∑ y : H, shiftKernel weight lines p K x y) ≤ + Fintype.card H + (T.card : ℝ) * C * (2 * p) ^ K := by + rw [sum_pairs_split_diagonal] + apply add_le_add + · exact (Finset.sum_le_sum (fun x _ => (shiftKernel_range weight lines p K x x).2)).trans_eq + (by simp) + · calc + (∑ z : DistinctPairs H, shiftKernel weight lines p K z.1 z.2) ≤ + ∑ z : DistinctPairs H, ((p : ℝ) * strength lines weight z) ^ K := + Finset.sum_le_sum (fun z _ => min_le_right _ _) + _ = (p : ℝ) ^ K * ∑ z : DistinctPairs H, strength lines weight z ^ K := by + simp only [mul_pow, Finset.mul_sum] + _ ≤ (p : ℝ) ^ K * ((T.card : ℝ) * 2 ^ K * C) := by + apply mul_le_mul_of_nonneg_left _ (by positivity) + exact moment_le_of_cover _ a T K hK C hC + (strength_nonneg lines weight) ha hcover hcount + _ = _ := by rw [mul_pow]; ring + +omit [Fintype D] [DecidableEq B] in + +theorem pairMoment_labelled_le (lines : H → Finset D) (rate : D → ℝ≥0) + (K : ℕ) (mass : ℝ) (_hm : 0 ≤ mass) + (hmass : ∀ x, ∑ d ∈ lines x, (rate d : ℝ) ≤ mass) : + pairMoment (B := B) (fun x : H × V => lines x.1) rate K ≤ + (Fintype.card V : ℝ) ^ 2 * + (pairMoment (B := B) lines rate K + + Fintype.card H * ((Fintype.card B : ℝ) * mass) ^ K) := by + let F : H → H → ℝ := fun x y => + ((Fintype.card B : ℝ) * ∑ d ∈ lines x ∩ lines y, (rate d : ℝ)) ^ K + have hF : ∀ x y, 0 ≤ F x y := by intro x y; dsimp [F]; positivity + have he : pairMoment (B := B) lines rate K = ∑ x : H, ∑ y : {y : H // y ≠ x}, F x y := rfl + have hdiag : (∑ x : H, F x x) ≤ + Fintype.card H * ((Fintype.card B : ℝ) * mass) ^ K := by + apply (Finset.sum_le_sum (fun x _ => show F x x ≤ + ((Fintype.card B : ℝ) * mass) ^ K from ?_)).trans_eq (by simp) + dsimp [F] + simp only [Finset.inter_self] + exact pow_le_pow_left₀ (by positivity) + (mul_le_mul_of_nonneg_left (hmass x) (Nat.cast_nonneg _)) K + have hfull : (∑ x : H, ∑ y : H, F x y) ≤ + pairMoment (B := B) lines rate K + Fintype.card H * ((Fintype.card B : ℝ) * mass) ^ K := by + rw [sum_pairs_split_diagonal, add_comm] + change (∑ z : (Σ x : H, {y : H // y ≠ x}), F z.1 z.2) + _ ≤ _ + rw [Fintype.sum_sigma, ← he] + exact add_le_add le_rfl hdiag + calc + _ ≤ ∑ x : H × V, ∑ y : H × V, F x.1 y.1 := by + unfold pairMoment + apply Finset.sum_le_sum + intro x _ + rw [sum_split_diagonal _ x] + apply le_add_of_nonneg_left (hF _ _) + _ = (Fintype.card V : ℝ) ^ 2 * (∑ x : H, ∑ y : H, F x y) := by + simp only [Fintype.sum_prod_type] + simp only [Finset.sum_const, nsmul_eq_mul, Finset.card_univ, ← Finset.mul_sum] + ring + _ ≤ _ := mul_le_mul_of_nonneg_left hfull (by positivity) + +end SharpRamseyFive.SingletonEnumeration + +namespace SharpRamseyFive.ResidualElimination +open scoped BigOperators +open Classical +variable {V H : Type} [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] + +noncomputable def patch (g : V → H) (T : Finset V) (x : T → H) : V → H := + fun u => if hu : u ∈ T then x ⟨u,hu⟩ else g u + +omit [Fintype V] [Fintype H] [DecidableEq H] in +lemma patch_mem (g : V → H) (T : Finset V) (x : T → H) (u : T) : + patch g T x u = x u := by simp [patch] + +end SharpRamseyFive.ResidualElimination +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Entropy/SinglesUnique.lean b/lean/OAI/Combinatorics/SharpRamsey/Entropy/SinglesUnique.lean new file mode 100644 index 0000000000000000000000000000000000000000..5f48dd35bf97070c629659a8c7f5abca9a5a33a8 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Entropy/SinglesUnique.lean @@ -0,0 +1,482 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Entropy.PatchNotMem + +namespace OAI + +/-! High moments, finite-field subspaces, and incidence bounds. -/ + +section +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open scoped BigOperators +open MeasureTheory ProbabilityTheory +open scoped BigOperators ENNReal NNReal +namespace SharpRamseyFive.ComponentPartition +open scoped BigOperators +open Classical +variable {V C : Type} [Fintype V] [DecidableEq V] [Fintype C] [DecidableEq C] +omit [DecidableEq V] [Fintype C] in +lemma singles_iff_unique (r : V → C) (v : V) : + v ∈ singles r ↔ ∀ w, r w = r v → w = v := by + rw [mem_singles] + constructor + · intro hc + obtain ⟨w,hw⟩ := Finset.card_eq_one.mp hc + have hvw : v = w := by simpa only [hw, Finset.mem_singleton] using self_mem_fiber r v + intro u hu + have huw : u = w := by simpa only [hw, Finset.mem_singleton] using (mem_fiber r (r v) u).mpr hu + exact huw.trans hvw.symm + · intro hu + have he : fiber r (r v) = {v} := by + ext w + simp only [mem_fiber, Finset.mem_singleton] + exact ⟨hu w, fun h => h ▸ rfl⟩ + rw [he,Finset.card_singleton] + +lemma large_card_sum (r : V → C) : + ∑ c ∈ largeLabels r, (fiber r c).card = Fintype.card V - (singles r).card := by + rw [← Finset.card_biUnion (fun c _ d _ hne => fiber_disjoint r hne), large_union, + Finset.card_sdiff_of_subset (Finset.subset_univ _), Finset.card_univ] + +variable (G : SimpleGraph V) +noncomputable def componentMap : V → V := fun v => (G.connectedComponentMk v).out + +omit [Fintype V] [DecidableEq V] in +lemma componentMap_eq_iff (v w : V) : componentMap G v = componentMap G w ↔ + G.connectedComponentMk v = G.connectedComponentMk w := by + constructor + · intro h + have hh := congrArg G.connectedComponentMk h + have he (c : G.ConnectedComponent) : G.connectedComponentMk c.out = c := c.out_eq + simpa only [componentMap, he] using hh + · intro h + exact congrArg (fun c : G.ConnectedComponent => c.out) h + +omit [Fintype V] [DecidableEq V] in +lemma componentMap_idempotent (v : V) : componentMap G (componentMap G v) = componentMap G v := by + have he (c : G.ConnectedComponent) : G.connectedComponentMk c.out = c := c.out_eq + simp only [componentMap, he] + +end SharpRamseyFive.ComponentPartition +namespace SharpRamseyFive.ComponentEnumeration +open Classical +open scoped BigOperators +open CertificateEnumeration +variable {V H : Type} [Fintype V] [DecidableEq V] [Fintype H] + +omit [Fintype V] in +lemma boundary_of_walk (G : SimpleGraph V) (E : Finset V) {u v : V} + (p : G.Walk u v) (hu : u ∈ E) (hv : v ∉ E) : + ∃ a ∈ E, ∃ b ∉ E, G.Adj a b := by + induction p with + | nil => exact False.elim (hv hu) + | @cons a b c hab p ih => + by_cases hb : b ∈ E + · exact ih hb hv + · exact ⟨a, hu, b, hb, hab⟩ + +lemma connected_boundary (G : SimpleGraph V) (hG : G.Connected) + (E : Finset V) (hE : E.Nonempty) (hne : E ≠ Finset.univ) : + ∃ a ∈ E, ∃ b ∉ E, G.Adj a b := by + classical + obtain ⟨u, hu⟩ := hE + have : ∃ v, v ∉ E := by + by_contra h + apply hne + ext v + simp only [Finset.mem_univ, iff_true] + exact Classical.not_not.mp (fun hv => h ⟨v, hv⟩) + obtain ⟨v, hv⟩ := this + obtain ⟨p⟩ := hG u v + exact boundary_of_walk G E p hu hv + +variable (R : H → H → Prop) +noncomputable def relationGraph (hsym : Std.Symm R) (f : V → H) : SimpleGraph V where + Adj u v := u ≠ v ∧ R (f u) (f v) + symm := ⟨fun _ _ h => ⟨h.1.symm, hsym.symm _ _ h.2⟩⟩ + loopless := ⟨fun _ h => h.1 rfl⟩ + +abbrev Extension (s : V → H) := (u : V) × V × {h : H // R (s u) h} +noncomputable def extend (s : V → H) (a : Extension R s) : V → H := + Function.update s a.2.1 a.2.2.1 + +omit [DecidableEq V] in +lemma extension_card (Δ : ℕ) + (hΔ : ∀ h, Fintype.card {h' : H // R h h'} ≤ Δ) (s : V → H) : + Fintype.card (Extension R s) ≤ Fintype.card V ^ 2 * Δ := by + classical + rw [Fintype.card_sigma] + simp only [Fintype.card_prod] + calc + _ ≤ ∑ u : V, Fintype.card V * Δ := by + apply Finset.sum_le_sum + intro u _ + exact Nat.mul_le_mul_left _ (hΔ (s u)) + _ = _ := by simp; ring + +lemma dword_card_le {S : Type} (C : S → Type) (step : (s : S) → C s → S) + [∀ s, Fintype (C s)] (M : ℕ) (hM : ∀ s, Fintype.card (C s) ≤ M) + (n : ℕ) (s : S) : Fintype.card (DWord C step n s) ≤ M ^ n := by + induction n generalizing s with + | zero => + change Fintype.card PUnit ≤ 1 + exact le_of_eq Fintype.card_unique + | succ n ih => + change Fintype.card ((a : C s) × DWord C step n (step s a)) ≤ M ^ (n + 1) + rw [Fintype.card_sigma] + calc + _ ≤ ∑ a : C s, M ^ n := Finset.sum_le_sum (fun a _ => ih (step s a)) + _ = Fintype.card (C s) * M ^ n := by simp + _ ≤ M * M ^ n := Nat.mul_le_mul_right _ (hM s) + _ = _ := (pow_succ' M n).symm + +omit [Fintype H] in + +theorem connected_extension_cover (hsym : Std.Symm R) (f s : V → H) + (hf : (relationGraph R hsym f).Connected) (E : Finset V) (hE : E.Nonempty) + (hcoh : ∀ u ∈ E, s u = f u) : + ∃ w : DWord (Extension R) (extend R) (Fintype.card V - E.card) s, + dFinish (Extension R) (extend R) s w = f := by + classical + generalize hm : Fintype.card V - E.card = m + induction m generalizing s E with + | zero => + have hEu : E = Finset.univ := by + apply Finset.eq_univ_of_card + have := Finset.card_le_univ E + omega + have hsf : s = f := by + funext u + exact hcoh u (by simp [hEu]) + subst s + exact ⟨PUnit.unit, rfl⟩ + | succ n ih => + have hne : E ≠ Finset.univ := by + intro h + simp [h] at hm + obtain ⟨u, hu, v, hv, huv⟩ := connected_boundary _ hf E hE hne + let a : Extension R s := ⟨u, v, f v, by + rw [hcoh u hu] + exact huv.2⟩ + have hcoh' : ∀ z ∈ insert v E, extend R s a z = f z := by + intro z hz + rcases Finset.mem_insert.mp hz with rfl | hz + · simp [extend, a] + · have hzv : z ≠ v := by intro h; subst z; exact hv hz + simpa [extend, a, hzv] using hcoh z hz + have hn : Fintype.card V - (insert v E).card = n := by + rw [Finset.card_insert_of_notMem hv] + omega + obtain ⟨w, hw⟩ := ih (extend R s a) (insert v E) (by simp) hcoh' hn + exact ⟨⟨a, w⟩, hw⟩ + +abbrev RelatedPair := (h : H) × {h' : H // R h h'} +abbrev Seed := V × V × RelatedPair R +noncomputable def seedStart (z : Seed (V := V) R) : V → H := + Function.update (fun _ => z.2.2.1) z.2.1 z.2.2.2.1 + +theorem connected_tuple_count (hsym : Std.Symm R) (hV : 2 ≤ Fintype.card V) + (Δ : ℕ) (hΔ : ∀ h, Fintype.card {h' : H // R h h'} ≤ Δ) : + Fintype.card {f : V → H // (relationGraph R hsym f).Connected} ≤ + Fintype.card V ^ 2 * Fintype.card (RelatedPair R) * + (Fintype.card V ^ 2 * Δ) ^ (Fintype.card V - 2) := by + classical + let Code := (z : Seed (V := V) R) × + DWord (Extension R) (extend R) (Fintype.card V - 2) (seedStart R z) + let decode : Code → V → H := fun c => + dFinish (Extension R) (extend R) (seedStart R c.1) c.2 + have hcover (f : {f : V → H // (relationGraph R hsym f).Connected}) : + ∃ c : Code, decode c = f.1 := by + have : Nonempty V := Fintype.card_pos_iff.mp (by omega) + let u : V := Classical.choice inferInstance + have hne : ({u} : Finset V) ≠ Finset.univ := by + intro h + have hh := congrArg Finset.card h + simp at hh + omega + obtain ⟨a, ha, v, hv, huv⟩ := connected_boundary _ f.2 {u} (by simp) hne + have hau : a = u := by simpa using ha + subst a + have hvu : v ≠ u := by simpa using hv + let z : Seed (V := V) R := ⟨u, v, f.1 u, f.1 v, huv.2⟩ + have hcoh : ∀ x ∈ ({u, v} : Finset V), seedStart R z x = f.1 x := by + intro x hx + simp only [Finset.mem_insert, Finset.mem_singleton] at hx + rcases hx with rfl | rfl + · simp [seedStart, z, hvu.symm] + · simp [seedStart, z] + have hcov := connected_extension_cover R hsym f.1 (seedStart R z) + f.2 {u,v} (by simp) hcoh + have hcard : ({u,v} : Finset V).card = 2 := by simp [hvu.symm] + rw [hcard] at hcov + obtain ⟨w, hw⟩ := hcov + exact ⟨⟨z, w⟩, hw⟩ + let enc : {f : V → H // (relationGraph R hsym f).Connected} → Code := + fun f => Classical.choose (hcover f) + have henc : Function.Injective enc := by + intro f g hfg + apply Subtype.ext + calc + f.1 = decode (enc f) := (Classical.choose_spec (hcover f)).symm + _ = decode (enc g) := congrArg decode hfg + _ = g.1 := Classical.choose_spec (hcover g) + calc + _ ≤ Fintype.card Code := Fintype.card_le_of_injective enc henc + _ = ∑ z : Seed (V := V) R, Fintype.card + (DWord (Extension R) (extend R) (Fintype.card V - 2) (seedStart R z)) := + Fintype.card_sigma + _ ≤ ∑ _z : Seed (V := V) R, + (Fintype.card V ^ 2 * Δ) ^ (Fintype.card V - 2) := by + apply Finset.sum_le_sum + intro z _ + exact dword_card_le (Extension R) (extend R) _ (extension_card R Δ hΔ) _ _ + _ = _ := by simp [Seed, Fintype.card_prod, pow_two, mul_assoc] + +end SharpRamseyFive.ComponentEnumeration + +namespace SharpRamseyFive.ComponentPartition +open scoped BigOperators +open Classical +open SharpRamseyFive.ComponentEnumeration SharpRamseyFive.ResidualElimination +variable {V H C : Type} [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] + [Fintype C] [DecidableEq C] + +omit [Fintype H] [DecidableEq H] in +lemma connected_fiber (R : H → H → Prop) (hsym : Std.Symm R) (f : V → H) + (c : V) (hc : (fiber (componentMap (relationGraph R hsym f)) c).Nonempty) : + (relationGraph R hsym (fun v : fiber (componentMap (relationGraph R hsym f)) c => f v)).Connected := by + let G := relationGraph R hsym f + let r := componentMap G + obtain ⟨w,hw⟩ := hc + have hw : r w = c := (mem_fiber _ _ _).mp hw + let S := G.connectedComponentMk w + let e : fiber r c ≃ S := + { toFun := fun v => ⟨v, (S.mem_supp_iff v).mpr + ((componentMap_eq_iff G v w).mp ((mem_fiber r c v).mp v.property |>.trans hw.symm))⟩ + invFun := fun v => ⟨v, (mem_fiber r c v).mpr + (((componentMap_eq_iff G v w).mpr ((S.mem_supp_iff v).mp v.property)).trans hw)⟩ + left_inv := fun _ => rfl + right_inv := fun _ => rfl } + let φ : relationGraph R hsym (fun v : fiber r c => f v) ≃g S.toSimpleGraph := + { toEquiv := e + map_rel_iff' := by + intro x y + change (x.val ≠ y.val ∧ R (f x) (f y)) ↔ (x ≠ y ∧ R (f x) (f y)) + simp only [ne_eq, Subtype.val_inj] } + exact φ.connected_iff.mpr S.connected_toSimpleGraph + +noncomputable def connectedWeight (R : H → H → Prop) (hsym : Std.Symm R) + (r : V → C) (c : C) (x : fiber r c → H) : ℝ := + if (relationGraph R hsym x).Connected then 1 else 0 + +omit [Fintype H] [DecidableEq H] [Fintype C] in +lemma connectedWeight_nonneg (R : H → H → Prop) (hsym : Std.Symm R) + (r : V → C) (c : C) (x : fiber r c → H) : 0 ≤ connectedWeight R hsym r c x := by + unfold connectedWeight + split_ifs <;> norm_num + +omit [DecidableEq H] in +lemma connectedWeight_sum_le (R : H → H → Prop) (hsym : Std.Symm R) + (r : V → C) (c : C) (hc : c ∈ largeLabels r) + (Δ : ℕ) (hΔ : ∀ h, Fintype.card {h' : H // R h h'} ≤ Δ) : + (∑ x : fiber r c → H, connectedWeight R hsym r c x) ≤ + ((fiber r c).card : ℝ) ^ 2 * Fintype.card (RelatedPair R) * + (((fiber r c).card : ℝ) ^ 2 * Δ) ^ ((fiber r c).card - 2) := by + have hc : 2 ≤ Fintype.card (fiber r c) := by simpa only [Fintype.card_coe] using (mem_largeLabels r c).mp hc + have h := connected_tuple_count (V := fiber r c) R hsym hc Δ hΔ + have he : (∑ x : fiber r c → H, connectedWeight R hsym r c x) = + (Fintype.card {x : fiber r c → H // (relationGraph R hsym x).Connected} : ℝ) := by + simp only [connectedWeight, Fintype.card_subtype, Finset.sum_boole] + rw [he] + simpa only [Fintype.card_coe, Nat.cast_mul, Nat.cast_pow] using (Nat.cast_le (α := ℝ)).mpr h + +end SharpRamseyFive.ComponentPartition + +namespace SharpRamseyFive.ComponentPartition +open scoped BigOperators +open Classical +open SharpRamseyFive.ComponentEnumeration SharpRamseyFive.ResidualElimination +variable {V H C : Type} [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] + [Fintype C] [DecidableEq C] + +lemma univ_sub_large (r : V → C) : + Finset.univ \ (largeLabels r).biUnion (fiber r) = singles r := by + rw [large_union] + simp + +lemma partition_block_bound (R : H → H → Prop) (hsym : Std.Symm R) + (r : V → C) (b A : ℝ) (hb : 0 ≤ b) (hA : 0 ≤ A) + (Δ : ℕ) (hΔ : ∀ h, Fintype.card {h' : H // R h h'} ≤ Δ) + (hnum : ∀ c ∈ largeLabels r, + b * (((fiber r c).card : ℝ) ^ 2 * Fintype.card (RelatedPair R) * + (((fiber r c).card : ℝ) ^ 2 * Δ) ^ ((fiber r c).card - 2)) + ≤ A ^ (fiber r c).card) + (F : (V → H) → ℝ) + (hres : ∀ g, completionSum (singles r) g F ≤ A ^ (singles r).card) + (g : V → H) : + completionSum Finset.univ g + (fun f => (∏ c ∈ largeLabels r, + b * connectedWeight R hsym r c (fun v => f v)) * F f) ≤ A ^ Fintype.card V := by + have ht := disjoint_blocks_exposure Finset.univ (largeLabels r) (fiber r) + (fun c x => b * connectedWeight R hsym r c x) (fun c => A ^ (fiber r c).card) + (fun c x => mul_nonneg hb (connectedWeight_nonneg R hsym r c x)) + (fun c => pow_nonneg hA _) (fun _ _ => Finset.subset_univ _) + (fun _ _ _ _ hne => fiber_disjoint r hne) + (fun c hc => by + rw [← Finset.mul_sum] + exact (mul_le_mul_of_nonneg_left (connectedWeight_sum_le R hsym r c hc Δ hΔ) hb).trans (hnum c hc)) + F (A ^ (singles r).card) (pow_nonneg hA _) + (fun g => by simpa only [univ_sub_large] using hres g) g + apply ht.trans_eq + rw [Finset.prod_pow_eq_pow_sum, large_card_sum, ← pow_add] + rw [Nat.sub_add_cancel (Finset.card_le_univ _)] + +theorem graph_partition_sum (R : H → H → Prop) (hsym : Std.Symm R) + (b A : ℝ) (hb : 0 ≤ b) (hA : 0 ≤ A) + (Δ : ℕ) (hΔ : ∀ h, Fintype.card {h' : H // R h h'} ≤ Δ) + (hnum : ∀ m : ℕ, 2 ≤ m → m ≤ Fintype.card V → + b * ((m : ℝ) ^ 2 * Fintype.card (RelatedPair R) * ((m : ℝ) ^ 2 * Δ) ^ (m - 2)) ≤ A ^ m) + (F : Finset V → (V → H) → ℝ) (hF : ∀ E f, 0 ≤ F E f) + (hres : ∀ (r : V → V) g, + completionSum (singles r) g (F (singles r)) ≤ A ^ (singles r).card) : + (∑ f : V → H, b ^ (largeLabels (componentMap (relationGraph R hsym f))).card * + F (singles (componentMap (relationGraph R hsym f))) f) ≤ + (Fintype.card V : ℝ) ^ Fintype.card V * A ^ Fintype.card V := by + let W (r : V → V) (f : V → H) : ℝ := + (∏ c ∈ largeLabels r, b * connectedWeight R hsym r c (fun v => f v)) * F (singles r) f + have hW (r : V → V) (f : V → H) : 0 ≤ W r f := + mul_nonneg (Finset.prod_nonneg (fun c _ => mul_nonneg hb (connectedWeight_nonneg R hsym r c _))) (hF _ f) + have hw (f : V → H) : W (componentMap (relationGraph R hsym f)) f = + b ^ (largeLabels (componentMap (relationGraph R hsym f))).card * + F (singles (componentMap (relationGraph R hsym f))) f := by + dsimp only [W] + congr 1 + calc + _ = ∏ _c ∈ largeLabels (componentMap (relationGraph R hsym f)), b := by + apply Finset.prod_congr rfl + intro c hc + have hfc : (fiber (componentMap (relationGraph R hsym f)) c).Nonempty := + Finset.card_pos.mp (by have := (mem_largeLabels _ c).mp hc; omega) + simp only [connectedWeight, ite_eq_left (connected_fiber R hsym f c hfc), mul_one] + _ = _ := Finset.prod_const _ + calc + _ = ∑ f : V → H, W (componentMap (relationGraph R hsym f)) f := by simp only [hw] + _ ≤ ∑ f : V → H, ∑ r : V → V, W r f := by + apply Finset.sum_le_sum + intro f _ + exact Finset.single_le_sum (fun r _ => hW r f) (Finset.mem_univ _) + _ = ∑ r : V → V, ∑ f : V → H, W r f := Finset.sum_comm + _ ≤ ∑ _r : V → V, A ^ Fintype.card V := by + apply Finset.sum_le_sum + intro r _ + classical + by_cases hn : Nonempty (V → H) + · let g : V → H := hn.some + have hh := partition_block_bound R hsym r b A hb hA Δ hΔ + (fun c hc => hnum _ ((mem_largeLabels _ _).mp hc) (Finset.card_le_univ _)) + (F (singles r)) (hres r) g + simpa [completionSum, Agrees, W] using hh + · have : IsEmpty (V → H) := not_nonempty_iff.mp hn + simp only [Finset.univ_eq_empty, Finset.sum_empty] + exact pow_nonneg hA _ + _ = _ := by simp [Nat.cast_pow] + +end SharpRamseyFive.ComponentPartition + +namespace SharpRamseyFive.AmbientEnumeration +open scoped BigOperators NNReal +open Classical +open SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponents +open SharpRamseyFive.AmbientDesignations SharpRamseyFive.ComponentPartition +open SharpRamseyFive.ComponentEnumeration SharpRamseyFive.ResidualElimination +open SharpRamseyFive.SingletonEnumeration SharpRamseyFive.SelectionBridge +variable {D V H : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V] + [Fintype H] [DecidableEq H] + +noncomputable def overlapRelation (weight : D → ℝ≥0) (lines : H → Finset D) (t : ℝ) + (h k : H) : Prop := t < mass weight (lines h ∩ lines k) + +omit [Fintype D] [Fintype H] [DecidableEq H] in +lemma overlapRelation_symm (weight : D → ℝ≥0) (lines : H → Finset D) (t : ℝ) : + Std.Symm (overlapRelation weight lines t) := by + constructor + intro h k hh + simpa only [overlapRelation, Finset.inter_comm] using hh + +omit [Fintype V] [DecidableEq V] in +omit [Fintype D] [Fintype H] [DecidableEq H] in +lemma relation_graph_eq (weight : D → ℝ≥0) (lines : H → Finset D) (t : ℝ) (f : V → H) : + relationGraph (overlapRelation weight lines t) (overlapRelation_symm weight lines t) f = + strongGraph weight (lines ∘ f) t := by + rfl +omit [Fintype D] in + +lemma simple_image (weight : D → ℝ≥0) (s : V → Finset D) (t : ℝ) : + (simpleSet weight s t).image (vertex weight s t) = singles (componentMap (strongGraph weight s t)) := by + ext v + rw [singles_iff_unique] + simp only [Finset.mem_image, simpleSet, Finset.mem_filter, Finset.mem_univ, true_and] + constructor + · rintro ⟨c,hc,rfl⟩ w hw + exact hc w (((componentMap_eq_iff _ _ _).mp hw).trans (vertex_color weight s t c)) + · intro hv + let c := (strongGraph weight s t).connectedComponentMk v + have he : vertex weight s t c = v := hv _ ((componentMap_eq_iff _ _ _).mpr (vertex_color weight s t c)) + exact ⟨c, fun w hw => (hv w ((componentMap_eq_iff _ _ _).mpr hw)).trans he.symm, he⟩ +omit [Fintype D] in + +lemma simple_card (weight : D → ℝ≥0) (s : V → Finset D) (t : ℝ) : + (simpleSet weight s t).card = (singles (componentMap (strongGraph weight s t))).card := by + rw [← simple_image, Finset.card_image_of_injective _ (vertex_injective weight s t)] +omit [Fintype D] in + +lemma large_image (weight : D → ℝ≥0) (s : V → Finset D) (t : ℝ) : + (Finset.univ \ simpleSet weight s t).image (vertex weight s t) = + largeLabels (componentMap (strongGraph weight s t)) := by + let G := strongGraph weight s t + let r := componentMap G + ext v + simp only [Finset.mem_image, Finset.mem_sdiff, Finset.mem_univ, true_and, mem_largeLabels] + constructor + · rintro ⟨c,hc,rfl⟩ + have hpos : 0 < (fiber r (vertex weight s t c)).card := by + apply Finset.card_pos.mpr + refine ⟨vertex weight s t c, ?_⟩ + rw [mem_fiber] + exact congrArg (vertex weight s t) (vertex_color weight s t c) + have hne : (fiber r (vertex weight s t c)).card ≠ 1 := by + intro he + apply hc + simp only [simpleSet, Finset.mem_filter, Finset.mem_univ, true_and] + intro w hw + have hr : r (vertex weight s t c) = vertex weight s t c := by + exact congrArg (vertex weight s t) (vertex_color weight s t c) + have hs : vertex weight s t c ∈ singles r := by + rw [mem_singles, hr]; exact he + exact (singles_iff_unique r (vertex weight s t c)).mp hs w + ((componentMap_eq_iff G _ _).mpr (hw.trans (vertex_color weight s t c).symm)) + change 2 ≤ (fiber r (vertex weight s t c)).card + omega + · intro hv + change 2 ≤ (fiber r v).card at hv + have hpos : 0 < (fiber r v).card := by omega + obtain ⟨w,hw⟩ := Finset.card_pos.mp hpos + let c := G.connectedComponentMk w + have he : vertex weight s t c = v := (mem_fiber r v w).mp hw + refine ⟨c, ?_, he⟩ + intro hc + have hs : vertex weight s t c ∈ singles r := by + rw [← simple_image] + exact Finset.mem_image.mpr ⟨c,hc,rfl⟩ + have hcard := (mem_singles r (vertex weight s t c)).mp hs + have hr : r (vertex weight s t c) = vertex weight s t c := by + exact congrArg (vertex weight s t) (vertex_color weight s t c) + rw [hr,he] at hcard + omega + +end SharpRamseyFive.AmbientEnumeration +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Entropy/StrongDegreeBudget.lean b/lean/OAI/Combinatorics/SharpRamsey/Entropy/StrongDegreeBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..c7ff2f7944c218f302084992d71ae9a64f633e26 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Entropy/StrongDegreeBudget.lean @@ -0,0 +1,353 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Entropy.LargeCard + +namespace OAI + +/-! High moments, finite-field subspaces, and incidence bounds. -/ + +section +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open scoped BigOperators +open MeasureTheory ProbabilityTheory +open scoped BigOperators ENNReal NNReal +namespace SharpLogRamsey.MomentBudgetBridge +lemma strong_degree_budget (B P : ℝ) (hP : 1 ≤ P) (hB : Real.exp (3*P) ≤ B) : + 1+B*Real.exp (-3*P) ≤ B*Real.exp (-P) := by + have he := mul_le_mul_of_nonneg_right hB (Real.exp_pos (-3*P)).le + have h1 : 1 ≤ B*Real.exp (-3*P) := by + simpa only [← Real.exp_add, show 3*P + -3*P = 0 by ring, Real.exp_zero] using he + have hexp : 2*Real.exp (-3*P) ≤ Real.exp (-P) := by + have h2 : 2 ≤ Real.exp (2*P) := by + have ht := Real.add_one_le_exp (2*P) + linarith + have hm := mul_le_mul_of_nonneg_right h2 (Real.exp_pos (-3*P)).le + calc + _ ≤ Real.exp (2*P)*Real.exp (-3*P) := hm + _ = _ := by rw [← Real.exp_add]; congr 1; ring + have hm := mul_le_mul_of_nonneg_left hexp (le_trans (Real.exp_pos _).le hB) + nlinarith only [h1, hm] + +end SharpLogRamsey.MomentBudgetBridge + +namespace SharpLogRamsey.HighMoment +open scoped BigOperators NNReal +open Classical +open SharpRamseyFive WeightedPrograms SingletonEnumeration +open PoissonScore AmbientEnumeration ComponentEnumeration +open SharpLogRamsey.MomentBudgetBridge + +variable {D H I : Type} [Fintype D] [DecidableEq D] + [Fintype H] [DecidableEq H] [DecidableEq I] + +omit [Fintype D] [DecidableEq I] in + +theorem labelled_pair_bound (weight : D → ℝ≥0) (lines : H → Finset D) + (p R : ℕ) (L : ℝ≥0) (B : ℝ) + (hH : (Fintype.card H : ℝ) ≤ 4*B^2) + (hmass : ∀ x, mass weight (lines x) ≤ 2) + (T : Finset I) (a : I → ℝ) (ha : ∀ i ∈ T, 0 ≤ a i) + (hcover : ∀ z : DistinctPairs H, 0 < strength lines weight z → + ∃ i ∈ T, a i ≤ strength lines weight z ∧ strength lines weight z ≤ 2*a i) + (hcount : ∀ i ∈ T, + ((Finset.univ.filter (fun z : DistinctPairs H => a i ≤ strength lines weight z)).card : ℝ) * + a i ^ 200 ≤ B^2*Real.exp (((L : ℝ)*R)/50)) : + pairMoment (B := Fin R) (fun z : H × Fin p => lines z.1) (fun d => L*weight d) 200 ≤ + (p : ℝ)^2 * (B^2*Real.exp (((L : ℝ)*R)/50)*((T.card : ℝ)+4)*(2*((L : ℝ)*R))^200) := by + have he : 1 ≤ Real.exp (((L : ℝ)*R)/50) := Real.one_le_exp_iff.mpr (by positivity) + have hmass' x : ∑ d ∈ lines x, ((L*weight d : ℝ≥0) : ℝ) ≤ 2*(L : ℝ) := by + simp only [NNReal.coe_mul, ← Finset.mul_sum] + have ht := mul_le_mul_of_nonneg_left (hmass x) L.coe_nonneg + simpa only [mass, mul_comm] using ht + have hlabel := pairMoment_labelled_le (V := Fin p) (B := Fin R) lines + (fun d => L*weight d) 200 (2*(L : ℝ)) (by positivity) hmass' + have hpair := pairMoment_dyadic (B := Fin R) lines weight L 200 (by decide) T a ha hcover + (B^2*Real.exp (((L : ℝ)*R)/50)) (by positivity) hcount + have hH' : (Fintype.card H : ℝ) ≤ 4*B^2*Real.exp (((L : ℝ)*R)/50) := + hH.trans (le_mul_of_one_le_right (by positivity) he) + simp only [Fintype.card_fin] at hlabel hpair + apply hlabel.trans + apply mul_le_mul_of_nonneg_left _ (by positivity) + have hdiag := mul_le_mul_of_nonneg_right hH' (pow_nonneg (show 0 ≤ (R : ℝ)*(2*(L : ℝ)) by positivity) 200) + calc + _ ≤ (T.card : ℝ)*(B^2*Real.exp (((L : ℝ)*R)/50))*(2*R*(L : ℝ))^200 + + 4*B^2*Real.exp (((L : ℝ)*R)/50)*((R : ℝ)*(2*(L : ℝ)))^200 := add_le_add hpair hdiag + _ = _ := by ring + +omit [Fintype D] [DecidableEq I] in + +theorem full_branching_bound (weight : D → ℝ≥0) (lines : H → Finset D) + (p R N : ℕ) (L : ℝ≥0) (B : ℝ) (hB : 1 ≤ B) + (hH : (Fintype.card H : ℝ) ≤ 4*B^2) (hN : (N : ℝ) ≤ 4*B) + (hmass : ∀ x, mass weight (lines x) ≤ 2) + (T : Finset I) (a : I → ℝ) (ha : ∀ i ∈ T, 0 ≤ a i) + (hcover : ∀ z : DistinctPairs H, 0 < strength lines weight z → + ∃ i ∈ T, a i ≤ strength lines weight z ∧ strength lines weight z ≤ 2*a i) + (hcount : ∀ i ∈ T, + ((Finset.univ.filter (fun z : DistinctPairs H => a i ≤ strength lines weight z)).card : ℝ) * + a i ^ 200 ≤ B^2*Real.exp (((L : ℝ)*R)/50)) + (hpoly : certificateOverhead p T.card ((L : ℝ)*R) ≤ Real.exp (2*((L : ℝ)*R)/25)) : + B*(1+branchingBound (V := Fin p) (B := Fin R) + (fun z : H × Fin p => lines z.1) (fun d => L*weight d) B B (2*(L : ℝ)) 200 + (N*p) (1*p) true) ≤ B*Real.exp (((L : ℝ)*R)/10) := by + have hM := labelled_pair_bound weight lines p R L B hH hmass T a ha hcover hcount + have hn := labelled_branching_bound p T.card ((L : ℝ)*R) B (Fintype.card H) N + (pairMoment (B := Fin R) (fun z : H × Fin p => lines z.1) (fun d => L*weight d) 200) + (by positivity) hB hH hN hM + have hid : uniformAnchorBudget (V := Fin p) (B := Fin R) 200 (2*(L : ℝ)) = + anchorBudget p ((L : ℝ)*R) := by + simp only [uniformAnchorBudget, MomentBudgetBridge.anchorBudget, Fintype.card_fin, Nat.cast_ofNat] + ring + have hnorm : 1+branchingBound (V := Fin p) (B := Fin R) + (fun z : H × Fin p => lines z.1) (fun d => L*weight d) B B (2*(L : ℝ)) 200 + (N*p) (1*p) true ≤ Real.exp (((L : ℝ)*R)/10) := by + unfold branchingBound + simp only [Fintype.card_prod, Fintype.card_fin, Nat.cast_mul, ite_true, one_mul, hid] + exact hn.trans (absorb_certificate p T.card ((L : ℝ)*R) hpoly) + exact mul_le_mul_of_nonneg_left hnorm (by linarith) + +lemma relation_row_card (rel : H → H → Prop) (y : H) : + (Fintype.card {x : H // rel y x} : ℝ) ≤ + 1+((Finset.univ.filter (fun x : {x : H // x ≠ y} => rel y x)).card : ℝ) := by + classical + have he : (Fintype.card {x : H // rel y x} : ℝ) = + ∑ x : H, if rel y x then (1 : ℝ) else 0 := by + simp only [Fintype.card_subtype, Finset.sum_boole] + rw [he, sum_split_diagonal _ y] + simp only [Finset.sum_boole] + split_ifs <;> linarith + +lemma relation_pairs_card (rel : H → H → Prop) : + (Fintype.card (RelatedPair rel) : ℝ) ≤ Fintype.card H+ + ((Finset.univ.filter (fun z : DistinctPairs H => rel z.1 z.2)).card : ℝ) := by + classical + have he : (Fintype.card (RelatedPair rel) : ℝ) = + ∑ x : H, ∑ y : H, if rel x y then (1 : ℝ) else 0 := by + simp only [RelatedPair, Fintype.card_sigma, Nat.cast_sum, Fintype.card_subtype, + Finset.sum_boole] + rw [he, sum_pairs_split_diagonal] + simp only [Finset.sum_boole] + gcongr + exact_mod_cast Finset.card_le_card (Finset.filter_subset _ _) + +lemma strong_pairs_markov (θ : DistinctPairs H → ℝ) (hθ : ∀ z, 0 ≤ θ z) + (t : ℝ) (ht : 0 ≤ t) (K : ℕ) : + ((Finset.univ.filter (fun z => t < θ z)).card : ℝ)*t^K ≤ ∑ z, θ z ^ K := by + classical + have he : ((Finset.univ.filter (fun z => t < θ z)).card : ℝ) = + ∑ z, if t < θ z then (1 : ℝ) else 0 := by simp only [Finset.sum_boole] + rw [he, Finset.sum_mul] + apply Finset.sum_le_sum + intro z _ + by_cases htz : t < θ z + · simpa only [ite_eq_left htz, one_mul] using pow_le_pow_left₀ ht htz.le K + · simp only [ite_eq_right htz, zero_mul] + exact pow_nonneg (hθ z) K + +omit [Fintype D] [DecidableEq D] [DecidableEq H] in + +lemma deviation_sum (weight : D → ℝ≥0) (lines : H → Finset D) + (base : ℝ) (R : ℕ) (hR : 4 ≤ R) + (hdelta : ∀ x, |mass weight (lines x)-base| ≤ (17/100 : ℝ)) + (C : ℝ) (hsq : (∑ x, (mass weight (lines x)-base)^2) ≤ C) : + (∑ x, |mass weight (lines x)-base|^(R/2)) ≤ C := by + apply le_trans _ hsq + apply Finset.sum_le_sum + intro x _ + calc + _ ≤ |mass weight (lines x)-base|^2 := + pow_le_pow_of_le_one (abs_nonneg _) ((hdelta x).trans (by norm_num)) (by omega) + _ = _ := sq_abs _ + +omit [DecidableEq I] in +omit [Fintype D] in + +theorem dyadic_shift_bounds (weight : D → ℝ≥0) (lines : H → Finset D) + (p : ℕ) (B P : ℝ) (hB : 1 ≤ B) (hP : 0 ≤ P) + (hH : (Fintype.card H : ℝ) ≤ 4*B^2) + (T : Finset I) (a : I → ℝ) (ha : ∀ i ∈ T, 0 ≤ a i) + (hcover : ∀ z : DistinctPairs H, 0 < strength lines weight z → + ∃ i ∈ T, a i ≤ strength lines weight z ∧ strength lines weight z ≤ 2*a i) + (hcount : ∀ i ∈ T, + ((Finset.univ.filter (fun z : DistinctPairs H => a i ≤ strength lines weight z)).card : ℝ)* + a i^200 ≤ B^2*Real.exp (P/50)) + (hrow : ∀ y i, i ∈ T → + ((Finset.univ.filter (fun x : {x : H // x ≠ y} => + a i ≤ mass weight (lines x ∩ lines y))).card : ℝ)*a i^200 ≤ B*Real.exp (P/50)) + (hpoly : shiftOverhead p T.card ≤ Real.exp (2*P/25)) : + (∀ y, (∑ x : H, shiftKernel weight lines p 200 x y) ≤ B*Real.exp (P/10)) ∧ + (∑ x : H, ∑ y : H, shiftKernel weight lines p 200 x y) ≤ (B*Real.exp (P/10))^2 := by + have hB0 : 0 ≤ B := by linarith + constructor + · intro y + have hcover' (x : {x : H // x ≠ y}) (hx : 0 < mass weight (lines x ∩ lines y)) : + ∃ i ∈ T, a i ≤ mass weight (lines x ∩ lines y) ∧ + mass weight (lines x ∩ lines y) ≤ 2*a i := by + have hh := hcover ⟨y, x⟩ + simpa only [strength, mass, Finset.inter_comm] using hh (by + simpa only [strength, mass, Finset.inter_comm] using hx) + have hs := shift_row_dyadic weight lines p 200 (by decide) y T a + (B*Real.exp (P/50)) (by positivity) ha hcover' (hrow y) + apply hs.trans + calc + _ ≤ 4*B+(T.card : ℝ)*B*Real.exp (P/50)*(2*(p : ℝ))^200 := by + nlinarith only [hB] + _ ≤ _ := shifted_dyadic_budget p T.card P B hP hB0 hpoly + · have hs := shift_pairs_dyadic weight lines p 200 (by decide) T a + (B^2*Real.exp (P/50)) (by positivity) ha hcover hcount + apply hs.trans + calc + _ ≤ 4*B^2+(T.card : ℝ)*B^2*Real.exp (P/50)*(2*(p : ℝ))^200 := by + nlinarith only [hH] + _ ≤ B^2*Real.exp (P/10) := shifted_dyadic_budget p T.card P (B^2) hP (sq_nonneg _) hpoly + _ ≤ (B*Real.exp (P/10))^2 := by + have he : 1 ≤ Real.exp (P/10) := Real.one_le_exp_iff.mpr (by positivity) + have hsq : Real.exp (P/10) ≤ Real.exp (P/10)^2 := le_self_pow₀ he (by decide : 2 ≠ 0) + simpa only [mul_pow] using mul_le_mul_of_nonneg_left hsq (sq_nonneg B) + +omit [Fintype D] [DecidableEq I] in + +theorem strong_relation_pairs (weight : D → ℝ≥0) (lines : H → Finset D) + (p : ℕ) (hp : 0 < p) (B P : ℝ) (hP : 0 ≤ P) + (hH : (Fintype.card H : ℝ) ≤ 4*B^2) + (T : Finset I) (a : I → ℝ) (ha : ∀ i ∈ T, 0 ≤ a i) + (hcover : ∀ z : DistinctPairs H, 0 < strength lines weight z → + ∃ i ∈ T, a i ≤ strength lines weight z ∧ strength lines weight z ≤ 2*a i) + (hcount : ∀ i ∈ T, + ((Finset.univ.filter (fun z : DistinctPairs H => a i ≤ strength lines weight z)).card : ℝ)* + a i^200 ≤ B^2*Real.exp (P/50)) + (hpoly : shiftOverhead p T.card ≤ Real.exp (2*P/25)) : + (Fintype.card (RelatedPair (overlapRelation weight lines (1/(100*p)))) : ℝ) ≤ + B^2*Real.exp (P/10) := by + have hp0 : (0 : ℝ) < p := by exact_mod_cast hp + have hpne : (100*(p : ℝ)) ≠ 0 := by positivity + have hmoment := DyadicMoments.moment_le_of_cover (strength lines weight) a T 200 + (by decide) (B^2*Real.exp (P/50)) (by positivity) + (strength_nonneg lines weight) ha hcover hcount + have hmarkov := strong_pairs_markov (strength lines weight) (strength_nonneg lines weight) + (1/(100*(p : ℝ))) (by positivity) 200 + have hm := mul_le_mul_of_nonneg_right (hmarkov.trans hmoment) + (pow_nonneg (show 0 ≤ 100*(p : ℝ) by positivity) 200) + have hcancel : (1/(100*(p : ℝ)))^200*(100*(p : ℝ))^200 = 1 := by + rw [← mul_pow, one_div_mul_cancel hpne, one_pow] + have hdistinct : ((Finset.univ.filter (fun z : DistinctPairs H => + 1/(100*(p : ℝ)) < strength lines weight z)).card : ℝ) ≤ + (T.card : ℝ)*(B^2)*Real.exp (P/50)*(200*(p : ℝ))^200 := by + rw [mul_assoc, hcancel, mul_one] at hm + apply hm.trans_eq + rw [show 200*(p : ℝ) = 2*(100*(p : ℝ)) by ring, mul_pow] + ring + have hh := relation_pairs_card (overlapRelation weight lines (1/(100*(p : ℝ)))) + apply hh.trans + have hn : ((Finset.univ.filter (fun z : DistinctPairs H => + overlapRelation weight lines (1/(100*(p : ℝ))) z.1 z.2)).card : ℝ) ≤ + (T.card : ℝ)*B^2*Real.exp (P/50)*(200*(p : ℝ))^200 := by + convert hdistinct using 1 + congr 2 + calc + _ ≤ 4*B^2+(T.card : ℝ)*B^2*Real.exp (P/50)*(200*(p : ℝ))^200 := add_le_add hH hn + _ ≤ _ := strong_dyadic_budget p T.card P (B^2) hP (sq_nonneg B) hpoly + +omit [Fintype D] in + +theorem strong_relation_degree (weight : D → ℝ≥0) (lines : H → Finset D) + (p : ℕ) (B P : ℝ) (hP : 1 ≤ P) (hB : Real.exp (3*P) ≤ B) + (hstrong : ∀ y, + ((Finset.univ.filter (fun x : {x : H // x ≠ y} => + 1/(100*(p : ℝ)) ≤ mass weight (lines x ∩ lines y))).card : ℝ) ≤ B*Real.exp (-3*P)) : + ∃ Δ : ℕ, + (∀ y, Fintype.card {x : H // overlapRelation weight lines (1/(100*p)) y x} ≤ Δ) ∧ + (Δ : ℝ) ≤ B*Real.exp (-P) := by + have hB0 : 0 ≤ B := (Real.exp_pos _).le.trans hB + refine ⟨⌊B*Real.exp (-P)⌋₊, ?_, Nat.floor_le (by positivity)⟩ + intro y + apply Nat.le_floor + have hh := relation_row_card (overlapRelation weight lines (1/(100*(p : ℝ)))) y + have hm : ((Finset.univ.filter (fun x : {x : H // x ≠ y} => + overlapRelation weight lines (1/(100*(p : ℝ))) y x)).card : ℝ) ≤ + ((Finset.univ.filter (fun x : {x : H // x ≠ y} => + 1/(100*(p : ℝ)) ≤ mass weight (lines x ∩ lines y))).card : ℝ) := by + apply Nat.cast_le.mpr + apply Finset.card_le_card + intro x hx + simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hx ⊢ + have ht := hx.le + simpa only [overlapRelation, Finset.inter_comm] using ht + apply hh.trans + calc + _ ≤ 1+B*Real.exp (-3*P) := by linarith only [hm, hstrong y] + _ ≤ _ := strong_degree_budget B P hP hB + +omit [DecidableEq I] in + +theorem prepared_pencil_high_moment (weight : D → ℝ≥0) (lines : H → Finset D) + {p : ℕ} (hp : 0 < p) (R : ℕ) (own : H → Fin R → Bool) + (L : ℝ≥0) (base B : ℝ) + (hL : 10000 ≤ (L : ℝ)) (hbase : (24/25 : ℝ) ≤ base) + (hlower : ∀ x, (3/4 : ℝ) ≤ mass weight (lines x)) + (hupper : ∀ x, mass weight (lines x) ≤ 2) + (hdelta : ∀ x, |mass weight (lines x)-base| ≤ (17/100 : ℝ)) + (hB : Real.exp (3*((L : ℝ)*R)) ≤ B) + (hH : (Fintype.card H : ℝ) ≤ 4*B^2) + (N : ℕ) (hN : (N : ℝ) ≤ 4*B) + (hone : ∀ d, (Finset.univ.filter (fun x => d ∈ lines x)).card ≤ N) + (htwo : ∀ d e, d ≠ e → + (Finset.univ.filter (fun x => d ∈ lines x ∧ e ∈ lines x)).card ≤ 1) + (T : Finset I) (a : I → ℝ) (ha : ∀ i ∈ T, 0 ≤ a i) + (hcover : ∀ z : DistinctPairs H, 0 < strength lines weight z → + ∃ i ∈ T, a i ≤ strength lines weight z ∧ strength lines weight z ≤ 2*a i) + (hcount : ∀ i ∈ T, + ((Finset.univ.filter (fun z : DistinctPairs H => a i ≤ strength lines weight z)).card : ℝ)* + a i^200 ≤ B^2*Real.exp (((L : ℝ)*R)/50)) + (hrow : ∀ y i, i ∈ T → + ((Finset.univ.filter (fun x : {x : H // x ≠ y} => + a i ≤ mass weight (lines x ∩ lines y))).card : ℝ)*a i^200 ≤ + B*Real.exp (((L : ℝ)*R)/50)) + (hstrong : ∀ y, + ((Finset.univ.filter (fun x : {x : H // x ≠ y} => + 1/(100*(p : ℝ)) ≤ mass weight (lines x ∩ lines y))).card : ℝ) ≤ + B*Real.exp (-3*((L : ℝ)*R))) + (hsq : (∑ x, (mass weight (lines x)-base)^2) ≤ B*Real.exp (((L : ℝ)*R)/100)) + (hpoly : certificateOverhead p T.card ((L : ℝ)*R) ≤ Real.exp (2*((L : ℝ)*R)/25)) + (hshift : shiftOverhead p T.card ≤ Real.exp (2*((L : ℝ)*R)/25)) + (hp2 : (p : ℝ)^2 ≤ Real.exp (((L : ℝ)*R)/10)) + (hps : 2*(p : ℝ)+3 ≤ Real.exp (((L : ℝ)*R)/10)) + (h : ℕ) (hh : 0 < h) (hR : 400 ≤ R) + (hsize : h ≤ (R/2)/400) + (herr : (p : ℝ)*h*(19/20 : ℝ)^(h-1) < 1/2) : + (∫ ω, (∑ x : H, scoreTerm (lines x) (Real.exp (-(L : ℝ)*base)) (own x) + (fun r d => ω (r,d)))^p + ∂batchMeasure (fun i : Fin R × D => L*weight i.2)) ≤ + B^p*Real.exp (-(1/10 : ℝ)*(p*((L : ℝ)*R))) := by + have hP0 : 0 ≤ (L : ℝ)*R := by positivity + have hP : 1 ≤ (L : ℝ)*R := by + have hR' : (400 : ℝ) ≤ R := by exact_mod_cast hR + nlinarith + have hB1 : 1 ≤ B := (Real.one_le_exp_iff.mpr (by positivity)).trans hB + have hB0 : 0 ≤ B := by linarith + have hbranch := full_branching_bound weight lines p R N L B hB1 hH hN hupper + T a ha hcover hcount hpoly + obtain ⟨hrows, hpairs⟩ := dyadic_shift_bounds weight lines p B ((L : ℝ)*R) + hB1 hP0 hH T a ha hcover hcount hrow hshift + obtain ⟨Δ, hΔ, hdeg⟩ := strong_relation_degree weight lines p B ((L : ℝ)*R) hP hB hstrong + have hrel := strong_relation_pairs weight lines p hp B ((L : ℝ)*R) hP0 hH + T a ha hcover hcount hshift + have hmass x : ∑ d ∈ lines x, ((L*weight d : ℝ≥0) : ℝ) ≤ 2*(L : ℝ) := by + simp only [NNReal.coe_mul, ← Finset.mul_sum] + have ht := mul_le_mul_of_nonneg_left (hupper x) L.coe_nonneg + simpa only [mass, mul_comm] using ht + exact ambient_untruncated_moment weight lines hp R own L B B (2*(L : ℝ)) + (B*Real.exp (((L : ℝ)*R)/10)) (B*Real.exp (((L : ℝ)*R)/100)) base B + hL (by linarith) hlower hdelta (by linarith) hB1 (by positivity) + (by positivity) (by positivity) hB0 hmass 200 h N 1 (by decide) (by omega) + hh hsize herr hone htwo hbranch hrows hpairs + (deviation_sum weight lines base R (by omega) hdelta _ hsq) + (singleton_budget p B ((L : ℝ)*R) hB0 hP0 hps) hp2 Δ hΔ hdeg hrel + +end SharpLogRamsey.HighMoment + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Entropy/TerminalEntropy.lean b/lean/OAI/Combinatorics/SharpRamsey/Entropy/TerminalEntropy.lean new file mode 100644 index 0000000000000000000000000000000000000000..0c327c4331970af76dc9b003ca47f35c295d707e --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Entropy/TerminalEntropy.lean @@ -0,0 +1,80 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.TrackedStep + +namespace OAI + +section +namespace SharpLogRamsey.Marking +open Finset Real Filter Selection Selection.Windows ActualHighRank SourceScales ActualPivot +open scoped Classical BigOperators Topology +noncomputable section +local instance terminalFiniteDual {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Fin (d+1)→K)) := + Finite.of_injective ((↑) : Module.Dual K (Fin (d+1)→K)→((Fin (d+1)→K)→K)) DFunLike.coe_injective +local instance terminalFiniteDouble {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Module.Dual K (Fin (d+1)→K))) := + Finite.of_injective ((↑) : Module.Dual K (Module.Dual K (Fin (d+1)→K))→(Module.Dual K (Fin (d+1)→K)→K)) DFunLike.coe_injective +local instance terminalProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Fin (d+1)→K)) := Fintype.ofFinite _ +local instance terminalDualProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Fin (d+1)→K))) := Fintype.ofFinite _ +local instance terminalDoubleProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Module.Dual K (Fin (d+1)→K)))) := Fintype.ofFinite _ + +lemma terminal_entropy_upper (i q : ℕ) [Fact q.Prime] (σ P Δ Λ L : ℝ) + (hσ : 1 ≤ σ) (hP : 1 ≤ P) (hΔ : 0 ≤ Δ) (he : exp σ=(q:ℝ)) + (Ω : Type) [Fintype Ω] (k m : ℕ) (p : Law Ω) + (F : Ω→Fin k→Flag (ZMod q) (Fin (i+4)→ZMod q)) + (hcons : ∀ x,p.mass x≠0→ScanConsistent ((List.ofFn (fun j=>flagPair (F x j))).map toScan)) + (e : ContextOutput p (fun x j=>flagPair (F x j)) m (P*(q:ℝ)^(i+3)*exp Δ) Λ L) : + entropy (e.μ.map (fun x j=>flagPair (F (e.source x) (e.chosen x j)))) ≤ + Λ+(m:ℝ)*(((i+3:ℕ):ℝ)*σ+log (3*((i:ℝ)+5))+log 64)+ + (32*((i:ℝ)+5)^3)*(q:ℝ)*σ*(Δ+(|log P|+|log 64|)) := by + let G:=fun x j=>flagPair (F (e.source x) (e.chosen x j)) + let B:=|log P|+|log 64| + let J:=jointJ (ZMod q) (i+3) + have hB : 0 ≤ B:=by dsimp [B];positivity + have hq0 : (0:ℝ) < q:=he ▸ exp_pos _ + have hlog : log (q:ℝ)=σ:=by rw [←he,log_exp] + have hdim : Module.finrank (ZMod q) (Fin (i+4)→ZMod q)=(i+1)+3:=by simp + obtain ⟨hJ0,hBJ,hJgap⟩:=tracked_log_budget i q σ Δ P (zero_le_one.trans hσ) hΔ hP he + have hprev : ∀ z j,log (e.domains z j).card ≤ J+(Δ+B):=by + intro z j + have hh:=e.log_size hJ0 hBJ z j + change _ ≤ jointJ (ZMod q) (i+3)+(Δ+B) + linarith + have hc : ∀ x,e.μ.mass x≠0→ScanConsistent ((List.ofFn (G x)).map toScan):=by + intro x _ + exact scanConsistent_ordered _ (hcons _ (e.supported x)) (e.chosen x) + have HH:=actual_entropy_upper hdim e.μ e.msg G e.domains (J+(Δ+B)) hc + (fun x _ j=>(F (e.source x) (e.chosen x j)).incident) (fun x _ j=>e.hit x j) hprev + have HE:=expected_expensive_bound e.μ G + have hpoints:=projective_log_card_add_one + (show Module.finrank (ZMod q) (Fin (i+4)→ZMod q)=(i+3)+1 by simp) + (by simpa only [Nat.card_zmod,hlog] using hσ) + rw [Nat.card_zmod,hlog] at hpoints + have hExp : (32*(Module.finrank (ZMod q) (Fin (i+4)→ZMod q)+1)^2*(Nat.card (ZMod q):ℝ)* + log (Fintype.card (Points (K:=ZMod q) (V:=Fin (i+4)→ZMod q))+1:ℝ)) ≤ + (32*((i:ℝ)+5)^3)*(q:ℝ)*σ:=by + simp only [Points] at * + have hh:=mul_le_mul_of_nonneg_left hpoints + (by positivity : 0 ≤ 32*((i:ℝ)+5)^2*(q:ℝ)) + simp only [Module.finrank_pi,Fintype.card_fin,Nat.card_zmod] + push_cast at hh ⊢ + nlinarith only [hh] + have hj : J=log 64+((i+3:ℕ):ℝ)*σ:=by + dsimp only [J,jointJ] + rw [Nat.card_zmod,log_mul (by norm_num) (pow_ne_zero _ hq0.ne'),log_pow,hlog] + have heterm:=mul_le_mul_of_nonneg_right (HE.trans hExp) (add_nonneg hΔ hB) + have hcost:=e.cost + change _ ≤ entropy (e.μ.map e.msg)+_+(m:ℝ)*J+_*(J+(Δ+B)-J) at HH + rw [add_sub_cancel_left,hj] at HH + simp only [Module.finrank_pi,Fintype.card_fin] at HH + push_cast at HH + have hMask : log (((i:ℝ)+4+1)*3)=log (3*((i:ℝ)+5)):=by congr 1;ring + rw [hMask] at HH + change entropy (e.μ.map G) ≤ _ + dsimp only [B] at heterm + push_cast + nlinarith only [HH,heterm,hcost] +end +end SharpLogRamsey.Marking + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Entropy/TestActualSecondMoment.lean b/lean/OAI/Combinatorics/SharpRamsey/Entropy/TestActualSecondMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..ac8fa03af5a6cf918058a550b4921113c0b474f3 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Entropy/TestActualSecondMoment.lean @@ -0,0 +1,139 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Learning.TestActualMoment +import OAI.Combinatorics.SharpRamsey.Entropy.TestSecondMomentBase + +namespace OAI + +section +namespace SharpLogRamsey.PreparedProjectiveGeometry +open Finset MeasureTheory SharpRamseyFive.PoissonScore +open scoped Classical BigOperators NNReal +noncomputable section +variable {K V I : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedTestActualSecondMoment_1 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedTestActualSecondMoment_2 : Fintype (Projectivization K (Module.Dual K V)) := Fintype.ofFinite _ + +def pencilTheta (S : Finset (Projectivization K V)) (x : Projectivization K V) + (c : ℝ≥0) (H J : Projectivization K (Module.Dual K V)) : ℝ := + if H=J then 0 else overlap S x c H J + +omit [Finite K] [FiniteDimensional K V] in +lemma family_all_pairs_card (A : Finset (Projectivization K (Module.Dual K V))) + (S : Finset (Projectivization K V)) (x : Projectivization K V) (c : ℝ≥0) + (a : ℝ) (ha : 0 a ≤ pencilTheta S x c z.1 z.2)).card= + (largePairs S x c a A).card := by + rw [←Fintype.card_coe,←Fintype.card_coe] + apply Fintype.card_congr + refine { + toFun := fun z => ⟨(z.1.1.1,z.1.2.1),?_⟩ + invFun := fun z => ⟨(⟨z.1.1,?_⟩,⟨z.1.2,?_⟩),?_⟩ + left_inv := fun z => rfl + right_inv := fun z => rfl } + · have hc := (mem_filter.mp z.2).2 + have hn : z.1.1.1≠z.1.2.1 := by + intro he + simp only [pencilTheta,ite_eq_left he] at hc + linarith + exact mem_filter.mpr ⟨mem_product.mpr ⟨z.1.1.2,z.1.2.2⟩,hn, + by simpa only [pencilTheta,ite_eq_right hn] using hc⟩ + · exact (mem_product.mp (mem_filter.mp z.2).1).1 + · exact (mem_product.mp (mem_filter.mp z.2).1).2 + · apply mem_filter.mpr + refine ⟨mem_univ _,?_⟩ + simpa only [pencilTheta,ite_eq_right (mem_filter.mp z.2).2.1] using (mem_filter.mp z.2).2.2 + +omit [Finite K] [FiniteDimensional K V] in +lemma pencilTheta_nonneg (S : Finset (Projectivization K V)) (x : Projectivization K V) + (c : ℝ≥0) (H J : Projectivization K (Module.Dual K V)) : + 0 ≤ pencilTheta S x c H J := by + unfold pencilTheta overlap + split_ifs <;> positivity + +lemma pencilTheta_le_mass (S : Finset (Projectivization K V)) (x : Projectivization K V) + (c : ℝ≥0) (H J : Projectivization K (Module.Dual K V)) + (hH : x.submodule ≤ LinearMap.ker H.rep) (hJ : x.submodule ≤ LinearMap.ker J.rep) : + pencilTheta S x c H J ≤ mass (radialWeight S x c) (lines x H) := by + unfold pencilTheta + split_ifs with he + · exact mass_nonneg _ _ + · rw [←radialWeight_intersection S x c H J hH hJ] + exact mass_mono _ inter_subset_left + +theorem actual_projective_second_moment + (j : ℕ) (hdim : Module.finrank K V ≤ j+1) + (S : Finset (Projectivization K V)) (x : Projectivization K V) (c L : ℝ≥0) + (A : Finset (Projectivization K (Module.Dual K V))) + (hA : ∀ H∈A,x.submodule ≤ LinearMap.ker H.rep) + (f B C : ℝ) (hf : f ≤ 1/4) (hB : 0 ≤ B) (hC : 0 ≤ C) + (R : ℕ) (own : A → Fin R → Bool) (hL : 1 ≤ (L:ℝ)) (hR : 200 ≤ R) + (hlow : ∀ H∈A,3/4 ≤ (c:ℝ)*(S.filter (fun y => y≠x ∧ y.submodule ≤ LinearMap.ker H.rep)).card) + (hupp : ∀ H∈A,(c:ℝ)*(S.filter (fun y => y≠x ∧ y.submodule ≤ LinearMap.ker H.rep)).card ≤ 2) + (hdelta : ∀ H∈A,|(c:ℝ)*(S.filter (fun y => y≠x ∧ y.submodule ≤ LinearMap.ker H.rep)).card-(1-f)| ≤ 1) + (hsq : (∑ H∈A,((c:ℝ)*(S.filter (fun y => y≠x ∧ y.submodule ≤ LinearMap.ker H.rep)).card-(1-f))^2) ≤ C*B*Real.exp ((L:ℝ)/100)) + (hcard : ((∑ i∈range j,Nat.card K^i):ℝ) ≤ C*B^2) + (T : Finset I) (a : I → ℝ) (ha : ∀ i∈T,0 ω (r,d)))^2 ∂batchMeasure (fun i : Fin R × RadialLine x => L*radialWeight S x c i.2)) + ≤ B^2*Real.exp (-(3/5:ℝ)*((L:ℝ)*R)) := by + let lam : A → ℝ := fun H => (c:ℝ)*(S.filter (fun y => y≠x ∧ y.submodule ≤ LinearMap.ker H.1.rep)).card + let θ : A → A → ℝ := fun H J => pencilTheta S x c H J + have hm (H : A) : mass (radialWeight S x c) (lines x H)=lam H := + radialWeight_mass S x c H (hA H H.2) + have hscaled (D : Finset (RadialLine x)) : + mass (fun d => L*radialWeight S x c d) D=(L:ℝ)*mass (radialWeight S x c) D := by + simp only [mass,NNReal.coe_mul,Finset.mul_sum] + have hs := SharpLogRamsey.SecondMoment.prepared_pencil_second_moment + (fun d => L*radialWeight S x c d) (fun H : A => lines x H) R own + (L:ℝ) (1-f) B C lam θ T a hL (by linarith) hB hC hR + (fun H => by rw [hscaled,hm]) (fun H => hlow H H.2) (fun H => hdelta H H.2) + (by + simp only [sq_abs] + calc + _ = ∑ H∈A,((c:ℝ)*(S.filter (fun y => y≠x ∧ y.submodule ≤ LinearMap.ker H.rep)).card-(1-f))^2 := by + rw [←Finset.sum_coe_sort A (fun H => ((c:ℝ)*(S.filter (fun y => y≠x ∧ y.submodule ≤ LinearMap.ker H.rep)).card-(1-f))^2)] + _ ≤ _ := hsq) + (by + rw [Fintype.card_coe] + exact (Nat.cast_le.mpr (pencil_rank_card j hdim A x hA)).trans (by exact_mod_cast hcard)) + (fun H J => pencilTheta_nonneg S x c H J) + (fun H J => (pencilTheta_le_mass S x c H J (hA H H.2) (hA J J.2)).trans + (by rw [hm]; exact hupp H H.2)) + (fun H J hne => by + rw [hscaled,radialWeight_intersection S x c H J (hA H H.2) (hA J J.2)] + dsimp [θ,pencilTheta] + rw [ite_eq_right (fun he => hne (Subtype.ext he))]) + (fun i hi => (ha i hi).le) + (fun H J hθ => by + have hne : H.1≠J.1 := by + intro he + simp only [θ,pencilTheta,ite_eq_left he] at hθ + linarith + simp only [θ,pencilTheta,ite_eq_right hne] at hθ ⊢ + exact hcover H H.2 J J.2 hne hθ) + (fun i hi => by + rw [family_all_pairs_card A S x c (a i) (ha i hi)] + exact hcount i hi) + hd hp hb h2 + have he := (measurePreserving_uncurry_schedule + (fun d => L*radialWeight S x c d) R).integral_comp + (MeasurableEquiv.curry (Fin R) (RadialLine x) ℕ).symm.measurableEmbedding + (fun ω => (∑ H : A,scoreTerm (lines x H) (Real.exp (-(L:ℝ)*(1-f))) (own H) + (fun r d => ω (r,d)))^2) + rw [←he] + exact hs + +end +end SharpLogRamsey.PreparedProjectiveGeometry + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Entropy/TestPointMoments.lean b/lean/OAI/Combinatorics/SharpRamsey/Entropy/TestPointMoments.lean new file mode 100644 index 0000000000000000000000000000000000000000..8b99c217a96cc7c5efaf49037e9aa13eb2ab0d21 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Entropy/TestPointMoments.lean @@ -0,0 +1,94 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Entropy.TestActualSecondMoment +import OAI.Combinatorics.SharpRamsey.Geometry.TestProjectiveTail + +namespace OAI + +section +namespace SharpLogRamsey.PreparedProjectiveGeometry +open Finset MeasureTheory SharpRamseyFive.PoissonScore SharpLogRamsey.PointScore +open scoped Classical BigOperators NNReal +noncomputable section +variable {K V I : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedTestPointMoments_1 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedTestPointMoments_2 : Fintype (Projectivization K (Module.Dual K V)) := Fintype.ofFinite _ + +theorem actual_point_high_tail + (j : ℕ) (hj : 2 ≤ j) (hj3 : j ≤ 3) (hdim : Module.finrank K V ≤ j+1) + (S O : Finset (Projectivization K V)) (x : Projectivization K V) (c L : ℝ≥0) + (A : Finset (Projectivization K (Module.Dual K V))) + (hA : ∀ H∈A,x.submodule ≤ LinearMap.ker H.rep) + (f B : ℝ) (hf : f ≤ 1/25) {p : ℕ} (hp : 0 y≠x ∧ y.submodule ≤ LinearMap.ker H.rep)).card) + (hupp : ∀ H∈A,(c:ℝ)*((S\(O∪{x})).filter (fun y => y≠x ∧ y.submodule ≤ LinearMap.ker H.rep)).card ≤ 2) + (hdelta : ∀ H∈A,|(c:ℝ)*((S\(O∪{x})).filter (fun y => y≠x ∧ y.submodule ≤ LinearMap.ker H.rep)).card-(1-f)| ≤ 13/100) + (hB : Real.exp (3*((L:ℝ)*R)) ≤ B) + (hcard : ((∑ i∈range j,Nat.card K^i):ℝ) ≤ 4*B^2) + (hdir : ((∑ i∈range (j-1),Nat.card K^i):ℝ) ≤ 4*B) + (T : Finset I) (a : I → ℝ) (ha : ∀ i∈T,0 ≤ a i) + (hcover : ∀ H∈A,∀ J∈A,H≠J → 0 y≠x ∧ y.submodule ≤ LinearMap.ker H.rep)).card-(1-f))^2) ≤ B*Real.exp (((L:ℝ)*R)/100)) + (hpoly : SharpLogRamsey.MomentBudgetBridge.certificateOverhead p T.card ((L:ℝ)*R) ≤ Real.exp (2*((L:ℝ)*R)/25)) + (hshift : SharpLogRamsey.MomentBudgetBridge.shiftOverhead p T.card ≤ Real.exp (2*((L:ℝ)*R)/25)) + (hp2 : (p:ℝ)^2 ≤ Real.exp (((L:ℝ)*R)/10)) + (hps : 2*(p:ℝ)+3 ≤ Real.exp (((L:ℝ)*R)/10)) + (h : ℕ) (hh : 0 L*c)).real + {ω | (∀ r (y : S),y.1=x → ω (r,y)=0) ∧ + t ≤ |pointScore (fun y : S => y.1∈O) + (fun (H : A) (y : S) => y.1.submodule ≤ LinearMap.ker H.1.rep) + (Real.exp (-(L:ℝ)*(1-f))) ω|} + ≤ (B^p*Real.exp (-(1/10:ℝ)*(p*((L:ℝ)*R))))/t^p := by + have hB0 : 0≤B := (Real.exp_pos _).le.trans hB + apply projective_point_tail S O x c L A hA R _ p hpe t _ ht (by positivity) + intro bits + exact actual_projective_high_moment j hj hj3 hdim (S\(O∪{x})) x c L A hA f B hf hp R bits + hL hlow hupp hdelta hB hcard hdir T a ha hcover hcount hrow hstrong hsq + hpoly hshift hp2 hps h hh hR hsize herr + +theorem actual_point_second_tail + (j : ℕ) (hdim : Module.finrank K V ≤ j+1) + (S O : Finset (Projectivization K V)) (x : Projectivization K V) (c L : ℝ≥0) + (A : Finset (Projectivization K (Module.Dual K V))) + (hA : ∀ H∈A,x.submodule ≤ LinearMap.ker H.rep) + (f B C : ℝ) (hf : f ≤ 1/4) (hB : 0 ≤ B) (hC : 0 ≤ C) + (R : ℕ) (hL : 1 ≤ (L:ℝ)) (hR : 200 ≤ R) + (hlow : ∀ H∈A,3/4 ≤ (c:ℝ)*((S\(O∪{x})).filter (fun y => y≠x ∧ y.submodule ≤ LinearMap.ker H.rep)).card) + (hupp : ∀ H∈A,(c:ℝ)*((S\(O∪{x})).filter (fun y => y≠x ∧ y.submodule ≤ LinearMap.ker H.rep)).card ≤ 2) + (hdelta : ∀ H∈A,|(c:ℝ)*((S\(O∪{x})).filter (fun y => y≠x ∧ y.submodule ≤ LinearMap.ker H.rep)).card-(1-f)| ≤ 1) + (hsq : (∑ H∈A,((c:ℝ)*((S\(O∪{x})).filter (fun y => y≠x ∧ y.submodule ≤ LinearMap.ker H.rep)).card-(1-f))^2) ≤ C*B*Real.exp ((L:ℝ)/100)) + (hcard : ((∑ i∈range j,Nat.card K^i):ℝ) ≤ C*B^2) + (T : Finset I) (a : I → ℝ) (ha : ∀ i∈T,0 L*c)).real + {ω | (∀ r (y : S),y.1=x → ω (r,y)=0) ∧ + t ≤ |pointScore (fun y : S => y.1∈O) + (fun (H : A) (y : S) => y.1.submodule ≤ LinearMap.ker H.1.rep) + (Real.exp (-(L:ℝ)*(1-f))) ω|} + ≤ (B^2*Real.exp (-(3/5:ℝ)*((L:ℝ)*R)))/t^2 := by + apply projective_point_tail S O x c L A hA R _ 2 (by decide) t _ ht (by positivity) + intro bits + exact actual_projective_second_moment j hdim (S\(O∪{x})) x c L A hA f B C hf hB hC R bits + hL hR hlow hupp hdelta hsq hcard T a ha hcover hcount hd hp hb h2 + +end +end SharpLogRamsey.PreparedProjectiveGeometry + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Entropy/TestSecondMomentBase.lean b/lean/OAI/Combinatorics/SharpRamsey/Entropy/TestSecondMomentBase.lean new file mode 100644 index 0000000000000000000000000000000000000000..89de32be77ede7cac4e6f724e282b902a5e9e390 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Entropy/TestSecondMomentBase.lean @@ -0,0 +1,271 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Entropy.StrongDegreeBudget + +namespace OAI + +section +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +namespace SharpLogRamsey.SecondMoment + +open SharpRamseyFive.PoissonScore SharpRamseyFive.DyadicMoments + +variable {ι H : Type*} [Fintype ι] [DecidableEq ι] [Fintype H] + +lemma abs_pairMean_self_le (rate : ι → ℝ≥0) (s : Finset ι) + {L lam base c : ℝ} (hL : 0 ≤ L) (hbase0 : 0 ≤ base) + (hmass : mass rate s = L * lam) (hlam : c ≤ lam) (hbase : c ≤ base) : + |pairMean rate s s (Real.exp (-L * base))| ≤ 2 * Real.exp (-L * c) := by + rw [pairMean, ← integral_centeredFactor_mul] + have hb : Real.exp (-L * base) ∈ Set.Icc (0 : ℝ) 1 := + ⟨(Real.exp_pos _).le, Real.exp_le_one_iff.mpr (by nlinarith)⟩ + have hn : 0 ≤ ∫ ω, centeredFactor s (Real.exp (-L * base)) ω * + centeredFactor s (Real.exp (-L * base)) ω ∂batchMeasure rate := + integral_nonneg (fun ω => mul_self_nonneg _) + rw [abs_of_nonneg hn] + refine (integral_mono (integrable_centeredFactor_mul rate s s _) + (integrable_centeredFactor rate s _).abs ?_).trans + (integral_abs_centeredFactor_exp_le rate s hL hmass hlam hbase) + intro ω + have ha := abs_centeredFactor_le_one s _ hb ω + have he := sq_abs (centeredFactor s (Real.exp (-L * base)) ω) + nlinarith [abs_nonneg (centeredFactor s (Real.exp (-L * base)) ω)] + +theorem second_moment_finite (rate : ι → ℝ≥0) (directions : H → Finset ι) + (R : ℕ) (own : H → Fin R → Bool) (L base : ℝ) + (lam : H → ℝ) (θ : H → H → ℝ) + (hL : 1 ≤ L) (hbase : 3/4 ≤ base) + (hmass : ∀ h, mass rate (directions h) = L * lam h) + (hlam : ∀ h, 3/4 ≤ lam h) + (hθ : ∀ h k, 0 ≤ θ h k) + (hinter : ∀ h k, h ≠ k → mass rate (directions h ∩ directions k) = L * θ h k) : + (∫ ω, (typicalScore Finset.univ directions (Real.exp (-L * base)) own ω)^2 + ∂scheduleMeasure rate R) ≤ + (Fintype.card H : ℝ) * (2 * Real.exp (-L * (3/4)))^R + + (L^2 * Real.exp (-L * (3/4)))^R * 2^(R-1) * + ((∑ h, |lam h - base|^R)^2 + ∑ h, ∑ k, (θ h k)^R) := by + classical + let A := L^2 * Real.exp (-L * (3/4)) + let d := (2 * Real.exp (-L * (3/4)))^R + have hA : 0 ≤ A := by dsimp [A]; positivity + have hd : 0 ≤ d := by dsimp [d]; positivity + have hp (h k : H) : |pairMean rate (directions h) (directions k) + (Real.exp (-L * base))|^R ≤ + (if h = k then d else 0) + A^R * 2^(R-1) * + (|lam h - base|^R * |lam k - base|^R + (θ h k)^R) := by + by_cases hk : h = k + · subst k + have hg := pow_le_pow_left₀ (abs_nonneg _) (abs_pairMean_self_le rate + (directions h) (by linarith : 0 ≤ L) (by linarith : 0 ≤ base) + (hmass h) (hlam h) hbase) R + rw [ite_eq_left rfl] + exact hg.trans (le_add_of_nonneg_right (by positivity [hθ h h])) + · have hi := abs_integral_centeredFactor_mul_exp_le rate (directions h) + (directions k) hL (by norm_num : (0 : ℝ) ≤ 3/4) (hmass h) (hmass k) + (hinter h k hk) (hlam h) (hlam k) hbase + rw [integral_centeredFactor_mul] at hi + change |pairMean rate (directions h) (directions k) (Real.exp (-L * base))| ≤ + A * (|lam h - base| * |lam k - base| + θ h k) at hi + simp only [ite_eq_right hk, zero_add] + calc + _ ≤ (A * (|lam h - base| * |lam k - base| + θ h k))^R := + pow_le_pow_left₀ (abs_nonneg _) hi R + _ = A^R * (|lam h - base| * |lam k - base| + θ h k)^R := mul_pow _ _ _ + _ ≤ A^R * (2^(R-1) * ((|lam h - base| * |lam k - base|)^R + (θ h k)^R)) := + mul_le_mul_of_nonneg_left (add_pow_le (by positivity) (hθ h k) R) + (pow_nonneg hA R) + _ = _ := by rw [mul_pow]; ring + have hs := (integral_typicalScore_sq_le rate Finset.univ directions + (Real.exp (-L * base)) own).trans (Finset.sum_le_sum (fun h _ => + Finset.sum_le_sum (fun k _ => hp h k))) + apply hs.trans_eq + simp only [Finset.sum_add_distrib] + simp only [Finset.sum_ite_eq, Finset.mem_univ, ite_true, Finset.sum_const, + Finset.card_univ, nsmul_eq_mul] + simp only [← Finset.mul_sum] + simp only [Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.sum_mul, ← pow_two] + rfl + +theorem second_moment_dyadic {J : Type*} (rate : ι → ℝ≥0) + (directions : H → Finset ι) (R : ℕ) (own : H → Fin R → Bool) + (L base B C : ℝ) (lam : H → ℝ) (θ : H → H → ℝ) + (T : Finset J) (a : J → ℝ) + (hL : 1 ≤ L) (hbase : 3/4 ≤ base) (_hB : 0 ≤ B) (_hC : 0 ≤ C) + (hR : 200 ≤ R) + (hmass : ∀ h, mass rate (directions h) = L * lam h) + (hlam : ∀ h, 3/4 ≤ lam h) + (hδ : ∀ h, |lam h - base| ≤ 1) + (hδsum : (∑ h, |lam h - base|^2) ≤ C*B*Real.exp (L/100)) + (hcard : (Fintype.card H : ℝ) ≤ C*B^2) + (hθ : ∀ h k, 0 ≤ θ h k) (hθmax : ∀ h k, θ h k ≤ 2) + (hinter : ∀ h k, h ≠ k → mass rate (directions h ∩ directions k) = L * θ h k) + (ha : ∀ i ∈ T, 0 ≤ a i) + (hcover : ∀ h k, 0 < θ h k → ∃ i ∈ T, a i ≤ θ h k ∧ θ h k ≤ 2*a i) + (hcount : ∀ i ∈ T, + ((Finset.univ.filter (fun z : H × H => a i ≤ θ z.1 z.2)).card : ℝ) * + a i^200 ≤ B^2*Real.exp (L*R/50)) : + (∫ ω, (typicalScore Finset.univ directions (Real.exp (-L * base)) own ω)^2 + ∂scheduleMeasure rate R) ≤ B^2 * + (C * (2 * Real.exp (-L * (3/4)))^R + + (L^2 * Real.exp (-L * (3/4)))^R * 2^(R-1) * + (C^2 * Real.exp (L/50) + (T.card : ℝ) * 2^R * Real.exp (L*R/50))) := by + have hs : (∑ h, |lam h - base|^R) ≤ C*B*Real.exp (L/100) := by + refine (Finset.sum_le_sum (fun h _ => + pow_le_pow_of_le_one (abs_nonneg _) (hδ h) (by omega : 2 ≤ R))).trans hδsum + have hs2 : (∑ h, |lam h - base|^R)^2 ≤ B^2 * (C^2 * Real.exp (L/50)) := by + calc + _ ≤ (C*B*Real.exp (L/100))^2 := + pow_le_pow_left₀ (Finset.sum_nonneg (fun h _ => by positivity)) hs 2 + _ = _ := by rw [mul_pow, mul_pow, ← Real.exp_nat_mul]; ring_nf + have ht := higher_moment_le_of_cover (fun z : H × H => θ z.1 z.2) a T + 200 R (by decide) hR (B^2*Real.exp (L*R/50)) 2 (by positivity) (by norm_num) + (fun z => hθ z.1 z.2) (fun z => hθmax z.1 z.2) ha + (fun z => hcover z.1 z.2) hcount + have ht' : (∑ h, ∑ k, (θ h k)^R) ≤ B^2 * ((T.card : ℝ)*2^R*Real.exp (L*R/50)) := by + calc + _ ≤ (T.card : ℝ)*2^200*(B^2*Real.exp (L*R/50))*2^(R-200) := by + simpa only [Fintype.sum_prod_type] using ht + _ = _ := by + have hp : (2 : ℝ)^200*2^(R-200) = 2^R := by + rw [← pow_add, Nat.add_sub_of_le hR] + calc + _ = B^2*((T.card : ℝ)*((2 : ℝ)^200*2^(R-200))*Real.exp (L*R/50)) := by ring + _ = _ := by rw [hp] + have hd := mul_le_mul_of_nonneg_right hcard + (pow_nonneg (by positivity : 0 ≤ 2*Real.exp (-L*(3/4))) R) + have hb := add_le_add hs2 ht' + have hm := mul_le_mul_of_nonneg_left hb + (by positivity : 0 ≤ (L^2*Real.exp (-L*(3/4)))^R*2^(R-1)) + exact (second_moment_finite rate directions R own L base lam θ hL hbase + hmass hlam hθ hinter).trans ((add_le_add hd hm).trans_eq (by ring)) + +lemma second_moment_exponent (L C N : ℝ) (R : ℕ) (hL : 0 ≤ L) + (_hC : 0 ≤ C) (hN : 0 ≤ N) + (hd : C*2^R ≤ Real.exp (L*R/20)) + (hp : (2*L^2)^R ≤ Real.exp (L*R/25)) + (hb : C^2*Real.exp (L/50) + N*2^R*Real.exp (L*R/50) ≤ Real.exp (L*R/20)) + (h2 : 2 ≤ Real.exp (L*R/20)) : + C*(2*Real.exp (-L*(3/4)))^R + + (L^2*Real.exp (-L*(3/4)))^R*2^(R-1)* + (C^2*Real.exp (L/50)+N*2^R*Real.exp (L*R/50)) ≤ Real.exp (-(3/5)*(L*R)) := by + have hP : 0 ≤ L*(R : ℝ) := mul_nonneg hL (Nat.cast_nonneg R) + have he : (Real.exp (-L*(3/4)))^R = Real.exp (-(3/4)*(L*R)) := by + rw [← Real.exp_nat_mul] + congr 1 + ring + have hd' : C*(2*Real.exp (-L*(3/4)))^R ≤ Real.exp (-(13/20)*(L*R)) := by + rw [mul_pow, he, ← mul_assoc] + calc + _ ≤ Real.exp (L*R/20)*Real.exp (-(3/4)*(L*R)) := + mul_le_mul_of_nonneg_right hd (Real.exp_pos _).le + _ = Real.exp (-(7/10)*(L*R)) := by rw [← Real.exp_add]; congr 1; ring + _ ≤ _ := Real.exp_le_exp.mpr (by nlinarith) + have ho : (L^2*Real.exp (-L*(3/4)))^R*2^(R-1) ≤ + (2*L^2)^R*Real.exp (-(3/4)*(L*R)) := by + rw [mul_pow, he, mul_pow] + have hh : (2 : ℝ)^(R-1) ≤ 2^R := + pow_le_pow_right₀ (by norm_num) (Nat.sub_le R 1) + nlinarith [mul_le_mul_of_nonneg_left hh + (show 0 ≤ (L^2)^R*Real.exp (-(3/4)*(L*R)) by positivity)] + have ht : (L^2*Real.exp (-L*(3/4)))^R*2^(R-1)* + (C^2*Real.exp (L/50)+N*2^R*Real.exp (L*R/50)) ≤ Real.exp (-(13/20)*(L*R)) := by + calc + _ ≤ ((2*L^2)^R*Real.exp (-(3/4)*(L*R)))*Real.exp (L*R/20) := + mul_le_mul ho hb (by positivity) (by positivity) + _ ≤ (Real.exp (L*R/25)*Real.exp (-(3/4)*(L*R)))*Real.exp (L*R/20) := by + gcongr + _ = Real.exp (-(33/50)*(L*R)) := by + rw [← Real.exp_add, ← Real.exp_add] + congr 1 + ring + _ ≤ _ := Real.exp_le_exp.mpr (by nlinarith) + calc + _ ≤ 2*Real.exp (-(13/20)*(L*R)) := by linarith + _ ≤ Real.exp (L*R/20)*Real.exp (-(13/20)*(L*R)) := + mul_le_mul_of_nonneg_right h2 (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +lemma numerical_budgets (L C N : ℝ) (R : ℕ) (hL : 0 ≤ L) (hR : 1 ≤ R) + (hC : C ≤ Real.exp (L*R/100)) (hC2 : C^2 ≤ Real.exp (L*R/100)) + (hN : N ≤ Real.exp (L*R/100)) (hL2 : 2 ≤ Real.exp (L/100)) + (hLp : 2*L^2 ≤ Real.exp (L/25)) : + C*2^R ≤ Real.exp (L*R/20) ∧ + (2*L^2)^R ≤ Real.exp (L*R/25) ∧ + C^2*Real.exp (L/50)+N*2^R*Real.exp (L*R/50) ≤ Real.exp (L*R/20) ∧ + 2 ≤ Real.exp (L*R/20) := by + have hLR : L ≤ L*(R : ℝ) := le_mul_of_one_le_right hL (by exact_mod_cast hR) + have hP : 0 ≤ L*(R : ℝ) := mul_nonneg hL (Nat.cast_nonneg R) + have h2 : (2 : ℝ)^R ≤ Real.exp (L*R/100) := by + have hh := pow_le_pow_left₀ (by norm_num : (0 : ℝ) ≤ 2) hL2 R + rw [← Real.exp_nat_mul] at hh + convert hh using 1 + congr 1 + ring + have hsmall : 2 ≤ Real.exp (L*R/100) := + hL2.trans (Real.exp_le_exp.mpr (by linarith)) + have hfirst : C^2*Real.exp (L/50) ≤ Real.exp (L*R/25) := by + calc + _ ≤ Real.exp (L*R/100)*Real.exp (L*R/50) := by gcongr + _ = Real.exp (3*(L*R)/100) := by rw [← Real.exp_add]; congr 1; ring + _ ≤ _ := Real.exp_le_exp.mpr (by nlinarith) + have hsecond : N*2^R*Real.exp (L*R/50) ≤ Real.exp (L*R/25) := by + calc + _ ≤ Real.exp (L*R/100)*Real.exp (L*R/100)*Real.exp (L*R/50) := by + gcongr + _ = _ := by rw [← Real.exp_add, ← Real.exp_add]; congr 1; ring + refine ⟨?_, ?_, ?_, hsmall.trans (Real.exp_le_exp.mpr (by nlinarith))⟩ + · calc + _ ≤ Real.exp (L*R/100)*Real.exp (L*R/100) := by gcongr + _ = Real.exp (L*R/50) := by rw [← Real.exp_add]; congr 1; ring + _ ≤ _ := Real.exp_le_exp.mpr (by nlinarith) + · have hh := pow_le_pow_left₀ (by positivity : 0 ≤ 2*L^2) hLp R + rw [← Real.exp_nat_mul] at hh + convert hh using 1 + congr 1 + ring + · calc + _ ≤ 2*Real.exp (L*R/25) := by linarith + _ ≤ Real.exp (L*R/100)*Real.exp (L*R/25) := + mul_le_mul_of_nonneg_right hsmall (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +end SharpLogRamsey.SecondMoment + +namespace SharpLogRamsey.SecondMoment +open MeasureTheory SharpRamseyFive.PoissonScore +open scoped BigOperators NNReal +variable {ι H J : Type*} [Fintype ι] [DecidableEq ι] [Fintype H] [DecidableEq H] + +omit [DecidableEq H] in + +theorem prepared_pencil_second_moment (rate : ι → ℝ≥0) (directions : H → Finset ι) + (R : ℕ) (own : H → Fin R → Bool) (L base B C : ℝ) + (lam : H → ℝ) (θ : H → H → ℝ) (T : Finset J) (a : J → ℝ) + (hL : 1 ≤ L) (hbase : 3/4 ≤ base) (hB : 0 ≤ B) (hC : 0 ≤ C) (hR : 200 ≤ R) + (hmass : ∀ h, mass rate (directions h) = L * lam h) + (hlam : ∀ h, 3/4 ≤ lam h) (hδ : ∀ h, |lam h - base| ≤ 1) + (hδsum : (∑ h, |lam h - base|^2) ≤ C*B*Real.exp (L/100)) + (hcard : (Fintype.card H : ℝ) ≤ C*B^2) + (hθ : ∀ h k, 0 ≤ θ h k) (hθmax : ∀ h k, θ h k ≤ 2) + (hinter : ∀ h k, h ≠ k → mass rate (directions h ∩ directions k) = L * θ h k) + (ha : ∀ i ∈ T, 0 ≤ a i) + (hcover : ∀ h k, 0 < θ h k → ∃ i ∈ T, a i ≤ θ h k ∧ θ h k ≤ 2*a i) + (hcount : ∀ i ∈ T, + ((Finset.univ.filter (fun z : H × H => a i ≤ θ z.1 z.2)).card : ℝ)*a i^200 ≤ + B^2*Real.exp (L*R/50)) + (hd : C*2^R ≤ Real.exp (L*R/20)) + (hp : (2*L^2)^R ≤ Real.exp (L*R/25)) + (hb : C^2*Real.exp (L/50)+(T.card : ℝ)*2^R*Real.exp (L*R/50) ≤ Real.exp (L*R/20)) + (h2 : 2 ≤ Real.exp (L*R/20)) : + (∫ ω, (typicalScore Finset.univ directions (Real.exp (-L * base)) own ω)^2 + ∂scheduleMeasure rate R) ≤ B^2*Real.exp (-(3/5)*(L*R)) := by + exact (second_moment_dyadic rate directions R own L base B C lam θ T a + hL hbase hB hC hR hmass hlam hδ hδsum hcard hθ hθmax hinter ha hcover hcount).trans + (mul_le_mul_of_nonneg_left (second_moment_exponent L C T.card R (by linarith) + hC (Nat.cast_nonneg _) hd hp hb h2) (sq_nonneg B)) + +end SharpLogRamsey.SecondMoment + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Entropy/TreeCodeEntropy.lean b/lean/OAI/Combinatorics/SharpRamsey/Entropy/TreeCodeEntropy.lean new file mode 100644 index 0000000000000000000000000000000000000000..35f76a8d6f3261523f042b6af3d26f453cd7701b --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Entropy/TreeCodeEntropy.lean @@ -0,0 +1,132 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Trees.TreeDecoder +import OAI.Combinatorics.SharpRamsey.Entropy.ProtocolEntropy + +namespace OAI + +section +namespace SharpLogRamsey.TreeCodeEntropy +open Finset Real BinaryTree TreeDecoder +open scoped Classical +noncomputable section +variable {A B C : Type*} + +def codes (allowed : Domains A B→Finset C) (read : CapReader A B C) : + BinaryTree Unit→Domains A B→Finset (BinaryTree C) + | .nil,_ => {.nil} + | .node _ l r,U => (allowed U).biUnion (fun c=> + ((codes allowed read l ((read U c).1,U.2)) ×ˢ + (codes allowed read r (U.1,(read U c).2))).image + (fun z=>.node c z.1 z.2)) + +def cost (allowed : Domains A B→Finset C) (read : CapReader A B C) : + BinaryTree C→Domains A B→ℝ + | .nil,_ => 0 + | .node c l r,U => log (allowed U).card+ + cost allowed read l ((read U c).1,U.2)+cost allowed read r (U.1,(read U c).2) + +lemma weight_node (allowed : Domains A B→Finset C) (read : CapReader A B C) + (c : C) (l r : BinaryTree C) (U : Domains A B) : + exp (-cost allowed read (.node c l r) U)= + exp (-log (allowed U).card)*exp (-cost allowed read l ((read U c).1,U.2))* + exp (-cost allowed read r (U.1,(read U c).2)) := by + simp only [cost,neg_add,exp_add] + +theorem kraft (allowed : Domains A B→Finset C) (read : CapReader A B C) + (shape : BinaryTree Unit) (U : Domains A B) : + (∑ t∈codes allowed read shape U,exp (-cost allowed read t U))≤1 := by + induction shape generalizing U with + | nil => simp [codes,cost] + | node v l r hl hr => + rw [codes] + rw [sum_biUnion] + rotate_left + · intro c hc c' hc' hne + apply disjoint_left.mpr + intro t ht ht' + obtain ⟨z,hz,rfl⟩ := mem_image.mp ht + obtain ⟨z',hz',he⟩ := mem_image.mp ht' + exact hne (BinaryTree.node.inj he).1.symm + have hone (c : C) : + ∑ t∈(((codes allowed read l ((read U c).1,U.2)) ×ˢ + (codes allowed read r (U.1,(read U c).2))).image + (fun z=>BinaryTree.node c z.1 z.2)),exp (-cost allowed read t U) ≤ + exp (-log (allowed U).card) := by + rw [sum_image] + · simp_rw [weight_node] + rw [sum_product] + simp_rw [←mul_sum] + rw [←sum_mul,←mul_sum] + have hL := hl ((read U c).1,U.2) + have hR := hr (U.1,(read U c).2) + have hLn : 0≤∑ t∈codes allowed read l ((read U c).1,U.2), + exp (-cost allowed read t ((read U c).1,U.2)) := sum_nonneg (fun _ _=>(exp_pos _).le) + have hRn : 0≤∑ t∈codes allowed read r (U.1,(read U c).2), + exp (-cost allowed read t (U.1,(read U c).2)) := sum_nonneg (fun _ _=>(exp_pos _).le) + nlinarith [exp_pos (-log (allowed U).card),mul_le_mul hL hR hRn (by norm_num : (0:ℝ)≤1)] + · intro z hz z' hz' he + exact Prod.ext (BinaryTree.node.inj he).2.1 (BinaryTree.node.inj he).2.2 + apply (sum_le_sum (fun c _=>hone c)).trans + by_cases he : (allowed U).card=0 + · simp [card_eq_zero.mp he] + · have hp : (0:ℝ)<(allowed U).card := by exact_mod_cast Nat.pos_of_ne_zero he + simp only [sum_const,nsmul_eq_mul] + rw [exp_neg,exp_log hp] + exact le_of_eq (mul_inv_cancel₀ hp.ne') + +theorem card_le_exp (allowed : Domains A B→Finset C) (read : CapReader A B C) + (shape : BinaryTree Unit) (U : Domains A B) (K : ℝ) + (hK : ∀ t∈codes allowed read shape U,cost allowed read t U≤K) : + ((codes allowed read shape U).card:ℝ)≤exp K := by + have hh : ((codes allowed read shape U).card:ℝ)*exp (-K)≤1 := by + calc + _ = ∑ _t∈codes allowed read shape U,exp (-K) := by simp + _ ≤ ∑ t∈codes allowed read shape U,exp (-cost allowed read t U) := + sum_le_sum (fun t ht=>exp_le_exp.mpr (neg_le_neg (hK t ht))) + _ ≤ 1 := kraft allowed read shape U + have hm := mul_le_mul_of_nonneg_right hh (exp_pos K).le + rw [mul_assoc,←exp_add,neg_add_cancel,exp_zero,mul_one,one_mul] at hm + exact hm + +theorem card_subset_le_exp (allowed : Domains A B→Finset C) (read : CapReader A B C) + (shape : BinaryTree Unit) (U : Domains A B) (S : Finset (BinaryTree C)) (K : ℝ) + (hS : S⊆codes allowed read shape U) + (hK : ∀ t∈S,cost allowed read t U≤K) : (S.card:ℝ)≤exp K := by + have hh : (S.card:ℝ)*exp (-K)≤1 := by + calc + _ = ∑ _t∈S,exp (-K) := by simp + _ ≤ ∑ t∈S,exp (-cost allowed read t U) := + sum_le_sum (fun t ht=>exp_le_exp.mpr (neg_le_neg (hK t ht))) + _ ≤ ∑ t∈codes allowed read shape U,exp (-cost allowed read t U) := + sum_le_sum_of_subset_of_nonneg hS (fun _ _ _=>(exp_pos _).le) + _ ≤ 1 := kraft allowed read shape U + have hm := mul_le_mul_of_nonneg_right hh (exp_pos K).le + rw [mul_assoc,←exp_add,neg_add_cancel,exp_zero,mul_one,one_mul] at hm + exact hm + +variable {Ω : Type*} [Fintype Ω] + +theorem entropy_le (p : Selection.Law Ω) (allowed : Domains A B→Finset C) + (read : CapReader A B C) (shape : BinaryTree Unit) (U : Domains A B) (K : ℝ) + (F : Ω→codes allowed read shape U) + (hK : ∀ t∈codes allowed read shape U,cost allowed read t U≤K) : + Selection.entropy (p.map F)≤K := by + have hn : 0<(codes allowed read shape U).card := by + by_contra! hn + have hz : codes allowed read shape U=∅ := card_eq_zero.mp (by omega) + have ht : ∑ x,p.mass x=0 := by + apply sum_eq_zero + intro x _ + exact False.elim (by simpa [hz] using (F x).property) + linarith [p.total] + have h := Selection.entropy_le_log_card (p.map F) univ (fun x hx=>False.elim (hx (mem_univ x))) + simp only [card_univ,Fintype.card_coe] at h + apply h.trans + exact (log_le_iff_le_exp (by exact_mod_cast hn)).mpr (card_le_exp allowed read shape U K hK) + +end +end SharpLogRamsey.TreeCodeEntropy + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Entropy/TreeMessageEntropy.lean b/lean/OAI/Combinatorics/SharpRamsey/Entropy/TreeMessageEntropy.lean new file mode 100644 index 0000000000000000000000000000000000000000..5f16f27ad34c6414d0b8917ce1f341953a30e1c7 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Entropy/TreeMessageEntropy.lean @@ -0,0 +1,92 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Entropy.TreeCodeEntropy +import OAI.Combinatorics.SharpRamsey.Trees.TreeShapes + +namespace OAI + +section +namespace SharpLogRamsey.TreeCodeEntropy +open Finset Real BinaryTree TreeDecoder +open scoped Classical +noncomputable section +variable {A B C Γ : Type*} [Fintype Γ] + +def shape (t : BinaryTree C) : BinaryTree Unit := t.map (fun _=>()) + +omit [Fintype Γ] in +lemma shape_numNodes (t : BinaryTree C) : (shape t).numNodes=t.numNodes := by + induction t with + | nil => rfl + | node _ l r hl hr => simpa only [shape,BinaryTree.map,numNodes] using congrArg₂ (fun x y=>x+y+1) hl hr + +theorem tree_message_entropy (p : Selection.Law Γ) + (allowed : Domains A B→Finset C) (read : CapReader A B C) (U : Domains A B) + (m : Γ→BinaryTree C) (hinj : Function.Injective m) (N : ℕ) (K : ℝ) + (hN : ∀ g,(m g).numNodes≤N) + (hmem : ∀ g,m g∈codes allowed read (shape (m g)) U) + (hK : ∀ g,cost allowed read (m g) U≤K) : + Selection.entropy p≤((2*N+1:ℕ):ℝ)*log 2+K := by + let R := univ.image (fun g=>shape (m g)) + let ctx : Γ→R := fun g=>⟨shape (m g),mem_image.mpr ⟨g,mem_univ _,rfl⟩⟩ + have hc (c : R) (hc : (p.map ctx).mass c≠0) : Selection.entropy (p.cond ctx c)≤K := by + let S := univ.filter (fun g=>shape (m g)=c.val) + let T := S.image m + have hT : T⊆codes allowed read c.val U := by + intro t ht + obtain ⟨g,hg,rfl⟩ := mem_image.mp ht + have he := (mem_filter.mp hg).2 + simpa only [he] using hmem g + have hTK : ∀ t∈T,cost allowed read t U≤K := by + intro t ht + obtain ⟨g,hg,rfl⟩ := mem_image.mp ht + exact hK g + have hcard : (S.card:ℝ)≤exp K := by + have h := card_subset_le_exp allowed read c.val U T K hT hTK + simpa only [T,card_image_of_injective S hinj] using h + have hp : S.Nonempty := by + obtain ⟨g,hg,he⟩ := mem_image.mp c.property + exact ⟨g,mem_filter.mpr ⟨mem_univ _,he⟩⟩ + have hb := Selection.entropy_le_log_card (p.cond ctx c) S (by + intro g hg + by_contra hn + obtain ⟨hg',he⟩ := p.cond_support ctx c hc g hn + have hv := congrArg Subtype.val he + exact hg (mem_filter.mpr ⟨mem_univ _,hv⟩)) + exact hb.trans ((log_le_iff_le_exp (by exact_mod_cast card_pos.mpr hp)).mpr hcard) + have hhead : Selection.entropy (p.map ctx)≤((2*N+1:ℕ):ℝ)*log 2 := by + have h := Selection.entropy_le_log_card (p.map ctx) univ + (fun c hc=>False.elim (hc (mem_univ c))) + simp only [card_univ,Fintype.card_coe] at h + have hR : R.Nonempty := by + have hn : (univ:Finset Γ).Nonempty := by + by_contra hn + have hz : (univ:Finset Γ)=∅ := not_nonempty_iff_eq_empty.mp hn + have ht := p.total + rw [hz,sum_empty] at ht + norm_num at ht + exact hn.image _ + have hs : R.card≤2^(2*N+1) := TreeShapes.card_le N R (by + intro t ht + obtain ⟨g,hg,rfl⟩ := mem_image.mp ht + simpa only [shape_numNodes] using hN g) + apply h.trans + have hpow : (R.card:ℝ)≤(2:ℝ)^(2*N+1) := by exact_mod_cast hs + have hh := log_le_log (show (0:ℝ) allTrunc R J ω * + ∏ v, scoreTerm (s (f v)) b (own (f v)) (fun r d => ω (r,d))) + (batchMeasure (fun i : Fin R × D => rate i.2)) := by + apply Integrable.of_bound (measurable_of_countable _).aestronglyMeasurable 1 + exact Filter.Eventually.of_forall (fun ω => by + simpa only [Real.norm_eq_abs] using truncated_tuple_abs_le R s b own J hb f ω) + +omit [DecidableEq H] in + +theorem integral_truncated_score_pow (weight rate : D → ℝ≥0) (t : ℝ) (J p : ℕ) + (hb : b ∈ Set.Icc (0 : ℝ) 1) : + (∫ ω, allTrunc R J ω * + (∑ h : H, scoreTerm (s h) b (own h) (fun r d => ω (r,d))) ^ p + ∂batchMeasure (fun i : Fin R × D => rate i.2)) = + ∑ f : Fin p → H, strongSplit R (s ∘ f) b (own ∘ f) weight rate t J := by + have hp (ω : Fin R × D → ℕ) : + (∑ h : H, scoreTerm (s h) b (own h) (fun r d => ω (r,d))) ^ p = + ∑ f : Fin p → H, ∏ v, scoreTerm (s (f v)) b (own (f v)) (fun r d => ω (r,d)) := by + simpa using Finset.sum_pow' Finset.univ + (fun h : H => scoreTerm (s h) b (own h) (fun r d => ω (r,d))) p + simp_rw [hp, Finset.mul_sum] + rw [integral_finsetSum _ (fun f _ => truncated_tuple_integrable R s b own rate J hb f)] + apply Finset.sum_congr rfl + intro f _ + exact strong_tuple_integral_split R (s ∘ f) b (own ∘ f) weight rate t J hb + +variable {V : Type} [Fintype V] [DecidableEq V] + +noncomputable def absSplit (f : V → H) (weight rate : D → ℝ≥0) (t : ℝ) (J : ℕ) : ℝ := by + let sf := s ∘ f + let G := strongGraph weight sf t + let label := componentLabel weight sf t + exact ∫ z, blockTrunc label R J none z * ∏ c : G.ConnectedComponent, + |∫ x, componentFactor label R G.connectedComponentMk sf b (own ∘ f) J c z x + ∂batchMeasure (fun i : Block label R (some c) => rate i.1.2)| + ∂batchMeasure (fun i : Block label R none => rate i.1.2) +omit [DecidableEq V] in +omit [DecidableEq D] in + +lemma integral_abs_component_le_one {C : Type} [Fintype C] [DecidableEq C] + (label : D → Option C) (col : V → C) (sf : V → Finset D) + (of : V → Fin R → Bool) (rate : D → ℝ≥0) (J : ℕ) + (hb : b ∈ Set.Icc (0 : ℝ) 1) (c : C) (z : Block label R none → ℕ) : + |∫ x, componentFactor label R col sf b of J c z x + ∂batchMeasure (fun i : Block label R (some c) => rate i.1.2)| ≤ 1 := by + have hi : Integrable (fun x => |componentFactor label R col sf b of J c z x|) + (batchMeasure (fun i : Block label R (some c) => rate i.1.2)) := by + apply Integrable.of_bound (measurable_of_countable _).aestronglyMeasurable 1 + exact Filter.Eventually.of_forall (fun x => by + simpa only [Real.norm_eq_abs, abs_abs] using + componentFactor_bound label R col sf b of J hb c z x) + calc + _ ≤ ∫ x, |componentFactor label R col sf b of J c z x| + ∂batchMeasure (fun i : Block label R (some c) => rate i.1.2) := abs_integral_le_integral_abs + _ ≤ ∫ _, (1 : ℝ) ∂batchMeasure (fun i : Block label R (some c) => rate i.1.2) := + integral_mono hi (integrable_const _) (componentFactor_bound label R col sf b of J hb c z) + _ = 1 := by simp + +omit [Fintype H] [DecidableEq H] in +lemma absSplit_nonneg (f : V → H) (weight rate : D → ℝ≥0) (t : ℝ) (J : ℕ) : + 0 ≤ absSplit R s b own f weight rate t J := by + unfold absSplit + apply integral_nonneg + intro z + exact mul_nonneg (blockTrunc_range _ R J none z).1 (Finset.prod_nonneg (fun _ _ => abs_nonneg _)) + +omit [Fintype H] [DecidableEq H] in +lemma strongSplit_abs_le (f : V → H) (weight rate : D → ℝ≥0) (t : ℝ) (J : ℕ) + (_hb : b ∈ Set.Icc (0 : ℝ) 1) : + |strongSplit R (s ∘ f) b (own ∘ f) weight rate t J| ≤ + absSplit R s b own f weight rate t J := by + unfold strongSplit absSplit + apply (abs_integral_le_integral_abs).trans_eq + apply integral_congr_ae + apply Filter.Eventually.of_forall + intro z + dsimp only + rw [abs_mul, abs_of_nonneg (blockTrunc_range _ R J none z).1, Finset.abs_prod] + +omit [DecidableEq H] in + +theorem truncated_moment_le_tuple_sum (weight rate : D → ℝ≥0) (t : ℝ) (J p : ℕ) + (hb : b ∈ Set.Icc (0 : ℝ) 1) : + (∫ ω, allTrunc R J ω * + (∑ h : H, scoreTerm (s h) b (own h) (fun r d => ω (r,d))) ^ p + ∂batchMeasure (fun i : Fin R × D => rate i.2)) ≤ + ∑ f : Fin p → H, absSplit R s b own f weight rate t J := by + rw [integral_truncated_score_pow R s b own weight rate t J p hb] + apply Finset.sum_le_sum + intro f _ + exact (le_abs_self _).trans (strongSplit_abs_le R s b own f weight rate t J hb) + +theorem truncated_moment_le_representative_sum (weight rate : D → ℝ≥0) (t : ℝ) (J p : ℕ) + (hb : b ∈ Set.Icc (0 : ℝ) 1) : + (∫ ω, allTrunc R J ω * + (∑ h : H, scoreTerm (s h) b (own h) (fun r d => ω (r,d))) ^ p + ∂batchMeasure (fun i : Fin R × D => rate i.2)) ≤ + ∑ r : TupleMultiplicity.RepresentativeMap (Fin p), + ∑ h : TupleMultiplicity.Representatives r ↪ H, + absSplit R s b own (TupleMultiplicity.decode r h) weight rate t J := by + apply (truncated_moment_le_tuple_sum R s b own weight rate t J p hb).trans + convert TupleMultiplicity.sum_tuples_le_representative_assignments (V := Fin p) (H := H) _ + (fun f : Fin p → H => absSplit_nonneg R s b own f weight rate t J) using 1 + apply Finset.sum_congr (by ext; simp) + intro representative _ + rfl + +end SharpRamseyFive.HighMoment + +namespace SharpRamseyFive.Designations +open MeasureTheory +open scoped BigOperators +open Classical +variable {C Ω : Type*} [Fintype C] [DecidableEq C] + +noncomputable def badIndicator (bad : C → Ω → Prop) (c : C) (z : Ω) : ℝ := + if bad c z then 1 else 0 + +omit [Fintype C] [DecidableEq C] in +lemma badIndicator_range (bad : C → Ω → Prop) (c : C) (z : Ω) : + badIndicator bad c z ∈ Set.Icc (0 : ℝ) 1 := by + unfold badIndicator + split_ifs <;> constructor <;> norm_num + +lemma product_expansion (S : Finset C) (A N : ℝ) (w : C → ℝ) + (bad : C → Ω → Prop) (T : Ω → ℝ) (z : Ω) : + T z * ∏ c : C, (if c ∈ S then A * (w c + badIndicator bad c z) else N) = + (A ^ S.card * N ^ (Fintype.card C - S.card)) * + ∑ U ∈ S.powerset, (∏ c ∈ S \ U, w c) * (T z * ∏ c ∈ U, badIndicator bad c z) := by + have hf : Finset.univ.filter (fun c : C => c ∈ S) = S := by ext; simp + have hg : Finset.univ.filter (fun c : C => c ∉ S) = Finset.univ \ S := by ext; simp + rw [Finset.prod_ite, hf, hg, Finset.prod_mul_distrib, Finset.prod_const, + Finset.prod_const, Finset.card_sdiff_of_subset (Finset.subset_univ _), Finset.card_univ] + have ha : (∏ c ∈ S, (w c + badIndicator bad c z)) = + ∑ U ∈ S.powerset, (∏ c ∈ U, badIndicator bad c z) * ∏ c ∈ S \ U, w c := by + rw [← Finset.prod_add] + apply Finset.prod_congr rfl + intro c _ + exact add_comm _ _ + rw [ha, Finset.mul_sum, Finset.mul_sum, Finset.sum_mul, Finset.mul_sum] + apply Finset.sum_congr rfl + intro U _ + ring + +variable [MeasurableSpace Ω] [Countable Ω] [MeasurableSingletonClass Ω] + (μ : Measure Ω) [IsProbabilityMeasure μ] + +noncomputable def badMass (T : Ω → ℝ) (bad : C → Ω → Prop) (U : Finset C) : ℝ := + ∫ z, T z * ∏ c ∈ U, badIndicator bad c z ∂μ + +omit [MeasurableSpace Ω] [Countable Ω] [MeasurableSingletonClass Ω] in +omit [Fintype C] [DecidableEq C] in +lemma badTerm_range (T : Ω → ℝ) (hT : ∀ z, T z ∈ Set.Icc (0 : ℝ) 1) + (bad : C → Ω → Prop) (U : Finset C) (z : Ω) : + T z * ∏ c ∈ U, badIndicator bad c z ∈ Set.Icc (0 : ℝ) 1 := by + constructor + · exact mul_nonneg (hT z).1 (Finset.prod_nonneg (fun c _ => (badIndicator_range bad c z).1)) + · exact (mul_le_of_le_one_left + (Finset.prod_nonneg (fun component _ => (badIndicator_range bad component z).1)) + (hT z).2).trans + (Finset.prod_le_one₀ (fun component _ => (badIndicator_range bad component z).1) + (fun component _ => (badIndicator_range bad component z).2)) +omit [Fintype C] [DecidableEq C] in + +lemma badTerm_integrable (T : Ω → ℝ) (hT : ∀ z, T z ∈ Set.Icc (0 : ℝ) 1) + (bad : C → Ω → Prop) (U : Finset C) : + Integrable (fun z => T z * ∏ c ∈ U, badIndicator bad c z) μ := by + apply Integrable.of_bound (measurable_of_countable _).aestronglyMeasurable 1 + exact Filter.Eventually.of_forall (fun z => by + rw [Real.norm_eq_abs, abs_of_nonneg (badTerm_range T hT bad U z).1] + exact (badTerm_range T hT bad U z).2) + +omit [IsProbabilityMeasure μ] in +omit [Countable Ω] [MeasurableSingletonClass Ω] in +omit [Fintype C] [DecidableEq C] in +lemma badMass_nonneg (T : Ω → ℝ) (hT : ∀ z, T z ∈ Set.Icc (0 : ℝ) 1) + (bad : C → Ω → Prop) (U : Finset C) : 0 ≤ badMass μ T bad U := + integral_nonneg (fun z => (badTerm_range T hT bad U z).1) + +lemma majorant_integrable (S : Finset C) (A N : ℝ) (w : C → ℝ) + (bad : C → Ω → Prop) (T : Ω → ℝ) (hT : ∀ z, T z ∈ Set.Icc (0 : ℝ) 1) : + Integrable (fun z => T z * ∏ c : C, + if c ∈ S then A * (w c + badIndicator bad c z) else N) μ := by + simp_rw [product_expansion] + exact (integrable_finsetSum _ (fun U _ => + (badTerm_integrable μ T hT bad U).const_mul (∏ c ∈ S \ U, w c))).const_mul _ + +lemma integral_expansion (S : Finset C) (A N : ℝ) (w : C → ℝ) + (bad : C → Ω → Prop) (T : Ω → ℝ) (hT : ∀ z, T z ∈ Set.Icc (0 : ℝ) 1) : + (∫ z, T z * ∏ c : C, + if c ∈ S then A * (w c + badIndicator bad c z) else N ∂μ) = + (A ^ S.card * N ^ (Fintype.card C - S.card)) * + ∑ U ∈ S.powerset, (∏ c ∈ S \ U, w c) * badMass μ T bad U := by + simp_rw [product_expansion] + rw [integral_const_mul, integral_finsetSum _ (fun U _ => + (badTerm_integrable μ T hT bad U).const_mul (∏ c ∈ S \ U, w c))] + simp_rw [integral_const_mul] + rfl + +theorem integral_product_le (S : Finset C) (A N : ℝ) (w : C → ℝ) + (bad : C → Ω → Prop) (T : Ω → ℝ) (hT : ∀ z, T z ∈ Set.Icc (0 : ℝ) 1) + (F : C → Ω → ℝ) (hF : ∀ c z, F c z ∈ Set.Icc (0 : ℝ) 1) + (hs : ∀ c ∈ S, ∀ z, F c z ≤ A * (w c + badIndicator bad c z)) + (hn : ∀ c ∉ S, ∀ z, F c z ≤ N) : + (∫ z, T z * ∏ c, F c z ∂μ) ≤ + (A ^ S.card * N ^ (Fintype.card C - S.card)) * + ∑ U ∈ S.powerset, (∏ c ∈ S \ U, w c) * badMass μ T bad U := by + rw [← integral_expansion μ S A N w bad T hT] + have hi : Integrable (fun z => T z * ∏ c, F c z) μ := by + apply Integrable.of_bound (measurable_of_countable _).aestronglyMeasurable 1 + apply Filter.Eventually.of_forall + intro z + rw [Real.norm_eq_abs, abs_of_nonneg (mul_nonneg (hT z).1 + (Finset.prod_nonneg (fun c _ => (hF c z).1)))] + exact (mul_le_of_le_one_left + (Finset.prod_nonneg (fun component _ => (hF component z).1)) (hT z).2).trans + (Finset.prod_le_one₀ (fun component _ => (hF component z).1) + (fun component _ => (hF component z).2)) + apply integral_mono hi (majorant_integrable μ S A N w bad T hT) + intro z + apply mul_le_mul_of_nonneg_left _ (hT z).1 + apply Finset.prod_le_prod₀ (fun component _ => (hF component z).1) + intro c _ + split_ifs with hc + · exact hs c hc z + · exact hn c hc z + +end SharpRamseyFive.Designations + +namespace SharpRamseyFive.AmbientDesignations +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open SharpRamseyFive.PoissonScore SharpRamseyFive.TupleComponents +open SharpRamseyFive.Designations +open Classical +variable {D V : Type} [Fintype D] [DecidableEq D] [Fintype V] [DecidableEq V] +variable (weight : D → ℝ≥0) (s : V → Finset D) (t : ℝ) + +abbrev Components := (strongGraph weight s t).ConnectedComponent +noncomputable def vertex (c : Components weight s t) : V := c.out +omit [Fintype D] [Fintype V] [DecidableEq V] in +lemma vertex_color (c : Components weight s t) : + (strongGraph weight s t).connectedComponentMk (vertex weight s t c) = c := + c.out_eq + +noncomputable def simpleSet : Finset (Components weight s t) := + Finset.univ.filter (fun c => ∀ v, (strongGraph weight s t).connectedComponentMk v = c → + v = vertex weight s t c) + +noncomputable def alpha (v : V) : ℝ := mass weight (externalPart weight s t v) +noncomputable def delta (base : ℝ) (v : V) : ℝ := mass weight (s v) - base + +omit [Fintype V] [DecidableEq V] in +omit [Fintype D] in +lemma alpha_nonneg (v : V) : 0 ≤ alpha weight s t v := mass_nonneg weight _ +omit [Fintype D] in + +lemma source_alpha_le {p : ℕ} (hp : 0 < p) (hc : Fintype.card V ≤ p) (v : V) : + alpha weight s (1 / (100 * p)) v ≤ (1 / 100 : ℝ) := by + have hl := external_mass_le weight s (show (0 : ℝ) ≤ 1 / (100 * p : ℝ) by positivity) v + have hcr : ((Fintype.card V - 1 : ℕ) : ℝ) ≤ p := by + exact_mod_cast (Nat.sub_le (Fintype.card V) 1).trans hc + have hpr : (0 : ℝ) < p := by exact_mod_cast hp + have he : (p : ℝ) * (1 / (100 * p : ℝ)) = 1 / 100 := by field_simp + exact hl.trans ((mul_le_mul_of_nonneg_right hcr (by positivity)).trans_eq he) +omit [Fintype D] [Fintype V] [DecidableEq V] in + +lemma internal_mass_eq (base : ℝ) (v : V) : + mass weight (internalPart weight s t v) = + base + delta weight s base v - alpha weight s t v := by + have he := internal_external_mass weight s t v + dsimp [delta, alpha] + linarith +omit [Fintype D] in + +lemma source_local_data {p : ℕ} (hp : 0 < p) (hc : Fintype.card V ≤ p) + (base : ℝ) (hlower : ∀ v, (3 / 4 : ℝ) ≤ mass weight (s v)) + (hdelta : ∀ v, |delta weight s base v| ≤ (17 / 100 : ℝ)) (v : V) : + (37 / 50 : ℝ) ≤ base + delta weight s base v - alpha weight s (1 / (100 * p)) v ∧ + |delta weight s base v| + alpha weight s (1 / (100 * p)) v ≤ 1 := by + constructor + · rw [← internal_mass_eq] + exact source_internal_mass_lower weight s hp hc hlower v + · have ha := source_alpha_le weight s hp hc v + have hd := hdelta v + linarith + +variable (R J K : ℕ) (L : ℝ≥0) (base : ℝ) (own : V → Fin R → Bool) + +noncomputable def extraWeight (c : Components weight s t) : ℝ := + |delta weight s base (vertex weight s t c)| ^ (R / 2) + + alpha weight s t (vertex weight s t c) ^ K + + (if R < J then 0 else + ∑ d ∈ inside (componentLabel weight s t) c (s (vertex weight s t c)), + ((R : ℝ) * ((L * weight d : ℝ≥0) : ℝ)) ^ J) + +noncomputable def isBad (c : Components weight s t) + (z : Block (componentLabel weight s t) R none → ℕ) : Prop := + BAD (touched (componentLabel weight s t) R c (s (vertex weight s t c)) z) + +noncomputable def componentAbs (c : Components weight s t) + (z : Block (componentLabel weight s t) R none → ℕ) : ℝ := + |∫ x, componentFactor (componentLabel weight s t) R + (strongGraph weight s t).connectedComponentMk s (Real.exp (-(L : ℝ) * base)) own J c z x + ∂batchMeasure (fun i : Block (componentLabel weight s t) R (some c) => L * weight i.1.2)| +omit [DecidableEq V] in + +lemma scaled_internal (c : Components weight s t) : + mass (fun d : IntDir (componentLabel weight s t) c => L * weight d) + (inside (componentLabel weight s t) c (s (vertex weight s t c))) = + (L : ℝ) * (base + delta weight s base (vertex weight s t c) - + alpha weight s t (vertex weight s t c)) := by + have he := mass_inside_eq weight (fun d => L * weight d) s t (vertex weight s t c) + rw [vertex_color] at he + rw [he, mass_scaled, internal_mass_eq weight s t base] + +lemma componentAbs_range (hbase : (23 / 25 : ℝ) ≤ base) + (c : Components weight s t) (z : Block (componentLabel weight s t) R none → ℕ) : + componentAbs weight s t R J L base own c z ∈ Set.Icc (0 : ℝ) 1 := by + constructor + · exact abs_nonneg _ + · change |∫ x, componentFactor (componentLabel weight s t) R + (strongGraph weight s t).connectedComponentMk s (Real.exp (-(L : ℝ) * base)) own J c z x + ∂batchMeasure (fun i : Block (componentLabel weight s t) R (some c) => L * weight i.1.2)| ≤ 1 + apply SharpRamseyFive.HighMoment.integral_abs_component_le_one R + (Real.exp (-(L : ℝ) * base)) (componentLabel weight s t) + (strongGraph weight s t).connectedComponentMk s own (fun d => L * weight d) J + refine ⟨(Real.exp_pos _).le, Real.exp_le_one_iff.mpr ?_⟩ + have hb : 0 ≤ base := by linarith + simpa only [neg_mul] using neg_nonpos.mpr (mul_nonneg L.coe_nonneg hb) + +lemma simple_bound {p : ℕ} (hp : 0 < p) (hc : Fintype.card V ≤ p) + (hL : 10000 ≤ (L : ℝ)) (hbase : (23 / 25 : ℝ) ≤ base) + (hlower : ∀ v, (3 / 4 : ℝ) ≤ mass weight (s v)) + (hdelta : ∀ v, |delta weight s base v| ≤ (17 / 100 : ℝ)) (hK : K ≤ R / 2) + (c : Components weight s (1 / (100 * p))) + (hs : c ∈ simpleSet weight s (1 / (100 * p))) + (z : Block (componentLabel weight s (1 / (100 * p))) R none → ℕ) : + componentAbs weight s (1 / (100 * p)) R J L base own c z ≤ + Real.exp (-(17 / 25 : ℝ) * ((L : ℝ) * R)) * + (extraWeight weight s (1 / (100 * p)) R J K L base c + + badIndicator (isBad weight s (1 / (100 * p)) R) c z) := by + let v := vertex weight s (1 / (100 * p)) c + have hv : (strongGraph weight s (1 / (100 * p))).connectedComponentMk v = c := + vertex_color weight s (1 / (100 * p)) c + have hs' : ∀ u, (strongGraph weight s (1 / (100 * p))).connectedComponentMk u = c → u = v := + (Finset.mem_filter.mp hs).2 + have hi := simple_inside_univ s weight (1 / (100 * p)) v (by + intro u hu + exact hs' u (hu.trans hv)) + rw [hv] at hi + have hm := source_local_data weight s hp hc base hlower hdelta v + exact simple_component_designations (componentLabel weight s (1 / (100 * p))) R + (strongGraph weight s (1 / (100 * p))).connectedComponentMk s own (fun d => L * weight d) + J c ⟨v,hv⟩ hs' (fun d hd => by + simpa only [hv] using direction_internal_or_external weight s (1 / (100 * p)) hd) + hi z hL (scaled_internal weight s (1 / (100 * p)) L base c) + hm.1 (by linarith) (alpha_nonneg weight s _ v) hm.2 hK + +lemma nonsimple_bound {p : ℕ} (hp : 0 < p) (hc : Fintype.card V ≤ p) + (hL : 10000 ≤ (L : ℝ)) (hbase : (23 / 25 : ℝ) ≤ base) + (hlower : ∀ v, (3 / 4 : ℝ) ≤ mass weight (s v)) + (c : Components weight s (1 / (100 * p))) + (z : Block (componentLabel weight s (1 / (100 * p))) R none → ℕ) : + componentAbs weight s (1 / (100 * p)) R J L base own c z ≤ + Real.exp (-(7 / 10 : ℝ) * ((L : ℝ) * R)) := by + let v := vertex weight s (1 / (100 * p)) c + have hv : (strongGraph weight s (1 / (100 * p))).connectedComponentMk v = c := + vertex_color weight s (1 / (100 * p)) c + change |∫ x, componentFactor (componentLabel weight s (1 / (100 * p))) R + (strongGraph weight s (1 / (100 * p))).connectedComponentMk s + (Real.exp (-(L : ℝ) * base)) own J c z x + ∂batchMeasure (fun i : Block (componentLabel weight s (1 / (100 * p))) R (some c) => + L * weight i.1.2)| ≤ _ + apply abs_integral_le_integral_abs.trans + apply nonsimple_component_attenuation (componentLabel weight s (1 / (100 * p))) R + (strongGraph weight s (1 / (100 * p))).connectedComponentMk s own (fun d => L * weight d) + J c ⟨v,hv⟩ z (fun d hd => by + simpa only [hv] using direction_internal_or_external weight s (1 / (100 * p)) hd) + hL (scaled_internal weight s (1 / (100 * p)) L base c) _ (by linarith) + rw [← internal_mass_eq] + exact source_internal_mass_lower weight s hp hc hlower v + +noncomputable def designatedBound : ℝ := + let S := simpleSet weight s t + (Real.exp (-(17 / 25 : ℝ) * ((L : ℝ) * R)) ^ S.card * + Real.exp (-(7 / 10 : ℝ) * ((L : ℝ) * R)) ^ + (Fintype.card (Components weight s t) - S.card)) * + ∑ U ∈ S.powerset, (∏ c ∈ S \ U, extraWeight weight s t R J K L base c) * + badMass (batchMeasure (fun i : Block (componentLabel weight s t) R none => L * weight i.1.2)) + (blockTrunc (componentLabel weight s t) R J none) (isBad weight s t R) U +omit [DecidableEq V] in + +lemma extraWeight_nonneg (c : Components weight s t) : + 0 ≤ extraWeight weight s t R J K L base c := by + unfold extraWeight + apply add_nonneg (add_nonneg (by positivity) (pow_nonneg (alpha_nonneg weight s t _) _)) + split_ifs <;> positivity + +lemma designatedBound_nonneg : 0 ≤ designatedBound weight s t R J K L base := by + unfold designatedBound + apply mul_nonneg (mul_nonneg (by positivity) (by positivity)) + apply Finset.sum_nonneg + intro U _ + apply mul_nonneg + · exact Finset.prod_nonneg (fun c _ => extraWeight_nonneg weight s t R J K L base c) + · exact badMass_nonneg _ _ (blockTrunc_range _ R J none) _ U + +theorem component_product_designated {p : ℕ} (hp : 0 < p) (hc : Fintype.card V ≤ p) + (hL : 10000 ≤ (L : ℝ)) (hbase : (23 / 25 : ℝ) ≤ base) + (hlower : ∀ v, (3 / 4 : ℝ) ≤ mass weight (s v)) + (hdelta : ∀ v, |delta weight s base v| ≤ (17 / 100 : ℝ)) (hK : K ≤ R / 2) : + (∫ z, blockTrunc (componentLabel weight s (1 / (100 * p))) R J none z * + ∏ c, componentAbs weight s (1 / (100 * p)) R J L base own c z + ∂batchMeasure (fun i : Block (componentLabel weight s (1 / (100 * p))) R none => + L * weight i.1.2)) ≤ + designatedBound weight s (1 / (100 * p)) R J K L base := by + exact integral_product_le _ (simpleSet weight s (1 / (100 * p))) _ _ _ _ _ + (blockTrunc_range _ R J none) _ + (componentAbs_range weight s (1 / (100 * p)) R J L base own hbase) + (simple_bound weight s R J K L base own hp hc hL hbase hlower hdelta hK) + (fun c _ z => nonsimple_bound weight s R J L base own hp hc hL hbase hlower c z) + +variable {H : Type} [Fintype H] [DecidableEq H] + +omit [DecidableEq H] in + +theorem truncated_power_designated (sf : H → Finset D) (of : H → Fin R → Bool) + {p : ℕ} (hp : 0 < p) (hL : 10000 ≤ (L : ℝ)) + (hbase : (23 / 25 : ℝ) ≤ base) + (hlower : ∀ h, (3 / 4 : ℝ) ≤ mass weight (sf h)) + (hdelta : ∀ h, |mass weight (sf h) - base| ≤ (17 / 100 : ℝ)) (hK : K ≤ R / 2) : + (∫ ω, HighMoment.allTrunc R J ω * + (∑ h : H, scoreTerm (sf h) (Real.exp (-(L : ℝ) * base)) (of h) + (fun r d => ω (r,d))) ^ p + ∂batchMeasure (fun i : Fin R × D => L * weight i.2)) ≤ + ∑ f : Fin p → H, designatedBound weight (sf ∘ f) (1 / (100 * p)) R J K L base := by + have hb : Real.exp (-(L : ℝ) * base) ∈ Set.Icc (0 : ℝ) 1 := by + refine ⟨(Real.exp_pos _).le, Real.exp_le_one_iff.mpr ?_⟩ + have hbas : 0 ≤ base := by linarith + exact mul_nonpos_of_nonpos_of_nonneg (neg_nonpos.mpr L.coe_nonneg) hbas + apply (HighMoment.truncated_moment_le_tuple_sum R sf _ of weight + (fun d => L * weight d) (1 / (100 * p)) J p hb).trans + apply Finset.sum_le_sum + intro f _ + exact component_product_designated weight (sf ∘ f) R J K L base (of ∘ f) hp + (by simp) hL hbase (fun v => hlower (f v)) (fun v => hdelta (f v)) hK + +end SharpRamseyFive.AmbientDesignations + +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal + +namespace SharpRamseyFive.StaticCertificates + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +end SharpRamseyFive.StaticCertificates +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Entropy/TwoAnchorCrossCost.lean b/lean/OAI/Combinatorics/SharpRamsey/Entropy/TwoAnchorCrossCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..97a65b2571f270d7f12bee7f651672e62a952758 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Entropy/TwoAnchorCrossCost.lean @@ -0,0 +1,465 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Entropy.PoissonLaw + +namespace OAI + +/-! High moments, finite-field subspaces, and incidence bounds. -/ + +section +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +namespace SharpRamseyFive.StaticCertificates +variable {ι : Type*} [Fintype ι] [DecidableEq ι] +section PairWitnesses +variable {κ : Type*} [Fintype κ] [DecidableEq κ] +section AnchorGeometry +variable {H : Type*} [Fintype H] [DecidableEq H] +omit [Fintype ι] [DecidableEq κ] [DecidableEq H] in +theorem two_anchor_cross_cost (rate : ι → ℝ≥0) (C : Finset (κ × ι)) + (S T : Finset ι) (lineSet : H → Finset ι) (N₂ : ℕ) + (hN : ∀ d e, d ≠ e → + (Finset.univ.filter (fun H => d ∈ lineSet H ∧ e ∈ lineSet H)).card ≤ N₂) : + (∑ x : AnchorChoice C S, ∑ y : AnchorChoice C T, + if x.direction ≠ y.direction then x.cost rate * y.cost rate * + (Finset.univ.filter (fun H => x.direction ∈ lineSet H ∧ y.direction ∈ lineSet H)).card + else 0) ≤ + (N₂ : ℝ) * (C.card + Fintype.card κ * ∑ i ∈ S, (rate i : ℝ)) * + (C.card + Fintype.card κ * ∑ i ∈ T, (rate i : ℝ)) := by + classical + calc + _ ≤ ∑ x : AnchorChoice C S, ∑ y : AnchorChoice C T, + x.cost rate * y.cost rate * N₂ := by + apply Finset.sum_le_sum + intro x _ + apply Finset.sum_le_sum + intro y _ + split_ifs with hxy + · apply mul_le_mul_of_nonneg_left _ (mul_nonneg (x.cost_nonneg rate) (y.cost_nonneg rate)) + exact_mod_cast hN x.direction y.direction hxy + · exact mul_nonneg (mul_nonneg (x.cost_nonneg rate) (y.cost_nonneg rate)) (Nat.cast_nonneg _) + _ = (N₂ : ℝ) * (∑ x : AnchorChoice C S, x.cost rate) * + (∑ y : AnchorChoice C T, y.cost rate) := by + simp only [Finset.sum_mul, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro y _ + apply Finset.sum_congr rfl + intro x _ + ring + _ ≤ _ := by + apply mul_le_mul + · exact mul_le_mul_of_nonneg_left (sum_anchor_cost_le rate C S) (Nat.cast_nonneg _) + · exact sum_anchor_cost_le rate C T + · exact Finset.sum_nonneg (fun x _ => x.cost_nonneg rate) + · positivity + +omit [Fintype ι] [DecidableEq κ] [DecidableEq H] in + +lemma one_anchor_subtype_sum (rate : ι → ℝ≥0) (C : Finset (κ × ι)) + (S : Finset ι) (lineSet : H → Finset ι) : + (∑ x : AnchorChoice C S, ∑ _h : {h : H // x.direction ∈ lineSet h}, x.cost rate) = + ∑ x : AnchorChoice C S, x.cost rate * + (Finset.univ.filter (fun h => x.direction ∈ lineSet h)).card := by + apply Finset.sum_congr rfl + intro x _ + simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_comm, + Fintype.card_subtype] + +omit [Fintype ι] [DecidableEq κ] [DecidableEq H] in +lemma two_anchor_subtype_sum (rate : ι → ℝ≥0) (C : Finset (κ × ι)) + (S T : Finset ι) (lineSet : H → Finset ι) : + (∑ x : AnchorChoice C S, ∑ y : AnchorChoice C T, + ∑ _h : {h : H // x.direction ≠ y.direction ∧ + x.direction ∈ lineSet h ∧ y.direction ∈ lineSet h}, x.cost rate * y.cost rate) = + ∑ x : AnchorChoice C S, ∑ y : AnchorChoice C T, + if x.direction ≠ y.direction then x.cost rate * y.cost rate * + (Finset.univ.filter (fun h => x.direction ∈ lineSet h ∧ y.direction ∈ lineSet h)).card + else 0 := by + classical + apply Finset.sum_congr rfl + intro x _ + apply Finset.sum_congr rfl + intro y _ + by_cases hxy : x.direction ≠ y.direction <;> + simp [hxy, Fintype.card_subtype, mul_comm] + +end AnchorGeometry + +end PairWitnesses + +end SharpRamseyFive.StaticCertificates + +open scoped BigOperators +namespace SharpRamseyFive.CertificateEnumeration + +universe u v +variable {S : Type u} {A : Type v} + +def Word (A : Type v) : ℕ → Type v + | 0 => PUnit + | n + 1 => A × Word A n + +instance flat_HighMomentRecovered_4 [Fintype A] (n : ℕ) : Fintype (Word A n) := by + induction n with + | zero => exact inferInstanceAs (Fintype PUnit) + | succ n ih => + letI := ih + exact inferInstanceAs (Fintype (A × Word A n)) + +def finish (next : S → A → S) : {n : ℕ} → S → Word A n → S + | 0, s, _ => s + | _ + 1, s, w => finish next (next s w.1) w.2 + +noncomputable def pathWeight (next : S → A → S) (cost : S → A → ℝ) : + {n : ℕ} → S → Word A n → ℝ + | 0, _, _ => 1 + | _ + 1, s, w => cost s w.1 * pathWeight next cost (next s w.1) w.2 + +def charge (c : A → ℤ) : {n : ℕ} → Word A n → ℤ + | 0, _ => 0 + | _ + 1, w => c w.1 + charge c w.2 + +lemma pathWeight_nonneg (next : S → A → S) (cost : S → A → ℝ) + (hc : ∀ s a, 0 ≤ cost s a) {n : ℕ} (s : S) (w : Word A n) : + 0 ≤ pathWeight next cost s w := by + induction n generalizing s with + | zero => exact zero_le_one + | succ n ih => exact mul_nonneg (hc s w.1) (ih _ w.2) + +theorem sum_pathWeight_le [Fintype A] (next : S → A → S) (cost : S → A → ℝ) + (hc : ∀ s a, 0 ≤ cost s a) (M : ℝ) (hM : 0 ≤ M) + (hrow : ∀ s, (∑ a, cost s a) ≤ M) (n : ℕ) (s : S) : + (∑ w : Word A n, pathWeight next cost s w) ≤ M ^ n := by + induction n generalizing s with + | zero => + let : Unique (Word A 0) := inferInstanceAs (Unique PUnit) + simp [pathWeight] + | succ n ih => + change (∑ w : A × Word A n, cost s w.1 * + pathWeight next cost (next s w.1) w.2) ≤ M ^ (n + 1) + rw [Fintype.sum_prod_type] + calc + _ = ∑ a, cost s a * ∑ w : Word A n, pathWeight next cost (next s a) w := by + simp only [Finset.mul_sum] + _ ≤ ∑ a, cost s a * M ^ n := by + apply Finset.sum_le_sum + intro a _ + exact mul_le_mul_of_nonneg_left (ih (next s a)) (hc s a) + _ = (∑ a, cost s a) * M ^ n := by rw [Finset.sum_mul] + _ ≤ M * M ^ n := mul_le_mul_of_nonneg_right (hrow s) (pow_nonneg hM n) + _ = _ := (pow_succ' M n).symm + +lemma reweighted_path (next : S → A → S) (cost : S → A → ℝ) + (c : A → ℤ) (b : ℝ) (hb : b ≠ 0) {n : ℕ} (s : S) (w : Word A n) : + pathWeight next (fun s a => cost s a * b ^ c a) s w = + pathWeight next cost s w * b ^ charge c w := by + induction n generalizing s with + | zero => simp [pathWeight, charge] + | succ n ih => + simp only [pathWeight, charge, ih, zpow_add₀ hb] + ring + +theorem constrained_path_sum_le [Fintype A] (next : S → A → S) + (cost : S → A → ℝ) (hc : ∀ s a, 0 ≤ cost s a) + (c : A → ℤ) (b M : ℝ) (hb : 1 ≤ b) (hM : 0 ≤ M) + (hrow : ∀ s, (∑ a, cost s a * b ^ c a) ≤ M) + (n : ℕ) (s : S) (valid : Word A n → Prop) [DecidablePred valid] + (hvalid : ∀ w, valid w → 0 ≤ charge c w) : + (∑ w : Word A n, if valid w then pathWeight next cost s w else 0) ≤ M ^ n := by + classical + have hb0 : 0 < b := lt_of_lt_of_le zero_lt_one hb + calc + _ ≤ ∑ w : Word A n, pathWeight next (fun s a => cost s a * b ^ c a) s w := by + apply Finset.sum_le_sum + intro w _ + split_ifs with hv + · rw [reweighted_path next cost c b hb0.ne'] + apply le_mul_of_one_le_right (pathWeight_nonneg next cost hc s w) + exact one_le_zpow₀ hb (hvalid w hv) + · exact pathWeight_nonneg next _ + (fun s a => mul_nonneg (hc s a) (zpow_nonneg hb0.le _)) s w + _ ≤ _ := sum_pathWeight_le next _ + (fun s a => mul_nonneg (hc s a) (zpow_nonneg hb0.le _)) M hM hrow n s + +lemma root_charge_nonneg (r s : ℕ) (h : 10 * r ≤ r + s) : + 0 ≤ (s : ℤ) - 8 * r := by omega + +section Dependent +variable (C : S → Type v) (step : (s : S) → C s → S) + +def DWord : ℕ → S → Type v + | 0, _ => PUnit + | n + 1, s => (a : C s) × DWord n (step s a) + +instance flat_HighMomentRecovered_5 [∀ s, Fintype (C s)] (n : ℕ) (s : S) : Fintype (DWord C step n s) := by + induction n generalizing s with + | zero => exact inferInstanceAs (Fintype PUnit) + | succ n ih => + letI := ih + exact inferInstanceAs (Fintype ((a : C s) × DWord C step n (step s a))) + +def dFinish : {n : ℕ} → (s : S) → DWord C step n s → S + | 0, s, _ => s + | _ + 1, s, w => dFinish (step s w.1) w.2 + +noncomputable def dWeight (cost : (s : S) → C s → ℝ) : + {n : ℕ} → (s : S) → DWord C step n s → ℝ + | 0, _, _ => 1 + | _ + 1, s, w => cost s w.1 * dWeight cost (step s w.1) w.2 + +def dCharge (c : (s : S) → C s → ℤ) : + {n : ℕ} → (s : S) → DWord C step n s → ℤ + | 0, _, _ => 0 + | _ + 1, s, w => c s w.1 + dCharge c (step s w.1) w.2 + +lemma dWeight_nonneg (cost : (s : S) → C s → ℝ) + (hc : ∀ s a, 0 ≤ cost s a) {n : ℕ} (s : S) (w : DWord C step n s) : + 0 ≤ dWeight C step cost s w := by + induction n generalizing s with + | zero => exact zero_le_one + | succ n ih => exact mul_nonneg (hc s w.1) (ih _ w.2) + +theorem sum_dWeight_le [∀ s, Fintype (C s)] (cost : (s : S) → C s → ℝ) + (hc : ∀ s a, 0 ≤ cost s a) (M : ℝ) (hM : 0 ≤ M) + (hrow : ∀ s, (∑ a, cost s a) ≤ M) (n : ℕ) (s : S) : + (∑ w : DWord C step n s, dWeight C step cost s w) ≤ M ^ n := by + induction n generalizing s with + | zero => + let : Unique (DWord C step 0 s) := inferInstanceAs (Unique PUnit) + simp [dWeight] + | succ n ih => + change (∑ w : (a : C s) × DWord C step n (step s a), cost s w.1 * + dWeight C step cost (step s w.1) w.2) ≤ M ^ (n + 1) + rw [Fintype.sum_sigma] + calc + _ = ∑ a, cost s a * ∑ w : DWord C step n (step s a), + dWeight C step cost (step s a) w := by simp only [Finset.mul_sum] + _ ≤ ∑ a, cost s a * M ^ n := by + apply Finset.sum_le_sum + intro a _ + exact mul_le_mul_of_nonneg_left (ih (step s a)) (hc s a) + _ = (∑ a, cost s a) * M ^ n := by rw [Finset.sum_mul] + _ ≤ M * M ^ n := mul_le_mul_of_nonneg_right (hrow s) (pow_nonneg hM n) + _ = _ := (pow_succ' M n).symm + +lemma dReweighted (cost : (s : S) → C s → ℝ) + (c : (s : S) → C s → ℤ) (b : ℝ) (hb : b ≠ 0) + {n : ℕ} (s : S) (w : DWord C step n s) : + dWeight C step (fun s a => cost s a * b ^ c s a) s w = + dWeight C step cost s w * b ^ dCharge C step c s w := by + induction n generalizing s with + | zero => simp [dWeight, dCharge] + | succ n ih => + simp only [dWeight, dCharge, ih, zpow_add₀ hb] + ring + +theorem constrained_dSum_le [∀ s, Fintype (C s)] (cost : (s : S) → C s → ℝ) + (hc : ∀ s a, 0 ≤ cost s a) (c : (s : S) → C s → ℤ) + (b M : ℝ) (hb : 1 ≤ b) (hM : 0 ≤ M) + (hrow : ∀ s, (∑ a, cost s a * b ^ c s a) ≤ M) + (n : ℕ) (s : S) (valid : DWord C step n s → Prop) [DecidablePred valid] + (hvalid : ∀ w, valid w → 0 ≤ dCharge C step c s w) : + (∑ w : DWord C step n s, if valid w then dWeight C step cost s w else 0) ≤ M ^ n := by + classical + have hb0 : 0 < b := lt_of_lt_of_le zero_lt_one hb + calc + _ ≤ ∑ w : DWord C step n s, + dWeight C step (fun s a => cost s a * b ^ c s a) s w := by + apply Finset.sum_le_sum + intro w _ + split_ifs with hv + · rw [dReweighted C step cost c b hb0.ne'] + apply le_mul_of_one_le_right (dWeight_nonneg C step cost hc s w) + exact one_le_zpow₀ hb (hvalid w hv) + · exact dWeight_nonneg C step _ + (fun s a => mul_nonneg (hc s a) (zpow_nonneg hb0.le _)) s w + _ ≤ _ := sum_dWeight_le C step _ + (fun s a => mul_nonneg (hc s a) (zpow_nonneg hb0.le _)) M hM hrow n s + +end Dependent + +end SharpRamseyFive.CertificateEnumeration + +namespace SharpRamseyFive.WeightedPrograms +open SharpRamseyFive.StaticCertificates +open SharpRamseyFive.CertificateEnumeration +open scoped BigOperators NNReal + +variable {V H D B : Type*} [Fintype V] [DecidableEq V] + [Fintype H] [DecidableEq H] [Fintype D] [DecidableEq D] + [Fintype B] [DecidableEq B] + +abbrev State (V H D B : Type*) := (V → H) × Finset (B × D) + +variable (lines : H → Finset D) + +abbrev RootChoice := V × H +abbrev OneChoice (s : State V H D B) := + (_v : V) × (u : V) × (x : AnchorChoice s.2 (lines (s.1 u))) × + {h : H // x.direction ∈ lines h} +abbrev TwoChoice (s : State V H D B) := + (_v : V) × (u : V) × (w : V) × + (x : AnchorChoice s.2 (lines (s.1 u))) × + (y : AnchorChoice s.2 (lines (s.1 w))) × + {h : H // x.direction ≠ y.direction ∧ x.direction ∈ lines h ∧ y.direction ∈ lines h} +abbrev PairDirections (s : State V H D B) (h h' : H) := + (lines h ∩ lines h') \ dictionary s.2 +abbrev PairChoice (K : ℕ) (s : State V H D B) := + (_v : V) × (_u : V) × (h : H) × (h' : {h' : H // h' ≠ h}) × + (T : {T : Finset B // T ∈ (Finset.univ : Finset B).powersetCard K}) × + (T.val → PairDirections lines s h h'.val) +abbrev Action (K : ℕ) (s : State V H D B) := + RootChoice (V := V) (H := H) ⊕ OneChoice lines s ⊕ TwoChoice lines s ⊕ PairChoice lines K s + +noncomputable instance actionFintype (K : ℕ) (s : State V H D B) : + Fintype (Action lines K s) := by + letI : Fintype (RootChoice (V := V) (H := H)) := inferInstance + letI : Fintype (OneChoice lines s) := inferInstance + letI : Fintype (TwoChoice lines s) := inferInstance + letI : Fintype (PairChoice lines K s) := inferInstance + exact inferInstanceAs (Fintype (RootChoice (V := V) (H := H) ⊕ + OneChoice lines s ⊕ TwoChoice lines s ⊕ PairChoice lines K s)) + +noncomputable def oneCost (rate : D → ℝ≥0) (denom : ℝ) + (s : State V H D B) (c : OneChoice lines s) : ℝ := + c.2.2.1.cost rate / denom +noncomputable def twoCost (rate : D → ℝ≥0) (denom : ℝ) + (s : State V H D B) (c : TwoChoice lines s) : ℝ := + c.2.2.2.1.cost rate * c.2.2.2.2.1.cost rate / denom +noncomputable def pairCost (rate : D → ℝ≥0) (denom : ℝ) (K : ℕ) + (s : State V H D B) (c : PairChoice lines K s) : ℝ := + weight (fun p : B × D => rate p.2) + (witnessRequirements c.2.2.2.2.1.val + (PairDirections lines s c.2.2.1 c.2.2.2.1.val) c.2.2.2.2.2) / denom ^ 2 + +noncomputable def anchorBudget (_rate : D → ℝ≥0) (s : State V H D B) (mass : ℝ) : ℝ := + s.2.card + Fintype.card B * mass + +omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] [Fintype D] [DecidableEq D] [DecidableEq B] in +lemma anchorBudget_nonneg (rate : D → ℝ≥0) (s : State V H D B) + (mass : ℝ) (hmass : 0 ≤ mass) : 0 ≤ anchorBudget rate s mass := by + unfold anchorBudget + positivity + +omit [DecidableEq V] in +omit [DecidableEq H] in +omit [Fintype D] [DecidableEq B] in + +theorem sum_oneCost_le (rate : D → ℝ≥0) (denom : ℝ) (hd : 0 ≤ denom) + (s : State V H D B) (mass : ℝ) + (hmass : ∀ h, ∑ d ∈ lines h, (rate d : ℝ) ≤ mass) + (N₁ : ℕ) (hN : ∀ d, (Finset.univ.filter (fun h => d ∈ lines h)).card ≤ N₁) : + (∑ c : OneChoice lines s, oneCost lines rate denom s c) ≤ + Fintype.card V ^ 2 * (N₁ : ℝ) * anchorBudget rate s mass / denom := by + classical + simp only [OneChoice, oneCost, Fintype.sum_sigma] + simp only [← Finset.sum_div] + apply div_le_div_of_nonneg_right _ hd + calc + _ ≤ ∑ _v : V, ∑ _u : V, (N₁ : ℝ) * anchorBudget rate s mass := by + apply Finset.sum_le_sum + intro v _ + apply Finset.sum_le_sum + intro u _ + rw [one_anchor_subtype_sum] + apply (one_anchor_geometric_cost rate s.2 (lines (s.1 u)) lines N₁ hN).trans + apply mul_le_mul_of_nonneg_left _ (Nat.cast_nonneg _) + exact add_le_add le_rfl (mul_le_mul_of_nonneg_left (hmass (s.1 u)) (Nat.cast_nonneg _)) + _ = _ := by simp [pow_two, anchorBudget]; ring + +omit [DecidableEq V] [DecidableEq H] in +omit [Fintype D] [DecidableEq B] in + +theorem sum_twoCost_le (rate : D → ℝ≥0) (denom : ℝ) (hd : 0 ≤ denom) + (s : State V H D B) (mass : ℝ) (hm0 : 0 ≤ mass) + (hmass : ∀ h, ∑ d ∈ lines h, (rate d : ℝ) ≤ mass) + (N₂ : ℕ) (hN : ∀ d e, d ≠ e → + (Finset.univ.filter (fun h => d ∈ lines h ∧ e ∈ lines h)).card ≤ N₂) : + (∑ c : TwoChoice lines s, twoCost lines rate denom s c) ≤ + Fintype.card V ^ 3 * (N₂ : ℝ) * anchorBudget rate s mass ^ 2 / denom := by + classical + simp only [TwoChoice, twoCost, Fintype.sum_sigma] + simp only [← Finset.sum_div] + apply div_le_div_of_nonneg_right _ hd + calc + _ ≤ ∑ _v : V, ∑ _u : V, ∑ _w : V, + (N₂ : ℝ) * anchorBudget rate s mass ^ 2 := by + apply Finset.sum_le_sum + intro v _ + apply Finset.sum_le_sum + intro u _ + apply Finset.sum_le_sum + intro w _ + rw [two_anchor_subtype_sum] + apply (two_anchor_cross_cost rate s.2 (lines (s.1 u)) (lines (s.1 w)) lines N₂ hN).trans + have ha (j : V) : (s.2.card : ℝ) + Fintype.card B * + ∑ d ∈ lines (s.1 j), (rate d : ℝ) ≤ anchorBudget rate s mass := + add_le_add le_rfl (mul_le_mul_of_nonneg_left (hmass (s.1 j)) (Nat.cast_nonneg _)) + rw [pow_two, ← mul_assoc] + apply mul_le_mul + · exact mul_le_mul_of_nonneg_left (ha u) (Nat.cast_nonneg _) + · exact ha w + · positivity + · exact mul_nonneg (Nat.cast_nonneg _) (anchorBudget_nonneg rate s mass hm0) + _ = _ := by simp; ring + +noncomputable def pairMoment (rate : D → ℝ≥0) (K : ℕ) : ℝ := + ∑ h : H, ∑ h' : {h' : H // h' ≠ h}, + ((Fintype.card B : ℝ) * ∑ d ∈ lines h ∩ lines h'.val, (rate d : ℝ)) ^ K + +omit [Fintype D] [DecidableEq B] in +lemma pairMoment_nonneg (rate : D → ℝ≥0) (K : ℕ) : + 0 ≤ pairMoment (B := B) lines rate K := by + unfold pairMoment + positivity + +omit [Fintype V] [DecidableEq V] [Fintype H] [DecidableEq H] in +omit [Fintype D] in +lemma sum_pair_choices_le (rate : D → ℝ≥0) (K : ℕ) (s : State V H D B) (h h' : H) : + (∑ T : {T : Finset B // T ∈ (Finset.univ : Finset B).powersetCard K}, + ∑ f : T.val → PairDirections lines s h h', + weight (fun p : B × D => rate p.2) + (witnessRequirements T.val (PairDirections lines s h h') f)) ≤ + ((Fintype.card B : ℝ) * ∑ d ∈ lines h ∩ lines h', (rate d : ℝ)) ^ K := by + classical + rw [Finset.sum_coe_sort (Finset.univ.powersetCard K) + (fun T : Finset B => ∑ f : T → PairDirections lines s h h', + weight (fun p : B × D => rate p.2) + (witnessRequirements T (PairDirections lines s h h') f))] + apply (pair_certificate_weight_le rate (PairDirections lines s h h') K).trans + apply pow_le_pow_left₀ (by positivity) + apply mul_le_mul_of_nonneg_left _ (Nat.cast_nonneg _) + exact Finset.sum_le_sum_of_subset_of_nonneg Finset.sdiff_subset + (by intro d _ _; exact (rate d).coe_nonneg) + +omit [DecidableEq V] in +omit [Fintype D] in + +theorem sum_pairCost_le (rate : D → ℝ≥0) (denom : ℝ) (K : ℕ) + (s : State V H D B) : + (∑ c : PairChoice lines K s, pairCost lines rate denom K s c) ≤ + Fintype.card V ^ 2 * pairMoment (B := B) lines rate K / denom ^ 2 := by + classical + simp only [PairChoice, pairCost, Fintype.sum_sigma] + simp only [← Finset.sum_div] + apply div_le_div_of_nonneg_right _ (sq_nonneg _) + calc + _ ≤ ∑ _v : V, ∑ _u : V, pairMoment (B := B) lines rate K := by + apply Finset.sum_le_sum + intro v _ + apply Finset.sum_le_sum + intro u _ + unfold pairMoment + apply Finset.sum_le_sum + intro h _ + apply Finset.sum_le_sum + intro h' _ + exact sum_pair_choices_le lines rate K s h h'.val + _ = _ := by simp [pow_two]; ring + +end SharpRamseyFive.WeightedPrograms +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Entropy/WitnessList.lean b/lean/OAI/Combinatorics/SharpRamsey/Entropy/WitnessList.lean new file mode 100644 index 0000000000000000000000000000000000000000..e85f8b371069081d992f3fb081e0b73e904cb8ae --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Entropy/WitnessList.lean @@ -0,0 +1,441 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Entropy.NewEvents + +namespace OAI + +/-! High moments, finite-field subspaces, and incidence bounds. -/ + +section +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +open scoped BigOperators +open MeasureTheory ProbabilityTheory +open scoped BigOperators ENNReal NNReal +namespace SharpRamseyFive.ResidualCertificate +variable {V : Type*} [Fintype V] [DecidableEq V] +section WitnessMatching +variable {E N D : Type*} [DecidableEq E] [DecidableEq N] [DecidableEq D] +theorem exists_witness_list (s : Finset E) (neighbor : E → N) (direction : E → D) + (K h : ℕ) (hn : ∀ n, (s.filter (fun e => neighbor e = n)).card ≤ K) + (hd : ∀ d, (s.filter (fun e => direction e = d)).card ≤ K) + (hh : h ≤ s.card / (2 * K)) : + ∃ t ⊆ s, t.card = h ∧ Set.InjOn neighbor (t : Set E) ∧ Set.InjOn direction (t : Set E) := by + obtain ⟨u, hu, hun, hud, hcard⟩ := exists_distinct_witnesses s neighbor direction K hn hd + have hle : h ≤ u.card := hh.trans (Nat.div_le_of_le_mul hcard) + obtain ⟨t, htu, htc⟩ := Finset.exists_subset_card_eq hle + exact ⟨t, htu.trans hu, htc, hun.mono htu, hud.mono htu⟩ + +theorem exists_residual_roots [Fintype N] (batchSet : N → Finset E) + (neighbor : N → E → N) (direction : N → E → D) (K h : ℕ) + (hh : 0 < h) + (hsize : ∀ v, h ≤ (batchSet v).card / (2 * K)) + (hn : ∀ v n, ((batchSet v).filter (fun e => neighbor v e = n)).card ≤ K) + (hd : ∀ v d, ((batchSet v).filter (fun e => direction v e = d)).card ≤ K) + (herr : (Fintype.card N : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) : + ∃ roots : Finset N, 10 * roots.card ≤ Fintype.card N ∧ + ∀ v, ∃ b₁ ∈ batchSet v, ∃ b₂ ∈ batchSet v, + neighbor v b₁ ∈ roots ∧ neighbor v b₂ ∈ roots ∧ + neighbor v b₁ ≠ neighbor v b₂ ∧ direction v b₁ ≠ direction v b₂ := by + classical + have hex (v : N) := exists_witness_list (batchSet v) (neighbor v) (direction v) + K h (hn v) (hd v) (hsize v) + choose lists hsub hcard hin hn_dir using hex + let W : N → Finset N := fun v => (lists v).image (neighbor v) + have hW (v : N) : (W v).card = h := by + change ((lists v).image (neighbor v)).card = h + rw [Finset.card_image_of_injOn (hin v), hcard v] + obtain ⟨roots, hr, hall⟩ := exists_small_root_set W hh hW herr + refine ⟨roots, hr, ?_⟩ + intro v + have htwo : 1 < (W v ∩ roots).card := by have := hall v; omega + obtain ⟨a, ha, b, hb, hab⟩ := Finset.one_lt_card.mp htwo + obtain ⟨b₁, hb₁, rfl⟩ := Finset.mem_image.mp (Finset.mem_inter.mp ha).1 + obtain ⟨b₂, hb₂, rfl⟩ := Finset.mem_image.mp (Finset.mem_inter.mp hb).1 + refine ⟨b₁, hsub v hb₁, b₂, hsub v hb₂, (Finset.mem_inter.mp ha).2, + (Finset.mem_inter.mp hb).2, hab, ?_⟩ + intro heq + have := hn_dir v hb₁ hb₂ heq + exact hab (congrArg (neighbor v) this) + +end WitnessMatching + +section SharedHitGeometry + +open scoped Classical + +variable {D B : Type*} [Fintype D] [DecidableEq D] [Fintype B] [DecidableEq B] + +noncomputable def sharedBatches (s : V → Finset D) (hit : B → D → Prop) (v u : V) : Finset B := + Finset.univ.filter (fun r => ∃ d ∈ s v ∩ s u, hit r d) + +noncomputable def touchedBatches (s : V → Finset D) (hit : B → D → Prop) (v : V) : Finset B := + Finset.univ.filter (fun r => ∃ u, u ≠ v ∧ r ∈ sharedBatches s hit v u) + +omit [Fintype D] in + +theorem roots_from_shared_hits (s : V → Finset D) (hit : B → D → Prop) + (K h : ℕ) (hh : 0 < h) + (hsize : ∀ v, h ≤ (touchedBatches s hit v).card / (2 * K)) + (hpair : ∀ v u, v ≠ u → (sharedBatches s hit v u).card ≤ K) + (herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) : + ∃ roots : Finset V, 10 * roots.card ≤ Fintype.card V ∧ + ∀ v, ∃ u ∈ roots, ∃ w ∈ roots, u ≠ w ∧ u ≠ v ∧ w ≠ v ∧ + ∃ d₁ ∈ s v ∩ s u, ∃ d₂ ∈ s v ∩ s w, + d₁ ≠ d₂ ∧ (∃ r, hit r d₁) ∧ (∃ r, hit r d₂) := by + classical + have hwit (v : V) (r : touchedBatches s hit v) : + ∃ z : V × D, z.1 ≠ v ∧ z.2 ∈ s v ∩ s z.1 ∧ hit r.val z.2 := by + obtain ⟨u, hu, hs⟩ := (Finset.mem_filter.mp r.property).2 + obtain ⟨d, hd, hr⟩ := (Finset.mem_filter.mp hs).2 + exact ⟨(u, d), hu, hd, hr⟩ + choose wit hwit using hwit + let neighbor (v : V) (r : B) : V := + if hr : r ∈ touchedBatches s hit v then (wit v ⟨r, hr⟩).1 else v + let direction (v : V) (r : B) : Option D := + if hr : r ∈ touchedBatches s hit v then some (wit v ⟨r, hr⟩).2 else none + have hvalid (v : V) (r : B) (hr : r ∈ touchedBatches s hit v) : + ∃ d, direction v r = some d ∧ neighbor v r ≠ v ∧ + d ∈ s v ∩ s (neighbor v r) ∧ hit r d := by + refine ⟨(wit v ⟨r, hr⟩).2, ?_⟩ + simp only [neighbor, direction, dite_eq_left hr] + exact ⟨trivial, hwit v ⟨r, hr⟩⟩ + have hn (v u : V) : + ((touchedBatches s hit v).filter (fun r => neighbor v r = u)).card ≤ K := by + by_cases hu : v = u + · have he : (touchedBatches s hit v).filter (fun r => neighbor v r = u) = ∅ := by + apply Finset.eq_empty_iff_forall_notMem.mpr + intro r hr + obtain ⟨hr, he⟩ := Finset.mem_filter.mp hr + obtain ⟨d, _, hd, _⟩ := hvalid v r hr + exact hd (he.trans hu.symm) + simp [he] + · apply (Finset.card_le_card (show + (touchedBatches s hit v).filter (fun r => neighbor v r = u) ⊆ + sharedBatches s hit v u from ?_)).trans (hpair v u hu) + intro r hr + obtain ⟨hr, he⟩ := Finset.mem_filter.mp hr + obtain ⟨d, _, _, hd, hp⟩ := hvalid v r hr + exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, d, he ▸ hd, hp⟩ + have hd (v : V) (d : Option D) : + ((touchedBatches s hit v).filter (fun r => direction v r = d)).card ≤ K := by + let T := (touchedBatches s hit v).filter (fun r => direction v r = d) + by_cases he : T.Nonempty + · obtain ⟨r₀, hr₀⟩ := he + obtain ⟨hm₀, hd₀⟩ := Finset.mem_filter.mp hr₀ + obtain ⟨a, ha, hu, has, hp⟩ := hvalid v r₀ hm₀ + apply (Finset.card_le_card (show T ⊆ sharedBatches s hit v (neighbor v r₀) from ?_)).trans + (hpair v (neighbor v r₀) hu.symm) + intro r hr + obtain ⟨hm, hd⟩ := Finset.mem_filter.mp hr + obtain ⟨b, hb, _, hbs, hhit⟩ := hvalid v r hm + have heq : b = a := Option.some.inj (hb.symm.trans (hd.trans (hd₀.symm.trans ha))) + subst b + exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, a, + Finset.mem_inter.mpr ⟨(Finset.mem_inter.mp hbs).1, (Finset.mem_inter.mp has).2⟩, hhit⟩ + · have hem : T = ∅ := Finset.not_nonempty_iff_eq_empty.mp he + change T.card ≤ K + simp [hem] + obtain ⟨roots, hr, hroots⟩ := exists_residual_roots (touchedBatches s hit) + neighbor direction K h hh hsize hn hd herr + refine ⟨roots, hr, ?_⟩ + intro v + obtain ⟨r₁, hr₁, r₂, hr₂, hu, hw, huv, hdir⟩ := hroots v + obtain ⟨a, ha, hne₁, hmem₁, hhit₁⟩ := hvalid v r₁ hr₁ + obtain ⟨b, hb, hne₂, hmem₂, hhit₂⟩ := hvalid v r₂ hr₂ + refine ⟨neighbor v r₁, hu, neighbor v r₂, hw, huv, hne₁, hne₂, + a, hmem₁, b, hmem₂, ?_, ⟨r₁, hhit₁⟩, ⟨r₂, hhit₂⟩⟩ + intro heq + exact hdir (ha.trans (congrArg some heq) |>.trans hb.symm) + +noncomputable def encodedDirections (s : V → Finset D) (E : Finset V) : Finset D := + E.biUnion s + +noncomputable def touchedToEncoded (s : V → Finset D) (hit : B → D → Prop) + (E : Finset V) (v : V) : Finset D := + (s v ∩ encodedDirections s E).filter (fun d => ∃ r, hit r d) + +noncomputable def batchesOn (hit : B → D → Prop) (T : Finset D) : Finset B := + T.biUnion (fun d => Finset.univ.filter (fun r => hit r d)) + +noncomputable def survivingDirections (s : V → Finset D) (E : Finset V) + (v : {v // v ∉ E}) : Finset D := s v.val \ encodedDirections s E + +omit [Fintype D] [DecidableEq D] in +lemma mem_batchesOn (hit : B → D → Prop) (T : Finset D) (r : B) : + r ∈ batchesOn hit T ↔ ∃ d ∈ T, hit r d := by + simp [batchesOn] + +omit [Fintype D] in + +lemma surviving_touches (s : V → Finset D) (hit : B → D → Prop) + (E : Finset V) (v : {v // v ∉ E}) : + touchedBatches s hit v.val \ batchesOn hit (touchedToEncoded s hit E v.val) ⊆ + touchedBatches (survivingDirections s E) hit v := by + classical + intro r hr + obtain ⟨hr, hnot⟩ := Finset.mem_sdiff.mp hr + obtain ⟨u, huv, hu⟩ := (Finset.mem_filter.mp hr).2 + obtain ⟨d, hd, hh⟩ := (Finset.mem_filter.mp hu).2 + have hde : d ∉ encodedDirections s E := by + intro he + apply hnot + rw [mem_batchesOn] + exact ⟨d, Finset.mem_filter.mpr + ⟨Finset.mem_inter.mpr ⟨(Finset.mem_inter.mp hd).1, he⟩, ⟨r, hh⟩⟩, hh⟩ + have hue : u ∉ E := by + intro hu + exact hde (Finset.mem_biUnion.mpr ⟨u, hu, (Finset.mem_inter.mp hd).2⟩) + refine Finset.mem_filter.mpr ⟨Finset.mem_univ _, ⟨u, hue⟩, ?_, ?_⟩ + · intro he + exact huv (congrArg Subtype.val he) + · refine Finset.mem_filter.mpr ⟨Finset.mem_univ _, d, ?_, hh⟩ + exact Finset.mem_inter.mpr ⟨Finset.mem_sdiff.mpr ⟨(Finset.mem_inter.mp hd).1, hde⟩, + Finset.mem_sdiff.mpr ⟨(Finset.mem_inter.mp hd).2, hde⟩⟩ + +omit [Fintype D] [DecidableEq D] in +lemma batchesOn_card_le (hit : B → D → Prop) (T : Finset D) (J : ℕ) + (hJ : ∀ d ∈ T, (Finset.univ.filter (fun r => hit r d)).card ≤ J) : + (batchesOn hit T).card ≤ T.card * J := by + classical + apply (Finset.card_biUnion_le).trans + calc + ∑ d ∈ T, (Finset.univ.filter (fun r => hit r d)).card ≤ ∑ _d ∈ T, J := + Finset.sum_le_sum hJ + _ = _ := by simp +omit [Fintype D] in + +lemma surviving_touches_card (s : V → Finset D) (hit : B → D → Prop) + (E : Finset V) (v : {v // v ∉ E}) (J N : ℕ) + (hbad : N ≤ (touchedBatches s hit v.val).card) + (hloss : (batchesOn hit (touchedToEncoded s hit E v.val)).card ≤ J) : + N - J ≤ (touchedBatches (survivingDirections s E) hit v).card := by + have hs := Finset.card_le_card (surviving_touches s hit E v) + have hd := Finset.card_sdiff_add_card_inter + (touchedBatches s hit v.val) (batchesOn hit (touchedToEncoded s hit E v.val)) + have hi := Finset.card_le_card (Finset.inter_subset_right + (s₁ := touchedBatches s hit v.val) + (s₂ := batchesOn hit (touchedToEncoded s hit E v.val))) + omega + +omit [Fintype V] [DecidableEq V] in +omit [Fintype D] in + +lemma terminal_high_loss (s : V → Finset D) (hit : B → D → Prop) + (E : Finset V) (v : V) (J : ℕ) + (hanchor : (touchedToEncoded s hit E v).card ≤ 1) + (htrunc : ∀ d, (Finset.univ.filter (fun r => hit r d)).card ≤ J) : + (batchesOn hit (touchedToEncoded s hit E v)).card ≤ J := by + exact (batchesOn_card_le hit _ J (fun d _ => htrunc d)).trans + (by simpa using Nat.mul_le_mul_right J hanchor) + +omit [Fintype V] [DecidableEq V] [Fintype D] in +lemma terminal_low_loss (s : V → Finset D) (hit : B → D → Prop) + (E : Finset V) (v : V) (hanchor : touchedToEncoded s hit E v = ∅) : + (batchesOn hit (touchedToEncoded s hit E v)).card = 0 := by + simp [hanchor, batchesOn] + +omit [Fintype D] in + +theorem terminal_state_roots (s : V → Finset D) (hit : B → D → Prop) + (E : Finset V) (K J h : ℕ) (hh : 0 < h) + (hsize : h ≤ (Fintype.card B / 2 - J) / (2 * K)) + (hbad : ∀ v ∉ E, Fintype.card B / 2 ≤ (touchedBatches s hit v).card) + (hloss : ∀ v ∉ E, (batchesOn hit (touchedToEncoded s hit E v)).card ≤ J) + (hpair : ∀ (v u : {v // v ∉ E}), v ≠ u → + (sharedBatches (survivingDirections s E) hit v u).card < K) + (herr : (Fintype.card {v // v ∉ E} : ℝ) * h * + (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) : + ∃ roots : Finset {v // v ∉ E}, 10 * roots.card ≤ Fintype.card {v // v ∉ E} ∧ + ∀ v, ∃ u ∈ roots, ∃ w ∈ roots, u ≠ w ∧ u ≠ v ∧ w ≠ v ∧ + ∃ d₁ ∈ survivingDirections s E v ∩ survivingDirections s E u, + ∃ d₂ ∈ survivingDirections s E v ∩ survivingDirections s E w, + d₁ ≠ d₂ ∧ (∃ r, hit r d₁) ∧ (∃ r, hit r d₂) := by + classical + apply roots_from_shared_hits (survivingDirections s E) hit K h hh + · intro v + apply hsize.trans + apply Nat.div_le_div_right + exact surviving_touches_card s hit E v J _ (hbad v.val v.property) + (hloss v.val v.property) + · intro v u hvu + exact (hpair v u hvu).le + · exact herr + +noncomputable def outsideDirections (s : V → Finset D) (E : Finset V) (v : V) : Finset D := + s v \ encodedDirections s E + +inductive EncodingStep (s : V → Finset D) (hit : B → D → Prop) + (anchorNumber K : ℕ) : Finset V → Finset V → Prop + | anchor (E : Finset V) (v : V) (hv : v ∉ E) + (ha : anchorNumber ≤ (touchedToEncoded s hit E v).card) : + EncodingStep s hit anchorNumber K E (insert v E) + | pair (E : Finset V) (v u : V) (hv : v ∉ E) (hu : u ∉ E) (hne : v ≠ u) + (hp : K ≤ (sharedBatches (outsideDirections s E) hit v u).card) : + EncodingStep s hit anchorNumber K E (insert v (insert u E)) + +omit [Fintype V] [Fintype D] [DecidableEq B] in +lemma encodingStep_strict (s : V → Finset D) (hit : B → D → Prop) + (a K : ℕ) {E F : Finset V} (h : EncodingStep s hit a K E F) : E ⊂ F := by + cases h with + | anchor v hv ha => exact Finset.ssubset_insert hv + | pair v u hv hu hne hp => + exact (Finset.ssubset_insert hu).trans_subset (Finset.subset_insert _ _) +omit [Fintype V] [Fintype D] [DecidableEq B] in + +lemma encoding_reachable_subset (s : V → Finset D) (hit : B → D → Prop) + (a K : ℕ) {E F : Finset V} (h : Relation.ReflTransGen (EncodingStep s hit a K) E F) : + E ⊆ F := by + induction h with + | refl => exact Finset.Subset.refl _ + | @tail F G h hFG ih => exact ih.trans (encodingStep_strict s hit a K hFG).subset + +omit [Fintype D] [DecidableEq B] in + +theorem exists_terminal_encoding (s : V → Finset D) (hit : B → D → Prop) + (a K : ℕ) (E : Finset V) : + ∃ F, Relation.ReflTransGen (EncodingStep s hit a K) E F ∧ + (∀ v ∉ F, (touchedToEncoded s hit F v).card < a) ∧ + ∀ v ∉ F, ∀ u ∉ F, v ≠ u → + (sharedBatches (outsideDirections s F) hit v u).card < K := by + classical + let reachable : Finset (Finset V) := Finset.univ.filter + (fun F => Relation.ReflTransGen (EncodingStep s hit a K) E F) + have hE : E ∈ reachable := Finset.mem_filter.mpr ⟨Finset.mem_univ _, .refl⟩ + obtain ⟨F, hF, hmax⟩ := reachable.exists_max_image Finset.card ⟨E, hE⟩ + have hreach := (Finset.mem_filter.mp hF).2 + have hterminal (G : Finset V) : ¬EncodingStep s hit a K F G := by + intro hs + have hG : G ∈ reachable := Finset.mem_filter.mpr ⟨Finset.mem_univ _, hreach.tail hs⟩ + exact (Nat.not_lt_of_ge (hmax G hG)) (Finset.card_lt_card (encodingStep_strict s hit a K hs)) + refine ⟨F, hreach, ?_, ?_⟩ + · intro v hv + by_contra ha + exact hterminal _ (.anchor F v hv (Nat.not_lt.mp ha)) + · intro v hv u hu hne + by_contra hp + exact hterminal _ (.pair F v u hv hu hne (Nat.not_lt.mp hp)) + +omit [Fintype D] in + +theorem high_case_certificate_geometry (s : V → Finset D) (hit : B → D → Prop) + (E : Finset V) (K J h : ℕ) (hh : 0 < h) + (hsize : h ≤ (Fintype.card B / 2 - J) / (2 * K)) + (hbad : ∀ v ∉ E, Fintype.card B / 2 ≤ (touchedBatches s hit v).card) + (htrunc : ∀ d, (Finset.univ.filter (fun r => hit r d)).card ≤ J) + (herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) : + ∃ F, Relation.ReflTransGen (EncodingStep s hit 2 K) E F ∧ + ∃ roots : Finset {v // v ∉ F}, 10 * roots.card ≤ Fintype.card {v // v ∉ F} ∧ + ∀ v, ∃ u ∈ roots, ∃ w ∈ roots, u ≠ w ∧ u ≠ v ∧ w ≠ v ∧ + ∃ d₁ ∈ survivingDirections s F v ∩ survivingDirections s F u, + ∃ d₂ ∈ survivingDirections s F v ∩ survivingDirections s F w, + d₁ ≠ d₂ ∧ (∃ r, hit r d₁) ∧ (∃ r, hit r d₂) := by + classical + obtain ⟨F, hF, ha, hp⟩ := exists_terminal_encoding s hit 2 K E + refine ⟨F, hF, ?_⟩ + apply terminal_state_roots s hit F K J h hh hsize + · intro v hv + exact hbad v (fun he => hv (encoding_reachable_subset s hit 2 K hF he)) + · intro v hv + exact terminal_high_loss s hit F v J (by have := ha v hv; omega) htrunc + · intro v u hvu + have hne : v.val ≠ u.val := fun he => hvu (Subtype.ext he) + exact hp v.val v.property u.val u.property hne + · apply lt_of_le_of_lt _ herr + have hc : (Fintype.card {v // v ∉ F} : ℝ) ≤ Fintype.card V := by + exact_mod_cast Fintype.card_subtype_le (fun v => v ∉ F) + gcongr + +omit [Fintype D] in + +theorem low_case_certificate_geometry (s : V → Finset D) (hit : B → D → Prop) + (E : Finset V) (K h : ℕ) (hh : 0 < h) + (hsize : h ≤ (Fintype.card B / 2) / (2 * K)) + (hbad : ∀ v ∉ E, Fintype.card B / 2 ≤ (touchedBatches s hit v).card) + (herr : (Fintype.card V : ℝ) * h * (19 / 20 : ℝ) ^ (h - 1) < 1 / 2) : + ∃ F, Relation.ReflTransGen (EncodingStep s hit 1 K) E F ∧ + ∃ roots : Finset {v // v ∉ F}, 10 * roots.card ≤ Fintype.card {v // v ∉ F} ∧ + ∀ v, ∃ u ∈ roots, ∃ w ∈ roots, u ≠ w ∧ u ≠ v ∧ w ≠ v ∧ + ∃ d₁ ∈ survivingDirections s F v ∩ survivingDirections s F u, + ∃ d₂ ∈ survivingDirections s F v ∩ survivingDirections s F w, + d₁ ≠ d₂ ∧ (∃ r, hit r d₁) ∧ (∃ r, hit r d₂) := by + classical + obtain ⟨F, hF, ha, hp⟩ := exists_terminal_encoding s hit 1 K E + refine ⟨F, hF, ?_⟩ + apply terminal_state_roots s hit F K 0 h hh (by simpa using hsize) + · intro v hv + exact hbad v (fun he => hv (encoding_reachable_subset s hit 1 K hF he)) + · intro v hv + have hem : touchedToEncoded s hit F v = ∅ := Finset.card_eq_zero.mp (by + have := ha v hv + omega) + exact (terminal_low_loss s hit F v hem).le + · intro v u hvu + have hne : v.val ≠ u.val := fun he => hvu (Subtype.ext he) + exact hp v.val v.property u.val u.property hne + · apply lt_of_le_of_lt _ herr + have hc : (Fintype.card {v // v ∉ F} : ℝ) ≤ Fintype.card V := by + exact_mod_cast Fintype.card_subtype_le (fun v => v ∉ F) + gcongr + +def paidDirections (C : Finset (B × D)) : Finset D := C.image Prod.snd + +def Realized (hit : B → D → Prop) (C : Finset (B × D)) : Prop := + ∀ p ∈ C, hit p.1 p.2 + +def DictionaryInvariant (s : V → Finset D) (E : Finset V) (C : Finset (B × D)) : Prop := + paidDirections C ⊆ encodedDirections s E + +omit [Fintype V] [DecidableEq V] [Fintype D] in +lemma encodedDirections_mono (s : V → Finset D) {E F : Finset V} (h : E ⊆ F) : + encodedDirections s E ⊆ encodedDirections s F := by + intro d hd + obtain ⟨v, hv, hdv⟩ := Finset.mem_biUnion.mp hd + exact Finset.mem_biUnion.mpr ⟨v, h hv, hdv⟩ + +omit [Fintype D] [Fintype B] in +lemma paidDirections_union (C C' : Finset (B × D)) : + paidDirections (C ∪ C') = paidDirections C ∪ paidDirections C' := by + simp only [paidDirections, Finset.image_union] + +omit [Fintype D] [Fintype B] in +lemma realized_union (hit : B → D → Prop) {C C' : Finset (B × D)} + (h : Realized hit C) (h' : Realized hit C') : Realized hit (C ∪ C') := by + intro p hp + rcases Finset.mem_union.mp hp with hp | hp + · exact h p hp + · exact h' p hp + +noncomputable def anchorEvents (C : Finset (B × D)) (A : Finset D) (r : A → B) : + Finset (B × D) := + (A.attach.filter (fun d => d.val ∉ paidDirections C)).image (fun d => (r d, d.val)) + +omit [Fintype D] [Fintype B] in +lemma anchorEvents_fresh (C : Finset (B × D)) (A : Finset D) (r : A → B) : + Disjoint C (anchorEvents C A r) := by + apply Finset.disjoint_left.mpr + intro p hp he + obtain ⟨d, hd, hdp⟩ := Finset.mem_image.mp he + have hdC : d.val ∉ paidDirections C := (Finset.mem_filter.mp hd).2 + apply hdC + exact Finset.mem_image.mpr ⟨p, hp, (congrArg Prod.snd hdp).symm⟩ + +omit [Fintype D] [Fintype B] in +lemma anchorEvents_card (C : Finset (B × D)) (A : Finset D) (r : A → B) : + (anchorEvents C A r).card ≤ A.card := + (Finset.card_image_le).trans ((Finset.card_filter_le _ _).trans_eq Finset.card_attach) + +omit [Fintype D] [Fintype B] in +lemma anchorEvents_directions (C : Finset (B × D)) (A : Finset D) (r : A → B) : + paidDirections (anchorEvents C A r) ⊆ A := by + intro d hd + obtain ⟨p, hp, rfl⟩ := Finset.mem_image.mp hd + obtain ⟨a, _, rfl⟩ := Finset.mem_image.mp hp + exact a.property + +end SharedHitGeometry +end SharpRamseyFive.ResidualCertificate +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/ContextOutput.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/ContextOutput.lean new file mode 100644 index 0000000000000000000000000000000000000000..3fbf1215029292a93b2285cf9f93536e2e6e0a73 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/ContextOutput.lean @@ -0,0 +1,86 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Exposure.StreamTransport + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset Real +open scoped Classical BigOperators +noncomputable section + +structure ContextOutput {Ω F : Type} [Fintype Ω] [Fintype F] {ℓ : ℕ} + (p : Law Ω) (G : Ω→Fin ℓ→F) (m : ℕ) (B C L : ℝ) where + X : Type + Γ : Type + finiteX : Fintype X + finiteΓ : Fintype Γ + μ : @Law X finiteX + source : X→Ω + msg : X→Γ + chosen : X→Fin m↪o Fin ℓ + domains : Γ→Fin m→Finset F + supported : ∀ x,p.mass (source x)≠0 + hit : ∀ x i,G (source x) (chosen x i)∈domains (msg x) i + size : ∀ c i,((domains c i).card:ℝ)≤B + dominated : letI:=finiteX; ∀ a,(μ.map source).mass a≤L*p.mass a + cost : letI:=finiteX; letI:=finiteΓ; entropy (μ.map msg)≤C +attribute [instance] ContextOutput.finiteX ContextOutput.finiteΓ + +variable {Ω F X Γ : Type} [Fintype Ω] [Fintype F] [Fintype X] [Fintype Γ] + {ℓ m : ℕ} {B C L : ℝ} + +theorem contextOutput_of_lists (p : Law Ω) (G : Ω→Fin ℓ→F) (μ : Law X) + (source : X→Ω) (msg : X→Γ) (out : X→List F) (domains : Γ→List (Finset F)) + (hB : 0≤B) + (hlen : ∀ x,μ.mass x≠0→(out x).length=m) + (hsub : ∀ x,μ.mass x≠0→(out x).Sublist (List.ofFn (G (source x)))) + (hhit : ∀ x,μ.mass x≠0→List.Forall₂ (fun f D=>f∈D) (out x) (domains (msg x))) + (hsize : ∀ c D,D∈domains c→(D.card:ℝ)≤B) + (hdom : ∀ a,(μ.map source).mass a≤L*p.mass a) + (hcost : entropy (μ.map msg)≤C) : Nonempty (ContextOutput p G m B C L) := by + let Y:={x // μ.mass x≠0} + have he : ∀ x : Y,∃ e : Fin m↪o Fin ℓ,∀ i, + G (source x.val) (e i)=(out x.val).get ⟨i.val,by rw [hlen x.val x.property];exact i.isLt⟩ := by + intro x + obtain ⟨e,he⟩:=List.sublist_iff_exists_fin_orderEmbedding_get_eq.mp (hsub x.val x.property) + let f : Fin m↪o Fin ℓ:= + (Fin.castOrderIso (hlen x.val x.property).symm).toOrderEmbedding.trans + (e.trans (Fin.castOrderIso (List.length_ofFn (f:=G (source x.val)))).toOrderEmbedding) + refine ⟨f,?_⟩ + intro i + have hh:=he ((Fin.castOrderIso (hlen x.val x.property).symm) i) + rw [List.get_ofFn] at hh + exact hh.symm + choose e he using he + refine ⟨⟨Y,Γ,inferInstance,inferInstance,μ.nullFree,(fun x=>source x.val), + (fun x=>msg x.val),e,(fun c i=>(domains c).getD i.val ∅),?_,?_,?_,?_,?_⟩⟩ + · intro x hz + have ha:=hdom (source x.val) + rw [hz,mul_zero] at ha + have hh:=(μ.le_map source x.val).trans ha + exact x.property (le_antisymm hh (μ.nonneg x.val)) + · intro x i + rw [he] + have hdlen : (domains (msg x.val)).length=m := by + rw [←(hhit x.val x.property).length_eq,hlen x.val x.property] + rw [List.getD_eq_getElem _ _ (by rw [hdlen];exact i.isLt)] + exact (hhit x.val x.property).get (by rw [hlen x.val x.property];exact i.isLt) + (by rw [hdlen];exact i.isLt) + · intro c i + by_cases hi : i.val<(domains c).length + · rw [List.getD_eq_getElem _ _ hi] + exact hsize c _ (List.getElem_mem hi) + · rw [List.getD_eq_default _ _ (by omega)] + simpa using hB + · intro a + rw [Law.nullFree_map] + exact hdom a + · rw [Law.nullFree_map] + exact hcost +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedConditioning.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedConditioning.lean new file mode 100644 index 0000000000000000000000000000000000000000..189b10e9120f26c12aca4faea369d3a388883da4 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedConditioning.lean @@ -0,0 +1,66 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.ExecutedRetention + +namespace OAI + +section +namespace SharpLogRamsey.PublicTables +open Finset +open scoped Classical BigOperators +noncomputable section +variable {Ω Ξ : Type*} [Fintype Ω] [Fintype Ξ] + +def conditionSuccess (p : Law Ω) (E : Ω→Prop) (h : 0 simp only [zero_div] + rw [he] + have ht : (∑ x,if E x then p.mass x else 0)=acceptProb p E := by + simp only [acceptProb,accepted,mul_one] + rw [ht,div_self (ne_of_gt h)] + +lemma conditionSuccess_support (p : Law Ω) (E : Ω→Prop) (h : 0stream ω=x),p.mass ω)≤L*base x) : + ∀ x,(∑ ω∈univ.filter (fun ω=>stream ω=x),(conditionSuccess p E h).mass ω)≤ + (L/c)*base x := by + intro x + calc + _ ≤ ∑ ω∈univ.filter (fun ω=>stream ω=x),p.mass ω/acceptProb p E := by + apply sum_le_sum + intro ω _ + dsimp only [conditionSuccess] + split_ifs + · exact le_rfl + · exact div_nonneg (p.nonneg ω) h.le + _ = (∑ ω∈univ.filter (fun ω=>stream ω=x),p.mass ω)/acceptProb p E := (sum_div ..).symm + _ ≤ (L*base x)/acceptProb p E := div_le_div_of_nonneg_right (hdom x) h.le + _ ≤ (L*base x)/c := div_le_div_of_nonneg_left (mul_nonneg hL (hb x)) hc hprob + _ = _ := by ring + +end +end SharpLogRamsey.PublicTables + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedCosts.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedCosts.lean new file mode 100644 index 0000000000000000000000000000000000000000..1213841dd78e586070966b44f8f59a42097cb439 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedCosts.lean @@ -0,0 +1,73 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Trees.ChronologicalTree +import OAI.Combinatorics.SharpRamsey.Execution.ExecutedPotential + +namespace OAI + +section +namespace SharpLogRamsey.ExecutedPotential +open Finset Real BinaryTree TreeDecoder +open scoped Classical +noncomputable section +variable {A B I C : Type*} + +lemma total_cost_local (Q c P : ℝ) (read : CapReader A B C) + (choose : I→Domains A B→Option C) (cost : I→Domains A B→C→ℝ) + (hcost : ∀ i U x,choose i U=some x → cost i U x≤c*(potential Q U+P)) + (t : BinaryTree I) (U : Domains A B) : + TreePotential.total (fun z : I×Domains A B×C => cost z.1 z.2.1 z.2.2) + (annotate read choose t U)≤ + c*(TreePotential.total (fun z : I×Domains A B×C => potential Q z.2.1) + (annotate read choose t U)+((annotate read choose t U).numNodes:ℝ)*P) := by + induction t generalizing U with + | nil => simp [annotate,TreePotential.total] + | node i l r hl hr => + simp only [annotate] + split + · simp [TreePotential.total] + · rename_i x hx + have h := hcost i U x hx + have hl' := hl ((read U x).1,U.2) + have hr' := hr (U.1,(read U x).2) + simp only [TreePotential.total,numNodes,Nat.cast_add,Nat.cast_one] + linarith + +theorem maximum_cost (Q C₀ b c P : ℝ) (hQ : 0 cost z.1 z.2.1 z.2.2) + (annotate read choose t U)≤ + c*((t.height:ℝ)*(potential Q U+(t.numNodes:ℝ)*(b+log 4+2*log C₀))+ + (t.numNodes:ℝ)*P) := by + let K := b+log 4+2*log C₀ + have hK : 0≤K := add_nonneg (add_nonneg hb (log_nonneg (by norm_num))) + (mul_nonneg (by norm_num) (log_nonneg hC)) + have ha := admissible Q C₀ b hQ hC read choose hvalid t U + have ht := TreePotential.total_le_height _ K hK _ ha + have hr := root_le Q read choose t U + have hh : ((annotate read choose t U).height:ℝ)≤t.height := by + exact_mod_cast annotate_height read choose t U + have hn : ((annotate read choose t U).numNodes:ℝ)≤t.numNodes := by + exact_mod_cast annotate_numNodes read choose t U + apply (total_cost_local Q c P read choose cost hcost t U).trans + apply mul_le_mul_of_nonneg_left _ hc + apply add_le_add _ (mul_le_mul_of_nonneg_right hn hP) + apply ht.trans + apply mul_le_mul hh (add_le_add hr (mul_le_mul_of_nonneg_right hn hK)) + · exact add_nonneg (TreePotential.root_nonneg _ K ha) (mul_nonneg (by positivity) hK) + · positivity + +end +end SharpLogRamsey.ExecutedPotential + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedDecodedSize.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedDecodedSize.lean new file mode 100644 index 0000000000000000000000000000000000000000..e6a0b04e0453f2b0630ca30b85bcede74988ca00 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedDecodedSize.lean @@ -0,0 +1,80 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.ExecutedFullMessage + +namespace OAI + +section +namespace SharpLogRamsey.ExecutedPotential +open Finset BinaryTree TreeDecoder Real +open scoped Classical +noncomputable section +variable {A B C I : Type*} + +lemma flagDomain_size (R : A→B→Prop) (V : Domains A B) + (S : Finset A) (T : Finset B) (hS : S.Nonempty) (hT : T.Nonempty) + (Q C₀ b : ℝ) (hQ : 0 simp only [execute,message,decode,List.not_mem_nil,IsEmpty.forall_iff,implies_true] + | node i l r hl hr => + cases he : choose i U with + | none => simp only [execute,he,message,decode,List.not_mem_nil,IsEmpty.forall_iff,implies_true] + | some c => + simp only [execute,he,message,decode,List.mem_append] + intro D hD + rcases hD with (hD | hD) | hD + · exact hl _ D hD + · obtain ⟨_,rfl⟩:=List.mem_replicate.mp hD + exact hcap i U c he + · exact hr _ D hD + +theorem reciprocal_decoded_domains_size (R : A→B→Prop) (read : CapReader A B C) + (choose : I→Domains A B→Option C) (targets : I→List (A×B)) (counts : I→ℕ) + (Q C₀ b : ℝ) (hQ : 0∅ + | .node i l r=>if i=target then {i} else + insert i (if target∈labels l then plannedPath target l else plannedPath target r) + +lemma plannedPath_subset (target : I) (t : BinaryTree I) : plannedPath target t⊆labels t := by + induction t with + | nil=>exact empty_subset _ + | node i l r hl hr=> + rw [plannedPath,labels_node] + split_ifs with hi hj + · exact singleton_subset_iff.mpr (mem_insert_self _ _) + · exact insert_subset_insert i (hl.trans subset_union_left) + · exact insert_subset_insert i (hr.trans subset_union_right) + +lemma plannedPath_card (target : I) (t : BinaryTree I) : + (plannedPath target t).card≤t.height := by + induction t with + | nil=>rfl + | node i l r hl hr=> + rw [plannedPath] + split_ifs + · simp only [card_singleton,height]; omega + · exact (card_insert_le _ _).trans (by simp only [height]; omega) + · exact (card_insert_le _ _).trans (by simp only [height]; omega) + +def trialFailure (choose : ∀ i,α i→Domains A B→Option C) + (i : I) (V : Domains A B) (x : α i) : ℝ := if choose i x V=none then 1 else 0 + +def pivotSuccess (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (target : I) + (t : BinaryTree I) (U : Domains A B) (z : ∀ i,α i) : ℝ := + produced choose read target (fun V x=>1-trialFailure choose target V x) t U z + +theorem deletion_eq_path (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (z : ∀ i,α i) (target : I) + (t : BinaryTree I) (U : Domains A B) (ht : Separated t) + (hmem : target∈labels t) : + 1-pivotSuccess choose read target t U z= + ∑ j∈plannedPath target t,produced choose read j (trialFailure choose j) t U z := by + induction t generalizing U with + | nil=>simp [labels_nil] at hmem + | node i l r hl hr=> + rcases ht with ⟨htl,htr,hli,hri,hd⟩ + by_cases hi : i=target + · subst target + rw [plannedPath,ite_eq_left rfl,sum_singleton,produced_root,pivotSuccess,produced_root] + ring + · rw [plannedPath,ite_eq_right hi] + by_cases hL : target∈labels l + · rw [ite_eq_left hL,sum_insert (fun hj=>hli (plannedPath_subset target l hj)),produced_root] + cases hc : choose i (z i) U with + | none=> + rw [pivotSuccess,produced_deleted choose read z i target _ l r U hi hc] + have hzero : (∑ j∈plannedPath target l, + produced choose read j (trialFailure choose j) (.node i l r) U z)=0 := by + apply sum_eq_zero + intro j hj + exact produced_deleted choose read z i j _ l r U + (fun he=>hli (he ▸ plannedPath_subset target l hj)) hc + rw [hzero] + simp only [trialFailure,hc,ite_true,sub_zero,add_zero] + | some c=> + rw [pivotSuccess,produced_left choose read z i target _ l r U hL hli hd c hc] + have he : (∑ j∈plannedPath target l, + produced choose read j (trialFailure choose j) (.node i l r) U z)= + ∑ j∈plannedPath target l,produced choose read j (trialFailure choose j) + l ((read i (z i) U c).1,U.2) z := by + apply sum_congr rfl + intro j hj + exact produced_left choose read z i j _ l r U + (plannedPath_subset target l hj) hli hd c hc + rw [he] + simp only [trialFailure,hc,Option.some_ne_none,ite_false,zero_add] + exact hl _ htl hL + · have hR : target∈labels r := by + rw [labels_node,mem_insert,mem_union] at hmem + rcases hmem with he|he|he + · exact False.elim (hi he.symm) + · exact False.elim (hL he) + · exact he + rw [ite_eq_right hL,sum_insert (fun hj=>hri (plannedPath_subset target r hj)),produced_root] + cases hc : choose i (z i) U with + | none=> + rw [pivotSuccess,produced_deleted choose read z i target _ l r U hi hc] + have hzero : (∑ j∈plannedPath target r, + produced choose read j (trialFailure choose j) (.node i l r) U z)=0 := by + apply sum_eq_zero + intro j hj + exact produced_deleted choose read z i j _ l r U + (fun he=>hri (he ▸ plannedPath_subset target r hj)) hc + rw [hzero] + simp only [trialFailure,hc,ite_true,sub_zero,add_zero] + | some c=> + rw [pivotSuccess,produced_right choose read z i target _ l r U hR hri hd c hc] + have he : (∑ j∈plannedPath target r, + produced choose read j (trialFailure choose j) (.node i l r) U z)= + ∑ j∈plannedPath target r,produced choose read j (trialFailure choose j) + r (U.1,(read i (z i) U c).2) z := by + apply sum_congr rfl + intro j hj + exact produced_right choose read z i j _ l r U + (plannedPath_subset target r hj) hri hd c hc + rw [he] + simp only [trialFailure,hc,Option.some_ne_none,ite_false,zero_add] + exact hr _ htr hR + +variable [Fintype I] [∀ i,Fintype (α i)] + +theorem expected_deletion (p : ∀ i,Law (α i)) + (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (target : I) + (t : BinaryTree I) (U : Domains A B) (ht : Separated t) + (hmem : target∈labels t) (δ : ℝ) (hδ : 0≤δ) + (hlocal : ∀ j∈plannedPath target t, + (∑ z,(piLaw p).mass z*produced choose read j (trialFailure choose j) t U z)≤δ) : + (∑ z,(piLaw p).mass z*(1-pivotSuccess choose read target t U z))≤t.height*δ := by + simp_rw [deletion_eq_path choose read _ target t U ht hmem,mul_sum] + rw [sum_comm] + calc + _ ≤ ∑ j∈plannedPath target t,δ := sum_le_sum (fun j hj=>hlocal j hj) + _ = ((plannedPath target t).card:ℝ)*δ := by simp only [sum_const,nsmul_eq_mul] + _ ≤ _ := mul_le_mul_of_nonneg_right (by exact_mod_cast plannedPath_card target t) hδ + +theorem expected_deletion_quadratic (p : ∀ i,Law (α i)) + (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (target : I) + (t : BinaryTree I) (U : Domains A B) (ht : Separated t) + (hmem : target∈labels t) (a b : ℝ) (ha : 0≤a) (hb : 0≤b) + (hlocal : ∀ j∈plannedPath target t, + (∑ z,(piLaw p).mass z*produced choose read j (trialFailure choose j) t U z)≤a*t.height+b) : + (∑ z,(piLaw p).mass z*(1-pivotSuccess choose read target t U z))≤a*t.height^2+b*t.height := by + have h:=expected_deletion p choose read target t U ht hmem (a*t.height+b) + (add_nonneg (mul_nonneg ha (Nat.cast_nonneg _)) hb) hlocal + nlinarith + +end +end SharpLogRamsey.FreshExecution + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedEndpoint.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedEndpoint.lean new file mode 100644 index 0000000000000000000000000000000000000000..531ff18812209c8738e56514cd5efd7642b43a90 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedEndpoint.lean @@ -0,0 +1,119 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.ExecutedDeletion +import OAI.Combinatorics.SharpRamsey.Execution.ExecutedSecondTrim + +namespace OAI + +section +namespace SharpLogRamsey.FreshExecution +open Finset BinaryTree TreeDecoder PublicTables +open scoped Classical BigOperators +noncomputable section +variable {I A B C : Type*} [DecidableEq I] {α : I→Type*} + +def targetFailure (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (a : A) (b : B) (i : I) + (t : BinaryTree I) (U : Domains A B) (z : ∀ i,α i) : ℝ := + match arrive choose read z i t U with + | none=>1 + | some V=>match choose i (z i) V with + | none=>1 + | some c=>if a∈(read i (z i) V c).1 ∧ b∈(read i (z i) V c).2 then 0 else 1 + +theorem target_failure_charge (choose : ∀ i,α i→Domains A B→Option C) + (read mask : ∀ i,α i→CapReader A B C) + (hreadA : ∀ i x V c,(read i x V c).1=V.1∩(mask i x V c).1) + (hreadB : ∀ i x V c,(read i x V c).2=V.2∩(mask i x V c).2) + (z : ∀ i,α i) (target : I) (a : A) (b : B) + (t : BinaryTree I) (U : Domains A B) (ht : Separated t) + (hmem : target∈labels t) (haU : a∈U.1) (hbU : b∈U.2) : + targetFailure choose read a b target t U z≤ + 1-pivotSuccess choose read target t U z+ + (∑ j∈leftPath target t,produced choose read j (firstLoss choose mask {a} j) t U z)+ + (∑ j∈rightPath target t,produced choose read j (secondLoss choose mask {b} j) t U z)+ + produced choose read target (firstLoss choose mask {a} target) t U z+ + produced choose read target (secondLoss choose mask {b} target) t U z := by + have hpA : 0≤∑ j∈leftPath target t,produced choose read j (firstLoss choose mask {a} j) t U z := by + apply sum_nonneg + intro j _ + exact produced_nonneg choose read j _ (firstLoss_nonneg choose mask {a} j) t U z + have hpB : 0≤∑ j∈rightPath target t,produced choose read j (secondLoss choose mask {b} j) t U z := by + apply sum_nonneg + intro j _ + exact produced_nonneg choose read j _ (secondLoss_nonneg choose mask {b} j) t U z + have hoA := produced_nonneg choose read target _ (firstLoss_nonneg choose mask {a} target) t U z + have hoB := produced_nonneg choose read target _ (secondLoss_nonneg choose mask {b} target) t U z + cases hv : arrive choose read z target t U with + | none=> + have hs : pivotSuccess choose read target t U z=0 := by simp only [pivotSuccess,produced,hv] + rw [targetFailure,hv,hs] + linarith + | some V=> + cases hc : choose target (z target) V with + | none=> + have hs : pivotSuccess choose read target t U z=0 := by + simp only [pivotSuccess,produced,hv,trialFailure,hc,ite_true,sub_self] + simp only [targetFailure,hv,hc,hs] + linarith + | some c=> + have hs : pivotSuccess choose read target t U z=1 := by + simp only [pivotSuccess,produced,hv,trialFailure,hc,Option.some_ne_none,ite_false,sub_zero] + have hoA' : produced choose read target (firstLoss choose mask {a} target) t U z= + (({a}\(mask target (z target) V c).1).card:ℝ) := by + simp only [produced,hv,firstLoss,hc] + have hoB' : produced choose read target (secondLoss choose mask {b} target) t U z= + (({b}\(mask target (z target) V c).2).card:ℝ) := by + simp only [produced,hv,secondLoss,hc] + have hf:=reached_first_loss choose read mask hreadA z target {a} t U V ht hmem hv + have hg:=reached_second_loss choose read mask hreadB z target {b} t U V ht hmem hv + rw [sdiff_eq_empty_iff_subset.mpr (singleton_subset_iff.mpr haU),card_empty,Nat.cast_zero,zero_add] at hf + rw [sdiff_eq_empty_iff_subset.mpr (singleton_subset_iff.mpr hbU),card_empty,Nat.cast_zero,zero_add] at hg + have hcapA : (({a}\(read target (z target) V c).1).card:ℝ)≤ + (({a}\V.1).card:ℝ)+({a}\(mask target (z target) V c).1).card := by + rw [hreadA] + exact sdiff_inter_card {a} V.1 _ + have hcapB : (({b}\(read target (z target) V c).2).card:ℝ)≤ + (({b}\V.2).card:ℝ)+({b}\(mask target (z target) V c).2).card := by + rw [hreadB] + exact sdiff_inter_card {b} V.2 _ + have hpoint : (if a∈(read target (z target) V c).1 ∧ b∈(read target (z target) V c).2 + then (0:ℝ) else 1)≤ + (({a}\(read target (z target) V c).1).card:ℝ)+({b}\(read target (z target) V c).2).card := by + have haa : (({a}\(read target (z target) V c).1).card:ℝ) = + if a∈(read target (z target) V c).1 then 0 else 1 := by + by_cases ha : a∈(read target (z target) V c).1 + · rw [sdiff_eq_empty_iff_subset.mpr (singleton_subset_iff.mpr ha)] + simp [ha] + · have he : {a}\(read target (z target) V c).1={a} := by + ext x + simp only [mem_sdiff,mem_singleton] + constructor + · exact And.left + · rintro rfl + exact ⟨rfl,ha⟩ + simp [he,ha] + have hbb : (({b}\(read target (z target) V c).2).card:ℝ) = + if b∈(read target (z target) V c).2 then 0 else 1 := by + by_cases hb : b∈(read target (z target) V c).2 + · rw [sdiff_eq_empty_iff_subset.mpr (singleton_subset_iff.mpr hb)] + simp [hb] + · have he : {b}\(read target (z target) V c).2={b} := by + ext x + simp only [mem_sdiff,mem_singleton] + constructor + · exact And.left + · rintro rfl + exact ⟨rfl,hb⟩ + simp [he,hb] + rw [haa,hbb] + split_ifs <;> norm_num + tauto + simp only [targetFailure,hv,hc,hs,hoA',hoB'] + linarith + +end +end SharpLogRamsey.FreshExecution + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedExpectedOutput.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedExpectedOutput.lean new file mode 100644 index 0000000000000000000000000000000000000000..c548a7bb8a8562e3549bc43aee43ed14a8869f88 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedExpectedOutput.lean @@ -0,0 +1,57 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.ExecutedOutputCount + +namespace OAI + +section +namespace SharpLogRamsey.FreshExecution +open Finset BinaryTree TreeDecoder PublicTables +open scoped Classical BigOperators +noncomputable section +variable {I A B C Ω : Type*} [DecidableEq I] [Fintype Ω] {α : I→Type*} + +theorem expected_literal_loss (μ : Law Ω) (R : A→B→Prop) + (choose : Ω→∀ i,α i→Domains A B→Option C) + (read : Ω→∀ i,α i→CapReader A B C) (z : Ω→∀ i,α i) + (n : ℕ) (target : Ω→I→Fin n→A×B) (t : BinaryTree I) (U : Domains A B) + (ht : Separated t) + (hR : ∀ ω,∀ i∈labels t,∀ j,R (target ω i j).1 (target ω i j).2) + (δ : ℝ) + (hpoint : ∀ i∈labels t,∀ j,(∑ ω,μ.mass ω* + targetFailure (choose ω) (read ω) (target ω i j).1 (target ω i j).2 i t U (z ω))≤δ) : + (∑ ω,μ.mass ω*(((labels t).card:ℝ)*n- + (fullOutput R (choose ω) (read ω) (fun i=>List.ofFn (target ω i)) (z ω) t U).length))≤ + ((labels t).card:ℝ)*n*δ := by + have hsize (ω : Ω) : + ((population (fun i=>List.ofFn (target ω i)) t).length:ℝ)=((labels t).card:ℝ)*n := by + rw [population_length_sum _ t ht] + simp only [List.length_ofFn,sum_const,nsmul_eq_mul] + have he (ω : Ω) : ((labels t).card:ℝ)*n- + (fullOutput R (choose ω) (read ω) (fun i=>List.ofFn (target ω i)) (z ω) t U).length= + ∑ i∈labels t,∑ j : Fin n,targetFailure (choose ω) (read ω) + (target ω i j).1 (target ω i j).2 i t U (z ω) := by + rw [←hsize ω,output_loss_eq_targets R (choose ω) (read ω) _ (z ω) t U ht] + · simp only [List.map_ofFn,List.sum_ofFn,Function.comp_apply] + · intro i hi x hx + obtain ⟨j,rfl⟩:=List.mem_ofFn.mp hx + exact hR ω i hi j + simp_rw [he,mul_sum] + rw [sum_comm] + calc + _ = ∑ i∈labels t,∑ j : Fin n,∑ ω,μ.mass ω* + targetFailure (choose ω) (read ω) (target ω i j).1 (target ω i j).2 i t U (z ω) := by + apply sum_congr rfl + intro i _ + exact sum_comm + _ ≤ ∑ _i∈labels t,∑ _j : Fin n,δ := by + apply sum_le_sum + intro i hi + exact sum_le_sum (fun j _=>hpoint i hi j) + _ = _ := by simp only [sum_const,card_univ,Fintype.card_fin,nsmul_eq_mul,mul_assoc] + +end +end SharpLogRamsey.FreshExecution + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedExtraction.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedExtraction.lean new file mode 100644 index 0000000000000000000000000000000000000000..1726ffde6192816d2230112f4dc7487670aed7c6 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedExtraction.lean @@ -0,0 +1,78 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.ExecutedConditioning + +namespace OAI + +section +namespace SharpLogRamsey.FreshExecution +open Finset BinaryTree TreeDecoder PublicTables +open scoped Classical BigOperators +noncomputable section +variable {I A B C Ω : Type*} [DecidableEq I] {α : I→Type*} + +def fullMessage (R : A→B→Prop) + (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (targets : I→List (A×B)) + (z : ∀ i,α i) (t : BinaryTree I) (U : Domains A B) : BinaryTree ((I×C)×ℕ) := + message R (fixedRead read z) targets (fun i=>(targets i).length) + (execute (fixedRead read z) (fixedChoose choose z) t U) U + +omit [DecidableEq I] in +lemma prefix_decoder_correct (R : A→B→Prop) + (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (targets : I→List (A×B)) + (z : ∀ i,α i) (t : BinaryTree I) (U : Domains A B) (m : ℕ) : + List.Forall₂ (fun x D=>x∈D) + ((fullOutput R choose read targets z t U).take m) + ((decode R (fixedRead read z) (fullMessage R choose read targets z t U) U).take m) := by + exact List.forall₂_take m (decoder_correct R (fixedRead read z) targets + (fun i=>(targets i).length) (execute (fixedRead read z) (fixedChoose choose z) t U) U) + +variable [Fintype Ω] [Fintype I] [∀ i,Fintype (α i)] + +theorem fixed_extraction (μ : Law Ω) (p : ∀ i,Law (α i)) (R : A→B→Prop) + (choose : Ω→∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (targets : Ω→I→List (A×B)) + (t : Ω→BinaryTree I) (U : Domains A B) (N : ℕ) (hN : 0(N:ℝ)/2≤(fullOutput R (choose ω) read (targets ω) z (t ω) U).length + ∃ hE : 0x∈D) out + ((decode R (fixedRead read z) (fullMessage R (choose ω) read (targets ω) z (t ω) U) U).take (N/2)) := by + obtain ⟨z,hz⟩:=fixed_output_half μ p R choose (fun _=>read) targets t U N hN hsize hmean + let E:=fun ω=>(N:ℝ)/2≤(fullOutput R (choose ω) read (targets ω) z (t ω) U).length + have he : (1/2:ℝ)≤acceptProb μ E := by + convert hz using 1 + simp only [acceptProb,accepted] + apply sum_congr rfl + intro ω _ + split_ifs <;> simp only [mul_zero,mul_one] + have hp : 0 + by_cases hb : bad <;> simp [firstTrim,secondTrim,ha,hb] + | some V=> + have hS : firstTrim choose read S i t U z ↔ + ((S∩V.1).card:ℝ)<(9/10:ℝ)*S.card := by simp [firstTrim,ha] + have hT : secondTrim choose read T i t U z ↔ + ((T∩V.2).card:ℝ)<(9/10:ℝ)*T.card := by simp [secondTrim,ha] + rw [hS,hT] + by_cases hs : ((S∩V.1).card:ℝ)<(9/10:ℝ)*S.card <;> + by_cases ht : ((T∩V.2).card:ℝ)<(9/10:ℝ)*T.card <;> + by_cases hb : bad <;> by_cases hc : choose i (z i) V=none <;> + norm_num [readyFailure,trialFailure,hs,ht,hb,hc] + +variable [Fintype I] [Fintype Ω] [∀ i,Fintype (α i)] + +theorem averaged_failure_budget (μ : Law Ω) (p : ∀ i,Law (α i)) (dummy : ∀ i,α i) + (choose : Ω→∀ i,α i→Domains A B→Option C) + (read : Ω→∀ i,α i→CapReader A B C) (i : I) + (S : Ω→Finset A) (T : Ω→Finset B) (bad : Ω→Prop) + (t : BinaryTree I) (U : Domains A B) (F G D ρ : ℝ) (hρ : 0≤ρ) + (hfirst : (∑ ω,μ.mass ω*(∑ z,(piLaw p).mass z* + (if firstTrim (choose ω) (read ω) (S ω) i t U z then (1:ℝ) else 0)))≤F) + (hsecond : (∑ ω,μ.mass ω*(∑ z,(piLaw p).mass z* + (if secondTrim (choose ω) (read ω) (T ω) i t U z then (1:ℝ) else 0)))≤G) + (hdensity : (∑ ω,μ.mass ω*(if bad ω then (1:ℝ) else 0))≤D) + (hready : ∀ ω V,(∑ x,(p i).mass x*readyFailure (choose ω) (S ω) (T ω) (bad ω) i V x)≤ρ) : + (∑ ω,μ.mass ω*(∑ z,(piLaw p).mass z* + produced (choose ω) (read ω) i (trialFailure (choose ω) i) t U z))≤F+G+D+ρ := by + have hprodω (ω : Ω) : (∑ z,(piLaw p).mass z* + produced (choose ω) (read ω) i (readyFailure (choose ω) (S ω) (T ω) (bad ω) i) t U z)≤ρ := + produced_bound p (choose ω) (read ω) i (dummy i) _ t U ρ hρ (hready ω) + have hprod : (∑ ω,μ.mass ω*(∑ z,(piLaw p).mass z* + produced (choose ω) (read ω) i (readyFailure (choose ω) (S ω) (T ω) (bad ω) i) t U z))≤ρ := by + calc + _ ≤ ∑ ω,μ.mass ω*ρ := sum_le_sum (fun ω _=>mul_le_mul_of_nonneg_left (hprodω ω) (μ.nonneg ω)) + _ = ρ := by rw [←sum_mul,μ.total,one_mul] + have hpart : (∑ ω,μ.mass ω*(∑ z,(piLaw p).mass z* + produced (choose ω) (read ω) i (trialFailure (choose ω) i) t U z))≤ + ∑ ω,μ.mass ω*(∑ z,(piLaw p).mass z*((if firstTrim (choose ω) (read ω) (S ω) i t U z then (1:ℝ) else 0)+ + (if secondTrim (choose ω) (read ω) (T ω) i t U z then (1:ℝ) else 0)+ + (if bad ω then (1:ℝ) else 0)+produced (choose ω) (read ω) i + (readyFailure (choose ω) (S ω) (T ω) (bad ω) i) t U z)) := by + apply sum_le_sum + intro ω _ + apply mul_le_mul_of_nonneg_left _ (μ.nonneg ω) + apply sum_le_sum + intro z _ + exact mul_le_mul_of_nonneg_left + (failure_partition (choose ω) (read ω) z i (S ω) (T ω) (bad ω) t U) ((piLaw p).nonneg z) + simp_rw [mul_add,sum_add_distrib] at hpart + simp only [←sum_mul,(piLaw p).total,one_mul] at hpart + simp_rw [mul_add,sum_add_distrib] at hpart + linarith + +theorem original_deletion_quadratic (μ : Law Ω) (p : ∀ i,Law (α i)) (dummy : ∀ i,α i) + (choose : Ω→∀ i,α i→Domains A B→Option C) + (read : Ω→∀ i,α i→CapReader A B C) + (S : Ω→I→Finset A) (T : Ω→I→Finset B) (bad : Ω→I→Prop) + (target : I) (t : BinaryTree I) (U : Domains A B) (ht : Separated t) + (hmem : target∈labels t) (ε D ρ : ℝ) (hε : 0≤ε) (hD : 0≤D) (hρ : 0≤ρ) + (hfirst : ∀ i∈plannedPath target t,(∑ ω,μ.mass ω*(∑ z,(piLaw p).mass z* + (if firstTrim (choose ω) (read ω) (S ω i) i t U z then (1:ℝ) else 0)))≤10*t.height*ε) + (hsecond : ∀ i∈plannedPath target t,(∑ ω,μ.mass ω*(∑ z,(piLaw p).mass z* + (if secondTrim (choose ω) (read ω) (T ω i) i t U z then (1:ℝ) else 0)))≤10*t.height*ε) + (hdensity : ∀ i∈plannedPath target t,(∑ ω,μ.mass ω*(if bad ω i then (1:ℝ) else 0))≤D) + (hready : ∀ i∈plannedPath target t,∀ ω V, + (∑ x,(p i).mass x*readyFailure (choose ω) (S ω i) (T ω i) (bad ω i) i V x)≤ρ) : + (∑ ω,μ.mass ω*(∑ z,(piLaw p).mass z*(1-pivotSuccess (choose ω) (read ω) target t U z)))≤ + 20*ε*t.height^2+(D+ρ)*t.height := by + have hloc (i : I) (hi : i∈plannedPath target t) : + (∑ ω,μ.mass ω*(∑ z,(piLaw p).mass z* + produced (choose ω) (read ω) i (trialFailure (choose ω) i) t U z))≤ + 20*t.height*ε+D+ρ := by + have h:=averaged_failure_budget μ p dummy choose read i (fun ω=>S ω i) (fun ω=>T ω i) + (fun ω=>bad ω i) t U (10*t.height*ε) (10*t.height*ε) D ρ hρ + (hfirst i hi) (hsecond i hi) (hdensity i hi) (hready i hi) + linarith + have he (ω : Ω) : + (∑ z,(piLaw p).mass z*(1-pivotSuccess (choose ω) (read ω) target t U z))= + ∑ i∈plannedPath target t,(∑ z,(piLaw p).mass z* + produced (choose ω) (read ω) i (trialFailure (choose ω) i) t U z) := by + simp_rw [deletion_eq_path (choose ω) (read ω) _ target t U ht hmem,mul_sum] + rw [sum_comm] + simp_rw [he,mul_sum] + rw [sum_comm] + simp_rw [mul_sum] at hloc + calc + _ ≤ ∑ _i∈plannedPath target t,(20*t.height*ε+D+ρ) := sum_le_sum (fun i hi=>hloc i hi) + _ = ((plannedPath target t).card:ℝ)*(20*t.height*ε+D+ρ) := by simp only [sum_const,nsmul_eq_mul] + _ ≤ (t.height:ℝ)*(20*t.height*ε+D+ρ) := by + apply mul_le_mul_of_nonneg_right (by exact_mod_cast plannedPath_card target t) + positivity + _ = _ := by ring + +end +end SharpLogRamsey.FreshExecution + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedFullMessage.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedFullMessage.lean new file mode 100644 index 0000000000000000000000000000000000000000..5ad442d3510b9c9b37f3f557d1265ed1945930cd --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedFullMessage.lean @@ -0,0 +1,127 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.ExecutedMessage + +namespace OAI + +section +namespace SharpLogRamsey.ExecutedPotential +open Finset Real BinaryTree TreeDecoder TreeCodeEntropy +open scoped Classical +noncomputable section +variable {A B C I Ω : Type*} + +def countReader (read : CapReader A B C) : CapReader A B (C×ℕ) := + fun U x=>read U x.1 + +def countChoose (R : A→B→Prop) (read : CapReader A B C) + (choose : I→Domains A B→Option C) (targets : I→List (A×B)) (counts : I→ℕ) : + I→Domains A B→Option (C×ℕ) := fun i U=> + (choose i U).map (fun c=>(c,(retained R (read U c) (targets i) (counts i)).length)) + +lemma fullMessage_eq_codeTree (R : A→B→Prop) (read : CapReader A B C) + (choose : I→Domains A B→Option C) (targets : I→List (A×B)) (counts : I→ℕ) + (t : BinaryTree I) (U : Domains A B) : + message R read targets counts (execute read choose t U) U= + codeTree (countReader read) (countChoose R read choose targets counts) t U := by + induction t generalizing U with + | nil => rfl + | node i l r hl hr => + cases he : choose i U with + | none => simp only [execute,he,message,codeTree,countChoose,Option.map_none,BinaryTree.map] + | some c => + simp only [execute,he,message,codeTree,countChoose,Option.map_some,countReader,BinaryTree.map] + exact congrArg₂ (fun x y=>BinaryTree.node _ x y) (hl _) (hr _) + +def countAlphabet (allowed : Domains A B→Finset C) (n : ℕ) (U : Domains A B) : Finset (C×ℕ) := + allowed U ×ˢ range (n+1) + +lemma countChoose_mem (R : A→B→Prop) (read : CapReader A B C) + (choose : I→Domains A B→Option C) (targets : I→List (A×B)) (counts : I→ℕ) + (allowed : Domains A B→Finset C) (n : ℕ) + (hc : ∀ i,counts i≤n) (ha : ∀ i U c,choose i U=some c→c∈allowed U) + (i : I) (U : Domains A B) (x : C×ℕ) + (hx : countChoose R read choose targets counts i U=some x) : x∈countAlphabet allowed n U := by + obtain ⟨c,he,rfl⟩:=Option.map_eq_some_iff.mp hx + apply mem_product.mpr + refine ⟨ha i U c he,mem_range.mpr ?_⟩ + have hh : (retained R (read U c) (targets i) (counts i)).length≤counts i := + List.length_take_le _ _ + have hn:=hc i + omega + +lemma countAlphabet_log (allowed : Domains A B→Finset C) (n : ℕ) (U : Domains A B) (h : (allowed U).Nonempty) : + log (countAlphabet allowed n U).card=log (allowed U).card+log (n+1:ℕ) := by + rw [countAlphabet,card_product,card_range,Nat.cast_mul] + exact log_mul (by exact_mod_cast (card_pos.mpr h).ne') (by positivity) + +variable [Fintype Ω] + +theorem full_execution_entropy (p : Selection.Law Ω) + (Q C₀ b c P : ℝ) (hQ : 0codeTree (countReader read) + (countChoose R read (choose ω) (targets ω) (counts ω)) (t ω) U + let S := univ.image M + let msg : Ω→S := fun ω=>⟨M ω,mem_image.mpr ⟨ω,mem_univ _,rfl⟩⟩ + Selection.entropy (p.map msg)≤((2*N+1:ℕ):ℝ)*log 2+ + (c+1)*((H:ℝ)*(potential Q U+(N:ℝ)*(b+log 4+2*log C₀))+ + (N:ℝ)*(P+log (n+1:ℕ))) := by + have hn : 0≤log (n+1:ℕ) := log_nonneg (by exact_mod_cast Nat.le_add_left 1 n) + have hV : ∀ ω i V x,countChoose R read (choose ω) (targets ω) (counts ω) i V=some x→ + ∃ S : Finset A,∃ T : Finset B,S.Nonempty ∧ T.Nonempty ∧ + (9/10:ℝ)*S.card≤(S∩V.1).card ∧ (9/10:ℝ)*T.card≤(T∩V.2).card ∧ + Q*exp (-b)≤(S.card:ℝ)*T.card ∧ + (((countReader read) V x).1.card:ℝ)≤C₀*Q/T.card ∧ + (((countReader read) V x).2.card:ℝ)≤C₀*Q/S.card := by + intro ω i V x hx + obtain ⟨y,hy,rfl⟩:=Option.map_eq_some_iff.mp hx + exact hvalid ω i V y hy + have hC' : ∀ ω i V x,countChoose R read (choose ω) (targets ω) (counts ω) i V=some x→ + log (countAlphabet allowed n V).card≤(c+1)*(potential Q V+(P+log (n+1:ℕ))) := by + intro ω i V x hx + obtain ⟨y,hy,rfl⟩:=Option.map_eq_some_iff.mp hx + rw [countAlphabet_log allowed n V ⟨y,hallowed ω i V y hy⟩] + have hbnd:=hcost ω i V y hy + have hp:=potential_nonneg Q V + nlinarith [mul_nonneg hc hn] + dsimp only + apply tree_message_entropy _ (countAlphabet allowed n) (countReader read) U + Subtype.val Subtype.val_injective N + · intro g + obtain ⟨ω,hω,he⟩:=mem_image.mp g.property + rw [←he] + exact (codeTree_numNodes (countReader read) + (countChoose R read (choose ω) (targets ω) (counts ω)) (t ω) U).trans (hN ω) + · intro g + obtain ⟨ω,hω,he⟩:=mem_image.mp g.property + rw [←he] + exact codeTree_mem (countAlphabet allowed n) (countReader read) + (countChoose R read (choose ω) (targets ω) (counts ω)) + (countChoose_mem R read (choose ω) (targets ω) (counts ω) allowed n + (hcounts ω) (hallowed ω)) (t ω) U + · intro g + obtain ⟨ω,hω,he⟩:=mem_image.mp g.property + rw [←he] + exact codeTree_cost_bound Q C₀ b (c+1) (P+log (n+1:ℕ)) hQ hC hb + (by linarith) (add_nonneg hP hn) N H (countAlphabet allowed n) (countReader read) + (countChoose R read (choose ω) (targets ω) (counts ω)) (hV ω) (hC' ω) + (t ω) (hN ω) (hH ω) U + +end +end SharpLogRamsey.ExecutedPotential + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedGoodTarget.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedGoodTarget.lean new file mode 100644 index 0000000000000000000000000000000000000000..ca936e14b853d6ed9d4600fbd6f8f41f0550e271 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedGoodTarget.lean @@ -0,0 +1,163 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.ExecutedTargetBudget + +namespace OAI + +section +namespace SharpLogRamsey.FreshExecution +open Finset BinaryTree TreeDecoder PublicTables +open scoped Classical BigOperators +noncomputable section +variable {I A B C Ω : Type*} [DecidableEq I] {α : I→Type*} + +def goodSingleton (good : Prop) (a : A) : Finset A := if good then {a} else ∅ + +lemma targetFailure_le_one (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (a : A) (b : B) (i : I) + (t : BinaryTree I) (U : Domains A B) (z : ∀ i,α i) : + targetFailure choose read a b i t U z≤1 := by + unfold targetFailure + split + · exact le_rfl + · split + · exact le_rfl + · split_ifs <;> norm_num + +lemma deletion_nonneg (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (i : I) + (t : BinaryTree I) (U : Domains A B) (z : ∀ i,α i) : + 0≤1-pivotSuccess choose read i t U z := by + unfold pivotSuccess produced + split + · norm_num + · dsimp [trialFailure] + split_ifs <;> norm_num + +lemma target_failure_good_charge (choose : ∀ i,α i→Domains A B→Option C) + (read mask : ∀ i,α i→CapReader A B C) + (hreadA : ∀ i x V c,(read i x V c).1=V.1∩(mask i x V c).1) + (hreadB : ∀ i x V c,(read i x V c).2=V.2∩(mask i x V c).2) + (goodA goodB : Prop) (z : ∀ i,α i) (target : I) (a : A) (b : B) + (t : BinaryTree I) (U : Domains A B) (ht : Separated t) + (hmem : target∈labels t) (haU : a∈U.1) (hbU : b∈U.2) : + targetFailure choose read a b target t U z≤ + 1-pivotSuccess choose read target t U z+ + (if goodA then (0:ℝ) else 1)+(if goodB then (0:ℝ) else 1)+ + (∑ j∈leftPath target t,produced choose read j (firstLoss choose mask (goodSingleton goodA a) j) t U z)+ + (∑ j∈rightPath target t,produced choose read j (secondLoss choose mask (goodSingleton goodB b) j) t U z)+ + produced choose read target (firstLoss choose mask (goodSingleton goodA a) target) t U z+ + produced choose read target (secondLoss choose mask (goodSingleton goodB b) target) t U z := by + by_cases hA : goodA ∧ goodB + · simpa only [goodSingleton,ite_eq_left hA.1,ite_eq_left hA.2,add_zero] using + target_failure_charge choose read mask hreadA hreadB z target a b t U ht hmem haU hbU + · have hbad : (1:ℝ)≤(if goodA then (0:ℝ) else 1)+(if goodB then (0:ℝ) else 1) := by + split_ifs <;> try norm_num + tauto + have hlo := targetFailure_le_one choose read a b target t U z + have hd := deletion_nonneg choose read target t U z + have hoA := produced_nonneg choose read target _ + (firstLoss_nonneg choose mask (goodSingleton goodA a) target) t U z + have hoB := produced_nonneg choose read target _ + (secondLoss_nonneg choose mask (goodSingleton goodB b) target) t U z + have hpA : 0≤∑ j∈leftPath target t,produced choose read j + (firstLoss choose mask (goodSingleton goodA a) j) t U z := by + exact sum_nonneg (fun j _=>produced_nonneg choose read j _ + (firstLoss_nonneg choose mask _ j) t U z) + have hpB : 0≤∑ j∈rightPath target t,produced choose read j + (secondLoss choose mask (goodSingleton goodB b) j) t U z := by + exact sum_nonneg (fun j _=>produced_nonneg choose read j _ + (secondLoss_nonneg choose mask _ j) t U z) + linarith + +variable [Fintype I] [Fintype Ω] [∀ i,Fintype (α i)] + +theorem original_good_target_loss (μ : Law Ω) (p : ∀ i,Law (α i)) (dummy : ∀ i,α i) + (choose : Ω→∀ i,α i→Domains A B→Option C) + (read mask : Ω→∀ i,α i→CapReader A B C) + (hreadA : ∀ ω i x V c,(read ω i x V c).1=V.1∩(mask ω i x V c).1) + (hreadB : ∀ ω i x V c,(read ω i x V c).2=V.2∩(mask ω i x V c).2) + (goodA goodB : Ω→Prop) (a : Ω→A) (b : Ω→B) (target : I) (t : BinaryTree I) (U : Domains A B) + (ht : Separated t) (hmem : target∈labels t) + (haU : ∀ ω,a ω∈U.1) (hbU : ∀ ω,b ω∈U.2) + (BA BB : Ω→I→ℝ) (εA εB L δA δB : ℝ) (hεA : 0≤εA) (hεB : 0≤εB) + (hBA : ∀ ω,∀ i∈insert target (leftPath target t),0≤BA ω i) + (hBB : ∀ ω,∀ i∈insert target (rightPath target t),0≤BB ω i) + (hlocalA : ∀ ω,∀ i∈insert target (leftPath target t),∀ V, + (∑ x,(p i).mass x*firstLoss (choose ω) (mask ω) (goodSingleton (goodA ω) (a ω)) i V x)≤BA ω i) + (hlocalB : ∀ ω,∀ i∈insert target (rightPath target t),∀ V, + (∑ x,(p i).mass x*secondLoss (choose ω) (mask ω) (goodSingleton (goodB ω) (b ω)) i V x)≤BB ω i) + (hmeanA : ∀ i∈insert target (leftPath target t),(∑ ω,μ.mass ω*BA ω i)≤εA) + (hmeanB : ∀ i∈insert target (rightPath target t),(∑ ω,μ.mass ω*BB ω i)≤εB) + (hbadA : (∑ ω,μ.mass ω*(if goodA ω then (0:ℝ) else 1))≤δA) + (hbadB : (∑ ω,μ.mass ω*(if goodB ω then (0:ℝ) else 1))≤δB) + (hdelete : (∑ ω,μ.mass ω*(∑ z,(piLaw p).mass z* + (1-pivotSuccess (choose ω) (read ω) target t U z)))≤L) : + (∑ ω,μ.mass ω*(∑ z,(piLaw p).mass z* + targetFailure (choose ω) (read ω) (a ω) (b ω) target t U z))≤ + L+δA+δB+((t.height:ℝ)+1)*(εA+εB) := by + have hpathA := averaged_path_bound μ p dummy choose read + (fun ω i=>firstLoss (choose ω) (mask ω) (goodSingleton (goodA ω) (a ω)) i) t U (leftPath target t) + (fun _=>1) (fun _=>by norm_num) BA + (fun ω i hi=>hBA ω i (mem_insert_of_mem hi)) + (fun ω i hi=>hlocalA ω i (mem_insert_of_mem hi)) εA + (fun i hi=>by simpa only [div_one] using hmeanA i (mem_insert_of_mem hi)) + have hpathB := averaged_path_bound μ p dummy choose read + (fun ω i=>secondLoss (choose ω) (mask ω) (goodSingleton (goodB ω) (b ω)) i) t U (rightPath target t) + (fun _=>1) (fun _=>by norm_num) BB + (fun ω i hi=>hBB ω i (mem_insert_of_mem hi)) + (fun ω i hi=>hlocalB ω i (mem_insert_of_mem hi)) εB + (fun i hi=>by simpa only [div_one] using hmeanB i (mem_insert_of_mem hi)) + have hownA := averaged_path_bound μ p dummy choose read + (fun ω i=>firstLoss (choose ω) (mask ω) (goodSingleton (goodA ω) (a ω)) i) t U {target} + (fun _=>1) (fun _=>by norm_num) BA + (fun ω i hi=>hBA ω i (by rw [mem_singleton.mp hi]; exact mem_insert_self _ _)) + (fun ω i hi=>hlocalA ω i (by rw [mem_singleton.mp hi]; exact mem_insert_self _ _)) εA + (fun i hi=>by + have hi' : i=target := mem_singleton.mp hi + subst i + simpa only [div_one] using hmeanA target (mem_insert_self _ _)) + have hownB := averaged_path_bound μ p dummy choose read + (fun ω i=>secondLoss (choose ω) (mask ω) (goodSingleton (goodB ω) (b ω)) i) t U {target} + (fun _=>1) (fun _=>by norm_num) BB + (fun ω i hi=>hBB ω i (by rw [mem_singleton.mp hi]; exact mem_insert_self _ _)) + (fun ω i hi=>hlocalB ω i (by rw [mem_singleton.mp hi]; exact mem_insert_self _ _)) εB + (fun i hi=>by + have hi' : i=target := mem_singleton.mp hi + subst i + simpa only [div_one] using hmeanB target (mem_insert_self _ _)) + simp only [div_one] at hpathA hpathB + simp only [div_one,sum_singleton,card_singleton,Nat.cast_one,one_mul] at hownA hownB + have hcA : ((leftPath target t).card:ℝ)*εA≤(t.height:ℝ)*εA := + mul_le_mul_of_nonneg_right (by exact_mod_cast leftPath_card target t) hεA + have hcB : ((rightPath target t).card:ℝ)*εB≤(t.height:ℝ)*εB := + mul_le_mul_of_nonneg_right (by exact_mod_cast rightPath_card target t) hεB + have hpart : (∑ ω,μ.mass ω*(∑ z,(piLaw p).mass z* + targetFailure (choose ω) (read ω) (a ω) (b ω) target t U z))≤ + ∑ ω,μ.mass ω*(∑ z,(piLaw p).mass z*( + 1-pivotSuccess (choose ω) (read ω) target t U z+ + (if goodA ω then (0:ℝ) else 1)+(if goodB ω then (0:ℝ) else 1)+ + (∑ j∈leftPath target t,produced (choose ω) (read ω) j + (firstLoss (choose ω) (mask ω) (goodSingleton (goodA ω) (a ω)) j) t U z)+ + (∑ j∈rightPath target t,produced (choose ω) (read ω) j + (secondLoss (choose ω) (mask ω) (goodSingleton (goodB ω) (b ω)) j) t U z)+ + produced (choose ω) (read ω) target (firstLoss (choose ω) (mask ω) (goodSingleton (goodA ω) (a ω)) target) t U z+ + produced (choose ω) (read ω) target (secondLoss (choose ω) (mask ω) (goodSingleton (goodB ω) (b ω)) target) t U z)) := by + apply sum_le_sum + intro ω _ + apply mul_le_mul_of_nonneg_left _ (μ.nonneg ω) + apply sum_le_sum + intro z _ + exact mul_le_mul_of_nonneg_left (target_failure_good_charge (choose ω) (read ω) (mask ω) + (hreadA ω) (hreadB ω) (goodA ω) (goodB ω) z target (a ω) (b ω) t U ht hmem (haU ω) (hbU ω)) + ((piLaw p).nonneg z) + simp_rw [mul_add,sum_add_distrib] at hpart + simp_rw [mul_add,sum_add_distrib] at hpart + simp only [←sum_mul,(piLaw p).total,one_mul] at hpart + linarith + +end +end SharpLogRamsey.FreshExecution + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedLawExtraction.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedLawExtraction.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a1b24cf2053002874c02f06c31aa3a56fb7d6ae --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedLawExtraction.lean @@ -0,0 +1,74 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.ExecutedExtraction + +namespace OAI + +section +namespace SharpLogRamsey.FreshExecution +open Finset BinaryTree TreeDecoder PublicTables +open scoped Classical BigOperators +noncomputable section +variable {I A B C Ω : Type*} [DecidableEq I] [Fintype I] [Fintype Ω] + {α : I→Type*} [∀ i,Fintype (α i)] + +def sourcePublicLaw (μ : Law Ω) (p : ∀ i,Law (α i)) : Law (Ω×(∀ i,α i)) where + mass x := μ.mass x.1*(piLaw p).mass x.2 + nonneg x := mul_nonneg (μ.nonneg x.1) ((piLaw p).nonneg x.2) + total := by + rw [Fintype.sum_prod_type] + simp only [←mul_sum,(piLaw p).total,mul_one,μ.total] + +theorem original_output_loss (μ : Law Ω) (p : ∀ i,Law (α i)) (R : A→B→Prop) + (choose : Ω→∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) + (n : ℕ) (target : Ω→I→Fin n→A×B) (t : BinaryTree I) (U : Domains A B) + (ht : Separated t) + (hR : ∀ ω,∀ i∈labels t,∀ j,R (target ω i j).1 (target ω i j).2) + (δ : ℝ) + (hpoint : ∀ i∈labels t,∀ j,(∑ ω,μ.mass ω*∑ z,(piLaw p).mass z* + targetFailure (choose ω) read (target ω i j).1 (target ω i j).2 i t U z)≤δ) : + (∑ z,(piLaw p).mass z*∑ ω,μ.mass ω*(((labels t).card:ℝ)*n- + (fullOutput R (choose ω) read (fun i=>List.ofFn (target ω i)) z t U).length))≤ + ((labels t).card:ℝ)*n*δ := by + have hh := expected_literal_loss (sourcePublicLaw μ p) R (fun x=>choose x.1) + (fun _=>read) (fun x=>x.2) n (fun x=>target x.1) t U ht (fun x=>hR x.1) δ + (by + intro i hi j + have hp:=hpoint i hi j + simpa only [sourcePublicLaw,Fintype.sum_prod_type,mul_assoc,←mul_sum] using hp) + simp only [sourcePublicLaw,Fintype.sum_prod_type,mul_assoc,←mul_sum] at hh + convert hh using 1 + · simp only [mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro ω _ + apply sum_congr rfl + intro z _ + ring + · ring + +theorem fixed_original_output (μ : Law Ω) (p : ∀ i,Law (α i)) (R : A→B→Prop) + (choose : Ω→∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) + (n : ℕ) (target : Ω→I→Fin n→A×B) (t : BinaryTree I) (U : Domains A B) + (ht : Separated t) (hsize : 0<(labels t).card*n) + (hR : ∀ ω,∀ i∈labels t,∀ j,R (target ω i j).1 (target ω i j).2) + (hpoint : ∀ i∈labels t,∀ j,(∑ ω,μ.mass ω*∑ z,(piLaw p).mass z* + targetFailure (choose ω) read (target ω i j).1 (target ω i j).2 i t U z)≤1/4) : + ∃ z,(1/2:ℝ)≤∑ ω,μ.mass ω*(if (((labels t).card*n:ℕ):ℝ)/2≤ + (fullOutput R (choose ω) read (fun i=>List.ofFn (target ω i)) z t U).length then 1 else 0) := by + apply fixed_output_half μ p R choose (fun _=>read) (fun ω i=>List.ofFn (target ω i)) + (fun _=>t) U ((labels t).card*n) hsize + · intro ω + have hh:=population_length_sum (fun i=>List.ofFn (target ω i)) t ht + simp only [List.length_ofFn,sum_const,nsmul_eq_mul] at hh + exact_mod_cast hh + · have hh:=original_output_loss μ p R choose read n target t U ht hR (1/4) hpoint + simpa only [Nat.cast_mul,div_eq_mul_inv,one_mul] using hh + +end +end SharpLogRamsey.FreshExecution + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedLoss.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedLoss.lean new file mode 100644 index 0000000000000000000000000000000000000000..2baf9a940a07a40a21e61486ba06ead127f2a7c1 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedLoss.lean @@ -0,0 +1,164 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Selection.FreshAccrual + +namespace OAI + +section +namespace SharpLogRamsey.FreshExecution +open Finset BinaryTree TreeDecoder PublicTables +open scoped Classical BigOperators +noncomputable section +variable {I A B C : Type*} [DecidableEq I] {α : I→Type*} + +def compatible (R : A→B→Prop) (U : Domains A B) (xs : List (A×B)) : ℝ := + (xs.filter (fun z=>z∈flagDomain R U)).length + +lemma compatible_append (R : A→B→Prop) (U : Domains A B) (xs ys : List (A×B)) : + compatible R U (xs++ys)=compatible R U xs+compatible R U ys := by + simp only [compatible,List.filter_append,List.length_append,Nat.cast_add] + +lemma retained_all (R : A→B→Prop) (U : Domains A B) (xs : List (A×B)) : + retained R U xs xs.length=xs.filter (fun z=>z∈flagDomain R U) := by + exact List.take_of_length_le (List.length_filter_le _ _) + +def fullOutput (R : A→B→Prop) + (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (targets : I→List (A×B)) + (z : ∀ i,α i) (t : BinaryTree I) (U : Domains A B) : List (A×B) := + output R (fixedRead read z) targets (fun i=>(targets i).length) + (execute (fixedRead read z) (fixedChoose choose z) t U) U + +omit [DecidableEq I] in +lemma fullOutput_nil (R : A→B→Prop) + (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (targets : I→List (A×B)) + (z : ∀ i,α i) (U : Domains A B) : + fullOutput R choose read targets z .nil U=[] := rfl + +omit [DecidableEq I] in +lemma fullOutput_fail (R : A→B→Prop) + (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (targets : I→List (A×B)) + (z : ∀ i,α i) (i : I) (l r : BinaryTree I) (U : Domains A B) + (hc : choose i (z i) U=none) : + fullOutput R choose read targets z (.node i l r) U=[] := by + simp only [fullOutput,execute,fixedChoose,hc,Option.map_none,output] + +omit [DecidableEq I] in +lemma fullOutput_success (R : A→B→Prop) + (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (targets : I→List (A×B)) + (z : ∀ i,α i) (i : I) (l r : BinaryTree I) (U : Domains A B) + (c : C) (hc : choose i (z i) U=some c) : + let V:=read i (z i) U c + fullOutput R choose read targets z (.node i l r) U= + fullOutput R choose read targets z l (V.1,U.2)++ + (targets i).filter (fun x=>x∈flagDomain R V)++ + fullOutput R choose read targets z r (U.1,V.2) := by + simp only [fullOutput,execute,fixedChoose,hc,Option.map_some,output,fixedRead,retained_all] + +def nodeCharge (R : A→B→Prop) + (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (targets : I→List (A×B)) + (i : I) (l r : BinaryTree I) (U : Domains A B) (x : α i) : ℝ := + compatible R U (population targets (.node i l r))- + match choose i x U with + | none=>0 + | some c=> + let V:=read i x U c + compatible R (V.1,U.2) (population targets l)+ + compatible R V (targets i)+compatible R (U.1,V.2) (population targets r) + +def charges (R : A→B→Prop) + (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (targets : I→List (A×B)) : + BinaryTree I→∀ i,Domains A B→α i→ℝ + | .nil,_,_,_=>0 + | .node j l r,i,U,x=>if i=j then nodeCharge R choose read targets i l r U x + else if i∈labels l then charges R choose read targets l i U x + else charges R choose read targets r i U x + +lemma accrued_congr (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (f g : ∀ i,Domains A B→α i→ℝ) + (z : ∀ i,α i) (t : BinaryTree I) (U : Domains A B) + (h : ∀ i∈labels t,∀ V x,f i V x=g i V x) : + accrued choose read f z t U=accrued choose read g z t U := by + induction t generalizing U with + | nil=>rfl + | node i l r hl hr=> + have hi : i∈labels (.node i l r) := by rw [labels_node]; exact mem_insert_self _ _ + have hL : ∀ j∈labels l,∀ V x,f j V x=g j V x := by + intro j hj + exact h j (by rw [labels_node]; exact mem_insert_of_mem (mem_union_left _ hj)) + have hR : ∀ j∈labels r,∀ V x,f j V x=g j V x := by + intro j hj + exact h j (by rw [labels_node]; exact mem_insert_of_mem (mem_union_right _ hj)) + rw [accrued,accrued,h i hi] + cases choose i (z i) U with + | none=>rfl + | some c=>dsimp only; rw [hl _ hL,hr _ hR] + +theorem output_loss_eq_accrued (R : A→B→Prop) + (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (targets : I→List (A×B)) + (z : ∀ i,α i) (t : BinaryTree I) (U : Domains A B) (ht : Separated t) : + compatible R U (population targets t)- + (fullOutput R choose read targets z t U).length= + accrued choose read (charges R choose read targets t) z t U := by + induction t generalizing U with + | nil=>simp only [population,compatible,List.filter_nil,List.length_nil,Nat.cast_zero, + fullOutput_nil,sub_self,accrued] + | node i l r hl hr=> + rcases ht with ⟨htl,htr,hli,hri,hd⟩ + have heL (V : Domains A B) : + accrued choose read (charges R choose read targets (.node i l r)) z l V= + accrued choose read (charges R choose read targets l) z l V := by + apply accrued_congr + intro j hj W x + have hji : j≠i := by intro he; exact hli (he ▸ hj) + simp only [charges,ite_eq_right hji,ite_eq_left hj] + have heR (V : Domains A B) : + accrued choose read (charges R choose read targets (.node i l r)) z r V= + accrued choose read (charges R choose read targets r) z r V := by + apply accrued_congr + intro j hj W x + have hji : j≠i := by intro he; exact hri (he ▸ hj) + have hjl : j∉labels l := disjoint_right.mp hd hj + simp only [charges,ite_eq_right hji,ite_eq_right hjl] + rw [accrued] + have hroot : charges R choose read targets (.node i l r) i U (z i)= + nodeCharge R choose read targets i l r U (z i) := by simp only [charges,ite_true] + rw [hroot] + cases hc : choose i (z i) U with + | none=> + rw [fullOutput_fail R choose read targets z i l r U hc] + simp only [nodeCharge,hc,List.length_nil,Nat.cast_zero,sub_zero,add_zero] + | some c=> + rw [fullOutput_success R choose read targets z i l r U c hc] + dsimp only + rw [heL,heR,←hl _ htl,←hr _ htr] + simp only [nodeCharge,hc,List.length_append,Nat.cast_add] + change _-(_+compatible R (read i (z i) U c) (targets i)+_)=_ + ring + +variable [Fintype I] [∀ i,Fintype (α i)] + +theorem expected_output_loss (p : ∀ i,Law (α i)) (dummy : ∀ i,α i) + (R : A→B→Prop) (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (targets : I→List (A×B)) + (t : BinaryTree I) (U : Domains A B) (ht : Separated t) + (budget : I→ℝ) (hb : ∀ i∈labels t,0≤budget i) + (hlocal : ∀ i∈labels t,∀ V, + (∑ x,(p i).mass x*charges R choose read targets t i V x)≤budget i) : + (∑ z,(piLaw p).mass z*(compatible R U (population targets t)- + (fullOutput R choose read targets z t U).length))≤∑ i∈labels t,budget i := by + simp_rw [output_loss_eq_accrued R choose read targets _ t U ht] + exact accrued_expectation p dummy choose read (charges R choose read targets t) + t U ht budget hb hlocal + +end +end SharpLogRamsey.FreshExecution + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedMessage.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedMessage.lean new file mode 100644 index 0000000000000000000000000000000000000000..47818acc47972557eade30e98057ce5f4073c9bb --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedMessage.lean @@ -0,0 +1,129 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Entropy.TreeMessageEntropy +import OAI.Combinatorics.SharpRamsey.Execution.ExecutedCosts + +namespace OAI + +section +namespace SharpLogRamsey.ExecutedPotential +open Finset Real BinaryTree TreeDecoder TreeCodeEntropy +open scoped Classical +noncomputable section +variable {A B C I Ω : Type*} + +def codeTree (read : CapReader A B C) (choose : I→Domains A B→Option C) + (t : BinaryTree I) (U : Domains A B) : BinaryTree C := + (execute read choose t U).map Prod.snd + +lemma codeTree_numNodes (read : CapReader A B C) (choose : I→Domains A B→Option C) + (t : BinaryTree I) (U : Domains A B) : (codeTree read choose t U).numNodes≤t.numNodes := by + induction t generalizing U with + | nil => rfl + | node i l r hl hr => + simp only [codeTree,execute] + split + · simp only [BinaryTree.map,numNodes]; omega + · simp only [BinaryTree.map,numNodes] + exact Nat.add_le_add_right (Nat.add_le_add (hl _) (hr _)) 1 + +lemma codeTree_mem (allowed : Domains A B→Finset C) (read : CapReader A B C) + (choose : I→Domains A B→Option C) + (hallowed : ∀ i U c,choose i U=some c→c∈allowed U) + (t : BinaryTree I) (U : Domains A B) : + codeTree read choose t U∈codes allowed read (shape (codeTree read choose t U)) U := by + induction t generalizing U with + | nil => simp [codeTree,execute,shape,BinaryTree.map,codes] + | node i l r hl hr => + simp only [codeTree,execute] + split + · simp [shape,BinaryTree.map,codes] + · rename_i c hc + simp only [BinaryTree.map,shape,codes] + apply mem_biUnion.mpr + refine ⟨c,hallowed i U c hc,mem_image.mpr ?_⟩ + exact ⟨(_, _),mem_product.mpr ⟨hl _,hr _⟩,rfl⟩ + +lemma codeTree_cost (allowed : Domains A B→Finset C) (read : CapReader A B C) + (choose : I→Domains A B→Option C) (t : BinaryTree I) (U : Domains A B) : + TreeCodeEntropy.cost allowed read (codeTree read choose t U) U= + TreePotential.total (fun z : I×Domains A B×C=>log (allowed z.2.1).card) + (annotate read choose t U) := by + induction t generalizing U with + | nil => rfl + | node i l r hl hr => + cases hj : choose i U with + | none => simp only [codeTree,execute,annotate,hj,BinaryTree.map,TreeCodeEntropy.cost, + TreePotential.total] + | some c => + simp only [codeTree,execute,annotate,hj,BinaryTree.map,TreeCodeEntropy.cost, + TreePotential.total] + exact congrArg₂ (fun x y=>log (allowed U).card+x+y) (hl _) (hr _) + +theorem codeTree_cost_bound (Q C₀ b c P : ℝ) (hQ : 0log (allowed U).card) hcost t U).trans + have hK : 0≤b+log 4+2*log C₀ := add_nonneg + (add_nonneg hb (log_nonneg (by norm_num))) + (mul_nonneg (by norm_num) (log_nonneg hC)) + have hn : (t.numNodes:ℝ)≤N := by exact_mod_cast hN + have hh : (t.height:ℝ)≤H := by exact_mod_cast hH + apply mul_le_mul_of_nonneg_left _ hc + apply add_le_add _ (mul_le_mul_of_nonneg_right hn hP) + apply mul_le_mul hh (add_le_add le_rfl (mul_le_mul_of_nonneg_right hn hK)) + · exact add_nonneg (potential_nonneg Q U) (mul_nonneg (by positivity) hK) + · positivity + +variable [Fintype Ω] + +theorem execution_entropy (p : Selection.Law Ω) + (Q C₀ b c P : ℝ) (hQ : 0codeTree read (choose ω) (t ω) U + let R := univ.image M + let msg : Ω→R := fun ω=>⟨M ω,mem_image.mpr ⟨ω,mem_univ _,rfl⟩⟩ + Selection.entropy (p.map msg)≤((2*N+1:ℕ):ℝ)*log 2+ + c*((H:ℝ)*(potential Q U+(N:ℝ)*(b+log 4+2*log C₀))+(N:ℝ)*P) := by + dsimp only + apply tree_message_entropy _ allowed read U Subtype.val Subtype.val_injective N + · intro g + obtain ⟨ω,hω,he⟩ := mem_image.mp g.property + rw [←he] + exact (codeTree_numNodes read (choose ω) (t ω) U).trans (hN ω) + · intro g + obtain ⟨ω,hω,he⟩ := mem_image.mp g.property + rw [←he] + exact codeTree_mem allowed read (choose ω) (hallowed ω) (t ω) U + · intro g + obtain ⟨ω,hω,he⟩ := mem_image.mp g.property + rw [←he] + exact codeTree_cost_bound Q C₀ b c P hQ hC hb hc hP N H allowed read + (choose ω) (hvalid ω) (hcost ω) (t ω) (hN ω) (hH ω) U + +end +end SharpLogRamsey.ExecutedPotential + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedOutputCount.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedOutputCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..b12cb7384a757f1b920f45a4d0fa54b7a21b9bad --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedOutputCount.lean @@ -0,0 +1,114 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.ExecutedLoss +import OAI.Combinatorics.SharpRamsey.Execution.ExecutedEndpoint + +namespace OAI + +section +namespace SharpLogRamsey.FreshExecution +open Finset BinaryTree TreeDecoder PublicTables +open scoped Classical BigOperators +noncomputable section +variable {I A B C : Type*} [DecidableEq I] {α : I→Type*} + +def keptCount (R : A→B→Prop) (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (targets : I→List (A×B)) + (i : I) (U : Domains A B) (x : α i) : ℝ := + match choose i x U with + | none=>0 + | some c=>compatible R (read i x U c) (targets i) + +omit [DecidableEq I] in +lemma fullOutput_length_accrued (R : A→B→Prop) + (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (targets : I→List (A×B)) + (z : ∀ i,α i) (t : BinaryTree I) (U : Domains A B) : + ((fullOutput R choose read targets z t U).length:ℝ)= + accrued choose read (keptCount R choose read targets) z t U := by + induction t generalizing U with + | nil=>simp only [fullOutput_nil,List.length_nil,Nat.cast_zero,accrued] + | node i l r hl hr=> + cases hc : choose i (z i) U with + | none=>simp only [fullOutput_fail R choose read targets z i l r U hc, + accrued,keptCount,hc,add_zero,List.length_nil,Nat.cast_zero] + | some c=> + rw [fullOutput_success R choose read targets z i l r U c hc] + simp only [List.length_append,Nat.cast_add,hl,hr,accrued,keptCount,hc] + dsimp only [compatible] + ring + +lemma population_length_sum (targets : I→List (A×B)) (t : BinaryTree I) + (ht : Separated t) : + ((population targets t).length:ℝ)=∑ i∈labels t,((targets i).length:ℝ) := by + induction t with + | nil=>simp only [population,labels_nil,List.length_nil,Nat.cast_zero,sum_empty] + | node i l r hl hr=> + rcases ht with ⟨htl,htr,hli,hri,hd⟩ + rw [labels_node,sum_insert (by simp only [mem_union,not_or]; exact ⟨hli,hri⟩),sum_union hd] + simp only [population,List.length_append,Nat.cast_add,hl htl,hr htr] + ring + +omit [DecidableEq I] in +lemma compatible_complement (R : A→B→Prop) (V : Domains A B) (xs : List (A×B)) + (hR : ∀ x∈xs,R x.1 x.2) : + (xs.map (fun x=>if x.1∈V.1 ∧ x.2∈V.2 then (0:ℝ) else 1)).sum= + (xs.length:ℝ)-compatible R V xs := by + induction xs with + | nil=>simp only [List.map_nil,List.sum_nil,List.length_nil,Nat.cast_zero, + compatible,List.filter_nil,sub_self] + | cons x xs ih=> + have hx : R x.1 x.2 := hR x (List.mem_cons_self ..) + have ht : ∀ y∈xs,R y.1 y.2 := fun y hy=>hR y (List.mem_cons_of_mem _ hy) + have hm : x∈flagDomain R V ↔ x.1∈V.1 ∧ x.2∈V.2 := by + simp only [flagDomain,mem_filter,mem_product,hx,and_true] + by_cases hc : x.1∈V.1 ∧ x.2∈V.2 + · have hxV : x∈flagDomain R V := hm.mpr hc + simp only [List.map_cons,List.sum_cons,ite_eq_left hc,zero_add,ih ht, + List.length_cons,Nat.cast_add,Nat.cast_one,compatible,List.filter_cons_of_pos (p:=fun z=>decide (z∈flagDomain R V)) (a:=x) (l:=xs) (by simpa only [decide_eq_true_eq] using hxV), + List.length_cons,Nat.cast_add,Nat.cast_one] + ring + · have hxV : x∉flagDomain R V := fun h=>hc (hm.mp h) + simp only [List.map_cons,List.sum_cons,ite_eq_right hc,ih ht, + List.length_cons,Nat.cast_add,Nat.cast_one,compatible,List.filter_cons_of_neg (p:=fun z=>decide (z∈flagDomain R V)) (a:=x) (l:=xs) (by simpa only [decide_eq_true_eq] using hxV)] + ring + +lemma pivot_count_complement (R : A→B→Prop) + (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (targets : I→List (A×B)) + (z : ∀ i,α i) (i : I) (t : BinaryTree I) (U : Domains A B) + (hR : ∀ x∈targets i,R x.1 x.2) : + ((targets i).map (fun x=>targetFailure choose read x.1 x.2 i t U z)).sum= + ((targets i).length:ℝ)-produced choose read i (keptCount R choose read targets i) t U z := by + have hones (xs : List (A×B)) : (xs.map (fun _=>(1:ℝ))).sum=(xs.length:ℝ) := by + induction xs with + | nil=>simp + | cons x xs ih=>simp only [List.map_cons,List.sum_cons,ih,List.length_cons, + Nat.cast_add,Nat.cast_one]; ring + cases ha : arrive choose read z i t U with + | none=>simpa only [targetFailure,ha,produced,sub_zero] using hones (targets i) + | some V=> + cases hc : choose i (z i) V with + | none=>simpa only [targetFailure,ha,hc,produced,keptCount,sub_zero] using hones (targets i) + | some c=> + simp only [targetFailure,ha,hc,produced,keptCount] + exact compatible_complement R (read i (z i) V c) (targets i) hR + +theorem output_loss_eq_targets (R : A→B→Prop) + (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (targets : I→List (A×B)) + (z : ∀ i,α i) (t : BinaryTree I) (U : Domains A B) (ht : Separated t) + (hR : ∀ i∈labels t,∀ x∈targets i,R x.1 x.2) : + ((population targets t).length:ℝ)-(fullOutput R choose read targets z t U).length= + ∑ i∈labels t,((targets i).map (fun x=>targetFailure choose read x.1 x.2 i t U z)).sum := by + rw [population_length_sum targets t ht,fullOutput_length_accrued, + accrued_eq_sum choose read _ z t U ht,←sum_sub_distrib] + apply sum_congr rfl + intro i hi + exact (pivot_count_complement R choose read targets z i t U (hR i hi)).symm + +end +end SharpLogRamsey.FreshExecution + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedOverhead.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedOverhead.lean new file mode 100644 index 0000000000000000000000000000000000000000..1e7770a3db5b072e06e437db89d9de1cb1265657 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedOverhead.lean @@ -0,0 +1,118 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.ExecutedFullMessage + +namespace OAI + +section +namespace SharpLogRamsey.TreePotential +open BinaryTree +lemma total_sub_const {α : Type*} (f : α→ℝ) (D : ℝ) (t : BinaryTree α) : + total (fun a=>f a-D) t=total f t-(t.numNodes:ℝ)*D := by + induction t with + | nil=>simp [total] + | node a l r hl hr=>simp only [total,numNodes,Nat.cast_add,Nat.cast_one,hl,hr]; ring +end SharpLogRamsey.TreePotential + +namespace SharpLogRamsey.ExecutedPotential +open Finset Real BinaryTree TreeDecoder TreeCodeEntropy +open scoped Classical +noncomputable section +variable {A B C I Ω : Type*} + +theorem codeTree_cost_overhead (Q C₀ b c P D : ℝ) (hQ : 0log (allowed V).card-D) (by intro i V x hx; linarith [hcost i V x hx]) t U + rw [TreePotential.total_sub_const] at hx + have hn₀ : ((annotate read choose t U).numNodes:ℝ)≤N := by + exact_mod_cast (annotate_numNodes read choose t U).trans hN + have hn : (t.numNodes:ℝ)≤N := by exact_mod_cast hN + have hh : (t.height:ℝ)≤H := by exact_mod_cast hH + have hK : 0≤b+log 4+2*log C₀ := add_nonneg + (add_nonneg hb (log_nonneg (by norm_num))) (mul_nonneg (by norm_num) (log_nonneg hC)) + have hupper : c*((t.height:ℝ)*(potential Q U+(t.numNodes:ℝ)*(b+log 4+2*log C₀))+(t.numNodes:ℝ)*P)≤ + c*((H:ℝ)*(potential Q U+(N:ℝ)*(b+log 4+2*log C₀))+(N:ℝ)*P) := by + apply mul_le_mul_of_nonneg_left _ hc + apply add_le_add _ (mul_le_mul_of_nonneg_right hn hP) + exact mul_le_mul hh (add_le_add le_rfl (mul_le_mul_of_nonneg_right hn hK)) + (add_nonneg (potential_nonneg _ _) (mul_nonneg (by positivity) hK)) (by positivity) + rw [codeTree_cost] + linarith [mul_le_mul_of_nonneg_right hn₀ hD] + +variable [Fintype Ω] + +theorem full_execution_entropy_overhead (p : Selection.Law Ω) + (Q C₀ b c P D : ℝ) (hQ : 0codeTree (countReader read) + (countChoose R read (choose ω) (targets ω) (counts ω)) (t ω) U + let S := univ.image M + let msg : Ω→S := fun ω=>⟨M ω,mem_image.mpr ⟨ω,mem_univ _,rfl⟩⟩ + Selection.entropy (p.map msg)≤((2*N+1:ℕ):ℝ)*log 2+(N:ℝ)*(D+log (n+1:ℕ))+ + c*((H:ℝ)*(potential Q U+(N:ℝ)*(b+log 4+2*log C₀))+(N:ℝ)*P) := by + have hn : 0≤log (n+1:ℕ) := log_nonneg (by exact_mod_cast Nat.le_add_left 1 n) + have hV (ω : Ω) : ∀ i U x,countChoose R read (choose ω) (targets ω) (counts ω) i U=some x→ + ∃ S : Finset A,∃ T : Finset B,S.Nonempty ∧ T.Nonempty ∧ + (9/10:ℝ)*S.card≤(S∩U.1).card ∧ (9/10:ℝ)*T.card≤(T∩U.2).card ∧ + Q*exp (-b)≤(S.card:ℝ)*T.card ∧ + (((countReader read) U x).1.card:ℝ)≤C₀*Q/T.card ∧ + (((countReader read) U x).2.card:ℝ)≤C₀*Q/S.card := by + intro i V x hx + obtain ⟨y,hy,rfl⟩:=Option.map_eq_some_iff.mp hx + exact hvalid ω i V y hy + have hC' (ω : Ω) : ∀ i U x,countChoose R read (choose ω) (targets ω) (counts ω) i U=some x→ + log (countAlphabet allowed n U).card≤D+log (n+1:ℕ)+c*(potential Q U+P) := by + intro i V x hx + obtain ⟨y,hy,rfl⟩:=Option.map_eq_some_iff.mp hx + rw [countAlphabet_log allowed n V ⟨y,hallowed ω i V y hy⟩] + linarith [hcost ω i V y hy] + dsimp only + rw [add_assoc] + apply tree_message_entropy _ (countAlphabet allowed n) (countReader read) U + Subtype.val Subtype.val_injective N + · intro g + obtain ⟨ω,hω,he⟩:=mem_image.mp g.property + rw [←he] + exact (codeTree_numNodes _ _ _ _).trans (hN ω) + · intro g + obtain ⟨ω,hω,he⟩:=mem_image.mp g.property + rw [←he] + exact codeTree_mem _ _ _ + (countChoose_mem R read (choose ω) (targets ω) (counts ω) allowed n + (hcounts ω) (hallowed ω)) (t ω) U + · intro g + obtain ⟨ω,hω,he⟩:=mem_image.mp g.property + rw [←he] + exact codeTree_cost_overhead Q C₀ b c P (D+log (n+1:ℕ)) hQ hC hb hc hP + (add_nonneg hD hn) N H _ _ _ (hV ω) (hC' ω) (t ω) (hN ω) (hH ω) U + +end +end SharpLogRamsey.ExecutedPotential + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedPotential.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedPotential.lean new file mode 100644 index 0000000000000000000000000000000000000000..2da07e3a9e9b9ae0c37175654732c0e19e512f32 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedPotential.lean @@ -0,0 +1,149 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Trees.TreeDecoder +import OAI.Combinatorics.SharpRamsey.Reciprocal.ReciprocalPotential +import OAI.Combinatorics.SharpRamsey.Trees.TreePotential + +namespace OAI + +section +namespace SharpLogRamsey.ExecutedPotential +open Finset Real BinaryTree TreeDecoder +open scoped Classical +noncomputable section +variable {A B I C : Type*} + +def potential (Q : ℝ) (U : Domains A B) : ℝ := + max (log ((U.1.card:ℝ)*U.2.card/Q)) 0 + +lemma potential_nonneg (Q : ℝ) (U : Domains A B) : 0≤potential Q U := le_max_right _ _ + +lemma cap_potential_zero_allowed {b t Q C a' : ℝ} (hb : 0 .nil + | .node i l r,U => match choose i U with + | none => .nil + | some c => + let V := read U c + .node (i,U,c) (annotate read choose l (V.1,U.2)) + (annotate read choose r (U.1,V.2)) + +lemma erase_annotate (read : CapReader A B C) (choose : I→Domains A B→Option C) + (t : BinaryTree I) (U : Domains A B) : + (annotate read choose t U).map (fun z => (z.1,z.2.2))=execute read choose t U := by + induction t generalizing U with + | nil => rfl + | node i l r hl hr => + cases hc : choose i U <;> simp only [annotate,execute,hc,BinaryTree.map,hl,hr] + +lemma annotate_height (read : CapReader A B C) (choose : I→Domains A B→Option C) + (t : BinaryTree I) (U : Domains A B) : + (annotate read choose t U).height≤t.height := by + induction t generalizing U with + | nil => rfl + | node i l r hl hr => + simp only [annotate] + split + · simp + · simp only [height] + exact Nat.add_le_add_right (max_le_max (hl _) (hr _)) 1 + +lemma annotate_numNodes (read : CapReader A B C) (choose : I→Domains A B→Option C) + (t : BinaryTree I) (U : Domains A B) : + (annotate read choose t U).numNodes≤t.numNodes := by + induction t generalizing U with + | nil => rfl + | node i l r hl hr => + simp only [annotate] + split + · simp + · simp only [numNodes] + exact Nat.add_le_add_right (Nat.add_le_add (hl _) (hr _)) 1 + +lemma root_le (Q : ℝ) (read : CapReader A B C) (choose : I→Domains A B→Option C) + (t : BinaryTree I) (U : Domains A B) : + TreePotential.root (fun z : I×Domains A B×C => potential Q z.2.1) + (annotate read choose t U)≤potential Q U := by + cases t with + | nil => exact potential_nonneg Q U + | node i l r => + simp only [annotate] + split + · exact potential_nonneg Q U + · exact le_rfl + +theorem admissible (Q C₀ b : ℝ) (hQ : 0 potential Q z.2.1) + (b+log 4+2*log C₀) (annotate read choose t U) := by + induction t generalizing U with + | nil => trivial + | node i l r hl hr => + simp only [annotate] + split + · trivial + · rename_i c hc + obtain ⟨S,T,hS,hT,htrS,htrT,hp,hca,hcb⟩ := hvalid i U c hc + refine ⟨potential_nonneg Q U,?_,hl _,hr _⟩ + apply (add_le_add (root_le Q read choose l _) (root_le Q read choose r _)).trans + exact branch Q C₀ b hQ hC U (read U c) S T hS hT htrS htrT hp hca hcb + +end +end SharpLogRamsey.ExecutedPotential + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedReplacement.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedReplacement.lean new file mode 100644 index 0000000000000000000000000000000000000000..534574a122449d0b09da5d89f24633f66e507618 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedReplacement.lean @@ -0,0 +1,103 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Selection.NullFreeLaw +import OAI.Combinatorics.SharpRamsey.Execution.VariableExtraction +import OAI.Combinatorics.SharpRamsey.Reciprocal.ReciprocalDomains + +namespace OAI + +section +namespace SharpLogRamsey.Selection +variable {Ω : Type*} [Fintype Ω] +def Law.ofPublic (p : PublicTables.Law Ω) : Law Ω := ⟨p.mass,p.nonneg,p.total⟩ +end SharpLogRamsey.Selection + +namespace SharpLogRamsey.ActualPivot +open Finset Real TreeDecoder FreshExecution BinaryTree ExecutedPotential +open scoped Classical BigOperators +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] + {I Ω Ξ : Type*} [Fintype I] [Fintype Ω] + {n : ℕ} {b τ P H : ℝ} +local instance flat_ActualExecutedReplacement_1 : DecidableEq I := Classical.decEq _ +local instance replacementBanksFintype : Fintype (Banks (K:=K) (V:=V) b) := inferInstance + +abbrev Flag := Projectivization K (Module.Dual K V)×Projectivization K V + +variable (hdim : Module.finrank K V=n+3) + (book : Book (K:=K) (V:=V) (Nat.card K) b τ P H (n+3)) + (hb : 0≤b) (hH : 0≤H) (hP : 4≤P) (haP : b+log 1000000≤P) + (hτ : 0≤τ) (hτsmall : τ≤1/40000) + +include hb hH hP haP + +theorem Book.actual_replacement (μ : Selection.Law Ω) + (s : Ω→I→Original (K:=K) (V:=V) n b) + (targets : Ω→I→List (Flag (K:=K) (V:=V))) (t : Ω→BinaryTree I) + (U : ChronoDomains (K:=K) (V:=V)) (N W ht m : ℕ) (hN : 0stream ω=x),μ.mass ω)≤L*base x) + (hmean : (∑ z,(PublicTables.piLaw (fun _ : I=>banksLaw (K:=K) (V:=V) b)).mass z* + ∑ ω,μ.mass ω*((N:ℝ)- + (fullOutput (fun y x=>SharpLogRamsey.Incidence.Incident x y) + (fun i=>book.chronoChoose hdim hτ hτsmall (s ω i)) + (fun _=>chronoRead b) (targets ω) z (t ω) U).length))≤(N:ℝ)/4) : + ∃ z : I→Banks (K:=K) (V:=V) b, + let R:=fun (y : Projectivization K (Module.Dual K V)) (x : Projectivization K V)=>SharpLogRamsey.Incidence.Incident x y + let choose:=fun ω i=>book.chronoChoose hdim hτ hτsmall (s ω i) + let read:=fun _ : I=>chronoRead (K:=K) (V:=V) b + let E:=fun ω=>(N:ℝ)/2≤(fullOutput R (choose ω) read (targets ω) z (t ω) U).length + ∃ hE : 0fullMessage R (choose ω) read (targets ω) z (t ω) U + let S:=univ.image M + let msg : Ω→S:=fun ω=>⟨M ω,mem_image.mpr ⟨ω,mem_univ _,rfl⟩⟩ + let domains:=fun c : S=>(decode R (fixedRead read z) c.val U).take (N/2) + (1/2:ℝ)≤PublicTables.acceptProb μ.asPublic E ∧ + (∀ x,(∑ ω∈univ.filter (fun ω=>stream ω=x),ν.mass ω)≤(2*L)*base x) ∧ + (∀ ω,ν.mass ω≠0→ + let out:=(fullOutput R (choose ω) read (targets ω) z (t ω) U).take (N/2) + out.length=N/2 ∧ out.Sublist (population (targets ω) (t ω)) ∧ + out.Pairwise Q ∧ List.Forall₂ (fun x D=>x∈D) out (domains (msg ω))) ∧ + (∀ c D,D∈domains c→(D.card:ℝ)≤8000000*(Nat.card K:ℝ)^(n+2)*exp b) ∧ + Selection.entropy (ν.map msg)≤((2*W+1:ℕ):ℝ)*log 2+ + (W:ℝ)*(log ((Fintype.card I:ℝ)+1)+headerCost (K:=K) (V:=V)+log (m+1:ℕ))+ + (2*(H+22)*(Nat.card K:ℝ)*P)* + ((ht:ℝ)*(potential ((Nat.card K:ℝ)^(n+3)) U+(W:ℝ)*(b+log 4+2*log 2000))+(W:ℝ)*P) := by + let R:=fun (y : Projectivization K (Module.Dual K V)) (x : Projectivization K V)=>SharpLogRamsey.Incidence.Incident x y + let choose:=fun ω i=>book.chronoChoose hdim hτ hτsmall (s ω i) + let read:=fun _ : I=>chronoRead (K:=K) (V:=V) b + obtain ⟨z,hE,hprob,hextract⟩:=fixed_extraction_le μ.asPublic + (fun _ : I=>banksLaw (K:=K) (V:=V) b) R choose read targets t U N hN hsize Q hcons hmean + refine ⟨z,hE,hprob,?_,hextract,?_,?_⟩ + · have hh:=PublicTables.conditionSuccess_fiber μ.asPublic _ hE stream base L (1/2) + (by norm_num) hprob hb0 hL hdom + simpa only [Selection.Law.ofPublic, R, choose, read, div_div,div_one,one_div,div_inv_eq_mul,mul_comm] using hh + · intro c D hD + obtain ⟨ω,_,he⟩:=mem_image.mp c.property + have hm : D∈decode R (fixedRead read z) (fullMessage R (choose ω) read (targets ω) z (t ω) U) U := by + change D∈(decode R (fixedRead read z) c.val U).take (N/2) at hD + rw [←he] at hD + exact List.mem_of_mem_take hD + exact book.actual_decoded_size hdim hb hτ hτsmall (s ω) z (targets ω) + (fun i=>(targets ω i).length) (t ω) U D hm + · have hh:=book.actual_full_entropy hb hH hP haP hdim hτ hτsmall + (Selection.Law.ofPublic (PublicTables.conditionSuccess μ.asPublic _ hE)) s z t U + W ht m targets (fun ω i=>(targets ω i).length) hcounts hnodes hheight + simp only [Selection.entropy_map] at hh ⊢ + simpa only [R, choose, read, Selection.Law.map, + Subtype.mk.injEq, fullMessage, fullMessage_eq_codeTree] using hh + +end +end SharpLogRamsey.ActualPivot + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedRetention.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedRetention.lean new file mode 100644 index 0000000000000000000000000000000000000000..3ee6c22095a9f24f193d699ff2d2048a6d090e11 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedRetention.lean @@ -0,0 +1,61 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.ExecutedExpectedOutput + +namespace OAI + +section +namespace SharpLogRamsey.FreshExecution +open Finset BinaryTree TreeDecoder PublicTables +open scoped Classical BigOperators +noncomputable section +variable {I A B C Ω : Type*} [DecidableEq I] {α : I→Type*} + +omit [DecidableEq I] in +lemma fullOutput_sublist (R : A→B→Prop) + (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (targets : I→List (A×B)) + (z : ∀ i,α i) (t : BinaryTree I) (U : Domains A B) : + List.Sublist (fullOutput R choose read targets z t U) (population targets t) := + output_sublist R (fixedRead read z) (fixedChoose choose z) targets _ t U + +variable [Fintype Ω] [Fintype I] [∀ i,Fintype (α i)] + +theorem fixed_output_half (μ : Law Ω) (p : ∀ i,Law (α i)) (R : A→B→Prop) + (choose : Ω→∀ i,α i→Domains A B→Option C) + (read : Ω→∀ i,α i→CapReader A B C) (targets : Ω→I→List (A×B)) + (t : Ω→BinaryTree I) (U : Domains A B) (N : ℕ) (hN : 0 (fullOutput R (choose ω) (read ω) (targets ω) z (t ω) U).length + have hbound (ω : Ω) (z : ∀ i,α i) : out ω z≤N := by + simpa only [hsize] using (fullOutput_sublist R (choose ω) (read ω) (targets ω) z (t ω) U).length_le + have hp (ω : Ω) (z : ∀ i,α i) : + (N:ℝ)/2-((N:ℝ)-out ω z)≤(N:ℝ)/2*(if (N:ℝ)/2≤out ω z then 1 else 0) := by + split_ifs with hh + · have hb : (out ω z:ℝ)≤N := by exact_mod_cast hbound ω z + linarith + · linarith + have hz (z : ∀ i,α i) : + (N:ℝ)/2-(∑ ω,μ.mass ω*((N:ℝ)-out ω z))≤ + (N:ℝ)/2*(∑ ω,μ.mass ω*(if (N:ℝ)/2≤out ω z then 1 else 0)) := by + have hh:=sum_le_sum (fun ω (_ : ω∈univ)=>mul_le_mul_of_nonneg_left (hp ω z) (μ.nonneg ω)) + simpa only [mul_sub,sum_sub_distrib,←sum_mul,μ.total,one_mul,mul_left_comm,mul_sum] using hh + have hall:=sum_le_sum (fun z (_ : z∈univ)=>mul_le_mul_of_nonneg_left (hz z) ((piLaw p).nonneg z)) + have hall' : (N:ℝ)/2-(∑ z,(piLaw p).mass z*∑ ω,μ.mass ω*((N:ℝ)-out ω z))≤ + (N:ℝ)/2*(∑ z,(piLaw p).mass z*∑ ω,μ.mass ω*(if (N:ℝ)/2≤out ω z then 1 else 0)) := by + simpa only [mul_sub,sum_sub_distrib,←sum_mul,(piLaw p).total,one_mul,mul_left_comm,mul_sum] using hall + have hn : (0:ℝ)(N:ℝ)/2≤out ω z) (1/2) hs + +end +end SharpLogRamsey.FreshExecution + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedSecondTrim.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedSecondTrim.lean new file mode 100644 index 0000000000000000000000000000000000000000..47fa556271bcada694bc6c5bb6af390a10928dfb --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedSecondTrim.lean @@ -0,0 +1,215 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.ExecutedTrim + +namespace OAI + +section +namespace SharpLogRamsey.FreshExecution +open Finset BinaryTree TreeDecoder PublicTables +open scoped Classical BigOperators +noncomputable section +variable {I A B C : Type*} [DecidableEq I] {α : I→Type*} + +def rightPath (target : I) : BinaryTree I→Finset I + | .nil=>∅ + | .node i l r=>if i=target then ∅ else + if target∈labels r then insert i (rightPath target r) else rightPath target l + +lemma rightPath_subset (target : I) (t : BinaryTree I) : rightPath target t⊆labels t := by + induction t with + | nil=>exact empty_subset _ + | node i l r hl hr=> + rw [rightPath,labels_node] + split_ifs with hi hj + · exact empty_subset _ + · exact insert_subset_insert i (hr.trans subset_union_right) + · exact hl.trans (subset_union_left.trans (subset_insert _ _)) + +lemma rightPath_card (target : I) (t : BinaryTree I) : + (rightPath target t).card≤t.height := by + induction t with + | nil=>rfl + | node i l r hl hr=> + rw [rightPath] + split_ifs + · exact Nat.zero_le _ + · exact (card_insert_le _ _).trans (by simp only [height]; omega) + · simp only [height]; omega + +def secondLoss (choose : ∀ i,α i→Domains A B→Option C) + (mask : ∀ i,α i→CapReader A B C) (Y : Finset B) + (i : I) (U : Domains A B) (x : α i) : ℝ := + match choose i x U with + | none=>0 + | some c=>((Y\(mask i x U c).2).card:ℝ) + +omit [DecidableEq I] in +lemma secondLoss_nonneg (choose : ∀ i,α i→Domains A B→Option C) + (mask : ∀ i,α i→CapReader A B C) (Y : Finset B) + (i : I) (U : Domains A B) (x : α i) : 0 ≤ secondLoss choose mask Y i U x := by + unfold secondLoss + cases choose i x U <;> positivity + +theorem reached_second_loss (choose : ∀ i,α i→Domains A B→Option C) + (read mask : ∀ i,α i→CapReader A B C) + (hread : ∀ i x U c,(read i x U c).2=U.2∩(mask i x U c).2) + (z : ∀ i,α i) (target : I) (Y : Finset B) + (t : BinaryTree I) (U V : Domains A B) (ht : Separated t) + (hmem : target∈labels t) (hv : arrive choose read z target t U=some V) : + ((Y\V.2).card:ℝ)≤((Y\U.2).card:ℝ)+ + ∑ j∈rightPath target t,produced choose read j (secondLoss choose mask Y j) t U z := by + induction t generalizing U V with + | nil=>simp [labels_nil] at hmem + | node i l r hl hr=> + rcases ht with ⟨htl,htr,hli,hri,hd⟩ + by_cases hi : i=target + · rw [arrive,ite_eq_left hi] at hv + have hUV : U=V := Option.some.inj hv + rw [rightPath,ite_eq_left hi,hUV,sum_empty,add_zero] + · by_cases hR : target∈labels r + · have hL : target∉labels l := disjoint_right.mp hd hR + rw [arrive,ite_eq_right hi] at hv + cases hc : choose i (z i) U with + | none=>simp only [hc] at hv; contradiction + | some c=> + rw [hc] at hv + dsimp only at hv + rw [arrive_absent choose read z target l _ hL] at hv + have hv' : arrive choose read z target r (U.1,(read i (z i) U c).2)=some V := hv + have hchild:=hr _ _ htr hR hv' + rw [rightPath,ite_eq_right hi,ite_eq_left hR] + have hnot : i∉rightPath target r := fun hj=>hri (rightPath_subset target r hj) + rw [sum_insert hnot,produced_root] + have he : (∑ j∈rightPath target r,produced choose read j (secondLoss choose mask Y j) + (.node i l r) U z)= + ∑ j∈rightPath target r,produced choose read j (secondLoss choose mask Y j) + r (U.1,(read i (z i) U c).2) z := by + apply sum_congr rfl + intro j hj + exact produced_right choose read z i j _ l r U (rightPath_subset target r hj) hri hd c hc + rw [he] + have hs:=sdiff_inter_card Y U.2 (mask i (z i) U c).2 + have hs' : ((Y\(read i (z i) U c).2).card:ℝ)≤ + ((Y\U.2).card:ℝ)+(Y\(mask i (z i) U c).2).card := by + rw [hread] + exact hs + simp only [secondLoss,hc] + linarith + · have hL : target∈labels l := by + rw [labels_node,mem_insert,mem_union] at hmem + rcases hmem with he|he|he + · exact False.elim (hi he.symm) + · exact he + · exact False.elim (hR he) + rw [arrive,ite_eq_right hi] at hv + cases hc : choose i (z i) U with + | none=>simp only [hc] at hv; contradiction + | some c=> + rw [hc] at hv + dsimp only at hv + rw [arrive_absent choose read z target r _ hR] at hv + have hv' : arrive choose read z target l ((read i (z i) U c).1,U.2)=some V := by + cases hh : arrive choose read z target l ((read i (z i) U c).1,U.2) with + | none=>simp [hh] at hv + | some W=>rw [hh] at hv; exact hv + have hchild:=hl _ _ htl hL hv' + rw [rightPath,ite_eq_right hi,ite_eq_right hR] + have he : (∑ j∈rightPath target l,produced choose read j (secondLoss choose mask Y j) + (.node i l r) U z)= + ∑ j∈rightPath target l,produced choose read j (secondLoss choose mask Y j) + l ((read i (z i) U c).1,U.2) z := by + apply sum_congr rfl + intro j hj + exact produced_left choose read z i j _ l r U (rightPath_subset target l hj) hli hd c hc + rw [he] + exact hchild + +variable [Fintype I] [∀ i,Fintype (α i)] +theorem expected_second_path_loss (p : ∀ i,Law (α i)) (dummy : ∀ i,α i) + (choose : ∀ i,α i→Domains A B→Option C) + (read mask : ∀ i,α i→CapReader A B C) (Y : Finset B) + (target : I) (t : BinaryTree I) (U : Domains A B) + (δ : ℝ) (hδ : 0≤δ) + (hlocal : ∀ i∈rightPath target t,∀ V, + (∑ x,(p i).mass x*secondLoss choose mask Y i V x)≤δ) : + (∑ z,(piLaw p).mass z*(∑ j∈rightPath target t, + produced choose read j (secondLoss choose mask Y j) t U z))≤(t.height:ℝ)*δ := by + simp_rw [mul_sum] + rw [sum_comm] + calc + _ ≤ ∑ j∈rightPath target t,δ := by + apply sum_le_sum + intro j hj + exact produced_bound p choose read j (dummy j) (secondLoss choose mask Y j) t U δ hδ (hlocal j hj) + _ = ((rightPath target t).card:ℝ)*δ := by simp only [sum_const,nsmul_eq_mul] + _ ≤ _ := mul_le_mul_of_nonneg_right (by exact_mod_cast rightPath_card target t) hδ + +def secondTrim (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (Y : Finset B) + (target : I) (t : BinaryTree I) (U : Domains A B) (z : ∀ i,α i) : Prop := + ∃ V,arrive choose read z target t U=some V ∧ + ((Y∩V.2).card:ℝ)<(9/10:ℝ)*Y.card + +omit [Fintype I] [∀ i,Fintype (α i)] in +theorem reached_second_trim_charge (choose : ∀ i,α i→Domains A B→Option C) + (read mask : ∀ i,α i→CapReader A B C) + (hread : ∀ i x U c,(read i x U c).2=U.2∩(mask i x U c).2) + (z : ∀ i,α i) (target : I) (Y : Finset B) (hY : Y.Nonempty) + (t : BinaryTree I) (U : Domains A B) (ht : Separated t) + (hmem : target∈labels t) (hYU : Y⊆U.2) : + (if secondTrim choose read Y target t U z then (1:ℝ) else 0)≤ + (10/(Y.card:ℝ))*∑ j∈rightPath target t, + produced choose read j (secondLoss choose mask Y j) t U z := by + have hy : 0<(Y.card:ℝ) := by exact_mod_cast card_pos.mpr hY + split_ifs with htrim + · obtain ⟨V,hv,hsmall⟩:=htrim + have hl:=reached_second_loss choose read mask hread z target Y t U V ht hmem hv + rw [sdiff_eq_empty_iff_subset.mpr hYU,card_empty,Nat.cast_zero,zero_add] at hl + have hc : ((Y\V.2).card:ℝ)+((Y∩V.2).card:ℝ)=Y.card := by + exact_mod_cast card_sdiff_add_card_inter Y V.2 + rw [div_mul_eq_mul_div] + apply (le_div_iff₀ hy).mpr + nlinarith + · apply mul_nonneg (div_nonneg (by norm_num) hy.le) + apply sum_nonneg + intro j _ + exact produced_nonneg choose read j _ (secondLoss_nonneg choose mask Y j) t U z + +theorem expected_second_trim (p : ∀ i,Law (α i)) (dummy : ∀ i,α i) + (choose : ∀ i,α i→Domains A B→Option C) + (read mask : ∀ i,α i→CapReader A B C) + (hread : ∀ i x U c,(read i x U c).2=U.2∩(mask i x U c).2) + (target : I) (Y : Finset B) (hY : Y.Nonempty) + (t : BinaryTree I) (U : Domains A B) (ht : Separated t) + (hmem : target∈labels t) (hYU : Y⊆U.2) + (δ : ℝ) (hδ : 0≤δ) + (hlocal : ∀ i∈rightPath target t,∀ V, + (∑ x,(p i).mass x*secondLoss choose mask Y i V x)≤δ) : + (∑ z,(piLaw p).mass z*(if secondTrim choose read Y target t U z then (1:ℝ) else 0))≤ + (10/(Y.card:ℝ))*t.height*δ := by + have hy : 0≤10/(Y.card:ℝ) := div_nonneg (by norm_num) (Nat.cast_nonneg _) + calc + _ ≤ ∑ z,(piLaw p).mass z*((10/(Y.card:ℝ))*∑ j∈rightPath target t, + produced choose read j (secondLoss choose mask Y j) t U z) := by + apply sum_le_sum + intro z _ + exact mul_le_mul_of_nonneg_left + (reached_second_trim_charge choose read mask hread z target Y hY t U ht hmem hYU) + ((piLaw p).nonneg z) + _ = (10/(Y.card:ℝ))*(∑ z,(piLaw p).mass z*∑ j∈rightPath target t, + produced choose read j (secondLoss choose mask Y j) t U z) := by + rw [mul_sum] + apply sum_congr rfl + intro z _ + ring + _ ≤ (10/(Y.card:ℝ))*((t.height:ℝ)*δ) := + mul_le_mul_of_nonneg_left + (expected_second_path_loss p dummy choose read mask Y target t U δ hδ hlocal) hy + _ = _ := by ring + +end +end SharpLogRamsey.FreshExecution + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedSupportTrim.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedSupportTrim.lean new file mode 100644 index 0000000000000000000000000000000000000000..061a41d494c877fdee818b50cb8b14ee8d2c8f63 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedSupportTrim.lean @@ -0,0 +1,140 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.ExecutedSecondTrim + +namespace OAI + +section +namespace SharpLogRamsey.FreshExecution +open Finset BinaryTree TreeDecoder PublicTables +open scoped Classical BigOperators +noncomputable section +variable {I A B C Ω : Type*} [DecidableEq I] [Fintype I] [Fintype Ω] + {α : I→Type*} [∀ i,Fintype (α i)] + +theorem averaged_path_bound (μ : Law Ω) (p : ∀ i,Law (α i)) (dummy : ∀ i,α i) + (choose : Ω→∀ i,α i→Domains A B→Option C) + (read : Ω→∀ i,α i→CapReader A B C) + (loss : Ω→∀ i,Domains A B→α i→ℝ) + (t : BinaryTree I) (U : Domains A B) (J : Finset I) + (M : Ω→ℝ) (hM : ∀ ω,0≤M ω) (budget : Ω→I→ℝ) + (hb : ∀ ω,∀ i∈J,0≤budget ω i) + (hlocal : ∀ ω,∀ i∈J,∀ V,(∑ x,(p i).mass x*loss ω i V x)≤budget ω i) + (ε : ℝ) (hmean : ∀ i∈J,(∑ ω,μ.mass ω*(budget ω i/M ω))≤ε) : + (∑ ω,μ.mass ω*(∑ z,(piLaw p).mass z* + ((∑ j∈J,produced (choose ω) (read ω) j (loss ω j) t U z)/M ω)))≤J.card*ε := by + have hω (ω : Ω) : (∑ z,(piLaw p).mass z* + ((∑ j∈J,produced (choose ω) (read ω) j (loss ω j) t U z)/M ω))≤ + ∑ j∈J,budget ω j/M ω := by + simp_rw [←mul_div_assoc,←sum_div,mul_sum] + rw [sum_comm] + apply div_le_div_of_nonneg_right _ (hM ω) + apply sum_le_sum + intro j hj + exact produced_bound p (choose ω) (read ω) j (dummy j) (loss ω j) t U + (budget ω j) (hb ω j hj) (hlocal ω j hj) + calc + _ ≤ ∑ ω,μ.mass ω*(∑ j∈J,budget ω j/M ω) := by + apply sum_le_sum + intro ω _ + exact mul_le_mul_of_nonneg_left (hω ω) (μ.nonneg ω) + _ = ∑ j∈J,∑ ω,μ.mass ω*(budget ω j/M ω) := by + simp_rw [mul_sum] + rw [sum_comm] + _ ≤ ∑ _j∈J,ε := sum_le_sum (fun j hj=>hmean j hj) + _ = _ := by simp only [sum_const,nsmul_eq_mul] + +theorem averaged_charge_bound (μ : Law Ω) (p : ∀ i,Law (α i)) (dummy : ∀ i,α i) + (choose : Ω→∀ i,α i→Domains A B→Option C) + (read : Ω→∀ i,α i→CapReader A B C) + (loss : Ω→∀ i,Domains A B→α i→ℝ) + (t : BinaryTree I) (U : Domains A B) (J : Finset I) + (M : Ω→ℝ) (hM : ∀ ω,0≤M ω) (budget : Ω→I→ℝ) + (hb : ∀ ω,∀ i∈J,0≤budget ω i) + (hlocal : ∀ ω,∀ i∈J,∀ V,(∑ x,(p i).mass x*loss ω i V x)≤budget ω i) + (ε : ℝ) (hmean : ∀ i∈J,(∑ ω,μ.mass ω*(budget ω i/M ω))≤ε) + (E : Ω→(∀ i,α i)→Prop) + (hcharge : ∀ ω z,(if E ω z then (1:ℝ) else 0)≤ + (10/M ω)*∑ j∈J,produced (choose ω) (read ω) j (loss ω j) t U z) : + (∑ ω,μ.mass ω*(∑ z,(piLaw p).mass z*(if E ω z then (1:ℝ) else 0)))≤10*J.card*ε := by + have hpath:=averaged_path_bound μ p dummy choose read loss t U J M hM budget hb hlocal ε hmean + calc + _ ≤ ∑ ω,μ.mass ω*(∑ z,(piLaw p).mass z*((10/M ω)* + ∑ j∈J,produced (choose ω) (read ω) j (loss ω j) t U z)) := by + apply sum_le_sum + intro ω _ + apply mul_le_mul_of_nonneg_left _ (μ.nonneg ω) + apply sum_le_sum + intro z _ + exact mul_le_mul_of_nonneg_left (hcharge ω z) ((piLaw p).nonneg z) + _ = 10*(∑ ω,μ.mass ω*(∑ z,(piLaw p).mass z* + ((∑ j∈J,produced (choose ω) (read ω) j (loss ω j) t U z)/M ω))) := by + rw [mul_sum] + apply sum_congr rfl + intro ω _ + have hh : (∑ z,(piLaw p).mass z*((10/M ω)* + ∑ j∈J,produced (choose ω) (read ω) j (loss ω j) t U z))= + 10*(∑ z,(piLaw p).mass z*((∑ j∈J, + produced (choose ω) (read ω) j (loss ω j) t U z)/M ω)) := by + rw [mul_sum] + apply sum_congr rfl + intro z _ + ring + rw [hh] + ring + _ ≤ 10*(J.card*ε) := mul_le_mul_of_nonneg_left hpath (by norm_num) + _ = _ := by ring + +theorem original_first_trim (μ : Law Ω) (p : ∀ i,Law (α i)) (dummy : ∀ i,α i) + (choose : Ω→∀ i,α i→Domains A B→Option C) + (read mask : Ω→∀ i,α i→CapReader A B C) + (hread : ∀ ω i x U c,(read ω i x U c).1=U.1∩(mask ω i x U c).1) + (target : I) (Y : Ω→Finset A) (hY : ∀ ω,(Y ω).Nonempty) + (t : BinaryTree I) (U : Domains A B) (ht : Separated t) + (hmem : target∈labels t) (hYU : ∀ ω,Y ω⊆U.1) + (budget : Ω→I→ℝ) (hb : ∀ ω,∀ i∈leftPath target t,0≤budget ω i) + (hlocal : ∀ ω,∀ i∈leftPath target t,∀ V, + (∑ x,(p i).mass x*firstLoss (choose ω) (mask ω) (Y ω) i V x)≤budget ω i) + (ε : ℝ) (hε : 0≤ε) + (hmean : ∀ i∈leftPath target t,(∑ ω,μ.mass ω*(budget ω i/(Y ω).card))≤ε) : + (∑ ω,μ.mass ω*(∑ z,(piLaw p).mass z* + (if firstTrim (choose ω) (read ω) (Y ω) target t U z then (1:ℝ) else 0)))≤ + 10*t.height*ε := by + apply (averaged_charge_bound μ p dummy choose read + (fun ω=>firstLoss (choose ω) (mask ω) (Y ω)) t U (leftPath target t) + (fun ω=>((Y ω).card:ℝ)) (fun ω=>Nat.cast_nonneg _) budget hb hlocal ε hmean + (fun ω=>firstTrim (choose ω) (read ω) (Y ω) target t U) + (fun ω z=>reached_first_trim_charge (choose ω) (read ω) (mask ω) (hread ω) + z target (Y ω) (hY ω) t U ht hmem (hYU ω))).trans + have hh : ((leftPath target t).card:ℝ)≤t.height := by exact_mod_cast leftPath_card target t + gcongr + +theorem original_second_trim (μ : Law Ω) (p : ∀ i,Law (α i)) (dummy : ∀ i,α i) + (choose : Ω→∀ i,α i→Domains A B→Option C) + (read mask : Ω→∀ i,α i→CapReader A B C) + (hread : ∀ ω i x U c,(read ω i x U c).2=U.2∩(mask ω i x U c).2) + (target : I) (Y : Ω→Finset B) (hY : ∀ ω,(Y ω).Nonempty) + (t : BinaryTree I) (U : Domains A B) (ht : Separated t) + (hmem : target∈labels t) (hYU : ∀ ω,Y ω⊆U.2) + (budget : Ω→I→ℝ) (hb : ∀ ω,∀ i∈rightPath target t,0≤budget ω i) + (hlocal : ∀ ω,∀ i∈rightPath target t,∀ V, + (∑ x,(p i).mass x*secondLoss (choose ω) (mask ω) (Y ω) i V x)≤budget ω i) + (ε : ℝ) (hε : 0≤ε) + (hmean : ∀ i∈rightPath target t,(∑ ω,μ.mass ω*(budget ω i/(Y ω).card))≤ε) : + (∑ ω,μ.mass ω*(∑ z,(piLaw p).mass z* + (if secondTrim (choose ω) (read ω) (Y ω) target t U z then (1:ℝ) else 0)))≤ + 10*t.height*ε := by + apply (averaged_charge_bound μ p dummy choose read + (fun ω=>secondLoss (choose ω) (mask ω) (Y ω)) t U (rightPath target t) + (fun ω=>((Y ω).card:ℝ)) (fun ω=>Nat.cast_nonneg _) budget hb hlocal ε hmean + (fun ω=>secondTrim (choose ω) (read ω) (Y ω) target t U) + (fun ω z=>reached_second_trim_charge (choose ω) (read ω) (mask ω) (hread ω) + z target (Y ω) (hY ω) t U ht hmem (hYU ω))).trans + have hh : ((rightPath target t).card:ℝ)≤t.height := by exact_mod_cast rightPath_card target t + gcongr + +end +end SharpLogRamsey.FreshExecution + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedTargetBudget.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedTargetBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..2dc6951718384700e468de0e4b404efba0b2293c --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedTargetBudget.lean @@ -0,0 +1,100 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.ExecutedEndpoint +import OAI.Combinatorics.SharpRamsey.Execution.ExecutedSupportTrim + +namespace OAI + +section +namespace SharpLogRamsey.FreshExecution +open Finset BinaryTree TreeDecoder PublicTables +open scoped Classical BigOperators +noncomputable section +variable {I A B C Ω : Type*} [DecidableEq I] [Fintype I] [Fintype Ω] + {α : I→Type*} [∀ i,Fintype (α i)] + +theorem original_target_loss (μ : Law Ω) (p : ∀ i,Law (α i)) (dummy : ∀ i,α i) + (choose : Ω→∀ i,α i→Domains A B→Option C) + (read mask : Ω→∀ i,α i→CapReader A B C) + (hreadA : ∀ ω i x V c,(read ω i x V c).1=V.1∩(mask ω i x V c).1) + (hreadB : ∀ ω i x V c,(read ω i x V c).2=V.2∩(mask ω i x V c).2) + (a : Ω→A) (b : Ω→B) (target : I) (t : BinaryTree I) (U : Domains A B) + (ht : Separated t) (hmem : target∈labels t) + (haU : ∀ ω,a ω∈U.1) (hbU : ∀ ω,b ω∈U.2) + (BA BB : Ω→I→ℝ) (εA εB L : ℝ) (hεA : 0≤εA) (hεB : 0≤εB) + (hBA : ∀ ω,∀ i∈insert target (leftPath target t),0≤BA ω i) + (hBB : ∀ ω,∀ i∈insert target (rightPath target t),0≤BB ω i) + (hlocalA : ∀ ω,∀ i∈insert target (leftPath target t),∀ V, + (∑ x,(p i).mass x*firstLoss (choose ω) (mask ω) {a ω} i V x)≤BA ω i) + (hlocalB : ∀ ω,∀ i∈insert target (rightPath target t),∀ V, + (∑ x,(p i).mass x*secondLoss (choose ω) (mask ω) {b ω} i V x)≤BB ω i) + (hmeanA : ∀ i∈insert target (leftPath target t),(∑ ω,μ.mass ω*BA ω i)≤εA) + (hmeanB : ∀ i∈insert target (rightPath target t),(∑ ω,μ.mass ω*BB ω i)≤εB) + (hdelete : (∑ ω,μ.mass ω*(∑ z,(piLaw p).mass z* + (1-pivotSuccess (choose ω) (read ω) target t U z)))≤L) : + (∑ ω,μ.mass ω*(∑ z,(piLaw p).mass z* + targetFailure (choose ω) (read ω) (a ω) (b ω) target t U z))≤ + L+((t.height:ℝ)+1)*(εA+εB) := by + have hpathA := averaged_path_bound μ p dummy choose read + (fun ω i=>firstLoss (choose ω) (mask ω) {a ω} i) t U (leftPath target t) + (fun _=>1) (fun _=>by norm_num) BA + (fun ω i hi=>hBA ω i (mem_insert_of_mem hi)) + (fun ω i hi=>hlocalA ω i (mem_insert_of_mem hi)) εA + (fun i hi=>by simpa only [div_one] using hmeanA i (mem_insert_of_mem hi)) + have hpathB := averaged_path_bound μ p dummy choose read + (fun ω i=>secondLoss (choose ω) (mask ω) {b ω} i) t U (rightPath target t) + (fun _=>1) (fun _=>by norm_num) BB + (fun ω i hi=>hBB ω i (mem_insert_of_mem hi)) + (fun ω i hi=>hlocalB ω i (mem_insert_of_mem hi)) εB + (fun i hi=>by simpa only [div_one] using hmeanB i (mem_insert_of_mem hi)) + have hownA := averaged_path_bound μ p dummy choose read + (fun ω i=>firstLoss (choose ω) (mask ω) {a ω} i) t U {target} + (fun _=>1) (fun _=>by norm_num) BA + (fun ω i hi=>hBA ω i (by rw [mem_singleton.mp hi]; exact mem_insert_self _ _)) + (fun ω i hi=>hlocalA ω i (by rw [mem_singleton.mp hi]; exact mem_insert_self _ _)) εA + (fun i hi=>by + have hi' : i=target := mem_singleton.mp hi + subst i + simpa only [div_one] using hmeanA target (mem_insert_self _ _)) + have hownB := averaged_path_bound μ p dummy choose read + (fun ω i=>secondLoss (choose ω) (mask ω) {b ω} i) t U {target} + (fun _=>1) (fun _=>by norm_num) BB + (fun ω i hi=>hBB ω i (by rw [mem_singleton.mp hi]; exact mem_insert_self _ _)) + (fun ω i hi=>hlocalB ω i (by rw [mem_singleton.mp hi]; exact mem_insert_self _ _)) εB + (fun i hi=>by + have hi' : i=target := mem_singleton.mp hi + subst i + simpa only [div_one] using hmeanB target (mem_insert_self _ _)) + simp only [div_one] at hpathA hpathB + simp only [div_one,sum_singleton,card_singleton,Nat.cast_one,one_mul] at hownA hownB + have hcA : ((leftPath target t).card:ℝ)*εA≤(t.height:ℝ)*εA := + mul_le_mul_of_nonneg_right (by exact_mod_cast leftPath_card target t) hεA + have hcB : ((rightPath target t).card:ℝ)*εB≤(t.height:ℝ)*εB := + mul_le_mul_of_nonneg_right (by exact_mod_cast rightPath_card target t) hεB + have hpart : (∑ ω,μ.mass ω*(∑ z,(piLaw p).mass z* + targetFailure (choose ω) (read ω) (a ω) (b ω) target t U z))≤ + ∑ ω,μ.mass ω*(∑ z,(piLaw p).mass z*( + 1-pivotSuccess (choose ω) (read ω) target t U z+ + (∑ j∈leftPath target t,produced (choose ω) (read ω) j + (firstLoss (choose ω) (mask ω) {a ω} j) t U z)+ + (∑ j∈rightPath target t,produced (choose ω) (read ω) j + (secondLoss (choose ω) (mask ω) {b ω} j) t U z)+ + produced (choose ω) (read ω) target (firstLoss (choose ω) (mask ω) {a ω} target) t U z+ + produced (choose ω) (read ω) target (secondLoss (choose ω) (mask ω) {b ω} target) t U z)) := by + apply sum_le_sum + intro ω _ + apply mul_le_mul_of_nonneg_left _ (μ.nonneg ω) + apply sum_le_sum + intro z _ + exact mul_le_mul_of_nonneg_left (target_failure_charge (choose ω) (read ω) (mask ω) + (hreadA ω) (hreadB ω) z target (a ω) (b ω) t U ht hmem (haU ω) (hbU ω)) + ((piLaw p).nonneg z) + simp_rw [mul_add,sum_add_distrib] at hpart + simp_rw [mul_add,sum_add_distrib] at hpart + linarith + +end +end SharpLogRamsey.FreshExecution + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedTrim.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedTrim.lean new file mode 100644 index 0000000000000000000000000000000000000000..13f326179827544b63ab27d7f5bf8db631710b9b --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/ExecutedTrim.lean @@ -0,0 +1,235 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Selection.FreshAccrual + +namespace OAI + +section +namespace SharpLogRamsey.FreshExecution +open Finset BinaryTree TreeDecoder PublicTables +open scoped Classical BigOperators +noncomputable section +variable {I A B C : Type*} [DecidableEq I] {α : I→Type*} + +def leftPath (target : I) : BinaryTree I→Finset I + | .nil=>∅ + | .node i l r=>if i=target then ∅ else + if target∈labels l then insert i (leftPath target l) else leftPath target r + +lemma leftPath_subset (target : I) (t : BinaryTree I) : leftPath target t⊆labels t := by + induction t with + | nil=>exact empty_subset _ + | node i l r hl hr=> + rw [leftPath,labels_node] + split_ifs with hi hj + · exact empty_subset _ + · exact insert_subset_insert i (hl.trans subset_union_left) + · exact hr.trans (subset_union_right.trans (subset_insert _ _)) + +lemma leftPath_card (target : I) (t : BinaryTree I) : + (leftPath target t).card≤t.height := by + induction t with + | nil=>rfl + | node i l r hl hr=> + rw [leftPath] + split_ifs + · exact Nat.zero_le _ + · exact (card_insert_le _ _).trans (by simp only [height]; omega) + · simp only [height]; omega + +def firstLoss (choose : ∀ i,α i→Domains A B→Option C) + (mask : ∀ i,α i→CapReader A B C) (Y : Finset A) + (i : I) (U : Domains A B) (x : α i) : ℝ := + match choose i x U with + | none=>0 + | some c=>((Y\(mask i x U c).1).card:ℝ) + +omit [DecidableEq I] in +lemma firstLoss_nonneg (choose : ∀ i,α i→Domains A B→Option C) + (mask : ∀ i,α i→CapReader A B C) (Y : Finset A) + (i : I) (U : Domains A B) (x : α i) : 0≤firstLoss choose mask Y i U x := by + unfold firstLoss + cases choose i x U <;> positivity + +lemma sdiff_inter_card (Y U M : Finset A) : + ((Y\(U∩M)).card:ℝ)≤((Y\U).card:ℝ)+(Y\M).card := by + have he : Y\(U∩M)=(Y\U)∪(Y\M) := by ext x; simp; tauto + rw [he] + exact_mod_cast card_union_le (Y\U) (Y\M) + +theorem reached_first_loss (choose : ∀ i,α i→Domains A B→Option C) + (read mask : ∀ i,α i→CapReader A B C) + (hread : ∀ i x U c,(read i x U c).1=U.1∩(mask i x U c).1) + (z : ∀ i,α i) (target : I) (Y : Finset A) + (t : BinaryTree I) (U V : Domains A B) (ht : Separated t) + (hmem : target∈labels t) (hv : arrive choose read z target t U=some V) : + ((Y\V.1).card:ℝ)≤((Y\U.1).card:ℝ)+ + ∑ j∈leftPath target t,produced choose read j (firstLoss choose mask Y j) t U z := by + induction t generalizing U V with + | nil=>simp [labels_nil] at hmem + | node i l r hl hr=> + rcases ht with ⟨htl,htr,hli,hri,hd⟩ + by_cases hi : i=target + · rw [arrive,ite_eq_left hi] at hv + have hUV : U=V := Option.some.inj hv + rw [leftPath,ite_eq_left hi,hUV,sum_empty,add_zero] + · by_cases hL : target∈labels l + · have hR : target∉labels r := disjoint_left.mp hd hL + rw [arrive,ite_eq_right hi] at hv + cases hc : choose i (z i) U with + | none=>simp only [hc] at hv; contradiction + | some c=> + rw [hc] at hv + dsimp only at hv + rw [arrive_absent choose read z target r _ hR] at hv + have hv' : arrive choose read z target l ((read i (z i) U c).1,U.2)=some V := by + cases hh : arrive choose read z target l ((read i (z i) U c).1,U.2) with + | none=>simp [hh] at hv + | some W=>rw [hh] at hv; exact hv + have hchild:=hl _ _ htl hL hv' + rw [leftPath,ite_eq_right hi,ite_eq_left hL] + have hnot : i∉leftPath target l := fun hj=>hli (leftPath_subset target l hj) + rw [sum_insert hnot,produced_root] + have he : (∑ j∈leftPath target l,produced choose read j (firstLoss choose mask Y j) + (.node i l r) U z)= + ∑ j∈leftPath target l,produced choose read j (firstLoss choose mask Y j) + l ((read i (z i) U c).1,U.2) z := by + apply sum_congr rfl + intro j hj + exact produced_left choose read z i j _ l r U (leftPath_subset target l hj) hli hd c hc + rw [he] + have hs:=sdiff_inter_card Y U.1 (mask i (z i) U c).1 + have hs' : ((Y\(read i (z i) U c).1).card:ℝ)≤ + ((Y\U.1).card:ℝ)+(Y\(mask i (z i) U c).1).card := by + rw [hread] + exact hs + simp only [firstLoss,hc] + linarith + · have hR : target∈labels r := by + rw [labels_node,mem_insert,mem_union] at hmem + rcases hmem with he|he|he + · exact False.elim (hi he.symm) + · exact False.elim (hL he) + · exact he + rw [arrive,ite_eq_right hi] at hv + cases hc : choose i (z i) U with + | none=>simp only [hc] at hv; contradiction + | some c=> + rw [hc] at hv + dsimp only at hv + rw [arrive_absent choose read z target l _ hL] at hv + have hv' : arrive choose read z target r (U.1,(read i (z i) U c).2)=some V := hv + have hchild:=hr _ _ htr hR hv' + rw [leftPath,ite_eq_right hi,ite_eq_right hL] + have he : (∑ j∈leftPath target r,produced choose read j (firstLoss choose mask Y j) + (.node i l r) U z)= + ∑ j∈leftPath target r,produced choose read j (firstLoss choose mask Y j) + r (U.1,(read i (z i) U c).2) z := by + apply sum_congr rfl + intro j hj + exact produced_right choose read z i j _ l r U (leftPath_subset target r hj) hri hd c hc + rw [he] + exact hchild + +variable [Fintype I] [∀ i,Fintype (α i)] + +theorem expected_first_path_loss (p : ∀ i,Law (α i)) (dummy : ∀ i,α i) + (choose : ∀ i,α i→Domains A B→Option C) + (read mask : ∀ i,α i→CapReader A B C) (Y : Finset A) + (target : I) (t : BinaryTree I) (U : Domains A B) + (δ : ℝ) (hδ : 0≤δ) + (hlocal : ∀ i∈leftPath target t,∀ V, + (∑ x,(p i).mass x*firstLoss choose mask Y i V x)≤δ) : + (∑ z,(piLaw p).mass z*(∑ j∈leftPath target t, + produced choose read j (firstLoss choose mask Y j) t U z))≤(t.height:ℝ)*δ := by + simp_rw [mul_sum] + rw [sum_comm] + calc + _ ≤ ∑ j∈leftPath target t,δ := by + apply sum_le_sum + intro j hj + exact produced_bound p choose read j (dummy j) (firstLoss choose mask Y j) t U δ hδ (hlocal j hj) + _ = ((leftPath target t).card:ℝ)*δ := by simp only [sum_const,nsmul_eq_mul] + _ ≤ _ := mul_le_mul_of_nonneg_right (by exact_mod_cast leftPath_card target t) hδ + +def firstTrim (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (Y : Finset A) + (target : I) (t : BinaryTree I) (U : Domains A B) (z : ∀ i,α i) : Prop := + ∃ V,arrive choose read z target t U=some V ∧ + ((Y∩V.1).card:ℝ)<(9/10:ℝ)*Y.card + +omit [Fintype I] [∀ i,Fintype (α i)] in + +lemma produced_nonneg (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (target : I) + (f : Domains A B→α target→ℝ) (hf : ∀ V x,0≤f V x) + (t : BinaryTree I) (U : Domains A B) (z : ∀ i,α i) : + 0≤produced choose read target f t U z := by + unfold produced + cases arrive choose read z target t U with + | none=>exact le_rfl + | some V=>exact hf V (z target) + +omit [Fintype I] [∀ i,Fintype (α i)] in + +theorem reached_first_trim_charge (choose : ∀ i,α i→Domains A B→Option C) + (read mask : ∀ i,α i→CapReader A B C) + (hread : ∀ i x U c,(read i x U c).1=U.1∩(mask i x U c).1) + (z : ∀ i,α i) (target : I) (Y : Finset A) (hY : Y.Nonempty) + (t : BinaryTree I) (U : Domains A B) (ht : Separated t) + (hmem : target∈labels t) (hYU : Y⊆U.1) : + (if firstTrim choose read Y target t U z then (1:ℝ) else 0)≤ + (10/(Y.card:ℝ))*∑ j∈leftPath target t, + produced choose read j (firstLoss choose mask Y j) t U z := by + have hy : 0<(Y.card:ℝ) := by exact_mod_cast card_pos.mpr hY + split_ifs with htrim + · obtain ⟨V,hv,hsmall⟩:=htrim + have hl:=reached_first_loss choose read mask hread z target Y t U V ht hmem hv + rw [sdiff_eq_empty_iff_subset.mpr hYU,card_empty,Nat.cast_zero,zero_add] at hl + have hc : ((Y\V.1).card:ℝ)+((Y∩V.1).card:ℝ)=Y.card := by + exact_mod_cast card_sdiff_add_card_inter Y V.1 + rw [div_mul_eq_mul_div] + apply (le_div_iff₀ hy).mpr + nlinarith + · apply mul_nonneg (div_nonneg (by norm_num) hy.le) + apply sum_nonneg + intro j _ + exact produced_nonneg choose read j _ (firstLoss_nonneg choose mask Y j) t U z + +theorem expected_first_trim (p : ∀ i,Law (α i)) (dummy : ∀ i,α i) + (choose : ∀ i,α i→Domains A B→Option C) + (read mask : ∀ i,α i→CapReader A B C) + (hread : ∀ i x U c,(read i x U c).1=U.1∩(mask i x U c).1) + (target : I) (Y : Finset A) (hY : Y.Nonempty) + (t : BinaryTree I) (U : Domains A B) (ht : Separated t) + (hmem : target∈labels t) (hYU : Y⊆U.1) + (δ : ℝ) (hδ : 0≤δ) + (hlocal : ∀ i∈leftPath target t,∀ V, + (∑ x,(p i).mass x*firstLoss choose mask Y i V x)≤δ) : + (∑ z,(piLaw p).mass z*(if firstTrim choose read Y target t U z then (1:ℝ) else 0))≤ + (10/(Y.card:ℝ))*t.height*δ := by + have hy : 0≤10/(Y.card:ℝ) := div_nonneg (by norm_num) (Nat.cast_nonneg _) + calc + _ ≤ ∑ z,(piLaw p).mass z*((10/(Y.card:ℝ))*∑ j∈leftPath target t, + produced choose read j (firstLoss choose mask Y j) t U z) := by + apply sum_le_sum + intro z _ + exact mul_le_mul_of_nonneg_left + (reached_first_trim_charge choose read mask hread z target Y hY t U ht hmem hYU) + ((piLaw p).nonneg z) + _ = (10/(Y.card:ℝ))*(∑ z,(piLaw p).mass z*∑ j∈leftPath target t, + produced choose read j (firstLoss choose mask Y j) t U z) := by + rw [mul_sum] + apply sum_congr rfl + intro z _ + ring + _ ≤ (10/(Y.card:ℝ))*((t.height:ℝ)*δ) := + mul_le_mul_of_nonneg_left + (expected_first_path_loss p dummy choose read mask Y target t U δ hδ hlocal) hy + _ = _ := by ring + +end +end SharpLogRamsey.FreshExecution + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/FreshExecution.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/FreshExecution.lean new file mode 100644 index 0000000000000000000000000000000000000000..261a08e015c8c5b5c5ae1d1269d1593f083a6d23 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/FreshExecution.lean @@ -0,0 +1,121 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Selection.FreshFamilies +import OAI.Combinatorics.SharpRamsey.Trees.ChronologicalTree + +namespace OAI + +section +namespace SharpLogRamsey.FreshExecution +open Finset BinaryTree TreeDecoder PublicTables +open scoped Classical BigOperators +noncomputable section +variable {I A B C : Type*} [DecidableEq I] +variable {α : I→Type*} + +def arrive (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (z : ∀ i,α i) (target : I) : + BinaryTree I→Domains A B→Option (Domains A B) + | .nil,_=>none + | .node i l r,U=>if i=target then some U else + match choose i (z i) U with + | none=>none + | some c=> + let V:=read i (z i) U c + (arrive choose read z target l (V.1,U.2)).orElse + (fun _=>arrive choose read z target r (U.1,V.2)) + +theorem arrive_congr (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (z z' : ∀ i,α i) (target : I) + (hz : ∀ j,j≠target→z j=z' j) (t : BinaryTree I) (U : Domains A B) : + arrive choose read z target t U=arrive choose read z' target t U := by + induction t generalizing U with + | nil=>rfl + | node i l r hl hr=> + simp only [arrive] + split_ifs with hi + · rfl + · rw [hz i hi] + cases choose i (z' i) U with + | none=>rfl + | some c=> + simp only + rw [hl,hr] + +def outsideState (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (target : I) (dummy : α target) + (t : BinaryTree I) (U : Domains A B) (s : Outside (α:=α) target) : + Option (Domains A B) := + arrive choose read ((Equiv.piSplitAt target α).symm (dummy,s)) target t U + +theorem arrive_outside (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (target : I) (dummy : α target) + (t : BinaryTree I) (U : Domains A B) (z : ∀ i,α i) : + arrive choose read z target t U= + outsideState choose read target dummy t U (outside target z) := by + apply arrive_congr + intro j hj + simp only [Equiv.piSplitAt_symm_apply,dite_eq_right hj,outside] + +def produced (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (target : I) + (f : Domains A B→α target→ℝ) (t : BinaryTree I) (U : Domains A B) + (z : ∀ i,α i) : ℝ := + match arrive choose read z target t U with + | none=>0 + | some V=>f V (z target) + +variable [Fintype I] [∀ i,Fintype (α i)] + +theorem produced_bound (p : ∀ i,Law (α i)) + (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (target : I) (dummy : α target) + (f : Domains A B→α target→ℝ) (t : BinaryTree I) (U : Domains A B) + (B₀ : ℝ) (hB : 0≤B₀) + (hlocal : ∀ V,(∑ x,(p target).mass x*f V x)≤B₀) : + (∑ z,(piLaw p).mass z*produced choose read target f t U z)≤B₀ := by + let g := fun s : Outside (α:=α) target=>fun x : α target=> + match outsideState choose read target dummy t U s with + | none=>0 + | some V=>f V x + have he (z : ∀ i,α i) : produced choose read target f t U z= + g (outside target z) (z target) := by + unfold produced g + rw [arrive_outside choose read target dummy] + simp_rw [he] + rw [family_integral] + calc + _ ≤ ∑ s,(outsideLaw p target).mass s*B₀ := by + apply sum_le_sum + intro s _ + apply mul_le_mul_of_nonneg_left _ ((outsideLaw p target).nonneg s) + dsimp only [g] + cases outsideState choose read target dummy t U s with + | none=>simpa only [mul_zero,sum_const_zero] using hB + | some V=>exact hlocal V + _ = B₀ := by rw [←sum_mul,(outsideLaw p target).total,one_mul] + +def fixedRead (read : ∀ i,α i→CapReader A B C) (z : ∀ i,α i) : + CapReader A B (I×C) := fun U c=>read c.1 (z c.1) U c.2 + +def fixedChoose (choose : ∀ i,α i→Domains A B→Option C) (z : ∀ i,α i) : + I→Domains A B→Option (I×C) := fun i U=>(choose i (z i) U).map (fun c=>(i,c)) + +omit [DecidableEq I] [Fintype I] [∀ i,Fintype (α i)] in + +theorem fixed_decoder_correct (R : A→B→Prop) + (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (z : ∀ i,α i) + (targets : I→List (A×B)) (counts : I→ℕ) (t : BinaryTree I) (U : Domains A B) : + let tr:=execute (fixedRead read z) (fixedChoose choose z) t U + List.Forall₂ (fun x D=>x∈D) + (output R (fixedRead read z) targets counts tr U) + (decode R (fixedRead read z) + (message R (fixedRead read z) targets counts tr U) U) := by + exact decoder_correct R (fixedRead read z) targets counts _ U + +end +end SharpLogRamsey.FreshExecution + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/HighRankExtraction.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/HighRankExtraction.lean new file mode 100644 index 0000000000000000000000000000000000000000..34c155654a1ce375efb0d287767a71bddae9cb55 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/HighRankExtraction.lean @@ -0,0 +1,185 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.GoodRows +import OAI.Combinatorics.SharpRamsey.Parameters.HighRankScales + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset Real FiniteMarginals HighRankCoverageProbability FiniteEventBounds +open scoped Classical BigOperators +noncomputable section + +variable {X A B : Type*} [Fintype X] [Fintype A] [Fintype B] +lemma Law.swap_map_marginal (p : Law X) (f : X→A×B) (a : A) (b : B) : + FiniteMarginals.marginal p.mass (fun x=>(f x).swap) (b,a)=(p.map f).mass (a,b) := by + simp only [FiniteMarginals.marginal,Law.map,sum_filter] + apply sum_congr rfl + intro x _ + have he : (f x).swap=(b,a) ↔ f x=(a,b) := by + rcases f x with ⟨c,d⟩ + simp only [Prod.swap_prod_mk,Prod.mk.injEq,and_comm] + simp only [he] + split_ifs <;> rfl +end +end SharpLogRamsey.Selection + +namespace SharpLogRamsey.ActualHighRank +open Finset Real Selection FiniteMarginals HighRankCoverageProbability FiniteEventBounds HighRankAssembly +open scoped Classical BigOperators +noncomputable section +variable {K Ξ : Type} [Field K] [Fintype K] [Fintype Ξ] {d : ℕ} +local instance flat_ActualHighRankExtraction_1 : Finite (Module.Dual K (Fin (d+1)→K)) := + Finite.of_injective ((↑) : Module.Dual K (Fin (d+1)→K)→((Fin (d+1)→K)→K)) DFunLike.coe_injective +local instance flat_ActualHighRankExtraction_2 : Fintype (Projectivization K (Fin (d+1)→K)) := Fintype.ofFinite _ +local instance flat_ActualHighRankExtraction_3 : Fintype (Projectivization K (Module.Dual K (Fin (d+1)→K))) := Fintype.ofFinite _ +local notation "A" => Projectivization K (Module.Dual K (Fin (d+1)→K)) +local notation "B" => Projectivization K (Fin (d+1)→K) +local notation "q" => (Nat.card K:ℝ) + +theorem extraction (hd : 2≤d) {ℓ : ℕ} (hℓ : 0<ℓ) + (s : Law (A×B)) (S : Finset (A×B)) + (p : Law Ξ) (f : Ξ→Fin ℓ→A×B) (U : Fin ℓ→Finset (A×B)) + (σ β D : ℝ) (hσ : 1≤σ) (hβ : 0≤β) (hlog : log q=σ) (hD : σ^β≤D) + (h r r' T : ℕ) (hr : 2≤r) (hrd : r≤d) (hrank : d+2≤r+r') (hhd : 2*d≤h) + (u I : ℝ) (hu : 0(a,b)∈S)).card:ℝ)≤2*exp (((d:ℝ)-r')*σ)) + (hsfB : ∀ b,((univ.filter (fun a=>(a,b)∈S)).card:ℝ)≤2*exp (((d:ℝ)-r)*σ)) + (hsdef : (d:ℝ)*σ-entropy s≤D*σ^β) + (hp : ∀ x,p.mass x≠0→∀ i,f x i∈U i) + (hinc : ∀ x,p.mass x≠0→∀ i,(f x i).1.rep (f x i).2.rep=0) + (hUA : ∀ i,(((U i).image Prod.fst).card:ℝ)≤1024*q^r') + (hUB : ∀ i,(((U i).image Prod.snd).card:ℝ)≤1024*q^r) + (hU : ∀ i,((U i).card:ℝ)≤64*q^d) + (hufA : ∀ i a,((univ.filter (fun b=>(a,b)∈U i)).card:ℝ)≤2*exp (((d:ℝ)-r')*σ)) + (hufB : ∀ i b,((univ.filter (fun a=>(a,b)∈U i)).card:ℝ)≤2*exp (((d:ℝ)-r)*σ)) + (hdef : ∀ i,(d:ℝ)*σ-entropy (p.map (fun x=>f x i))≤D*σ^β) + (hconflict : ∀ i,(∑ x,p.mass x*∑ z,s.mass z* + indicator (z.1.rep (f x i).2.rep=0 ∧ (f x i).1.rep z.2.rep≠0))≤I) + (hTlo : (h:ℝ)/(10*q)≤T) (hThi : (T:ℝ)≤(h:ℝ)/(10*q)+1) + (hTn : d+2≤T) (hescape : 20480*exp (D*σ^(3*β))≤q) : + let κ:=D*σ^(3*β) + let E:=univ.filter (fun z : A×B=> + highGoodFirst s (1024*q^r') ((d:ℝ)*σ) κ (exp (κ-(r':ℝ)*σ)) z.1 ∧ + highGoodSecond s (1024*q^r) ((d:ℝ)*σ) κ (exp (κ-(r:ℝ)*σ)) z.2) + ∃ hE : (1:ℝ)/2≤ s.event E, + let w:=(s.onEvent E (by linarith)).mass + let Sz:=(10*(d+1)*1024*exp κ/u)^(d+1)*1024*(1+2^(d+2))*(2*q^d) + let err:=4365*σ^(-2*β)+100*1024^2*exp (2*κ)/q+ + (d*exp (-3*(h:ℝ)/(20*d*q))+exp (1-(h:ℝ)/(10*q)))+4*h*I+2048*exp κ/q + let W:=fun z : (Fin h→E)×(Fin h→E)=>ProductLaw.weight w z.1*ProductLaw.weight w z.2 + let DD:=fun z : (Fin h→E)×(Fin h→E)=>HighRankSize.domain (fun z : E=>z.val.1.rep) + (fun z : E=>z.val.2) z.1 z.2 r T + 1-2*err-1/4≤∑ v∈univ.filter (fun v : Ξ×((Fin h→E)×(Fin h→E))=> + ((DD v.2).card:ℝ)≤4*Sz ∧ ∃ e : Fin (ℓ/2)↪o Fin ℓ,∀ i,(f v.1 (e i)).swap∈DD v.2), + p.mass v.1*W v.2 := by + dsimp only + let κ:=D*σ^(3*β) + have hq : 0 + highGoodFirst s (1024*q^r') ((d:ℝ)*σ) κ (exp (κ-(r':ℝ)*σ)) z.1 ∧ + highGoodSecond s (1024*q^r) ((d:ℝ)*σ) κ (exp (κ-(r:ℝ)*σ)) z.2) + obtain ⟨hE,hfirst,hsecond,hmean⟩:=high_good_rows s (1024*q^r') (1024*q^r) ((d:ℝ)*σ) κ + (exp (κ-(r':ℝ)*σ)) (exp (κ-(r:ℝ)*σ)) (4300*σ^(-2*β)) + (exp_nonneg _) (exp_nonneg _) hsmall hm.1 hm.2.1 + change (1:ℝ)/2≤ s.event E at hE + refine ⟨hE,?_⟩ + let row:=s.onEvent E (by linarith : 0p.map (fun x=>f x i) + have hsup i : ∀ z,z∉U i→(tp i).mass z=0 := by + intro z hz + by_contra hh + obtain ⟨x,hx,heq⟩:=p.map_support (fun x=>f x i) z hh + exact hz (heq ▸ hp x hx i) + have htarg i:=actual_high_endpoint_errors (tp i) (U i) σ β D d r r' hσ hβ hD (hsup i) + (by simpa only [he] using hUA i) (by simpa only [he] using hUB i) + (by simpa only [he] using hU i) (hufA i) (hufB i) (hdef i) + dsimp only at htarg + simp only [he] at htarg + let good:=fun i b=>highGoodSecond (tp i) (1024*q^r) ((d:ℝ)*σ) κ (exp (κ-(r:ℝ)*σ)) b + have hsw i a b : FiniteMarginals.marginal p.mass (fun x=>(f x i).swap) (b,a)=(tp i).mass (a,b) := + p.swap_map_marginal _ a b + have hsum i b : (∑ a,FiniteMarginals.marginal p.mass (fun x=>(f x i).swap) (b,a))=(tp i).snd.mass b := by + simp only [hsw] + rfl + have hcap (j : ℕ) : 2*exp (κ-(j:ℝ)*σ)≤1024*exp κ/q^j := by + rw [exp_sub,he] + have hp0 : 0≤exp κ/q^j := by positivity + simpa only [mul_div_assoc] using mul_le_mul_of_nonneg_right (by norm_num : (2:ℝ)≤1024) hp0 + have HC:=extraction_source hd hℓ row.mass row.nonneg row.total + (fun z : E=>z.val.1) (fun z : E=>z.val.2) p.mass p.nonneg p.total + (fun x i=>(f x i).swap) (fun i=>(U i).image Prod.snd) good h r r' T hr hrd hrank hhd + 1024 κ u (4300*σ^(-2*β)) (65*σ^(-2*β)) (2*I) (by norm_num) hu + (by simpa only [show (2:ℝ)*1024=2048 by norm_num] using huA) hu20 hCu + (fun a=>(hfirst a).trans (hcap r')) (fun b=>(hsecond b).trans (hcap r)) + (S.image Prod.snd) ?_ hSB ?_ ?_ ?_ hUB ?_ ?_ ?_ hTlo hThi hTn + (by simpa only [show (20:ℝ)*1024=20480 by norm_num] using hescape) + · convert HC using 1 + dsimp only [κ] + ring + · intro b hb + have hzero:=s.map_image_support S Prod.snd hs b hb + rw [Law.map_snd] at hzero + have hh:=s.onEvent_map_le_two E hE Prod.snd b + rw [Law.map_snd,hzero,mul_zero,row.map_mass_eq_marginal] at hh + exact le_antisymm hh (marginal_nonneg row.mass row.nonneg _ b) + · intro i ⟨b,a⟩ hmass + rw [hsw] at hmass + obtain ⟨x,hx,heq⟩:=p.map_support (fun x=>f x i) (a,b) hmass + simpa only [heq] using hinc x hx i + · intro i ⟨b,a⟩ hmass + rw [hsw] at hmass + have hz : (a,b)∈U i := by by_contra hh; exact hmass (hsup i (a,b) hh) + exact mem_image.mpr ⟨(a,b),hz,rfl⟩ + · intro i b hb + rw [hsum] + exact hb.2.trans (by + rw [exp_sub,he] + have hp0 : 0≤exp κ/q^r := by positivity + simpa only [one_mul,mul_div_assoc] using mul_le_mul_of_nonneg_right (by norm_num : (1:ℝ)≤1024) hp0) + · intro i + simp only [hsum] + exact (htarg i).2.1 + · intro i + have hh:=(htarg i).2.2 + rw [exp_sub,he] at hh + simp only [Law.event,sum_filter] at hh + calc + _ ≤ ∑ t : B×A, if exp κ/q^d(f x i).swap) t + then FiniteMarginals.marginal p.mass (fun x=>(f x i).swap) t else 0 := + sum_le_univ_sum_of_nonneg (fun t=>by split_ifs; exact marginal_nonneg p.mass p.nonneg _ t; rfl) + _ = ∑ z : A×B, if exp κ/q^d<(tp i).mass z then (tp i).mass z else 0 := by + rw [Fintype.sum_prod_type,Fintype.sum_prod_type,sum_comm] + simp only [hsw] + _ ≤ _ := hh + · intro i + rw [sum_marginal] + calc + _ ≤ ∑ x,p.mass x*(2*∑ z,s.mass z* + indicator (z.1.rep (f x i).2.rep=0 ∧ (f x i).1.rep z.2.rep≠0)) := by + apply sum_le_sum + intro x _ + apply mul_le_mul_of_nonneg_left _ (p.nonneg x) + exact hmean (fun z=>indicator (z.1.rep (f x i).2.rep=0 ∧ (f x i).1.rep z.2.rep≠0)) + (fun z=>indicator_nonneg _) + _ = 2*(∑ x,p.mass x*∑ z,s.mass z* + indicator (z.1.rep (f x i).2.rep=0 ∧ (f x i).1.rep z.2.rep≠0)) := by simp only [mul_sum]; ring_nf + _ ≤ 2*I := mul_le_mul_of_nonneg_left (hconflict i) (by norm_num) +end +end SharpLogRamsey.ActualHighRank + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/HighRankReplacement.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/HighRankReplacement.lean new file mode 100644 index 0000000000000000000000000000000000000000..2f5450dc2a338ece4f7e6036624875aee7c10b55 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/HighRankReplacement.lean @@ -0,0 +1,138 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Entropy.HighRankEntropy + +namespace OAI + +section +namespace SharpLogRamsey.ActualHighRank +open Finset Real Filter Selection HighRankBudgets +open scoped Classical BigOperators Topology +noncomputable section + +structure Replacement {F Ξ Γ : Type} [Fintype F] [Fintype Ξ] [Fintype Γ] + (p : Law Ξ) {ℓ : ℕ} (f : Ξ→Fin ℓ→F) (DD : Γ→Finset F) (B C : ℝ) where + Ω : Type + inst : Fintype Ω + μ : @Law Ω inst + source : Ω→Ξ + msg : Ω→Γ + chosen : Ω→(Fin (ℓ/2)↪o Fin ℓ) + hit : ∀ ω i,f (source ω) (chosen ω i)∈DD (msg ω) + size : ∀ ω,((DD (msg ω)).card:ℝ)≤B + dominated : letI := inst; ∀ a,(μ.map source).mass a≤2*p.mass a + cost : letI := inst; entropy (μ.map msg)≤C +attribute [instance] Replacement.inst + +section Generic +variable {F Ξ : Type} [Fintype F] [Fintype Ξ] + +theorem replacement_of_success {h ℓ : ℕ} (p : Law Ξ) (E : Finset F) (row : Law E) + (f : Ξ→Fin ℓ→F) (DD : ((Fin h→F)×(Fin h→F))→Finset F) (B : ℝ) : + let rows:=(Law.pi (fun _ : Fin h=>row)).prod (Law.pi (fun _ : Fin h=>row)) + let μ:=p.prod rows + let code:=fun z : Ξ×((Fin h→E)×(Fin h→E))=> + (fun i=>(z.2.1 i).val,fun i=>(z.2.2 i).val) + let G:=univ.filter (fun z=>((DD (code z)).card:ℝ)≤B ∧ + ∃ e : Fin (ℓ/2)↪o Fin ℓ,∀ i,f z.1 (e i)∈DD (code z)) + (1:ℝ)/2≤μ.event G → + Nonempty (Replacement p f DD B (2*(h:ℝ)*log (Fintype.card F))) := by + intro rows μ code G hg + obtain ⟨hG,ch,hch,hcard,_,hdom,hcost⟩:=context_replacement p E row f DD B + (fun _ _=>True) (by simp) id hg + refine ⟨⟨G,inferInstance,μ.onEvent G hG,(fun z=>z.val.1),(fun z=>code z.val),ch,hch,hcard,?_,hcost⟩⟩ + intro a + have hh:=hdom a + rw [Law.map_id] at hh + exact hh + +theorem replacement_of_weight_success {h ℓ : ℕ} (p : Law Ξ) (E : Finset F) (row : Law E) + (f : Ξ→Fin ℓ→F) (DD : ((Fin h→F)×(Fin h→F))→Finset F) (B : ℝ) + (hg : (1:ℝ)/2≤∑ v∈univ.filter (fun v : Ξ×((Fin h→E)×(Fin h→E))=> + ((DD (fun i=>(v.2.1 i).val,fun i=>(v.2.2 i).val)).card:ℝ)≤B ∧ + ∃ e : Fin (ℓ/2)↪o Fin ℓ,∀ i,f v.1 (e i)∈DD (fun i=>(v.2.1 i).val,fun i=>(v.2.2 i).val)), + p.mass v.1*(ProductLaw.weight row.mass v.2.1*ProductLaw.weight row.mass v.2.2)) : + Nonempty (Replacement p f DD B (2*(h:ℝ)*log (Fintype.card F))) := by + apply replacement_of_success (h:=h) (ℓ:=ℓ) p E row f DD B + simpa only [Law.event,Law.prod,Law.pi,ProductLaw.weight] using hg + +variable {Γ : Type} [Fintype Γ] {p : Law Ξ} {ℓ : ℕ} {f : Ξ→Fin ℓ→F} + {DD : Γ→Finset F} {B C C' : ℝ} + +def Replacement.cost_mono (e : Replacement p f DD B C) (h : C≤C') : + Replacement p f DD B C' := { e with cost := e.cost.trans h } +end Generic + +variable {K Ξ : Type} [Field K] [Fintype K] [Fintype Ξ] {d : ℕ} +local instance flat_ActualHighRankReplacement_1 : Finite (Module.Dual K (Fin (d+1)→K)) := + Finite.of_injective ((↑) : Module.Dual K (Fin (d+1)→K)→((Fin (d+1)→K)→K)) DFunLike.coe_injective +local instance flat_ActualHighRankReplacement_2 : Fintype (Projectivization K (Fin (d+1)→K)) := Fintype.ofFinite _ +local instance flat_ActualHighRankReplacement_3 : Fintype (Projectivization K (Module.Dual K (Fin (d+1)→K))) := Fintype.ofFinite _ +local notation "A" => Projectivization K (Module.Dual K (Fin (d+1)→K)) +local notation "B" => Projectivization K (Fin (d+1)→K) +local notation "q" => (Nat.card K:ℝ) + +structure Caps (σ : ℝ) (r r' : ℕ) (S : Finset (A×B)) : Prop where + first : ((S.image Prod.fst).card:ℝ)≤1024*q^r' + second : ((S.image Prod.snd).card:ℝ)≤1024*q^r + joint : (S.card:ℝ)≤64*q^d + firstFiber : ∀ a,((univ.filter (fun b=>(a,b)∈S)).card:ℝ)≤2*exp (((d:ℝ)-r')*σ) + secondFiber : ∀ b,((univ.filter (fun a=>(a,b)∈S)).card:ℝ)≤2*exp (((d:ℝ)-r)*σ) + +theorem eventually_replacement {η : ℝ} (hη : 0<η) (d : ℕ) (hd : 2≤d) : + ∀ᶠ σ : ℝ in atTop, ∀ (K Ξ : Type) [Field K] [Fintype K] [Fintype Ξ], + log (Nat.card K:ℝ)=σ → + ∀ (ℓ : ℕ), 0<ℓ → + ∀ (s : Law (Projectivization K (Module.Dual K (Fin (d+1)→K))×Projectivization K (Fin (d+1)→K))) + (S : Finset (Projectivization K (Module.Dual K (Fin (d+1)→K))×Projectivization K (Fin (d+1)→K))) + (p : Law Ξ) (f : Ξ→Fin ℓ→Projectivization K (Module.Dual K (Fin (d+1)→K))×Projectivization K (Fin (d+1)→K)) + (U : Fin ℓ→Finset (Projectivization K (Module.Dual K (Fin (d+1)→K))×Projectivization K (Fin (d+1)→K))) + (D : ℝ), σ^beta η≤D → D≤σ^(1-η/2) → + ∀ r r' : ℕ, 2≤r → r≤d → d+2≤r+r' → + (∀ z,z∉S→s.mass z=0) → Caps σ r r' S → + ((d:ℝ)*σ-entropy s≤D*σ^beta η) → + (∀ x,p.mass x≠0→∀ i,f x i∈U i) → + (∀ x,p.mass x≠0→∀ i,(f x i).1.rep (f x i).2.rep=0) → + (∀ i,Caps σ r r' (U i)) → + (∀ i,(d:ℝ)*σ-entropy (p.map (fun x=>f x i))≤D*σ^beta η) → + (∀ i,(∑ x,p.mass x*∑ z,s.mass z*FiniteEventBounds.indicator + (z.1.rep (f x i).2.rep=0 ∧ (f x i).1.rep z.2.rep≠0))≤2*σ^(-2000*beta η)/(Nat.card K:ℝ)) → + Nonempty (Replacement p f (fun z=>rawDomain (h:=rawRows σ η) z r (rawThreshold σ η)) + (highPrefactor d*(Nat.card K:ℝ)^d*exp (((d:ℝ)+1)*scaleK σ η D)) + (4*(rawRows σ η:ℝ)*(log 2+(d:ℝ)*σ))) := by + filter_upwards [eventually_success hη d hd] with σ he + intro K Ξ _ _ _ hlog ℓ hℓ s S p f U D hDl hDu r r' hr hrd hrank hs hS hsdef hp hinc hU hdef hcon + obtain ⟨hE,hgood⟩:=he K Ξ hlog ℓ hℓ s S p f U D hDl hDu r r' hr hrd hrank + hs hS.first hS.second hS.joint hS.firstFiber hS.secondFiber hsdef hp hinc + (fun i=>(hU i).first) (fun i=>(hU i).second) (fun i=>(hU i).joint) + (fun i=>(hU i).firstFiber) (fun i=>(hU i).secondFiber) hdef hcon + let E:=univ.filter (fun z : Projectivization K (Module.Dual K (Fin (d+1)→K))×Projectivization K (Fin (d+1)→K)=> + highGoodFirst s (1024*(Nat.card K:ℝ)^r') ((d:ℝ)*σ) (scaleK σ η D) + (exp (scaleK σ η D-(r':ℝ)*σ)) z.1 ∧ + highGoodSecond s (1024*(Nat.card K:ℝ)^r) ((d:ℝ)*σ) (scaleK σ η D) + (exp (scaleK σ η D-(r:ℝ)*σ)) z.2) + have hE0 : 0rawDomain (K:=K) (d:=d) (h:=h) z r (rawThreshold σ η) + let B₀:=highPrefactor d*(Nat.card K:ℝ)^d*exp (((d:ℝ)+1)*scaleK σ η D) + have extract:=replacement_of_weight_success (h:=h) (ℓ:=ℓ) p E row f DD B₀ + have hex : Nonempty (Replacement p f DD B₀ (2*(h:ℝ)*log (Fintype.card + (Projectivization K (Module.Dual K (Fin (d+1)→K))×Projectivization K (Fin (d+1)→K))))) := by + apply extract + dsimp only at hgood + simpa only [DD, B₀, row, E, h] using hgood + obtain ⟨e⟩:=hex + refine ⟨e.cost_mono ?_⟩ + have hdim : Module.finrank K (Fin (d+1)→K)=d+1 := by simp + have hc:=mul_le_mul_of_nonneg_left (flag_card_log hdim) (by positivity : 0≤2*(h:ℝ)) + rw [hlog] at hc + calc + _ ≤ 2*(h:ℝ)*(2*(log 2+(d:ℝ)*σ)) := hc + _ = _ := by dsimp only [h]; ring + +end +end SharpLogRamsey.ActualHighRank + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/OriginalTargetLoss.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/OriginalTargetLoss.lean new file mode 100644 index 0000000000000000000000000000000000000000..638cea5326137f41825928169d801f0ff5cc96a7 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/OriginalTargetLoss.lean @@ -0,0 +1,137 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Trees.OriginalTreeLoss +import OAI.Combinatorics.SharpRamsey.Execution.ExecutedGoodTarget + +namespace OAI + +section +namespace SharpLogRamsey.ActualPivot +open Finset Real Incidence PublicTables FreshExecution TreeDecoder SupportMixtures BinaryTree +open scoped Classical BigOperators +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] + {I Ω : Type*} [Fintype I] [DecidableEq I] [Fintype Ω] + +local instance targetBanksFintype (b : ℝ) : Fintype (Banks (K:=K) (V:=V) b) := inferInstance + +def firstTargetDensity (good : Prop) (y : Projectivization K (Module.Dual K V)) + (T : Finset (Projectivization K V)) : ℝ := + if good then ∑ x,kernel T x*(if y.rep x.rep=0 then 1 else 0) else 0 + +def secondTargetDensity (good : Prop) (x : Projectivization K V) + (S : Finset (Projectivization K (Module.Dual K V))) : ℝ := + if good then ∑ y,kernel S y*(if y.rep x.rep=0 then 1 else 0) else 0 + +omit [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma firstTargetDensity_nonneg (good : Prop) (y : Projectivization K (Module.Dual K V)) + (T : Finset (Projectivization K V)) : 0≤firstTargetDensity good y T := by + unfold firstTargetDensity + split_ifs + · exact sum_nonneg (fun x _=>mul_nonneg (kernel_nonneg _ _) (by split_ifs <;> norm_num)) + · exact le_rfl + +omit [Finite K] [FiniteDimensional K V] [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma secondTargetDensity_nonneg (good : Prop) (x : Projectivization K V) + (S : Finset (Projectivization K (Module.Dual K V))) : 0 ≤ secondTargetDensity good x S := by + unfold secondTargetDensity + split_ifs + · exact sum_nonneg (fun y _=>mul_nonneg (kernel_nonneg _ _) (by split_ifs <;> norm_num)) + · exact le_rfl + +omit [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma firstTargetDensity_eq (good : Prop) (y : Projectivization K (Module.Dual K V)) + (T : Finset (Projectivization K V)) : + ((goodSingleton good y).card:ℝ)*density (goodSingleton good y) T=firstTargetDensity good y T := by + have he : density (goodSingleton good y) T = + ∑ y',kernel (goodSingleton good y) y' * (∑ x,kernel T x*(if y'.rep x.rep=0 then 1 else 0)) := by + simp only [density,pairing,mul_sum,mul_assoc] + rw [he,card_mul_kernel_sum] + by_cases hg : good <;> simp [goodSingleton,hg,firstTargetDensity] + +omit [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma secondTargetDensity_eq (good : Prop) (x : Projectivization K V) + (S : Finset (Projectivization K (Module.Dual K V))) : + ((goodSingleton good x).card:ℝ)*density S (goodSingleton good x)=secondTargetDensity good x S := by + have he : density S (goodSingleton good x) = + ∑ x',kernel (goodSingleton good x) x' * (∑ y,kernel S y*(if y.rep x'.rep=0 then 1 else 0)) := by + unfold density + rw [Selection.pairing_reverse] + simp only [pairing,mul_sum,mul_assoc] + rw [he,card_mul_kernel_sum] + by_cases hg : good <;> simp [goodSingleton,hg,secondTargetDensity] + +variable {n : ℕ} {b τ P H : ℝ} (hdim : Module.finrank K V=n+3) + (book : Book (K:=K) (V:=V) (Nat.card K) b τ P H (n+3)) (hτ : 0≤τ) (hτsmall : τ≤1/40000) + +theorem Book.target_loss (μ : Law Ω) (s : Ω→I→Original (K:=K) (V:=V) n b) + (target : I) (t : BinaryTree I) (U : ChronoDomains (K:=K) (V:=V)) + (ht : Separated t) (hmem : target∈labels t) + (hU : ∀ ω,∀ i∈labels t,(s ω i).B⊆U.1 ∧ (s ω i).A⊆U.2) + (goodA goodB : Ω→Prop) (a : Ω→Projectivization K (Module.Dual K V)) + (c : Ω→Projectivization K V) (haU : ∀ ω,a ω∈U.1) (hcU : ∀ ω,c ω∈U.2) + (hτpos : 0<τ) (E EA EB δA δB : ℝ) (hE : 0≤E) (hEA : 0≤EA) (hEB : 0≤EB) + (hfirst : ∀ i∈plannedPath target t,∀ j∈leftPath i t, + (∑ ω,μ.mass ω*density (s ω i).B (s ω j).A)≤E) + (hsecond : ∀ i∈plannedPath target t,∀ j∈rightPath i t, + (∑ ω,μ.mass ω*density (s ω j).B (s ω i).A)≤E) + (hself : ∀ i∈plannedPath target t,(∑ ω,μ.mass ω*density (s ω i).B (s ω i).A)≤E) + (hmeanA : ∀ i∈insert target (leftPath target t), + (∑ ω,μ.mass ω*firstTargetDensity (goodA ω) (a ω) (s ω i).A)≤EA) + (hmeanB : ∀ i∈insert target (rightPath target t), + (∑ ω,μ.mass ω*secondTargetDensity (goodB ω) (c ω) (s ω i).B)≤EB) + (hbadA : (∑ ω,μ.mass ω*(if goodA ω then (0:ℝ) else 1))≤δA) + (hbadB : (∑ ω,μ.mass ω*(if goodB ω then (0:ℝ) else 1))≤δB) : + (∑ ω,μ.mass ω*(∑ z,(piLaw (fun _ : I=>banksLaw (K:=K) (V:=V) b)).mass z* + targetFailure (fun i=>book.chronoChoose hdim hτ hτsmall (s ω i)) + (fun _=>chronoRead b) (a ω) (c ω) target t U z))≤ + 20*(12*(Nat.card K:ℝ)*E)*t.height^2+ + ((Nat.card K:ℝ)*E/τ+2*exp (-(Nat.card K:ℝ)))*t.height+ + δA+δB+((t.height:ℝ)+1)*(12*(Nat.card K:ℝ)*EA+12*(Nat.card K:ℝ)*EB) := by + apply original_good_target_loss μ (fun _=>banksLaw (K:=K) (V:=V) b) + (fun _=>(banks_nonempty (K:=K) (V:=V) b).some) + (fun ω i=>book.chronoChoose hdim hτ hτsmall (s ω i)) (fun _ _=>chronoRead b) + (fun _ _=>chronoMask b) (fun _ _=>chronoRead_first b) (fun _ _=>chronoRead_second b) + goodA goodB a c target t U ht hmem haU hcU + (fun ω i=>12*(Nat.card K:ℝ)*firstTargetDensity (goodA ω) (a ω) (s ω i).A) + (fun ω i=>12*(Nat.card K:ℝ)*secondTargetDensity (goodB ω) (c ω) (s ω i).B) + (12*(Nat.card K:ℝ)*EA) (12*(Nat.card K:ℝ)*EB) _ δA δB (by positivity) (by positivity) + · intros; exact mul_nonneg (by positivity) (firstTargetDensity_nonneg _ _ _) + · intros; exact mul_nonneg (by positivity) (secondTargetDensity_nonneg _ _ _) + · intro ω i hi U + have hh := book.first_loss_bound hdim hτ hτsmall (s ω) i (goodSingleton (goodA ω) (a ω)) U + change _≤12*(Nat.card K:ℝ)*_ * density _ _ at hh + rw [mul_assoc,firstTargetDensity_eq] at hh + exact hh + · intro ω i hi U + have hh := book.second_loss_bound hdim hτ hτsmall (s ω) i (goodSingleton (goodB ω) (c ω)) U + change _≤12*(Nat.card K:ℝ)*_ * density _ _ at hh + rw [mul_assoc,secondTargetDensity_eq] at hh + exact hh + · intro i hi + calc + _ = 12*(Nat.card K:ℝ)*(∑ ω,μ.mass ω*firstTargetDensity (goodA ω) (a ω) (s ω i).A) := by + rw [mul_sum]; apply sum_congr rfl; intros; ring + _ ≤ _ := mul_le_mul_of_nonneg_left (hmeanA i hi) (by positivity) + · intro i hi + calc + _ = 12*(Nat.card K:ℝ)*(∑ ω,μ.mass ω*secondTargetDensity (goodB ω) (c ω) (s ω i).B) := by + rw [mul_sum]; apply sum_congr rfl; intros; ring + _ ≤ _ := mul_le_mul_of_nonneg_left (hmeanB i hi) (by positivity) + · exact hbadA + · exact hbadB + · exact book.deletion_loss hdim hτ hτsmall μ s target t U ht hmem hU hτpos E hE hfirst hsecond hself + +end +end SharpLogRamsey.ActualPivot + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/OutputComposition.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/OutputComposition.lean new file mode 100644 index 0000000000000000000000000000000000000000..cdbb801c09831552fccfe81f5960971cb3d49d04 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/OutputComposition.lean @@ -0,0 +1,70 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Selection.UnifiedContext + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset Real +open scoped Classical BigOperators +noncomputable section +variable {Ω F A : Type} [Fintype Ω] [Fintype F] [Fintype A] + {N ℓ m : ℕ} {p : Law Ω} {G : Ω→Fin ℓ→F} {B C L : ℝ} + +def ContextOutput.transport (e : ContextOutput p G m B C L) + (φ : F≃A) (G₀ : Ω→Fin N→A) (j : Ω→Fin ℓ↪o Fin N) + (h : ∀ x i,φ (G x i)=G₀ x (j x i)) : + ContextOutput p G₀ m B C L where + X:=e.X + Γ:=e.Γ + finiteX:=e.finiteX + finiteΓ:=e.finiteΓ + μ:=e.μ + source:=e.source + msg:=e.msg + chosen:=fun x=>(e.chosen x).trans (j (e.source x)) + domains:=fun c i=>(e.domains c i).map φ.toEmbedding + supported:=e.supported + hit:=by + intro x i + change G₀ (e.source x) (j (e.source x) (e.chosen x i)) ∈ _ + rw [←h] + exact mem_map.mpr ⟨_,e.hit x i,rfl⟩ + size:=by intro c i;simpa only [card_map] using e.size c i + dominated:=e.dominated + cost:=e.cost + +def ContextOutput.compose (e : ContextOutput p G m B C L) + {n : ℕ} {B' C' L' : ℝ} + (f : ContextOutput e.μ (fun x i=>G (e.source x) (e.chosen x i)) n B' C' L') + (hL' : 0≤L') : ContextOutput p G n B' C' (L'*L) where + X:=f.X + Γ:=f.Γ + finiteX:=f.finiteX + finiteΓ:=f.finiteΓ + μ:=f.μ + source:=e.source∘f.source + msg:=f.msg + chosen:=fun x=>(f.chosen x).trans (e.chosen (f.source x)) + domains:=f.domains + supported:=fun x=>e.supported (f.source x) + hit:=f.hit + size:=f.size + dominated:=by + intro a + rw [←Law.map_map] + calc + _ ≤ ∑ y ∈ univ.filter (fun y=>e.source y=a),L'*e.μ.mass y := by + change (∑ y ∈ univ.filter (fun y=>e.source y=a),(f.μ.map f.source).mass y)≤_ + exact sum_le_sum (fun y _=>f.dominated y) + _ = L'*(e.μ.map e.source).mass a := by + simp only [Law.map,mul_sum] + _ ≤ L'*(L*p.mass a) := mul_le_mul_of_nonneg_left (e.dominated a) hL' + _ = _ := by ring + cost:=f.cost +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/OutputCost.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/OutputCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..f2e553a5737975dacc60766791f693927ee2f75c --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/OutputCost.lean @@ -0,0 +1,75 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.RootCost + +namespace OAI + +section +namespace SharpLogRamsey.ActualPivot +open Finset Real ExecutedPotential TreeDecoder +open scoped Classical +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V))) ] + +omit [FiniteDimensional K V] in +lemma reciprocal_cost_envelope {d w h m : ℕ} {b P H σ C : ℝ} + (hdim : Module.finrank K V=d+3) (hlog : log (Nat.card K:ℝ)=σ) + (hσ : 1≤σ) (hw : 1≤w) (hh : 1≤h) + (hH : 0≤H) (hP : 4≤P) (hbP : b+log 1000000≤P) + (hwlog : log ((w:ℝ)+1)≤C*σ) (hmlog : log ((m:ℝ)+1)≤C*σ) : + reciprocalOutputCost (K:=K) (V:=V) (I:=Fin w) (d:=d) (b:=b) (P:=P) (H:=H) w h m ≤ + (2*(H+22)*(2*((d:ℝ)+4)+1003))*(Nat.card K:ℝ)*P*(h:ℝ)*(σ+(w:ℝ)*P)+ + (3+2*C+2*((d:ℝ)+4))*(w:ℝ)*σ := by + have hσ0 : 0≤σ:=by linarith + have hw1 : (1:ℝ)≤w:=by exact_mod_cast hw + have hh1 : (1:ℝ)≤h:=by exact_mod_cast hh + have hP0 : 0≤P:=by linarith + have hhead:=headerCost_linear hdim (by rwa [hlog]) + have hpot:=root_potential_linear hdim (by rwa [hlog]) + rw [hlog] at hhead hpot + have hlog2 : log (2:ℝ)≤1 := by + have hh:=log_le_sub_one_of_pos (by norm_num : (0:ℝ)<2) + linarith + have hshape : ((2*w+1:ℕ):ℝ)*log 2≤3*(w:ℝ)*σ := by + push_cast + calc + _ ≤ (2*(w:ℝ)+1)*1 := mul_le_mul_of_nonneg_left hlog2 (by positivity) + _ ≤ 3*(w:ℝ) := by linarith + _ ≤ _ := le_mul_of_one_le_right (by positivity) hσ + have hb : b≤P := by linarith [log_nonneg (by norm_num : (1:ℝ)≤1000000)] + have hab : b+log 4+2*log 2000≤1002*P := by + have h4:=log_le_sub_one_of_pos (by norm_num : (0:ℝ)<4) + have h2:=log_le_sub_one_of_pos (by norm_num : (0:ℝ)<2000) + linarith + have hinner : (h:ℝ)*(potential ((Nat.card K:ℝ)^(d+3)) + ((univ,univ) : ChronoDomains (K:=K) (V:=V))+(w:ℝ)*(b+log 4+2*log 2000))+ + (w:ℝ)*P ≤ (2*((d:ℝ)+4)+1003)*(h:ℝ)*(σ+(w:ℝ)*P) := by + calc + _ ≤ (h:ℝ)*(2*((d:ℝ)+4)*σ+(w:ℝ)*(1002*P))+(w:ℝ)*P := by + gcongr + _ ≤ (h:ℝ)*(2*((d:ℝ)+4)*σ+(w:ℝ)*(1002*P))+(h:ℝ)*((w:ℝ)*P) := by + exact add_le_add le_rfl (le_mul_of_one_le_left (mul_nonneg (Nat.cast_nonneg w) hP0) hh1) + _ ≤ _ := by + have h1 : 0≤(h:ℝ)*σ:=by positivity + have h2 : 0≤(2*((d:ℝ)+4))*(h:ℝ)*((w:ℝ)*P):=by positivity + nlinarith only [h1,h2] + unfold reciprocalOutputCost + simp only [Fintype.card_fin,Nat.cast_add,Nat.cast_one] + have haux : (w:ℝ)*(log ((w:ℝ)+1)+headerCost (K:=K) (V:=V)+log ((m:ℝ)+1))≤ + (w:ℝ)*((2*C+2*((d:ℝ)+4))*σ) := by + apply mul_le_mul_of_nonneg_left _ (Nat.cast_nonneg w) + linarith + calc + _ ≤ 3*(w:ℝ)*σ+(w:ℝ)*((2*C+2*((d:ℝ)+4))*σ)+ + (2*(H+22)*(Nat.card K:ℝ)*P)*((2*((d:ℝ)+4)+1003)*(h:ℝ)*(σ+(w:ℝ)*P)) := by + exact add_le_add (add_le_add (by simpa only [Nat.cast_add,Nat.cast_one] using hshape) haux) + (mul_le_mul_of_nonneg_left hinner (by positivity)) + _ = _ := by ring +end +end SharpLogRamsey.ActualPivot + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/OutputRebase.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/OutputRebase.lean new file mode 100644 index 0000000000000000000000000000000000000000..3edd6c8891eb3c0eeb2e30e1922eb69449361231 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/OutputRebase.lean @@ -0,0 +1,79 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.OutputComposition + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset Real +open scoped Classical BigOperators +noncomputable section +variable {Ω F : Type} [Fintype Ω] [Fintype F] + {ℓ m : ℕ} {p : Law Ω} {G : Ω→Fin ℓ→F} {B C L : ℝ} + +def ContextOutput.mono (e : ContextOutput p G m B C L) + {B' C' L' : ℝ} (hB : B ≤ B') (hC : C ≤ C') (hL : L ≤ L') : + ContextOutput p G m B' C' L' where + X:=e.X + Γ:=e.Γ + finiteX:=e.finiteX + finiteΓ:=e.finiteΓ + μ:=e.μ + source:=e.source + msg:=e.msg + chosen:=e.chosen + domains:=e.domains + supported:=e.supported + hit:=e.hit + size:=fun c i=>(e.size c i).trans hB + dominated:=fun a=>(e.dominated a).trans (mul_le_mul_of_nonneg_right hL (p.nonneg a)) + cost:=e.cost.trans hC + +def ContextOutput.rebase (e : ContextOutput p G m B C L) + (p₀ : Law Ω) {L₀ : ℝ} (hL : 0 ≤ L) + (hp : ∀ x,p.mass x ≤ L₀*p₀.mass x) : ContextOutput p₀ G m B C (L*L₀) where + X:=e.X + Γ:=e.Γ + finiteX:=e.finiteX + finiteΓ:=e.finiteΓ + μ:=e.μ + source:=e.source + msg:=e.msg + chosen:=e.chosen + domains:=e.domains + supported:=by + intro x hz + have h:=hp (e.source x) + rw [hz,mul_zero] at h + exact e.supported x (le_antisymm h (p.nonneg _)) + hit:=e.hit + size:=e.size + dominated:=by + intro x + exact (e.dominated x).trans (by simpa only [mul_assoc] using mul_le_mul_of_nonneg_left (hp x) hL) + cost:=e.cost + +def ContextOutput.restrict (e : ContextOutput p G m B C L) {n : ℕ} (hn : n ≤ m) : + ContextOutput p G n B C L where + X:=e.X + Γ:=e.Γ + finiteX:=e.finiteX + finiteΓ:=e.finiteΓ + μ:=e.μ + source:=e.source + msg:=e.msg + chosen:=fun x=>(OrderEmbedding.ofStrictMono (Fin.castLE hn) (by + intro i j hij + exact hij)).trans (e.chosen x) + domains:=fun c i=>e.domains c (Fin.castLE hn i) + supported:=e.supported + hit:=fun x i=>e.hit x (Fin.castLE hn i) + size:=fun c i=>e.size c (Fin.castLE hn i) + dominated:=e.dominated + cost:=e.cost +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/PreparedOutput.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/PreparedOutput.lean new file mode 100644 index 0000000000000000000000000000000000000000..acfa95905f6bca27096e436e67a30534672d5fe8 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/PreparedOutput.lean @@ -0,0 +1,80 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Windows.PopulationSublist +import OAI.Combinatorics.SharpRamsey.Exposure.PreparedMixture +import OAI.Combinatorics.SharpRamsey.Reciprocal.ReciprocalOutput + +namespace OAI + +section +namespace SharpLogRamsey.Selection.Windows +open Finset Real ExposureModel ChronologicalTree FreshExecution TreeDecoder BinaryTree ActualPivot +open scoped Classical BigOperators +noncomputable section +variable {K V Ω Θ : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] + [Fintype Ω] [Fintype Θ] {d : ℕ} {b τ P H : ℝ} +local instance prepOutBanks : Fintype (Banks (K:=K) (V:=V) b) := inferInstance +local instance prepOutFinDec (j : ℕ) : DecidableEq (Fin j) := Classical.decEq _ +local instance prepOutBlockDec (w : ℕ) : DecidableEq (Block w) := Classical.decEq _ +variable (w n k : ℕ) (p : Law Ω) (θ : Ω→Θ) + (G : Ω→Slot w (n+k)→ActualPivot.Flag (K:=K) (V:=V)) (t : Fin k) + (hp : ∀ z,0<(model w n k p θ G t).remaining z) + (e : ∀ z : PositiveHistory w n k p θ G t hp, + Realization (K:=K) (V:=V) (I:=Fin w) (d:=d) (b:=b) + (ExposureModel.tupleLaw (model w n k p θ G t) (Sigma.fst (Subtype.val z)))) + (bad : ∀ z : (model w n k p θ G t).FreshHistory,Finset ((model w n k p θ G t).Index z.1)) + (live : (model w n k p θ G t).FreshHistory→Finset (Fin w)) (fallback : Fin w) + +abbrev preparedTargets (y : (mixedPrepared w n k p θ G t hp e).Ω) : Fin w→List (ActualPivot.Flag (K:=K) (V:=V)) := + fun i=>List.ofFn (fun j=>(e y.1).source y.2 (goodTarget w n k p θ G t y.1.val (bad y.1.val) i j)) + +abbrev preparedTree (y : (mixedPrepared w n k p θ G t hp e).Ω) := liveTree (live y.1.val) fallback + +theorem prepared_context_of_mean (hdim : Module.finrank K V=d+3) + (book : Book (K:=K) (V:=V) (Nat.card K) b τ P H (d+3)) + (hb : 0≤b) (hH : 0≤H) (hP : 4≤P) (haP : b+log 1000000≤P) + (hτ : 0≤τ) (hτsmall : τ≤1/40000) (hn : 0banksLaw (K:=K) (V:=V) b)).mass tab* + ∑ ω,(attachedPrepared w n k p θ G t hp e).μ.mass ω*((w*(2*(n+k)):ℝ)- + (fullOutput (fun y x=>SharpLogRamsey.Incidence.Incident x y) + (fun i=>book.chronoChoose hdim hτ hτsmall ((e ω.1.1).supports ω.1.2 i)) + (fun _=>chronoRead b) (preparedTargets w n k p θ G t hp e bad ω.1) tab + (preparedTree w n k p θ G t hp e live fallback ω.1) (univ,univ)).length))≤ + (w*(2*(n+k)):ℝ)/4) : + Nonempty (ContextOutput p (fun ω=>flattenTuple (G ω)) (w*(n+k)) + (8000000*(Nat.card K:ℝ)^(d+2)*exp b) + (reciprocalOutputCost (K:=K) (V:=V) (I:=Fin w) (d:=d) (b:=b) (P:=P) (H:=H) + w (Nat.log 2 w+1) (2*(n+k))) 2) := by + have hw : 0ω.2)=p := + (attachedPrepared w n k p θ G t hp e).marginal + have hres:=book.context_output hdim hb hH hP haP hτ hτsmall p (fun ω=>flattenTuple (G ω)) + (attachedPrepared w n k p θ G t hp e).μ (fun ω=>ω.2) hmarg + (fun ω=>(e ω.1.1).supports ω.1.2) + (fun ω=>preparedTargets w n k p θ G t hp e bad ω.1) + (fun ω=>preparedTree w n k p θ G t hp e live fallback ω.1) + (w*(2*(n+k))) w (Nat.log 2 w+1) (2*(n+k)) hN + (fun ω=>by rw [goodPopulation_length];exact goodPopulation_size w n k p θ G t _ _ _) + (fun ω=>by rw [liveTree_nodes];simpa using card_le_univ (live ω.1.1.val)) + (fun ω=>by + apply (liveTree_height _ _).trans + exact Nat.add_le_add_right (Nat.log_mono_right (by simpa using card_le_univ (live ω.1.1.val))) 1) + (fun ω i=>by rw [List.length_ofFn];simpa using card_le_univ (goodMiddle w n k p θ G t ω.1.1.val (bad ω.1.1.val) i)) + (fun ω hω=>goodPopulation_sublist w n k p θ G t ω.1.1.val (bad ω.1.1.val) + (live ω.1.1.val) fallback ((e ω.1.1).source ω.1.2) (G ω.2) + (fun i=>((attachedPrepared_tuple w n k p θ G t hp e ω hω).2.2 i).symm)) + (by simpa only [Nat.cast_mul,Nat.cast_add,Nat.cast_ofNat] using hmean) + have heq : w*(2*(n+k))/2=w*(n+k) := by + have : w*(2*(n+k))=2*(w*(n+k)) := by ring + omega + simpa only [heq] using hres +end +end SharpLogRamsey.Selection.Windows + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/VariableExtraction.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/VariableExtraction.lean new file mode 100644 index 0000000000000000000000000000000000000000..6f3a6b50d471bc8b092a93b21d383c89df9acfe8 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/VariableExtraction.lean @@ -0,0 +1,59 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.VariableRetention + +namespace OAI + +section +namespace SharpLogRamsey.FreshExecution +open Finset BinaryTree TreeDecoder PublicTables +open scoped Classical BigOperators +noncomputable section +variable {I A B C Ω : Type*} [DecidableEq I] {α : I→Type*} +variable [Fintype Ω] [Fintype I] [∀ i,Fintype (α i)] + +theorem fixed_extraction_le (μ : Law Ω) (p : ∀ i,Law (α i)) (R : A→B→Prop) + (choose : Ω→∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (targets : Ω→I→List (A×B)) + (t : Ω→BinaryTree I) (U : Domains A B) (N : ℕ) (hN : 0(N:ℝ)/2≤(fullOutput R (choose ω) read (targets ω) z (t ω) U).length + ∃ hE : 0x∈D) out + ((decode R (fixedRead read z) (fullMessage R (choose ω) read (targets ω) z (t ω) U) U).take (N/2)) := by + obtain ⟨z,hz⟩:=fixed_output_half_le μ p R choose (fun _=>read) targets t U N hN hsize hmean + let E:=fun ω=>(N:ℝ)/2≤(fullOutput R (choose ω) read (targets ω) z (t ω) U).length + have he : (1/2:ℝ)≤acceptProb μ E := by + convert hz using 1 + simp only [acceptProb,accepted] + apply sum_congr rfl + intro ω _ + split_ifs <;> simp only [mul_zero,mul_one] + have hp : 0List.ofFn (target ω i)) (z ω) t U).length))≤ + (∑ i∈labels t,(n i:ℝ))*δ := by + have hsize (ω : Ω) : + ((population (fun i=>List.ofFn (target ω i)) t).length:ℝ)=∑ i∈labels t,(n i:ℝ) := by + rw [population_length_sum _ t ht] + simp only [List.length_ofFn] + have he (ω : Ω) : (∑ i∈labels t,(n i:ℝ))- + (fullOutput R (choose ω) (read ω) (fun i=>List.ofFn (target ω i)) (z ω) t U).length= + ∑ i∈labels t,∑ j : Fin (n i),targetFailure (choose ω) (read ω) + (target ω i j).1 (target ω i j).2 i t U (z ω) := by + rw [←hsize ω,output_loss_eq_targets R (choose ω) (read ω) _ (z ω) t U ht] + · simp only [List.map_ofFn,List.sum_ofFn,Function.comp_apply] + · intro i hi x hx + obtain ⟨j,rfl⟩:=List.mem_ofFn.mp hx + exact hR ω i hi j + simp_rw [he,mul_sum] + rw [sum_comm] + calc + _ = ∑ i∈labels t,∑ j : Fin (n i),∑ ω,μ.mass ω* + targetFailure (choose ω) (read ω) (target ω i j).1 (target ω i j).2 i t U (z ω) := by + apply sum_congr rfl + intro i _ + exact sum_comm + _ ≤ ∑ i∈labels t,∑ _j : Fin (n i),δ := by + apply sum_le_sum + intro i hi + exact sum_le_sum (fun j _=>hpoint i hi j) + _ = _ := by simp only [sum_const,card_univ,Fintype.card_fin,nsmul_eq_mul,sum_mul] + +variable [Fintype I] [∀ i,Fintype (α i)] + +theorem original_variable_loss (μ : Law Ω) (p : ∀ i,Law (α i)) (R : A→B→Prop) + (choose : Ω→∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) + (n : I→ℕ) (target : Ω→∀ i,Fin (n i)→A×B) (t : BinaryTree I) (U : Domains A B) + (ht : Separated t) + (hR : ∀ ω,∀ i∈labels t,∀ j,R (target ω i j).1 (target ω i j).2) + (δ : ℝ) + (hpoint : ∀ i∈labels t,∀ j,(∑ ω,μ.mass ω*∑ z,(piLaw p).mass z* + targetFailure (choose ω) read (target ω i j).1 (target ω i j).2 i t U z)≤δ) : + (∑ z,(piLaw p).mass z*∑ ω,μ.mass ω*((∑ i∈labels t,(n i:ℝ))- + (fullOutput R (choose ω) read (fun i=>List.ofFn (target ω i)) z t U).length))≤ + (∑ i∈labels t,(n i:ℝ))*δ := by + have hh:=expected_variable_loss (sourcePublicLaw μ p) R (fun x=>choose x.1) + (fun _=>read) (fun x=>x.2) n (fun x=>target x.1) t U ht (fun x=>hR x.1) δ + (by + intro i hi j + have hp:=hpoint i hi j + simpa only [sourcePublicLaw,Fintype.sum_prod_type,mul_assoc,←mul_sum] using hp) + simp only [sourcePublicLaw,Fintype.sum_prod_type,mul_assoc,←mul_sum] at hh + convert hh using 1 + simp only [mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro ω _ + apply sum_congr rfl + intro z _ + ring + +end +end SharpLogRamsey.FreshExecution + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Execution/VariableRetention.lean b/lean/OAI/Combinatorics/SharpRamsey/Execution/VariableRetention.lean new file mode 100644 index 0000000000000000000000000000000000000000..411264adef12c71b4ecc84e11a8b9a90b99cc294 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Execution/VariableRetention.lean @@ -0,0 +1,81 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.ExecutedLawExtraction + +namespace OAI + +section +namespace SharpLogRamsey.FreshExecution +open Finset BinaryTree TreeDecoder PublicTables +open scoped Classical BigOperators +noncomputable section +variable {I A B C Ω : Type*} [DecidableEq I] {α : I→Type*} +variable [Fintype Ω] [Fintype I] [∀ i,Fintype (α i)] + +theorem fixed_output_half_le (μ : Law Ω) (p : ∀ i,Law (α i)) (R : A→B→Prop) + (choose : Ω→∀ i,α i→Domains A B→Option C) + (read : Ω→∀ i,α i→CapReader A B C) (targets : Ω→I→List (A×B)) + (t : Ω→BinaryTree I) (U : Domains A B) (N : ℕ) (hN : 0 (fullOutput R (choose ω) (read ω) (targets ω) z (t ω) U).length + have hbound (ω : Ω) (z : ∀ i,α i) : out ω z≤N := by + exact (fullOutput_sublist R (choose ω) (read ω) (targets ω) z (t ω) U).length_le.trans (hsize ω) + have hp (ω : Ω) (z : ∀ i,α i) : + (N:ℝ)/2-((N:ℝ)-out ω z)≤(N:ℝ)/2*(if (N:ℝ)/2≤out ω z then 1 else 0) := by + split_ifs with hh + · have hb : (out ω z:ℝ)≤N := by exact_mod_cast hbound ω z + linarith + · linarith + have hz (z : ∀ i,α i) : + (N:ℝ)/2-(∑ ω,μ.mass ω*((N:ℝ)-out ω z))≤ + (N:ℝ)/2*(∑ ω,μ.mass ω*(if (N:ℝ)/2≤out ω z then 1 else 0)) := by + have hh:=sum_le_sum (fun ω (_ : ω∈univ)=>mul_le_mul_of_nonneg_left (hp ω z) (μ.nonneg ω)) + simpa only [mul_sub,sum_sub_distrib,←sum_mul,μ.total,one_mul,mul_left_comm,mul_sum] using hh + have hall:=sum_le_sum (fun z (_ : z∈univ)=>mul_le_mul_of_nonneg_left (hz z) ((piLaw p).nonneg z)) + have hall' : (N:ℝ)/2-(∑ z,(piLaw p).mass z*∑ ω,μ.mass ω*((N:ℝ)-out ω z))≤ + (N:ℝ)/2*(∑ z,(piLaw p).mass z*∑ ω,μ.mass ω*(if (N:ℝ)/2≤out ω z then 1 else 0)) := by + simpa only [mul_sub,sum_sub_distrib,←sum_mul,(piLaw p).total,one_mul,mul_left_comm,mul_sum] using hall + have hn : (0:ℝ)(N:ℝ)/2≤out ω z) (1/2) hs + +theorem fixed_output_of_budgets (μ : Law Ω) (p : ∀ i,Law (α i)) (R : A→B→Prop) + (choose : Ω→∀ i,α i→Domains A B→Option C) + (read : Ω→∀ i,α i→CapReader A B C) (targets : Ω→I→List (A×B)) + (t : Ω→BinaryTree I) (U : Domains A B) (N : ℕ) (hN : 0 f a = b)) p.mass q.mass + (fun a ha => p.nonneg a) (fun a ha => q.nonneg a) (fun a ha => hab a) + _ = _ := sum_fiberwise univ f _ + +end SharpLogRamsey.Selection + +namespace SharpLogRamsey.Selection +variable {α β γ δ : Type*} [Fintype α] [Fintype β] [Fintype γ] [Fintype δ] + +@[ext] theorem Law.ext {p q : Law α} (h : ∀ a, p.mass a = q.mass a) : p = q := by + cases p with | mk p hp hpt => + cases q with | mk q hq hqt => + have hh : p = q := funext h + subst q + rfl + +@[simp] theorem Law.map_id (p : Law α) : p.map id = p := by + ext a + simp [Law.map, sum_filter] + +@[simp] theorem Law.map_map (p : Law α) (f : α → β) (g : β → γ) : + (p.map f).map g = p.map (g ∘ f) := by + ext c + change (∑ b with g b = c, (p.map f).mass b) = ∑ a with g (f a) = c, p.mass a + have h := p.sum_map f (fun b => if g b = c then 1 else 0) + simpa [mul_ite, sum_filter] using h + +@[simp] theorem Law.map_fst (p : Law (α × β)) : p.map Prod.fst = p.fst := by + ext a + simp only [Law.map, Law.fst, sum_filter, Fintype.sum_prod_type] + rw [sum_comm] + simp + +@[simp] theorem Law.map_snd (p : Law (α × β)) : p.map Prod.snd = p.snd := by + ext b + simp [Law.map, Law.snd, sum_filter, Fintype.sum_prod_type] + +theorem Law.prod_map (p : Law α) (q : Law β) (f : α → γ) (g : β → δ) : + (p.prod q).map (fun z => (f z.1,g z.2)) = (p.map f).prod (q.map g) := by + ext z + rcases z with ⟨c,d⟩ + simp only [Law.map, Law.prod, Prod.mk.injEq, Fintype.sum_prod_type, sum_filter] + rw [sum_mul_sum] + apply sum_congr rfl + intro a ha + apply sum_congr rfl + intro b hb + split_ifs <;> simp_all + +@[simp] theorem Law.fst_map_pair (p : Law (α × β)) (f : α → γ) (g : β → δ) : + (p.map (fun z => (f z.1,g z.2))).fst = p.fst.map f := by + rw [← Law.map_fst, Law.map_map, ← Law.map_fst, Law.map_map] + rfl + +@[simp] theorem Law.snd_map_pair (p : Law (α × β)) (f : α → γ) (g : β → δ) : + (p.map (fun z => (f z.1,g z.2))).snd = p.snd.map g := by + rw [← Law.map_snd, Law.map_map, ← Law.map_snd, Law.map_map] + rfl + +theorem mutualInfo_map_le (p : Law (α × β)) (f : α → γ) (g : β → δ) : + mutualInfo (p.map (fun z => (f z.1,g z.2))) ≤ mutualInfo p := by + rw [mutualInfo_eq_divergence, Law.fst_map_pair, Law.snd_map_pair, + mutualInfo_eq_divergence, ← Law.prod_map] + exact divergence_map_le _ _ p.absContinuous_prod _ + +theorem entropy_map_eq_of_leftInverse (p : Law α) (f : α → β) (g : β → α) + (h : Function.LeftInverse g f) : entropy (p.map f) = entropy p := by + apply le_antisymm (entropy_map_le p f) + have hh := entropy_map_le (p.map f) g + have he : g ∘ f = id := funext h + simpa only [Law.map_map, he, Law.map_id] using hh + +theorem entropy_pair_self (p : Law α) (f : α → β) : + entropy (p.map (fun a => (a,f a))) = entropy p := + entropy_map_eq_of_leftInverse p _ Prod.fst (fun _a => rfl) + +@[simp] theorem Law.fst_map_self (p : Law α) (f : α → β) : + (p.map (fun a => (a,f a))).fst = p := by + rw [← Law.map_fst, Law.map_map] + exact p.map_id + +@[simp] theorem Law.snd_map_self (p : Law α) (f : α → β) : + (p.map (fun a => (a,f a))).snd = p.map f := by + rw [← Law.map_snd, Law.map_map] + rfl + +noncomputable def Law.cond (p : Law α) (f : α → β) (b : β) : Law α := + (p.map (fun a => (a,f a))).condFst b + +theorem Law.cond_mass (p : Law α) (f : α → β) (b : β) + (hb : (p.map f).mass b ≠ 0) (a : α) : + (p.cond f b).mass a = (if f a = b then p.mass a else 0)/(p.map f).mass b := by + unfold Law.cond + rw [Law.condFst_mass _ _ (by simpa using hb)] + rw [Law.snd_map_self] + congr 1 + simp [Law.map, sum_filter, ite_and] + +theorem Law.cond_map_weight (p : Law α) (f : α → β) (g : α → γ) (b : β) (c : γ) : + (p.map f).mass b * ((p.cond f b).map g).mass c = + (p.map (fun a => (g a,f a))).mass (c,b) := by + by_cases hb : (p.map f).mass b = 0 + · rw [hb,zero_mul] + have hh := (p.map (fun a => (g a,f a))).le_snd c b + have he : (p.map (fun a => (g a,f a))).snd = p.map f := by + rw [← Law.map_snd, Law.map_map]; rfl + rw [he,hb] at hh + exact (le_antisymm hh ((p.map _).nonneg _)).symm + change (p.map f).mass b*(∑ a with g a = c, (p.cond f b).mass a) = _ + simp_rw [p.cond_mass f b hb] + rw [← sum_div, mul_div_cancel₀ _ hb] + simp only [Law.map, Prod.mk.injEq, sum_filter] + apply sum_congr rfl + intro a ha + split_ifs <;> simp_all + +theorem entropy_cond_chain (p : Law α) (f : α → β) (g : α → γ) : + entropy (p.map (fun a => (g a,f a))) = entropy (p.map f)+ + ∑ b, (p.map f).mass b*entropy ((p.cond f b).map g) := by + let q := p.map (fun a => (g a,f a)) + have he : q.snd = p.map f := by rw [← Law.map_snd, Law.map_map]; rfl + have hm (b : β) : (p.map f).mass b*entropy (q.condFst b) = + (p.map f).mass b*entropy ((p.cond f b).map g) := by + by_cases hb : (p.map f).mass b = 0 + · simp [hb] + congr 1 + congr 1 + ext c + apply (mul_left_cancel₀ hb) + rw [← he, q.snd_mul_condFst, he, p.cond_map_weight] + rw [entropy_chain, he] + congr 1 + exact sum_congr rfl fun b hb => hm b + +theorem entropy_cond_self (p : Law α) (f : α → β) : + entropy p = entropy (p.map f)+∑ b, (p.map f).mass b*entropy (p.cond f b) := by + simpa only [id_eq, Law.map_id, entropy_pair_self] using entropy_cond_chain p f id + +end SharpLogRamsey.Selection + +namespace SharpLogRamsey.Selection +variable {α β : Type*} [Fintype α] [Fintype β] +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +noncomputable def Law.pi (p : ι → Law β) : Law (ι → β) where + mass x := ∏ i, (p i).mass (x i) + nonneg x := prod_nonneg fun i hi => (p i).nonneg (x i) + total := by + have h := prod_univ_sum (fun _ : ι => (univ : Finset β)) (fun i b => (p i).mass b) + simpa only [Fintype.piFinset_univ, Law.total, prod_const_one] using h.symm + +noncomputable def Law.marginal (p : Law (ι → β)) (i : ι) : Law β := + p.map (fun x => x i) + +noncomputable def totalCorrelation (p : Law (ι → β)) : ℝ := + (∑ i, entropy (p.marginal i))-entropy p + +theorem Law.absContinuous_pi (p : Law (ι → β)) : + p.AbsolutelyContinuous (Law.pi p.marginal) := by + intro x hz + change (∏ i, (p.marginal i).mass (x i)) = 0 at hz + obtain ⟨i,hi⟩ := (prod_eq_zero_iff).mp hz + have hh : p.mass x ≤ (p.marginal i).mass (x i) := p.le_map (fun y => y i) x + exact le_antisymm (hi.2 ▸ hh) (p.nonneg _) + +theorem totalCorrelation_eq_divergence (p : Law (ι → β)) : + totalCorrelation p = divergence p (Law.pi p.marginal) := by + have pointwise (x : ι → β) : + p.mass x*Real.log (p.mass x/(∏ i, (p.marginal i).mass (x i))) = + p.mass x*Real.log (p.mass x)-∑ i, p.mass x*Real.log ((p.marginal i).mass (x i)) := by + by_cases hz : p.mass x = 0 + · simp [hz] + have hp : 0 < p.mass x := lt_of_le_of_ne (p.nonneg x) (Ne.symm hz) + have hm (i : ι) : 0 < (p.marginal i).mass (x i) := hp.trans_le (p.le_map _ x) + rw [Real.log_div hz (prod_ne_zero_iff.mpr fun i hi => (hm i).ne'), + Real.log_prod (fun i hi => (hm i).ne'),mul_sub,mul_sum] + have hs : ∑ x, ∑ i, p.mass x*Real.log ((p.marginal i).mass (x i)) = + ∑ i, ∑ b, (p.marginal i).mass b*Real.log ((p.marginal i).mass b) := by + rw [sum_comm] + apply sum_congr rfl + intro i hi + exact (p.sum_map (fun x => x i) (fun b => Real.log ((p.marginal i).mass b))).symm + unfold divergence + change _ = ∑ x, p.mass x*Real.log (p.mass x/(∏ i, (p.marginal i).mass (x i))) + simp_rw [pointwise] + rw [sum_sub_distrib,hs] + unfold totalCorrelation entropy + rw [sum_neg_distrib] + ring + +theorem totalCorrelation_nonneg (p : Law (ι → β)) : 0 ≤ totalCorrelation p := by + rw [totalCorrelation_eq_divergence] + exact divergence_nonneg _ _ p.absContinuous_pi + +theorem entropy_subadditive_pi (p : Law (ι → β)) : + entropy p ≤ ∑ i, entropy (p.marginal i) := by + have h := totalCorrelation_nonneg p + unfold totalCorrelation at h + linarith + +theorem Law.map_mass_injective (p : Law α) (f : α → β) (hf : Function.Injective f) (a : α) : + (p.map f).mass (f a) = p.mass a := by + change (∑ x with f x = f a, p.mass x) = p.mass a + simp only [hf.eq_iff] + simp [sum_filter] + +theorem entropy_map_eq_of_injective (p : Law α) (f : α → β) (hf : Function.Injective f) : + entropy (p.map f) = entropy p := by + rw [entropy_map] + simp only [p.map_mass_injective f hf] + rfl + +noncomputable def Law.restrict (p : Law (ι → β)) (S : Finset ι) : Law (S → β) := + p.map (fun x i => x i) + +theorem entropy_restrict_chain (p : Law (ι → β)) (E : Finset ι) : + entropy p = entropy (p.restrict E)+ + ∑ e, (p.restrict E).mass e*entropy ((p.cond (fun x (i:E) => x i) e).restrict Eᶜ) := by + have hx : Function.Injective (fun x : ι → β => + ((fun i : ↥(Eᶜ) => x i),(fun i : E => x i))) := by + intro x y h + funext i + by_cases hi : i ∈ E + · exact congr_fun (congrArg Prod.snd h) ⟨i,hi⟩ + · exact congr_fun (congrArg Prod.fst h) ⟨i,by simpa using hi⟩ + have h := entropy_cond_chain p (fun x (i:E) => x i) (fun x (i:↥(Eᶜ)) => x i) + rwa [entropy_map_eq_of_injective p _ hx] at h + +theorem entropy_marginal_cond (p : Law (ι → β)) (E : Finset ι) (i : ι) : + (∑ e, (p.restrict E).mass e*entropy ((p.cond (fun x (j:E) => x j) e).marginal i)) = + entropy (p.marginal i)-mutualInfo (p.map (fun x => (x i,fun j:E => x j))) := by + have he : (p.map (fun x => (x i,fun j:E => x j))).fst = p.marginal i := by + rw [← Law.map_fst, Law.map_map]; rfl + have hs : (p.map (fun x => (x i,fun j:E => x j))).snd = p.restrict E := by + rw [← Law.map_snd, Law.map_map]; rfl + have h := entropy_cond_chain p (fun x (j:E) => x j) (fun x => x i) + unfold mutualInfo + rw [he,hs,h] + change _ = entropy (p.marginal i)-(entropy (p.marginal i)+entropy (p.restrict E)- + (entropy (p.restrict E)+∑ e, (p.restrict E).mass e*entropy ((p.cond (fun x (j:E) => x j) e).marginal i))) + ring + +@[simp] theorem Law.marginal_restrict (p : Law (ι → β)) (S : Finset ι) (i : S) : + (p.restrict S).marginal i = p.marginal i := by + unfold Law.marginal Law.restrict + rw [Law.map_map] + rfl + +theorem totalCorrelation_drop (p : Law (ι → β)) (E : Finset ι) : + totalCorrelation p- + (∑ e, (p.restrict E).mass e* + totalCorrelation ((p.cond (fun x (i:E) => x i) e).restrict Eᶜ)) = + totalCorrelation (p.restrict E)+ + ∑ i ∈ Eᶜ, mutualInfo (p.map (fun x => (x i,fun j:E => x j))) := by + have hc := entropy_restrict_chain p E + have hm : ∑ e, (p.restrict E).mass e * + (∑ i : ↥(Eᶜ), entropy (((p.cond (fun x (i:E) => x i) e).restrict Eᶜ).marginal i)) = + ∑ i ∈ Eᶜ, (entropy (p.marginal i)-mutualInfo (p.map (fun x => (x i,fun j:E => x j)))) := by + simp only [Law.marginal_restrict,mul_sum] + rw [sum_comm] + simp_rw [entropy_marginal_cond] + exact (sum_subtype (Eᶜ) (fun _ => Iff.rfl) (fun i => entropy (p.marginal i)-mutualInfo (p.map (fun x => (x i,fun j:E => x j))))).symm + unfold totalCorrelation + simp only [mul_sub,sum_sub_distrib] + rw [hm] + have he : (∑ i : E, entropy ((p.restrict E).marginal i)) = + ∑ i ∈ E, entropy (p.marginal i) := by + simp only [Law.marginal_restrict] + exact (sum_subtype E (fun _ => Iff.rfl) (fun i => entropy (p.marginal i))).symm + rw [he,sum_sub_distrib] + have hsum := sum_add_sum_compl E (fun i => entropy (p.marginal i)) + linarith + +end SharpLogRamsey.Selection + +namespace SharpLogRamsey.Selection +variable {B X : Type*} [Fintype B] [Fintype X] [DecidableEq B] + +theorem fresh_draw_identity (b : B) (g : X→(B→X)→ℝ) + (hdep : ∀ j f x, g j (Function.update f b x)=g j f) : + (Fintype.card X:ℝ)*(∑ f : B→X, g (f b) f)= + ∑ f : B→X, ∑ j, g j f := by + classical + let e := Equiv.funSplitAt b X + have hi (x : X) (r : {z : B // z≠b}→X) : e.symm (x,r) b=x := by + simp [e,Equiv.funSplitAt,Equiv.piSplitAt] + have hu (x j : X) (r : {z : B // z≠b}→X) : + Function.update (e.symm (x,r)) b j=e.symm (j,r) := by + funext z + by_cases hz : z=b + · subst z + simp [hi] + · simp [e,Equiv.funSplitAt,Equiv.piSplitAt,hz] + have hg (x j : X) (r : {z : B // z≠b}→X) : g j (e.symm (x,r))=g j (e.symm (j,r)) := by + rw [←hu x j r] + exact (hdep j (e.symm (x,r)) j).symm + rw [←e.symm.sum_comp (fun f => g (f b) f),←e.symm.sum_comp (fun f => ∑ j, g j f)] + simp only [Fintype.sum_prod_type,hi] + trans (∑ _x : X, ∑ j : X, ∑ r : {z : B // z≠b}→X, g j (e.symm (j,r))) + · simp only [sum_const,nsmul_eq_mul,card_univ] + · apply sum_congr rfl + intro x _ + rw [sum_comm] + apply sum_congr rfl + intro r _ + apply sum_congr rfl + intro j _ + exact (hg x j r).symm + +end SharpLogRamsey.Selection + +namespace SharpLogRamsey.Selection +variable {ι β : Type*} [Fintype ι] [DecidableEq ι] [Fintype β] + +noncomputable def pairInformation (p : Law (ι → β)) (i j : ι) : NNReal := + ⟨mutualInfo (p.map (fun x => (x i,x j))),mutualInfo_nonneg _⟩ + +noncomputable def exposedInformation (p : Law (ι → β)) (i : ι) (E : Finset ι) : NNReal := + ⟨mutualInfo (p.map (fun x => (x i,fun j : E => x j))),mutualInfo_nonneg _⟩ + +noncomputable def maximumInformation (p : Law (ι → β)) (i : ι) (J : Finset ι) : NNReal := + J.sup (pairInformation p i) + +lemma pairInformation_le_exposed (p : Law (ι → β)) (i : ι) (E : Finset ι) + {j : ι} (hj : j∈E) : pairInformation p i j ≤ exposedInformation p i E := by + change mutualInfo (p.map (fun x => (x i,x j))) ≤ + mutualInfo (p.map (fun x => (x i,fun z : E => x z))) + have H := mutualInfo_map_le (p.map (fun x => (x i,fun z : E => x z))) + id (fun z : E → β => z ⟨j,hj⟩) + simpa only [Law.map_map,Function.comp_def,id_eq] using H + +lemma maximumInformation_le_exposed (p : Law (ι → β)) (i : ι) (E J : Finset ι) + (hJ : J⊆E) : maximumInformation p i J ≤ exposedInformation p i E := by + apply Finset.sup_le + intro j hj + exact pairInformation_le_exposed p i E (hJ hj) + +theorem maximum_exposure_drop (p : Law (ι → β)) (E : Finset ι) + (J : ι → Finset ι) (hJ : ∀ i, J i⊆E) : + (∑ i, (maximumInformation p i (J i):ℝ)) ≤ + totalCorrelation p- + (∑ e, (p.restrict E).mass e* + totalCorrelation ((p.cond (fun x (j:E) => x j) e).restrict Eᶜ))+ + ∑ i∈E, (maximumInformation p i (J i):ℝ) := by + have H := totalCorrelation_drop p E + have hn := totalCorrelation_nonneg (p.restrict E) + have hle : (∑ i∈Eᶜ, (maximumInformation p i (J i):ℝ)) ≤ + ∑ i∈Eᶜ, mutualInfo (p.map (fun x => (x i,fun j:E => x j))) := by + apply sum_le_sum + intro i _ + exact maximumInformation_le_exposed p i E (J i) (hJ i) + have hs := sum_add_sum_compl E (fun i => (maximumInformation p i (J i):ℝ)) + linarith + +end SharpLogRamsey.Selection + +namespace SharpLogRamsey.Selection +variable {ι β B X : Type*} [Fintype ι] [DecidableEq ι] [Fintype β] + [Fintype B] [Fintype X] [DecidableEq B] + +noncomputable def freshRepresentatives (e : B×X ↪ ι) (f : B→X) : Finset ι := + univ.image (fun b => e (b,f b)) + +noncomputable def otherRepresentatives (e : B×X ↪ ι) (own : ι→Option B) + (f : B→X) (i : ι) : Finset ι := + (univ.filter (fun b => some b≠own i)).image (fun b => e (b,f b)) + +omit [Fintype ι] [Fintype X] in +lemma otherRepresentatives_sub (e : B×X ↪ ι) (own : ι→Option B) + (f : B→X) (i : ι) : otherRepresentatives e own f i⊆freshRepresentatives e f := by + exact image_subset_image (filter_subset _ _) + +omit [Fintype ι] [Fintype X] in +lemma otherRepresentatives_update (e : B×X ↪ ι) (own : ι→Option B) + (hown : ∀ b x, own (e (b,x))=some b) (b : B) (x y : X) (f : B→X) : + otherRepresentatives e own (Function.update f b y) (e (b,x))= + otherRepresentatives e own f (e (b,x)) := by + unfold otherRepresentatives + rw [hown] + apply image_congr + intro c hc + have hn : c≠b := by simpa using (mem_filter.mp hc).2 + simp only [Function.update_of_ne hn] + +theorem selected_maximum_absorption (p : Law (ι→β)) (e : B×X ↪ ι) + (own : ι→Option B) (hown : ∀ b x, own (e (b,x))=some b) : + (Fintype.card X:ℝ)* + (∑ f : B→X, ∑ i∈freshRepresentatives e f, + (maximumInformation p i (otherRepresentatives e own f i):ℝ)) ≤ + ∑ f : B→X, ∑ i, (maximumInformation p i (otherRepresentatives e own f i):ℝ) := by + let M (f : B→X) (i : ι) : ℝ := maximumInformation p i (otherRepresentatives e own f i) + have hsel (f : B→X) : (∑ i∈freshRepresentatives e f,M f i)=∑ b,M f (e (b,f b)) := by + apply sum_image + intro b _ c _ he + exact (Prod.mk.inj (e.injective he)).1 + change (Fintype.card X:ℝ)*(∑ f, ∑ i∈freshRepresentatives e f,M f i)≤∑ f,∑ i,M f i + simp_rw [hsel] + rw [sum_comm,mul_sum] + have hb (b : B) : (Fintype.card X:ℝ)*(∑ f : B→X,M f (e (b,f b)))= + ∑ f : B→X,∑ x : X, M f (e (b,x)) := by + apply fresh_draw_identity b (fun x f => M f (e (b,x))) + intro x f y + dsimp [M] + rw [otherRepresentatives_update e own hown] + simp_rw [hb] + rw [sum_comm] + apply sum_le_sum + intro f _ + have h : (∑ z∈univ.map e, M f z) ≤ ∑ i, M f i := by + apply sum_le_sum_of_subset_of_nonneg (subset_univ _) + intro i _ _ + exact (maximumInformation p i _).property + simpa only [sum_map,Fintype.sum_prod_type] using h + +theorem fresh_round_drop (p : Law (ι→β)) (e : B×X ↪ ι) + (own : ι→Option B) (hown : ∀ b x, own (e (b,x))=some b) + (hX : 0 x j) z).restrict + (freshRepresentatives e f)ᶜ)) := by + have H := sum_le_sum (fun f (_ : f∈(univ : Finset (B→X))) => + maximum_exposure_drop p (freshRepresentatives e f) (otherRepresentatives e own f) + (otherRepresentatives_sub e own f)) + rw [sum_add_distrib] at H + have hs := selected_maximum_absorption p e own hown + have hn : 0<(Fintype.card X:ℝ) := by exact_mod_cast hX + let A : ℝ := ∑ f : B→X, ∑ i, (maximumInformation p i (otherRepresentatives e own f i):ℝ) + let S : ℝ := ∑ f : B→X, ∑ i∈freshRepresentatives e f, + (maximumInformation p i (otherRepresentatives e own f i):ℝ) + have hh : S≤A/(Fintype.card X:ℝ) := by + apply (le_div_iff₀ hn).mpr + change S*(Fintype.card X:ℝ)≤A + change (Fintype.card X:ℝ)*S≤A at hs + nlinarith + change A≤_+S at H + change (1-1/(Fintype.card X:ℝ))*A≤_ + have he : (1-1/(Fintype.card X:ℝ))*A=A-A/(Fintype.card X:ℝ) := by ring + rw [he] + linarith + +end SharpLogRamsey.Selection + +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical +noncomputable section +variable {B β ι : Type*} [Fintype B] [Fintype β] [Fintype ι] [DecidableEq ι] [DecidableEq B] + +end +end SharpLogRamsey.Selection +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Exposure/DominatedCoupling.lean b/lean/OAI/Combinatorics/SharpRamsey/Exposure/DominatedCoupling.lean new file mode 100644 index 0000000000000000000000000000000000000000..7c2efd07393591b272177b94a0c862131f3b4a3f --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Exposure/DominatedCoupling.lean @@ -0,0 +1,53 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Exposure.SourceCoupling + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical BigOperators +noncomputable section +variable {X Ω B : Type*} [Fintype X] [Fintype Ω] [Fintype B] + +theorem Law.attach_source_le (q : Law X) (μ : Law Ω) (f : X→B) (g : Ω→B) + (c : ℝ) (h : ∀ b,(q.map f).mass b≤c*(μ.map g).mass b) + (φ : Ω→ℝ) (hφ : ∀ ω,0≤φ ω) : + (∑ x,(q.attach μ f g).mass x*φ x.2)≤c*∑ ω,μ.mass ω*φ ω := by + rw [Law.attach,Law.sigma_sum] + change (∑ x,q.mass x*(fun b=>∑ ω,(μ.cond g b).mass ω*φ ω) (f x))≤_ + rw [←q.sum_map f (fun b=>∑ ω,(μ.cond g b).mass ω*φ ω)] + calc + _ ≤ ∑ b,c*(μ.map g).mass b*∑ ω,(μ.cond g b).mass ω*φ ω := by + apply sum_le_sum + intro b _ + exact mul_le_mul_of_nonneg_right (h b) + (sum_nonneg (fun ω _=>mul_nonneg ((μ.cond g b).nonneg ω) (hφ ω))) + _ = c*∑ ω,μ.mass ω*φ ω := by + simp_rw [mul_assoc] + rw [←mul_sum,μ.history_sum] + +lemma Law.attach_support_of_dominated (q : Law X) (μ : Law Ω) (f : X→B) (g : Ω→B) + (c : ℝ) (h : ∀ b,(q.map f).mass b≤c*(μ.map g).mass b) + (x : Σ _x : X,Ω) (hx : (q.attach μ f g).mass x≠0) : + q.mass x.1≠0 ∧ μ.mass x.2≠0 ∧ g x.2=f x.1 := by + have hx' : q.mass x.1≠0 ∧ (μ.cond g (f x.1)).mass x.2≠0 := mul_ne_zero_iff.mp hx + have hf : (μ.map g).mass (f x.1)≠0 := by + intro he + have hh:=h (f x.1) + rw [he,mul_zero] at hh + have hp : 0x.2)).mass ω≤c*μ.mass ω := by + have hh:=q.attach_source_le μ f g c h (fun x=>if x=ω then 1 else 0) (by intro x; positivity) + simpa only [Law.map,sum_filter,mul_ite,mul_one,mul_zero,sum_ite_eq',mem_univ,ite_true] using hh +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Exposure/DominatedMixture.lean b/lean/OAI/Combinatorics/SharpRamsey/Exposure/DominatedMixture.lean new file mode 100644 index 0000000000000000000000000000000000000000..38286f95f7940ae7809f8aca6dbbfba675f553b2 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Exposure/DominatedMixture.lean @@ -0,0 +1,82 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.GoodRows +import OAI.Combinatorics.SharpRamsey.Exposure.DominatedCoupling + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset Real +open scoped Classical BigOperators +noncomputable section +variable {Z B : Type} [Fintype Z] [Fintype B] + +lemma Law.event_nonzero_filter (μ : Law Z) (H : Finset Z) : + μ.event (H.filter (fun z=>μ.mass z≠0))=μ.event H := by + unfold Law.event + rw [sum_filter] + apply sum_congr rfl + intro z hz + split_ifs with h + · rfl + · exact (not_not.mp h).symm + +lemma Law.dominated_observable {X Y : Type} [Fintype X] [Fintype Y] + (p : Law X) (q : Law Y) (f : X→Y) (c : ℝ) + (h : ∀ y,(p.map f).mass y≤c*q.mass y) (g : Y→ℝ) (hg : ∀ y,0≤g y) : + (∑ x,p.mass x*g (f x))≤c*∑ y,q.mass y*g y := by + rw [←p.sum_map f g,mul_sum] + apply sum_le_sum + intro y _ + exact (mul_le_mul_of_nonneg_right (h y) (hg y)).trans_eq (mul_assoc _ _ _) + +omit [Fintype B] in + +theorem Law.dominated_history_mixture (μ : Law Z) (H : Finset Z) + (hH : (1:ℝ)/2≤μ.event H) (Q : Z→Type) [∀ z,Fintype (Q z)] (q : ∀ z,Law (Q z)) + (X : H→Type) [∀ z,Fintype (X z)] (ν : ∀ z,Law (X z)) + (f : ∀ z,X z→Q z.val) (c : ℝ) (hc : 0≤c) + (hd : ∀ z y,((ν z).map (f z)).mass y≤c*(q z.val).mass y) + (restore : ∀ z,Q z→B) (φ : B→ℝ) (hφ : ∀ b,0≤φ b) : + (∑ x,((μ.onEvent H (by linarith)).sigma ν).mass x* + φ (restore x.1.val (f x.1 x.2)))≤(2*c)* + ∑ y,(μ.sigma q).mass y*φ (restore y.1 y.2) := by + rw [Law.sigma_sum,Law.sigma_sum] + calc + _ ≤ ∑ z : H,(μ.onEvent H (by linarith)).mass z* + (c*∑ y,(q z.val).mass y*φ (restore z.val y)) := by + apply sum_le_sum + intro z _ + apply mul_le_mul_of_nonneg_left _ ((μ.onEvent H (by linarith)).nonneg z) + exact (ν z).dominated_observable (q z.val) (f z) c (hd z) + (fun y=>φ (restore z.val y)) (fun y=>hφ _) + _ = c*∑ z : H,(μ.onEvent H (by linarith)).mass z* + (∑ y,(q z.val).mass y*φ (restore z.val y)) := by + rw [mul_sum] + apply sum_congr rfl + intro z _ + ring + _ ≤ c*(2*∑ z,μ.mass z*∑ y,(q z).mass y*φ (restore z y)) := by + apply mul_le_mul_of_nonneg_left _ hc + exact μ.onEvent_mean_le_two H hH (fun z=>∑ y,(q z).mass y*φ (restore z y)) + (fun z=>sum_nonneg (fun y _=>mul_nonneg ((q z).nonneg y) (hφ _))) + _ = _ := by ring + +lemma Law.dominated_history_map (μ : Law Z) (H : Finset Z) + (hH : (1:ℝ)/2≤μ.event H) (Q : Z→Type) [∀ z,Fintype (Q z)] (q : ∀ z,Law (Q z)) + (X : H→Type) [∀ z,Fintype (X z)] (ν : ∀ z,Law (X z)) + (f : ∀ z,X z→Q z.val) (c : ℝ) (hc : 0≤c) + (hd : ∀ z y,((ν z).map (f z)).mass y≤c*(q z.val).mass y) + (restore : ∀ z,Q z→B) (b : B) : + (((μ.onEvent H (by linarith)).sigma ν).map + (fun x=>restore x.1.val (f x.1 x.2))).mass b≤ + (2*c)*((μ.sigma q).map (fun y=>restore y.1 y.2)).mass b := by + have hh:=μ.dominated_history_mixture H hH Q q X ν f c hc hd restore + (fun y=>if y=b then 1 else 0) (by intro y; positivity) + simpa only [Law.map,sum_filter,mul_ite,mul_one,mul_zero] using hh +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Exposure/ExposureAverages.lean b/lean/OAI/Combinatorics/SharpRamsey/Exposure/ExposureAverages.lean new file mode 100644 index 0000000000000000000000000000000000000000..1f73534ffb77c968a550257ee3a5c0fdeeb2507a --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Exposure/ExposureAverages.lean @@ -0,0 +1,132 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Exposure.ExposureRealization + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical BigOperators +noncomputable section +variable {β C : Type} [Fintype β] [Fintype C] + +abbrev StateStatistic (β C : Type) [Fintype β] := + ∀ (I : Type) [Fintype I] [DecidableEq I] (m : ℕ), + Law (I→β)→(C×Fin m↪I)→(I→Option C)→ℝ + +namespace ExposureModel +variable {ι : Type} [Fintype ι] [DecidableEq ι] + +def mean (M : ExposureModel ι β C) (F : StateStatistic β C) : ℝ := + ∑ z,M.historyLaw.mass z*F (M.Index z) (M.remaining z) (M.tupleLaw z) (M.embedding z) (M.owner z) + +omit [Fintype C] in +lemma initial_mean (p : Law (ι→β)) {m : ℕ} (e : C×Fin m↪ι) (own : ι→Option C) + (F : StateStatistic β C) : (initial p e own).mean F=F ι m p e own := by + change (∑ _z : Unit,(1/(Fintype.card Unit:ℝ))*F ι m p e own)=_ + simp + +lemma join_mean {m : ℕ} (p : Law (ι→β)) (e : C×Fin (m+1)↪ι) + (child : ∀ f : C→Fin (m+1), (freshRepresentatives e f→β)→ + ExposureModel ↥((freshRepresentatives e f)ᶜ) β C) + (F : StateStatistic β C) : + (join p e child).mean F=(∑ f : C→Fin (m+1),∑ z, + (p.restrict (freshRepresentatives e f)).mass z*(child f z).mean F)/ + Fintype.card (C→Fin (m+1)) := by + unfold mean + change (∑ h,((Law.equiprobable (C→Fin (m+1))).sigma (fun f=> + (p.restrict (freshRepresentatives e f)).sigma (fun z=>(child f z).historyLaw))).mass h* + F ((child h.1 h.2.1).Index h.2.2) ((child h.1 h.2.1).remaining h.2.2) + ((child h.1 h.2.1).tupleLaw h.2.2) ((child h.1 h.2.1).embedding h.2.2) + ((child h.1 h.2.1).owner h.2.2))=_ + rw [Law.sigma_sum] + simp_rw [Law.sigma_sum] + exact Law.equiprobable_sum _ _ + +end ExposureModel + +def exposureAverage (F : StateStatistic β C) (n : ℕ) : (k : ℕ)→ {ι : Type}→ + [Fintype ι] → [DecidableEq ι] → Law (ι→β)→(C×Fin (n+k)↪ι)→(ι→Option C)→Fin k→ℝ + | 0,_,_,_,_,_,_,j => Fin.elim0 j + | k+1,I,_,_,p,e,own,j => Fin.cases (F I (n+(k+1)) p e own) + (fun t=>(∑ f : C→Fin (n+k+1),∑ z,(p.restrict (freshRepresentatives e f)).mass z* + exposureAverage F n k ((p.cond (fun y (i:freshRepresentatives e f)=>y i) z).restrict + (freshRepresentatives e f)ᶜ) (remainingEmbedding e f) (fun i=>own i) t)/ + Fintype.card (C→Fin (n+k+1))) j + +theorem ExposureModel.atRound_mean (F : StateStatistic β C) (n k : ℕ) + {ι : Type} [Fintype ι] [DecidableEq ι] + (p : Law (ι→β)) (e : C×Fin (n+k)↪ι) (own : ι→Option C) (t : Fin k) : + (atRound n k p e own t).mean F=exposureAverage F n k p e own t := by + induction k generalizing ι with + | zero => exact Fin.elim0 t + | succ k ih => + refine Fin.cases ?_ (fun j=>?_) t + · exact initial_mean p e own F + · change (join p e _).mean F=_ + rw [join_mean] + simp_rw [ih] + rfl + +variable {A B K V : Type} [Fintype A] [Fintype B] [Field K] + [AddCommGroup V] [Module K V] [FiniteDimensional K V] + +def reciprocalBadStatistic (v : B→V) (w : A→Module.Dual K V) (ρ : ℝ) (r s : ℕ) + (J D a : ℝ) : StateStatistic (A×B) C := + fun _ _ _ _ p e own=>roundBad p e own (reciprocalCharges p v w ρ r s) J D a + +def reciprocalSelectedStatistic (v : B→V) (w : A→Module.Dual K V) (ρ : ℝ) (r s : ℕ) + (J D a : ℝ) : StateStatistic (A×B) C := + fun _ _ _ _ p e own=>roundSelectedBad p e own (reciprocalCharges p v w ρ r s) J D a + +omit [FiniteDimensional K V] in +lemma exposureAverage_bad (v : B→V) (w : A→Module.Dual K V) (ρ : ℝ) (r s n k : ℕ) + (J D a : ℝ) {ι : Type} [Fintype ι] [DecidableEq ι] + (p : Law (ι→A×B)) (e : C×Fin (n+k)↪ι) (own : ι→Option C) (t : Fin k) : + exposureAverage (reciprocalBadStatistic v w ρ r s J D a) n k p e own t= + chargedBad v w ρ r s n J D a k p e own t := by + induction k generalizing ι with + | zero => exact Fin.elim0 t + | succ k ih => + refine Fin.cases ?_ (fun j=>?_) t + · rfl + · change (∑ f : C→Fin (n+k+1),∑ z,(p.restrict (freshRepresentatives e f)).mass z* + exposureAverage _ n k _ _ _ j)/_=_ + simp_rw [ih] + rfl + +omit [FiniteDimensional K V] in +lemma exposureAverage_selected (v : B→V) (w : A→Module.Dual K V) (ρ : ℝ) (r s n k : ℕ) + (J D a : ℝ) {ι : Type} [Fintype ι] [DecidableEq ι] + (p : Law (ι→A×B)) (e : C×Fin (n+k)↪ι) (own : ι→Option C) (t : Fin k) : + exposureAverage (reciprocalSelectedStatistic v w ρ r s J D a) n k p e own t= + chargedSelectedBad v w ρ r s n J D a k p e own t := by + induction k generalizing ι with + | zero => exact Fin.elim0 t + | succ k ih => + refine Fin.cases ?_ (fun j=>?_) t + · rfl + · change (∑ f : C→Fin (n+k+1),∑ z,(p.restrict (freshRepresentatives e f)).mass z* + exposureAverage _ n k _ _ _ j)/_=_ + simp_rw [ih] + rfl + +omit [FiniteDimensional K V] in +theorem ExposureModel.atRound_bad_selected + (v : B→V) (w : A→Module.Dual K V) (ρ : ℝ) (r s n k : ℕ) + (J D a : ℝ) {ι : Type} [Fintype ι] [DecidableEq ι] + (p : Law (ι→A×B)) (e : C×Fin (n+k)↪ι) (own : ι→Option C) (t : Fin k) : + (atRound n k p e own t).mean (reciprocalBadStatistic v w ρ r s J D a)= + chargedBad v w ρ r s n J D a k p e own t ∧ + (atRound n k p e own t).mean (reciprocalSelectedStatistic v w ρ r s J D a)= + chargedSelectedBad v w ρ r s n J D a k p e own t := by + constructor + · rw [atRound_mean,exposureAverage_bad] + · rw [atRound_mean,exposureAverage_selected] + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Exposure/ExposureBudget.lean b/lean/OAI/Combinatorics/SharpRamsey/Exposure/ExposureBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..7dde7ebd9cf56a903046521bd6224010bd279d97 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Exposure/ExposureBudget.lean @@ -0,0 +1,433 @@ +import Mathlib + +namespace OAI + +/-! Entropy and counting bounds for selected coordinates in finite probability laws. -/ + +section +open scoped BigOperators +open Finset +open scoped Classical + +namespace SharpLogRamsey.Selection + +structure Law (α : Type*) [Fintype α] where + mass : α → ℝ + nonneg : ∀ a, 0 ≤ mass a + total : ∑ a, mass a = 1 + +variable {α β : Type*} [Fintype α] [Fintype β] + +noncomputable def entropy (p : Law α) : ℝ := - ∑ a, p.mass a * Real.log (p.mass a) + +theorem entropy_ge_neg_log (p : Law α) {c : ℝ} (_hc : 0 < c) + (hcap : ∀ a, p.mass a ≤ c) : -Real.log c ≤ entropy p := by + have h : ∑ a, p.mass a * Real.log (p.mass a) ≤ Real.log c := by + calc + _ ≤ ∑ a, p.mass a * Real.log c := by + apply Finset.sum_le_sum + intro a _ + rcases (p.nonneg a).eq_or_lt with hz | hp + · simp [← hz] + · exact mul_le_mul_of_nonneg_left (Real.log_le_log hp (hcap a)) (p.nonneg a) + _ = Real.log c := by rw [← Finset.sum_mul, p.total, one_mul] + exact neg_le_neg h + +noncomputable def Law.map (p : Law α) (f : α → β) : Law β := by + classical + refine ⟨fun b => ∑ a with f a = b, p.mass a, ?_, ?_⟩ + · intro b; exact Finset.sum_nonneg fun a _ => p.nonneg a + · exact (Finset.sum_fiberwise Finset.univ f p.mass).trans p.total + +theorem card_fixed_coordinates {N ℓ : ℕ} (e : Fin ℓ ↪ Fin N) + (f : Fin ℓ → α) : + Fintype.card {g : Fin N → α // ∀ i, g (e i) = f i} ≤ + Fintype.card α ^ (N - ℓ) := by + classical + let S : Finset (Fin N) := Finset.univ.map e + have hS : S.card = ℓ := by simp [S] + have he (i : Fin ℓ) : e i ∈ S := Finset.mem_map.mpr ⟨i, Finset.mem_univ _, rfl⟩ + let restrict : {g : Fin N → α // ∀ i, g (e i) = f i} → ({x // x ∉ S} → α) := + fun g x => g.val x.val + have hi : Function.Injective restrict := by + intro g h hgh + apply Subtype.ext + funext x + by_cases hx : x ∈ S + · obtain ⟨i, _, rfl⟩ := Finset.mem_map.mp hx + exact (g.property i).trans (h.property i).symm + · exact congr_fun hgh ⟨x, hx⟩ + have hc : Fintype.card {x // x ∉ S} = N - ℓ := by + rw [Fintype.card_subtype_compl, Fintype.card_coe, Fintype.card_fin, hS] + simpa only [Fintype.card_fun, hc] using Fintype.card_le_of_injective restrict hi + +abbrev Positions (N ℓ : ℕ) := {S : Finset (Fin N) // S.card = ℓ} + +noncomputable def positionMap {N ℓ : ℕ} (S : Positions N ℓ) : Fin ℓ ↪ Fin N := + (S.val.orderEmbOfFin S.property).toEmbedding + +def Occurs {N ℓ : ℕ} (f : Fin ℓ → α) (g : Fin N → α) : Prop := + ∃ S : Positions N ℓ, ∀ i, g (positionMap S i) = f i + +theorem card_occurs {N ℓ : ℕ} (f : Fin ℓ → α) : + Fintype.card {g : Fin N → α // Occurs f g} ≤ + N.choose ℓ * Fintype.card α ^ (N - ℓ) := by + classical + let cyl (S : Positions N ℓ) : Finset (Fin N → α) := + {g | ∀ i, g (positionMap S i) = f i} + have h : ({g | Occurs f g} : Finset (Fin N → α)) = Finset.univ.biUnion cyl := by + ext g; simp [cyl, Occurs] + rw [Fintype.card_subtype, h] + calc + _ ≤ ∑ S : Positions N ℓ, (cyl S).card := Finset.card_biUnion_le + _ ≤ ∑ _S : Positions N ℓ, Fintype.card α ^ (N - ℓ) := by + apply Finset.sum_le_sum + intro S _ + simpa only [cyl, ← Fintype.card_subtype] using card_fixed_coordinates (positionMap S) f + _ = N.choose ℓ * Fintype.card α ^ (N - ℓ) := by simp [Fintype.card_finset_len] + +theorem card_occurs_two {N ℓ : ℕ} (f f' : Fin ℓ → α) : + Fintype.card {g : Fin N → α // Occurs f g ∨ Occurs f' g} ≤ + 2 * N.choose ℓ * Fintype.card α ^ (N - ℓ) := by + classical + have h : ({g | Occurs f g ∨ Occurs f' g} : Finset (Fin N → α)) = + ({g | Occurs f g} : Finset _) ∪ ({g | Occurs f' g} : Finset _) := by ext; simp + rw [Fintype.card_subtype, h] + have h1 := card_occurs f (N := N) + have h2 := card_occurs f' (N := N) + rw [Fintype.card_subtype] at h1 h2 + exact (Finset.card_union_le _ _).trans (by nlinarith) + +noncomputable def Law.fst (p : Law (α × β)) : Law α where + mass a := ∑ b, p.mass (a,b) + nonneg a := Finset.sum_nonneg fun b _ => p.nonneg (a,b) + total := by simpa only [← Fintype.sum_prod_type] using p.total + +noncomputable def Law.snd (p : Law (α × β)) : Law β where + mass b := ∑ a, p.mass (a,b) + nonneg b := Finset.sum_nonneg fun a _ => p.nonneg (a,b) + total := by rw [Finset.sum_comm]; simpa only [← Fintype.sum_prod_type] using p.total + +theorem selected_atom_bound [Nonempty α] {N ℓ : ℕ} (hℓ : ℓ ≤ N) + (p : Law ((Fin N → α) × (Fin ℓ → α))) + (reverse : (Fin ℓ → α) → (Fin ℓ → α)) {C : ℝ} (hC : 0 < C) + (hdom : ∀ g, p.fst.mass g ≤ C / (Fintype.card α : ℝ)^N) + (hselect : ∀ g f, p.mass (g,f) ≠ 0 → Occurs f g ∨ Occurs (reverse f) g) + (f : Fin ℓ → α) : + p.snd.mass f ≤ 2 * C * N.choose ℓ / (Fintype.card α : ℝ)^ℓ := by + let a : ℝ := Fintype.card α + have ha : 0 < a := by + dsimp [a]; exact_mod_cast (Fintype.card_pos (α := α)) + let E : Finset (Fin N → α) := {g | Occurs f g ∨ Occurs (reverse f) g} + have hcard : (E.card : ℝ) ≤ 2 * N.choose ℓ * a^(N-ℓ) := by + have hc := card_occurs_two f (reverse f) (N := N) + rw [Fintype.card_subtype] at hc + dsimp [E, a] + exact_mod_cast hc + have hsum : p.snd.mass f ≤ (E.card : ℝ) * (C / a^N) := by + calc + _ = ∑ g, p.mass (g,f) := rfl + _ ≤ ∑ g, if g ∈ E then C / a^N else 0 := by + apply Finset.sum_le_sum + intro g _ + by_cases hg : g ∈ E + · rw [ite_eq_left hg] + exact (Finset.single_le_sum (fun b _ => p.nonneg (g,b)) + (Finset.mem_univ f)).trans (hdom g) + · rw [ite_eq_right hg] + have hz : p.mass (g,f) = 0 := by + by_contra h + exact hg (Finset.mem_filter.mpr ⟨Finset.mem_univ _, hselect g f h⟩) + rw [hz] + _ = _ := by simp only [← Finset.sum_filter, Finset.filter_mem_eq_inter, + Finset.univ_inter, Finset.sum_const, nsmul_eq_mul] + calc + _ ≤ (2 * (N.choose ℓ : ℝ) * a^(N-ℓ)) * (C / a^N) := + hsum.trans (mul_le_mul_of_nonneg_right hcard (by positivity)) + _ = 2 * C * N.choose ℓ / a^ℓ := by + have hp : a^N = a^(N-ℓ) * a^ℓ := by rw [← pow_add, Nat.sub_add_cancel hℓ] + rw [hp] + field_simp + +theorem selected_entropy_bound [Nonempty α] {N ℓ : ℕ} (hℓ : ℓ ≤ N) + (p : Law ((Fin N → α) × (Fin ℓ → α))) + (reverse : (Fin ℓ → α) → (Fin ℓ → α)) {C : ℝ} (hC : 0 < C) + (hdom : ∀ g, p.fst.mass g ≤ C / (Fintype.card α : ℝ)^N) + (hselect : ∀ g f, p.mass (g,f) ≠ 0 → Occurs f g ∨ Occurs (reverse f) g) : + (ℓ : ℝ) * Real.log (Fintype.card α) - Real.log (2 * C * N.choose ℓ) + ≤ entropy p.snd := by + have ha : (0 : ℝ) < Fintype.card α := by exact_mod_cast Fintype.card_pos + have hchoose : (0 : ℝ) < N.choose ℓ := by exact_mod_cast Nat.choose_pos hℓ + have h := entropy_ge_neg_log p.snd + (c := 2 * C * N.choose ℓ / (Fintype.card α : ℝ)^ℓ) (by positivity) + (selected_atom_bound hℓ p reverse hC hdom hselect) + rw [Real.log_div (by positivity) (by positivity), Real.log_pow] at h + linarith + +end SharpLogRamsey.Selection + +namespace SharpLogRamsey.Selection +variable {α β γ : Type*} [Fintype α] [Fintype β] [Fintype γ] + +def Law.AbsolutelyContinuous (p q : Law α) : Prop := ∀ a, q.mass a = 0 → p.mass a = 0 + +noncomputable def divergence (p q : Law α) : ℝ := + ∑ a, p.mass a * Real.log (p.mass a / q.mass a) + +theorem Law.mass_le_one (p : Law α) (a : α) : p.mass a ≤ 1 := by + rw [← p.total] + exact single_le_sum (fun b hb => p.nonneg b) (mem_univ a) + +theorem entropy_nonneg (p : Law α) : 0 ≤ entropy p := by + apply neg_nonneg.mpr + exact sum_nonpos fun a ha => mul_nonpos_of_nonneg_of_nonpos (p.nonneg a) + (Real.log_nonpos (p.nonneg a) (p.mass_le_one a)) + +theorem mul_log_div_ge {x y : ℝ} (hx : 0 ≤ x) (hy : 0 ≤ y) + (hab : y = 0 → x = 0) : x-y ≤ x*Real.log (x/y) := by + rcases hx.eq_or_lt with hx0 | hx0 + · rw [← hx0]; simp [hy] + have hy0 : 0 < y := lt_of_le_of_ne hy (fun h => hx0.ne' (hab h.symm)) + have h := Real.log_le_sub_one_of_pos (div_pos hy0 hx0) + rw [Real.log_div hy0.ne' hx0.ne'] at h + rw [Real.log_div hx0.ne' hy0.ne'] + have hh := mul_le_mul_of_nonneg_left h hx0.le + have he : x*(y/x-1) = y-x := by field_simp + rw [he] at hh + nlinarith + +theorem divergence_nonneg (p q : Law α) (hab : p.AbsolutelyContinuous q) : + 0 ≤ divergence p q := by + calc + 0 = ∑ a, (p.mass a-q.mass a) := by rw [sum_sub_distrib,p.total,q.total]; ring + _ ≤ _ := sum_le_sum fun a ha => mul_log_div_ge (p.nonneg a) (q.nonneg a) (hab a) + +noncomputable def Law.event (p : Law α) (E : Finset α) : ℝ := ∑ a ∈ E, p.mass a + +theorem Law.event_nonneg (p : Law α) (E : Finset α) : 0 ≤ p.event E := + sum_nonneg fun a _ha => p.nonneg a + +theorem Law.event_le_one (p : Law α) (E : Finset α) : p.event E ≤ 1 := by + rw [← p.total] + exact sum_le_sum_of_subset_of_nonneg (subset_univ E) (fun a ha hE => p.nonneg a) + +theorem event_transfer (p q : Law α) (hab : p.AbsolutelyContinuous q) (E : Finset α) : + q.event E ≤ 2*(divergence p q+p.event E) := by + have hlog2 : Real.log 2 ≤ 1 := by simpa only [show (2:ℝ)-1=1 by norm_num] using Real.log_le_sub_one_of_pos (by norm_num : (0:ℝ)<2) + have pointwise (a : α) : p.mass a-q.mass a + (if a ∈ E then q.mass a/2 else 0) ≤ + p.mass a*Real.log (p.mass a/q.mass a)+(if a ∈ E then p.mass a*Real.log 2 else 0) := by + by_cases ha : a ∈ E + · simp only [ite_eq_left ha] + have h := mul_log_div_ge (p.nonneg a) (div_nonneg (q.nonneg a) (by norm_num : (0:ℝ) ≤ 2)) + (fun h => hab a (by linarith)) + by_cases hp : p.mass a = 0 + · simp only [hp,zero_mul,zero_sub] at h ⊢; linarith + have hp0 := lt_of_le_of_ne (p.nonneg a) (Ne.symm hp) + have hq : q.mass a ≠ 0 := fun h => hp (hab a h) + have he : Real.log (p.mass a/(q.mass a/2)) = + Real.log (p.mass a/q.mass a)+Real.log 2 := by + rw [div_div_eq_mul_div, mul_div_right_comm, + Real.log_mul (div_ne_zero hp hq) (by norm_num)] + rw [he] at h + nlinarith + · simpa only [ite_eq_right ha,add_zero] using mul_log_div_ge (p.nonneg a) (q.nonneg a) (hab a) + have h := sum_le_sum (fun a (_ : a ∈ univ) => pointwise a) + simp only [sum_add_distrib, sum_sub_distrib, p.total, q.total, sub_self, zero_add, + ← sum_filter, filter_mem_eq_inter, univ_inter] at h + rw [← sum_div, ← sum_mul] at h + change q.event E/2 ≤ divergence p q+p.event E*Real.log 2 at h + have hh := mul_le_mul_of_nonneg_left hlog2 (p.event_nonneg E) + nlinarith + +noncomputable def Law.prod (p : Law α) (q : Law β) : Law (α × β) where + mass z := p.mass z.1*q.mass z.2 + nonneg z := mul_nonneg (p.nonneg z.1) (q.nonneg z.2) + total := by rw [Fintype.sum_prod_type, ← sum_mul_sum, p.total,q.total]; ring + +theorem Law.le_fst (p : Law (α × β)) (a : α) (b : β) : p.mass (a,b) ≤ p.fst.mass a := + single_le_sum (fun c _hc => p.nonneg (a,c)) (mem_univ b) + +theorem Law.le_snd (p : Law (α × β)) (a : α) (b : β) : p.mass (a,b) ≤ p.snd.mass b := + single_le_sum (fun c _hc => p.nonneg (c,b)) (mem_univ a) + +theorem Law.absContinuous_prod (p : Law (α × β)) : p.AbsolutelyContinuous (p.fst.prod p.snd) := by + rintro ⟨a,b⟩ h + rcases mul_eq_zero.mp h with h | h + · exact le_antisymm (by simpa [h] using p.le_fst a b) (p.nonneg _) + · exact le_antisymm (by simpa [h] using p.le_snd a b) (p.nonneg _) + +noncomputable def mutualInfo (p : Law (α × β)) : ℝ := + entropy p.fst+entropy p.snd-entropy p + +theorem mutualInfo_eq_divergence (p : Law (α × β)) : + mutualInfo p = divergence p (p.fst.prod p.snd) := by + have he (a : α) (b : β) : p.mass (a,b)*Real.log (p.mass (a,b)/(p.fst.mass a*p.snd.mass b)) = + p.mass (a,b)*Real.log (p.mass (a,b))- + p.mass (a,b)*Real.log (p.fst.mass a)-p.mass (a,b)*Real.log (p.snd.mass b) := by + by_cases h : p.mass (a,b) = 0 + · simp [h] + have hp := lt_of_le_of_ne (p.nonneg (a,b)) (Ne.symm h) + have hf : 0 < p.fst.mass a := hp.trans_le (p.le_fst a b) + have hs : 0 < p.snd.mass b := hp.trans_le (p.le_snd a b) + rw [Real.log_div h (mul_ne_zero hf.ne' hs.ne'),Real.log_mul hf.ne' hs.ne'] + ring + have hf : ∑ a, ∑ b, p.mass (a,b)*Real.log (p.fst.mass a) = + ∑ a, p.fst.mass a*Real.log (p.fst.mass a) := by + apply sum_congr rfl; intro a ha + rw [← sum_mul]; rfl + have hs : ∑ a, ∑ b, p.mass (a,b)*Real.log (p.snd.mass b) = + ∑ b, p.snd.mass b*Real.log (p.snd.mass b) := by + rw [sum_comm] + apply sum_congr rfl; intro b hb + rw [← sum_mul]; rfl + unfold divergence mutualInfo entropy Law.prod + simp only [Fintype.sum_prod_type, he, sum_sub_distrib] + rw [hf,hs] + ring + +theorem mutualInfo_nonneg (p : Law (α × β)) : 0 ≤ mutualInfo p := by + rw [mutualInfo_eq_divergence] + exact divergence_nonneg _ _ p.absContinuous_prod + +theorem entropy_subadditive (p : Law (α × β)) : entropy p ≤ entropy p.fst+entropy p.snd := by + have h := mutualInfo_nonneg p + unfold mutualInfo at h + linarith + +theorem mutualInfo_event_transfer (p : Law (α × β)) (E : Finset (α × β)) : + (p.fst.prod p.snd).event E ≤ 2*(mutualInfo p+p.event E) := by + rw [mutualInfo_eq_divergence] + exact event_transfer p _ p.absContinuous_prod E + +end SharpLogRamsey.Selection + +namespace SharpLogRamsey.Selection +variable {α β γ : Type*} [Fintype α] [Fintype β] [Fintype γ] + +theorem Law.sum_map (p : Law α) (f : α → β) (g : β → ℝ) : + ∑ b, (p.map f).mass b*g b = ∑ a, p.mass a*g (f a) := by + change ∑ b, (∑ a with f a = b, p.mass a)*g b = _ + simp_rw [sum_mul] + calc + _ = ∑ b, ∑ a with f a = b, p.mass a*g (f a) := by + apply sum_congr rfl; intro b hb + apply sum_congr rfl; intro a ha + rw [(mem_filter.mp ha).2] + _ = _ := sum_fiberwise univ f (fun a => p.mass a*g (f a)) + +theorem entropy_map (p : Law α) (f : α → β) : + entropy (p.map f) = -∑ a, p.mass a*Real.log ((p.map f).mass (f a)) := by + exact congrArg Neg.neg (p.sum_map f (fun b => Real.log ((p.map f).mass b))) + +theorem Law.le_map (p : Law α) (f : α → β) (a : α) : + p.mass a ≤ (p.map f).mass (f a) := by + apply single_le_sum (fun b hb => p.nonneg b) + simp + +theorem entropy_map_le (p : Law α) (f : α → β) : entropy (p.map f) ≤ entropy p := by + rw [entropy_map,entropy] + apply neg_le_neg + apply sum_le_sum + intro a ha + by_cases hz : p.mass a = 0 + · simp [hz] + apply mul_le_mul_of_nonneg_left _ (p.nonneg a) + exact Real.log_le_log (lt_of_le_of_ne (p.nonneg a) (Ne.symm hz)) (p.le_map f a) + +noncomputable def Law.condFst (p : Law (α × β)) (b : β) : Law α := by + by_cases h : p.snd.mass b = 0 + · exact p.fst + · refine ⟨fun a => p.mass (a,b)/p.snd.mass b, ?_, ?_⟩ + · intro a; exact div_nonneg (p.nonneg _) (p.snd.nonneg b) + · rw [← sum_div] + change p.snd.mass b/p.snd.mass b = 1 + exact div_self h + +theorem Law.condFst_mass (p : Law (α × β)) (b : β) (h : p.snd.mass b ≠ 0) (a : α) : + (p.condFst b).mass a = p.mass (a,b)/p.snd.mass b := by + simp [Law.condFst,h] + +theorem Law.snd_mul_condFst (p : Law (α × β)) (a : α) (b : β) : + p.snd.mass b*(p.condFst b).mass a = p.mass (a,b) := by + by_cases h : p.snd.mass b = 0 + · rw [h,zero_mul] + exact (le_antisymm (by simpa [h] using p.le_snd a b) (p.nonneg _)).symm + · rw [p.condFst_mass b h a] + field_simp + +theorem entropy_chain (p : Law (α × β)) : + entropy p = entropy p.snd+∑ b, p.snd.mass b*entropy (p.condFst b) := by + have pointwise (a : α) (b : β) : + p.mass (a,b)*Real.log (p.mass (a,b)) = + p.mass (a,b)*Real.log (p.snd.mass b)+ + p.snd.mass b*((p.condFst b).mass a*Real.log ((p.condFst b).mass a)) := by + by_cases hp : p.mass (a,b) = 0 + · have hh := p.snd_mul_condFst a b + rw [hp] at hh + simp only [hp,zero_mul,zero_add] + rw [← mul_assoc,hh,zero_mul] + have hs : 0 < p.snd.mass b := (lt_of_le_of_ne (p.nonneg (a,b)) (Ne.symm hp)).trans_le (p.le_snd a b) + rw [p.condFst_mass b hs.ne', Real.log_div hp hs.ne'] + field_simp + ring + unfold entropy + rw [Fintype.sum_prod_type, sum_comm] + simp_rw [pointwise, sum_add_distrib, ← mul_sum, ← sum_mul] + change -((∑ b, p.snd.mass b*Real.log (p.snd.mass b))+ + ∑ b, p.snd.mass b*∑ a, (p.condFst b).mass a*Real.log ((p.condFst b).mass a)) = _ + simp only [mul_neg, sum_neg_distrib] + ring + +theorem conditional_entropy_le (p : Law (α × β)) : + ∑ b, p.snd.mass b*entropy (p.condFst b) ≤ entropy p.fst := by + have h := entropy_subadditive p + rw [entropy_chain] at h + linarith + +theorem log_sum {ι : Type*} (s : Finset ι) (x y : ι → ℝ) + (hx : ∀ i ∈ s, 0 ≤ x i) (hy : ∀ i ∈ s, 0 ≤ y i) + (hab : ∀ i ∈ s, y i = 0 → x i = 0) : + (∑ i ∈ s, x i)*Real.log ((∑ i ∈ s, x i)/(∑ i ∈ s, y i)) ≤ + ∑ i ∈ s, x i*Real.log (x i/y i) := by + let X := ∑ i ∈ s, x i + let Y := ∑ i ∈ s, y i + have hX : 0 ≤ X := sum_nonneg hx + have hY : 0 ≤ Y := sum_nonneg hy + by_cases hz : X = 0 + · have hh : ∀ i ∈ s, x i = 0 := (sum_eq_zero_iff_of_nonneg hx).mp hz + change X*Real.log (X/Y) ≤ _ + rw [hz,zero_mul] + rw [sum_eq_zero (fun i hi => by rw [hh i hi,zero_mul])] + have hXp : 0 < X := lt_of_le_of_ne hX (Ne.symm hz) + have hYp : 0 < Y := by + by_contra hn + have hyz : Y = 0 := le_antisymm (le_of_not_gt hn) hY + have hh := (sum_eq_zero_iff_of_nonneg hy).mp hyz + apply hz + apply sum_eq_zero + intro i hi + exact hab i hi (hh i hi) + have hscale : 0 < X/Y := div_pos hXp hYp + have hterm (i : ι) (hi : i ∈ s) : + x i-y i*(X/Y) ≤ x i*Real.log (x i/y i)-x i*Real.log (X/Y) := by + by_cases hxi : x i = 0 + · simp only [hxi,zero_mul,zero_sub,sub_zero] + exact neg_nonpos.mpr (mul_nonneg (hy i hi) hscale.le) + have hyi : y i ≠ 0 := fun h => hxi (hab i hi h) + have h := mul_log_div_ge (hx i hi) (mul_nonneg (hy i hi) hscale.le) + (fun h => hab i hi ((mul_eq_zero.mp h).resolve_right hscale.ne')) + have he : Real.log (x i/(y i*(X/Y))) = Real.log (x i/y i)-Real.log (X/Y) := by + rw [← div_div,Real.log_div (div_ne_zero hxi hyi) hscale.ne'] + rw [he,mul_sub] at h + exact h + have hsum := sum_le_sum hterm + simp only [sum_sub_distrib, ← sum_mul] at hsum + change X-Y*(X/Y) ≤ (∑ i ∈ s, x i*Real.log (x i/y i))-X*Real.log (X/Y) at hsum + have he : Y*(X/Y) = X := by field_simp + rw [he,sub_self] at hsum + linarith + +end SharpLogRamsey.Selection +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Exposure/ExposureContexts.lean b/lean/OAI/Combinatorics/SharpRamsey/Exposure/ExposureContexts.lean new file mode 100644 index 0000000000000000000000000000000000000000..f9be236dd326f4c04a00d3309ff1d415a8a72ef5 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Exposure/ExposureContexts.lean @@ -0,0 +1,127 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Reciprocal.ExposureReciprocal + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical BigOperators NNReal +noncomputable section +universe u v w z +variable {Θ : Type z} {C : Type v} {β : Type w} {ι : Type u} +variable [Fintype Θ] [Fintype C] [Fintype β] [Fintype ι] [DecidableEq ι] + +def contextAverage (μ : Law Θ) (f : Θ → ℝ) : ℝ := ∑ θ, μ.mass θ*f θ + +lemma contextAverage_mono (μ : Law Θ) {f g : Θ→ℝ} + (h : ∀ θ,μ.mass θ≠0 → f θ≤g θ) : contextAverage μ f≤contextAverage μ g := by + apply sum_le_sum + intro θ _ + by_cases hθ : μ.mass θ=0 + · simp only [hθ,zero_mul,le_refl] + · exact mul_le_mul_of_nonneg_left (h θ hθ) (μ.nonneg θ) + +lemma contextAverage_const (μ : Law Θ) (a : ℝ) : contextAverage μ (fun _ => a)=a := by + unfold contextAverage + rw [←sum_mul,μ.total,one_mul] + +lemma contextAverage_add (μ : Law Θ) (f g : Θ→ℝ) : + contextAverage μ (fun θ => f θ+g θ)=contextAverage μ f+contextAverage μ g := by + simp only [contextAverage,mul_add,sum_add_distrib] + +lemma contextAverage_div (μ : Law Θ) (f : Θ→ℝ) (a : ℝ) : + contextAverage μ (fun θ => f θ/a)=contextAverage μ f/a := by + simp only [contextAverage,←mul_div_assoc,←sum_div] + +lemma contextAverage_mul (μ : Law Θ) (f : Θ→ℝ) (a : ℝ) : + contextAverage μ (fun θ => a*f θ)=a*contextAverage μ f := by + simp only [contextAverage,mul_left_comm,←mul_sum] + +lemma contextScores_sum (n k : ℕ) (hn : 2≤n) (μ : Law Θ) + (p : Θ→Law (ι→β)) (e : Θ→C×Fin (n+k) ↪ ι) (own : Θ→ι→Option C) + (hown : ∀ θ b x,own θ (e θ (b,x))=some b) : + ∑ t : Fin k,contextAverage μ (fun θ => exposureScores n k (p θ) (e θ) (own θ) t) ≤ + 2*contextAverage μ (fun θ => totalCorrelation (p θ)) := by + simp only [contextAverage] + rw [sum_comm] + simp only [←mul_sum] + rw [mul_sum] + apply sum_le_sum + intro θ _ + calc + _ ≤ μ.mass θ*(2*totalCorrelation (p θ)) := + mul_le_mul_of_nonneg_left (exposureScores_sum_le n k hn (p θ) (e θ) (own θ) (hown θ)) (μ.nonneg θ) + _ = _ := by ring + +lemma exists_context_round (n k : ℕ) (hn : 2≤n) (hk : 0 exposureScores n k (p θ) (e θ) (own θ) t) ≤ + 2*contextAverage μ (fun θ => totalCorrelation (p θ))/(k:ℝ) := by + let : Nonempty (Fin k) := ⟨⟨0,hk⟩⟩ + have hk0 : (k:ℝ)≠0 := by exact_mod_cast (Nat.ne_of_gt hk) + have hconst : (∑ _t : Fin k, + 2*contextAverage μ (fun θ => totalCorrelation (p θ))/(k:ℝ)) = + 2*contextAverage μ (fun θ => totalCorrelation (p θ)) := by + simp only [sum_const,card_univ,Fintype.card_fin,nsmul_eq_mul] + field_simp + obtain ⟨t,_,ht⟩ := exists_le_of_sum_le (univ_nonempty : (univ : Finset (Fin k)).Nonempty) + ((contextScores_sum n k hn μ p e own hown).trans_eq hconst.symm) + exact ⟨t,ht⟩ + +variable {A B : Type w} [Fintype A] [Fintype B] +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] + +theorem exists_context_good_reciprocal (v : B→V) (w : A→Module.Dual K V) + {ρ : ℝ} (hρ : 0≤ρ) {r s : ℕ} (hsum : Module.finrank K V=r+s) + (n k : ℕ) (hn : 2≤n) (hk : 0 chargedBad v w ρ r s n J D a k (p θ) (e θ) (own θ) t) ≤ + contextAverage μ (fun θ => tupleDeficit J (p θ))/D+ + 2*contextAverage μ (fun θ => totalCorrelation (p θ))/((k:ℝ)*a)+ + 2*Fintype.card ι*M/((n:ℝ)*a) ∧ + (n:ℝ)*contextAverage μ (fun θ => chargedSelectedBad v w ρ r s n J D a k (p θ) (e θ) (own θ) t) ≤ + contextAverage μ (fun θ => tupleDeficit J (p θ))/D+ + 2*contextAverage μ (fun θ => totalCorrelation (p θ))/((k:ℝ)*a)+ + 2*Fintype.card ι*M/((n:ℝ)*a) := by + obtain ⟨t,ht⟩ := exists_context_round n k hn hk μ p e own hown + have hbθ (θ : Θ) (hθ : μ.mass θ≠0) : + chargedBad v w ρ r s n J D a k (p θ) (e θ) (own θ) t ≤ + tupleDeficit J (p θ)/D+exposureScores n k (p θ) (e θ) (own θ) t/a+ + 2*Fintype.card ι*M/((n:ℝ)*a) := by + have hb := chargedBad_budget v w hρ hsum n k (by omega) J D a (Fintype.card ι) M hD ha hM + (p θ) (e θ) (own θ) (S θ) (hS θ hθ) (hJ θ) le_rfl (hf θ hθ) (ho θ hθ) t + have hd := exposureDeficits_le n k J (p θ) (e θ) (S θ) (hS θ hθ) (hJ θ) t + exact hb.trans (by gcongr) + have hb := contextAverage_mono μ hbθ + simp only [contextAverage_add,contextAverage_div,contextAverage_const] at hb + have hbound : contextAverage μ (fun θ => chargedBad v w ρ r s n J D a k (p θ) (e θ) (own θ) t) ≤ + contextAverage μ (fun θ => tupleDeficit J (p θ))/D+ + 2*contextAverage μ (fun θ => totalCorrelation (p θ))/((k:ℝ)*a)+ + 2*Fintype.card ι*M/((n:ℝ)*a) := by + calc + _ ≤ _ := hb + _ ≤ contextAverage μ (fun θ => tupleDeficit J (p θ))/D+ + (2*contextAverage μ (fun θ => totalCorrelation (p θ))/(k:ℝ))/a+_ := by gcongr + _ = _ := by rw [div_div] + refine ⟨t,hbound,le_trans ?_ hbound⟩ + rw [←contextAverage_mul] + apply contextAverage_mono μ + intro θ _ + exact chargedSelectedBad_le v w ρ r s n k J D a (p θ) (e θ) (own θ) (hown θ) t + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Exposure/ExposureGood.lean b/lean/OAI/Combinatorics/SharpRamsey/Exposure/ExposureGood.lean new file mode 100644 index 0000000000000000000000000000000000000000..2c6272859da1ea4203e71032f6790d1f28d4c956 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Exposure/ExposureGood.lean @@ -0,0 +1,150 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.GoodRound + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical BigOperators NNReal +noncomputable section +universe u v w +variable {B : Type v} {β : Type w} [Fintype B] [Fintype β] + +def exposureBad (n : ℕ) (J D a : ℝ) : (k : ℕ) → {ι : Type u} → [Fintype ι] → + [DecidableEq ι] → Law (ι → β) → (B × Fin (n+k) ↪ ι) → + (ι → Option B) → Fin k → ℝ + | 0, _, _, _, _, _, _, j => Fin.elim0 j + | k+1, _, _, _, p, e, own, j => Fin.cases + (roundBad p e own (fun _ _ => 0) J D a) + (fun t => (∑ f : B → Fin (n+k+1), + ∑ z, (p.restrict (freshRepresentatives e f)).mass z * + exposureBad n J D a k + ((p.cond (fun x (i : freshRepresentatives e f) => x i) z).restrict + (freshRepresentatives e f)ᶜ) + (remainingEmbedding e f) (fun i => own i) t) / + Fintype.card (B → Fin (n+k+1))) j + +def exposureSelectedBad (n : ℕ) (J D a : ℝ) : (k : ℕ) → {ι : Type u} → [Fintype ι] → + [DecidableEq ι] → Law (ι → β) → (B × Fin (n+k) ↪ ι) → + (ι → Option B) → Fin k → ℝ + | 0, _, _, _, _, _, _, j => Fin.elim0 j + | k+1, _, _, _, p, e, own, j => Fin.cases + (roundSelectedBad p e own (fun _ _ => 0) J D a) + (fun t => (∑ f : B → Fin (n+k+1), + ∑ z, (p.restrict (freshRepresentatives e f)).mass z * + exposureSelectedBad n J D a k + ((p.cond (fun x (i : freshRepresentatives e f) => x i) z).restrict + (freshRepresentatives e f)ᶜ) + (remainingEmbedding e f) (fun i => own i) t) / + Fintype.card (B → Fin (n+k+1))) j + +lemma roundSelectedBad_nonneg {ι : Type u} [Fintype ι] [DecidableEq ι] {m : ℕ} + (p : Law (ι→β)) (e : B×Fin m ↪ ι) (own : ι→Option B) + (c : ι→ι→NNReal) (J D a : ℝ) : 0≤roundSelectedBad p e own c J D a := by + unfold roundSelectedBad + positivity + +theorem exposureSelectedBad_le (n k : ℕ) (J D a : ℝ) + {ι : Type u} [Fintype ι] [DecidableEq ι] (p : Law (ι→β)) + (e : B×Fin (n+k) ↪ ι) (own : ι→Option B) + (hown : ∀ b x,own (e (b,x))=some b) (t : Fin k) : + (n:ℝ)*exposureSelectedBad n J D a k p e own t≤exposureBad n J D a k p e own t := by + induction k generalizing ι with + | zero => exact Fin.elim0 t + | succ k ih => + refine Fin.cases ?_ (fun j => ?_) t + · change (n:ℝ)*roundSelectedBad p e own (fun _ _ => 0) J D a≤ + roundBad p e own (fun _ _ => 0) J D a + exact (mul_le_mul_of_nonneg_right (by exact_mod_cast (show n≤n+(k+1) by omega)) + (roundSelectedBad_nonneg p e own _ J D a)).trans (roundSelectedBad_le p e own hown _ J D a) + · change (n:ℝ)*((∑ f : B→Fin (n+k+1),∑ z, + (p.restrict (freshRepresentatives e f)).mass z * + exposureSelectedBad n J D a k + ((p.cond (fun x (i : freshRepresentatives e f) => x i) z).restrict + (freshRepresentatives e f)ᶜ) + (remainingEmbedding e f) (fun i => own i) j)/_)≤_ + rw [←mul_div_assoc] + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) + rw [mul_sum] + apply sum_le_sum + intro f _ + rw [mul_sum] + apply sum_le_sum + intro z _ + rw [mul_left_comm] + apply mul_le_mul_of_nonneg_left _ ((p.restrict _).nonneg z) + exact ih _ (remainingEmbedding e f) (fun i => own i) + (fun b x => remaining_own e f own hown b x) j + +theorem exposureBad_budget (n k : ℕ) (J D a : ℝ) (hD : 0 exact Fin.elim0 t + | succ k ih => + refine Fin.cases ?_ (fun j => ?_) t + · change roundBad p e own (fun _ _ => 0) J D a≤tupleDeficit J p/D+roundInformation p e own/a + simpa only [NNReal.coe_zero,sum_const_zero,zero_div,add_zero] using + roundBad_le (by omega : 0 0) J D a hD ha + (tupleSupported_marginal_cap p S hS J hJ) + · change (∑ f : B→Fin (n+k+1),∑ z, + (p.restrict (freshRepresentatives e f)).mass z * + exposureBad n J D a k + ((p.cond (fun x (i : freshRepresentatives e f) => x i) z).restrict + (freshRepresentatives e f)ᶜ) + (remainingEmbedding e f) (fun i => own i) j)/_≤_ + calc + _ ≤ (∑ f : B→Fin (n+k+1),∑ z, + (p.restrict (freshRepresentatives e f)).mass z * + (exposureDeficits n J k + ((p.cond (fun x (i : freshRepresentatives e f) => x i) z).restrict + (freshRepresentatives e f)ᶜ) (remainingEmbedding e f) j/D+ + exposureScores n k + ((p.cond (fun x (i : freshRepresentatives e f) => x i) z).restrict + (freshRepresentatives e f)ᶜ) (remainingEmbedding e f) (fun i => own i) j/a)) / + Fintype.card (B→Fin (n+k+1)) := by + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) + apply sum_le_sum + intro f _ + apply sum_le_sum + intro z _ + by_cases hz : (p.restrict (freshRepresentatives e f)).mass z=0 + · rw [hz,zero_mul,zero_mul] + · apply mul_le_mul_of_nonneg_left _ ((p.restrict _).nonneg z) + exact ih _ (remainingEmbedding e f) (fun i => own i) (fun i => S i) + (tupleSupported_cond_restrict p S hS _ z hz) (fun i => hJ i) j + _ = _ := by + rw [exposureDeficits_succ,exposureScores_succ] + simp only [mul_add,←mul_div_assoc,sum_add_distrib,←sum_div,add_div] + ring + +theorem exists_good_exposure (n k : ℕ) (hn : 2≤n) (hk : 0(M z).historyLaw) + Index h := (M h.1).Index h.2 + finiteIndex _ := inferInstance + decIndex _ := inferInstance + tupleLaw h := (M h.1).tupleLaw h.2 + remaining h := (M h.1).remaining h.2 + embedding h := (M h.1).embedding h.2 + owner h := (M h.1).owner h.2 + origin h := (M h.1).origin h.2 + restore h := (M h.1).restore h.2 + restore_origin h := (M h.1).restore_origin h.2 + +omit [Fintype C] [Fintype ι] [DecidableEq ι] in +lemma mix_expectation (ν : Law Θ) (M : Θ→ExposureModel ι β C) (φ : (ι→β)→ℝ) : + (mix ν M).expectation φ=∑ z,ν.mass z*(M z).expectation φ := by + exact ν.sigma_sum (fun z=>(M z).historyLaw) _ + +omit [Fintype C] [Fintype ι] [DecidableEq ι] in +lemma mix_mean (ν : Law Θ) (M : Θ→ExposureModel ι β C) (F : StateStatistic β C) : + (mix ν M).mean F=∑ z,ν.mass z*(M z).mean F := by + exact ν.sigma_sum (fun z=>(M z).historyLaw) _ + +abbrev Joint (M : ExposureModel ι β C) := Σ z : M.History,M.Index z→β + +def joint (M : ExposureModel ι β C) : Law M.Joint := + M.historyLaw.sigma M.tupleLaw + +omit [Fintype C] [Fintype ι] [DecidableEq ι] in +lemma joint_expectation (M : ExposureModel ι β C) (φ : (ι→β)→ℝ) : + (∑ x,M.joint.mass x*φ (M.restore x.1 x.2))=M.expectation φ := + M.historyLaw.sigma_sum _ _ + +omit [Fintype C] in +lemma restored_map (M : ExposureModel ι β C) (p : Law (ι→β)) + (h : ∀ φ,M.expectation φ=∑ x,p.mass x*φ x) : + M.joint.map (fun x=>M.restore x.1 x.2)=p := by + ext y + have he := (M.joint_expectation (fun x=>if x=y then 1 else 0)).trans + (h (fun x=>if x=y then 1 else 0)) + simpa only [Law.map,sum_filter,mul_ite,mul_one,mul_zero,Finset.sum_ite_eq',mem_univ,ite_true] using he + +omit [Fintype C] in +lemma restore_support (M : ExposureModel ι β C) (p : Law (ι→β)) + (h : ∀ φ,M.expectation φ=∑ x,p.mass x*φ x) + (z : M.History) (hz : M.historyLaw.mass z≠0) (x : M.Index z→β) + (hx : (M.tupleLaw z).mass x≠0) : p.mass (M.restore z x)≠0 := by + rw [←M.restored_map p h] + have hp : 0M.restore x.1 x.2) ⟨z,x⟩)) + +def contextual (n k : ℕ) {Ω : Type} [Fintype Ω] (p : Law Ω) (θ : Ω→Θ) + (G : Ω→ι→β) (e : Θ→C×Fin (n+k)↪ι) (own : Θ→ι→Option C) (t : Fin k) : + ExposureModel ι β C := + mix (p.map θ) (fun z=>atRound n k ((p.cond θ z).map G) (e z) (own z) t) + +theorem contextual_preserves (n k : ℕ) {Ω : Type} [Fintype Ω] (p : Law Ω) (θ : Ω→Θ) + (G : Ω→ι→β) (e : Θ→C×Fin (n+k)↪ι) (own : Θ→ι→Option C) (t : Fin k) + (φ : (ι→β)→ℝ) : + (contextual n k p θ G e own t).expectation φ=∑ ω,p.mass ω*φ (G ω) := by + rw [contextual,mix_expectation] + simp_rw [atRound_preserves] + have hm (z : Θ) : (∑ x,((p.cond θ z).map G).mass x*φ x)= + ∑ ω,(p.cond θ z).mass ω*φ (G ω) := Law.sum_map _ _ _ + simp_rw [hm] + exact p.history_sum θ _ + +theorem contextual_map (n k : ℕ) {Ω : Type} [Fintype Ω] (p : Law Ω) (θ : Ω→Θ) + (G : Ω→ι→β) (e : Θ→C×Fin (n+k)↪ι) (own : Θ→ι→Option C) (t : Fin k) : + (contextual n k p θ G e own t).joint.map + (fun x=>(contextual n k p θ G e own t).restore x.1 x.2)=p.map G := by + apply restored_map + intro φ + rw [contextual_preserves,Law.sum_map] + +end ExposureModel +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Exposure/ExposureModel.lean b/lean/OAI/Combinatorics/SharpRamsey/Exposure/ExposureModel.lean new file mode 100644 index 0000000000000000000000000000000000000000..0947272985c7a6085639f3f381bac3cc56a6474b --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Exposure/ExposureModel.lean @@ -0,0 +1,159 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Selection.HistoryLaw +import OAI.Combinatorics.SharpRamsey.Reciprocal.SourceReciprocalExposure + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical BigOperators +noncomputable section + +variable {β C ι : Type} [Fintype β] [Fintype C] [Fintype ι] [DecidableEq ι] + +def Law.equiprobable (A : Type) [Fintype A] [Nonempty A] : Law A where + mass _ := 1/(Fintype.card A:ℝ) + nonneg _ := by positivity + total := by simp [ne_of_gt (show (0:ℝ)if h : i∈S then z ⟨i,h⟩ else x ⟨i,mem_compl.mpr h⟩ + +omit [Fintype β] in +lemma pasteTuple_compl (S : Finset ι) (z : S→β) (x : (Sᶜ:Finset ι)→β) (i : (Sᶜ:Finset ι)) : + pasteTuple S z x i=x i := by simp [pasteTuple,mem_compl.mp i.property] + +lemma Law.restore_restrict (p : Law (ι→β)) (S : Finset ι) (f : (ι→β)→ℝ) : + (∑ z,(p.restrict S).mass z*∑ x,((p.cond (fun y (i:S)=>y i) z).restrict Sᶜ).mass x* + f (pasteTuple S z x))=∑ y,p.mass y*f y := by + have h := p.history_sum (fun y (i:S)=>y i) f + apply Eq.trans _ h + apply sum_congr rfl + intro z _ + by_cases hz : (p.restrict S).mass z=0 + · change (p.restrict S).mass z * _=(p.restrict S).mass z * _ + rw [hz,zero_mul,zero_mul] + · congr 1 + rw [Law.restrict,Law.sum_map] + apply sum_congr rfl + intro y _ + by_cases hy : (p.cond (fun y (i:S)=>y i) z).mass y=0 + · simp only [hy,zero_mul] + · have he := (p.cond_support (fun y (i:S)=>y i) z hz y hy).2 + congr 2 + funext i + by_cases hi : i∈S + · simp only [pasteTuple,dite_eq_left hi] + exact (congrFun he ⟨i,hi⟩).symm + · simp only [pasteTuple,dite_eq_right hi] + +structure ExposureModel (ι β C : Type) [Fintype β] where + History : Type + [finiteHistory : Fintype History] + historyLaw : @Law History finiteHistory + Index : History→Type + [finiteIndex : ∀ z,Fintype (Index z)] + [decIndex : ∀ z,DecidableEq (Index z)] + tupleLaw : ∀ z,Law (Index z→β) + remaining : History→ℕ + embedding : ∀ z,C×Fin (remaining z) ↪ Index z + owner : ∀ z,Index z→Option C + origin : ∀ z,Index z↪ι + restore : ∀ z,(Index z→β)→ι→β + restore_origin : ∀ z x i,restore z x (origin z i)=x i + +attribute [instance] ExposureModel.finiteHistory ExposureModel.finiteIndex ExposureModel.decIndex + +namespace ExposureModel +variable (M : ExposureModel ι β C) + +def expectation (f : (ι→β)→ℝ) : ℝ := + ∑ z,M.historyLaw.mass z*∑ x,(M.tupleLaw z).mass x*f (M.restore z x) + +def initial (p : Law (ι→β)) {m : ℕ} (e : C×Fin m↪ι) (own : ι→Option C) : + ExposureModel ι β C where + History := Unit + finiteHistory := inferInstance + historyLaw := Law.equiprobable Unit + Index _ := ι + finiteIndex _ := inferInstance + decIndex _ := inferInstance + tupleLaw _ := p + remaining _ := m + embedding _ := e + owner _ := own + origin _ := Function.Embedding.refl ι + restore _ := id + restore_origin _ _ _ := rfl + +omit [Fintype C] in +lemma initial_expectation (p : Law (ι→β)) {m : ℕ} (e : C×Fin m↪ι) (own : ι→Option C) + (f : (ι→β)→ℝ) : (initial p e own).expectation f=∑ y,p.mass y*f y := by + change (∑ _z : Unit,(1/(Fintype.card Unit:ℝ))*(∑ x,p.mass x*f x))=_ + simp + +def join {m : ℕ} (p : Law (ι→β)) (e : C×Fin (m+1)↪ι) + (child : ∀ f : C→Fin (m+1), (freshRepresentatives e f→β)→ + ExposureModel ↥((freshRepresentatives e f)ᶜ) β C) : ExposureModel ι β C where + History := Σ f : C→Fin (m+1), Σ z : freshRepresentatives e f→β, (child f z).History + finiteHistory := inferInstance + historyLaw := (Law.equiprobable (C→Fin (m+1))).sigma (fun f=> + (p.restrict (freshRepresentatives e f)).sigma (fun z=>(child f z).historyLaw)) + Index h := (child h.1 h.2.1).Index h.2.2 + finiteIndex _ := inferInstance + decIndex _ := inferInstance + tupleLaw h := (child h.1 h.2.1).tupleLaw h.2.2 + remaining h := (child h.1 h.2.1).remaining h.2.2 + embedding h := (child h.1 h.2.1).embedding h.2.2 + owner h := (child h.1 h.2.1).owner h.2.2 + origin h := ((child h.1 h.2.1).origin h.2.2).trans (Function.Embedding.subtype _) + restore h x := pasteTuple (freshRepresentatives e h.1) h.2.1 + ((child h.1 h.2.1).restore h.2.2 x) + restore_origin h x i := by + change pasteTuple (freshRepresentatives e h.1) h.2.1 + ((child h.1 h.2.1).restore h.2.2 x) ((child h.1 h.2.1).origin h.2.2 i).val=x i + rw [pasteTuple_compl] + exact (child h.1 h.2.1).restore_origin h.2.2 x i + +lemma join_expectation {m : ℕ} (p : Law (ι→β)) (e : C×Fin (m+1)↪ι) + (child : ∀ f : C→Fin (m+1), (freshRepresentatives e f→β)→ + ExposureModel ↥((freshRepresentatives e f)ᶜ) β C) + (φ : (ι→β)→ℝ) : + (join p e child).expectation φ= + (∑ f : C→Fin (m+1),∑ z,(p.restrict (freshRepresentatives e f)).mass z* + (child f z).expectation (fun x=>φ (pasteTuple (freshRepresentatives e f) z x)))/ + Fintype.card (C→Fin (m+1)) := by + unfold expectation + change (∑ h,((Law.equiprobable (C→Fin (m+1))).sigma (fun f=> + (p.restrict (freshRepresentatives e f)).sigma (fun z=>(child f z).historyLaw))).mass h* + ∑ x,((child h.1 h.2.1).tupleLaw h.2.2).mass x* + φ (pasteTuple (freshRepresentatives e h.1) h.2.1 ((child h.1 h.2.1).restore h.2.2 x)))=_ + rw [Law.sigma_sum] + simp_rw [Law.sigma_sum] + exact Law.equiprobable_sum _ _ + +lemma join_preserves {m : ℕ} (p : Law (ι→β)) (e : C×Fin (m+1)↪ι) + (child : ∀ f : C→Fin (m+1), (freshRepresentatives e f→β)→ + ExposureModel ↥((freshRepresentatives e f)ᶜ) β C) + (hchild : ∀ f z φ,(child f z).expectation φ= + ∑ x,((p.cond (fun y (i:freshRepresentatives e f)=>y i) z).restrict + (freshRepresentatives e f)ᶜ).mass x*φ x) + (φ : (ι→β)→ℝ) : (join p e child).expectation φ=∑ y,p.mass y*φ y := by + rw [join_expectation] + simp_rw [hchild,p.restore_restrict] + rw [sum_const,card_univ,nsmul_eq_mul] + exact mul_div_cancel_left₀ _ (ne_of_gt (show (0:ℝ) Fin.elim0 j + | k+1,_,_,_,p,e,own,j => Fin.cases (initial p e own) + (fun t=>join p e (fun f z=> + atRound n k ((p.cond (fun y (i:freshRepresentatives e f)=>y i) z).restrict + (freshRepresentatives e f)ᶜ) (remainingEmbedding e f) (fun i=>own i) t)) j + +theorem atRound_preserves (n k : ℕ) {ι : Type} [Fintype ι] [DecidableEq ι] + (p : Law (ι→β)) (e : C×Fin (n+k)↪ι) (own : ι→Option C) (t : Fin k) + (φ : (ι→β)→ℝ) : (atRound n k p e own t).expectation φ=∑ y,p.mass y*φ y := by + induction k generalizing ι with + | zero => exact Fin.elim0 t + | succ k ih => + refine Fin.cases ?_ (fun j=>?_) t + · exact initial_expectation p e own φ + · apply join_preserves + intro f z ψ + exact ih _ (remainingEmbedding e f) (fun i=>own i) j ψ + +theorem atRound_remaining (n k : ℕ) {ι : Type} [Fintype ι] [DecidableEq ι] + (p : Law (ι→β)) (e : C×Fin (n+k)↪ι) (own : ι→Option C) (t : Fin k) + (z : (atRound n k p e own t).History) : + n≤(atRound n k p e own t).remaining z := by + induction k generalizing ι with + | zero => exact Fin.elim0 t + | succ k ih => + induction t using Fin.cases with + | zero => change n≤n+(k+1); omega + | succ j => exact ih _ (remainingEmbedding e z.1) (fun i=>own i) j z.2.2 + +theorem atRound_owner (n k : ℕ) {ι : Type} [Fintype ι] [DecidableEq ι] + (p : Law (ι→β)) (e : C×Fin (n+k)↪ι) (own : ι→Option C) (t : Fin k) + (z : (atRound n k p e own t).History) (i : (atRound n k p e own t).Index z) : + (atRound n k p e own t).owner z i=own ((atRound n k p e own t).origin z i) := by + induction k generalizing ι with + | zero => exact Fin.elim0 t + | succ k ih => + induction t using Fin.cases with + | zero => rfl + | succ j => exact ih _ (remainingEmbedding e z.1) (fun i=>own i) j z.2.2 i + +theorem atRound_embedding_owner (n k : ℕ) {ι : Type} [Fintype ι] [DecidableEq ι] + (p : Law (ι→β)) (e : C×Fin (n+k)↪ι) (own : ι→Option C) + (hown : ∀ b x,own (e (b,x))=some b) (t : Fin k) + (z : (atRound n k p e own t).History) (b : C) + (x : Fin ((atRound n k p e own t).remaining z)) : + (atRound n k p e own t).owner z ((atRound n k p e own t).embedding z (b,x))=some b := by + induction k generalizing ι with + | zero => exact Fin.elim0 t + | succ k ih => + induction t using Fin.cases with + | zero => exact hown b x + | succ j => + exact ih _ (remainingEmbedding e z.1) (fun i=>own i) + (remaining_own e z.1 own hown) j z.2.2 x + +theorem atRound_unowned (n k : ℕ) {ι : Type} [Fintype ι] [DecidableEq ι] + (p : Law (ι→β)) (e : C×Fin (n+k)↪ι) (own : ι→Option C) + (hown : ∀ b x,own (e (b,x))=some b) (t : Fin k) + (z : (atRound n k p e own t).History) (i : ι) (hi : own i=none) : + ∃ j,(atRound n k p e own t).origin z j=i := by + induction k generalizing ι with + | zero => exact Fin.elim0 t + | succ k ih => + induction t using Fin.cases with + | zero => exact ⟨i,rfl⟩ + | succ j => + have hn : i∉freshRepresentatives e z.1 := by + intro hh + obtain ⟨b,_,hb⟩:=mem_image.mp hh + have hh:=hown b (z.1 b) + rw [hb,hi] at hh + cases hh + obtain ⟨v,hv⟩ := ih _ (remainingEmbedding e z.1) (fun i=>own i) + (remaining_own e z.1 own hown) j z.2.2 ⟨i,mem_compl.mpr hn⟩ hi + exact ⟨v,congrArg Subtype.val hv⟩ + +end ExposureModel +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Exposure/ExposureSupport.lean b/lean/OAI/Combinatorics/SharpRamsey/Exposure/ExposureSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..1c8a8b9ca9d57990ae9fc052ab7d082fde3763d9 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Exposure/ExposureSupport.lean @@ -0,0 +1,71 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Exposure.SourceCoupling +import OAI.Combinatorics.SharpRamsey.Selection.FreshRepresentatives + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical BigOperators +noncomputable section +variable {X Ω B : Type*} [Fintype X] [Fintype Ω] [Fintype B] + +lemma Law.common_source_support (q : Law X) (p : Law Ω) (f : X→B) (g : Ω→B) + (h : q.map f=p.map g) (x : X) (hx : q.mass x≠0) : + ∃ ω,p.mass ω≠0 ∧ g ω=f x := by + have hf : (p.map g).mass (f x)≠0 := by + rw [←h] + exact ne_of_gt ((lt_of_le_of_ne (q.nonneg x) (Ne.symm hx)).trans_le (q.le_map f x)) + exact p.map_support g (f x) hf + +namespace ExposureModel +variable {β C ι Θ : Type} [Fintype β] [Fintype C] [Fintype ι] + [DecidableEq ι] [Fintype Θ] + +omit [Fintype Θ] [Fintype ι] [DecidableEq ι] in +lemma afterDraw_tagged (M : ExposureModel ι β C) (hp : ∀ z,0∑ y,(M.tupleLaw z).mass y*φ (tag z,M.restore z y)) + +theorem contextual_afterDraw_tagged_map (n k : ℕ) {Ω : Type} [Fintype Ω] + (p : Law Ω) (θ : Ω→Θ) (G : Ω→ι→β) + (e : Θ→C×Fin (n+k)↪ι) (own : Θ→ι→Option C) (t : Fin k) + (hp : ∀ z,0<(contextual n k p θ G e own t).remaining z) : + ((contextual n k p θ G e own t).afterDraw hp).joint.map + (fun x=>(x.1.1.1,((contextual n k p θ G e own t).afterDraw hp).restore x.1 x.2))= + p.map (fun ω=>(θ ω,G ω)) := by + ext y + have he:=afterDraw_tagged (contextual n k p θ G e own t) hp (fun z=>z.1) + (fun x=>if x=y then 1 else 0) + have he' := he.trans (contextual_tagged n k p θ G e own t (fun x=>if x=y then 1 else 0)) + simpa only [Law.map,sum_filter,mul_ite,mul_one,mul_zero] using he' + +theorem contextual_fresh_source (n k : ℕ) {Ω : Type} [Fintype Ω] + (p : Law Ω) (θ : Ω→Θ) (G : Ω→ι→β) + (e : Θ→C×Fin (n+k)↪ι) (own : Θ→ι→Option C) (t : Fin k) + (hp : ∀ z,0<(contextual n k p θ G e own t).remaining z) + (z : (contextual n k p θ G e own t).FreshHistory) + (hz : ((contextual n k p θ G e own t).freshLaw hp).mass z≠0) + (y : (contextual n k p θ G e own t).Index z.1→β) + (hy : ((contextual n k p θ G e own t).tupleLaw z.1).mass y≠0) : + ∃ ω,p.mass ω≠0 ∧ θ ω=z.1.1 ∧ + ∀ i,G ω ((contextual n k p θ G e own t).origin z.1 i)=y i := by + let M:=contextual n k p θ G e own t + obtain ⟨ω,hω,he⟩:=Law.common_source_support (M.afterDraw hp).joint p + (fun x=>(x.1.1.1,(M.afterDraw hp).restore x.1 x.2)) (fun ω=>(θ ω,G ω)) + (contextual_afterDraw_tagged_map n k p θ G e own t hp) ⟨z,y⟩ (mul_ne_zero hz hy) + refine ⟨ω,hω,congrArg Prod.fst he,fun i=>?_⟩ + have hh:=congrFun (congrArg Prod.snd he) (M.origin z.1 i) + exact hh.trans (M.restore_origin z.1 y i) + +end ExposureModel +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Exposure/FreshBlockBudgets.lean b/lean/OAI/Combinatorics/SharpRamsey/Exposure/FreshBlockBudgets.lean new file mode 100644 index 0000000000000000000000000000000000000000..efddf0b3ad9c5a6e2e53e24996bda6bfb37ce6f2 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Exposure/FreshBlockBudgets.lean @@ -0,0 +1,67 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Exposure.RemainingEmbedding + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical BigOperators NNReal +noncomputable section +variable {B X ι : Type*} [Fintype B] [Fintype X] [Fintype ι] [DecidableEq B] [DecidableEq ι] + +theorem selected_absorption (e : B×X ↪ ι) (M : (B→X)→ι→ℝ) + (hM : ∀ f i,0≤M f i) + (hupdate : ∀ b x f y,M (Function.update f b y) (e (b,x))=M f (e (b,x))) : + (Fintype.card X:ℝ)*(∑ f : B→X, ∑ i∈freshRepresentatives e f,M f i)≤ + ∑ f : B→X,∑ i,M f i := by + have hsel (f : B→X) : (∑ i∈freshRepresentatives e f,M f i)=∑ b,M f (e (b,f b)) := by + apply sum_image + intro b _ c _ he + exact (Prod.mk.inj (e.injective he)).1 + simp_rw [hsel] + rw [sum_comm,mul_sum] + have hb (b : B) : (Fintype.card X:ℝ)*(∑ f : B→X,M f (e (b,f b)))= + ∑ f : B→X,∑ x : X,M f (e (b,x)) := + fresh_draw_identity b (fun x f => M f (e (b,x))) (hupdate b) + simp_rw [hb] + rw [sum_comm] + apply sum_le_sum + intro f _ + have hh := sum_le_sum_of_subset_of_nonneg (s:=univ.map e) (t:=univ) + (f:=M f) (subset_univ _) (fun i _ _ => hM f i) + simpa only [sum_map,Fintype.sum_prod_type] using hh + +theorem selected_fixed_observable (e : B×X ↪ ι) (δ : ι→ℝ) (hδ : ∀ i,0≤δ i) : + (Fintype.card X:ℝ)*(∑ f : B→X, ∑ i∈freshRepresentatives e f,δ i)≤ + (Fintype.card (B→X):ℝ)*∑ i,δ i := by + simpa only [sum_const,card_univ,nsmul_eq_mul] using + selected_absorption e (fun _=>δ) (fun _=>hδ) (by intros; rfl) + +def maximumCharge (c : ι→ι→ℝ≥0) (i : ι) (J : Finset ι) : ℝ≥0 := J.sup (c i) + +omit [Fintype ι] [DecidableEq ι] in +lemma maximumCharge_le_sum (c : ι→ι→ℝ≥0) (i : ι) (J : Finset ι) : + (maximumCharge c i J:ℝ)≤∑ j∈J,(c i j:ℝ) := by + have hh : maximumCharge c i J≤∑ j∈J,c i j := by + apply Finset.sup_le + intro j hj + exact single_le_sum (fun j _ => (zero_le : (0:ℝ≥0)≤c i j)) hj + exact_mod_cast hh + +theorem selected_charge_absorption (e : B×X ↪ ι) (own : ι→Option B) + (hown : ∀ b x,own (e (b,x))=some b) (c : ι→ι→ℝ≥0) : + (Fintype.card X:ℝ)*(∑ f : B→X, ∑ i∈freshRepresentatives e f, + (maximumCharge c i (otherRepresentatives e own f i):ℝ))≤ + ∑ f : B→X,∑ i,(maximumCharge c i (otherRepresentatives e own f i):ℝ) := by + apply selected_absorption + · intros; positivity + · intro b x f y + rw [otherRepresentatives_update e own hown] + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Exposure/FreshBlockCollision.lean b/lean/OAI/Combinatorics/SharpRamsey/Exposure/FreshBlockCollision.lean new file mode 100644 index 0000000000000000000000000000000000000000..8701e773a144cea22f8141bb8191c507fb975f62 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Exposure/FreshBlockCollision.lean @@ -0,0 +1,51 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Exposure.FreshBlockBudgets + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical BigOperators NNReal +noncomputable section +variable {B X ι : Type*} [Fintype B] [Fintype X] [Fintype ι] [DecidableEq B] [DecidableEq ι] + +theorem collision_all_indices (e : B×X ↪ ι) (own : ι→Option B) (c : ι→ι→ℝ≥0) : + (Fintype.card X:ℝ)*(∑ f : B→X,∑ i, + (maximumCharge c i (otherRepresentatives e own f i):ℝ))≤ + (Fintype.card (B→X):ℝ)*∑ i,∑ j,(c i j:ℝ) := by + calc + _ ≤ (Fintype.card X:ℝ)*(∑ f : B→X,∑ i, + ∑ j∈freshRepresentatives e f,(c i j:ℝ)) := by + apply mul_le_mul_of_nonneg_left _ (Nat.cast_nonneg _) + apply sum_le_sum + intro f _ + apply sum_le_sum + intro i _ + exact (maximumCharge_le_sum c i _).trans + (sum_le_sum_of_subset_of_nonneg (otherRepresentatives_sub e own f i) + (fun j _ _ => NNReal.coe_nonneg (c i j))) + _ = ∑ i,(Fintype.card X:ℝ)*(∑ f : B→X, + ∑ j∈freshRepresentatives e f,(c i j:ℝ)) := by rw [sum_comm,mul_sum] + _ ≤ ∑ i,(Fintype.card (B→X):ℝ)*∑ j,(c i j:ℝ) := by + apply sum_le_sum + intro i _ + exact selected_fixed_observable e (fun j => (c i j:ℝ)) (fun j => (c i j).coe_nonneg) + _ = _ := by rw [mul_sum] + +theorem collision_selected_indices (e : B×X ↪ ι) (own : ι→Option B) + (hown : ∀ b x,own (e (b,x))=some b) (c : ι→ι→ℝ≥0) : + (Fintype.card X:ℝ)^2*(∑ f : B→X,∑ i∈freshRepresentatives e f, + (maximumCharge c i (otherRepresentatives e own f i):ℝ))≤ + (Fintype.card (B→X):ℝ)*∑ i,∑ j,(c i j:ℝ) := by + have hh := mul_le_mul_of_nonneg_left (selected_charge_absorption e own hown c) + (Nat.cast_nonneg (Fintype.card X) : (0:ℝ)≤Fintype.card X) + rw [← mul_assoc,←sq] at hh + exact hh.trans (collision_all_indices e own c) + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Exposure/HighRankMixture.lean b/lean/OAI/Combinatorics/SharpRamsey/Exposure/HighRankMixture.lean new file mode 100644 index 0000000000000000000000000000000000000000..049a32e831381a15fd821caae37b98b20e1ed3ca --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Exposure/HighRankMixture.lean @@ -0,0 +1,85 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.HighRankReplacement +import OAI.Combinatorics.SharpRamsey.Exposure.DominatedMixture +import OAI.Combinatorics.SharpRamsey.Selection.MixedLoss + +namespace OAI + +section +namespace SharpLogRamsey.ActualHighRank +open Finset Real Selection +open scoped Classical BigOperators +noncomputable section + +structure StreamReplacement {Ω F ι Γ : Type} [Fintype Ω] [Fintype F] [Fintype Γ] + (p : Law Ω) (G : Ω→ι→F) (pos : ι→ℕ) (m : ℕ) (DD : Γ→Finset F) (B C : ℝ) where + X : Type + finiteX : Fintype X + μ : @Law X finiteX + source : X→Ω + msg : X→Γ + index : X→Fin m→ι + ordered : ∀ x,StrictMono (fun i=>pos (index x i)) + supported : ∀ x,μ.mass x≠0→p.mass (source x)≠0 + hit : ∀ x,μ.mass x≠0→∀ i,G (source x) (index x i)∈DD (msg x) + size : ∀ x,((DD (msg x)).card:ℝ)≤B + dominated : letI:=finiteX; ∀ a,(μ.map source).mass a≤4*p.mass a + cost : letI:=finiteX; entropy (μ.map msg)≤C +attribute [instance] StreamReplacement.finiteX + +variable {Ω F ι Γ Z : Type} [Fintype Ω] [Fintype F] [Fintype ι] [Fintype Γ] [Fintype Z] + +omit [Fintype ι] in + +theorem mix_stream_replacement [Fintype (ι→F)] + (p : Law Ω) (G : Ω→ι→F) (pos : ι→ℕ) + (μ : Law Z) (Q : Z→Type) [∀ z,Fintype (Q z)] (q : ∀ z,Law (Q z)) + (restore : ∀ z,Q z→ι→F) + (hrestore : (μ.sigma q).map (fun z=>restore z.1 z.2)=p.map G) + (H : Finset Z) (hH : (1:ℝ)/2≤μ.event H) + (ℓ : H→ℕ) (target : ∀ z,Q z.val→Fin (ℓ z)→F) + (loc : ∀ z,Fin (ℓ z)→ι) + (hloc : ∀ z,StrictMono (fun i=>pos (loc z i))) + (hvalue : ∀ z y i,restore z.val y (loc z i)=target z y i) + (m : ℕ) (hm : ∀ z,m≤ℓ z/2) (DD : Γ→Finset F) (B C : ℝ) + (e : ∀ z,Replacement (q z.val) (target z) DD B C) + (hcost : ∀ (Y : Type) [Fintype Y] (ν : Law Y) (msg : Y→Γ),entropy (ν.map msg)≤C) : + Nonempty (StreamReplacement p G pos m DD B C) := by + let X : H→Type:=fun z=>(e z).Ω + let ν : ∀ z,Law (X z):=fun z=>(e z).μ + let f : ∀ z,X z→Q z.val:=fun z=>(e z).source + let ρ:=(μ.onEvent H (lt_of_lt_of_le (by norm_num : (0:ℝ)<1/2) hH)).sigma ν + let F0:=fun x : Σ z : H,X z=>restore x.1.val (f x.1 x.2) + have hd : ∀ y,(ρ.map F0).mass y≤4*(p.map G).mass y := by + intro y + have hh:=μ.dominated_history_map H hH Q q X ν f 2 (by norm_num) + (fun z=>(e z).dominated) restore y + rw [hrestore] at hh + simpa only [show (2:ℝ)*2=4 by norm_num] using hh + let τ:=ρ.attach p F0 G + let msg:=fun x : Σ _x : (Σ z : H,X z),Ω=>(e x.1.1).msg x.1.2 + let idx:=fun x : Σ _x : (Σ z : H,X z),Ω=>fun i : Fin m=> + loc x.1.1 ((e x.1.1).chosen x.1.2 (Fin.castLE (hm x.1.1) i)) + refine ⟨⟨_,inferInstance,τ,(fun x=>x.2),msg,idx,?_,?_,?_,?_,?_,hcost _ τ msg⟩⟩ + · intro x i j hij + exact hloc x.1.1 ((e x.1.1).chosen x.1.2|>.strictMono hij) + · intro x hx + exact (ρ.attach_support_of_dominated p F0 G 4 hd x hx).2.1 + · intro x hx i + have hh:=ρ.attach_support_of_dominated p F0 G 4 hd x hx + have he:=congrFun hh.2.2 (idx x i) + rw [he] + change restore x.1.1.val (f x.1.1 x.1.2) + (loc x.1.1 ((e x.1.1).chosen x.1.2 (Fin.castLE (hm x.1.1) i)))∈_ + rw [hvalue] + exact (e x.1.1).hit x.1.2 _ + · intro x + exact (e x.1.1).size x.1.2 + · intro x + exact ρ.attach_map_source_le p F0 G 4 hd x +end +end SharpLogRamsey.ActualHighRank + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Exposure/MixtureRealization.lean b/lean/OAI/Combinatorics/SharpRamsey/Exposure/MixtureRealization.lean new file mode 100644 index 0000000000000000000000000000000000000000..322e2990afffa200076ef6f34d1afe56a62d1ed7 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Exposure/MixtureRealization.lean @@ -0,0 +1,113 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.GoodRealization + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical BigOperators +noncomputable section +variable {A B : Type*} [Fintype A] [Fintype B] +lemma Law.eq_of_integrals (p q : Law A) + (h : ∀ f : A→ℝ,(∑ a,p.mass a*f a)=∑ a,q.mass a*f a) : p=q := by + ext a + simpa using h (fun x=>if x=a then 1 else 0) +end +end SharpLogRamsey.Selection + +namespace SharpLogRamsey.ActualPivot +open Finset Selection +open scoped Classical BigOperators +noncomputable section +variable {K V I Y₀ : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + {d : ℕ} {b : ℝ} [Fintype Y₀] + +omit [Finite K] [FiniteDimensional K V] [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K V))] in +lemma Realization.integral {q : Law Y₀} (e : Realization (K:=K) (V:=V) (I:=I) (d:=d) (b:=b) q) + (f : Y₀→ℝ) : (∑ ω,e.μ.mass ω*f (e.source ω))=∑ y,q.mass y*f y := by + rw [←e.μ.sum_map e.source f,e.marginal] + +variable {Θ : Type} [Fintype Θ] {Y : Θ→Type} [∀ θ,Fintype (Y θ)] + +def Realization.mix (ν : Law Θ) (q : ∀ θ,Law (Y θ)) + (e : ∀ θ : {θ // ν.mass θ≠0},Realization (K:=K) (V:=V) (I:=I) (d:=d) (b:=b) (q θ)) : + Realization (K:=K) (V:=V) (I:=I) (d:=d) (b:=b) (ν.sigma q) where + Ω := Σ θ : {θ // ν.mass θ≠0},(e θ).Ω + inst := inferInstance + μ := ν.nullFree.sigma (fun θ=>(e θ).μ) + source ω := ⟨ω.1.val,(e ω.1).source ω.2⟩ + supports ω := (e ω.1).supports ω.2 + marginal := by + apply Law.eq_of_integrals + intro f + rw [Law.sum_map,Law.sigma_sum,Law.sigma_sum] + calc + _ = ∑ z,ν.nullFree.mass z*∑ y,(q z).mass y*f ⟨z.val,y⟩ := by + apply sum_congr rfl + intro z _ + congr 1 + exact (e z).integral (fun y=>f ⟨z.val,y⟩) + _ = _ := ν.nullFree_integral (fun θ=>∑ y,(q θ).mass y*f ⟨θ,y⟩) + +def Realization.attach {Ω B : Type} [Fintype Ω] [Fintype B] + {q : Law Y₀} (e : Realization (K:=K) (V:=V) (I:=I) (d:=d) (b:=b) q) + (p : Law Ω) (tag : Y₀→B) (g : Ω→B) + (h : q.map tag=p.map g) : + Realization (K:=K) (V:=V) (I:=I) (d:=d) (b:=b) p where + Ω := Σ _x : e.Ω,Ω + inst := inferInstance + μ := e.μ.attach p (tag∘e.source) g + source ω := ω.2 + supports ω := e.supports ω.1 + marginal := by + apply Law.eq_of_integrals + intro f + rw [Law.sum_map] + apply Law.attach_source + rw [←Law.map_map,e.marginal,h] + +omit [Finite K] [FiniteDimensional K V] [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K V))] in +lemma Realization.attach_agrees {Ω B : Type} [Fintype Ω] [Fintype B] + {q : Law Y₀} (e : Realization (K:=K) (V:=V) (I:=I) (d:=d) (b:=b) q) + (p : Law Ω) (tag : Y₀→B) (g : Ω→B) (h : q.map tag=p.map g) + (ω : (e.attach p tag g h).Ω) (hω : (e.attach p tag g h).μ.mass ω≠0) : + e.μ.mass ω.1≠0 ∧ p.mass ω.2≠0 ∧ g ω.2=tag (e.source ω.1) := by + apply Law.attach_support e.μ p (tag∘e.source) g _ ω hω + rw [←Law.map_map,e.marginal,h] +end +end SharpLogRamsey.ActualPivot + +namespace SharpLogRamsey.Selection.ExposureModel +open Finset +open scoped Classical BigOperators +noncomputable section +variable {β C ι Θ Ω : Type} [Fintype β] [Fintype C] [Fintype ι] + [DecidableEq ι] [Fintype Θ] [Fintype Ω] + +lemma afterDraw_tagged_map (n k : ℕ) (p : Law Ω) (θ : Ω→Θ) + (G : Ω→ι→β) (e : Θ→C×Fin (n+k)↪ι) (own : Θ→ι→Option C) (t : Fin k) + (hp : ∀ z,0<(contextual n k p θ G e own t).remaining z) : + ((contextual n k p θ G e own t).afterDraw hp).joint.map + (fun x=>(x.1.1.1,(contextual n k p θ G e own t).restore x.1.1 x.2))= + p.map (fun ω=>(θ ω,G ω)) := by + rw [←contextual_tagged_map n k p θ G e own t] + apply Law.eq_of_integrals + intro f + rw [Law.sum_map,Law.sum_map] + let M:=contextual n k p θ G e own t + change (∑ x,((M.freshLaw hp).sigma (fun z=>M.tupleLaw z.1)).mass x* + f (x.1.1.1,M.restore x.1.1 x.2))= + ∑ x,(M.historyLaw.sigma M.tupleLaw).mass x*f (x.1.1,M.restore x.1 x.2) + rw [Law.sigma_sum,Law.sigma_sum] + exact M.freshLaw_old hp (fun z=>∑ y,(M.tupleLaw z).mass y*f (z.1,M.restore z y)) +end +end SharpLogRamsey.Selection.ExposureModel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Exposure/PreparedMixture.lean b/lean/OAI/Combinatorics/SharpRamsey/Exposure/PreparedMixture.lean new file mode 100644 index 0000000000000000000000000000000000000000..0243c2807997d9ef3e9dcd068636e3aedf07a5fb --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Exposure/PreparedMixture.lean @@ -0,0 +1,84 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Selection.MixedLoss +import OAI.Combinatorics.SharpRamsey.Selection.PredeletionMean + +namespace OAI + +section +namespace SharpLogRamsey.Selection.Windows +open Finset ExposureModel ActualPivot +open scoped Classical BigOperators +noncomputable section +variable {K V Ω Θ : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype Ω] [Fintype Θ] {d : ℕ} {b : ℝ} +variable (w n k : ℕ) (p : Law Ω) (θ : Ω→Θ) + (G : Ω→Slot w (n+k)→Projectivization K (Module.Dual K V)×Projectivization K V) (t : Fin k) +local instance mixBlockDec : DecidableEq (Block w) := Classical.decEq _ +variable (hp : ∀ z,0<(model w n k p θ G t).remaining z) +local notation "M" => model w n k p θ G t + +abbrev PositiveHistory := {z : (M).FreshHistory // ((M).freshLaw hp).mass z≠0} + +variable (e : ∀ z : PositiveHistory w n k p θ G t hp, + Realization (K:=K) (V:=V) (I:=Fin w) (d:=d) (b:=b) (ExposureModel.tupleLaw (model w n k p θ G t) (Sigma.fst (Subtype.val z)))) + +def mixedPrepared := Realization.mix (K:=K) (V:=V) (I:=Fin w) (d:=d) (b:=b) ((M).freshLaw hp) (fun z=>(M).tupleLaw z.1) e + +def attachedPrepared := + (mixedPrepared w n k p θ G t hp e).attach p + (fun x=>(x.1.1.1,(M).restore x.1.1 x.2)) (fun ω=>(θ ω,G ω)) + (afterDraw_tagged_map n k p θ G (fun _=>embedding w (n+k)) (fun _=>owner w (n+k)) t hp) + +omit [Finite K] [FiniteDimensional K V] in +lemma attachedPrepared_tuple (ω : (attachedPrepared w n k p θ G t hp e).Ω) + (hω : (attachedPrepared w n k p θ G t hp e).μ.mass ω≠0) : + p.mass ω.2≠0 ∧ θ ω.2=ω.1.1.val.1.1 ∧ + ∀ i,G ω.2 ((M).origin ω.1.1.val.1 i)=(e ω.1.1).source ω.1.2 i := by + have hh:=(mixedPrepared w n k p θ G t hp e).attach_agrees p + (fun x=>(x.1.1.1,(M).restore x.1.1 x.2)) (fun ω=>(θ ω,G ω)) + (afterDraw_tagged_map n k p θ G (fun _=>embedding w (n+k)) (fun _=>owner w (n+k)) t hp) ω hω + refine ⟨hh.2.1,congrArg Prod.fst hh.2.2,?_⟩ + intro i + have he:=congrFun (congrArg Prod.snd hh.2.2) ((M).origin ω.1.1.val.1 i) + exact he.trans ((M).restore_origin ω.1.1.val.1 ((e ω.1.1).source ω.1.2) i) + +omit [Finite K] [FiniteDimensional K V] in +lemma attachedPrepared_original (f : Ω→ℝ) : + (∑ ω,(attachedPrepared w n k p θ G t hp e).μ.mass ω*f ω.2)=∑ x,p.mass x*f x := + (attachedPrepared w n k p θ G t hp e).integral f + +omit [Finite K] [FiniteDimensional K V] in +lemma attachedPrepared_left (f : (mixedPrepared w n k p θ G t hp e).Ω→ℝ) : + (∑ ω,(attachedPrepared w n k p θ G t hp e).μ.mass ω*f ω.1)= + ∑ x,(mixedPrepared w n k p θ G t hp e).μ.mass x*f x := + Law.attach_left _ _ _ _ _ + +omit [Finite K] [FiniteDimensional K V] in +theorem attachedPrepared_loss {A : Type} [Fintype A] (ρ : Law A) + (N : ℕ) (pop : (M).FreshHistory→ℕ) + (out : A→(mixedPrepared w n k p θ G t hp e).Ω→ℕ) (δ B : ℝ) (hδ : 0≤δ) + (hsize : ∀ z,pop z≤N) + (hlocal : ∀ z,(∑ a,ρ.mass a*∑ y,(e z).μ.mass y* + ((pop z.val:ℝ)-(out a ⟨z,y⟩:ℝ)))≤(pop z.val:ℝ)*δ) + (hdelete : (∑ z,((M).freshLaw hp).mass z*((N:ℝ)-(pop z:ℝ)))≤B) : + (∑ a,ρ.mass a*∑ ω,(attachedPrepared w n k p θ G t hp e).μ.mass ω* + ((N:ℝ)-(out a ω.1:ℝ)))≤B+(N:ℝ)*δ := by + have heq : (∑ a,ρ.mass a*∑ ω,(attachedPrepared w n k p θ G t hp e).μ.mass ω* + ((N:ℝ)-(out a ω.1:ℝ)))= + ∑ a,ρ.mass a*∑ y,(mixedPrepared w n k p θ G t hp e).μ.mass y* + ((N:ℝ)-(out a y:ℝ)) := by + apply sum_congr rfl + intro a _ + congr 1 + exact attachedPrepared_left w n k p θ G t hp e (fun y=>(N:ℝ)-(out a y:ℝ)) + rw [heq] + exact (Law.mixed_loss ((M).freshLaw hp) (fun z=>(e z).μ) ρ N pop out δ hδ hsize hlocal).trans + (add_le_add hdelete le_rfl) +end +end SharpLogRamsey.Selection.Windows + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Exposure/RemainingEmbedding.lean b/lean/OAI/Combinatorics/SharpRamsey/Exposure/RemainingEmbedding.lean new file mode 100644 index 0000000000000000000000000000000000000000..50b83a66332d03d7160344513be7d66e9fc8cb18 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Exposure/RemainingEmbedding.lean @@ -0,0 +1,413 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Exposure.DivergenceMap + +namespace OAI + +/-! Entropy and counting bounds for selected coordinates in finite probability laws. -/ + +section +open scoped BigOperators +open Finset +open scoped Classical +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical +noncomputable section +variable {B β ι : Type*} [Fintype B] [Fintype β] [Fintype ι] [DecidableEq ι] [DecidableEq B] +def remainingEmbedding {m : ℕ} (e : B×Fin (m+1) ↪ ι) (f : B → Fin (m+1)) : + B×Fin m ↪ ↥((freshRepresentatives e f)ᶜ) where + toFun z := ⟨e (z.1,(f z.1).succAbove z.2), by + simp only [mem_compl, freshRepresentatives, mem_image, mem_univ,true_and,not_exists] + intro b hb + have he := e.injective hb + have hb' : b=z.1 := (Prod.mk.inj he).1 + subst b + exact Fin.succAbove_ne (f z.1) z.2 (Prod.mk.inj he).2.symm⟩ + inj' := by + intro z w h + have he := e.injective (congrArg Subtype.val h) + obtain ⟨hb,hx⟩ := Prod.mk.inj he + obtain ⟨b,x⟩ := z + obtain ⟨c,y⟩ := w + dsimp at hb hx + subst c + congr 1 + exact Fin.succAbove_right_injective hx + +omit [DecidableEq B] in +lemma remaining_own {m : ℕ} (e : B×Fin (m+1) ↪ ι) (f : B → Fin (m+1)) + (own : ι → Option B) (hown : ∀ b x,own (e (b,x))= some b) (b : B) (x : Fin m) : + own (remainingEmbedding e f (b,x))= some b := hown _ _ + +def roundInformation {m : ℕ} (p : Law (ι → β)) (e : B×Fin m ↪ ι) (own : ι → Option B) : ℝ := + (∑ f : B → Fin m, ∑ i, (maximumInformation p i (otherRepresentatives e own f i):ℝ))/ + Fintype.card (B → Fin m) + +def nextPotential {m : ℕ} (p : Law (ι → β)) (e : B×Fin m ↪ ι) : ℝ := + (∑ f : B → Fin m, ∑ z, (p.restrict (freshRepresentatives e f)).mass z* + totalCorrelation ((p.cond (fun x (j:freshRepresentatives e f) => x j) z).restrict + (freshRepresentatives e f)ᶜ))/Fintype.card (B → Fin m) + +lemma roundInformation_nonneg {m : ℕ} (p : Law (ι → β)) (e : B×Fin m ↪ ι) (own : ι → Option B) : + 0 ≤ roundInformation p e own := by + unfold roundInformation + positivity + +lemma nextPotential_nonneg {m : ℕ} (p : Law (ι → β)) (e : B×Fin m ↪ ι) : + 0 ≤ nextPotential p e := by + apply div_nonneg _ (Nat.cast_nonneg _) + exact sum_nonneg (fun f _ => sum_nonneg (fun z _ => + mul_nonneg ((p.restrict _).nonneg z) (totalCorrelation_nonneg _))) + +theorem roundInformation_budget {m : ℕ} (hm : 2 ≤ m) (p : Law (ι → β)) + (e : B×Fin m ↪ ι) (own : ι → Option B) (hown : ∀ b x,own (e (b,x))= some b) : + roundInformation p e own+2*nextPotential p e ≤ 2*totalCorrelation p := by + have hm0 : 0 < m := by omega + have hm' : (2:ℝ) ≤ m := by exact_mod_cast hm + have hmpos : (0:ℝ) < m := by positivity + let : Nonempty (Fin m) := ⟨⟨0,hm0⟩⟩ + have hc : (0:ℝ) Fin.elim0 j + | k+1, _, _, _, p, e, own, j => Fin.cases (roundInformation p e own) + (fun t => (∑ f : B → Fin (n+k+1), + ∑ z, (p.restrict (freshRepresentatives e f)).mass z * + exposureScores n k + ((p.cond (fun x (i : freshRepresentatives e f) => x i) z).restrict + (freshRepresentatives e f)ᶜ) + (remainingEmbedding e f) (fun i => own i) t) / + Fintype.card (B → Fin (n+k+1))) j + +lemma exposureScores_zero {ι : Type u} [Fintype ι] [DecidableEq ι] (n k : ℕ) + (p : Law (ι → β)) (e : B × Fin (n+(k+1)) ↪ ι) (own : ι → Option B) : + exposureScores n (k+1) p e own 0 = roundInformation p e own := rfl + +lemma exposureScores_succ {ι : Type u} [Fintype ι] [DecidableEq ι] (n k : ℕ) + (p : Law (ι → β)) (e : B × Fin (n+(k+1)) ↪ ι) (own : ι → Option B) (j : Fin k) : + exposureScores n (k+1) p e own j.succ = + (∑ f : B → Fin (n+k+1), ∑ z, + (p.restrict (freshRepresentatives e f)).mass z * + exposureScores n k + ((p.cond (fun x (i : freshRepresentatives e f) => x i) z).restrict + (freshRepresentatives e f)ᶜ) + (remainingEmbedding e f) (fun i => own i) j) / + Fintype.card (B → Fin (n+k+1)) := rfl + +theorem exposureScores_sum_le (n k : ℕ) (hn : 2 ≤ n) + {ι : Type u} [Fintype ι] [DecidableEq ι] (p : Law (ι → β)) (e : B × Fin (n+k) ↪ ι) + (own : ι → Option B) (hown : ∀ b x, own (e (b,x)) = some b) : + (∑ t, exposureScores n k p e own t) ≤ 2 * totalCorrelation p := by + induction k generalizing ι with + | zero => + simpa using mul_nonneg (by norm_num : (0:ℝ) ≤ 2) (totalCorrelation_nonneg p) + | succ k ih => + rw [Fin.sum_univ_succ, exposureScores_zero] + have hs : (∑ t : Fin k, exposureScores n (k+1) p e own t.succ) ≤ + 2 * nextPotential p e := by + simp_rw [exposureScores_succ, ← sum_div] + rw [sum_comm] + simp_rw [sum_comm (s := (univ : Finset (Fin k))), ← mul_sum] + unfold nextPotential + rw [← mul_div_assoc] + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) + rw [mul_sum] + apply sum_le_sum + intro f _ + rw [mul_sum] + apply sum_le_sum + intro z _ + rw [mul_left_comm (2:ℝ)] + apply mul_le_mul_of_nonneg_left _ ((p.restrict _).nonneg z) + exact ih _ (remainingEmbedding e f) (fun i => own i) + (fun b x => remaining_own e f own hown b x) + have hb := roundInformation_budget (by omega : 2 ≤ n+(k+1)) p e own hown + linarith only [hs,hb] + +end +end SharpLogRamsey.Selection + +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical +noncomputable section +universe u v w +variable {B : Type v} {β : Type w} [Fintype B] [Fintype β] + +theorem exists_exposure_round (n k : ℕ) (hn : 2 ≤ n) (hk : 0 < k) + {ι : Type u} [Fintype ι] [DecidableEq ι] (p : Law (ι → β)) + (e : B × Fin (n+k) ↪ ι) (own : ι → Option B) + (hown : ∀ b x, own (e (b,x)) = some b) : + ∃ t : Fin k, exposureScores n k p e own t ≤ 2 * totalCorrelation p / k := by + have hk' : (0:ℝ) < k := by exact_mod_cast hk + let : Nonempty (Fin k) := ⟨⟨0,hk⟩⟩ + have hs := exposureScores_sum_le n k hn p e own hown + have hconst : (∑ _t : Fin k, 2 * totalCorrelation p / (k:ℝ)) = + 2 * totalCorrelation p := by + simp only [sum_const, card_univ, Fintype.card_fin, nsmul_eq_mul] + field_simp + obtain ⟨t,_, ht⟩ := exists_le_of_sum_le (univ_nonempty : (univ : Finset (Fin k)).Nonempty) + (hs.trans_eq hconst.symm) + exact ⟨t,ht⟩ +end +end SharpLogRamsey.Selection +namespace SharpLogRamsey.Selection +open Finset +open scoped BigOperators Classical +noncomputable section +variable {ι β : Type*} [Fintype ι] [DecidableEq ι] [Fintype β] + +def tupleDeficit (J : ℝ) (p : Law (ι → β)) : ℝ := + (Fintype.card ι:ℝ)*J-entropy p + +lemma marginal_deficit_sum (p : Law (ι → β)) (J : ℝ) : + (∑ i, (J-entropy (p.marginal i))) ≤ tupleDeficit J p := by + have h := entropy_subadditive_pi p + simp only [tupleDeficit,sum_sub_distrib,sum_const,card_univ,nsmul_eq_mul] + linarith + +lemma tupleDeficit_nonneg (p : Law (ι → β)) (J : ℝ) + (h : ∀ i, entropy (p.marginal i) ≤ J) : 0 ≤ tupleDeficit J p := by + exact (sum_nonneg (fun i _ => sub_nonneg.mpr (h i))).trans (marginal_deficit_sum p J) + +theorem tupleDeficit_drop (p : Law (ι → β)) (E : Finset ι) (J : ℝ) : + tupleDeficit J p - ∑ z, (p.restrict E).mass z * + tupleDeficit J ((p.cond (fun x (i:E) => x i) z).restrict Eᶜ) = + tupleDeficit J (p.restrict E) := by + have hc := entropy_restrict_chain p E + have hn : (Fintype.card ι:ℝ) = (Fintype.card E:ℝ)+Fintype.card ↥(Eᶜ) := by + simp only [Fintype.card_coe] + exact_mod_cast (card_add_card_compl E).symm + simp only [tupleDeficit,mul_sub,sum_sub_distrib,← sum_mul,Law.total,one_mul] + rw [hn] + linarith + +lemma tupleDeficit_expected_le (p : Law (ι → β)) (E : Finset ι) (J : ℝ) + (h : ∀ i, entropy (p.marginal i) ≤ J) : + (∑ z, (p.restrict E).mass z * + tupleDeficit J ((p.cond (fun x (i:E) => x i) z).restrict Eᶜ)) ≤ tupleDeficit J p := by + have he := tupleDeficit_nonneg (p.restrict E) J (fun i => by + simpa only [Law.marginal_restrict] using h i) + have hd := tupleDeficit_drop p E J + linarith + +theorem tupleDeficit_restrict_le (p : Law (ι → β)) (E : Finset ι) (J : ℝ) + (h : ∀ i, entropy (p.marginal i) ≤ J) : + tupleDeficit J (p.restrict E) ≤ tupleDeficit J p := by + let F := fun x : ι → β => ((fun i : E => x i),(fun i : ↥(Eᶜ) => x i)) + have hf : Function.Injective F := by + intro x y hxy + funext i + by_cases hi : i ∈ E + · exact congr_fun (congrArg Prod.fst hxy) ⟨i,hi⟩ + · exact congr_fun (congrArg Prod.snd hxy) ⟨i,by simpa using hi⟩ + have he : (p.map F).fst = p.restrict E := by rw [← Law.map_fst,Law.map_map]; rfl + have he' : (p.map F).snd = p.restrict Eᶜ := by rw [← Law.map_snd,Law.map_map]; rfl + have hh := entropy_subadditive (p.map F) + rw [entropy_map_eq_of_injective p F hf,he,he'] at hh + have hcap := tupleDeficit_nonneg (p.restrict Eᶜ) J (fun i => by + simpa only [Law.marginal_restrict] using h i) + have hn : (Fintype.card ι:ℝ) = (Fintype.card E:ℝ)+Fintype.card ↥(Eᶜ) := by + simp only [Fintype.card_coe] + exact_mod_cast (card_add_card_compl E).symm + unfold tupleDeficit at hcap ⊢ + rw [hn] + linarith + +lemma totalCorrelation_le_tupleDeficit (p : Law (ι → β)) (J : ℝ) + (h : ∀ i, entropy (p.marginal i) ≤ J) : totalCorrelation p ≤ tupleDeficit J p := by + have hs := sum_le_sum (fun i (_ : i ∈ univ) => h i) + simp only [sum_const,card_univ,nsmul_eq_mul] at hs + unfold totalCorrelation tupleDeficit + linarith + +end +end SharpLogRamsey.Selection +namespace SharpLogRamsey.Selection +variable {Ω α Γ A : Type*} [Fintype Ω] [Fintype α] [Fintype Γ] [Fintype A] +theorem entropy_le_log_card (p : Law α) (S : Finset α) + (hs : ∀ a, a ∉ S → p.mass a = 0) : entropy p ≤ Real.log S.card := by + have hS : 0 < S.card := by + by_contra! h + have hz : S = ∅ := card_eq_zero.mp (by omega) + have hzero : ∑ a, p.mass a = 0 := by + apply sum_eq_zero + intro a ha + exact hs a (by simp [hz]) + linarith [p.total] + have hsr : (0:ℝ) < S.card := by exact_mod_cast hS + have hmass : ∑ a ∈ S, p.mass a = 1 := by + rw [← p.total] + exact sum_subset (subset_univ S) fun a ha hna => hs a hna + have h := log_sum S p.mass (fun _ => 1/(S.card:ℝ)) + (fun a ha => p.nonneg a) (fun a ha => by positivity) + (fun a ha hh => False.elim ((div_ne_zero (by norm_num) hsr.ne') hh)) + rw [hmass] at h + have hc : ∑ _a ∈ S, (1/(S.card:ℝ)) = 1 := by + simp only [sum_const, nsmul_eq_mul] + field_simp + rw [hc,div_one,Real.log_one,mul_zero] at h + have he (a : α) : p.mass a*Real.log (p.mass a/(1/(S.card:ℝ))) = + p.mass a*Real.log (p.mass a)+p.mass a*Real.log S.card := by + by_cases hz : p.mass a = 0 + · simp [hz] + rw [div_div_eq_mul_div, div_one, Real.log_mul hz hsr.ne'] + ring + simp_rw [he] at h + rw [sum_add_distrib, ← sum_mul, hmass,one_mul] at h + have hh : ∑ a ∈ S, p.mass a*Real.log (p.mass a) = + ∑ a, p.mass a*Real.log (p.mass a) := by + exact sum_subset (subset_univ S) fun a ha hna => by rw [hs a hna,zero_mul] + rw [hh] at h + unfold entropy + linarith + +lemma Law.map_support (p : Law Ω) (f : Ω → A) (a : A) (ha : (p.map f).mass a ≠ 0) : + ∃ x, p.mass x ≠ 0 ∧ f x = a := by + by_contra hn + push Not at hn + apply ha + change (∑ x with f x = a, p.mass x) = 0 + apply sum_eq_zero + intro x hx + by_contra hp + exact hn x hp (mem_filter.mp hx).2 + +lemma Law.cond_support (p : Law Ω) (C : Ω → Γ) (c : Γ) + (hc : (p.map C).mass c ≠ 0) (x : Ω) (hx : (p.cond C c).mass x ≠ 0) : + p.mass x ≠ 0 ∧ C x = c := by + rw [p.cond_mass C c hc] at hx + split_ifs at hx with he + · exact ⟨(div_ne_zero_iff.mp hx).1,he⟩ + · exact False.elim (hx (zero_div _)) + +lemma entropy_mapped_support (p : Law Ω) (F : Ω → α) (S : Finset α) + (hS : ∀ x, p.mass x ≠ 0 → F x ∈ S) : entropy (p.map F) ≤ Real.log S.card := by + apply entropy_le_log_card + intro a ha + by_contra hn + obtain ⟨x,hx,rfl⟩ := p.map_support F a hn + exact ha (hS x hx) + +end SharpLogRamsey.Selection +namespace SharpLogRamsey.Selection +open Finset +open scoped BigOperators Classical +noncomputable section +variable {ι β : Type*} [Fintype ι] [DecidableEq ι] [Fintype β] + +def tupleSupported (p : Law (ι → β)) (D : ι → Finset β) : Prop := + ∀ x, p.mass x ≠ 0 → ∀ i, x i ∈ D i + +lemma tupleSupported_marginal_cap (p : Law (ι → β)) (D : ι → Finset β) + (hD : tupleSupported p D) (J : ℝ) (hJ : ∀ i, Real.log (D i).card ≤ J) (i : ι) : + entropy (p.marginal i) ≤ J := + (entropy_mapped_support p (fun x => x i) (D i) (fun x hx => hD x hx i)).trans (hJ i) + +lemma tupleSupported_cond_restrict (p : Law (ι → β)) (D : ι → Finset β) + (hD : tupleSupported p D) (E : Finset ι) (z : E → β) + (hz : (p.restrict E).mass z ≠ 0) : + tupleSupported ((p.cond (fun x (i:E) => x i) z).restrict Eᶜ) (fun i => D i) := by + intro x hx i + obtain ⟨y,hy,rfl⟩ := (p.cond (fun x (i:E) => x i) z).map_support _ x hx + exact hD y ((p.cond_support (fun x (i:E) => x i) z hz y hy).1) i + +end +end SharpLogRamsey.Selection +namespace SharpLogRamsey.Selection +open Finset +open scoped BigOperators Classical +noncomputable section +universe u v w +variable {B : Type v} {β : Type w} [Fintype B] [Fintype β] + +def exposureDeficits (n : ℕ) (J : ℝ) : (k : ℕ) → {ι : Type u} → [Fintype ι] → + [DecidableEq ι] → Law (ι → β) → (B × Fin (n+k) ↪ ι) → Fin k → ℝ + | 0, _, _, _, _, _, j => Fin.elim0 j + | k+1, _, _, _, p, e, j => Fin.cases (tupleDeficit J p) + (fun t => (∑ f : B → Fin (n+k+1), + ∑ z, (p.restrict (freshRepresentatives e f)).mass z * + exposureDeficits n J k + ((p.cond (fun x (i : freshRepresentatives e f) => x i) z).restrict + (freshRepresentatives e f)ᶜ) + (remainingEmbedding e f) t) / + Fintype.card (B → Fin (n+k+1))) j + +lemma exposureDeficits_zero (n k : ℕ) (J : ℝ) {ι : Type u} [Fintype ι] [DecidableEq ι] + (p : Law (ι → β)) (e : B × Fin (n+(k+1)) ↪ ι) : + exposureDeficits n J (k+1) p e 0 = tupleDeficit J p := rfl + +lemma exposureDeficits_succ (n k : ℕ) (J : ℝ) {ι : Type u} [Fintype ι] [DecidableEq ι] + (p : Law (ι → β)) (e : B × Fin (n+(k+1)) ↪ ι) (j : Fin k) : + exposureDeficits n J (k+1) p e j.succ = + (∑ f : B → Fin (n+k+1), ∑ z, + (p.restrict (freshRepresentatives e f)).mass z * + exposureDeficits n J k + ((p.cond (fun x (i : freshRepresentatives e f) => x i) z).restrict + (freshRepresentatives e f)ᶜ) + (remainingEmbedding e f) j) / Fintype.card (B → Fin (n+k+1)) := rfl + +theorem exposureDeficits_le (n k : ℕ) (J : ℝ) {ι : Type u} [Fintype ι] [DecidableEq ι] + (p : Law (ι → β)) (e : B × Fin (n+k) ↪ ι) (D : ι → Finset β) + (hD : tupleSupported p D) (hJ : ∀ i, Real.log (D i).card ≤ J) (t : Fin k) : + exposureDeficits n J k p e t ≤ tupleDeficit J p := by + induction k generalizing ι with + | zero => exact Fin.elim0 t + | succ k ih => + refine Fin.cases ?_ (fun j => ?_) t + · exact le_rfl + · rw [exposureDeficits_succ] + have hn : (0:ℝ) < Fintype.card (B → Fin (n+k+1)) := by + let : Nonempty (Fin (n+k+1)) := ⟨⟨0,by omega⟩⟩ + exact_mod_cast Fintype.card_pos + apply (div_le_iff₀ hn).mpr + calc + _ ≤ ∑ f : B → Fin (n+k+1), ∑ z, + (p.restrict (freshRepresentatives e f)).mass z * + tupleDeficit J ((p.cond (fun x (i : freshRepresentatives e f) => x i) z).restrict + (freshRepresentatives e f)ᶜ) := by + apply sum_le_sum + intro f _ + apply sum_le_sum + intro z _ + by_cases hz : (p.restrict (freshRepresentatives e f)).mass z = 0 + · rw [hz,zero_mul,zero_mul] + · apply mul_le_mul_of_nonneg_left _ ((p.restrict _).nonneg z) + exact ih _ (remainingEmbedding e f) (fun i => D i) + (tupleSupported_cond_restrict p D hD _ z hz) (fun i => hJ i) j + _ ≤ ∑ _f : B → Fin (n+k+1), tupleDeficit J p := by + apply sum_le_sum + intro f _ + exact tupleDeficit_expected_le p _ J (tupleSupported_marginal_cap p D hD J hJ) + _ = _ := by simp only [sum_const,card_univ,nsmul_eq_mul]; ring +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Exposure/RestrictionBudget.lean b/lean/OAI/Combinatorics/SharpRamsey/Exposure/RestrictionBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..2b706a53c81201c0d658ed4ff55afca0fe9d0e9f --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Exposure/RestrictionBudget.lean @@ -0,0 +1,50 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.ActualClassLaw + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset Real +open scoped Classical BigOperators +noncomputable section +variable {Ω Θ α : Type} [Fintype Ω] [Fintype Θ] [Fintype α] +local instance restrictionFinDec (n : ℕ) : DecidableEq (Fin n) := Classical.decEq _ + +lemma ordered_restriction_budget {N m : ℕ} (hm : m≤N) + (p : Law Ω) (θ : Ω→Θ) (F : Ω→Fin N→α) + (D : Θ→Fin N→Finset α) (J : ℝ) + (hD : ∀ x,p.mass x≠0→∀ i,F x i∈D (θ x) i) + (hJ : ∀ z i,log (D z i).card≤J) + (S : Θ→Finset (Fin N)) + (hcard : ∀ z,(p.map θ).mass z≠0→(S z).card=m) : + (∑ z,(p.map θ).mass z*((m:ℝ)*J-entropy ((p.cond θ z).map + (orderedTuple S hm θ F))))≤ + ∑ z,(p.map θ).mass z*((N:ℝ)*J-entropy ((p.cond θ z).map F)) := by + have hord : (∑ z,(p.map θ).mass z*((m:ℝ)*J-entropy ((p.cond θ z).map + (orderedTuple S hm θ F))))=selectedDeficit p θ F S J := by + convert ordered_deficit p θ F S hm hcard J using 1 + congr! + rw [hord] + unfold selectedDeficit + apply sum_le_sum + intro z _ + by_cases hz : (p.map θ).mass z=0 + · simp only [hz,zero_mul,le_refl] + · apply mul_le_mul_of_nonneg_left _ ((p.map θ).nonneg z) + have hcap : ∀ i,entropy (((p.cond θ z).map F).marginal i)≤J := by + intro i + change entropy (((p.cond θ z).map F).map (fun f=>f i))≤J + rw [Law.map_map] + apply (entropy_mapped_support (p.cond θ z) (fun x=>F x i) (D z i) ?_).trans (hJ z i) + intro x hx + obtain ⟨hx,he⟩:=p.cond_support θ z hz x hx + simpa only [←he] using hD x hx i + have hh := (subset_budget_deficit ((p.cond θ z).map F) (S z) (fun _=>J) hcap).2 + simpa only [sum_const,nsmul_eq_mul,card_univ,Fintype.card_fin] using hh +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Exposure/RestrictionGeometry.lean b/lean/OAI/Combinatorics/SharpRamsey/Exposure/RestrictionGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..edfcf5614cc59b189c7fe332aef2f583e996b1dd --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Exposure/RestrictionGeometry.lean @@ -0,0 +1,47 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Exposure.RestrictionBudget + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical BigOperators +noncomputable section + +lemma count_injective_restriction {I J : Type} [Fintype I] [Fintype J] + (e : I↪J) (P : J→Prop) : + (univ.filter (fun i=>P (e i))).card≤(univ.filter P).card := by + calc + _ = ((univ.filter (fun i=>P (e i))).image e).card := by + rw [card_image_of_injective _ e.injective] + _ ≤ _ := card_le_card (by + intro j hj + obtain ⟨i,hi,rfl⟩:=mem_image.mp hj + exact mem_filter.mpr ⟨mem_univ _,(mem_filter.mp hi).2⟩) + +variable {Ω Θ α : Type} [Fintype Ω] [Fintype Θ] [Fintype α] + +def prefixSet {N m : ℕ} (hm : m≤N) : Finset (Fin N) := + univ.image (Fin.castLE hm) + +lemma prefixSet_card {N m : ℕ} (hm : m≤N) : (prefixSet hm).card=m := by + rw [prefixSet,card_image_of_injective _ (Fin.castLE_injective hm),card_univ,Fintype.card_fin] + +lemma prefix_budget {N m : ℕ} (hm : m≤N) + (p : Law Ω) (θ : Ω→Θ) (F : Ω→Fin N→α) + (D : Θ→Fin N→Finset α) (J : ℝ) + (hD : ∀ x,p.mass x≠0→∀ i,F x i∈D (θ x) i) + (hJ : ∀ z i,Real.log (D z i).card≤J) : + (∑ z,(p.map θ).mass z*((m:ℝ)*J-entropy ((p.cond θ z).map + (orderedTuple (fun _=>prefixSet hm) hm θ F))))≤ + ∑ z,(p.map θ).mass z*((N:ℝ)*J-entropy ((p.cond θ z).map F)) := by + convert ordered_restriction_budget hm p θ F D J hD hJ (fun _=>prefixSet hm) + (fun _ _=>prefixSet_card hm) using 1 + all_goals congr! +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Exposure/SourceCoupling.lean b/lean/OAI/Combinatorics/SharpRamsey/Exposure/SourceCoupling.lean new file mode 100644 index 0000000000000000000000000000000000000000..81b44b5f10ba32b819d069f90ef3df6f6ab1aa60 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Exposure/SourceCoupling.lean @@ -0,0 +1,70 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Exposure.ExposureMixture + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical BigOperators +noncomputable section +variable {X Ω B : Type*} [Fintype X] [Fintype Ω] [Fintype B] + +def Law.attach (q : Law X) (μ : Law Ω) (f : X→B) (g : Ω→B) : Law (Σ _x : X,Ω) := + q.sigma (fun x=>μ.cond g (f x)) + +theorem Law.attach_source (q : Law X) (μ : Law Ω) (f : X→B) (g : Ω→B) + (h : q.map f=μ.map g) (φ : Ω→ℝ) : + (∑ x,(q.attach μ f g).mass x*φ x.2)=∑ ω,μ.mass ω*φ ω := by + rw [Law.attach,Law.sigma_sum] + change (∑ x,q.mass x*(fun b=>∑ ω,(μ.cond g b).mass ω*φ ω) (f x))=_ + rw [←q.sum_map f (fun b=>∑ ω,(μ.cond g b).mass ω*φ ω),h] + exact μ.history_sum g φ + +lemma Law.attach_support (q : Law X) (μ : Law Ω) (f : X→B) (g : Ω→B) + (h : q.map f=μ.map g) (x : Σ _x : X,Ω) + (hx : (q.attach μ f g).mass x≠0) : + q.mass x.1≠0 ∧ μ.mass x.2≠0 ∧ g x.2=f x.1 := by + have hx' : q.mass x.1≠0 ∧ (μ.cond g (f x.1)).mass x.2≠0 := mul_ne_zero_iff.mp hx + have hf : (μ.map g).mass (f x.1)≠0 := by + rw [←h] + exact ne_of_gt ((lt_of_le_of_ne (q.nonneg x.1) (Ne.symm hx'.1)).trans_le (q.le_map f x.1)) + exact ⟨hx'.1,μ.cond_support g (f x.1) hf x.2 hx'.2⟩ + +variable {β C ι Θ : Type} [Fintype β] [Fintype C] [Fintype ι] + [DecidableEq ι] [Fintype Θ] +namespace ExposureModel + +theorem contextual_tagged (n k : ℕ) {Ω : Type} [Fintype Ω] (p : Law Ω) (θ : Ω→Θ) + (G : Ω→ι→β) (e : Θ→C×Fin (n+k)↪ι) (own : Θ→ι→Option C) (t : Fin k) + (φ : Θ×(ι→β)→ℝ) : + (∑ x,(contextual n k p θ G e own t).joint.mass x* + φ (x.1.1,(contextual n k p θ G e own t).restore x.1 x.2))= + ∑ ω,p.mass ω*φ (θ ω,G ω) := by + rw [joint,Law.sigma_sum] + change (∑ h,((p.map θ).sigma (fun z=>(atRound n k ((p.cond θ z).map G) + (e z) (own z) t).historyLaw)).mass h* + ∑ x,((atRound n k ((p.cond θ h.1).map G) (e h.1) (own h.1) t).tupleLaw h.2).mass x* + φ (h.1,(atRound n k ((p.cond θ h.1).map G) (e h.1) (own h.1) t).restore h.2 x))=_ + rw [Law.sigma_sum] + change (∑ z,(p.map θ).mass z*(atRound n k ((p.cond θ z).map G) + (e z) (own z) t).expectation (fun x=>φ (z,x)))=_ + simp_rw [atRound_preserves] + exact (p.history_observable_sum θ G (fun z x=>φ (z,x))).symm + +theorem contextual_tagged_map (n k : ℕ) {Ω : Type} [Fintype Ω] (p : Law Ω) (θ : Ω→Θ) + (G : Ω→ι→β) (e : Θ→C×Fin (n+k)↪ι) (own : Θ→ι→Option C) (t : Fin k) : + (contextual n k p θ G e own t).joint.map + (fun x=>(x.1.1,(contextual n k p θ G e own t).restore x.1 x.2))= + p.map (fun ω=>(θ ω,G ω)) := by + ext y + have he:=contextual_tagged n k p θ G e own t (fun x=>if x=y then 1 else 0) + simpa only [Law.map,sum_filter,mul_ite,mul_one,mul_zero] using he + +end ExposureModel +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Exposure/SourceExposure.lean b/lean/OAI/Combinatorics/SharpRamsey/Exposure/SourceExposure.lean new file mode 100644 index 0000000000000000000000000000000000000000..c1a3a069647e26059278675460981a8d1259ca61 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Exposure/SourceExposure.lean @@ -0,0 +1,101 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Exposure.SourceCoupling +import OAI.Combinatorics.SharpRamsey.Selection.FreshRepresentatives + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical BigOperators +noncomputable section +variable {Θ Ω C ι A B K V : Type} [Fintype Θ] [Fintype Ω] [Fintype C] + [Fintype ι] [DecidableEq ι] [Fintype A] [Fintype B] [Field K] + [AddCommGroup V] [Module K V] [FiniteDimensional K V] +namespace ExposureModel + +lemma contextual_remaining (n k : ℕ) (p : Law Ω) (θ : Ω→Θ) (G : Ω→ι→A×B) + (e : Θ→C×Fin (n+k)↪ι) (own : Θ→ι→Option C) (t : Fin k) + (z : (contextual n k p θ G e own t).History) : + n≤(contextual n k p θ G e own t).remaining z := + atRound_remaining n k ((p.cond θ z.1).map G) (e z.1) (own z.1) t z.2 + +lemma contextual_positive (n k : ℕ) (hn : 0G x i∈orthogonalRectangle v w W)).card:ℝ)≤M) + (hbudget : (∑ z,(p.map θ).mass z*((Fintype.card ι:ℝ)*J- + entropy ((p.cond θ z).map G)))≤budget) : + ∃ t : Fin k, + let E:=contextual n k p θ G e own t + let hp:=contextual_positive n k (by omega : 0reciprocalCharges (E.tupleLaw z) v w ρ r s) J D a + (∑ x,(E.freshLaw hp).mass x*((bad x).card:ℝ))≤ + budget/D+2*budget/((k:ℝ)*a)+2*Fintype.card ι*M/((n:ℝ)*a) ∧ + (n:ℝ)*(∑ x,(E.freshLaw hp).mass x*((E.freshSelected x∩bad x).card:ℝ))≤ + budget/D+2*budget/((k:ℝ)*a)+2*Fintype.card ι*M/((n:ℝ)*a) ∧ + (E.afterDraw hp).joint.map (fun x=>(E.afterDraw hp).restore x.1 x.2)=p.map G := by + obtain ⟨t,hb,hs⟩:=actual_source_reciprocal v w hρ hsum n k hn hk J D a M budget hD ha hM + p θ G e own hown S hS hJ hf ho hbudget + refine ⟨t,?_,?_,?_⟩ + · + rw [fresh_bad_mean,contextual_bad_mean] + exact hb + · + rw [fresh_selected_mean,contextual_selected_mean] + exact hs + · apply restored_map + intro φ + rw [afterDraw_preserves,contextual_preserves,Law.sum_map] + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Exposure/SourceZero.lean b/lean/OAI/Combinatorics/SharpRamsey/Exposure/SourceZero.lean new file mode 100644 index 0000000000000000000000000000000000000000..af2271d99ee3481f17d4f8339aa1df042ee969e3 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Exposure/SourceZero.lean @@ -0,0 +1,95 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Exposure.ExposureContexts + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical BigOperators +noncomputable section +variable {Θ Ω B ι β : Type*} [Fintype Θ] [Fintype Ω] [Fintype B] + [Fintype ι] [DecidableEq ι] [Fintype β] + +omit [Fintype Ω] in + +theorem exists_context_good_zero (n k : ℕ) (hn : 2≤n) (hk : 0tupleDeficit J (p θ))≤budget) : + ∃ t : Fin k, + contextAverage μ (fun θ=>exposureBad n J D a k (p θ) (e θ) (own θ) t)≤ + budget/D+2*budget/((k:ℝ)*a) ∧ + (n:ℝ)*contextAverage μ (fun θ=>exposureSelectedBad n J D a k (p θ) (e θ) (own θ) t)≤ + budget/D+2*budget/((k:ℝ)*a) := by + have hTC : contextAverage μ (fun θ=>totalCorrelation (p θ))≤budget := by + apply le_trans _ hbudget + apply contextAverage_mono μ + intro θ hθ + exact totalCorrelation_le_tupleDeficit (p θ) J + (tupleSupported_marginal_cap (p θ) (S θ) (hS θ hθ) J (hJ θ)) + obtain ⟨t,ht⟩:=exists_context_round n k hn hk μ p e own hown + have hbθ (θ : Θ) (hθ : μ.mass θ≠0) : + exposureBad n J D a k (p θ) (e θ) (own θ) t≤ + tupleDeficit J (p θ)/D+exposureScores n k (p θ) (e θ) (own θ) t/a := by + exact (exposureBad_budget n k J D a hD ha (p θ) (e θ) (own θ) + (S θ) (hS θ hθ) (hJ θ) t).trans (by + have hd:=exposureDeficits_le n k J (p θ) (e θ) (S θ) (hS θ hθ) (hJ θ) t + gcongr) + have hb:=contextAverage_mono μ hbθ + simp only [contextAverage_add,contextAverage_div] at hb + have hb' : contextAverage μ (fun θ=>exposureBad n J D a k (p θ) (e θ) (own θ) t)≤ + budget/D+2*budget/((k:ℝ)*a) := by + calc + _ ≤ _ := hb + _ ≤ budget/D+(2*budget/(k:ℝ))/a := + add_le_add (div_le_div_of_nonneg_right hbudget hD.le) + (div_le_div_of_nonneg_right + (ht.trans (div_le_div_of_nonneg_right + (mul_le_mul_of_nonneg_left hTC (by norm_num)) (Nat.cast_nonneg k))) ha.le) + _ = _ := by rw [div_div] + refine ⟨t,hb',le_trans ?_ hb'⟩ + rw [←contextAverage_mul] + apply contextAverage_mono μ + intro θ _ + exact exposureSelectedBad_le n k J D a (p θ) (e θ) (own θ) (hown θ) t + +lemma conditional_tupleSupported (p : Law Ω) (θ : Ω→Θ) (G : Ω→ι→β) + (S : Θ→ι→Finset β) + (hS : ∀ x,p.mass x≠0→∀ i,G x i∈S (θ x) i) + (z : Θ) (hz : (p.map θ).mass z≠0) : + tupleSupported ((p.cond θ z).map G) (S z) := by + intro f hf i + obtain ⟨x,hx,rfl⟩ := (p.cond θ z).map_support G f hf + obtain ⟨hx,he⟩:=p.cond_support θ z hz x hx + simpa only [he] using hS x hx i + +theorem actual_source_exposure (n k : ℕ) (hn : 2≤n) (hk : 0(p.cond θ z).map G) e own hown S + (conditional_tupleSupported p θ G S hS) hJ hbudget + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Exposure/StreamTransport.lean b/lean/OAI/Combinatorics/SharpRamsey/Exposure/StreamTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..cc426bad3b8b0eee6eb7249a4bc4e00a7e02aabd --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Exposure/StreamTransport.lean @@ -0,0 +1,62 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Exposure.HighRankMixture + +namespace OAI + +section +namespace SharpLogRamsey.ActualHighRank +open Finset Selection +open scoped Classical +noncomputable section +variable {Ω F F' ι ι' Γ : Type} [Fintype Ω] [Fintype F] [Fintype F'] [Fintype Γ] + +def StreamReplacement.transport {p : Law Ω} {G : Ω→ι→F} {pos : ι→ℕ} {m : ℕ} + {DD : Γ→Finset F} {B C : ℝ} (e : StreamReplacement p G pos m DD B C) + (f : F≃F') (j : ι→ι') (G' : Ω→ι'→F') (pos' : ι'→ℕ) + (htime : ∀ i,pos' (j i)=pos i) (hvalue : ∀ x i,G' x (j i)=f (G x i)) : + StreamReplacement p G' pos' m (fun c=>(DD c).map f.toEmbedding) B C where + X:=e.X + finiteX:=e.finiteX + μ:=e.μ + source:=e.source + msg:=e.msg + index x i:=j (e.index x i) + ordered x:=by simpa only [htime] using e.ordered x + supported:=e.supported + hit x hx i:=by + rw [hvalue] + exact mem_map.mpr ⟨_,e.hit x hx i,rfl⟩ + size x:=by simpa only [card_map] using e.size x + dominated:=e.dominated + cost:=e.cost +end +end SharpLogRamsey.ActualHighRank + +namespace SharpLogRamsey.Selection.Windows +open Finset +open scoped Classical +noncomputable section +variable {α Ω : Type} [Fintype α] [Fintype Ω] + +def singleTuple {n : ℕ} (F : Fin (4*n)→α) : Slot 1 n→α := fun i=>F i.2 + +omit [Fintype α] in +lemma singleTuple_injective (n : ℕ) : Function.Injective (singleTuple (α:=α) (n:=n)) := by + intro F G h + funext i + exact congrFun h (0,i) + +lemma single_position {n : ℕ} (i : Slot 1 n) : position i=i.2.val := by + have h : i.1.val=0 := Fin.eq_zero i.1 ▸ rfl + simp only [position,h,zero_mul,zero_add] + +lemma single_entropy {n : ℕ} (p : Law Ω) (F : Ω→Fin (4*n)→α) : + entropy (p.map (fun x=>singleTuple (F x)))=entropy (p.map F) := by + rw [show (fun x=>singleTuple (F x))=singleTuple ∘ F from rfl,←Law.map_map] + exact entropy_map_eq_of_injective _ _ (singleTuple_injective n) +end +end SharpLogRamsey.Selection.Windows + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Exposure/SupportMixtures.lean b/lean/OAI/Combinatorics/SharpRamsey/Exposure/SupportMixtures.lean new file mode 100644 index 0000000000000000000000000000000000000000..38e9f657b6e0ec8c4d4a5d3f1d18b776b61cee6c --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Exposure/SupportMixtures.lean @@ -0,0 +1,149 @@ +import Mathlib + +namespace OAI + +section +open scoped BigOperators +open Finset +open scoped Classical +namespace SharpLogRamsey.SupportMixtures +noncomputable section +variable {A B I J : Type*} [Fintype A] [Fintype B] [Fintype I] [Fintype J] + + def kernel (S : Finset A) (a : A) : ℝ := + if a∈S then 1/(S.card:ℝ) else 0 + +omit [Fintype A] in +lemma kernel_nonneg (S : Finset A) (a : A) : 0≤kernel S a := by + unfold kernel + split_ifs <;> positivity + +lemma kernel_total (S : Finset A) (hS : S.Nonempty) : ∑ a, kernel S a=1 := by + classical + simp only [kernel,←sum_filter] + have hf : univ.filter (fun a => a∈S)=S := by ext; simp + rw [hf,sum_const,nsmul_eq_mul] + have hn : (S.card:ℝ)≠0 := by exact_mod_cast card_ne_zero.mpr hS + field_simp + + def mixture (w : I→ℝ) (S : I→Finset A) (a : A) : ℝ := + ∑ i, w i*kernel (S i) a + + def pairing (f : A→ℝ) (g : B→ℝ) (R : A→B→ℝ) : ℝ := + ∑ a, ∑ b, f a*g b*R a b + +lemma pairing_mono (f f' : A→ℝ) (g g' : B→ℝ) (R : A→B→ℝ) + (hf : ∀ a, 0≤f a) (hg : ∀ b, 0≤g b) (hR : ∀ a b, 0≤R a b) + (hff : ∀ a,f a≤f' a) (hgg : ∀ b,g b≤g' b) : + pairing f g R≤pairing f' g' R := by + apply sum_le_sum + intro a _ + apply sum_le_sum + intro b _ + apply mul_le_mul_of_nonneg_right _ (hR a b) + exact mul_le_mul (hff a) (hgg b) (hg b) ((hf a).trans (hff a)) + +lemma pairing_scale (f : A→ℝ) (g : B→ℝ) (R : A→B→ℝ) (c d : ℝ) : + pairing (fun a => c*f a) (fun b => d*g b) R=c*d*pairing f g R := by + simp only [pairing,mul_sum] + apply sum_congr rfl + intro a _ + apply sum_congr rfl + intro b _ + ring + +lemma independent_pairing (w : I→ℝ) (v : J→ℝ) + (S : I→Finset A) (T : J→Finset B) (R : A→B→ℝ) : + (∑ i, ∑ j, w i*v j*pairing (kernel (S i)) (kernel (T j)) R)= + pairing (mixture w S) (mixture v T) R := by + simp only [pairing,mixture,mul_sum,sum_mul] + calc + _ = ∑ a, ∑ b, ∑ i, ∑ j, + w i*v j*(kernel (S i) a*kernel (T j) b*R a b) := by + calc + _ = ∑ ij : I×J, ∑ ab : A×B, + w ij.1*v ij.2*(kernel (S ij.1) ab.1*kernel (T ij.2) ab.2*R ab.1 ab.2) := by + simp only [Fintype.sum_prod_type] + _ = ∑ ab : A×B, ∑ ij : I×J, + w ij.1*v ij.2*(kernel (S ij.1) ab.1*kernel (T ij.2) ab.2*R ab.1 ab.2) := sum_comm + _ = _ := by simp only [Fintype.sum_prod_type] + _ = _ := by + apply sum_congr rfl + intro a _ + apply sum_congr rfl + intro b _ + rw [sum_comm] + apply sum_congr rfl + intro j _ + apply sum_congr rfl + intro i _ + ring + +theorem independent_pairing_le (w : I→ℝ) (v : J→ℝ) + (S : I→Finset A) (T : J→Finset B) (R : A→B→ℝ) + (p : A→ℝ) (q : B→ℝ) (c d : ℝ) + (hw : ∀ i, 0≤w i) (hv : ∀ j, 0≤v j) + (hR : ∀ a b, 0≤R a b) + (hS : ∀ a, mixture w S a≤c*p a) (hT : ∀ b, mixture v T b≤d*q b) : + (∑ i, ∑ j, w i*v j*pairing (kernel (S i)) (kernel (T j)) R)≤ + c*d*pairing p q R := by + rw [independent_pairing] + rw [←pairing_scale] + apply pairing_mono _ _ _ _ R _ _ hR hS hT + · intro a + exact sum_nonneg (fun i _ => mul_nonneg (hw i) (kernel_nonneg _ a)) + · intro b + exact sum_nonneg (fun j _ => mul_nonneg (hv j) (kernel_nonneg _ b)) + +lemma one_sided_pairing (w : I→ℝ) (S : I→Finset A) (q : B→ℝ) (R : A→B→ℝ) : + (∑ i, w i*pairing (kernel (S i)) q R)=pairing (mixture w S) q R := by + simp only [pairing,mixture,mul_sum,sum_mul] + rw [sum_comm] + apply sum_congr rfl + intro a _ + rw [sum_comm] + apply sum_congr rfl + intro b _ + apply sum_congr rfl + intro i _ + ring + +theorem one_sided_pairing_le (w : I→ℝ) (S : I→Finset A) + (p : A→ℝ) (q : B→ℝ) (R : A→B→ℝ) (c : ℝ) + (hw : ∀ i,0≤w i) (hq : ∀ b,0≤q b) (hR : ∀ a b,0≤R a b) + (hS : ∀ a,mixture w S a≤c*p a) : + (∑ i,w i*pairing (kernel (S i)) q R)≤c*pairing p q R := by + rw [one_sided_pairing] + have H := pairing_mono (mixture w S) (fun a => c*p a) q q R + (fun a => sum_nonneg (fun i _ => mul_nonneg (hw i) (kernel_nonneg _ a))) + hq hR hS (fun _ => le_rfl) + have he := pairing_scale p q R c 1 + simp only [one_mul,mul_one] at he + rwa [he] at H + +lemma kernel_incidence (S : Finset A) (T : Finset B) (R : A→B→Prop) : + pairing (kernel S) (kernel T) (fun a b => if R a b then 1 else 0)= + (((S×ˢT).filter (fun z => R z.1 z.2)).card:ℝ)/((S.card:ℝ)*(T.card:ℝ)) := by + classical + let U := (S×ˢT).filter (fun z => R z.1 z.2) + have he : pairing (kernel S) (kernel T) (fun a b => if R a b then 1 else 0)= + ∑ z : A×B, if z∈U then 1/((S.card:ℝ)*(T.card:ℝ)) else 0 := by + simp only [pairing,Fintype.sum_prod_type] + apply sum_congr rfl + intro a _ + apply sum_congr rfl + intro b _ + by_cases ha : a∈S <;> by_cases hb : b∈T <;> by_cases hr : R a b <;> + simp [kernel,U,ha,hb,hr,mul_comm] + rw [he,←sum_filter] + have hf : univ.filter (fun z => z∈U)=U := by ext; simp + rw [hf,sum_const,nsmul_eq_mul] + change (U.card:ℝ)*(1/((S.card:ℝ)*(T.card:ℝ)))=(U.card:ℝ)/_ + ring + +end +end SharpLogRamsey.SupportMixtures + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Exposure/ZeroExposure.lean b/lean/OAI/Combinatorics/SharpRamsey/Exposure/ZeroExposure.lean new file mode 100644 index 0000000000000000000000000000000000000000..7ec6383230dbb89164e2e0f8ddc54feb239074dd --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Exposure/ZeroExposure.lean @@ -0,0 +1,124 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Exposure.SourceExposure +import OAI.Combinatorics.SharpRamsey.Exposure.SourceZero + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical BigOperators +noncomputable section +variable {β C : Type} [Fintype β] [Fintype C] + +def zeroBadStatistic (J D a : ℝ) : StateStatistic β C := + fun _ _ _ _ p e own=>roundBad p e own (fun _ _=>0) J D a + +def zeroSelectedStatistic (J D a : ℝ) : StateStatistic β C := + fun _ _ _ _ p e own=>roundSelectedBad p e own (fun _ _=>0) J D a + +lemma exposureAverage_zero_bad (n k : ℕ) (J D a : ℝ) + {ι : Type} [Fintype ι] [DecidableEq ι] (p : Law (ι→β)) + (e : C×Fin (n+k)↪ι) (own : ι→Option C) (t : Fin k) : + exposureAverage (zeroBadStatistic J D a) n k p e own t=exposureBad n J D a k p e own t := by + induction k generalizing ι with + | zero => exact Fin.elim0 t + | succ k ih => + refine Fin.cases ?_ (fun j=>?_) t + · rfl + · change (∑ f : C→Fin (n+k+1),∑ z,(p.restrict (freshRepresentatives e f)).mass z* + exposureAverage _ n k _ _ _ j)/_=_ + simp_rw [ih] + rfl + +lemma exposureAverage_zero_selected (n k : ℕ) (J D a : ℝ) + {ι : Type} [Fintype ι] [DecidableEq ι] (p : Law (ι→β)) + (e : C×Fin (n+k)↪ι) (own : ι→Option C) (t : Fin k) : + exposureAverage (zeroSelectedStatistic J D a) n k p e own t= + exposureSelectedBad n J D a k p e own t := by + induction k generalizing ι with + | zero => exact Fin.elim0 t + | succ k ih => + refine Fin.cases ?_ (fun j=>?_) t + · rfl + · change (∑ f : C→Fin (n+k+1),∑ z,(p.restrict (freshRepresentatives e f)).mass z* + exposureAverage _ n k _ _ _ j)/_=_ + simp_rw [ih] + rfl + +namespace ExposureModel +variable {ι Θ Ω : Type} [Fintype ι] [DecidableEq ι] [Fintype Θ] [Fintype Ω] + +lemma contextual_positive_general (n k : ℕ) (hn : 00) J D a x).card:ℝ))= + M.mean (zeroBadStatistic J D a) := by + rw [freshLaw_sum] + rfl + +omit [Fintype ι] [DecidableEq ι] in +lemma fresh_zero_selected_mean (M : ExposureModel ι β C) (h : ∀ z,00) J D a x).card:ℝ))= + M.mean (zeroSelectedStatistic J D a) := by + rw [freshLaw_sum] + rfl + +lemma contextual_zero_bad_mean (n k : ℕ) (p : Law Ω) (θ : Ω→Θ) (G : Ω→ι→β) + (e : Θ→C×Fin (n+k)↪ι) (own : Θ→ι→Option C) (t : Fin k) (J D a : ℝ) : + (contextual n k p θ G e own t).mean (zeroBadStatistic J D a)= + ∑ z,(p.map θ).mass z*exposureBad n J D a k ((p.cond θ z).map G) (e z) (own z) t := by + rw [contextual,mix_mean] + simp_rw [atRound_mean,exposureAverage_zero_bad] + +lemma contextual_zero_selected_mean (n k : ℕ) (p : Law Ω) (θ : Ω→Θ) (G : Ω→ι→β) + (e : Θ→C×Fin (n+k)↪ι) (own : Θ→ι→Option C) (t : Fin k) (J D a : ℝ) : + (contextual n k p θ G e own t).mean (zeroSelectedStatistic J D a)= + ∑ z,(p.map θ).mass z*exposureSelectedBad n J D a k ((p.cond θ z).map G) (e z) (own z) t := by + rw [contextual,mix_mean] + simp_rw [atRound_mean,exposureAverage_zero_selected] +end ExposureModel +open ExposureModel + +variable {ι Θ Ω : Type} [Fintype ι] [DecidableEq ι] [Fintype Θ] [Fintype Ω] + +theorem actual_realized_zero (n k : ℕ) (hn : 2≤n) (hk : 00) J D a + (∑ x,(E.freshLaw hp).mass x*((bad x).card:ℝ))≤budget/D+2*budget/((k:ℝ)*a) ∧ + (n:ℝ)*(∑ x,(E.freshLaw hp).mass x*((E.freshSelected x∩bad x).card:ℝ))≤ + budget/D+2*budget/((k:ℝ)*a) ∧ + (E.afterDraw hp).joint.map (fun x=>(E.afterDraw hp).restore x.1 x.2)=p.map G := by + obtain ⟨t,hb,hs⟩:=actual_source_exposure n k hn hk J D a budget hD ha + p θ G e own hown S hS hJ hbudget + refine ⟨t,?_,?_,?_⟩ + · rw [fresh_zero_bad_mean,contextual_zero_bad_mean] + exact hb + · rw [fresh_zero_selected_mean,contextual_zero_selected_mean] + exact hs + · apply restored_map + intro φ + rw [afterDraw_preserves,contextual_preserves,Law.sum_map] + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/Card.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/Card.lean new file mode 100644 index 0000000000000000000000000000000000000000..400b1f67a123d5172c702c7c0e91e2f625a5ebb5 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/Card.lean @@ -0,0 +1,549 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.Triple + +namespace OAI + +/-! Incidence bounds for rich lines and finite point configurations. -/ + +section +section +namespace SharpLogRamsey.NonplaneRichLines +open Finset MvPolynomial +open AffineIncidence +variable {K : Type*} [Field K] [Infinite K] +noncomputable section +variable {ι : Type*} [Fintype ι] +theorem card_le {p : ℕ} [CharP K p] [IsAlgClosed K] + (F : MvPolynomial (Fin 3) K) (hF : F ≠ 0) (hdeg : F.totalDegree < p) + (hs : Squarefree F) (h2 : (2 : K) ≠ 0) + (hn : ∀ L : MvPolynomial (Fin 3) K, L ∣ F → L.totalDegree ≤ 1 → IsUnit L) + (x v : ι → Fin 3 → K) (hv : ∀ i, v i ≠ 0) + (hd : Function.Injective (fun i => carrier (x i) (v i))) + (hzero : ∀ i, LineFlatness.restrictLine (x i) (v i) F = 0) + (S : Finset (Fin 3 → K)) (M : ℕ) (hM : ∀ i, M ≤ (onLine x v S i).card) + (hMD : 3*F.totalDegree < M) : + Fintype.card ι ≤ 2*S.card/(M-3*F.totalDegree)+6*F.totalDegree^2 := by + classical + obtain ⟨Q,hQ,hQD,hQr⟩ := RichLinePolynomial.auxiliary_polynomial F hF hdeg hs h2 hn + let bad := univ.filter (fun i => (richPoints x v S i).card ≤ 3*F.totalDegree) + let good := univ.filter (fun i => 3*F.totalDegree < (richPoints x v S i).card) + have hb : bad.card ≤ 2*S.card/(M-3*F.totalDegree) := by + apply (Nat.le_div_iff_mul_le (by omega)).mpr + exact pruning_bound x v S M (3*F.totalDegree) hM + have hgood : ∀ i ∈ good, LineFlatness.restrictLine (x i) (v i) Q = 0 := by + intro i hi + obtain ⟨T,hcard,hT⟩ := many_parameters x v hv S i + apply hQr (x i) (v i) T (by rw [hcard]; exact (mem_filter.mp hi).2) + intro t ht + exact three_lines_at_rich F x v hv hd hzero _ (hT t ht) + have hg : good.card ≤ 6*F.totalDegree^2 := by + have H := CommonLines.card_le F Q hQ (fun i : good => x i) (fun i : good => v i) + (fun i => hv i) (fun i j H => Subtype.ext (hd H)) + (fun i t => eval_of_restrict_zero _ _ F (hzero i) _ ⟨t,rfl⟩) + (fun i t => eval_of_restrict_zero _ _ Q (hgood i i.property) _ ⟨t,rfl⟩) + have H' : good.card ≤ 2*F.totalDegree*Q.totalDegree := by simpa using H + calc + _ ≤ 2*F.totalDegree*Q.totalDegree := H' + _ ≤ 2*F.totalDegree*(3*F.totalDegree) := Nat.mul_le_mul_left _ hQD + _ = 6*F.totalDegree^2 := by ring + have hsplit : bad.card+good.card = Fintype.card ι := by + simpa only [bad,good,not_le,card_univ] using + card_filter_add_card_filter_not (s := univ) (p := fun i => (richPoints x v S i).card ≤ 3*F.totalDegree) + omega + +end +end SharpLogRamsey.NonplaneRichLines + +section + +namespace SharpLogRamsey.PlaneDecomposition +open MvPolynomial +variable {K : Type*} [Field K] +noncomputable section + +lemma unit_of_degree_zero (F : MvPolynomial (Fin 3) K) (hF : F ≠ 0) + (h : F.totalDegree = 0) : IsUnit F := by + have he := totalDegree_eq_zero_iff_eq_C.mp h + have hc : F.coeff 0 ≠ 0 := by + intro H + apply hF + rw [he,H,map_zero] + rw [he] + exact (isUnit_iff_ne_zero.mpr hc).map C + +theorem exists_decomposition (F : MvPolynomial (Fin 3) K) (hF : F ≠ 0) + (hs : Squarefree F) : + ∃ (planes : List (MvPolynomial (Fin 3) K)) (G : MvPolynomial (Fin 3) K), + G ≠ 0 ∧ Squarefree G ∧ F = planes.prod*G ∧ + (∀ L ∈ planes, L.totalDegree = 1) ∧ + planes.Pairwise IsRelPrime ∧ + (∀ L ∈ planes, L ∣ F) ∧ + (∀ L : MvPolynomial (Fin 3) K, L ∣ G → L.totalDegree ≤ 1 → IsUnit L) ∧ + planes.length+G.totalDegree = F.totalDegree := by + classical + suffices H : ∀ n (F : MvPolynomial (Fin 3) K), F.totalDegree = n → F ≠ 0 → Squarefree F → + ∃ (planes : List (MvPolynomial (Fin 3) K)) (G : MvPolynomial (Fin 3) K), + G ≠ 0 ∧ Squarefree G ∧ F = planes.prod*G ∧ + (∀ L ∈ planes, L.totalDegree = 1) ∧ planes.Pairwise IsRelPrime ∧ + (∀ L ∈ planes, L ∣ F) ∧ + (∀ L : MvPolynomial (Fin 3) K, L ∣ G → L.totalDegree ≤ 1 → IsUnit L) ∧ + planes.length+G.totalDegree = F.totalDegree by + exact H F.totalDegree F rfl hF hs + intro n + induction n using Nat.strong_induction_on with + | h n ih => + intro F hn hF hs + by_cases hno : ∀ L : MvPolynomial (Fin 3) K, L ∣ F → L.totalDegree ≤ 1 → IsUnit L + · exact ⟨[],F,hF,hs,by simp,by simp,by simp,by simp,hno,by simp⟩ + push Not at hno + obtain ⟨L,hLF,hd,hnu⟩ := hno + have hL : L ≠ 0 := ne_zero_of_dvd_ne_zero hF hLF + have hdL : L.totalDegree = 1 := by + have hn0 : L.totalDegree ≠ 0 := fun h => hnu (unit_of_degree_zero L hL h) + omega + obtain ⟨A,hFA⟩ := hLF + have hA : A ≠ 0 := by + intro H + apply hF + rw [hFA,H,mul_zero] + have hde : F.totalDegree = 1+A.totalDegree := by + rw [hFA,totalDegree_mul_of_isDomain hL hA,hdL] + have hAl : A.totalDegree < n := by omega + have hsq := squarefree_mul_iff.mp (hFA ▸ hs) + obtain ⟨planes,G,hG,hGs,hAG,hplanes,hpair,hdiv,hng,hdeg⟩ := + ih A.totalDegree hAl A rfl hA hsq.2.2 + refine ⟨L::planes,G,hG,hGs,?_,?_,?_,?_,hng,?_⟩ + · simp only [List.prod_cons] + rw [mul_assoc,← hAG,← hFA] + · intro J hJ + obtain rfl | hJ := List.mem_cons.mp hJ + · exact hdL + · exact hplanes J hJ + · apply List.pairwise_cons.mpr + exact ⟨fun J hJ => hsq.1.of_dvd_right (hdiv J hJ),hpair⟩ + · intro J hJ + obtain rfl | hJ := List.mem_cons.mp hJ + · exact ⟨A,hFA⟩ + · exact (hdiv J hJ).trans (hFA ▸ dvd_mul_left A L) + · simp only [List.length_cons] + omega + +end +end SharpLogRamsey.PlaneDecomposition + +end + +section + +namespace SharpLogRamsey.PlaneCount +open Finset +open scoped BigOperators +variable {ι X : Type*} [Fintype ι] [DecidableEq ι] [DecidableEq X] +noncomputable section +omit [DecidableEq ι] in + +lemma incidence_sum (A : ι → Finset X) (U : Finset X) (hU : ∀ i, A i ⊆ U) : + (∑ x ∈ U, (univ.filter (fun i => x ∈ A i)).card) = ∑ i, (A i).card := by + classical + simp only [card_filter] + rw [sum_comm] + apply sum_congr rfl + intro i hi + have H : U.filter (fun x => x ∈ A i) = A i := by + ext x + simp only [mem_filter] + exact ⟨fun h => h.2,fun h => ⟨hU i h,h⟩⟩ + rw [← card_filter,H] +omit [DecidableEq ι] in + +lemma incidence_sq_sum (A : ι → Finset X) (U : Finset X) (hU : ∀ i, A i ⊆ U) : + (∑ x ∈ U, (univ.filter (fun i => x ∈ A i)).card^2) = + ∑ i, ∑ j, (A i ∩ A j).card := by + classical + have he (x : X) : (univ.filter (fun i => x ∈ A i)).card^2 = + ∑ i, ∑ j, if x ∈ A i ∧ x ∈ A j then (1:ℕ) else 0 := by + simp only [card_filter,pow_two,sum_mul,mul_sum] + apply sum_congr rfl + intro i hi + apply sum_congr rfl + intro j hj + by_cases H : x ∈ A i <;> by_cases H' : x ∈ A j <;> simp [H,H'] + simp_rw [he] + rw [sum_comm] + apply sum_congr rfl + intro i hi + rw [sum_comm] + apply sum_congr rfl + intro j hj + have H : U.filter (fun x => x ∈ A i ∧ x ∈ A j) = A i ∩ A j := by + ext x + simp only [mem_filter,mem_inter] + exact ⟨fun h => h.2, fun h => ⟨hU i h.1,h⟩⟩ + rw [← card_filter,H] + +theorem card_mul_le (A : ι → Finset X) (U : Finset X) (M K : ℕ) + (hU : ∀ i, A i ⊆ U) (hM : ∀ i, (A i).card = M) + (hi : ∀ i j, i ≠ j → (A i ∩ A j).card ≤ 1) + (hK : U.card ≤ K) (hMK : 2*K ≤ M^2) (hM0 : 0 < M) : + Fintype.card ι*M ≤ 2*K := by + classical + let u := Fintype.card ι + have hs : (∑ x ∈ U, (univ.filter (fun i => x ∈ A i)).card) = u*M := by + rw [incidence_sum A U hU] + simp [hM,u] + have hs2 : (∑ x ∈ U, (univ.filter (fun i => x ∈ A i)).card^2) ≤ u*(M+u) := by + rw [incidence_sq_sum A U hU] + calc + _ ≤ ∑ i : ι, ∑ j : ι, ((if i = j then M else 0)+1) := by + apply sum_le_sum; intro i _ + apply sum_le_sum; intro j _ + by_cases H : i = j + · subst j; simp [hM] + · simpa [H] using (hi i j H) + _ = u*(M+u) := by simp [u,sum_add_distrib] + have hcs := sq_sum_le_card_mul_sum_sq (s := U) + (f := fun x => (univ.filter (fun i => x ∈ A i)).card) + rw [hs] at hcs + have H : (u*M)^2 ≤ K*(u*(M+u)) := hcs.trans (Nat.mul_le_mul hK hs2) + by_cases hu : u = 0 + · change u*M ≤ 2*K + simp [hu] + have hu0 : 0 < u := Nat.pos_of_ne_zero hu + have hcancel : u*M^2 ≤ K*(M+u) := by + apply Nat.le_of_mul_le_mul_left (c := u) + calc + u*(u*M^2) = (u*M)^2 := by ring + _ ≤ K*(u*(M+u)) := H + _ = u*(K*(M+u)) := by ring + exact hu0 + have hmid : u*M^2 ≤ 2*K*M := by nlinarith [Nat.mul_le_mul_left u hMK] + change u*M ≤ 2*K + apply Nat.le_of_mul_le_mul_right (c := M) + · nlinarith + · exact hM0 + +lemma exclusive_card (A : ι → Finset X) (i : ι) + (hi : ∀ j, i ≠ j → (A i ∩ A j).card ≤ 1) : + (A i).card ≤ (A i \ (univ.erase i).biUnion A).card+Fintype.card ι := by + classical + have he : A i ∩ (univ.erase i).biUnion A = + (univ.erase i).biUnion (fun j => A i ∩ A j) := by + ext x + simp only [mem_inter,mem_biUnion] + aesop + have h : (A i ∩ (univ.erase i).biUnion A).card ≤ Fintype.card ι := by + rw [he] + calc + _ ≤ ∑ j ∈ univ.erase i, (A i ∩ A j).card := card_biUnion_le + _ ≤ ∑ _j ∈ univ.erase i, 1 := by + apply sum_le_sum + intro j hj + exact hi j (mem_erase.mp hj).1.symm + _ ≤ Fintype.card ι := by simp + have hs := card_sdiff_add_card_inter (A i) ((univ.erase i).biUnion A) + omega + +lemma exclusive_disjoint (A : ι → Finset X) : + (↑(univ : Finset ι) : Set ι).PairwiseDisjoint (fun i => A i \ (univ.erase i).biUnion A) := by + classical + intro i hi j hj hij + apply disjoint_left.mpr + intro x hxi hxj + have hxi' := mem_sdiff.mp hxi + have hxj' := mem_sdiff.mp hxj + apply hxi'.2 + apply mem_biUnion.mpr + exact ⟨j,mem_erase.mpr ⟨hij.symm,mem_univ j⟩,hxj'.1⟩ + +theorem union_lower (A : ι → Finset X) (M : ℕ) + (hM : ∀ i, M ≤ (A i).card) + (hi : ∀ i j, i ≠ j → (A i ∩ A j).card ≤ 1) : + Fintype.card ι*(M-Fintype.card ι) ≤ (univ.biUnion A).card := by + classical + let E := fun i => A i \ (univ.erase i).biUnion A + calc + _ = ∑ _i : ι, (M-Fintype.card ι) := by simp + _ ≤ ∑ i, (E i).card := by + apply sum_le_sum + intro i _ + have H := exclusive_card A i (hi i) + have hm := hM i + dsimp [E] + omega + _ = (univ.biUnion E).card := (card_biUnion (exclusive_disjoint A)).symm + _ ≤ (univ.biUnion A).card := by + apply card_le_card + intro x hx + obtain ⟨i,hi,hx⟩ := mem_biUnion.mp hx + exact mem_biUnion.mpr ⟨i,hi,(mem_sdiff.mp hx).1⟩ + +end +end SharpLogRamsey.PlaneCount + +namespace SharpLogRamsey.SinglePlaneCount +open Finset +open scoped BigOperators +variable {κ ι X : Type*} [Fintype κ] [Fintype ι] [DecidableEq X] +noncomputable section + +theorem card_mul_le (A : ι → Finset X) (P : κ → Finset X) (owner : ι → κ) + (U : Finset X) (M K : ℕ) (hM0 : 0 < M) + (hM : ∀ i, (A i).card = M) + (hAU : ∀ i, A i ⊆ P (owner i)) (hPU : ∀ j, P j ⊆ U) + (hcap : ∀ j, (P j).card ≤ K) + (hcross : ∀ i j, j ≠ owner i → (A i ∩ P j).card ≤ 1) + (hpair : ∀ i j, i ≠ j → (A i ∩ A j).card ≤ 1) + (hKM : 8*K ≤ M^2) (hDM : 4*Fintype.card κ ≤ M) : + Fintype.card ι*M ≤ 2*U.card := by + classical + let D := Fintype.card κ + let Region (j : κ) := P j \ (univ.erase j).biUnion P + let u (j : κ) := Fintype.card {i : ι // owner i = j} + have hu (j : κ) : 4*u j ≤ M := by + have H := PlaneCount.card_mul_le (fun i : {i : ι // owner i = j} => A i.val) + (P j) M K (by intro i; simpa [i.property] using hAU i.val) + (fun i => hM i.val) (fun i k hik => hpair i.val k.val (by intro he; exact hik (Subtype.ext he))) + (hcap j) (by omega) hM0 + change u j*M ≤ 2*K at H + apply Nat.le_of_mul_le_mul_right (c := M) + · nlinarith + · exact hM0 + have hlocal (j : κ) : u j*M ≤ 2*(Region j).card := by + let E : {i : ι // owner i = j} → Finset X := fun i => A i.val \ (univ.erase j).biUnion P + have hEc (i : {i : ι // owner i = j}) : M-D ≤ (E i).card := by + have he : A i.val ∩ (univ.erase j).biUnion P = + (univ.erase j).biUnion (fun k => A i.val ∩ P k) := by + ext a + simp only [mem_inter,mem_biUnion] + aesop + have H : (A i.val ∩ (univ.erase j).biUnion P).card ≤ D := by + rw [he] + calc + _ ≤ ∑ k ∈ univ.erase j, (A i.val ∩ P k).card := card_biUnion_le + _ ≤ ∑ _k ∈ univ.erase j, 1 := by + apply sum_le_sum + intro k hk + apply hcross + simpa [i.property] using (mem_erase.mp hk).1 + _ ≤ D := by simp [D] + have H' := card_sdiff_add_card_inter (A i.val) ((univ.erase j).biUnion P) + rw [hM] at H' + change M-D ≤ (A i.val \ (univ.erase j).biUnion P).card + omega + have hE (i : {i : ι // owner i = j}) : E i ⊆ Region j := by + intro a ha + obtain ⟨ha,hn⟩ := mem_sdiff.mp ha + apply mem_sdiff.mpr + exact ⟨by simpa [i.property] using hAU i.val ha,hn⟩ + have hp (i k : {i : ι // owner i = j}) (hik : i ≠ k) : (E i ∩ E k).card ≤ 1 := by + apply le_trans (card_le_card ?_) (hpair i.val k.val (by intro he; exact hik (Subtype.ext he))) + intro a ha + exact mem_inter.mpr ⟨(mem_sdiff.mp (mem_inter.mp ha).1).1,(mem_sdiff.mp (mem_inter.mp ha).2).1⟩ + have H := PlaneCount.union_lower E (M-D) hEc hp + have H' : (univ.biUnion E).card ≤ (Region j).card := by + apply card_le_card + intro a ha + obtain ⟨i,hi,ha⟩ := mem_biUnion.mp ha + exact hE i ha + have hnum : M ≤ 2*(M-D-u j) := by + have h1 := hu j + change 4*D ≤ M at hDM + omega + change u j*(M-D-u j) ≤ (univ.biUnion E).card at H + nlinarith [Nat.mul_le_mul_left (u j) hnum] + have hregions : (↑(univ : Finset κ) : Set κ).PairwiseDisjoint Region := + PlaneCount.exclusive_disjoint P + have hregionU : univ.biUnion Region ⊆ U := by + intro a ha + obtain ⟨j,hj,ha⟩ := mem_biUnion.mp ha + exact hPU j (mem_sdiff.mp ha).1 + have hsumu : ∑ j, u j = Fintype.card ι := by + simp only [u,Fintype.card_subtype] + exact (card_eq_sum_card_fiberwise (s := (univ : Finset ι)) (t := univ) + (by intro _ _; exact mem_univ _)).symm + calc + _ = ∑ j, u j*M := by rw [← sum_mul,hsumu] + _ ≤ ∑ j, 2*(Region j).card := sum_le_sum (fun j _ => hlocal j) + _ = 2*(univ.biUnion Region).card := by rw [card_biUnion hregions,mul_sum] + _ ≤ 2*U.card := Nat.mul_le_mul_left _ (card_le_card hregionU) + +end +end SharpLogRamsey.SinglePlaneCount + +end + +namespace SharpLogRamsey.SurfaceRichLines +open MvPolynomial Finset AffineIncidence +open scoped BigOperators Classical +variable {K : Type*} [Field K] [Infinite K] +noncomputable section +omit [Infinite K] in + +lemma plane_crossing (S : Finset (Fin 3 → K)) (x v : Fin 3 → K) (hv : v ≠ 0) + (L : MvPolynomial (Fin 3) K) (hL : L.totalDegree ≤ 1) + (hn : LineFlatness.restrictLine x v L ≠ 0) : + (S.filter (fun y => y ∈ carrier x v ∧ eval y L = 0)).card ≤ 1 := by + classical + let A := S.filter (fun y => y ∈ carrier x v ∧ eval y L = 0) + let f : K → Fin 3 → K := fun t => x+t • v + let T := A.preimage f (parametrization_injective _ _ hv).injOn + have hc : T.card = A.card := by + rw [card_preimage] + congr 1 + apply filter_eq_self.mpr + intro y hy + exact (mem_filter.mp hy).2.1 + have H : T.card ≤ (LineFlatness.restrictLine x v L).natDegree := by + apply Polynomial.card_le_degree_of_subset_roots + intro t ht + apply (Polynomial.mem_roots hn).mpr + change Polynomial.eval t (LineFlatness.restrictLine x v L) = 0 + rw [RichLinePolynomial.restriction_eval] + have H := (mem_filter.mp (mem_preimage.mp ht)).2.2 + have he : f t = (fun j => x j+v j*t) := by ext j; simp [f,mul_comm] + simpa only [he] using H + rw [hc] at H + exact H.trans ((RichLinePolynomial.restriction_degree x v L).trans hL) + +variable {ι : Type*} [Fintype ι] + +theorem card_le {p : ℕ} [CharP K p] [IsAlgClosed K] + (F : MvPolynomial (Fin 3) K) (hF : F ≠ 0) (hdeg : F.totalDegree < p) + (hs : Squarefree F) (h2 : (2 : K) ≠ 0) + (x v : ι → Fin 3 → K) (hv : ∀ i, v i ≠ 0) + (hd : Function.Injective (fun i => carrier (x i) (v i))) + (hzero : ∀ i, LineFlatness.restrictLine (x i) (v i) F = 0) + (S : Finset (Fin 3 → K)) (M Kp : ℕ) + (hM : ∀ i, M ≤ (onLine x v S i).card) + (hcap : ∀ L : MvPolynomial (Fin 3) K, L ∣ F → L.totalDegree = 1 → + (S.filter (fun y => eval y L = 0)).card ≤ Kp) + (hMD : 6*F.totalDegree < M) (hKM : 8*Kp ≤ M^2) : + Fintype.card ι ≤ 2*S.card/M+2*S.card/(M-3*F.totalDegree)+8*F.totalDegree^2 := by + classical + obtain ⟨planes,G,hG,hGs,hprod,hplanes,hpair,hdiv,hng,hde⟩ := + PlaneDecomposition.exists_decomposition F hF hs + let κ := Fin planes.length + let L : κ → MvPolynomial (Fin 3) K := planes.get + have hLd (j : κ) : (L j).totalDegree = 1 := hplanes _ (List.get_mem planes j) + have hLdiv (j : κ) : L j ∣ F := hdiv _ (List.get_mem planes j) + have hLc (j k : κ) (hjk : j ≠ k) : IsRelPrime (L j) (L k) := by + rcases lt_or_gt_of_ne hjk with H | H + · exact hpair.rel_get_of_lt H + · exact (hpair.rel_get_of_lt H).symm + let On : ι → κ → Prop := fun i j => LineFlatness.restrictLine (x i) (v i) (L j) = 0 + let multiple : Finset ι := univ.filter (fun i => ∃ j k, j ≠ k ∧ On i j ∧ On i k) + let single : Finset ι := univ.filter (fun i => (∃ j, On i j) ∧ i ∉ multiple) + let none : Finset ι := univ.filter (fun i => ¬∃ j, On i j) + have hm : multiple.card ≤ 2*F.totalDegree^2 := by + let Both (j k : κ) := univ.filter (fun i => On i j ∧ On i k) + have hB (j k : κ) (hjk : j ≠ k) : (Both j k).card ≤ 2 := by + have H := CommonLines.card_le (L j) (L k) (hLc j k hjk) + (fun i : Both j k => x i) (fun i : Both j k => v i) (fun i => hv i) + (fun i l H => Subtype.ext (hd H)) + (fun i t => NonplaneRichLines.eval_of_restrict_zero _ _ _ (mem_filter.mp i.property).2.1 _ ⟨t,rfl⟩) + (fun i t => NonplaneRichLines.eval_of_restrict_zero _ _ _ (mem_filter.mp i.property).2.2 _ ⟨t,rfl⟩) + simpa only [Fintype.card_coe,hLd,mul_one] using H + have hc : multiple ⊆ univ.biUnion (fun j : κ => (univ.erase j).biUnion (Both j)) := by + intro i hi + obtain ⟨j,k,hjk,hj,hk⟩ := (mem_filter.mp hi).2 + exact mem_biUnion.mpr ⟨j,mem_univ j,mem_biUnion.mpr + ⟨k,mem_erase.mpr ⟨hjk.symm,mem_univ k⟩,mem_filter.mpr ⟨mem_univ i,hj,hk⟩⟩⟩ + calc + _ ≤ (univ.biUnion (fun j : κ => (univ.erase j).biUnion (Both j))).card := card_le_card hc + _ ≤ ∑ j : κ, ((univ.erase j).biUnion (Both j)).card := card_biUnion_le + _ ≤ ∑ j : κ, ∑ k ∈ univ.erase j, 2 := by + apply sum_le_sum + intro j hj + apply le_trans card_biUnion_le + apply sum_le_sum + intro k hk + exact hB j k (mem_erase.mp hk).1.symm + _ ≤ 2*planes.length^2 := by + simp only [sum_const, Nat.nsmul_eq_mul, card_erase_of_mem (mem_univ _), card_univ] + have H : planes.length - 1 ≤ planes.length := Nat.sub_le _ _ + dsimp [κ] + simp only [Fintype.card_fin] + nlinarith [Nat.mul_le_mul_left planes.length H] + _ ≤ 2*F.totalDegree^2 := by nlinarith + have hsing : single.card ≤ 2*S.card/M := by + have howner : ∀ i : single, ∃ j, On i.val j := fun i => (mem_filter.mp i.property).2.1 + choose owner ho using howner + have hchoices : ∀ i : single, ∃ A ⊆ onLine x v S i.val, A.card = M := + fun i => exists_subset_card_eq (hM i.val) + choose A hA hAc using hchoices + let P : κ → Finset (Fin 3 → K) := fun j => S.filter (fun y => eval y (L j) = 0) + have hAP (i : single) : A i ⊆ P (owner i) := by + intro y hy + have hy' := mem_filter.mp (hA i hy) + apply mem_filter.mpr + exact ⟨hy'.1,NonplaneRichLines.eval_of_restrict_zero _ _ _ (ho i) y hy'.2⟩ + have hc (i : single) (j : κ) (hj : j ≠ owner i) : (A i ∩ P j).card ≤ 1 := by + have hn : ¬On i.val j := by + intro H + exact (mem_filter.mp i.property).2.2 (mem_filter.mpr ⟨mem_univ i.val, + j,owner i,hj,H,ho i⟩) + apply le_trans (card_le_card ?_) (plane_crossing S (x i) (v i) (hv i) (L j) (hLd j).le hn) + intro y hy + have hAi := mem_filter.mp (hA i (mem_inter.mp hy).1) + exact mem_filter.mpr ⟨hAi.1,hAi.2,(mem_filter.mp (mem_inter.mp hy).2).2⟩ + have hp (i k : single) (hik : i ≠ k) : (A i ∩ A k).card ≤ 1 := by + exact points_intersection_le (fun i : single => x i) (fun i : single => v i) + (fun i => hv i) (fun i k H => Subtype.ext (hd H)) A + (fun i _ hy => (mem_filter.mp (hA i hy)).2) i k hik + have H := SinglePlaneCount.card_mul_le A P owner S M Kp (by omega) hAc hAP + (fun j => filter_subset _ _) (fun j => hcap (L j) (hLdiv j) (hLd j)) hc hp hKM + (by simp only [κ,Fintype.card_fin]; omega) + apply (Nat.le_div_iff_mul_le (by omega)).mpr + simpa only [Fintype.card_coe] using H + have hn : none.card ≤ 2*S.card/(M-3*F.totalDegree)+6*F.totalDegree^2 := by + have hz (i : none) : LineFlatness.restrictLine (x i) (v i) G = 0 := by + let φ : MvPolynomial (Fin 3) K →ₐ[K] Polynomial K := + aeval (fun j => Polynomial.C (x i j)+Polynomial.C (v i j)*Polynomial.X) + have H : φ F = 0 := hzero i + rw [hprod,map_mul] at H + apply (mul_eq_zero.mp H).resolve_left + intro hp0 + rw [map_list_prod,List.prod_eq_zero_iff,List.mem_map] at hp0 + obtain ⟨J,hJ,hφJ⟩ := hp0 + obtain ⟨j,rfl⟩ := List.mem_iff_get.mp hJ + exact (mem_filter.mp i.property).2 ⟨j,hφJ⟩ + have H := NonplaneRichLines.card_le G hG (by omega) hGs h2 hng + (fun i : none => x i) (fun i : none => v i) (fun i => hv i) + (fun i k H => Subtype.ext (hd H)) hz S M (fun i => hM i) (by omega) + have H' : none.card ≤ 2*S.card/(M-3*G.totalDegree)+6*G.totalDegree^2 := by + simpa only [Fintype.card_coe] using H + apply H'.trans + apply Nat.add_le_add + · exact Nat.div_le_div_left (by omega) (by omega) + · nlinarith + have hsplit : Fintype.card ι ≤ single.card+multiple.card+none.card := by + have H : (univ : Finset ι) ⊆ single ∪ multiple ∪ none := by + intro i hi + by_cases he : ∃ j, On i j + · by_cases hm : i ∈ multiple + · exact mem_union_left _ (mem_union_right _ hm) + · exact mem_union_left _ (mem_union_left _ (mem_filter.mpr ⟨hi,he,hm⟩)) + · exact mem_union_right _ (mem_filter.mpr ⟨hi,he⟩) + have H' := (card_le_card H).trans ((card_union_le _ _).trans (Nat.add_le_add_right (card_union_le _ _) _)) + simpa only [card_univ] using H' + omega + +end +end SharpLogRamsey.SurfaceRichLines + +section + +section + +open scoped BigOperators Classical +open Finset +namespace SharpLogRamsey.Sampling +variable {V : Type*} [Fintype V] [DecidableEq V] + +end SharpLogRamsey.Sampling +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/EightIntersections.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/EightIntersections.lean new file mode 100644 index 0000000000000000000000000000000000000000..9d316921a81e13fad62e7f7962e787efdca43c13 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/EightIntersections.lean @@ -0,0 +1,98 @@ +import Mathlib + +namespace OAI + +section +namespace SharpLogRamsey.CapComposition +open Finset Real +open scoped Classical BigOperators +noncomputable section +variable {α : Type*} + +def powers (L : Finset (Finset α)) (U : Finset α) : ℕ → Finset (Finset α) + | 0 => {U} + | k+1 => (powers L U k).biUnion (fun A => L.image (fun D => A∩D)) + +lemma powers_step (L : Finset (Finset α)) (U A D : Finset α) (k : ℕ) + (hA : A ∈ powers L U k) (hD : D ∈ L) : A∩D ∈ powers L U (k+1) := + mem_biUnion.mpr ⟨A,hA,mem_image.mpr ⟨D,hD,rfl⟩⟩ + +lemma powers_card (L : Finset (Finset α)) (U : Finset α) (k : ℕ) : + (powers L U k).card ≤ L.card^k := by + induction k with + | zero => simp [powers] + | succ k ih => + calc + _ ≤ ∑ A ∈ powers L U k,(L.image (fun D => A∩D)).card := card_biUnion_le + _ ≤ ∑ _A ∈ powers L U k,L.card := sum_le_sum (fun A hA => card_image_le) + _ = (powers L U k).card*L.card := by simp + _ ≤ L.card^k*L.card := Nat.mul_le_mul_right _ ih + _ = _ := (pow_succ _ _).symm + +lemma loss_inter (S A D : Finset α) : + (S\(A∩D)).card ≤ (S\A).card+(S\D).card := by + have he : S\(A∩D)=(S\A)∪(S\D) := by ext x; simp; tauto + rw [he] + exact card_union_le _ _ + +lemma remains_nonempty (S A : Finset α) (hS : S.Nonempty) (δ : ℝ) (hδ : δ < 1) + (hloss : ((S\A).card:ℝ) ≤ δ*S.card) : A.Nonempty := by + by_contra h + have he : A=∅ := not_nonempty_iff_eq_empty.mp h + rw [he,sdiff_empty] at hloss + have hs : (0:ℝ) < S.card := by exact_mod_cast card_pos.mpr hS + nlinarith + +theorem eight_intersections (U S : Finset α) (hS : S.Nonempty) (hSU : S ⊆ U) + (L : Finset (Finset α)) (m q ρ : ℝ) (hm : 0 ≤ m) (_hq : 0 ≤ q) + (hρ : 0 ≤ ρ) (hρhalf : ρ ≤ 1/2) (hρpow : q*ρ^7 ≤ 1) + (hfirst : ∀ D ∈ L,(D.card:ℝ) ≤ q*m) + (hstep : ∀ A,A ⊆ U → A.Nonempty → ∃ D ∈ L,D ⊆ U ∧ + ((S\D).card:ℝ) ≤ (3/100:ℝ)*S.card ∧ + ((A∩D).card:ℝ) ≤ m+ρ*A.card) : + ∃ A ∈ powers L U 8,A ⊆ U ∧ (A.card:ℝ) ≤ 3*m ∧ (S.card:ℝ)/2 ≤ (S∩A).card := by + have hU : U.Nonempty := hS.mono hSU + obtain ⟨D,hD,hDU,hloss,_hcont⟩ := hstep U Subset.rfl hU + have hinit : D ∈ powers L U 1 := by + have hh := powers_step L U U D 0 (by simp [powers]) hD + simpa only [inter_eq_right.mpr hDU] using hh + have hex : ∀ r : ℕ,r ≤ 7 → ∃ A ∈ powers L U (r+1),A ⊆ U ∧ + ((S\A).card:ℝ) ≤ ((r:ℝ)+1)*(3/100:ℝ)*S.card ∧ + (A.card:ℝ) ≤ 2*m+q*m*ρ^r := by + intro r + induction r with + | zero => + intro hr + refine ⟨D,hinit,hDU,by simpa using hloss,?_⟩ + have hh := hfirst D hD + simpa only [pow_zero,mul_one] using hh.trans (by linarith : q*m ≤ 2*m+q*m) + | succ r ih => + intro hr + obtain ⟨A,hA,hAU,hl,hsize⟩ := ih (by omega) + have hAne : A.Nonempty := remains_nonempty S A hS (((r:ℝ)+1)*(3/100:ℝ)) + (by + have hh : (r:ℝ) ≤ 6 := by exact_mod_cast (by omega : r ≤ 6) + linarith) hl + obtain ⟨E,hE,_hEU,hEl,hEc⟩ := hstep A hAU hAne + refine ⟨A∩E,powers_step L U A E (r+1) hA hE,inter_subset_left.trans hAU,?_,?_⟩ + · have hh : ((S\(A∩E)).card:ℝ) ≤ (S\A).card+(S\E).card := by exact_mod_cast loss_inter S A E + push_cast + linarith + · have hh := mul_le_mul_of_nonneg_left hsize hρ + rw [pow_succ] + have hb : 2*m*ρ ≤ m := by nlinarith + nlinarith + obtain ⟨A,hA,hAU,hl,hsize⟩ := hex 7 (le_refl _) + refine ⟨A,hA,hAU,?_,?_⟩ + · have hh := mul_le_mul_of_nonneg_right hρpow hm + nlinarith + · have he : ((S\A).card:ℝ)+(S∩A).card=S.card := by exact_mod_cast card_sdiff_add_card_inter S A + norm_num at hl + linarith + +end +end SharpLogRamsey.CapComposition + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/GeometricCover.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/GeometricCover.lean new file mode 100644 index 0000000000000000000000000000000000000000..42aea337dacca04ea96e4788372e963ea1d03781 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/GeometricCover.lean @@ -0,0 +1,38 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Spatial.SpatialValidated +import OAI.Combinatorics.SharpRamsey.Geometry.QuotientHeaderGaps +import OAI.Combinatorics.SharpRamsey.Learning.SizeHeader + +namespace OAI + +section +namespace SharpLogRamsey.GeometricCover +open Finset Real Incidence +open scoped Classical +noncomputable section +variable {K V : Type} [Field K] [AddCommGroup V] [Module K V] + +def Validated (q P H : ℝ) (r : ℕ) + (U : Finset (Projectivization K V)) + (UT : Finset (Projectivization K (Module.Dual K V))) + (n t : ℕ) (τ : ℝ) : Prop := + ∃ F : Finset (Finset (Projectivization K V)), + (∀ W∈F,W⊆U ∧ (W.card:ℝ)≤100000*q^r/t) ∧ + (∀ S T,S⊆U → S.card=n → T⊆UT → T.card=t → + (incidenceCount S T:ℝ)≤τ*(n:ℝ)*t/q → + ∃ W∈F,(99/100:ℝ)*n≤(S∩W).card) ∧ + log ((F.card:ℝ)+1)≤H*q*P*(log ((U.card:ℝ)/n)+log ((UT.card:ℝ)/t)+P) + +lemma quotient_product {q b : ℝ} (hq : 0 C*σ^(-100*beta η)) atTop (𝓝 0) := by + simpa using (tendsto_rpow_neg_atTop (by have := beta_pos hη; positivity : 0<100*beta η)).const_mul C + filter_upwards [ih η hη C' hC', + eventually_uniform_L hη (eventually_ge_atTop (1000000:ℝ)),eventually_uniform_R hη 1, + eventually_training_loss hη C 1 (by linarith) (by norm_num), + eventually_P_le_linear hη (1/5) (by norm_num), + hdec.eventually (gt_mem_nhds (by norm_num : (0:ℝ)<1/1000000)), + eventually_ge_atTop (1000000000000:ℝ)] + with σ hs hL hR hbsmall hPσ hτsmall hσ + intro q _ hq hex V _ _ _ hdim D R had U UT n t b τ hn ht hnu htu hb hbu hτ hτu hplo hphi + let P := scaleP σ η D R + have hσ1 : 1≤σ := by linarith + have hLP : scaleL σ η D≤P := le_mul_of_one_le_right (by linarith [hL D R had]) (hR D R had) + have hP : 1000000≤P := (hL D R had).trans hLP + have hbP : b≤P := by + have hh := hbsmall D R had b 0 hbu (mul_nonneg (by linarith) (rpow_nonneg (by linarith) _)) + simp only [mul_zero,add_zero,one_mul] at hh + exact hh.trans hLP + have hbσ : b≤σ/5 := hbP.trans (by dsimp only [P]; linarith [hPσ D R had]) + have hsmall : τ≤1/1000000 := hτu.trans hτsmall.le + have hq' : (0:ℝ) ring + have hd5 : Module.finrank (ZMod q) V=(i+2)+3 := by omega + by_cases hnt : n≤t + · obtain ⟨A,hAs,hAc,hAl⟩ := hdesc V hdim U UT n t hn ht hnu htu hnt hplo hphi + obtain ⟨F,hFs,hFc,hFl⟩ := return_gap_cover hd5 A U UT n t hn ht hnu htu P b (by linarith) hb hbP + (fun W hW => (hAs W hW).2) (by simpa only [hcard] using hphi) + (by simpa only [hcard] using hplo) + refine ⟨F,by simpa only [hcard] using hFs,?_,?_⟩ + · intro S T hSU hSn hTU hTt hsp + exact hFc S T hSU hSn hTU hTt (hspval S T hsp) (hAc S T hSU hSn hTU hTt hsp) + · simp only [hcard,Nat.cast_add,Nat.cast_ofNat] at hFl + dsimp only [P] at * + nlinarith only [hFl,hAl,hz] + · have htn : t≤n := le_of_not_ge hnt + let e := bidual (K:=ZMod q) (V:=V) + have hcU : (U.image e).card=U.card := card_image_of_injective _ e.injective + have hddual : Module.finrank (ZMod q) (Module.Dual (ZMod q) V)=i+5 := Subspace.dual_finrank_eq.trans hdim + obtain ⟨A,hAs,hAc,hAl⟩ := hdesc (Module.Dual (ZMod q) V) hddual UT (U.image e) t n + ht hn htu (by rwa [hcU]) htn (by simpa only [mul_comm] using hplo) (by simpa only [mul_comm] using hphi) + obtain ⟨F,hFs,hFc,hFl⟩ := reverse_gap_cover hd5 A U UT n t hn ht hnu htu P (by linarith) + (fun W hW => (hAs W hW).2) (by simpa only [hcard] using hphi) + refine ⟨F,by simpa only [hcard] using hFs,?_,?_⟩ + · intro S T hSU hSn hTU hTt hsp + have hcS : (S.image e).card=n := (card_image_of_injective _ e.injective).trans hSn + have hinc : incidenceCount T (S.image e)=incidenceCount S T := incidenceCount_bidual S T + have hspread : (incidenceCount T (S.image e):ℝ)≤τ*(t:ℝ)*n/q := by + rw [hinc] + convert hsp using 1; ring + exact hFc S T hSU hSn hTt (hspval S T hsp) + (hAc T (S.image e) hTU hTt (image_subset_image hSU) hcS hspread) + · simp only [hcard,Nat.cast_add,Nat.cast_ofNat] at hFl + rw [hcU] at hAl + dsimp only [P] at * + nlinarith only [hFl,hAl,hz] + +theorem uniform_all (i : ℕ) : ∃ H : ℝ,0≤H ∧ Uniform (i+4) H := by + induction i with + | zero => exact ⟨7000,by norm_num,uniform_four⟩ + | succ i ih => + obtain ⟨H,hH,ih⟩ := ih + exact ⟨16*H+32*(i:ℝ)+3000,by positivity,uniform_step i H hH ih⟩ + +end +end SharpLogRamsey.GeometricCover + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/HessianTangent.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/HessianTangent.lean new file mode 100644 index 0000000000000000000000000000000000000000..977462157a4b2f48673929f91b3134290aa017ec --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/HessianTangent.lean @@ -0,0 +1,464 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.RichLines + +namespace OAI + +/-! Incidence bounds for rich lines and finite point configurations. -/ + +section +section +section +open Finset Finsupp +namespace SharpLogRamsey.FlatnessCore +variable {σ K : Type*} [Fintype σ] [DecidableEq σ] [Field K] +variable {p : ℕ} [CharP K p] +variable {τ R : Type*} [CommRing R] [Algebra K R] +variable [Fintype τ] [DecidableEq τ] +lemma hessian_zero_of_tangent_zero (F : MvPolynomial (Option σ) K) + (h : MvPowerSeries σ K) (hroot : MvPolynomial.aeval (branchPoint h) F = 0) + (hu : IsUnit (MvPolynomial.aeval (branchPoint h) (MvPolynomial.pderiv none F))) + (ht : ∀ a b, (∑ j, ∑ i, MvPolynomial.aeval (branchPoint h) + (MvPolynomial.pderiv i (MvPolynomial.pderiv j F)) * + branchTangent h a i * branchTangent h b j) = 0) : + ∀ a b, MvPowerSeries.pderiv a (MvPowerSeries.pderiv b h) = 0 := by + intro a b + have H := deriv2_aeval (MvPowerSeries.pderiv a) (MvPowerSeries.pderiv b) + (branchPoint h) F + rw [hroot,map_zero,map_zero] at H + change 0 = (∑ j, ∑ i, _ * branchTangent h a i * branchTangent h b j) + _ at H + rw [ht a b,zero_add,branch_second_sum] at H + exact (IsUnit.mul_right_eq_zero hu).mp H.symm + +def scaledTangent (g : Option σ → R) (a : σ) : Option σ → R := + fun o => o.elim (-g (some a)) (fun i => if i = a then g none else 0) + +noncomputable def flatnessPolynomial (F : MvPolynomial (Option σ) K) (a b : σ) : + MvPolynomial (Option σ) K := + ∑ j, ∑ i, MvPolynomial.pderiv i (MvPolynomial.pderiv j F) * + scaledTangent (fun o => MvPolynomial.pderiv o F) a i * + scaledTangent (fun o => MvPolynomial.pderiv o F) b j +omit [Fintype σ] in + +lemma aeval_scaledTangent (x : Option σ → R) (F : MvPolynomial (Option σ) K) + (a : σ) (i : Option σ) : + MvPolynomial.aeval x (scaledTangent (fun o => MvPolynomial.pderiv o F) a i) = + scaledTangent (fun o => MvPolynomial.aeval x (MvPolynomial.pderiv o F)) a i := by + cases i with + | none => simp [scaledTangent] + | some i => by_cases hi : i = a <;> simp [scaledTangent,hi] + +lemma first_branch_derivative (F : MvPolynomial (Option σ) K) + (h : MvPowerSeries σ K) (a : σ) : + MvPowerSeries.pderiv a (MvPolynomial.aeval (branchPoint h) F) = + MvPolynomial.aeval (branchPoint h) (MvPolynomial.pderiv none F) * + MvPowerSeries.pderiv a h + + MvPolynomial.aeval (branchPoint h) (MvPolynomial.pderiv (some a) F) := by + rw [deriv_aeval,Fintype.sum_option] + simp [branchPoint,MvPowerSeries.pderiv_X,Pi.single_apply] + +lemma scaled_branch_tangent (F : MvPolynomial (Option σ) K) + (h : MvPowerSeries σ K) (hroot : MvPolynomial.aeval (branchPoint h) F = 0) + (a : σ) (i : Option σ) : + MvPolynomial.aeval (branchPoint h) (MvPolynomial.pderiv none F) * + branchTangent h a i = + scaledTangent (fun o => MvPolynomial.aeval (branchPoint h) + (MvPolynomial.pderiv o F)) a i := by + cases i with + | none => + have H := first_branch_derivative F h a + rw [hroot,map_zero] at H + change _ * MvPowerSeries.pderiv a h = -_ + exact eq_neg_of_add_eq_zero_left H.symm + | some i => simp [branchTangent,branchPoint,scaledTangent,MvPowerSeries.pderiv_X, + Pi.single_apply,mul_ite] + +lemma flatness_root_implies_hessian_zero (F : MvPolynomial (Option σ) K) + (h : MvPowerSeries σ K) (hroot : MvPolynomial.aeval (branchPoint h) F = 0) + (hu : IsUnit (MvPolynomial.aeval (branchPoint h) (MvPolynomial.pderiv none F))) + (hflat : ∀ a b, MvPolynomial.aeval (branchPoint h) (flatnessPolynomial F a b) = 0) : + ∀ a b, MvPowerSeries.pderiv a (MvPowerSeries.pderiv b h) = 0 := by + apply hessian_zero_of_tangent_zero F h hroot hu + intro a b + let z := MvPolynomial.aeval (branchPoint h) (MvPolynomial.pderiv none F) + have H := hflat a b + simp only [flatnessPolynomial,map_sum,map_mul,aeval_scaledTangent] at H + have he : MvPolynomial.aeval (branchPoint h) (flatnessPolynomial F a b) = + z*z*(∑ j, ∑ i, MvPolynomial.aeval (branchPoint h) + (MvPolynomial.pderiv i (MvPolynomial.pderiv j F)) * + branchTangent h a i * branchTangent h b j) := by + simp only [flatnessPolynomial,map_sum,map_mul,aeval_scaledTangent, + ← scaled_branch_tangent F h hroot,Finset.mul_sum] + apply Finset.sum_congr rfl + intro j hj + apply Finset.sum_congr rfl + intro i hi + dsimp [z] + ring + rw [hflat a b] at he + exact (IsUnit.mul_right_eq_zero (hu.mul hu)).mp he.symm + +end SharpLogRamsey.FlatnessCore + +namespace SharpLogRamsey.LocalFlatness +open SharpLogRamsey.FlatnessCore +variable {σ K : Type*} [Fintype σ] [DecidableEq σ] [Field K] +omit [Fintype σ] [DecidableEq σ] in + +lemma branch_constantCoeff (h : MvPowerSeries σ K) + (hh : MvPowerSeries.constantCoeff h = 0) (F : MvPolynomial (Option σ) K) : + MvPowerSeries.constantCoeff (MvPolynomial.aeval (branchPoint h) F) = + MvPolynomial.constantCoeff F := by + induction F using MvPolynomial.induction_on with + | C c => simp [← MvPowerSeries.c_eq_algebraMap] + | add f g hf hg => simp [hf,hg] + | mul_X f i hf => cases i <;> simp [branchPoint,hh] +omit [Fintype σ] [DecidableEq σ] in + +lemma rename_aeval (lin : MvPolynomial σ K) (G : MvPolynomial (Option σ) K) : + MvPolynomial.rename Option.some (MvPolynomial.aeval + (fun o => o.elim lin MvPolynomial.X) G) = + MvPolynomial.aeval (fun o => o.elim (MvPolynomial.rename Option.some lin) + (fun i => MvPolynomial.X (some i))) G := by + induction G using MvPolynomial.induction_on with + | C c => simp + | add f g hf hg => simp only [map_add,hf,hg] + | mul_X f i hf => cases i <;> simp only [map_mul,MvPolynomial.aeval_X,hf, + Option.elim_none,Option.elim_some,MvPolynomial.rename_X] + +omit [Fintype σ] [DecidableEq σ] in + +lemma plane_factor_of_zero (lin : MvPolynomial σ K) (G : MvPolynomial (Option σ) K) + (hz : MvPolynomial.aeval (fun o => o.elim lin MvPolynomial.X) G = 0) : + MvPolynomial.X none - MvPolynomial.rename Option.some lin ∣ G := by + let L : MvPolynomial (Option σ) K := MvPolynomial.X none-MvPolynomial.rename Option.some lin + let I := Ideal.span ({L} : Set (MvPolynomial (Option σ) K)) + have he : MvPolynomial.aeval (fun o => o.elim (MvPolynomial.rename Option.some lin) + (fun i => MvPolynomial.X (some i))) G = 0 := by + rw [← rename_aeval,hz,map_zero] + have H := aeval_sub_mem I (fun o => MvPolynomial.X o) + (fun o => o.elim (MvPolynomial.rename Option.some lin) (fun i => MvPolynomial.X (some i))) + (fun o => by cases o; exact Ideal.subset_span (Set.mem_singleton L); simp) G + rw [he,sub_zero,MvPolynomial.aeval_X_left_apply] at H + exact Ideal.mem_span_singleton.mp H + +theorem exists_plane_factor_of_flatness {p : ℕ} [CharP K p] + (G F : MvPolynomial (Option σ) K) (hdeg : G.totalDegree < p) + (hdiv : F ∣ G) (hF : MvPolynomial.constantCoeff F = 0) + (hDz : MvPolynomial.constantCoeff (MvPolynomial.pderiv none G) ≠ 0) + (hflat : ∀ a b, F ∣ flatnessPolynomial G a b) : + ∃ lin : MvPolynomial σ K, lin.totalDegree ≤ 1 ∧ + MvPolynomial.constantCoeff lin = 0 ∧ + MvPolynomial.X none-MvPolynomial.rename Option.some lin ∣ G := by + obtain ⟨J,hJ⟩ := hdiv + have hG : MvPolynomial.constantCoeff G = 0 := by simp [hJ,hF] + have hJ0 : MvPolynomial.constantCoeff J ≠ 0 := by + intro hz + apply hDz + simp [hJ,Derivation.leibniz,smul_eq_mul,hF,hz] + obtain ⟨h,hh,hr⟩ := ImplicitBranch.exists_formal_branch G hG hDz + change MvPolynomial.aeval (branchPoint h) G = 0 at hr + have hJu : IsUnit (MvPolynomial.aeval (branchPoint h) J) := by + rw [MvPowerSeries.isUnit_iff_constantCoeff,branch_constantCoeff h hh,isUnit_iff_ne_zero] + exact hJ0 + have hFr : MvPolynomial.aeval (branchPoint h) F = 0 := by + rw [hJ,map_mul] at hr + exact (IsUnit.mul_left_eq_zero hJu).mp hr + have hu : IsUnit (MvPolynomial.aeval (branchPoint h) (MvPolynomial.pderiv none G)) := by + rw [MvPowerSeries.isUnit_iff_constantCoeff,branch_constantCoeff h hh,isUnit_iff_ne_zero] + exact hDz + have hf : ∀ a b, MvPolynomial.aeval (branchPoint h) (flatnessPolynomial G a b) = 0 := by + intro a b + obtain ⟨V,hV⟩ := hflat a b + simp [hV,hFr] + have hess := flatness_root_implies_hessian_zero G h hr hu hf + have hz := flat_branch_zero_plane G hdeg h hr hess + refine ⟨MvPowerSeries.truncTotal 2 h,?_,?_,plane_factor_of_zero _ G hz⟩ + · have H := MvPowerSeries.totalDegree_truncTotal_lt h (by norm_num : (2:ℕ) ≠ 0) + omega + · simpa [MvPowerSeries.constantCoeff_truncTotal_eq_ite] using hh + +end SharpLogRamsey.LocalFlatness + +open scoped BigOperators +open MvPolynomial Finsupp +namespace SharpLogRamsey.PolynomialGeometry +variable {σ K : Type*} [Field K] + +lemma totalDegree_pderiv_lt (F : MvPolynomial σ K) (i : σ) + (hi : pderiv i F ≠ 0) : (pderiv i F).totalDegree < F.totalDegree := by + classical + obtain ⟨d,hd,he⟩ := Finset.exists_mem_eq_sup _ (MvPolynomial.support_nonempty.mpr hi) + (fun d : σ →₀ ℕ => d.sum fun _ e => e) + have hc : F.coeff (d+Finsupp.single i 1) ≠ 0 := by + have H := MvPolynomial.mem_support_iff.mp hd + rw [MvPolynomial.coeff_pderiv] at H + exact (mul_ne_zero_iff.mp H).1 + have H := MvPolynomial.le_totalDegree (MvPolynomial.mem_support_iff.mpr hc) + change Finsupp.degree (d+Finsupp.single i 1) ≤ F.totalDegree at H + have H' : d.degree+1 ≤ F.totalDegree := by + simpa only [map_add, Finsupp.degree_single] using H + change (pderiv i F).support.sup (fun d : σ →₀ ℕ => d.sum fun _ e => e) < F.totalDegree + rw [he] + exact H' + +lemma not_dvd_pderiv (F : MvPolynomial σ K) (i : σ) (hi : pderiv i F ≠ 0) : + ¬F ∣ pderiv i F := by + intro h + exact (totalDegree_pderiv_lt F i hi).not_ge + (MvPolynomial.totalDegree_le_of_dvd_of_isDomain h hi) + +lemma not_dvd_squarefree_derivative (G F : MvPolynomial σ K) + (hs : Squarefree G) (hF : Irreducible F) (hd : F ∣ G) (i : σ) + (hi : pderiv i F ≠ 0) : ¬ F ∣ pderiv i G := by + obtain ⟨J,rfl⟩ := hd + intro h + have hp : Prime F := irreducible_iff_prime.mp hF + have hn : ¬F ∣ J := by + intro hj + exact hF.not_isUnit (hs F (mul_dvd_mul dvd_rfl hj)) + have he : pderiv i (F*J) = pderiv i F*J+F*pderiv i J := by + rw [MvPolynomial.pderiv_mul] + rw [he,dvd_add_left (dvd_mul_right F _)] at h + rcases hp.dvd_mul.mp h with h|h + · exact not_dvd_pderiv F i hi h + · exact hn h + +lemma totalDegree_pos_of_irreducible (F : MvPolynomial σ K) (hF : Irreducible F) : + 0 < F.totalDegree := by + by_contra! h + have he : F = C (F.coeff 0) := totalDegree_eq_zero_iff_eq_C.mp (Nat.eq_zero_of_le_zero h) + have hc : F.coeff 0 ≠ 0 := by intro hc; apply hF.ne_zero; rw [he,hc,map_zero] + exact hF.not_isUnit (isUnit_iff_totalDegree_of_isReduced.mpr + ⟨isUnit_iff_ne_zero.mpr hc,Nat.eq_zero_of_le_zero h⟩) + +lemma exists_nonzero_pderiv {p : ℕ} [CharP K p] + (F : MvPolynomial σ K) (hpos : 0 < F.totalDegree) (hdeg : F.totalDegree < p) : + ∃ i, pderiv i F ≠ 0 := by + classical + have hF : F ≠ 0 := by intro he; simp [he] at hpos + obtain ⟨d,hd,he⟩ := Finset.exists_mem_eq_sup F.support (support_nonempty.mpr hF) + (fun d : σ →₀ ℕ => d.sum fun _ e => e) + change F.totalDegree = d.degree at he + have hdz : d ≠ 0 := by intro hd0; simp [hd0] at he; omega + obtain ⟨i,hi⟩ := Finsupp.ne_iff.mp hdz + have hi0 : 0 < d i := Nat.pos_of_ne_zero hi + have hdi : d i ≤ d.degree := by + rw [Finsupp.degree_apply] + exact Finset.single_le_sum (fun _ _ => Nat.zero_le _) (Finsupp.mem_support_iff.mpr hi) + have hcast : (d i : K) ≠ 0 := by + rw [ne_eq,CharP.cast_eq_zero_iff K p] + intro H + have := Nat.le_of_dvd hi0 H + omega + have hs : Finsupp.single i 1 ≤ d := by + intro j + by_cases hij : i = j + · subst j; simpa using (Nat.succ_le_iff.mpr hi0) + · simp [Finsupp.single_eq_of_ne (Ne.symm hij)] + refine ⟨i,fun hz => ?_⟩ + have hc := congrArg (fun poly : MvPolynomial σ K => poly.coeff (d-Finsupp.single i 1)) hz + rw [coeff_pderiv,tsub_add_cancel_of_le hs,AddMonoidAlgebra.coeff_zero] at hc + have hc' : F.coeff d * (d i : K) = 0 := by + simpa [Finsupp.coe_tsub,Pi.sub_apply,Finsupp.single_eq_same, + Nat.cast_sub (show 1 ≤ d i by omega)] using hc + exact (mul_ne_zero (MvPolynomial.mem_support_iff.mp hd) hcast) hc' + +variable [Finite σ] [IsAlgClosed K] + +lemma exists_zero_not_zero (F D : MvPolynomial σ K) + (hF : Irreducible F) (hD : ¬F ∣ D) : + ∃ x : σ → K, aeval x F = 0 ∧ aeval x D ≠ 0 := by + classical + let I : Ideal (MvPolynomial σ K) := Ideal.span {F} + let : I.IsPrime := (Ideal.span_singleton_prime hF.ne_zero).mpr + (irreducible_iff_prime.mp hF) + by_contra! H + have hv : D ∈ MvPolynomial.vanishingIdeal K (MvPolynomial.zeroLocus K I) := by + intro x hx + apply H x + exact hx F (Ideal.subset_span (Set.mem_singleton F)) + rw [MvPolynomial.IsPrime.vanishingIdeal_zeroLocus] at hv + exact hD (Ideal.mem_span_singleton.mp hv) + +lemma exists_nonsingular_factor_zero (G F : MvPolynomial σ K) + (hs : Squarefree G) (hF : Irreducible F) (hd : F ∣ G) (i : σ) + (hi : pderiv i F ≠ 0) : + ∃ x : σ → K, aeval x F = 0 ∧ aeval x (pderiv i G) ≠ 0 := + exists_zero_not_zero F _ hF (not_dvd_squarefree_derivative G F hs hF hd i hi) + +end SharpLogRamsey.PolynomialGeometry + +open scoped BigOperators +open MvPolynomial +namespace SharpLogRamsey.Translation +variable {σ K : Type*} [Field K] + +noncomputable def translate (x : σ → K) : + MvPolynomial σ K →ₐ[K] MvPolynomial σ K := + MvPolynomial.aeval fun i => X i+C (x i) + +@[simp] lemma translate_X (x : σ → K) (i : σ) : translate x (X i) = X i+C (x i) := by + simp [translate] +@[simp] lemma translate_C (x : σ → K) (c : K) : translate x (C c) = C c := by + simp [translate] + +lemma pderiv_translate (x : σ → K) (i : σ) (F : MvPolynomial σ K) : + pderiv i (translate x F) = translate x (pderiv i F) := by + classical + induction F using MvPolynomial.induction_on with + | C c => simp + | add f g hf hg => simp only [map_add,hf,hg] + | mul_X f j hf => + simp only [map_mul,translate_X,MvPolynomial.pderiv_mul,map_add,hf, + MvPolynomial.pderiv_X,MvPolynomial.pderiv_C,add_zero] + simp only [Pi.single_apply] + split_ifs <;> simp + +lemma constantCoeff_translate (x : σ → K) (F : MvPolynomial σ K) : + constantCoeff (translate x F) = aeval x F := by + induction F using MvPolynomial.induction_on with + | C c => simp + | add f g hf hg => simp only [map_add,hf,hg] + | mul_X f i hf => simp [hf] + +@[simp] lemma translate_neg_translate (x : σ → K) (F : MvPolynomial σ K) : + translate (-x) (translate x F) = F := by + induction F using MvPolynomial.induction_on with + | C c => simp + | add f g hf hg => simp only [map_add,hf,hg] + | mul_X f i hf => simp [hf] + +@[simp] lemma translate_translate_neg (x : σ → K) (F : MvPolynomial σ K) : + translate x (translate (-x) F) = F := by + simpa using translate_neg_translate (-x) F + +lemma translate_injective (x : σ → K) : Function.Injective (translate x) := + fun _ _ h => by simpa using congrArg (translate (-x)) h + +lemma translate_dvd_iff (x : σ → K) (F G : MvPolynomial σ K) : + translate x F ∣ translate x G ↔ F ∣ G := by + constructor + · intro h + simpa using map_dvd (translate (-x)) h + · exact map_dvd _ + +lemma translate_nonunit (x : σ → K) {F : MvPolynomial σ K} (h : ¬IsUnit F) : + ¬IsUnit (translate x F) := by + intro hu + apply h + simpa using hu.map (translate (-x)) +end SharpLogRamsey.Translation + +namespace SharpLogRamsey.GlobalFlatness +open MvPolynomial SharpLogRamsey.FlatnessCore SharpLogRamsey.Translation +variable {σ K : Type*} [Fintype σ] [DecidableEq σ] [Field K] + +lemma totalDegree_translate_le {τ : Type*} [Fintype τ] (x : τ → K) (F : MvPolynomial τ K) : + (Translation.translate x F).totalDegree ≤ F.totalDegree := by + classical + apply totalDegree_aeval_linear + intro i + apply (totalDegree_add _ _).trans + simp + +lemma translate_flatness (x : Option σ → K) (G : MvPolynomial (Option σ) K) (a b : σ) : + Translation.translate x (flatnessPolynomial G a b) = flatnessPolynomial (Translation.translate x G) a b := by + simp only [flatnessPolynomial,map_sum,map_mul] + apply Finset.sum_congr rfl + intro j hj + apply Finset.sum_congr rfl + intro i hi + have ht : ∀ c k, Translation.translate x (scaledTangent (fun o => pderiv o G) c k) = + scaledTangent (fun o => pderiv o (Translation.translate x G)) c k := by + intro c k + cases k with + | none => simp [scaledTangent,pderiv_translate] + | some k => by_cases h : k = c <;> simp [scaledTangent,h,pderiv_translate] + rw [ht,ht,← pderiv_translate,← pderiv_translate] + +theorem plane_factor_of_flatness {p : ℕ} [CharP K p] [IsAlgClosed K] + (G F : MvPolynomial (Option σ) K) (hdeg : G.totalDegree < p) + (hs : Squarefree G) (hF : Irreducible F) (hdiv : F ∣ G) + (hDzF : pderiv none F ≠ 0) (hflat : ∀ a b, F ∣ flatnessPolynomial G a b) : + ∃ L : MvPolynomial (Option σ) K, ¬IsUnit L ∧ L.totalDegree ≤ 1 ∧ L ∣ G := by + obtain ⟨x,hx,hDx⟩ := PolynomialGeometry.exists_nonsingular_factor_zero + G F hs hF hdiv none hDzF + have hpl := LocalFlatness.exists_plane_factor_of_flatness + (Translation.translate x G) (Translation.translate x F) + ((totalDegree_translate_le x G).trans_lt hdeg) (map_dvd (Translation.translate x) hdiv) + (by rwa [constantCoeff_translate]) + (by rwa [pderiv_translate,constantCoeff_translate]) + (fun a b => by rw [← translate_flatness]; exact map_dvd (Translation.translate x) (hflat a b)) + obtain ⟨lin,hlin,hlin0,hlind⟩ := hpl + let L : MvPolynomial (Option σ) K := X none-rename Option.some lin + have hL0 : constantCoeff L = 0 := by simp [L,hlin0] + have hLu : ¬IsUnit L := by + intro hu + have H := hu.map (constantCoeff : MvPolynomial (Option σ) K →+* K) + rw [hL0] at H + exact not_isUnit_zero H + have hLd : L.totalDegree ≤ 1 := by + apply (totalDegree_sub _ _).trans + apply max_le + · exact (totalDegree_X none).le + · exact (totalDegree_rename_le _ _).trans hlin + refine ⟨Translation.translate (-x) L,translate_nonunit _ hLu, + (totalDegree_translate_le _ _).trans hLd,?_⟩ + simpa only [translate_neg_translate] using map_dvd (Translation.translate (-x)) hlind + +lemma nonplane_factor_not_flat {p : ℕ} [CharP K p] [IsAlgClosed K] + (G F : MvPolynomial (Option σ) K) (hdeg : G.totalDegree < p) + (hs : Squarefree G) (hF : Irreducible F) (hdiv : F ∣ G) + (hDzF : pderiv none F ≠ 0) + (hn : ∀ L : MvPolynomial (Option σ) K, L ∣ G → L.totalDegree ≤ 1 → IsUnit L) : + ∃ a b, ¬ F ∣ flatnessPolynomial G a b := by + by_contra! h + obtain ⟨L,hu,hd,hdv⟩ := plane_factor_of_flatness G F hdeg hs hF hdiv hDzF h + exact hu (hn L hdv hd) +end SharpLogRamsey.GlobalFlatness + +open scoped BigOperators +open Finset MvPolynomial UniqueFactorizationMonoid +namespace SharpLogRamsey.CoprimeCombination +variable {σ ι K : Type*} [Fintype ι] [Field K] [Infinite K] + +noncomputable def combinationMap (Q : ι → MvPolynomial σ K) : + (ι → K) →ₗ[K] MvPolynomial σ K := + ∑ i, (LinearMap.proj i).smulRight (Q i) +omit [Infinite K] in + +@[simp] lemma combinationMap_apply (Q : ι → MvPolynomial σ K) (c : ι → K) : + combinationMap Q c = ∑ i, c i • Q i := by simp [combinationMap] + +theorem exists_coprime_combination (G : MvPolynomial σ K) (hG : G ≠ 0) + (Q : ι → MvPolynomial σ K) + (h : ∀ F : MvPolynomial σ K, Irreducible F → F ∣ G → ∃ i, ¬F ∣ Q i) : + ∃ c : ι → K, IsRelPrime G (∑ i, c i • Q i) := by + classical + let : NormalizationMonoid (MvPolynomial σ K) := UniqueFactorizationMonoid.strongNormalizationMonoid.toNormalizationMonoid + let S := (normalizedFactors G).toFinset + let P (F : S) : Submodule K (ι → K) := + ((Ideal.span ({F.val} : Set (MvPolynomial σ K))).restrictScalars K).comap (combinationMap Q) + have hp : ∀ F, P F ≠ ⊤ := by + intro F ht + have hfm : F.val ∈ normalizedFactors G := Multiset.mem_toFinset.mp F.property + obtain ⟨i,hi⟩ := h F.val (prime_of_normalized_factor _ hfm).irreducible + (dvd_of_mem_normalizedFactors hfm) + have H : Pi.single i 1 ∈ P F := ht ▸ Submodule.mem_top + change combinationMap Q (Pi.single i 1) ∈ Ideal.span ({F.val} : Set (MvPolynomial σ K)) at H + simp [Pi.single_apply] at H + exact hi (Ideal.mem_span_singleton.mp H) + obtain ⟨c,hc⟩ := Submodule.exists_forall_notMem_of_forall_ne_top P hp + refine ⟨c,(isRelPrime_iff_no_prime_factors hG).mpr ?_⟩ + intro F hFG hFQ hFp + obtain ⟨J,hJ,hassoc⟩ := exists_mem_normalizedFactors_of_dvd hG hFp.irreducible hFG + apply hc ⟨J,Multiset.mem_toFinset.mpr hJ⟩ + change combinationMap Q c ∈ Ideal.span ({J} : Set (MvPolynomial σ K)) + rw [combinationMap_apply,Ideal.mem_span_singleton] + exact hassoc.dvd_iff_dvd_left.mp hFQ +end SharpLogRamsey.CoprimeCombination +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/ListSourceRadial.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/ListSourceRadial.lean new file mode 100644 index 0000000000000000000000000000000000000000..9b64bf22570374b8ed806af779b89f45567a55eb --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/ListSourceRadial.lean @@ -0,0 +1,120 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.SourceStrongRadial + +namespace OAI + +section +namespace SharpLogRamsey.PreparedProjectiveGeometry +open Finset Filter Real SourceRadialTests GreedyPreparation +open scoped Classical BigOperators Topology +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedListSourceRadial_1 : Finite (Projectivization K V) := by + let : Finite V := Module.finite_of_finite K + infer_instance +local instance flat_JoinedListSourceRadial_2 : Fintype (Projectivization K V) := Fintype.ofFinite _ +local instance flat_JoinedListSourceRadial_3 : Finite (Submodule K V) := by + let : Finite V := Module.finite_of_finite K + exact Finite.of_injective (fun W : Submodule K V => (W : Set V)) SetLike.coe_injective +local instance flat_JoinedListSourceRadial_4 : Fintype (Submodule K V) := Fintype.ofFinite _ + +theorem source_list_radial (δ C : ℝ) (hδ : 0<δ) : + ∀ᶠ σ : ℝ in atTop,∀ (F : Finset (Submodule K V)) (m : ℕ) + (S : Finset (Projectivization K V)) (bs : List (Submodule K V)), + Complete F planePoints m S bs → (removed S planePoints bs).Nonempty → + ∀ (P g : ℝ) (p : ℕ),σ^δ≤P → P≤σ/40 → g≤σ/2+C → 0

removed S planePoints bs \ (own S planePoints bs x∪{x}) + let K₀ := exp (σ+P/100-2*g) + ∃ D₀ D₁ : Finset (Projectivization K V), + (D₀.card:ℝ)≤N*exp (-P/200) ∧ (D₁.card:ℝ)≤N*exp (5*P) ∧ + (∀ x,x∉D₀ → ∀ i∈range (Nat.log 2 N+2), + ((richRadials (X x) x c (DyadicGrid.value i)).card:ℝ)*(DyadicGrid.value i)^100≤K₀) ∧ + (∀ x,x∉D₁ → (richRadials (X x) x c (1/(100*(p:ℝ)))).card=0 ∨ + 2*(exp σ+1)/(1/(100*(p:ℝ)))≤(exp (3*σ)/N)*exp (-3*P)) := by + have hpbound := ScaleSelection.eventually_polynomial_le_exp_rpow 400000000 4 δ 1 hδ (by norm_num) + simp only [one_mul,rpow_ofNat] at hpbound + filter_upwards [eventually_activated_tests δ C hδ,eventually_activated_list δ hδ, + eventually_radial_loss δ C hδ,eventually_strong_tests δ C hδ,eventually_strong_list, + hpbound,eventually_ge_atTop (1:ℝ)] + with σ htests hlist hloss hstrong hstronglist hpoly hσ F m S bs hprep hnon P g p hP hPu hgu hp hpu hNl hNu hJ + let N := (removed S planePoints bs).card + let c := exp σ/(N:ℝ) + let K₀ := exp (σ+P/100-2*g) + have hN : (0:ℝ) DyadicGrid.value_pos i) + (by + intro i hi hh + change K₀ Or.inl (hzero x hx)⟩ + +end +end SharpLogRamsey.PreparedProjectiveGeometry + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/MarkingGeometricClass.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/MarkingGeometricClass.lean new file mode 100644 index 0000000000000000000000000000000000000000..c47855c3bf5bb75cf277bac574f6b98d9afda676 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/MarkingGeometricClass.lean @@ -0,0 +1,71 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.MarkingClassSelection +import OAI.Combinatorics.SharpRamsey.Marking.MarkingFiniteClasses + +namespace OAI + +section +namespace SharpLogRamsey.Marking +open Finset +open scoped BigOperators Classical +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] [Finite K] + {Ω Γ : Type*} [Fintype Ω] [Fintype Γ] + +omit [Finite K] in + +lemma cheapBoth_nonempty_of_mass {N : ℕ} + (p : Selection.Law Ω) (C : Ω→Γ) (F : Ω→Fin N→ProjectivePair (K:=K) (V:=V)) + (hcons : ∀ x,p.mass x≠0→ScanConsistent ((List.ofFn (F x)).map toScan)) + (hinc : ∀ x,p.mass x≠0→∀ i,Incidence.Incident (F x i).1 (F x i).2) + (z : TwoMessage (K:=K) (V:=V) Γ N) + (hz : (p.map (sourceMessage C F)).mass z≠0) (i : Fin N) + (hi : i∉bothExpensive z.2.2) : (cheapBoth z i).Nonempty := by + obtain ⟨x,hx,rfl⟩ := p.map_support (sourceMessage C F) z hz + exact ⟨F x i,cheapBoth_mem C F x (hcons x hx) (hinc x hx) i hi⟩ + +theorem actual_geometric_class {N n : ℕ} (hdim : Module.finrank K V=n+3) + {gap : ℝ} (hgap : 0≤gap) + (p : Selection.Law Ω) (C : Ω→Γ) (F : Ω→Fin N→ProjectivePair (K:=K) (V:=V)) + (D : Γ→Fin N→Finset (ProjectivePair (K:=K) (V:=V))) (Jprev : ℝ) + (hcons : ∀ x,p.mass x≠0→ScanConsistent ((List.ofFn (F x)).map toScan)) + (hinc : ∀ x,p.mass x≠0→∀ i,Incidence.Incident (F x i).1 (F x i).2) + (hD : ∀ x,p.mass x≠0→∀ i,F x i∈D (C x) i) + (hprev : ∀ c i,Real.log (D c i).card≤Jprev) + (m : ℕ) + (hm : ((2*(n+3)+(n+3)^2)*m:ℕ)+expensiveBudget K V+ + expensiveBudget K (Module.Dual K V)≤(N:ℝ)) : + ∃ (c : SlotClass (n+2)) (E : Finset (TwoMessage (K:=K) (V:=V) Γ N)) + (hE : 0<(p.map (sourceMessage C F)).event E) + (S : TwoMessage (K:=K) (V:=V) Γ N→Finset (Fin N)), + 1/((2*(n+3)+(n+3)^2:ℕ):ℝ)≤(p.map (sourceMessage C F)).event E ∧ + (∀ z,Disjoint (S z) (bothExpensive z.2.2)) ∧ + (∀ z∈E,(S z).card=m) ∧ + (∀ x,p.mass x≠0→sourceMessage C F x∈E→∀ i∈S (sourceMessage C F x), + F x i∈cheapBoth (sourceMessage C F x) i ∧ + ValidSlotClass (n+2) gap (cheapBoth (sourceMessage C F x) i) c) ∧ + conditionedDeficit p C F E hE S (jointJ K (n+2)) ≤ + excessCost p C F Jprev (jointJ K (n+2))/(p.map (sourceMessage C F)).event E := by + have hcard : Fintype.card (SlotClass (n+2))=2*(n+3)+(n+3)^2 := by + simpa only [Nat.add_assoc] using slotClass_card (n+2) + obtain ⟨c,E,hE,S,hprob,hS,hslots,hdef⟩ := + actual_common_class hdim p C F D Jprev hcons hinc hD hprev + (messageClass hdim hgap) m (by simpa only [hcard] using hm) + refine ⟨c,E,hE,S,?_,hS,(fun z hz=>(hslots z hz).1),?_,hdef⟩ + · simpa only [hcard] using hprob + · intro x hx he i hi + have hm := cheapBoth_mem C F x (hcons x hx) (hinc x hx) i + (disjoint_left.mp (hS (sourceMessage C F x)) hi) + refine ⟨hm,?_⟩ + have hc := messageClass_valid hdim hgap (sourceMessage C F x) i ⟨F x i,hm⟩ + rwa [(hslots _ he).2 i hi] at hc + +end +end SharpLogRamsey.Marking + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/PencilGeometry.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/PencilGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..31a8db522f36486a237e77235b07b577dbe54d59 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/PencilGeometry.lean @@ -0,0 +1,425 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.ActualClassLaw +import OAI.Combinatorics.SharpRamsey.Marking.UniformSupports + +namespace OAI + +section +namespace SharpLogRamsey.PreparedProjectiveGeometry +open scoped BigOperators +open Classical +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedPencilGeometry_1 : Finite (Submodule K V) := by + let : Finite V := Module.finite_of_finite K + exact Finite.of_injective (fun W : Submodule K V => (W : Set V)) SetLike.coe_injective +local instance flat_JoinedPencilGeometry_2 : Fintype (Submodule K V) := Fintype.ofFinite _ + +def RadialLine (x : Projectivization K V) := + {W : Submodule K V // Module.finrank K W = 2 ∧ x.submodule ≤ W} + +instance radialLineFintype (x : Projectivization K V) : Fintype (RadialLine x) := by + unfold RadialLine + infer_instance + +def lines (x : Projectivization K V) (H : Projectivization K (Module.Dual K V)) : + Finset (RadialLine x) := + Finset.univ.filter (fun W => W.1 ≤ LinearMap.ker H.rep) + +@[simp] lemma mem_lines (x : Projectivization K V) + (H : Projectivization K (Module.Dual K V)) (W : RadialLine x) : + W ∈ lines x H ↔ W.1 ≤ LinearMap.ker H.rep := by simp [lines] + +omit [Finite K] [FiniteDimensional K V] in +lemma finrank_join (x y : Projectivization K V) (hne : x ≠ y) : + Module.finrank K (x.submodule ⊔ y.submodule : Submodule K V) = 2 := by + have hh := finrank_span_eq_card (Projectivization.linearIndependent_pair_iff_ne.mpr hne) + have he : Set.range ![x.rep,y.rep] = {x.rep,y.rep} := by + ext v + simp [or_comm] + rw [he, Submodule.span_insert] at hh + rw [x.submodule_eq, y.submodule_eq] + exact hh + +omit [Finite K] in +lemma radial_unique (x y : Projectivization K V) (hne : x ≠ y) + (W : RadialLine x) (hy : y.submodule ≤ W.1) : + x.submodule ⊔ y.submodule = W.1 := + Submodule.eq_of_le_of_finrank_eq (sup_le W.2.2 hy) ((finrank_join x y hne).trans W.2.1.symm) + +def radialFiber (S : Finset (Projectivization K V)) (x : Projectivization K V) + (W : RadialLine x) : Finset (Projectivization K V) := + S.filter (fun y => y ≠ x ∧ y.submodule ≤ W.1) + +omit [Finite K] [FiniteDimensional K V] in +@[simp] lemma mem_radialFiber (S : Finset (Projectivization K V)) (x y : Projectivization K V) + (W : RadialLine x) : y ∈ radialFiber S x W ↔ y ∈ S ∧ y ≠ x ∧ y.submodule ≤ W.1 := by + simp [radialFiber] + +omit [Finite K] in + +lemma radialFiber_disjoint (S : Finset (Projectivization K V)) (x : Projectivization K V) + {W U : RadialLine x} (hne : W ≠ U) : Disjoint (radialFiber S x W) (radialFiber S x U) := by + apply Finset.disjoint_left.mpr + intro y hyW hyU + obtain ⟨_, hyx, hyW⟩ := (mem_radialFiber S x y W).mp hyW + have hyU := ((mem_radialFiber S x y U).mp hyU).2.2 + exact hne (Subtype.ext ((radial_unique x y hyx.symm W hyW).symm.trans + (radial_unique x y hyx.symm U hyU))) + +lemma radial_biUnion (S : Finset (Projectivization K V)) (x : Projectivization K V) + (U : Submodule K V) (hx : x.submodule ≤ U) : + (Finset.univ.filter (fun W : RadialLine x => W.1 ≤ U)).biUnion (radialFiber S x) = + S.filter (fun y => y ≠ x ∧ y.submodule ≤ U) := by + ext y + simp only [Finset.mem_biUnion, Finset.mem_filter, Finset.mem_univ, true_and, + mem_radialFiber] + constructor + · rintro ⟨W, hWU, hyS, hyx, hyW⟩ + exact ⟨hyS, hyx, hyW.trans hWU⟩ + · rintro ⟨hyS, hyx, hyU⟩ + refine ⟨⟨x.submodule ⊔ y.submodule, finrank_join x y hyx.symm, le_sup_left⟩, + sup_le hx hyU, hyS, hyx, le_sup_right⟩ + +theorem radial_count (S : Finset (Projectivization K V)) (x : Projectivization K V) + (U : Submodule K V) (hx : x.submodule ≤ U) : + ∑ W ∈ Finset.univ.filter (fun W : RadialLine x => W.1 ≤ U), (radialFiber S x W).card = + (S.filter (fun y => y ≠ x ∧ y.submodule ≤ U)).card := by + rw [← Finset.card_biUnion, radial_biUnion S x U hx] + intro W _ U _ hne + exact radialFiber_disjoint S x hne + +theorem radial_mass (S : Finset (Projectivization K V)) (x : Projectivization K V) + (U : Submodule K V) (hx : x.submodule ≤ U) (c : ℝ) : + ∑ W ∈ Finset.univ.filter (fun W : RadialLine x => W.1 ≤ U), c*(radialFiber S x W).card = + c*(S.filter (fun y => y ≠ x ∧ y.submodule ≤ U)).card := by + rw [← Finset.mul_sum, ← Nat.cast_sum, radial_count S x U hx] + +theorem hyperplane_mass (S : Finset (Projectivization K V)) (x : Projectivization K V) + (H : Projectivization K (Module.Dual K V)) (hx : x.submodule ≤ LinearMap.ker H.rep) (c : ℝ) : + ∑ W ∈ lines x H, c*(radialFiber S x W).card = + c*(S.filter (fun y => y ≠ x ∧ y.submodule ≤ LinearMap.ker H.rep)).card := + radial_mass S x (LinearMap.ker H.rep) hx c + +theorem intersection_mass (S : Finset (Projectivization K V)) (x : Projectivization K V) + (H J : Projectivization K (Module.Dual K V)) + (hxH : x.submodule ≤ LinearMap.ker H.rep) (hxJ : x.submodule ≤ LinearMap.ker J.rep) + (c : ℝ) : + ∑ W ∈ lines x H ∩ lines x J, c*(radialFiber S x W).card = + c*(S.filter (fun y => y ≠ x ∧ y.submodule ≤ LinearMap.ker H.rep ⊓ LinearMap.ker J.rep)).card := by + have he : lines x H ∩ lines x J = + Finset.univ.filter (fun W : RadialLine x => W.1 ≤ LinearMap.ker H.rep ⊓ LinearMap.ker J.rep) := by + ext W + simp only [Finset.mem_inter, mem_lines, Finset.mem_filter, Finset.mem_univ, true_and, le_inf_iff] + rw [he] + exact radial_mass S x _ (le_inf hxH hxJ) c + +end +end SharpLogRamsey.PreparedProjectiveGeometry + +open Finset Classical +namespace SharpLogRamsey.CertificateGeometry +open SharpLogRamsey.Incidence +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [Finite K] [FiniteDimensional K V] +noncomputable section +local instance flat_JoinedPencilGeometry_3 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedPencilGeometry_4 : Fintype (Projectivization K (Module.Dual K V)) := Fintype.ofFinite _ +omit [Finite K] [FiniteDimensional K V] in + +lemma through_iff (W : Submodule K V) (H : Projectivization K (Module.Dual K V)) : + W ≤ LinearMap.ker H.rep ↔ H.submodule ≤ W.dualAnnihilator := by + rw [Projectivization.submodule_eq,Submodule.span_singleton_le_iff_mem, + Submodule.mem_dualAnnihilator] + rfl + +theorem card_through (W : Submodule K V) : + Fintype.card {H : Projectivization K (Module.Dual K V) // W ≤ LinearMap.ker H.rep} = + ∑ i ∈ range (Module.finrank K W.dualAnnihilator), Nat.card K^i := by + rw [← Nat.card_eq_fintype_card, + Nat.card_congr (Equiv.subtypeEquivRight (through_iff W)), + ← Nat.card_congr (projectiveSubmoduleEquiv W.dualAnnihilator)] + exact Projectivization.card_of_finrank K W.dualAnnihilator rfl + +theorem line_card (hdim : Module.finrank K V = 4) (W : Submodule K V) + (hW : Module.finrank K W = 2) : + Fintype.card {H : Projectivization K (Module.Dual K V) // W ≤ LinearMap.ker H.rep} = + Nat.card K+1 := by + rw [card_through] + have hd := Subspace.finrank_add_finrank_dualAnnihilator_eq W + have H : Module.finrank K W.dualAnnihilator = 2 := by omega + rw [H] + simp [sum_range_succ,Nat.add_comm] + +end +end SharpLogRamsey.CertificateGeometry + +namespace SharpLogRamsey.PreparedProjectiveGeometry +open SharpLogRamsey.CertificateGeometry +open scoped BigOperators +open Classical +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedPencilGeometry_5 : Finite (Submodule K V) := by + let : Finite V := Module.finite_of_finite K + exact Finite.of_injective (fun W : Submodule K V => (W : Set V)) SetLike.coe_injective +local instance flat_JoinedPencilGeometry_6 : Fintype (Submodule K V) := Fintype.ofFinite _ +local instance flat_JoinedPencilGeometry_7 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedPencilGeometry_8 : Fintype (Projectivization K (Module.Dual K V)) := Fintype.ofFinite _ + +omit [Finite K] [FiniteDimensional K V] in +lemma point_dualCoannihilator (H : Projectivization K (Module.Dual K V)) : + H.submodule.dualCoannihilator = LinearMap.ker H.rep := by + apply SetLike.coe_injective + rw [H.submodule_eq, Submodule.coe_dualCoannihilator_span] + ext v + simp + +omit [Finite K] in +lemma intersection_finrank (hdim : Module.finrank K V = 4) + (H J : Projectivization K (Module.Dual K V)) (hne : H ≠ J) : + Module.finrank K (LinearMap.ker H.rep ⊓ LinearMap.ker J.rep : Submodule K V) = 2 := by + have hr := finrank_join H J hne + have hd := Subspace.finrank_add_finrank_dualCoannihilator_eq + (H.submodule ⊔ J.submodule : Submodule K (Module.Dual K V)) + rw [Submodule.dualCoannihilator_sup_eq, point_dualCoannihilator, + point_dualCoannihilator] at hd + omega + +def strength (S : Finset (Projectivization K V)) (x : Projectivization K V) + (c : ℝ) (W : RadialLine x) : ℝ := c*(radialFiber S x W).card + +def overlap (S : Finset (Projectivization K V)) (x : Projectivization K V) + (c : ℝ) (H J : Projectivization K (Module.Dual K V)) : ℝ := + c*(S.filter (fun y => y ≠ x ∧ y.submodule ≤ LinearMap.ker H.rep ⊓ LinearMap.ker J.rep)).card + +lemma overlap_is_strength (hdim : Module.finrank K V = 4) + (S : Finset (Projectivization K V)) (x : Projectivization K V) (c : ℝ) + (H J : Projectivization K (Module.Dual K V)) (hne : H ≠ J) + (hxH : x.submodule ≤ LinearMap.ker H.rep) (hxJ : x.submodule ≤ LinearMap.ker J.rep) : + ∃ W : RadialLine x, W ∈ lines x H ∧ W ∈ lines x J ∧ + overlap S x c H J = strength S x c W := by + refine ⟨⟨_, intersection_finrank hdim H J hne, le_inf hxH hxJ⟩, ?_, ?_, rfl⟩ + · exact (mem_lines _ _ _).mpr inf_le_left + · exact (mem_lines _ _ _).mpr inf_le_right + +lemma hyperplanes_on_line_card_le (hdim : Module.finrank K V = 4) + (A : Finset (Projectivization K (Module.Dual K V))) (x : Projectivization K V) + (W : RadialLine x) : + (A.filter (fun H => W ∈ lines x H)).card ≤ Nat.card K+1 := by + calc + _ ≤ Fintype.card {H : Projectivization K (Module.Dual K V) // W.1 ≤ LinearMap.ker H.rep} := by + rw [← Fintype.card_coe] + apply Fintype.card_le_of_injective (fun H : {H // H ∈ A.filter (fun H => W ∈ lines x H)} => + (⟨H.1, (mem_lines _ _ _).mp ((Finset.mem_filter.mp H.2).2)⟩ : + {H : Projectivization K (Module.Dual K V) // W.1 ≤ LinearMap.ker H.rep})) + intro H J he + exact Subtype.ext (congrArg (fun U : + {H : Projectivization K (Module.Dual K V) // W.1 ≤ LinearMap.ker H.rep} => U.1) he) + _ = _ := line_card hdim W.1 W.2.1 + +def richRadials (S : Finset (Projectivization K V)) (x : Projectivization K V) + (c a : ℝ) : Finset (RadialLine x) := univ.filter (fun W => a ≤ strength S x c W) + +def hyperplanesOn (A : Finset (Projectivization K (Module.Dual K V))) + (x : Projectivization K V) (W : RadialLine x) : + Finset (Projectivization K (Module.Dual K V)) := A.filter (fun H => W ∈ lines x H) + +def largePairs (S : Finset (Projectivization K V)) (x : Projectivization K V) + (c a : ℝ) (A : Finset (Projectivization K (Module.Dual K V))) := + (A ×ˢ A).filter (fun z => z.1 ≠ z.2 ∧ a ≤ overlap S x c z.1 z.2) + +theorem largePairs_card (hdim : Module.finrank K V = 4) + (S : Finset (Projectivization K V)) (x : Projectivization K V) (c a : ℝ) + (A : Finset (Projectivization K (Module.Dual K V))) + (hAx : ∀ H ∈ A, x.submodule ≤ LinearMap.ker H.rep) : + (largePairs S x c a A).card ≤ (richRadials S x c a).card*(Nat.card K+1)^2 := by + have hsub : largePairs S x c a A ⊆ + (richRadials S x c a).biUnion (fun W => hyperplanesOn A x W ×ˢ hyperplanesOn A x W) := by + rintro ⟨H,J⟩ hmem + obtain ⟨hmem,hne,hov⟩ := mem_filter.mp hmem + obtain ⟨hH,hJ⟩ := mem_product.mp hmem + obtain ⟨W,hWH,hWJ,he⟩ := overlap_is_strength hdim S x c H J hne (hAx H hH) (hAx J hJ) + apply mem_biUnion.mpr + exact ⟨W, by simp [richRadials, ← he, hov], + mem_product.mpr ⟨mem_filter.mpr ⟨hH,hWH⟩, mem_filter.mpr ⟨hJ,hWJ⟩⟩⟩ + calc + _ ≤ ((richRadials S x c a).biUnion + (fun W => hyperplanesOn A x W ×ˢ hyperplanesOn A x W)).card := card_le_card hsub + _ ≤ ∑ W ∈ richRadials S x c a, (hyperplanesOn A x W ×ˢ hyperplanesOn A x W).card := + card_biUnion_le + _ ≤ ∑ _W ∈ richRadials S x c a, (Nat.card K+1)^2 := by + apply sum_le_sum + intro W _ + rw [card_product, ← pow_two] + exact Nat.pow_le_pow_left (hyperplanes_on_line_card_le hdim A x W) 2 + _ = _ := by simp + +def largeNeighbors (S : Finset (Projectivization K V)) (x : Projectivization K V) + (c a : ℝ) (A : Finset (Projectivization K (Module.Dual K V))) + (H : Projectivization K (Module.Dual K V)) := + A.filter (fun J => H ≠ J ∧ a ≤ overlap S x c H J) + +lemma neighbors_card (hdim : Module.finrank K V = 4) + (S : Finset (Projectivization K V)) (x : Projectivization K V) (c a : ℝ) + (A : Finset (Projectivization K (Module.Dual K V))) + (hAx : ∀ H ∈ A, x.submodule ≤ LinearMap.ker H.rep) + (H : Projectivization K (Module.Dual K V)) (hxH : x.submodule ≤ LinearMap.ker H.rep) : + (largeNeighbors S x c a A H).card ≤ + (richRadials S x c a ∩ lines x H).card*(Nat.card K+1) := by + have hsub : largeNeighbors S x c a A H ⊆ + (richRadials S x c a ∩ lines x H).biUnion (hyperplanesOn A x) := by + intro J hJ + obtain ⟨hJ,hne,hov⟩ := mem_filter.mp hJ + obtain ⟨W,hWH,hWJ,he⟩ := overlap_is_strength hdim S x c H J hne hxH (hAx J hJ) + exact mem_biUnion.mpr ⟨W, mem_inter.mpr ⟨by simp [richRadials, ← he, hov], hWH⟩, + mem_filter.mpr ⟨hJ,hWJ⟩⟩ + calc + _ ≤ ((richRadials S x c a ∩ lines x H).biUnion (hyperplanesOn A x)).card := card_le_card hsub + _ ≤ ∑ W ∈ richRadials S x c a ∩ lines x H, (hyperplanesOn A x W).card := card_biUnion_le + _ ≤ ∑ _W ∈ richRadials S x c a ∩ lines x H, (Nat.card K+1) := + sum_le_sum (fun W _ => hyperplanes_on_line_card_le hdim A x W) + _ = _ := by simp + +theorem largeNeighbors_bound (hdim : Module.finrank K V = 4) + (S : Finset (Projectivization K V)) (x : Projectivization K V) (c a : ℝ) + (hc : 0 ≤ c) (ha : 0 < a) + (A : Finset (Projectivization K (Module.Dual K V))) + (hAx : ∀ H ∈ A, x.submodule ≤ LinearMap.ker H.rep) + (H : Projectivization K (Module.Dual K V)) (hxH : x.submodule ≤ LinearMap.ker H.rep) + (hmass : c*(S.filter (fun y => y ≠ x ∧ y.submodule ≤ LinearMap.ker H.rep)).card ≤ 2) : + ((largeNeighbors S x c a A H).card : ℝ) ≤ 2*((Nat.card K : ℝ)+1)/a := by + have hsum : ∑ W ∈ lines x H, strength S x c W ≤ 2 := + (hyperplane_mass S x H hxH c).le.trans hmass + have hthreshold : ((richRadials S x c a ∩ lines x H).card : ℝ)*a ≤ 2 := by + calc + _ = ∑ _W ∈ richRadials S x c a ∩ lines x H, a := by simp + _ ≤ ∑ W ∈ richRadials S x c a ∩ lines x H, strength S x c W := by + apply sum_le_sum + intro W hW + exact (mem_filter.mp (mem_inter.mp hW).1).2 + _ ≤ ∑ W ∈ lines x H, strength S x c W := by + apply sum_le_sum_of_subset_of_nonneg inter_subset_right + intro W _ _ + exact mul_nonneg hc (Nat.cast_nonneg _) + _ ≤ 2 := hsum + have hcard : ((largeNeighbors S x c a A H).card : ℝ) ≤ + (richRadials S x c a ∩ lines x H).card*((Nat.card K : ℝ)+1) := by + exact_mod_cast neighbors_card hdim S x c a A hAx H hxH + apply (le_div_iff₀ ha).mpr + have hqa : 0 ≤ (Nat.card K : ℝ)+1 := by positivity + have hmul := mul_le_mul_of_nonneg_right hthreshold hqa + have hmul' := mul_le_mul_of_nonneg_right hcard ha.le + nlinarith + +omit [Finite K] in +theorem overlap_plane_zero (hdim : Module.finrank K V = 3) + (S : Finset (Projectivization K V)) (x : Projectivization K V) (c : ℝ) + (H J : Projectivization K (Module.Dual K V)) (hne : H ≠ J) + (hxH : x.submodule ≤ LinearMap.ker H.rep) (hxJ : x.submodule ≤ LinearMap.ker J.rep) : + overlap S x c H J = 0 := by + have hr := finrank_join H J hne + have hd := Subspace.finrank_add_finrank_dualCoannihilator_eq + (H.submodule ⊔ J.submodule : Submodule K (Module.Dual K V)) + rw [Submodule.dualCoannihilator_sup_eq, point_dualCoannihilator, + point_dualCoannihilator] at hd + have hdim' : Module.finrank K (LinearMap.ker H.rep ⊓ LinearMap.ker J.rep : Submodule K V) = 1 := by omega + have he : x.submodule = LinearMap.ker H.rep ⊓ LinearMap.ker J.rep := + Submodule.eq_of_le_of_finrank_eq (le_inf hxH hxJ) (x.finrank_submodule.trans hdim'.symm) + have hfilter : S.filter (fun y => y ≠ x ∧ y.submodule ≤ LinearMap.ker H.rep ⊓ LinearMap.ker J.rep) = ∅ := by + apply filter_eq_empty_iff.mpr + intro y _ h + apply h.1 + apply Projectivization.submodule_injective + apply Submodule.eq_of_le_of_finrank_eq + · exact h.2.trans he.ge + · exact y.finrank_submodule.trans x.finrank_submodule.symm + unfold overlap + rw [hfilter] + simp + +end +end SharpLogRamsey.PreparedProjectiveGeometry + +namespace SharpLogRamsey.PreparedProjectiveGeometry +open Finset SharpLogRamsey.CertificateGeometry +open scoped Classical BigOperators +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedPencilGeometry_9 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedPencilGeometry_10 : Fintype (Projectivization K (Module.Dual K V)) := Fintype.ofFinite _ + +theorem one_direction_card (hdim : Module.finrank K V≤4) + (A : Finset (Projectivization K (Module.Dual K V))) (x : Projectivization K V) + (W : RadialLine x) : + (A.filter (fun H => W∈lines x H)).card≤Nat.card K+1 := by + have hd := Subspace.finrank_add_finrank_dualAnnihilator_eq W.1 + have hw := W.2.1 + have h2 : Module.finrank K W.1.dualAnnihilator≤2 := by omega + calc + _ ≤ Fintype.card {H : Projectivization K (Module.Dual K V) // W.1≤LinearMap.ker H.rep} := by + rw [←Fintype.card_coe] + apply Fintype.card_le_of_injective (fun H : {H // H∈A.filter (fun H => W∈lines x H)} => + (⟨H.1,(mem_lines _ _ _).mp (mem_filter.mp H.2).2⟩ : + {H : Projectivization K (Module.Dual K V) // W.1≤LinearMap.ker H.rep})) + intro H J he + apply Subtype.ext + exact congrArg (fun z => z.1) he + _ = ∑ i∈range (Module.finrank K W.1.dualAnnihilator),Nat.card K^i := card_through _ + _ ≤ ∑ i∈range 2,Nat.card K^i := + sum_le_sum_of_subset (range_mono h2) + _ = _ := by simp [sum_range_succ,Nat.add_comm] + +theorem two_directions_card (hdim : Module.finrank K V≤4) + (A : Finset (Projectivization K (Module.Dual K V))) (x : Projectivization K V) + (D E : RadialLine x) (hne : D≠E) : + (A.filter (fun H => D∈lines x H ∧ E∈lines x H)).card≤1 := by + apply card_le_one.mpr + intro H hH J hJ + by_contra hHJ + have hr := finrank_join H J hHJ + have hd := Subspace.finrank_add_finrank_dualCoannihilator_eq + (H.submodule⊔J.submodule : Submodule K (Module.Dual K V)) + rw [Submodule.dualCoannihilator_sup_eq,point_dualCoannihilator,point_dualCoannihilator] at hd + have hdimdual : Module.finrank K (Module.Dual K V)=Module.finrank K V := by simp + have hi : Module.finrank K (LinearMap.ker H.rep⊓LinearMap.ker J.rep : Submodule K V)≤2 := by omega + have hD : D.1≤LinearMap.ker H.rep⊓LinearMap.ker J.rep := + le_inf ((mem_lines _ _ _).mp (mem_filter.mp hH).2.1) + ((mem_lines _ _ _).mp (mem_filter.mp hJ).2.1) + have hE : E.1≤LinearMap.ker H.rep⊓LinearMap.ker J.rep := + le_inf ((mem_lines _ _ _).mp (mem_filter.mp hH).2.2) + ((mem_lines _ _ _).mp (mem_filter.mp hJ).2.2) + have hi2 : Module.finrank K (LinearMap.ker H.rep⊓LinearMap.ker J.rep : Submodule K V)=2 := + le_antisymm hi (D.2.1 ▸ Submodule.finrank_mono hD) + have heD := Submodule.eq_of_le_of_finrank_eq hD (D.2.1.trans hi2.symm) + have heE := Submodule.eq_of_le_of_finrank_eq hE (E.2.1.trans hi2.symm) + exact hne (Subtype.ext (heD.trans heE.symm)) + +theorem pencil_card (hdim : Module.finrank K V≤4) + (A : Finset (Projectivization K (Module.Dual K V))) (x : Projectivization K V) + (hA : ∀ H∈A,x.submodule≤LinearMap.ker H.rep) : + A.card≤(Nat.card K)^2+Nat.card K+1 := by + have hd := Subspace.finrank_add_finrank_dualAnnihilator_eq x.submodule + have hx := x.finrank_submodule + have h3 : Module.finrank K x.submodule.dualAnnihilator≤3 := by omega + calc + _ ≤ Fintype.card {H : Projectivization K (Module.Dual K V) // x.submodule≤LinearMap.ker H.rep} := by + rw [←Fintype.card_coe] + apply Fintype.card_le_of_injective (fun H : A => + (⟨H.1,hA H H.2⟩ : {H : Projectivization K (Module.Dual K V) // x.submodule≤LinearMap.ker H.rep})) + intro H J he + apply Subtype.ext + exact congrArg (fun z => z.1) he + _ = ∑ i∈range (Module.finrank K x.submodule.dualAnnihilator),Nat.card K^i := card_through _ + _ ≤ ∑ i∈range 3,Nat.card K^i := sum_le_sum_of_subset (range_mono h3) + _ = _ := by simp [sum_range_succ]; omega + +end +end SharpLogRamsey.PreparedProjectiveGeometry + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/PreparedRadial.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/PreparedRadial.lean new file mode 100644 index 0000000000000000000000000000000000000000..bdd10780f146ec0ad921fa44c3ef397fc0d78ac7 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/PreparedRadial.lean @@ -0,0 +1,199 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Learning.PreparedGeometry +import OAI.Combinatorics.SharpRamsey.Geometry.RadialPairCount +import OAI.Combinatorics.SharpRamsey.Geometry.SpanPairLine + +namespace OAI + +section +namespace SharpLogRamsey.GreedyPreparation +open Finset +open scoped Classical BigOperators +noncomputable section +variable {α β γ : Type*} + +lemma list_union_inter_card_le (U : β → Finset α) (bs : List β) + (L : Finset α) (hL : ∀ b ∈ bs, (U b ∩ L).card ≤ 1) : + (bs.toFinset.biUnion U ∩ L).card ≤ bs.length := by + induction bs with + | nil => simp + | cons b bs ih => + rw [List.toFinset_cons,biUnion_insert,union_inter_distrib_right] + have h1 := hL b (by simp) + have h2 := ih (fun c hc => hL c (by simp [hc])) + have hh := card_union_le (U b ∩ L) (bs.toFinset.biUnion U ∩ L) + simp only [List.length_cons] + omega + +theorem prepared_list_radial {F : Finset β} {U : β → Finset α} {m : ℕ} + {S : Finset α} {bs : List β} (h : Complete F U m S bs) + (A : Finset α) (G : Finset γ) (L : γ → Finset α) (r : ℕ) (hr0 : 0 < r) + (hplane : ∀ b ∈ bs, ∀ j ∈ G, ¬ L j ⊆ U b → (U b ∩ L j).card ≤ 1) + (hunique : ∀ i ∈ G, ∀ j ∈ G, i ≠ j → (L i ∩ L j).card ≤ 1) : + ((A ×ˢ G).filter (fun z => z.1 ∈ L z.2 ∧ + bs.length+r ≤ ((removed S U bs \ own S U bs z.1) ∩ L z.2).card)).card * + (r*(r-1)) ≤ (removed S U bs).card^2 := by + let C := indexedCell S U bs + let E : Fin bs.length → Finset γ := fun i => G.filter (fun j => + L j ⊆ U bs[i.val] ∧ (∀ b ∈ bs.take i.val, ¬ L j ⊆ U b) ∧ + r ≤ (C i ∩ L j).card) + let centers : Fin bs.length → γ → Finset α := fun i j => + (bs.take i.val).toFinset.biUnion U ∩ L j + have hcenter (i : Fin bs.length) (j : γ) (hj : j ∈ E i) : + (centers i j).card ≤ i.val := by + have hj' := mem_filter.mp hj + have hh := list_union_inter_card_le U (bs.take i.val) (L j) (fun b hb => + hplane b (List.mem_of_mem_take hb) j hj'.1 (hj'.2.2.1 b hb)) + exact hh.trans (List.length_take_le _ _) + have hcover : (A ×ˢ G).filter (fun z => z.1 ∈ L z.2 ∧ + bs.length+r ≤ ((removed S U bs \ own S U bs z.1) ∩ L z.2).card) ⊆ + univ.biUnion (fun i => (E i).biUnion (fun j => centers i j ×ˢ {j})) := by + intro z hz + obtain ⟨hzAG,hzx,hzrich⟩ := mem_filter.mp hz + have hjG := (mem_product.mp hzAG).2 + have hex : ∃ b ∈ bs, L z.2 ⊆ U b := by + by_contra hn + push Not at hn + have hb := removed_inter_card_le S U bs (L z.2) + (fun b hb => hplane b hb z.2 hjG (hn b hb)) + have hs : ((removed S U bs \ own S U bs z.1) ∩ L z.2).card ≤ + (removed S U bs ∩ L z.2).card := + card_le_card (inter_subset_inter_right sdiff_subset) + omega + obtain ⟨pre,b,post,he,hLb,hpre⟩ := first_containing U bs (L z.2) hex + have hplen : pre.length < bs.length := by rw [he,List.length_append,List.length_cons]; omega + let i : Fin bs.length := ⟨pre.length,hplen⟩ + have htake : bs.take i.val = pre := by simp [i,he] + have hget : bs[i.val] = b := by simp [i,he,List.getElem_append_right] + have hpreline : ∀ c ∈ pre, (U c ∩ L z.2).card ≤ 1 := by + intro c hc + exact hplane c (by rw [he]; simp [hc]) z.2 hjG (hpre c hc) + have hci : r ≤ (C i ∩ L z.2).card := by + have hh := removed_line_le_prefix_cell S U pre b post (L z.2) hLb hpreline + have hs : ((removed S U bs \ own S U bs z.1) ∩ L z.2).card ≤ + (removed S U bs ∩ L z.2).card := + card_le_card (inter_subset_inter_right sdiff_subset) + have hce : C i = residual S U pre ∩ U b := by + dsimp [C,indexedCell] + rw [htake,hget] + rw [hce] + rw [← he] at hh + omega + have hearlier : z.1 ∈ pre.toFinset.biUnion U := by + by_contra hn + have hxpre : ∀ c ∈ pre, z.1 ∉ U c := by + intro c hc hxc + exact hn (mem_biUnion.mpr ⟨c,List.mem_toFinset.mpr hc,hxc⟩) + have hh := outside_inter_prefix S U pre b post (L z.2) hLb z.1 hzx hxpre hpreline + rw [← he] at hh + omega + refine mem_biUnion.mpr ⟨i,mem_univ _,mem_biUnion.mpr ⟨z.2,?_,?_⟩⟩ + · apply mem_filter.mpr + refine ⟨hjG,?_,?_,hci⟩ + · rw [hget]; exact hLb + · simpa only [htake] using hpre + · exact mem_product.mpr ⟨by simpa only [centers,htake] using + (mem_inter.mpr ⟨hearlier,hzx⟩),mem_singleton_self _⟩ + calc + _ ≤ ((univ.biUnion (fun i => (E i).biUnion (fun j => centers i j ×ˢ {j}))).card)* + (r*(r-1)) := Nat.mul_le_mul_right _ (card_le_card hcover) + _ ≤ (∑ i, (C i).card)^2 := + RadialPairCount.centered_rich_lines C E L centers r + (fun _ _ hj => (mem_filter.mp hj).2.2.2) + (fun a ha b hb hab => hunique a + (by obtain ⟨i,_,hi⟩ := mem_biUnion.mp ha; exact (mem_filter.mp hi).1) + b (by obtain ⟨i,_,hi⟩ := mem_biUnion.mp hb; exact (mem_filter.mp hi).1) hab) + hcenter (indexedCell_antitone h) + _ = _ := by rw [indexedCell_sum] + +end +end SharpLogRamsey.GreedyPreparation +namespace SharpLogRamsey.PreparedProjectiveGeometry +open Finset +open scoped Classical BigOperators +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedPreparedRadial_1 : Finite (Projectivization K V) := by + let : Finite V := Module.finite_of_finite K + infer_instance +local instance flat_JoinedPreparedRadial_2 : Fintype (Projectivization K V) := Fintype.ofFinite _ +local instance flat_JoinedPreparedRadial_3 : Finite (Submodule K V) := by + let : Finite V := Module.finite_of_finite K + exact Finite.of_injective (fun W : Submodule K V => (W : Set V)) SetLike.coe_injective +local instance flat_JoinedPreparedRadial_4 : Fintype (Submodule K V) := Fintype.ofFinite _ + +def planePoints (W : Submodule K V) : Finset (Projectivization K V) := + univ.filter (fun x => x.submodule ≤ W) + +@[simp] lemma mem_planePoints {W : Submodule K V} {x : Projectivization K V} : + x ∈ planePoints W ↔ x.submodule ≤ W := by simp [planePoints] + +lemma points_mono {U W : Submodule K V} (h : U ≤ W) : planePoints U ⊆ planePoints W := by + intro x hx + exact mem_planePoints.mpr ((mem_planePoints.mp hx).trans h) + +omit [Finite K] in + +lemma join_eq_line (x y : Projectivization K V) (hne : x ≠ y) + (W : Submodule K V) (hW : Module.finrank K W = 2) + (hx : x.submodule ≤ W) (hy : y.submodule ≤ W) : + x.submodule ⊔ y.submodule = W := + Submodule.eq_of_le_of_finrank_eq (sup_le hx hy) ((finrank_join x y hne).trans hW.symm) + +lemma line_inter_points_le_one (W U : Submodule K V) (hW : Module.finrank K W = 2) + (hnot : ¬ planePoints W ⊆ planePoints U) : + (planePoints U ∩ planePoints W).card ≤ 1 := by + by_contra hn + obtain ⟨x,hx,y,hy,hxy⟩ := one_lt_card.mp (by omega : 1 < (planePoints U ∩ planePoints W).card) + have hx' := mem_inter.mp hx + have hy' := mem_inter.mp hy + have he := join_eq_line x y hxy W hW (mem_planePoints.mp hx'.2) (mem_planePoints.mp hy'.2) + apply hnot + apply points_mono + rw [← he] + exact sup_le (mem_planePoints.mp hx'.1) (mem_planePoints.mp hy'.1) + +lemma distinct_lines_inter_le_one (W U : Submodule K V) + (hW : Module.finrank K W = 2) (hU : Module.finrank K U = 2) (hne : W ≠ U) : + (planePoints W ∩ planePoints U).card ≤ 1 := by + by_contra hn + obtain ⟨x,hx,y,hy,hxy⟩ := one_lt_card.mp (by omega : 1 < (planePoints W ∩ planePoints U).card) + have hx' := mem_inter.mp hx + have hy' := mem_inter.mp hy + have heW := join_eq_line x y hxy W hW (mem_planePoints.mp hx'.1) (mem_planePoints.mp hy'.1) + have heU := join_eq_line x y hxy U hU (mem_planePoints.mp hx'.2) (mem_planePoints.mp hy'.2) + exact hne (heW.symm.trans heU) + +def ProjectiveLine := {W : Submodule K V // Module.finrank K W = 2} +instance flat_JoinedPreparedRadial_5 : Fintype (ProjectiveLine (K:=K) (V:=V)) := by unfold ProjectiveLine; infer_instance + +theorem projective_prepared_radial (F : Finset (Submodule K V)) (m : ℕ) + (S : Finset (Projectivization K V)) (bs : List (Submodule K V)) + (h : GreedyPreparation.Complete F planePoints m S bs) + (r : ℕ) (hr : 0 < r) : + ((univ : Finset (Projectivization K V × ProjectiveLine (K:=K) (V:=V))).filter + (fun z => z.1 ∈ planePoints z.2.1 ∧ bs.length+r ≤ + ((GreedyPreparation.removed S planePoints bs \ + (GreedyPreparation.own S planePoints bs z.1 ∪ {z.1})) ∩ planePoints z.2.1).card)).card * + (r*(r-1)) ≤ (GreedyPreparation.removed S planePoints bs).card^2 := by + have hh := GreedyPreparation.prepared_list_radial h univ univ + (fun W : ProjectiveLine (K:=K) (V:=V) => planePoints W.1) r hr + (fun b _ W _ hn => line_inter_points_le_one W.1 b W.2 hn) + (fun W _ U _ hne => distinct_lines_inter_le_one W.1 U.1 W.2 U.2 + (fun he => hne (Subtype.ext he))) + apply le_trans (Nat.mul_le_mul_right _ (card_le_card ?_)) hh + intro z hz + have hz' := (mem_filter.mp hz).2 + apply mem_filter.mpr + refine ⟨mem_product.mpr ⟨mem_univ _,mem_univ _⟩,hz'.1,hz'.2.trans ?_⟩ + apply card_le_card + apply inter_subset_inter_right + exact sdiff_subset_sdiff subset_rfl subset_union_left + +end +end SharpLogRamsey.PreparedProjectiveGeometry + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/PreparedRadialBounds.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/PreparedRadialBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..0d3f19e769ba7d1f38dab61369d14014100c4c62 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/PreparedRadialBounds.lean @@ -0,0 +1,87 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.RadialExceptions + +namespace OAI + +section +namespace SharpLogRamsey.PreparedProjectiveGeometry +open Finset +open scoped Classical BigOperators +noncomputable section + +lemma pair_square_budget (P N M J : ℕ) (hJ : 2*J≤M) (hM : 4≤M) + (hp : P*((M-J)*(M-J-1))≤N^2) : (P:ℝ)*(M:ℝ)^2≤8*(N:ℝ)^2 := by + have h1 : M≤2*(M-J) := by omega + have h2 : M≤4*(M-J-1) := by omega + have h1' : (M:ℝ)≤2*((M-J:ℕ):ℝ) := by exact_mod_cast h1 + have h2' : (M:ℝ)≤4*((M-J-1:ℕ):ℝ) := by exact_mod_cast h2 + have hd : (M:ℝ)^2≤8*((M-J:ℕ):ℝ)*((M-J-1:ℕ):ℝ) := by + have hh := mul_le_mul h1' h2' (Nat.cast_nonneg M) (by positivity) + nlinarith + have hp' : (P:ℝ)*(((M-J:ℕ):ℝ)*((M-J-1:ℕ):ℝ))≤(N:ℝ)^2 := by exact_mod_cast hp + have hh := mul_le_mul_of_nonneg_left hd (Nat.cast_nonneg P) + nlinarith + +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedPreparedRadialBounds_1 : Finite (Projectivization K V) := by + let : Finite V := Module.finite_of_finite K + infer_instance +local instance flat_JoinedPreparedRadialBounds_2 : Fintype (Projectivization K V) := Fintype.ofFinite _ +local instance flat_JoinedPreparedRadialBounds_3 : Finite (Submodule K V) := by + let : Finite V := Module.finite_of_finite K + exact Finite.of_injective (fun W : Submodule K V => (W : Set V)) SetLike.coe_injective +local instance flat_JoinedPreparedRadialBounds_4 : Fintype (Submodule K V) := Fintype.ofFinite _ + +lemma rich_threshold (X : Finset (Projectivization K V)) (x : Projectivization K V) + (W : RadialLine x) (a c : ℝ) (hc : 0 GreedyPreparation.removed S planePoints bs \ + (GreedyPreparation.own S planePoints bs x∪{x}) + let M := ⌈a/c⌉₊ + let P := ((univ : Finset (Projectivization K V × ProjectiveLine (K:=K) (V:=V))).filter + (fun z => z.1∈planePoints z.2.1 ∧ M≤(X z.1∩planePoints z.2.1).card)).card + have hMJ : bs.length≤M := by dsimp [M]; omega + have hr : 0 rich_threshold (X x) x W a c hc hw) + have haM : a≤c*M := by + have hh := Nat.le_ceil (a/c) + exact (div_le_iff₀ hc).mp hh |>.trans_eq (mul_comm _ _) + have hsquare : a^2≤c^2*(M:ℝ)^2 := by nlinarith + have hsum' := mul_le_mul_of_nonneg_right hsum (sq_nonneg a) + have hPscale := mul_le_mul_of_nonneg_left hsquare (Nat.cast_nonneg P) + have hfinal := mul_le_mul_of_nonneg_left hp2 (sq_nonneg c) + change (∑ x,((richRadials (X x) x c a).card:ℝ))*a^2≤_ + nlinarith + +end +end SharpLogRamsey.PreparedProjectiveGeometry + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/PreparedRadialCount.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/PreparedRadialCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..6f3f909562e47caa381b8de4e99a4e15cc7edc1c --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/PreparedRadialCount.lean @@ -0,0 +1,127 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.PreparedRadial + +namespace OAI + +section +namespace SharpLogRamsey.PreparedProjectiveGeometry +open Finset +open scoped Classical BigOperators +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedPreparedRadialCount_1 : Finite (Projectivization K V) := by + have : Finite V := Module.finite_of_finite K + infer_instance +local instance flat_JoinedPreparedRadialCount_2 : Fintype (Projectivization K V) := Fintype.ofFinite _ +local instance flat_JoinedPreparedRadialCount_3 : Finite (Submodule K V) := by + have : Finite V := Module.finite_of_finite K + exact Finite.of_injective (fun W : Submodule K V => (W : Set V)) SetLike.coe_injective +local instance flat_JoinedPreparedRadialCount_4 : Fintype (Submodule K V) := Fintype.ofFinite _ + +lemma planePoints_card (W : Submodule K V) : + (planePoints W).card=∑ i∈range (Module.finrank K W),Nat.card K^i := by + rw [planePoints,←Fintype.card_subtype,←Nat.card_eq_fintype_card, + ←Nat.card_congr (Incidence.projectiveSubmoduleEquiv W)] + exact Projectivization.card_of_finrank K W rfl + +lemma linePoints_card (W : ProjectiveLine (K:=K) (V:=V)) : + (planePoints W.1).card=Nat.card K+1 := by + rw [planePoints_card,W.2] + simp [sum_range_succ,Nat.add_comm] + +theorem residual_pairs_le (S : Finset (Projectivization K V)) + (X : Projectivization K V→Finset (Projectivization K V)) + (hX : ∀ x,X x⊆S) (M : ℕ) : + ((univ : Finset (Projectivization K V × ProjectiveLine (K:=K) (V:=V))).filter + (fun z => z.1∈planePoints z.2.1 ∧ M≤(X z.1∩planePoints z.2.1).card)).card ≤ + (Nat.card K+1)*((univ : Finset (ProjectiveLine (K:=K) (V:=V))).filter + (fun W => M≤(S∩planePoints W.1).card)).card := by + let R := (univ : Finset (ProjectiveLine (K:=K) (V:=V))).filter + (fun W => M≤(S∩planePoints W.1).card) + have hs : (univ.filter + (fun z : Projectivization K V × ProjectiveLine (K:=K) (V:=V) => + z.1∈planePoints z.2.1 ∧ M≤(X z.1∩planePoints z.2.1).card)) ⊆ + R.biUnion (fun W => planePoints W.1 ×ˢ {W}) := by + intro z hz + obtain ⟨_,hx,hrich⟩ := mem_filter.mp hz + apply mem_biUnion.mpr + refine ⟨z.2,mem_filter.mpr ⟨mem_univ _,hrich.trans ?_⟩, + mem_product.mpr ⟨hx,mem_singleton_self _⟩⟩ + exact card_le_card (inter_subset_inter_right (hX z.1)) + calc + _ ≤ (R.biUnion (fun W => planePoints W.1 ×ˢ {W})).card := card_le_card hs + _ ≤ ∑ W∈R,(planePoints W.1 ×ˢ {W}).card := card_biUnion_le + _ = (Nat.card K+1)*R.card := by simp [linePoints_card,mul_comm] + +lemma radialFiber_eq_inter (S : Finset (Projectivization K V)) (x : Projectivization K V) + (hx : x∉S) (W : RadialLine x) : radialFiber S x W=S∩planePoints W.1 := by + ext y + simp only [radialFiber,mem_filter,mem_inter,mem_planePoints] + constructor + · rintro ⟨hs,_,hw⟩; exact ⟨hs,hw⟩ + · rintro ⟨hs,hw⟩ + exact ⟨hs,(by intro he; exact hx (he ▸ hs)),hw⟩ + +end +end SharpLogRamsey.PreparedProjectiveGeometry + +namespace SharpLogRamsey.PreparedRadialResidual +open Finset PreparedProjectiveGeometry +open scoped Classical BigOperators +noncomputable section +variable {q : ℕ} [Fact q.Prime] +local instance flat_JoinedPreparedRadialCount_5 : Finite (Submodule (ZMod q) (Fin 4→ZMod q)) := + Finite.of_injective (fun W : Submodule (ZMod q) (Fin 4→ZMod q) => (W : Set (Fin 4→ZMod q))) + SetLike.coe_injective +local instance flat_JoinedPreparedRadialCount_6 : Fintype (Submodule (ZMod q) (Fin 4→ZMod q)) := Fintype.ofFinite _ +local instance flat_JoinedPreparedRadialCount_7 : Fintype (Projectivization (ZMod q) (Fin 4→ZMod q)) := Fintype.ofFinite _ + +theorem rich_card (hq : 3≤q) + (S : Finset (Projectivization (ZMod q) (Fin 4→ZMod q))) (hS : S.Nonempty) + (M Kp : ℕ) (hM2 : 2≤M) (hMN : M≤S.card) + (hcap : ∀ f : (Fin 4→ZMod q)→ₗ[ZMod q] ZMod q, f≠0 → + (S.filter (fun P => f P.rep=0)).card≤Kp) + (hsmall : 198*Real.sqrt ((S.card:ℝ)/M) M≤(S∩planePoints W.1).card)).card*M≤8718*S.card := by + let R := ((univ : Finset (ProjectiveLine (K:=ZMod q) (V:=Fin 4→ZMod q))).filter + (fun W => M≤(S∩planePoints W.1).card)) + have he (W : ProjectiveLine (K:=ZMod q) (V:=Fin 4→ZMod q)) : + S∩planePoints W.1=S.filter (fun P => P.submodule≤W.1) := by + ext P; simp + have hh := RichFiniteProjective.card_mul_le hq S hS (fun W : {W // W∈R} => W.1.1) + (fun W => W.1.2) (by intro W U h; exact Subtype.ext (Subtype.ext h)) M Kp hM2 hMN + (fun W => by simpa only [←he] using (mem_filter.mp W.2).2) + hcap hsmall hchar hprob hKM + simpa only [Fintype.card_coe] using hh + +theorem residual_pairs (hq : 3≤q) + (S : Finset (Projectivization (ZMod q) (Fin 4→ZMod q))) (hS : S.Nonempty) + (X : Projectivization (ZMod q) (Fin 4→ZMod q)→Finset (Projectivization (ZMod q) (Fin 4→ZMod q))) + (hX : ∀ x,X x⊆S) (M Kp : ℕ) (hM2 : 2≤M) (hMN : M≤S.card) + (hcap : ∀ f : (Fin 4→ZMod q)→ₗ[ZMod q] ZMod q, f≠0 → + (S.filter (fun P => f P.rep=0)).card≤Kp) + (hsmall : 198*Real.sqrt ((S.card:ℝ)/M) z.1∈planePoints z.2.1 ∧ M≤(X z.1∩planePoints z.2.1).card)).card*M ≤ + 8718*(q+1)*S.card := by + have h1 := Nat.mul_le_mul_right M (residual_pairs_le S X hX M) + have h2 := Nat.mul_le_mul_left (q+1) (rich_card hq S hS M Kp hM2 hMN hcap hsmall hchar hprob hKM) + have hqcard : Nat.card (ZMod q)=q := by simp + rw [hqcard] at h1 + nlinarith + +end +end SharpLogRamsey.PreparedRadialResidual + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/PrimeListRadial.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/PrimeListRadial.lean new file mode 100644 index 0000000000000000000000000000000000000000..561bac0dc8727d01c966ace3592ce2dba7857f74 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/PrimeListRadial.lean @@ -0,0 +1,110 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Spatial.SpatialCertificates + +namespace OAI + +section +namespace SharpLogRamsey.PreparedProjectiveGeometry +open Finset Filter Real SourceRadialTests GreedyPreparation +open scoped Classical BigOperators Topology +noncomputable section + +theorem prime_list_radial (δ C : ℝ) (hδ : 0<δ) : + ∀ᶠ σ : ℝ in atTop,∀ (q : ℕ) [Fact q.Prime],∀ (F : Finset (Submodule (ZMod q) (Fin 4→ZMod q))) (m : ℕ) + (S : Finset (Projectivization (ZMod q) (Fin 4→ZMod q))) (bs : List (Submodule (ZMod q) (Fin 4→ZMod q))), + Complete F planePoints m S bs → (removed S planePoints bs).Nonempty → + ∀ (P g : ℝ) (p : ℕ),σ^δ≤P → P≤σ/40 → g≤σ/2+C → 0

removed S planePoints bs \ (own S planePoints bs x∪{x}) + let K₀ := exp (σ+P/100-2*g) + ∃ D₀ D₁ : Finset (Projectivization (ZMod q) (Fin 4→ZMod q)), + (D₀.card:ℝ)≤N*exp (-P/200) ∧ (D₁.card:ℝ)≤N*exp (5*P) ∧ + (∀ x,x∉D₀ → ∀ i∈range (Nat.log 2 N+2), + ((richRadials (X x) x c (DyadicGrid.value i)).card:ℝ)*(DyadicGrid.value i)^100≤K₀) ∧ + (∀ x,x∉D₁ → (richRadials (X x) x c (1/(100*(p:ℝ)))).card=0 ∨ + 2*(exp σ+1)/(1/(100*(p:ℝ)))≤(exp (3*σ)/N)*exp (-3*P)) := by + have hpbound := ScaleSelection.eventually_polynomial_le_exp_rpow 400000000 4 δ 1 hδ (by norm_num) + simp only [one_mul,rpow_ofNat] at hpbound + filter_upwards [eventually_activated_tests δ C hδ,eventually_activated_list δ hδ, + eventually_radial_loss δ C hδ,eventually_strong_tests δ C hδ,eventually_strong_list, + hpbound,eventually_ge_atTop (1:ℝ)] + with σ htests hlist hloss hstrong hstronglist hpoly hσ q _ F m S bs hprep hnon P g p hP hPu hgu hp hpu hNl hNu hJ + let N := (removed S planePoints bs).card + let c := exp σ/(N:ℝ) + let K₀ := exp (σ+P/100-2*g) + have hN : (0:ℝ) DyadicGrid.value_pos i) + (by + intro i hi hh + change K₀ Or.inl (hzero x hx)⟩ + +end +end SharpLogRamsey.PreparedProjectiveGeometry + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/Projection.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/Projection.lean new file mode 100644 index 0000000000000000000000000000000000000000..7832ad861325984cc4a5fcecd3d1eb85b02975e8 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/Projection.lean @@ -0,0 +1,455 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.PencilGeometry + +namespace OAI + +section +open scoped BigOperators Classical +open Finset + +namespace SharpLogRamsey.Projection +open SharpLogRamsey.Incidence +open scoped Classical +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + +lemma rep_mem_line_iff (p z : Projectivization K V) : p.rep ∈ z.submodule ↔ p = z := by + rw [Projectivization.submodule_eq,Submodule.mem_span_singleton] + constructor + · intro h + exact p.mk_rep.symm.trans (((Projectivization.mk_eq_mk_iff' K _ _ _ _).mpr h).trans z.mk_rep) + · intro h + subst p + exact ⟨1,one_smul K z.rep⟩ + +lemma quotient_rep_ne_zero (z p : Projectivization K V) (hp : p ≠ z) : + z.submodule.mkQ p.rep ≠ 0 := by + intro h + have hm : p.rep ∈ LinearMap.ker z.submodule.mkQ := h + rw [Submodule.ker_mkQ] at hm + exact hp ((rep_mem_line_iff p z).mp hm) + +def project (z : Projectivization K V) (p : {p : Projectivization K V // p ≠ z}) : + Projectivization K (V ⧸ z.submodule) := + Projectivization.mk K (z.submodule.mkQ p.val.rep) (quotient_rep_ne_zero z p.val p.property) + +lemma quotient_dimension [FiniteDimensional K V] (z : Projectivization K V) : + Module.finrank K (V ⧸ z.submodule)+1 = Module.finrank K V := by + simpa only [Projectivization.finrank_submodule] using z.submodule.finrank_quotient_add_finrank + +lemma lift_covector_ne_zero (z : Projectivization K V) + (t : Projectivization K (Module.Dual K V)) (ht : SharpLogRamsey.Incidence.Incident z t) : + z.submodule.liftQ t.rep ((incident_iff_submodule z t).mp ht) ≠ 0 := by + intro h + have hc := congrArg (fun f : Module.Dual K (V ⧸ z.submodule) => f.comp z.submodule.mkQ) h + rw [Submodule.liftQ_mkQ] at hc + exact t.rep_nonzero hc + +def projectDual (z : Projectivization K V) + (t : {t : Projectivization K (Module.Dual K V) // SharpLogRamsey.Incidence.Incident z t}) : + Projectivization K (Module.Dual K (V ⧸ z.submodule)) := + Projectivization.mk K (z.submodule.liftQ t.val.rep + ((incident_iff_submodule z t.val).mp t.property)) (lift_covector_ne_zero z t.val t.property) + +lemma incident_mk_iff (v : V) (hv : v ≠ 0) (f : Module.Dual K V) (hf : f ≠ 0) : + SharpLogRamsey.Incidence.Incident (Projectivization.mk K v hv) (Projectivization.mk K f hf) ↔ f v = 0 := by + obtain ⟨a,ha⟩ := Projectivization.exists_smul_eq_mk_rep K v hv + obtain ⟨b,hb⟩ := Projectivization.exists_smul_eq_mk_rep K f hf + unfold SharpLogRamsey.Incidence.Incident + rw [← ha,← hb] + simp [Units.smul_def] + +lemma project_incident_iff (z : Projectivization K V) + (p : {p : Projectivization K V // p ≠ z}) + (t : {t : Projectivization K (Module.Dual K V) // SharpLogRamsey.Incidence.Incident z t}) : + SharpLogRamsey.Incidence.Incident (project z p) (projectDual z t) ↔ SharpLogRamsey.Incidence.Incident p.val t.val := by + rw [project,projectDual,incident_mk_iff] + rfl + +lemma projectDual_injective (z : Projectivization K V) : Function.Injective (projectDual z) := by + intro t u h + apply Subtype.ext + have hh := (Projectivization.mk_eq_mk_iff' K _ _ _ _).mp h + obtain ⟨a,ha⟩ := hh + rw [← t.val.mk_rep,← u.val.mk_rep,Projectivization.mk_eq_mk_iff'] + refine ⟨a,?_⟩ + ext v + exact congrArg (fun f : Module.Dual K (V ⧸ z.submodule) => f (z.submodule.mkQ v)) ha + +lemma collision_center_on_line (z : Projectivization K V) + (p q : {p : Projectivization K V // p ≠ z}) + (hpq : p.val ≠ q.val) (h : project z p = project z q) : + z.submodule ≤ p.val.submodule ⊔ q.val.submodule := by + obtain ⟨a,ha⟩ := (Projectivization.mk_eq_mk_iff' K _ _ _ _).mp h + have hker : p.val.rep-a • q.val.rep ∈ LinearMap.ker z.submodule.mkQ := by + change z.submodule.mkQ (p.val.rep-a • q.val.rep) = 0 + rw [map_sub,map_smul,ha,sub_self] + rw [Submodule.ker_mkQ] at hker + have hne : p.val.rep-a • q.val.rep ≠ 0 := by + intro he + apply hpq + rw [← p.val.mk_rep,← q.val.mk_rep,Projectivization.mk_eq_mk_iff'] + exact ⟨a,(sub_eq_zero.mp he).symm⟩ + let r := Projectivization.mk K (p.val.rep-a • q.val.rep) hne + have hr : r = z := by + apply Projectivization.submodule_injective + apply Submodule.eq_of_le_of_finrank_eq + · rw [Projectivization.submodule_mk,Submodule.span_singleton_le_iff_mem] + exact hker + · simp only [Projectivization.finrank_submodule] + have hline : r.submodule ≤ p.val.submodule ⊔ q.val.submodule := by + rw [Projectivization.submodule_mk,Submodule.span_singleton_le_iff_mem] + apply Submodule.sub_mem + · apply (le_sup_left : p.val.submodule ≤ p.val.submodule ⊔ q.val.submodule) + rw [Projectivization.submodule_eq] + exact Submodule.mem_span_singleton_self _ + · apply Submodule.smul_mem + apply (le_sup_right : q.val.submodule ≤ p.val.submodule ⊔ q.val.submodule) + rw [Projectivization.submodule_eq] + exact Submodule.mem_span_singleton_self _ + exact (congrArg Projectivization.submodule hr).symm.le.trans hline + +end +end SharpLogRamsey.Projection +namespace SharpLogRamsey.Projection +open SharpLogRamsey.Incidence Finset +open scoped Classical BigOperators +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + +lemma joining_line_finrank (p q : Projectivization K V) (hpq : p ≠ q) : + Module.finrank K ↥(p.submodule ⊔ q.submodule : Submodule K V) = 2 := by + have h := finrank_span_eq_card (Projectivization.linearIndependent_pair_iff_ne.mpr hpq) + rw [Matrix.range_cons_cons_empty] at h + rw [Submodule.span_insert] at h + rw [Projectivization.submodule_eq,Projectivization.submodule_eq] + exact h + +lemma joining_line_card [Finite K] (p q : Projectivization K V) (hpq : p ≠ q) : + Nat.card {z : Projectivization K V // z.submodule ≤ p.submodule ⊔ q.submodule} = + Nat.card K+1 := by + rw [← Nat.card_congr (projectiveSubmoduleEquiv (p.submodule ⊔ q.submodule))] + exact Projectivization.card_of_finrank_two K _ (joining_line_finrank p q hpq) + +def Collides (z p q : Projectivization K V) : Prop := ∃ (hp : p ≠ z) (hq : q ≠ z), + project z ⟨p,hp⟩ = project z ⟨q,hq⟩ + +lemma collides_on_line (z p q : Projectivization K V) (hpq : p ≠ q) (h : Collides z p q) : + z.submodule ≤ p.submodule ⊔ q.submodule := by + obtain ⟨hp,hq,h⟩ := h + exact collision_center_on_line z ⟨p,hp⟩ ⟨q,hq⟩ hpq h + +lemma collision_centers_card [Finite K] [Fintype (Projectivization K V)] + (p q : Projectivization K V) (hpq : p ≠ q) : + (univ.filter (fun z => Collides z p q)).card ≤ Nat.card K+1 := by + have hh := card_le_card (show univ.filter (fun z => Collides z p q) ⊆ + univ.filter (fun z => z.submodule ≤ p.submodule ⊔ q.submodule) from by + intro z hz + exact mem_filter.mpr ⟨mem_univ _,collides_on_line z p q hpq (mem_filter.mp hz).2⟩) + have he := joining_line_card p q hpq + rw [Nat.card_eq_fintype_card,Fintype.card_subtype] at he + exact hh.trans_eq he + +def orderedCollisions (A : Finset (Projectivization K V)) (z : Projectivization K V) : ℕ := + (A.offDiag.filter (fun pq => Collides z pq.1 pq.2)).card + +theorem collision_total [Finite K] [Fintype (Projectivization K V)] + (A : Finset (Projectivization K V)) : + ∑ z, orderedCollisions A z ≤ A.card*(A.card-1)*(Nat.card K+1) := by + unfold orderedCollisions + simp only [card_eq_sum_ones,sum_filter] + rw [sum_comm] + calc + _ ≤ ∑ pq ∈ A.offDiag, (Nat.card K+1) := by + apply sum_le_sum + rintro ⟨p,q⟩ hpq + have hh := collision_centers_card p q (mem_offDiag.mp hpq).2.2 + simpa only [card_eq_sum_ones,sum_filter] using hh + _ = _ := by simp [offDiag_card,Nat.mul_sub_left_distrib] + +end +end SharpLogRamsey.Projection +namespace SharpLogRamsey.FiniteImage +open Finset +open scoped Classical +noncomputable section +variable {α β : Type*} + +theorem card_le_image_add_collisions (s : Finset α) (f : α → β) : + s.card ≤ (s.image f).card+(s.offDiag.filter (fun ab => f ab.1 = f ab.2)).card := by + let r : (s.image f) → α := fun b => (mem_image.mp b.property).choose + have hr (b : s.image f) : r b ∈ s ∧ f (r b) = b.val := + (mem_image.mp b.property).choose_spec + let D : Finset α := (s.image f).attach.image r + let R := s \ D + let g (a : α) : α := if h : a ∈ s then r ⟨f a,mem_image_of_mem f h⟩ else a + have hg (a : α) (ha : a ∈ s) : g a ∈ D ∧ g a ∈ s ∧ f (g a) = f a := by + dsimp only [g] + rw [dite_eq_left ha] + exact ⟨mem_image.mpr ⟨⟨f a,mem_image_of_mem f ha⟩,mem_attach _ _,rfl⟩, + hr ⟨f a,mem_image_of_mem f ha⟩⟩ + have hR : R.card ≤ (s.offDiag.filter (fun ab => f ab.1 = f ab.2)).card := by + apply card_le_card_of_injOn (fun a => (a,g a)) + · intro a ha + obtain ⟨ha,hn⟩ := mem_sdiff.mp ha + obtain ⟨hgd,hgs,hgf⟩ := hg a ha + have hne : a ≠ g a := by + intro he + exact hn (he.symm ▸ hgd) + exact mem_filter.mpr ⟨mem_offDiag.mpr ⟨ha,hgs,hne⟩,hgf.symm⟩ + · intro a ha b hb he + exact congrArg Prod.fst he + have hD : D.card ≤ (s.image f).card := by + exact (card_image_le).trans_eq card_attach + calc + s.card ≤ (D ∪ R).card := card_le_card (by + intro a ha + by_cases hd : a ∈ D + · exact mem_union_left _ hd + · exact mem_union_right _ (mem_sdiff.mpr ⟨ha,hd⟩)) + _ ≤ D.card+R.card := card_union_le _ _ + _ ≤ _ := Nat.add_le_add hD hR + +end +end SharpLogRamsey.FiniteImage + +namespace SharpLogRamsey.Projection +open Finset +open scoped Classical +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + +def projected (A : Finset (Projectivization K V)) (z : Projectivization K V) : + Finset (Projectivization K (V ⧸ z.submodule)) := + (A.subtype (· ≠ z)).image (project z) + +lemma noncentral_collision_le (A : Finset (Projectivization K V)) (z : Projectivization K V) : + ((A.subtype (· ≠ z)).offDiag.filter (fun pq => project z pq.1 = project z pq.2)).card ≤ + orderedCollisions A z := by + apply card_le_card_of_injOn (fun pq => (pq.1.val,pq.2.val)) + · intro pq hpq + obtain ⟨hm,he⟩ := mem_filter.mp hpq + obtain ⟨hp,hq,hne⟩ := mem_offDiag.mp hm + apply mem_filter.mpr + refine ⟨mem_offDiag.mpr ⟨mem_subtype.mp hp,mem_subtype.mp hq,?_⟩,?_⟩ + · exact fun h => hne (Subtype.ext h) + · exact ⟨pq.1.property,pq.2.property,he⟩ + · intro p hp q hq he + apply Prod.ext <;> apply Subtype.ext + · exact congrArg Prod.fst he + · exact congrArg Prod.snd he + +theorem projection_loss (A : Finset (Projectivization K V)) (z : Projectivization K V) : + A.card ≤ (projected A z).card+orderedCollisions A z+1 := by + have h := FiniteImage.card_le_image_add_collisions (A.subtype (· ≠ z)) (project z) + have hcol := noncentral_collision_le A z + have ha : A.card ≤ (A.subtype (· ≠ z)).card+1 := by + rw [card_subtype] + have hcount := card_filter_add_card_filter_not (s := A) (p := fun p => p = z) + have hle : (A.filter (fun p => p = z)).card ≤ 1 := by + apply card_le_one.mpr + intro a ha b hb + exact (mem_filter.mp ha).2.trans (mem_filter.mp hb).2.symm + simpa only [not_not] using (show A.card ≤ (A.filter (fun p => ¬p = z)).card+1 by omega) + dsimp only [projected] + omega + +end +end SharpLogRamsey.Projection +namespace SharpLogRamsey.FiniteImage +open Finset +open scoped Classical BigOperators +noncomputable section +variable {α β : Type*} + +def collisions (s : Finset α) (f : α → β) : ℕ := + (s.offDiag.filter (fun ab => f ab.1 = f ab.2)).card + +lemma collisions_fiber_sum (s : Finset α) (f : α → β) : + collisions s f = ∑ b ∈ s.image f, + (s.filter (fun a => f a=b)).card*((s.filter (fun a => f a=b)).card-1) := by + let E := s.offDiag.filter (fun ab => f ab.1 = f ab.2) + have h : E.card = ∑ b ∈ s.image f, (E.filter (fun ab => f ab.1=b)).card := + card_eq_sum_card_fiberwise (f := fun ab => f ab.1) (fun ab hab => + mem_image_of_mem f (mem_offDiag.mp (mem_filter.mp hab).1).1) + change E.card = _ + rw [h] + apply sum_congr rfl + intro b hb + have he : E.filter (fun ab => f ab.1=b) = (s.filter (fun a => f a=b)).offDiag := by + ext ab + simp only [E,mem_filter,mem_offDiag] + aesop + rw [he,offDiag_card] + simp [Nat.mul_sub_left_distrib] + +lemma image_excess_sq (s : Finset α) (f : α → β) : + ((s.card:ℝ)-(s.image f).card)^2 ≤ (s.image f).card*collisions s f := by + let k (b : β) : ℝ := (s.filter (fun a => f a=b)).card + have hk (b : β) (hb : b ∈ s.image f) : 1 ≤ k b := by + obtain ⟨a,ha,rfl⟩ := mem_image.mp hb + have : 0 < (s.filter (fun x => f x=f a)).card := + card_pos.mpr ⟨a,mem_filter.mpr ⟨ha,rfl⟩⟩ + dsimp [k] + exact_mod_cast this + have hs : ∑ b ∈ s.image f, k b = s.card := by + simp only [k,← Nat.cast_sum] + congr 1 + exact (card_eq_sum_card_fiberwise (f := f) (fun a ha => mem_image_of_mem f ha)).symm + have hc : ∑ b ∈ s.image f, k b*(k b-1) = (collisions s f:ℝ) := by + rw [collisions_fiber_sum,Nat.cast_sum] + apply sum_congr rfl + intro b hb + have hh : 1 ≤ (s.filter (fun a => f a=b)).card := by + have hh := hk b hb + dsimp only [k] at hh + exact_mod_cast hh + rw [Nat.cast_mul,Nat.cast_sub hh,Nat.cast_one] + have hcs := sum_mul_sq_le_sq_mul_sq (s.image f) (fun _ => (1:ℝ)) (fun b => k b-1) + simp only [one_mul,one_pow,sum_const,nsmul_eq_mul,mul_one] at hcs + have he : ∑ b ∈ s.image f, (k b-1)^2 ≤ (collisions s f:ℝ) := by + rw [← hc] + apply sum_le_sum + intro b hb + nlinarith [hk b hb] + have ht : ∑ b ∈ s.image f, (k b-1) = (s.card:ℝ)-(s.image f).card := by + rw [sum_sub_distrib,hs] + simp + rw [ht] at hcs + exact hcs.trans (mul_le_mul_of_nonneg_left he (by positivity)) + +theorem image_excess (s : Finset α) (f : α → β) : + (s.card:ℝ) ≤ (s.image f).card+Real.sqrt ((s.image f).card*collisions s f) := by + have h := image_excess_sq s f + have hcard : ((s.image f).card:ℝ) ≤ s.card := by exact_mod_cast card_image_le (s:=s) (f:=f) + have hh : (s.card:ℝ)-(s.image f).card ≤ + Real.sqrt ((s.image f).card*collisions s f) := + (Real.le_sqrt (sub_nonneg.mpr hcard) (by positivity)).mpr h + linarith + +lemma collisions_mono (s t : Finset α) (h : s ⊆ t) (f : α → β) : + collisions s f ≤ collisions t f := by + apply card_le_card + intro ab hab + obtain ⟨⟨ha,hb,hn⟩,he⟩ := by simpa only [mem_filter,mem_offDiag] using hab + exact mem_filter.mpr ⟨mem_offDiag.mpr ⟨h ha,h hb,hn⟩,he⟩ + +theorem cap_contraction (s : Finset α) (f : α → β) (W : Finset β) : + ((s.filter (fun a => f a ∈ W)).card:ℝ) ≤ + W.card+Real.sqrt (W.card*collisions s f) := by + let t := s.filter (fun a => f a ∈ W) + have hi : t.image f ⊆ W := by + intro b hb + obtain ⟨a,ha,rfl⟩ := mem_image.mp hb + exact (mem_filter.mp ha).2 + have hic : ((t.image f).card:ℝ) ≤ W.card := by exact_mod_cast card_le_card hi + have hc : (collisions t f:ℝ) ≤ collisions s f := by + exact_mod_cast collisions_mono t s (filter_subset _ _) f + exact (image_excess t f).trans (add_le_add hic + (Real.sqrt_le_sqrt (mul_le_mul hic hc (by positivity) (by positivity)))) + +end +end SharpLogRamsey.FiniteImage +namespace SharpLogRamsey.Projection +open Finset +open scoped Classical BigOperators +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + +def liftCap (A : Finset (Projectivization K V)) (z : Projectivization K V) + (W : Finset (Projectivization K (V ⧸ z.submodule))) : Finset (Projectivization K V) := + (((A.subtype (· ≠ z)).filter (fun p => project z p ∈ W)).image Subtype.val) + +lemma liftCap_card (A : Finset (Projectivization K V)) (z : Projectivization K V) + (W : Finset (Projectivization K (V ⧸ z.submodule))) : + (liftCap A z W).card = ((A.subtype (· ≠ z)).filter (fun p => project z p ∈ W)).card := + card_image_of_injective _ Subtype.val_injective + +lemma mem_liftCap (A : Finset (Projectivization K V)) (z p : Projectivization K V) + (W : Finset (Projectivization K (V ⧸ z.submodule))) : + p ∈ liftCap A z W ↔ p ∈ A ∧ ∃ hp : p ≠ z, project z ⟨p,hp⟩ ∈ W := by + constructor + · intro h + obtain ⟨a,ha,rfl⟩ := mem_image.mp h + exact ⟨mem_subtype.mp (mem_filter.mp ha).1,a.property,(mem_filter.mp ha).2⟩ + · rintro ⟨hp,hn,hw⟩ + exact mem_image.mpr ⟨⟨p,hn⟩,mem_filter.mpr ⟨mem_subtype.mpr hp,hw⟩,rfl⟩ + +lemma liftCap_subset (A : Finset (Projectivization K V)) (z : Projectivization K V) + (W : Finset (Projectivization K (V ⧸ z.submodule))) : liftCap A z W ⊆ A := + fun _ hp => ((mem_liftCap _ _ _ _).mp hp).1 + +theorem liftCap_contraction (A : Finset (Projectivization K V)) (z : Projectivization K V) + (W : Finset (Projectivization K (V ⧸ z.submodule))) : + ((liftCap A z W).card:ℝ) ≤ W.card+Real.sqrt (W.card*orderedCollisions A z) := by + rw [liftCap_card] + apply (FiniteImage.cap_contraction (A.subtype (· ≠ z)) (project z) W).trans + apply add_le_add le_rfl + apply Real.sqrt_le_sqrt + apply mul_le_mul_of_nonneg_left _ (by positivity) + exact_mod_cast noncentral_collision_le A z + +lemma fiber_on_line (z p q : Projectivization K V) (hp : p ≠ z) (hq : q ≠ z) + (he : project z ⟨p,hp⟩ = project z ⟨q,hq⟩) : + q.submodule ≤ z.submodule ⊔ p.submodule := by + by_cases hpq : p=q + · subst q + exact le_sup_right + have hz := collision_center_on_line z ⟨p,hp⟩ ⟨q,hq⟩ hpq he + have hsub : z.submodule ⊔ p.submodule ≤ p.submodule ⊔ q.submodule := + sup_le hz le_sup_left + have hEq : z.submodule ⊔ p.submodule = p.submodule ⊔ q.submodule := by + apply Submodule.eq_of_le_of_finrank_eq hsub + rw [joining_line_finrank z p hp.symm,joining_line_finrank p q hpq] + rw [hEq] + exact le_sup_right + +variable [Finite K] [Fintype (Projectivization K V)] + +lemma project_fiber_card (A : Finset (Projectivization K V)) (z : Projectivization K V) + (b : Projectivization K (V ⧸ z.submodule)) : + ((A.subtype (· ≠ z)).filter (fun p => project z p=b)).card ≤ Nat.card K := by + let F := (A.subtype (· ≠ z)).filter (fun p => project z p=b) + by_cases hf : F.Nonempty + · obtain ⟨p,hp⟩ := hf + let L : Finset (Projectivization K V) := + univ.filter (fun q => q.submodule ≤ z.submodule ⊔ p.val.submodule) + have hL : L.card = Nat.card K+1 := by + have h := joining_line_card z p.val p.property.symm + rw [Nat.card_eq_fintype_card,Fintype.card_subtype] at h + exact h + have hz : z ∈ L := mem_filter.mpr ⟨mem_univ _,le_sup_left⟩ + have hb : F.card ≤ (L.erase z).card := by + apply card_le_card_of_injOn Subtype.val + · intro q hq + apply mem_erase.mpr + refine ⟨q.property,mem_filter.mpr ⟨mem_univ _,?_⟩⟩ + exact fiber_on_line z p.val q.val p.property q.property + ((mem_filter.mp hp).2.trans (mem_filter.mp hq).2.symm) + · intro x hx y hy he + exact Subtype.ext he + rw [card_erase_of_mem hz,hL] at hb + simpa using hb + · have : F=∅ := not_nonempty_iff_eq_empty.mp hf + change F.card ≤ _ + simp [this] + +theorem liftCap_initial (A : Finset (Projectivization K V)) (z : Projectivization K V) + (W : Finset (Projectivization K (V ⧸ z.submodule))) : + (liftCap A z W).card ≤ Nat.card K*W.card := by + rw [liftCap_card] + apply card_le_mul_card_image_of_maps_to (f := project z) + (fun p hp => (mem_filter.mp hp).2) (Nat.card K) + intro b hb + apply le_trans _ (project_fiber_card A z b) + apply card_le_card + intro p hp + obtain ⟨hp,he⟩ := mem_filter.mp hp + exact mem_filter.mpr ⟨(mem_filter.mp hp).1,he⟩ + +end +end SharpLogRamsey.Projection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/ProjectionCapture.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/ProjectionCapture.lean new file mode 100644 index 0000000000000000000000000000000000000000..d2ff71488d1814f99d0784a1f9c08ee9931f5111 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/ProjectionCapture.lean @@ -0,0 +1,71 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.Projection + +namespace OAI + +section +namespace SharpLogRamsey.Projection +open Finset Incidence +open scoped Classical BigOperators +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + +lemma projected_liftCap (S : Finset (Projectivization K V)) (z : Projectivization K V) + (W : Finset (Projectivization K (V ⧸ z.submodule))) : + projected (liftCap S z W) z=projected S z∩W := by + ext b + constructor + · intro hb + obtain ⟨p,hp,rfl⟩ := mem_image.mp hb + have hh := (mem_liftCap S z p.val W).mp (mem_subtype.mp hp) + obtain ⟨hS,hn,hW⟩ := hh + exact mem_inter.mpr ⟨mem_image.mpr ⟨p,mem_subtype.mpr hS,rfl⟩,hW⟩ + · intro hb + obtain ⟨hs,hw⟩ := mem_inter.mp hb + obtain ⟨p,hp,rfl⟩ := mem_image.mp hs + exact mem_image.mpr ⟨p,mem_subtype.mpr ((mem_liftCap _ _ _ _).mpr + ⟨mem_subtype.mp hp,p.property,hw⟩),rfl⟩ + +lemma projected_card_le (S : Finset (Projectivization K V)) (z : Projectivization K V) : + (projected S z).card≤S.card := by + exact card_image_le.trans (by rw [card_subtype]; exact card_filter_le _ _) + +lemma inter_liftCap (S U : Finset (Projectivization K V)) (hSU : S⊆U) + (z : Projectivization K V) (W : Finset (Projectivization K (V ⧸ z.submodule))) : + S∩liftCap U z W=liftCap S z W := by + ext p + simp only [mem_inter,mem_liftCap] + exact ⟨fun h => ⟨h.1,h.2.2⟩,fun h => ⟨h.1,hSU h.1,h.2⟩⟩ + +theorem original_support_loss (S U : Finset (Projectivization K V)) (hSU : S⊆U) + (z : Projectivization K V) (W : Finset (Projectivization K (V ⧸ z.submodule))) : + (S\liftCap U z W).card ≤ (projected S z\W).card+orderedCollisions S z+1 := by + have hc := projected_card_le (liftCap S z W) z + rw [projected_liftCap] at hc + have he : (S\liftCap U z W).card+(S∩liftCap U z W).card=S.card := + card_sdiff_add_card_inter S (liftCap U z W) + rw [inter_liftCap S U hSU] at he + have hi : (projected S z\W).card+(projected S z∩W).card=(projected S z).card := + card_sdiff_add_card_inter _ _ + have hp := projection_loss S z + omega + +theorem original_support_loss_real (S U : Finset (Projectivization K V)) (hSU : S⊆U) + (z : Projectivization K V) (W : Finset (Projectivization K (V ⧸ z.submodule))) + (ε δ : ℝ) (hε : 0≤ε) + (hcap : (projected S z\W).card≤ε*(projected S z).card) + (hcol : (orderedCollisions S z:ℝ)+1≤δ*S.card) : + ((S\liftCap U z W).card:ℝ)≤(ε+δ)*S.card := by + have h := original_support_loss S U hSU z W + have hr : ((S\liftCap U z W).card:ℝ)≤(projected S z\W).card+orderedCollisions S z+1 := by + exact_mod_cast h + have hp : ((projected S z).card:ℝ)≤S.card := by exact_mod_cast projected_card_le S z + have hpc := mul_le_mul_of_nonneg_left hp hε + linarith + +end +end SharpLogRamsey.Projection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/ProjectionCenterBounds.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/ProjectionCenterBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..09e9a19b79e7032814de8cda94f9748f0279297a --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/ProjectionCenterBounds.lean @@ -0,0 +1,117 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.ProjectionCenterTools + +namespace OAI + +section +namespace SharpLogRamsey.Projection +open Finset Real Incidence +open scoped Classical BigOperators +noncomputable section + +lemma center_budget (q N Q H s a t u e τ : ℝ) + (hq : 2≤q) (hN : 0 by positivity) (by simp) + simpa only [N,show n+2=(n+1)+1 by omega,pow_succ,mul_comm] using hh + have hs : (0:ℝ) if t ∈ T then 1 else 0 + have hw : (∑ t, w t) = (T.card:ℝ) := by simp [w] + have hw2 : (∑ t, w t^2) = (T.card:ℝ) := by simp [w] + have hv := projective_variance_le + (show Module.finrank K (Module.Dual K V) = n+3 from Subspace.dual_finrank_eq.trans hdim) w + rw [hw,hw2,← (bidual (K:=K) (V:=V)).sum_comp] at hv + have hcut (z : Projectivization K V) : + weightedIncidences SharpLogRamsey.Incidence.Incident w (bidual z) = ((cut T z).card:ℝ) := by + simp only [weightedIncidences,incident_bidual,w] + rw [← sum_filter,← sum_filter] + simp only [sum_const,nsmul_eq_mul,mul_one] + congr 2 + ext t + simp [cut,and_comm] + simp_rw [hcut] at hv + exact hv + +end +end SharpLogRamsey.Projection +namespace SharpLogRamsey.FiniteAveraging +open Finset +open scoped BigOperators + +lemma exists_small {α : Type*} [Fintype α] (f : α → ℝ) + (h : ∑ x, f x < Fintype.card α) : ∃ x, f x < 1 := by + by_contra hn + push Not at hn + have hh : (Fintype.card α:ℝ) ≤ ∑ x, f x := by + simpa using sum_le_sum (s := univ) (f := fun _ => (1:ℝ)) (g := f) (fun x _ => hn x) + exact not_lt_of_ge hh h + +lemma exists_five {α : Type*} [Fintype α] (f₁ f₂ f₃ f₄ f₅ : α → ℝ) + (hf₁ : ∀ x, 0 ≤ f₁ x) (hf₂ : ∀ x, 0 ≤ f₂ x) (hf₃ : ∀ x, 0 ≤ f₃ x) + (hf₄ : ∀ x, 0 ≤ f₄ x) (hf₅ : ∀ x, 0 ≤ f₅ x) + (h : (∑ x, f₁ x)+(∑ x, f₂ x)+(∑ x, f₃ x)+(∑ x, f₄ x)+(∑ x, f₅ x) < + Fintype.card α) : + ∃ x, f₁ x < 1 ∧ f₂ x < 1 ∧ f₃ x < 1 ∧ f₄ x < 1 ∧ f₅ x < 1 := by + have hs : ∑ x, (f₁ x+f₂ x+f₃ x+f₄ x+f₅ x) < (Fintype.card α:ℝ) := by + simpa only [sum_add_distrib] using h + obtain ⟨x,hx⟩ := exists_small _ hs + exact ⟨x,by linarith [hf₂ x,hf₃ x,hf₄ x,hf₅ x], + by linarith [hf₁ x,hf₃ x,hf₄ x,hf₅ x], + by linarith [hf₁ x,hf₂ x,hf₄ x,hf₅ x], + by linarith [hf₁ x,hf₂ x,hf₃ x,hf₅ x], + by linarith [hf₁ x,hf₂ x,hf₃ x,hf₄ x]⟩ + +end SharpLogRamsey.FiniteAveraging + +namespace SharpLogRamsey.Projection +open SharpLogRamsey.Incidence Finset +open scoped Classical BigOperators +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + +theorem exists_center {n : ℕ} (hdim : Module.finrank K V=n+3) + (S A : Finset (Projectivization K V)) + (T U : Finset (Projectivization K (Module.Dual K V))) + (δ u cS cA e : ℝ) (hδ : 0<δ) (hu : 0 div_nonneg (sq_nonneg _) (sq_nonneg _)) + (fun _ => div_nonneg (by positivity) hu.le) + (fun _ => div_nonneg (by positivity) hcS.le) + (fun _ => div_nonneg (by positivity) hcA.le) + (fun _ => div_nonneg (by positivity) he.le) hall + refine ⟨z,?_,(div_lt_one hu).mp hz₂,(div_lt_one hcS).mp hz₃, + (div_lt_one hcA).mp hz₄,(div_lt_one he).mp hz₅⟩ + have hh := (div_lt_one (sq_pos_of_pos hδ)).mp hz₁ + exact (sq_lt_sq₀ (abs_nonneg _) hδ.le).mp (by simpa [v,sq_abs] using hh) + +end +end SharpLogRamsey.Projection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/ProjectionDescription.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/ProjectionDescription.lean new file mode 100644 index 0000000000000000000000000000000000000000..9c9b08a909f39c0ddc3b2f56695cb82332bfd8a5 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/ProjectionDescription.lean @@ -0,0 +1,112 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.ProjectionFullDescription + +namespace OAI + +section +namespace SharpLogRamsey.GeometricCover +open Finset Real Incidence Projection +open scoped Classical +noncomputable section + +lemma expansion_cap {q P b N T : ℝ} {r : ℕ} (hN : 0 card_le_ceil_exp _ L (hF z).2.2 + let m := 300000*q^(i+5)/T + let A := powers (liftedLibrary U F) U 8 + let caps := A.filter (fun W => W⊆U ∧ (W.card:ℝ)≤3*m) + have hAc : A.card≤(Fintype.card (Projectivization K V)*M)^8 := + (powers_card _ _ _).trans (Nat.pow_le_pow_left (liftedLibrary_card U F M hM) 8) + refine ⟨caps,?_,?_,?_⟩ + · intro W hW + have hh := (mem_filter.mp hW).2 + refine ⟨hh.1,?_⟩ + convert hh.2 using 1 ; dsimp only [m,q] ; ring + · intro S T' hSU hSn hT'U hTt hsp + have hcover : ∀ z, + (9/10:ℝ)*S.card≤(projected S z).card → + (T'.card:ℝ)/(3*Nat.card K)≤(quotientCut T' z).card → + ((quotientCut T' z).card:ℝ)≤2*T'.card/Nat.card K → + ((quotientCut UT z).card:ℝ)≤100*UT.card/Nat.card K → + (S.card:ℝ)*T'.card/(4*Nat.card K)≤(projected S z).card*(quotientCut T' z).card → + (incidenceCount (projected S z) (quotientCut T' z):ℝ)≤ + 400*τ*(projected S z).card*(quotientCut T' z).card/Nat.card K → + ∃ W∈F z,(99/100:ℝ)*(projected S z).card≤(projected S z∩W).card := by + intro z h90 hlo _hhi hcut hpr hqs + apply (hF z).2.1 _ _ (projected_mono hSU z) (quotientCut_mono hT'U z) + · have ha : 0<(projected S z).card := by + have hh : (0:ℝ)<(projected S z).card := by rw [hSn] at h90; nlinarith + exact_mod_cast hh + have hc : 0<(quotientCut T' z).card := by + have hh : (0:ℝ)<(quotientCut T' z).card := + (by rw [hTt]; positivity : (0:ℝ)<(T'.card:ℝ)/(3*Nat.card K)).trans_le hlo + exact_mod_cast hh + refine ⟨ha,hc,card_le_card (projected_mono hSU z),card_le_card (quotientCut_mono hT'U z), + by simpa only [hSn] using h90,by simpa only [hTt] using hlo,?_,?_,hcut⟩ + · have hh := div_le_div_of_nonneg_right hprod (show 0≤4*q by positivity) + have heq := quotient_product hq0 (i+1) (b:=b) + rw [show i+1+3=i+4 by omega,show i+1+4=i+5 by omega] at heq + rw [←heq] at hh + apply hh.trans + simpa only [hSn,hTt,show i+1+3=i+4 by omega] using hpr + · let : Finite (V ⧸ z.submodule) := Module.finite_of_finite K + let : Fintype (Projectivization K (V ⧸ z.submodule)) := Fintype.ofFinite _ + let : Finite (Module.Dual K (V ⧸ z.submodule)) := Module.finite_of_finite K + let : Fintype (Projectivization K (Module.Dual K (V ⧸ z.submodule))) := Fintype.ofFinite _ + have hdimq : Module.finrank K (V ⧸ z.submodule)=(i+1)+3 := by + have hh := quotient_dimension z + omega + apply sparse_product_bound_two hdimq + apply hqs.trans + have hh := mul_le_mul_of_nonneg_right (show 400*τ≤1/20 by linarith) + (show 0≤((projected S z).card:ℝ)*(quotientCut T' z).card/q by positivity) + convert hh using 1 <;> ring + · exact hqs + have hdim' : Module.finrank K V=(i+2)+3 := by omega + obtain ⟨W,hWA,hWU,hWsize,hWcap,_⟩ := eight_projection_library hdim' U S hSU UT T' hT'U τ m hτ + (by dsimp only [m]; positivity) (by simpa only [hSn] using hN) + (by simpa only [hSn,show i+2+1=i+3 by omega] using hsmall) + (by simpa only [hTt] using hlarge) (by simpa only [hSn,hTt] using hsp) + F M hM (fun z W hW => (hF z).1 W hW |>.2) hcover + (by simpa only [m,q,show i+2+1=i+3 by omega] using hhalf) + (by simpa only [m,q,show i+2+1=i+3 by omega] using hpow) + exact ⟨W,mem_filter.mpr ⟨hWA,hWU,hWsize⟩,by simpa only [hSn] using hWcap⟩ + · have hh := power_pair_log (by decide : (8:ℕ)≠0) (show caps.card≤(Fintype.card (Projectivization K V)*M)^8 from (card_filter_le A (fun W => W⊆U ∧ (W.card:ℝ)≤3*m)).trans hAc) + have hc := projective_log_card (i+5) hdim + have hMlog := log_ceil_exp hL + have hheader := header_log_le (i+5) hdim U UT + simp only [Nat.cast_ofNat] at hh + change log ((caps.card:ℝ)+1)≤_ at hh + have hsum : log ((caps.card:ℝ)+1)≤8*(((i+5:ℕ):ℝ)+1)*q+8*L+16 := by + dsimp only [M] at hh + dsimp only [q] at * + linarith + have hLbound : L≤(2*(i:ℝ)+13)*q+2*H*Z := by + dsimp only [L] + dsimp only [q] at * + push_cast at hheader ⊢ + linarith + have hqZ := mul_le_mul_of_nonneg_left hZq (show 0≤24*(i:ℝ)+152 by positivity) + have h1Z : 1≤Z := hq.trans hZq + have hfinal : log ((caps.card:ℝ)+1)≤(16*H+24*(i:ℝ)+200)*Z := by + push_cast at hsum + nlinarith only [hsum,hLbound,hqZ,h1Z] + simpa only [Z,q,d,e,mul_assoc] using hfinal + +end +end SharpLogRamsey.GeometricCover + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/ProjectionMessageCost.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/ProjectionMessageCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..9181f394a180274c442a1ff2bf4adac9de2b79d8 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/ProjectionMessageCost.lean @@ -0,0 +1,67 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.GeometricCover + +namespace OAI + +section +namespace SharpLogRamsey.GeometricCover +open Finset Real Validation +open scoped Classical +noncomputable section + +lemma pair_header_log (A B : ℕ) : + log ((((A+1)*(B+1):ℕ):ℝ)+1)≤log ((A:ℝ)+1)+log ((B:ℝ)+1)+1 := by + have hm : (1:ℝ)≤((A:ℝ)+1)*((B:ℝ)+1) := by nlinarith [Nat.cast_nonneg (α:=ℝ) A,Nat.cast_nonneg (α:=ℝ) B] + have he : ((((A+1)*(B+1):ℕ):ℝ)+1)≤2*(((A:ℝ)+1)*((B:ℝ)+1)) := by + push_cast + linarith + have hh := log_le_log (by positivity) he + rw [log_mul (by norm_num : (2:ℝ)≠0) (by positivity),log_mul (by positivity) (by positivity)] at hh + have hl := log_le_sub_one_of_pos (by norm_num : (0:ℝ)<2) + linarith + +lemma power_pair_log {N A B k : ℕ} (hk : k≠0) (hN : N≤(A*B)^k) : + log ((N:ℝ)+1)≤(k:ℝ)*(log ((A:ℝ)+1)+log ((B:ℝ)+1)) := by + have ha : (0:ℝ)≤A := by positivity + have hb : (0:ℝ)≤B := by positivity + have hp : ((A:ℝ)*B)^k+1≤((A:ℝ)*B+1)^k := by + simpa only [one_pow] using pow_add_pow_le (mul_nonneg ha hb) (by norm_num : (0:ℝ)≤1) hk + have hmul : (A:ℝ)*B+1≤((A:ℝ)+1)*((B:ℝ)+1) := by nlinarith + have hc : (N:ℝ)≤((A:ℝ)*B)^k := by exact_mod_cast hN + have he : (N:ℝ)+1≤(((A:ℝ)+1)*((B:ℝ)+1))^k := + (by linarith only [hc] : (N:ℝ)+1≤((A:ℝ)*B)^k+1).trans + (hp.trans (pow_le_pow_left₀ (by positivity) hmul k)) + have hl := log_le_log (by positivity) he + rwa [log_pow,log_mul (by positivity) (by positivity)] at hl + +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedProjectionMessageCost_1 : Fintype (Projectivization K V) := by + letI : Finite V := Module.finite_of_finite K + exact Fintype.ofFinite _ +local instance flat_JoinedProjectionMessageCost_2 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedProjectionMessageCost_3 : Fintype (Projectivization K (Module.Dual K V)) := Fintype.ofFinite _ + +lemma domain_log_le (r : ℕ) (hdim : Module.finrank K V=r) + (U : Finset (Projectivization K V)) : + log ((U.card:ℝ)+1)≤((r:ℝ)+1)*Nat.card K := by + apply le_trans _ (projective_log_card r hdim) + apply log_le_log (by positivity) + exact_mod_cast Nat.add_le_add_right (card_le_univ U) 1 + +lemma header_log_le (r : ℕ) (hdim : Module.finrank K V=r) + (U : Finset (Projectivization K V)) + (UT : Finset (Projectivization K (Module.Dual K V))) : + log ((((U.card+1)*(UT.card+1):ℕ):ℝ)+1)≤(2*(r:ℝ)+3)*Nat.card K := by + have h1 := domain_log_le r hdim U + have h2 := domain_log_le r (Subspace.dual_finrank_eq.trans hdim) UT + have hq : (1:ℝ)≤Nat.card K := by exact_mod_cast (Nat.card_pos (α:=K)) + have h := pair_header_log U.card UT.card + linarith + +end +end SharpLogRamsey.GeometricCover + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/ProjectionPublic.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/ProjectionPublic.lean new file mode 100644 index 0000000000000000000000000000000000000000..f868964e0fb6445d169fa008d2ec19d92c30dce5 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/ProjectionPublic.lean @@ -0,0 +1,116 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.QuotientBounds +import OAI.Combinatorics.SharpRamsey.Geometry.EightIntersections + +namespace OAI + +section +namespace SharpLogRamsey.Projection +open Finset Real Incidence CapComposition +open scoped Classical BigOperators +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedProjectionPublic_1 : Fintype (Projectivization K V) := by + letI : Finite V := Module.finite_of_finite K + exact Fintype.ofFinite _ +local instance flat_JoinedProjectionPublic_2 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedProjectionPublic_3 : Fintype (Projectivization K (Module.Dual K V)) := Fintype.ofFinite _ + +omit [Finite K] [FiniteDimensional K V] in +lemma lift_contraction_numeric (A : Finset (Projectivization K V)) + (z : Projectivization K V) (W : Finset (Projectivization K (V ⧸ z.submodule))) + (m Q : ℝ) (hm : 0 ≤ m) (hQ : 0 < Q) (hW : (W.card:ℝ) ≤ m) + (hcol : (orderedCollisions A z:ℝ) ≤ 100*(A.card:ℝ)^2/Q) : + ((liftCap A z W).card:ℝ) ≤ m+sqrt (100*m/Q)*A.card := by + apply (liftCap_contraction A z W).trans + apply add_le_add hW + have hh : (W.card:ℝ)*orderedCollisions A z ≤ m*(100*(A.card:ℝ)^2/Q) := + mul_le_mul hW hcol (by positivity) hm + apply (sqrt_le_sqrt hh).trans_eq + rw [show m*(100*(A.card:ℝ)^2/Q)=(100*m/Q)*(A.card:ℝ)^2 by ring, + sqrt_mul (by positivity),sqrt_sq (by positivity : (0:ℝ) ≤ A.card)] + +def liftedLibrary (U : Finset (Projectivization K V)) + (F : ∀ z : Projectivization K V, Finset (Finset (Projectivization K (V ⧸ z.submodule)))) : + Finset (Finset (Projectivization K V)) := + univ.biUnion (fun z => (F z).image (liftCap U z)) + +lemma liftedLibrary_card (U : Finset (Projectivization K V)) + (F : ∀ z : Projectivization K V, Finset (Finset (Projectivization K (V ⧸ z.submodule)))) + (M : ℕ) (hM : ∀ z,(F z).card ≤ M) : + (liftedLibrary U F).card ≤ Fintype.card (Projectivization K V)*M := by + apply card_biUnion_le.trans + calc + _ ≤ ∑ z : Projectivization K V,M := + sum_le_sum (fun z hz => card_image_le.trans (hM z)) + _ = _ := by simp + +theorem eight_projection_library {n : ℕ} (hdim : Module.finrank K V=n+3) + (U S : Finset (Projectivization K V)) (hSU : S ⊆ U) + (UT T : Finset (Projectivization K (Module.Dual K V))) (hTU : T ⊆ UT) + (τ m : ℝ) (hτ : 0 < τ) (hm : 0 ≤ m) + (hS : 100 ≤ S.card) + (hsmall : (S.card:ℝ) ≤ (Nat.card K:ℝ)^(n+1)/100000) + (hlarge : 1000000*(Nat.card K:ℝ) ≤ T.card) + (hsparse : (incidenceCount S T:ℝ) ≤ τ*S.card*T.card/Nat.card K) + (F : ∀ z : Projectivization K V, Finset (Finset (Projectivization K (V ⧸ z.submodule)))) + (M : ℕ) (hM : ∀ z,(F z).card ≤ M) + (hsize : ∀ z W,W ∈ F z → (W.card:ℝ) ≤ m) + (hcover : ∀ z, + (9/10:ℝ)*S.card ≤ (projected S z).card → + (T.card:ℝ)/(3*Nat.card K) ≤ (quotientCut T z).card → + ((quotientCut T z).card:ℝ) ≤ 2*T.card/Nat.card K → + ((quotientCut UT z).card:ℝ) ≤ 100*UT.card/Nat.card K → + (S.card:ℝ)*T.card/(4*Nat.card K) ≤ (projected S z).card*(quotientCut T z).card → + (incidenceCount (projected S z) (quotientCut T z):ℝ) ≤ + 400*τ*(projected S z).card*(quotientCut T z).card/Nat.card K → + ∃ W ∈ F z,(99/100:ℝ)*(projected S z).card ≤ (projected S z∩W).card) + (hhalf : sqrt (100*m/(Nat.card K:ℝ)^(n+1)) ≤ 1/2) + (hpow : (Nat.card K:ℝ)*(sqrt (100*m/(Nat.card K:ℝ)^(n+1)))^7 ≤ 1) : + ∃ A ∈ powers (liftedLibrary U F) U 8,A ⊆ U ∧ + (A.card:ℝ) ≤ 3*m ∧ (S.card:ℝ)/2 ≤ (S∩A).card ∧ + (powers (liftedLibrary U F) U 8).card ≤ + (Fintype.card (Projectivization K V)*M)^8 := by + let q : ℝ := Nat.card K + have hq : 0 < q := by dsimp [q]; exact_mod_cast Nat.card_pos (α:=K) + have h1 : ∀ D ∈ liftedLibrary U F,(D.card:ℝ) ≤ q*m := by + intro D hD + obtain ⟨z,_,hz⟩ := mem_biUnion.mp hD + obtain ⟨W,hW,rfl⟩ := mem_image.mp hz + have hh : ((liftCap U z W).card:ℝ) ≤ q*W.card := by + dsimp [q] + exact_mod_cast liftCap_initial U z W + exact hh.trans (mul_le_mul_of_nonneg_left (hsize z W hW) hq.le) + have hstep : ∀ A,A ⊆ U → A.Nonempty → ∃ D ∈ liftedLibrary U F,D ⊆ U ∧ + ((S\D).card:ℝ) ≤ (3/100:ℝ)*S.card ∧ + ((A∩D).card:ℝ) ≤ m+sqrt (100*m/q^(n+1))*A.card := by + intro A hAU hA + obtain ⟨z,hSn,hTlo,hThi,hU,hmul,hsp,hcS,hcA⟩ := + quotient_data hdim S A T UT hA hTU τ hτ hS hsmall hlarge hsparse + obtain ⟨W,hW,hcap⟩ := hcover z hSn hTlo hThi hU hmul hsp + refine ⟨liftCap U z W,mem_biUnion.mpr ⟨z,mem_univ _,mem_image.mpr ⟨W,hW,rfl⟩⟩, + liftCap_subset U z W,?_,?_⟩ + · have hc : ((projected S z\W).card:ℝ) ≤ (1/100:ℝ)*(projected S z).card := by + have he : ((projected S z\W).card:ℝ)+(projected S z∩W).card=(projected S z).card := by + exact_mod_cast card_sdiff_add_card_inter (projected S z) W + linarith + have hcol : (orderedCollisions S z:ℝ)+1 ≤ (2/100:ℝ)*S.card := by + have hs : (100:ℝ) ≤ S.card := by exact_mod_cast hS + linarith + simpa only [show (1/100:ℝ)+2/100=3/100 by norm_num] using + original_support_loss_real S U hSU z W (1/100) (2/100) (by norm_num) hc hcol + · rw [inter_liftCap A U hAU] + exact lift_contraction_numeric A z W m (q^(n+1)) hm (pow_pos hq _) (hsize z W hW) hcA.le + obtain ⟨A,hA,hAU,hsizeA,hcapA⟩ := eight_intersections U S + (card_pos.mp (by omega)) hSU (liftedLibrary U F) m q (sqrt (100*m/q^(n+1))) hm hq.le + (sqrt_nonneg _) hhalf hpow h1 hstep + refine ⟨A,hA,hAU,hsizeA,hcapA,?_⟩ + exact (powers_card _ _ _).trans (Nat.pow_le_pow_left (liftedLibrary_card U F M hM) 8) + +end +end SharpLogRamsey.Projection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/ProjectiveTransport.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/ProjectiveTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..66f53f839820ebf09d5927c4138deb1808fd4fcd --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/ProjectiveTransport.lean @@ -0,0 +1,72 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.Projection +import OAI.Combinatorics.SharpRamsey.Learning.ValidationCover + +namespace OAI + +section +namespace SharpLogRamsey.ProjectiveDuality +open Incidence Finset +open scoped Classical BigOperators +noncomputable section +variable {K V W : Type*} [Field K] [AddCommGroup V] [Module K V] + [AddCommGroup W] [Module K W] + +lemma incident_mapEquiv (e : V ≃ₗ[K] W) (a : Projectivization K V) + (b : Projectivization K (Module.Dual K V)) : + SharpLogRamsey.Incidence.Incident (mapEquiv e a) (mapEquiv e.symm.dualMap b) ↔ SharpLogRamsey.Incidence.Incident a b := by + induction a using Projectivization.ind with + | h v hv => + induction b using Projectivization.ind with + | h f hf => + dsimp only [mapEquiv,Equiv.coe_fn_mk] + rw [Projectivization.map_mk,Projectivization.map_mk, + Projection.incident_mk_iff,Projection.incident_mk_iff] + simp only [LinearEquiv.coe_coe,LinearEquiv.dualMap_apply,e.symm_apply_apply] + +lemma incidenceCount_mapEquiv (e : V ≃ₗ[K] W) + (S : Finset (Projectivization K V)) (T : Finset (Projectivization K (Module.Dual K V))) : + incidenceCount (S.image (mapEquiv e)) (T.image (mapEquiv e.symm.dualMap))= + incidenceCount S T := by + unfold incidenceCount + rw [sum_image (mapEquiv e.symm.dualMap).injective.injOn] + apply sum_congr rfl + intro t ht + rw [filter_image] + simp only [incident_mapEquiv] + exact card_image_of_injective _ (mapEquiv e).injective + +variable [FiniteDimensional K V] +lemma incidenceCount_bidual (S : Finset (Projectivization K V)) + (T : Finset (Projectivization K (Module.Dual K V))) : + incidenceCount T (S.image bidual)=incidenceCount S T := by + unfold incidenceCount + rw [sum_image bidual.injective.injOn] + simp only [incident_bidual] + simp only [card_filter] + rw [sum_comm] + +lemma pullback_cover {α β : Type*} (e : α ≃ β) (U S : Finset α) + (E : Finset β) (hE : E ⊆ U.image e) : + E.image e.symm ⊆ U ∧ (E.image e.symm).card=E.card ∧ + (S∩E.image e.symm).card=((S.image e)∩E).card := by + refine ⟨?_,card_image_of_injective _ e.symm.injective,?_⟩ + · intro a ha + obtain ⟨b,hb,he⟩ := mem_image.mp ha + obtain ⟨a₀,ha₀,he₀⟩ := mem_image.mp (hE hb) + have hba : e.symm b=a₀ := by rw [←he₀,e.symm_apply_apply] + rw [←he,hba] + exact ha₀ + · have he : (S∩E.image e.symm).image e=(S.image e)∩E := by + rw [image_inter _ _ e.injective] + congr 1 + ext b + simp + rw [←he,card_image_of_injective _ e.injective] + +end +end SharpLogRamsey.ProjectiveDuality + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/QuotientBounds.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/QuotientBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..29ecead1612d6bf52bff15f192accb25bd65c4eb --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/QuotientBounds.lean @@ -0,0 +1,117 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.QuotientSupports + +namespace OAI + +section +namespace SharpLogRamsey.Projection +open Finset Real Incidence +open scoped Classical BigOperators +noncomputable section + +lemma cut_mean_bounds (q : ℝ) (hq : 2≤q) (n : ℕ) : + 1/(2*q) ≤ (∑ i∈range (n+2),q^i)/(∑ i∈range (n+3),q^i) ∧ + (∑ i∈range (n+2),q^i)/(∑ i∈range (n+3),q^i) ≤ 1/q := by + let H := ∑ i∈range (n+2),q^i + let Q := ∑ i∈range (n+3),q^i + have hH : 1≤H := by + have hh := single_le_sum (s:=range (n+2)) (f:=fun i => q^i) + (fun i hi => pow_nonneg (by linarith) i) (by simp : 0∈range (n+2)) + simpa only [pow_zero] using hh + have he : Q=q*H+1 := geom_sum_succ + have hq0 : 0 + W⊆projected U z ∧ (W.card:ℝ)≤300000*q^(r+4)/T + let Eligible := fun (S : Finset (Projectivization K (V ⧸ z.submodule))) + (T' : Finset (Projectivization K (Module.Dual K (V ⧸ z.submodule)))) => + S⊆projected U z ∧ T'⊆quotientCut UT z ∧ + (incidenceCount S T':ℝ)≤400*τ*S.card*T'.card/q + let Capture := fun S W : Finset (Projectivization K (V ⧸ z.submodule)) => + (99/100:ℝ)*S.card≤(S∩W).card + have hex : ∀ a≤U.card,∀ c≤UT.card,Good a c → ∃ F : Finset (Finset (Projectivization K (V ⧸ z.submodule))), + (∀ W∈F,Size W) ∧ + (∀ S T',S.card=a → T'.card=c → Eligible S T' → ∃ W∈F,Capture S W) ∧ + log ((F.card:ℝ)+1)≤L := by + intro a ha c hc hg + obtain ⟨F,hFs,hFc,hFl⟩ := low a c hg + obtain ⟨hapos,hcpos,haZ,hcW,hNa,hTc,_hlo,_hhi,hcut⟩ := hg + have ha' : (0:ℝ) ring + · intro S T' hSa hT'c hh + obtain ⟨hS,hT',hsp⟩ := hh + have hsp' : (incidenceCount S T':ℝ)≤(400*τ)*(a:ℝ)*c/Nat.card K := by + simpa only [hSa,hT'c] using hsp + obtain ⟨W,hW,hcap⟩ := hFc S T' hS hSa hT' hT'c hsp' + exact ⟨W,hW,by simpa only [Capture,hSa] using hcap⟩ + · have hgaps := quotient_gap_bounds hq hn ht ha' hc' hNa hTc + (show (a:ℝ)≤(projected U z).card by exact_mod_cast haZ) + (show (c:ℝ)≤(quotientCut UT z).card by exact_mod_cast hcW) + (show ((projected U z).card:ℝ)≤U.card by exact_mod_cast projected_card_le U z) hcut + have hh : log (((projected U z).card:ℝ)/a)+ + log (((quotientCut UT z).card:ℝ)/c)+P≤2*(d+e+P) := by + dsimp only [d,e] at * + linarith only [hgaps.1,hgaps.2,hP,hd,he] + have hm := mul_le_mul_of_nonneg_left hh (show 0≤H*q*P by positivity) + apply hFl.trans + convert hm using 1; dsimp only [L,d,e,q]; ring + obtain ⟨F,hFs,hFc,hFl⟩ := size_header_library U.card UT.card Good Size Eligible Capture L hL hex + refine ⟨F,hFs,?_,hFl⟩ + intro S T' hS hT' hg hsp + apply hFc S T' + · exact (card_le_card hS).trans (projected_card_le U z) + · apply (card_le_card hT').trans + rw [quotientCut_card] + exact card_filter_le _ _ + · exact hg + · exact ⟨hS,hT',hsp⟩ + +end +end SharpLogRamsey.GeometricCover + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/QuotientHeaderGaps.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/QuotientHeaderGaps.lean new file mode 100644 index 0000000000000000000000000000000000000000..170c64ae8e63e9478175491e863dcdc902762dbb --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/QuotientHeaderGaps.lean @@ -0,0 +1,53 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Validation.ValidationGapCosts +import OAI.Combinatorics.SharpRamsey.Parameters.ProjectionScales + +namespace OAI + +section +namespace SharpLogRamsey.Projection +open Real + +lemma quotient_gap_bounds {q U UT Z W N A T B : ℝ} + (hq : 0 projectDual_injective z he)] + have hrow (t : {t : Projectivization K (Module.Dual K V) // SharpLogRamsey.Incidence.Incident z t}) : + ((projected S z).filter (fun p => SharpLogRamsey.Incidence.Incident p (projectDual z t))).card≤ + (S.filter (fun p => SharpLogRamsey.Incidence.Incident p t.val)).card := by + unfold projected + rw [filter_image] + simp only [project_incident_iff] + apply card_image_le.trans + apply card_le_card_of_injOn (fun p : {p : Projectivization K V // p≠z} => p.val) + · intro p hp + exact mem_filter.mpr ⟨mem_subtype.mp (mem_filter.mp hp).1,(mem_filter.mp hp).2⟩ + · intro p hp r hr he + exact Subtype.ext he + apply (sum_le_sum (fun t ht => hrow t)).trans_eq + have he : (T.subtype (SharpLogRamsey.Incidence.Incident z)).image Subtype.val=cut T z := by + ext t + simp [cut] + rw [←he,sum_image (fun a ha b hb h => Subtype.ext h)] + +end +end SharpLogRamsey.Projection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/RadialExceptions.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/RadialExceptions.lean new file mode 100644 index 0000000000000000000000000000000000000000..e6a1b1b614983c94bb0865bb617623363ba3741f --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/RadialExceptions.lean @@ -0,0 +1,140 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.PreparedRadialCount + +namespace OAI + +section +namespace SharpLogRamsey.RadialExceptions +open Finset +open scoped Classical BigOperators +noncomputable section +variable {α ι : Type*} [Fintype α] + +theorem count_exception (s : α→ℝ) (hs : ∀ x,0 ≤ s x) (K : ℝ) : + ((univ.filter (fun x => K < s x)).card:ℝ)*K ≤ ∑ x,s x := by + calc + _ = ∑ _x∈univ.filter (fun x => K < s x),K := by simp + _ ≤ ∑ x∈univ.filter (fun x => K < s x),s x := + sum_le_sum (fun _ hx => (mem_filter.mp hx).2.le) + _ ≤ ∑ x,s x := sum_le_sum_of_subset_of_nonneg (filter_subset _ _) + (fun x _ _ => hs x) + +theorem radial_exceptions (I : Finset ι) (a : ι→ℝ) (ha : ∀ i∈I,0 univ.filter (fun x => K<(r x i:ℝ)*a i^100) + refine ⟨I.biUnion E,?_,?_⟩ + · have hlocal (i : ι) (hi : i∈I) : ((E i).card:ℝ)*K≤C*a i^98 := by + by_cases he : q*a i^99≤K + · have hempty : E i=∅ := by + apply filter_eq_empty_iff.mpr + intro x _ hx + have hh := mul_le_mul_of_nonneg_right (hcrude x i hi) (pow_nonneg (ha i hi).le 99) + have hp : a i*a i^99=a i^100 := by ring + rw [mul_assoc,hp] at hh + exact (not_lt_of_ge (hh.trans he)) hx + rw [hempty,card_empty,Nat.cast_zero,zero_mul] + positivity + · have hh := count_exception (fun x => (r x i:ℝ)*a i^100) + (fun x => by positivity) K + change ((E i).card:ℝ)*K≤_ at hh + have hs : (∑ x,(r x i:ℝ)*a i^100)= + ((∑ x,(r x i:ℝ))*a i^2)*a i^98 := by rw [←sum_mul]; ring + rw [hs] at hh + exact hh.trans (mul_le_mul_of_nonneg_right + (hpair i hi (lt_of_not_ge he)) (pow_nonneg (ha i hi).le 98)) + calc + _ ≤ (∑ i∈I,((E i).card:ℝ))*K := by + apply mul_le_mul_of_nonneg_right _ hK + exact_mod_cast card_biUnion_le (s:=I) (t:=E) + _ = ∑ i∈I,((E i).card:ℝ)*K := by rw [sum_mul] + _ ≤ ∑ i∈I,C*a i^98 := sum_le_sum hlocal + _ = _ := by rw [mul_sum] + · intro x hx i hi + exact le_of_not_gt (fun he => hx (mem_biUnion.mpr ⟨i,hi,mem_filter.mpr ⟨mem_univ _,he⟩⟩)) + +theorem strong_exceptions (r : α→ℕ) (a C : ℝ) + (hpair : (∑ x,(r x:ℝ))*a^2≤C) : + ∃ D : Finset α,(D.card:ℝ)*a^2≤C ∧ ∀ x,x∉D → r x=0 := by + let D := univ.filter (fun x => 0 (W : Set V)) SetLike.coe_injective +local instance flat_JoinedRadialExceptions_4 : Fintype (Submodule K V) := Fintype.ofFinite _ + +theorem richRadials_mul_le (S : Finset (Projectivization K V)) (x : Projectivization K V) + (c a : ℝ) (hc : 0≤c) : ((richRadials S x c a).card:ℝ)*a≤c*S.card := by + calc + _ = ∑ _W∈richRadials S x c a,a := by simp + _ ≤ ∑ W∈richRadials S x c a,strength S x c W := + sum_le_sum (fun W hW => (mem_filter.mp hW).2) + _ ≤ ∑ W,strength S x c W := sum_le_sum_of_subset_of_nonneg + (filter_subset _ _) (fun W _ _ => mul_nonneg hc (Nat.cast_nonneg _)) + _ = c*(S.filter (fun y => y≠x)).card := by + simpa only [strength,le_top,Finset.filter_true,and_true] using + radial_mass S x ⊤ le_top c + _ ≤ _ := mul_le_mul_of_nonneg_left (Nat.cast_le.mpr (card_filter_le _ _)) hc + +theorem sum_richRadials_le_pairs + (X : Projectivization K V→Finset (Projectivization K V)) (c a : ℝ) (M : ℕ) + (hM : ∀ x (W : RadialLine x),a ≤ strength (X x) x c W → + M≤(X x∩planePoints W.1).card) : + (∑ x,(richRadials (X x) x c a).card)≤ + ((univ : Finset (Projectivization K V × ProjectiveLine (K:=K) (V:=V))).filter + (fun z => z.1∈planePoints z.2.1 ∧ M≤(X z.1∩planePoints z.2.1).card)).card := by + let F := (univ : Finset (Projectivization K V)).sigma + (fun x => richRadials (X x) x c a) + have he : F.card=∑ x,(richRadials (X x) x c a).card := by simp [F,card_sigma] + rw [←he] + let f : (Σ x : Projectivization K V,RadialLine x) → + Projectivization K V × ProjectiveLine (K:=K) (V:=V) := + fun z => (z.1,⟨z.2.1,z.2.2.1⟩) + apply card_le_card_of_injOn f + · intro z hz + apply mem_filter.mpr + refine ⟨mem_univ _,?_,?_⟩ + · exact mem_planePoints.mpr z.2.2.2 + · exact hM z.1 z.2 (mem_filter.mp (mem_sigma.mp hz).2).2 + · rintro ⟨x,W⟩ _ ⟨y,U⟩ _ hh + have hxy : x=y := congrArg Prod.fst hh + subst y + have hWU : W.1=U.1 := congrArg (fun z => z.2.1) hh + have hWU' : W=U := Subtype.ext hWU + cases hWU' + rfl + +end +end SharpLogRamsey.PreparedProjectiveGeometry + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/RadialPairCount.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/RadialPairCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..4785bdce7db9146e90aa640589b99744f07c9edb --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/RadialPairCount.lean @@ -0,0 +1,108 @@ +import Mathlib + +namespace OAI + +section +namespace SharpLogRamsey.RadialPairCount +open Finset +open scoped Classical BigOperators +noncomputable section +variable {α ι : Type*} + +theorem rich_lines (C : Finset α) (F : Finset ι) (L : ι → Finset α) (r : ℕ) + (hr : ∀ i ∈ F, r ≤ (C ∩ L i).card) + (hunique : ∀ i ∈ F, ∀ j ∈ F, i ≠ j → (L i ∩ L j).card ≤ 1) : + F.card * (r*(r-1)) ≤ C.card^2 := by + have hd : (↑F : Set ι).PairwiseDisjoint (fun i => (C ∩ L i).offDiag) := by + intro i hi j hj hij + apply disjoint_left.mpr + intro z hzi hzj + have hi' := mem_offDiag.mp hzi + have hj' := mem_offDiag.mp hzj + have htwo : 1 < (L i ∩ L j).card := one_lt_card.mpr + ⟨z.1, mem_inter.mpr ⟨(mem_inter.mp hi'.1).2,(mem_inter.mp hj'.1).2⟩, + z.2, mem_inter.mpr ⟨(mem_inter.mp hi'.2.1).2,(mem_inter.mp hj'.2.1).2⟩,hi'.2.2⟩ + exact (not_lt_of_ge (hunique i hi j hj hij)) htwo + calc + F.card*(r*(r-1)) = ∑ _i ∈ F, r*(r-1) := by simp + _ ≤ ∑ i ∈ F, (C ∩ L i).offDiag.card := by + apply sum_le_sum + intro i hi + rw [offDiag_card,← Nat.mul_sub_one] + exact Nat.mul_le_mul (hr i hi) (Nat.sub_le_sub_right (hr i hi) 1) + _ = (F.biUnion (fun i => (C ∩ L i).offDiag)).card := (card_biUnion hd).symm + _ ≤ (C ×ˢ C).card := card_le_card (by + intro z hz + obtain ⟨i,hi,hz⟩ := mem_biUnion.mp hz + have hz' := mem_offDiag.mp hz + exact mem_product.mpr ⟨(mem_inter.mp hz'.1).1,(mem_inter.mp hz'.2.1).1⟩) + _ = C.card^2 := by simp [pow_two] + +theorem weighted_square_sum (m : ℕ) (c : Fin m → ℕ) + (hc : Antitone c) : + (∑ i, (i.val+1)*(c i)^2) ≤ (∑ i, c i)^2 := by + have hterm (i : Fin m) : (i.val+1)*(c i)^2 ≤ + c i * ∑ j ∈ Finset.univ.filter (fun j : Fin m => j ≤ i), c j := by + have hcard : (Finset.univ.filter (fun j : Fin m => j ≤ i)).card = i.val+1 := by + have he : Finset.univ.filter (fun j : Fin m => j ≤ i) = Finset.Iic i := by ext j; simp + rw [he] + exact Fin.card_Iic i + calc + (i.val+1)*(c i)^2 = (c i)*((Finset.univ.filter (fun j : Fin m => j ≤ i)).card*c i) := by + rw [hcard]; ring + _ = c i*(∑ _j ∈ Finset.univ.filter (fun j : Fin m => j ≤ i), c i) := by simp + _ ≤ _ := by + apply Nat.mul_le_mul_left + apply sum_le_sum + intro j hj + exact hc (mem_filter.mp hj).2 + calc + _ ≤ ∑ i, c i * ∑ j ∈ Finset.univ.filter (fun j : Fin m => j ≤ i), c j := + sum_le_sum (fun i _ => hterm i) + _ ≤ ∑ i, c i * ∑ j, c j := by + apply sum_le_sum + intro i _ + exact Nat.mul_le_mul_left _ (sum_le_sum_of_subset (filter_subset _ _)) + _ = _ := by rw [← sum_mul]; ring + +theorem centered_rich_lines {m : ℕ} (C : Fin m → Finset α) + (F : Fin m → Finset ι) (L : ι → Finset α) (centers : Fin m → ι → Finset α) + (r : ℕ) (hr : ∀ i j, j ∈ F i → r ≤ (C i ∩ L j).card) + (hunique : ∀ i ∈ univ.biUnion F, ∀ j ∈ univ.biUnion F, + i ≠ j → (L i ∩ L j).card ≤ 1) + (hcenter : ∀ i j, j ∈ F i → (centers i j).card ≤ i.val) + (hmono : Antitone (fun i => (C i).card)) : + ((univ.biUnion (fun i => (F i).biUnion (fun j => centers i j ×ˢ {j}))).card)* + (r*(r-1)) ≤ (∑ i, (C i).card)^2 := by + have hcount (i : Fin m) : ((F i).biUnion (fun j => centers i j ×ˢ {j})).card ≤ + i.val*(F i).card := by + apply (card_biUnion_le).trans + calc + (∑ j ∈ F i, (centers i j ×ˢ {j}).card) ≤ ∑ _j ∈ F i, i.val := by + apply sum_le_sum + intro j hj + simpa using hcenter i j hj + _ = _ := by simp [mul_comm] + calc + _ ≤ (∑ i, ((F i).biUnion (fun j => centers i j ×ˢ {j})).card)*(r*(r-1)) := + Nat.mul_le_mul_right _ card_biUnion_le + _ ≤ (∑ i, i.val*(F i).card)*(r*(r-1)) := + Nat.mul_le_mul_right _ (sum_le_sum (fun i _ => hcount i)) + _ = ∑ i, i.val*((F i).card*(r*(r-1))) := by + rw [sum_mul]; apply sum_congr rfl; intros; ring + _ ≤ ∑ i, (i.val+1)*(C i).card^2 := by + apply sum_le_sum + intro i _ + apply Nat.mul_le_mul (by omega) + apply rich_lines (C i) (F i) L r (hr i) + intro a ha b hb hab + exact hunique a (mem_biUnion.mpr ⟨i,mem_univ _,ha⟩) + b (mem_biUnion.mpr ⟨i,mem_univ _,hb⟩) hab + _ ≤ _ := weighted_square_sum m (fun i => (C i).card) hmono + +end +end SharpLogRamsey.RadialPairCount + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/ReadyProjectiveValidation.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/ReadyProjectiveValidation.lean new file mode 100644 index 0000000000000000000000000000000000000000..594c422e0a34678aab5f303f031f6a60876d52c1 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/ReadyProjectiveValidation.lean @@ -0,0 +1,108 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.GeometricInduction + +namespace OAI + +section +namespace SharpLogRamsey.Validation +open Finset Real Incidence +open scoped Classical BigOperators +noncomputable section +variable {K V I : Type*} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +variable [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + +omit [FiniteDimensional K V] [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K V))] in + +lemma trimmed_sparse (S : Finset (Projectivization K V)) + (T T' : Finset (Projectivization K (Module.Dual K V))) (hT : T'⊆T) + (C : ℝ) (hC : 0 1) m≤exp (-q) ∧ + (∀ y,PublicTables.integral (rowLaw W (hX.mono hXW) h) accept + (fun z => if ¬pass SharpLogRamsey.Incidence.Incident q z y then 1 else 0) m≤ + 6*C*q*(∑ x∈univ.filter (fun x => SharpLogRamsey.Incidence.Incident x y),uniformMass S x)) := by + exact scheduled_validation hdim S X W hS hX hXS hXW T' U hT' hT'U C a hC hcap hratio + (trimmed_sparse S T T' hT'T C (by linarith) htrim hsparse) + +variable [Fintype I] + +theorem scheduled_ready_exclusion {n : ℕ} (hdim : Module.finrank K V=n+3) + (p : PublicTables.Law I) (Ready : I→Prop) + (S : Finset (Projectivization K V)) (hS : S.Nonempty) + (T : Finset (Projectivization K (Module.Dual K V))) + (X W : I→Finset (Projectivization K V)) + (T' U : I→Finset (Projectivization K (Module.Dual K V))) + (hX : ∀ i,(X i).Nonempty) (hXW : ∀ i,X i⊆W i) + (hXS : ∀ i,Ready i→X i⊆S) + (hT' : ∀ i,Ready i→(T' i).Nonempty) + (hT'T : ∀ i,Ready i→T' i⊆T) (hT'U : ∀ i,Ready i→T' i⊆U i) + (htrim : ∀ i,Ready i→(T.card:ℝ)≤2*(T' i).card) + (C : ℝ) (a : I→ℝ) (hC : 1≤C) + (hcap : ∀ i,Ready i→(S.card:ℝ)≤C*(X i).card) + (hratio : ∀ i,Ready i→((W i).card:ℝ)≤exp (a i)*(X i).card) + (hsparse : (incidenceCount S T:ℝ)≤(S.card:ℝ)*T.card/(20000*C*Nat.card K)) + (y : Projectivization K (Module.Dual K V)) : + let q : ℝ := Nat.card K + let h i := scheduleLength q (U i).card (T' i).card + let m i := scheduleCutoff q (a i) (h i) + let M := 1000*C*q^(n+3)/S.card + (∑ i, if Ready i then p.mass i * + PublicTables.integral (rowLaw (W i) ((hX i).mono (hXW i)) (h i)) + (implementAccept (X i) (GoodCap SharpLogRamsey.Incidence.Incident q (U i) (T' i) M)) + (fun z => if ¬pass SharpLogRamsey.Incidence.Incident q z y then 1 else 0) (m i) else 0) ≤ + 6*C*q*(∑ x∈univ.filter (fun x => SharpLogRamsey.Incidence.Incident x y),uniformMass S x) := by + dsimp only + let B := 6*C*(Nat.card K:ℝ)*(∑ x∈univ.filter (fun x => SharpLogRamsey.Incidence.Incident x y),uniformMass S x) + have hB : 0≤B := by + dsimp [B] + apply mul_nonneg (by positivity) + exact sum_nonneg (fun x _ => uniform_nonneg S x) + calc + _ ≤ ∑ i,p.mass i*B := by + apply sum_le_sum + intro i _ + by_cases hi : Ready i + · rw [ite_eq_left hi] + apply mul_le_mul_of_nonneg_left _ (p.nonneg i) + exact (scheduled_from_original hdim S (X i) (W i) hS (hX i) (hXS i hi) (hXW i) + T (T' i) (U i) (hT' i hi) (hT'T i hi) (hT'U i hi) (htrim i hi) + C (a i) hC (hcap i hi) (hratio i hi) hsparse).2.2 y + · rw [ite_eq_right hi] + exact mul_nonneg (p.nonneg i) hB + _ = _ := by rw [←sum_mul,p.total,one_mul] + +end +end SharpLogRamsey.Validation + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/ResidualSourceRadial.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/ResidualSourceRadial.lean new file mode 100644 index 0000000000000000000000000000000000000000..9202c9210c2af433f991a754b81583c67d7c68a1 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/ResidualSourceRadial.lean @@ -0,0 +1,113 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.SourceStrongRadial + +namespace OAI + +section +namespace SharpLogRamsey.PreparedRadialResidual +open Finset Filter Real PreparedProjectiveGeometry SourceRadialTests +open scoped Classical BigOperators Topology +noncomputable section + +theorem source_residual_radial (δ C : ℝ) (hδ : 0<δ) : + ∀ᶠ σ : ℝ in atTop,∀ (q : ℕ) [Fact q.Prime],3≤q → exp σ=(q:ℝ) → + ∀ (S : Finset (Projectivization (ZMod q) (Fin 4→ZMod q))),S.Nonempty → + ∀ (X : Projectivization (ZMod q) (Fin 4→ZMod q)→Finset (Projectivization (ZMod q) (Fin 4→ZMod q))), + (∀ x,X x⊆S) → ∀ (P g : ℝ) (Kp p : ℕ), + σ^δ≤P → P≤σ/40 → g≤σ/2+C → 0

f x.rep=0)).card≤Kp) → + let c := exp σ/(S.card:ℝ) + let K₀ := exp (σ+P/100-2*g) + ∃ D₀ D₁ : Finset (Projectivization (ZMod q) (Fin 4→ZMod q)), + (D₀.card:ℝ)≤S.card*exp (-P/200) ∧ + (D₁.card:ℝ)≤S.card*exp (5*P) ∧ + (∀ x,x∉D₀ → ∀ i∈range (Nat.log 2 S.card+2), + ((richRadials (X x) x c (DyadicGrid.value i)).card:ℝ)*(DyadicGrid.value i)^100≤K₀) ∧ + (∀ x,x∉D₁ → (richRadials (X x) x c (1/(100*(p:ℝ)))).card=0 ∨ + 2*(exp σ+1)/(1/(100*(p:ℝ)))≤(exp (3*σ)/S.card)*exp (-3*P)) := by + have hpbound := ScaleSelection.eventually_polynomial_le_exp_rpow 400000000 4 δ 1 hδ (by norm_num) + simp only [one_mul,rpow_ofNat] at hpbound + filter_upwards [eventually_activated_tests δ C hδ,eventually_radial_loss δ C hδ, + eventually_strong_tests δ C hδ,hpbound,eventually_ge_atTop (1:ℝ)] + with σ htests hloss hstrong hpoly hσ q _ hq heq S hS X hX P g Kp p hP hPu hgu hp hpu hNl hNu hK hcap + let c := exp σ/(S.card:ℝ) + let K₀ := exp (σ+P/100-2*g) + have hN : (0:ℝ) DyadicGrid.value_pos i) (fun i _ => (DyadicGrid.value_le_one i).trans (by norm_num)) + (by + intro i hi hh + rw [hcN] at hh + have ht := htests P g (DyadicGrid.value i) S.card Kp hP hgu + (DyadicGrid.value_pos i).le ((DyadicGrid.value_le_one i).trans (by norm_num)) hNl hNu hK hh + simpa only [hceil,heq] using ht) + have hradial : (D₀.card:ℝ)≤S.card*exp (-P/200) := by + apply hloss P g S.card D₀.card hP hNl hgu + have hs := DyadicGrid.sum_pow_le_two (Nat.log 2 S.card+2) 98 (by norm_num) + rw [←heq,hcN] at hD₀ + have hq1 : 1≤exp σ := one_le_exp_iff.mpr (by linarith) + have hd : (D₀.card:ℝ)*K₀≤69744*(exp σ)^2 := by + calc + _ ≤ 17436*(exp σ+1)*exp σ*2 := mul_le_mul_of_nonneg_left hs (by positivity) |>.trans' hD₀ + _ ≤ _ := by nlinarith [sq_nonneg (exp σ-1)] + have hsq : (exp σ)^2=exp (2*σ) := by rw [←exp_nat_mul]; norm_num + rw [hsq] at hd + exact hd.trans (mul_le_mul_of_nonneg_right (by norm_num) (exp_pos _).le) + have hp' : (0:ℝ)

Or.inl (hzero x hx)⟩ + +end +end SharpLogRamsey.PreparedRadialResidual + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/RichLines.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/RichLines.lean new file mode 100644 index 0000000000000000000000000000000000000000..d8e919b7f4b7b14522a18eba26f230be928ce16d --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/RichLines.lean @@ -0,0 +1,444 @@ +/- +Portions of this file have been adapted from an external source. +The source copyright header and license information are preserved below. +-/ + +import Mathlib + +namespace OAI + +/-! Incidence bounds for rich lines and finite point configurations. -/ + +section +section + +section + +namespace SharpLogRamsey.ImplicitBranch +open Polynomial +open scoped Ring + +/- +Copyright (c) 2021 Johan Commelin. All rights reserved. +Released under Apache 2.0 license as described in the file LICENSE. +Authors: Johan Commelin + +The following Hensel lifting theorem is adapted from Mathlib.RingTheory.Henselian. +Source: https://github.com/leanprover-community/mathlib4/blob/d13f23b723b8a846827a245b89c10fc7d3f11612/Mathlib/RingTheory/Henselian.lean + +This code has been modified. +-/ + + theorem hensel_nonmonic {R : Type*} [CommRing R] (I : Ideal R) + [IsAdicComplete I R] (f : Polynomial R) (a₀ : R) + (h₁ : f.eval a₀ ∈ I) + (h₂ : IsUnit (Ideal.Quotient.mk I (f.derivative.eval a₀))) : + ∃ a, f.IsRoot a ∧ a-a₀ ∈ I := by + classical + let f' := derivative f + + let c : ℕ → R := fun n => Nat.recOn n a₀ fun _ b => b - f.eval b * (f'.eval b)⁻¹ʳ + have hc : ∀ n, c (n + 1) = c n - f.eval (c n) * (f'.eval (c n))⁻¹ʳ := by + intro n + simp only [c] + + have hc_mod : ∀ n, c n ≡ a₀ [SMOD I] := by + intro n + induction n with + | zero => rfl + | succ n ih => ?_ + rw [hc, sub_eq_add_neg, ← add_zero a₀] + refine ih.add ?_ + rw [SModEq.zero, Ideal.neg_mem_iff] + refine I.mul_mem_right _ ?_ + rw [← SModEq.zero] at h₁ ⊢ + exact (ih.eval f).trans h₁ + have hf'c : ∀ n, IsUnit (f'.eval (c n)) := by + intro n + have := isLocalHom_of_le_jacobson_bot I (IsAdicComplete.le_jacobson_bot I) + apply IsUnit.of_map (Ideal.Quotient.mk I) + convert! h₂ using 1 + exact SModEq.def.mp ((hc_mod n).eval _) + have hfcI : ∀ n, f.eval (c n) ∈ I ^ (n + 1) := by + intro n + induction n with + | zero => simpa only [Nat.rec_zero, zero_add, pow_one] using! h₁ + | succ n ih => ?_ + rw [← taylor_eval_sub (c n), hc, sub_eq_add_neg, sub_eq_add_neg, + add_neg_cancel_comm] + rw [eval_eq_sum, sum_over_range' _ _ _ (lt_add_of_pos_right _ zero_lt_two), ← + Finset.sum_range_add_sum_Ico _ (Nat.le_add_left _ _)] + swap + · intro i + rw [zero_mul] + refine Ideal.add_mem _ ?_ ?_ + · rw [← one_add_one_eq_two, Finset.sum_range_succ, Finset.range_one, Finset.sum_singleton, + taylor_coeff_zero, taylor_coeff_one, pow_zero, pow_one, mul_one, mul_neg, + mul_left_comm, Ring.mul_inverse_cancel _ (hf'c n), mul_one, add_neg_cancel] + exact Ideal.zero_mem _ + · refine Submodule.sum_mem _ ?_ + simp only [Finset.mem_Ico] + rintro i ⟨h2i, _⟩ + have aux : n + 2 ≤ i * (n + 1) := by trans 2 * (n + 1) <;> nlinarith only [h2i] + refine Ideal.mul_mem_left _ _ (Ideal.pow_le_pow_right aux ?_) + rw [pow_mul'] + exact Ideal.pow_mem_pow ((Ideal.neg_mem_iff _).2 <| Ideal.mul_mem_right _ _ ih) _ + + have aux : ∀ m n, m ≤ n → c m ≡ c n [SMOD (I ^ m • ⊤ : Ideal R)] := by + intro m n hmn + rw [← Ideal.one_eq_top, Ideal.smul_eq_mul, mul_one] + obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le hmn + clear hmn + induction k with + | zero => rw [add_zero] + | succ k ih => ?_ + rw [← add_assoc, hc, ← add_zero (c m), sub_eq_add_neg] + refine ih.add ?_ + symm + rw [SModEq.zero, Ideal.neg_mem_iff] + refine Ideal.mul_mem_right _ _ (Ideal.pow_le_pow_right ?_ (hfcI _)) + rw [add_assoc] + exact le_self_add + + obtain ⟨a, ha⟩ := IsPrecomplete.prec' c (aux _ _) + refine ⟨a, ?_, ?_⟩ + · show f.IsRoot a + suffices ∀ n, f.eval a ≡ 0 [SMOD (I ^ n • ⊤ : Ideal R)] by exact IsHausdorff.haus' _ this + intro n + specialize ha n + rw [← Ideal.one_eq_top, Ideal.smul_eq_mul, mul_one] at ha ⊢ + refine (ha.symm.eval f).trans ?_ + rw [SModEq.zero] + exact Ideal.pow_le_pow_right le_self_add (hfcI _) + · show a - a₀ ∈ I + specialize ha (0 + 1) + rw [hc, pow_one, ← Ideal.one_eq_top, Ideal.smul_eq_mul, mul_one, sub_eq_add_neg] at ha + rw [← SModEq.sub_mem, ← add_zero a₀] + refine ha.symm.trans (SModEq.rfl.add ?_) + rw [SModEq.zero, Ideal.neg_mem_iff] + exact Ideal.mul_mem_right _ _ h₁ + +variable {σ K R S : Type*} [Fintype σ] [DecidableEq σ] [Field K] + [CommRing R] [CommRing S] [Algebra K R] [Algebra K S] + +lemma aeval_hom {τ : Type*} (φ : R →ₐ[K] S) (x : τ → R) (F : MvPolynomial τ K) : + φ (MvPolynomial.aeval x F) = MvPolynomial.aeval (fun i => φ (x i)) F := by + induction F using MvPolynomial.induction_on with + | C c => simp + | add f g hf hg => simp [hf,hg] + | mul_X f i hf => simp [hf] + +noncomputable def liftZ (F : MvPolynomial (Option σ) K) : + Polynomial (MvPowerSeries σ K) := + MvPolynomial.aeval (fun o => o.elim Polynomial.X + (fun i => Polynomial.C (MvPowerSeries.X i))) F +omit [Fintype σ] [DecidableEq σ] in + +lemma eval_liftZ (F : MvPolynomial (Option σ) K) (h : MvPowerSeries σ K) : + (liftZ F).eval h = MvPolynomial.aeval (fun o => o.elim h MvPowerSeries.X) F := by + induction F using MvPolynomial.induction_on with + | C c => simp [liftZ,Polynomial.algebraMap_apply] + | add f g hf hg => simp_all [liftZ] + | mul_X f i hf => cases i <;> simp_all [liftZ] +omit [Fintype σ] in + +lemma derivative_liftZ (F : MvPolynomial (Option σ) K) : + (liftZ F).derivative = liftZ (MvPolynomial.pderiv none F) := by + induction F using MvPolynomial.induction_on with + | C c => simp [liftZ,Polynomial.algebraMap_apply] + | add f g hf hg => simp_all [liftZ] + | mul_X f i hf => + cases i <;> simp_all [liftZ,Derivation.leibniz,smul_eq_mul, + MvPolynomial.pderiv_X] <;> ring +omit [Fintype σ] [DecidableEq σ] in + +lemma zeroCoeff_aeval (F : MvPolynomial (Option σ) K) : + MvPowerSeries.constantCoeff + (MvPolynomial.aeval (fun o => o.elim 0 MvPowerSeries.X) F) = + MvPolynomial.constantCoeff F := by + let φ : MvPowerSeries σ K →ₐ[K] K := + { MvPowerSeries.constantCoeff with + commutes' := by intro c; simp [← MvPowerSeries.c_eq_algebraMap] } + have H := aeval_hom φ (fun o => o.elim 0 MvPowerSeries.X) F + have hz : (fun o : Option σ => φ (o.elim 0 MvPowerSeries.X)) = 0 := by + funext o + cases o with + | none => exact map_zero φ + | some i => change MvPowerSeries.constantCoeff (MvPowerSeries.X i) = 0; simp + rw [hz,MvPolynomial.aeval_zero] at H + exact H + +theorem exists_formal_branch (F : MvPolynomial (Option σ) K) + (hF : MvPolynomial.constantCoeff F = 0) + (hD : MvPolynomial.constantCoeff (MvPolynomial.pderiv none F) ≠ 0) : + ∃ h : MvPowerSeries σ K, + MvPowerSeries.constantCoeff h = 0 ∧ + MvPolynomial.aeval (fun o => o.elim h MvPowerSeries.X) F = 0 := by + let I : Ideal (MvPowerSeries σ K) := Ideal.span (Set.range MvPowerSeries.X) + have hmem : (liftZ F).eval 0 ∈ I := by + rw [← Ideal.Quotient.eq_zero_iff_mem,eval_liftZ] + let φ : MvPowerSeries σ K →ₐ[K] MvPowerSeries σ K ⧸ I := Ideal.Quotient.mkₐ K I + change φ _ = 0 + rw [aeval_hom] + have hz : (fun o : Option σ => φ (o.elim 0 MvPowerSeries.X)) = 0 := by + funext o + cases o with + | none => exact map_zero φ + | some i => + exact Ideal.Quotient.eq_zero_iff_mem.mpr (Ideal.subset_span ⟨i,rfl⟩) + rw [hz,MvPolynomial.aeval_zero,hF,map_zero] + have hu : IsUnit ((liftZ F).derivative.eval 0) := by + rw [derivative_liftZ,eval_liftZ,MvPowerSeries.isUnit_iff_constantCoeff, + zeroCoeff_aeval,isUnit_iff_ne_zero] + exact hD + let : IsAdicComplete I (MvPowerSeries σ K) := + inferInstanceAs (IsAdicComplete (Ideal.span (Set.range MvPowerSeries.X)) + (MvPowerSeries σ K)) + obtain ⟨h,hr,hh⟩ := hensel_nonmonic I (liftZ F) 0 hmem (hu.map (Ideal.Quotient.mk I)) + refine ⟨h,?_,?_⟩ + · have hi : I ≤ RingHom.ker (MvPowerSeries.constantCoeff (σ := σ) (R := K)) := by + apply Ideal.span_le.mpr + rintro _ ⟨i,rfl⟩ + simp + apply hi + simpa using hh + · simpa [Polynomial.IsRoot,eval_liftZ] using hr + +end SharpLogRamsey.ImplicitBranch + +open Finset Finsupp +namespace SharpLogRamsey.FlatnessCore +variable {σ K : Type*} [Fintype σ] [DecidableEq σ] [Field K] +variable {p : ℕ} [CharP K p] + +lemma cast_ne_zero_of_lt {n : ℕ} (hn : 0 < n) (hp : n < p) : (n : K) ≠ 0 := by + rw [ne_eq, CharP.cast_eq_zero_iff K p] + exact fun h => (Nat.le_of_dvd hn h).not_gt hp +omit [Fintype σ] in + +lemma coeff_deriv_predecessor (f : MvPowerSeries σ K) (d : σ →₀ ℕ) (i : σ) + (hi : 0 < d i) : + MvPowerSeries.coeff (d-single i 1) (MvPowerSeries.pderiv i f) = + MvPowerSeries.coeff d f * (d i : K) := by + have h : single i 1 ≤ d := by + intro j + by_cases he : i = j + · subst j; simpa using (Nat.succ_le_iff.mpr hi) + · simp [single_eq_of_ne (Ne.symm he)] + rw [MvPowerSeries.coeff_pderiv,tsub_add_cancel_of_le h, + coe_tsub,Pi.sub_apply,single_eq_same,Nat.cast_sub (by omega),Nat.cast_one,sub_add_cancel] +omit [DecidableEq σ] in + +lemma degree_pos_coordinate {d : σ →₀ ℕ} (hd : 0 < degree d) : + ∃ i, 0 < d i := by + by_contra! h + have hz : d = 0 := by ext i; exact Nat.eq_zero_of_le_zero (h i) + simp [hz] at hd +omit [Fintype σ] in + +lemma coordinate_le_degree (d : σ →₀ ℕ) (i : σ) : d i ≤ degree d := by + classical + rw [degree_apply] + by_cases hi : i ∈ d.support + · exact single_le_sum (fun _ _ => Nat.zero_le _) hi + · simp at hi + simp [hi] + +theorem coeff_zero_of_hessian_zero (h : MvPowerSeries σ K) + (hh : ∀ i j, MvPowerSeries.pderiv i (MvPowerSeries.pderiv j h) = 0) + (d : σ →₀ ℕ) (hd : 2 ≤ degree d) (hdp : degree d < p) : + MvPowerSeries.coeff d h = 0 := by + obtain ⟨i,hi⟩ := degree_pos_coordinate (d := d) (by omega) + have hs : single i 1 ≤ d := by + intro j + by_cases he : i = j + · subst j; simpa using (Nat.succ_le_iff.mpr hi) + · simp [single_eq_of_ne (Ne.symm he)] + let e := d-single i 1 + have hed : e + single i 1 = d := tsub_add_cancel_of_le hs + have hedeg : degree e + 1 = degree d := by + have := congrArg degree hed + simpa using this + obtain ⟨j,hj⟩ := degree_pos_coordinate (d := e) (by omega) + have hc := coeff_deriv_predecessor (MvPowerSeries.pderiv i h) e j hj + rw [hh j i,MvPowerSeries.coeff_zero] at hc + have hej : (e j : K) ≠ 0 := cast_ne_zero_of_lt (p := p) hj + (lt_of_le_of_lt (coordinate_le_degree e j) (by omega)) + have he0 : MvPowerSeries.coeff e (MvPowerSeries.pderiv i h) = 0 := + (mul_eq_zero.mp hc.symm).resolve_right hej + have hc' := coeff_deriv_predecessor h d i hi + change MvPowerSeries.coeff e (MvPowerSeries.pderiv i h) = _ at hc' + rw [he0] at hc' + exact (mul_eq_zero.mp hc'.symm).resolve_right + (cast_ne_zero_of_lt (p := p) hi (lt_of_le_of_lt (coordinate_le_degree d i) hdp)) + +noncomputable def jetIdeal (n : ℕ) : Ideal (MvPowerSeries σ K) where + carrier := {f | (n : ℕ∞) ≤ f.order} + zero_mem' := by simp + add_mem' := fun ha hb => (le_min ha hb).trans MvPowerSeries.min_order_le_add + smul_mem' := by + intro a f hf + change (n : ℕ∞) ≤ (a*f).order + exact hf.trans ((le_add_left le_rfl).trans MvPowerSeries.le_order_mul) +omit [Fintype σ] [DecidableEq σ] in + +lemma mem_jetIdeal_iff (n : ℕ) (f : MvPowerSeries σ K) : + f ∈ jetIdeal n ↔ ∀ d, degree d < n → MvPowerSeries.coeff d f = 0 := by + constructor + · intro h d hd + exact MvPowerSeries.coeff_of_lt_order + ((show ((degree d : ℕ) : ℕ∞) < n by exact_mod_cast hd).trans_le h) + · exact MvPowerSeries.nat_le_order + +theorem hessian_zero_affine_jet (h : MvPowerSeries σ K) + (hh : ∀ i j, MvPowerSeries.pderiv i (MvPowerSeries.pderiv j h) = 0) : + h - (MvPowerSeries.truncTotal 2 h : MvPolynomial σ K).toMvPowerSeries ∈ jetIdeal p := by + rw [mem_jetIdeal_iff] + intro d hdp + rw [map_sub,MvPolynomial.coeff_coe] + by_cases hd : degree d < 2 + · rw [MvPowerSeries.coeff_truncTotal _ hd,sub_self] + · rw [MvPowerSeries.coeff_truncTotal_eq_zero _ (by omega),sub_zero] + exact coeff_zero_of_hessian_zero h hh d (by omega) hdp + +variable {τ R : Type*} [CommRing R] [Algebra K R] + +lemma aeval_sub_mem (I : Ideal R) (x y : τ → R) + (hxy : ∀ i, x i-y i ∈ I) (F : MvPolynomial τ K) : + MvPolynomial.aeval x F-MvPolynomial.aeval y F ∈ I := by + induction F using MvPolynomial.induction_on with + | C c => simp + | add f g hf hg => simpa only [map_add,add_sub_add_comm] using I.add_mem hf hg + | mul_X f i hf => + simpa only [map_mul,MvPolynomial.aeval_X, + show MvPolynomial.aeval x f*x i-MvPolynomial.aeval y f*y i = + x i*(MvPolynomial.aeval x f-MvPolynomial.aeval y f)+ + MvPolynomial.aeval y f*(x i-y i) from by ring] using + I.add_mem (I.mul_mem_left (x i) hf) (I.mul_mem_left _ (hxy i)) + +variable [Fintype τ] [DecidableEq τ] + +omit [Fintype σ] [DecidableEq σ] [Fintype τ] [DecidableEq τ] in + +lemma totalDegree_aeval_linear (x : τ → MvPolynomial σ K) + (hx : ∀ i, (x i).totalDegree ≤ 1) (F : MvPolynomial τ K) : + (MvPolynomial.aeval x F).totalDegree ≤ F.totalDegree := by + classical + conv_lhs => rw [F.as_sum] + rw [map_sum] + apply MvPolynomial.totalDegree_finsetSum_le + intro d hd + rw [MvPolynomial.aeval_monomial] + apply le_trans (MvPolynomial.totalDegree_mul _ _) + simp only [MvPolynomial.algebraMap_eq, MvPolynomial.totalDegree_C,zero_add] + calc + _ ≤ ∑ i ∈ d.support, (x i ^ d i).totalDegree := MvPolynomial.totalDegree_finsetProd _ _ + _ ≤ ∑ i ∈ d.support, d i := by + apply Finset.sum_le_sum + intro i hi + apply (MvPolynomial.totalDegree_pow _ _).trans + simpa [Nat.mul_comm] using Nat.mul_le_mul_right (d i) (hx i) + _ ≤ F.totalDegree := MvPolynomial.le_totalDegree hd +omit [Fintype σ] [DecidableEq σ] [Fintype τ] [DecidableEq τ] in + +lemma toSeries_aeval (x : τ → MvPolynomial σ K) (F : MvPolynomial τ K) : + (MvPolynomial.aeval x F).toMvPowerSeries = + MvPolynomial.aeval (fun i => (x i).toMvPowerSeries) F := by + induction F using MvPolynomial.induction_on with + | C c => simp [← MvPowerSeries.c_eq_algebraMap] + | add f g hf hg => simp only [map_add,MvPolynomial.coe_add,hf,hg] + | mul_X f i hf => simp only [map_mul,MvPolynomial.coe_mul,MvPolynomial.aeval_X,hf] + +omit [Fintype σ] in + +lemma polynomial_eq_zero_of_jet {F : MvPolynomial σ K} {n : ℕ} + (hF : F.totalDegree < n) (h : F.toMvPowerSeries ∈ jetIdeal n) : F = 0 := by + ext d + rw [AddMonoidAlgebra.coeff_zero] + by_cases hd : d ∈ F.support + · have hle := MvPolynomial.le_totalDegree hd + have hc := (mem_jetIdeal_iff n F.toMvPowerSeries).mp h d (lt_of_le_of_lt hle hF) + simpa using hc + · exact MvPolynomial.notMem_support_iff.mp hd + +theorem flat_branch_zero_plane (F : MvPolynomial (Option σ) K) + (hF : F.totalDegree < p) (h : MvPowerSeries σ K) + (hroot : MvPolynomial.aeval (fun o => o.elim h MvPowerSeries.X) F = 0) + (hh : ∀ i j, MvPowerSeries.pderiv i (MvPowerSeries.pderiv j h) = 0) : + MvPolynomial.aeval (fun o => o.elim (MvPowerSeries.truncTotal 2 h) MvPolynomial.X) F = 0 := by + let lin := MvPowerSeries.truncTotal 2 h + let x : Option σ → MvPolynomial σ K := fun o => o.elim lin MvPolynomial.X + have hx : ∀ i, (x i).totalDegree ≤ 1 := by + intro i + cases i with + | none => + have H := MvPowerSeries.totalDegree_truncTotal_lt h (by norm_num : (2:ℕ) ≠ 0) + change lin.totalDegree ≤ 1 + dsimp [lin] + omega + | some i => exact (MvPolynomial.totalDegree_X (R := K) i).le + apply polynomial_eq_zero_of_jet (n := p) + · exact (totalDegree_aeval_linear x hx F).trans_lt hF + · have H := aeval_sub_mem (jetIdeal p) + (fun o => o.elim h MvPowerSeries.X) (fun i => (x i).toMvPowerSeries) (fun i => ?_) F + · rw [hroot,zero_sub] at H + rw [toSeries_aeval] + exact neg_mem_iff.mp H + cases i with + | none => exact hessian_zero_affine_jet h hh + | some i => simp [x] + +lemma deriv_aeval (D : Derivation K R R) (x : τ → R) (F : MvPolynomial τ K) : + D (MvPolynomial.aeval x F) = + ∑ i, MvPolynomial.aeval x (MvPolynomial.pderiv i F) * D (x i) := by + induction F using MvPolynomial.induction_on with + | C c => simp + | add f g hf hg => simp [hf,hg,add_mul,Finset.sum_add_distrib] + | mul_X f j hf => + simp only [map_mul,MvPolynomial.aeval_X,Derivation.leibniz,smul_eq_mul, + map_add,MvPolynomial.pderiv_X] + simp only [ + add_mul,Finset.sum_add_distrib] + rw [hf,Finset.mul_sum] + congr 1 + · simp [Pi.single_apply] + · apply Finset.sum_congr rfl + intro i hi + ring + +lemma deriv2_aeval (D E : Derivation K R R) (x : τ → R) (F : MvPolynomial τ K) : + D (E (MvPolynomial.aeval x F)) = + (∑ j, ∑ i, MvPolynomial.aeval x (MvPolynomial.pderiv i + (MvPolynomial.pderiv j F)) * D (x i) * E (x j)) + + ∑ j, MvPolynomial.aeval x (MvPolynomial.pderiv j F) * D (E (x j)) := by + rw [deriv_aeval E,map_sum] + simp only [Derivation.leibniz,smul_eq_mul,Finset.sum_add_distrib] + rw [add_comm] + congr 1 + apply Finset.sum_congr rfl + intro j hj + rw [deriv_aeval D,Finset.mul_sum] + apply Finset.sum_congr rfl + intro i hi + ring + +noncomputable def branchPoint (h : MvPowerSeries σ K) : Option σ → MvPowerSeries σ K := + fun o => o.elim h MvPowerSeries.X + +noncomputable def branchTangent (h : MvPowerSeries σ K) (a : σ) : + Option σ → MvPowerSeries σ K := fun o => MvPowerSeries.pderiv a (branchPoint h o) + +lemma branch_second_sum (h : MvPowerSeries σ K) (g : Option σ → MvPowerSeries σ K) + (a b : σ) : + (∑ j, g j * MvPowerSeries.pderiv a + (MvPowerSeries.pderiv b (branchPoint h j))) = + g none * MvPowerSeries.pderiv a (MvPowerSeries.pderiv b h) := by + rw [Fintype.sum_option] + simp [branchPoint,MvPowerSeries.pderiv_X,Pi.single_apply,apply_ite] + +end SharpLogRamsey.FlatnessCore +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/ScaledTangentDot.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/ScaledTangentDot.lean new file mode 100644 index 0000000000000000000000000000000000000000..6d2e2170a80b4eceaf64daa83ecc8f5acc1cfa02 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/ScaledTangentDot.lean @@ -0,0 +1,517 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.TotalDegreeCombination + +namespace OAI + +/-! Incidence bounds for rich lines and finite point configurations. -/ + +section +section +section +open Finset Finsupp +open scoped BigOperators +open MvPolynomial Finsupp +open scoped BigOperators +open MvPolynomial +open scoped BigOperators +open Finset MvPolynomial UniqueFactorizationMonoid +open scoped BigOperators +open Finset MvPolynomial +namespace SharpLogRamsey.RichLinePolynomial +open MvPolynomial Finset +open FlatnessCore NonplaneCertificate +variable {K : Type*} [Field K] +lemma scaled_tangent_dot (g : Option (Fin 2) → K) (a : Fin 2) : + ∑ i, g i*FlatnessCore.scaledTangent g a i = 0 := by + simp [FlatnessCore.scaledTangent,Fintype.sum_option,mul_comm] + +lemma eval_flatness (F : MvPolynomial (Option (Fin 2)) K) (x : Option (Fin 2) → K) + (a b : Fin 2) : eval x (FlatnessCore.flatnessPolynomial F a b) = + LineFlatness.hessian x F + (FlatnessCore.scaledTangent (fun i => eval x (pderiv i F)) a) + (FlatnessCore.scaledTangent (fun i => eval x (pderiv i F)) b) := by + unfold FlatnessCore.flatnessPolynomial LineFlatness.hessian + simp only [map_sum,map_mul] + congr 1; ext j + congr 1; ext i + have he (a : Fin 2) (i : Option (Fin 2)) : + eval x (FlatnessCore.scaledTangent (fun i => pderiv i F) a i) = + FlatnessCore.scaledTangent (fun i => eval x (pderiv i F)) a i := by + cases i with + | none => simp [FlatnessCore.scaledTangent] + | some i => by_cases hi : i = a <;> simp [FlatnessCore.scaledTangent,hi] + rw [he,he] + +theorem family_zero_at_three_lines (F : MvPolynomial (Fin 3) K) + (x : Fin 3 → K) (v : Fin 3 → Fin 3 → K) + (h2 : (2 : K) ≠ 0) (hl : ∀ i, LineFlatness.restrictLine x (v i) F = 0) + (h01 : LinearIndependent K ![v 0,v 1]) + (h02 : LinearIndependent K ![v 0,v 2]) + (h12 : LinearIndependent K ![v 1,v 2]) (idx : Index) : + eval x (flatFamily F idx) = 0 := by + let e := idx.1 + let G := renameEquiv K e.symm F + let y := x ∘ e + let g := fun i => eval y (pderiv i G) + have hc (z : Fin 3 → K) : (z ∘ e) ∘ e.symm = z := by ext i; simp + have hge (i : Option (Fin 2)) : g i = eval x (pderiv (e i) F) := by + have H := pderiv_rename e.symm.injective (e i) F + simpa only [g,G,y,renameEquiv_apply,e.symm_apply_apply,eval_rename,hc] using congrArg (eval y) H + change eval x (renameEquiv K e (flatnessPolynomial G idx.2.1 idx.2.2)) = 0 + rw [renameEquiv_apply,eval_rename,eval_flatness] + change LineFlatness.hessian y G (FlatnessCore.scaledTangent g idx.2.1) + (FlatnessCore.scaledTangent g idx.2.2) = 0 + by_cases hn : ∃ i, eval x (pderiv i F) ≠ 0 + · let u := FlatnessCore.scaledTangent g idx.2.1 + let w := FlatnessCore.scaledTangent g idx.2.2 + have hu : ∑ i, eval x (pderiv i F)*(u ∘ e.symm) i = 0 := by + rw [← e.sum_comp] + simpa only [Function.comp_apply,e.symm_apply_apply,← hge] using + scaled_tangent_dot g idx.2.1 + have hw : ∑ i, eval x (pderiv i F)*(w ∘ e.symm) i = 0 := by + rw [← e.sum_comp] + simpa only [Function.comp_apply,e.symm_apply_apply,← hge] using + scaled_tangent_dot g idx.2.2 + have H := LineFlatness.three_lines_tangent_zero F x v h2 hn hl h01 h02 h12 + (u ∘ e.symm) (w ∘ e.symm) hu hw + simpa only [G,y,LineFlatness.hessian_rename,hc] using H + · have hg : g = 0 := by + ext i + exact not_ne_iff.mp (fun h => hn ⟨e i,hge i ▸ h⟩) + simp [hg,FlatnessCore.scaledTangent,LineFlatness.hessian] + +variable {σ : Type*} [Fintype σ] [DecidableEq σ] +omit [Fintype σ] [DecidableEq σ] in +lemma natDegree_aeval_linear (x : σ → Polynomial K) + (hx : ∀ i, (x i).natDegree ≤ 1) (F : MvPolynomial σ K) : + (aeval x F).natDegree ≤ F.totalDegree := by + conv_lhs => rw [F.as_sum] + rw [map_sum] + apply Polynomial.natDegree_sum_le_of_forall_le + intro d hd + rw [aeval_monomial] + apply (Polynomial.natDegree_mul_le).trans + simp only [Polynomial.algebraMap_apply,Polynomial.natDegree_C,zero_add] + calc + _ ≤ ∑ i ∈ d.support, (x i ^ d i).natDegree := Polynomial.natDegree_prod_le _ _ + _ ≤ ∑ i ∈ d.support, d i := by + apply Finset.sum_le_sum + intro i hi + rw [Polynomial.natDegree_pow] + simpa [Nat.mul_comm] using Nat.mul_le_mul_right (d i) (hx i) + _ ≤ F.totalDegree := le_totalDegree hd +omit [Fintype σ] [DecidableEq σ] in + +lemma restriction_degree (x v : σ → K) (F : MvPolynomial σ K) : + (LineFlatness.restrictLine x v F).natDegree ≤ F.totalDegree := by + apply natDegree_aeval_linear + intro i + exact (Polynomial.natDegree_add_le _ _).trans (max_le (by simp) + ((Polynomial.natDegree_mul_le).trans (by simp))) +omit [Fintype σ] [DecidableEq σ] in + +lemma restriction_eval (x v : σ → K) (F : MvPolynomial σ K) (t : K) : + (LineFlatness.restrictLine x v F).eval t = eval (fun i => x i+v i*t) F := by + induction F using MvPolynomial.induction_on with + | C c => simp [LineFlatness.restrictLine] + | add f g hf hg => simp_all [LineFlatness.restrictLine] + | mul_X f i hf => simp_all [LineFlatness.restrictLine] +omit [Fintype σ] [DecidableEq σ] in + +lemma restriction_zero_of_many (x v : σ → K) (F : MvPolynomial σ K) + (S : Finset K) (hcard : F.totalDegree < S.card) + (hzero : ∀ t ∈ S, eval (fun i => x i+v i*t) F = 0) : + LineFlatness.restrictLine x v F = 0 := by + by_contra hn + have H : S.card ≤ (LineFlatness.restrictLine x v F).natDegree := by + apply Polynomial.card_le_degree_of_subset_roots + intro t ht + exact (Polynomial.mem_roots hn).mpr ((restriction_eval x v F t).trans (hzero t ht)) + exact (not_lt_of_ge (H.trans (restriction_degree x v F))) hcard + +theorem auxiliary_polynomial {p : ℕ} [CharP K p] [IsAlgClosed K] + (F : MvPolynomial (Fin 3) K) (hF : F ≠ 0) (hdeg : F.totalDegree < p) + (hs : Squarefree F) (h2 : (2 : K) ≠ 0) + (hn : ∀ L : MvPolynomial (Fin 3) K, L ∣ F → L.totalDegree ≤ 1 → IsUnit L) : + ∃ Q : MvPolynomial (Fin 3) K, IsRelPrime F Q ∧ Q.totalDegree ≤ 3*F.totalDegree ∧ + ∀ (x v : Fin 3 → K) (S : Finset K), 3*F.totalDegree < S.card → + (∀ t ∈ S, ∃ w : Fin 3 → Fin 3 → K, + (∀ i, LineFlatness.restrictLine (fun j => x j+v j*t) (w i) F = 0) ∧ + LinearIndependent K ![w 0,w 1] ∧ LinearIndependent K ![w 0,w 2] ∧ + LinearIndependent K ![w 1,w 2]) → LineFlatness.restrictLine x v Q = 0 := by + obtain ⟨c,hc,hd⟩ := exists_coprime_flat_combination F hF hdeg hs hn + refine ⟨∑ i, c i • flatFamily F i,hc,hd,?_⟩ + intro x v S hS hpoints + apply restriction_zero_of_many x v _ S (hd.trans_lt hS) + intro t ht + obtain ⟨w,hw,h01,h02,h12⟩ := hpoints t ht + simp only [map_sum,Algebra.smul_def,MvPolynomial.algebraMap_eq,map_mul,eval_C] + apply sum_eq_zero + intro i hi + rw [family_zero_at_three_lines F _ w h2 hw h01 h02 h12 i,mul_zero] + +end SharpLogRamsey.RichLinePolynomial + +end + +section + +section + +open scoped BigOperators nonZeroDivisors +open Polynomial Finset +namespace SharpLogRamsey.ParametricBezout + +section Fraction +variable {R K : Type*} [CommRing R] [IsDomain R] [NormalizedGCDMonoid R] + [Field K] [Algebra R K] [IsFractionRing R K] + +lemma isCoprime_map_fraction {f g : R[X]} (h : IsRelPrime f g) : + IsCoprime (f.map (algebraMap R K)) (g.map (algebraMap R K)) := by + apply isRelPrime_iff_isCoprime.mp + intro a haf hag + have ha : a ≠ 0 := by + intro hz + rw [hz,zero_dvd_iff] at haf hag + have hf : f = 0 := (Polynomial.map_injective _ (IsFractionRing.injective R K)) + (by simpa using haf) + have hg : g = 0 := (Polynomial.map_injective _ (IsFractionRing.injective R K)) + (by simpa using hag) + rcases h.ne_zero_or_ne_zero with H|H <;> contradiction + let b : R[X] := IsLocalization.integerNormalization R⁰ a + have hb : b.primPart.IsPrimitive := Polynomial.isPrimitive_primPart b + have hab : b.primPart.map (algebraMap R K) ∣ a := by + have H := Polynomial.map_dvd (algebraMap R K) (Polynomial.primPart_dvd b) + obtain ⟨c,hc,hbmap⟩ := IsLocalization.integerNormalization_spec R⁰ a + change b.map (algebraMap R K) = _ at hbmap + rw [hbmap,Algebra.smul_def,Polynomial.algebraMap_apply] at H + have hc0 : algebraMap R K c ≠ 0 := by + intro he + apply nonZeroDivisors.ne_zero hc + apply IsFractionRing.injective R K + simpa using he + exact (IsUnit.dvd_mul_left (Polynomial.isUnit_C.mpr + (isUnit_iff_ne_zero.mpr hc0))).mp H + have hbf := hb.dvd_of_fraction_map_dvd_fraction_map (hab.trans haf) + have hbg := hb.dvd_of_fraction_map_dvd_fraction_map (hab.trans hag) + exact Polynomial.isUnit_or_eq_zero_of_isUnit_integerNormalization_primPart ha (h hbf hbg) + +include K in +lemma resultant_ne_zero_of_isRelPrime {f g : R[X]} (h : IsRelPrime f g) : + f.resultant g ≠ 0 := by + have hc := isCoprime_map_fraction (K := K) h + have H := Polynomial.resultant_ne_zero _ _ hc + have hf := Polynomial.natDegree_map_eq_of_injective (IsFractionRing.injective R K) f + have hg := Polynomial.natDegree_map_eq_of_injective (IsFractionRing.injective R K) g + rw [hf,hg,Polynomial.resultant_map_map] at H + exact fun he => H (by rw [he,map_zero]) +end Fraction + +variable {K : Type*} [CommRing K] [IsDomain K] [NormalizedGCDMonoid K] +omit [IsDomain K] [NormalizedGCDMonoid K] in + +lemma natDegree_det_le {ι : Type*} [Fintype ι] [DecidableEq ι] + (M : Matrix ι ι K[X]) (d : ι → ℕ) + (h : ∀ i j, (M i j).natDegree ≤ d j) : + M.det.natDegree ≤ ∑ j,d j := by + rw [Matrix.det_apply] + apply Polynomial.natDegree_sum_le_of_forall_le + intro e he + apply (Polynomial.natDegree_smul_le _ _).trans + apply (Polynomial.natDegree_prod_le _ _).trans + apply sum_le_sum + intro i hi + exact h (e i) i + +omit [IsDomain K] [NormalizedGCDMonoid K] in + +lemma resultant_degree_bound (f g : (K[X])[X]) (Df Dg : ℕ) + (hf : ∀ i, (f.coeff i).natDegree ≤ Df) + (hg : ∀ i, (g.coeff i).natDegree ≤ Dg) : + (f.resultant g).natDegree ≤ f.natDegree*Dg+g.natDegree*Df := by + calc + _ ≤ ∑ j : Fin (f.natDegree+g.natDegree), + j.addCases (fun _ => Dg) (fun _ => Df) := by + apply natDegree_det_le + intro i j + refine Fin.addCases ?_ ?_ j + · intro j + simp only [Polynomial.sylvester,Matrix.of_apply,Fin.addCases_left] + split_ifs <;> simp_all + · intro j + simp only [Polynomial.sylvester,Matrix.of_apply,Fin.addCases_right] + split_ifs <;> simp_all + _ = _ := by rw [Fin.sum_univ_add]; simp + +omit [IsDomain K] [NormalizedGCDMonoid K] in + +lemma resultant_eval_zero (f g : (K[X])[X]) (x y : K) + (hf : (f.map (Polynomial.evalRingHom x)).eval y = 0) + (hg : (g.map (Polynomial.evalRingHom x)).eval y = 0) + (hdeg : f.natDegree ≠ 0 ∨ g.natDegree ≠ 0) : + (f.resultant g).eval x = 0 := by + obtain ⟨a,b,ha,hb,H⟩ := Polynomial.exists_mul_add_mul_eq_C_resultant f g le_rfl le_rfl hdeg + have h := congrArg (fun p : (K[X])[X] => (p.map (Polynomial.evalRingHom x)).eval y) H + simpa [hf,hg] using h.symm + +lemma common_points_card_le (f g : (K[X])[X]) (Df Dg : ℕ) + (hc : IsRelPrime f g) + (hf : ∀ i, (f.coeff i).natDegree ≤ Df) + (hg : ∀ i, (g.coeff i).natDegree ≤ Dg) + (hdeg : f.natDegree ≠ 0 ∨ g.natDegree ≠ 0) + (S : Finset (K × K)) (hinj : Set.InjOn Prod.fst (S : Set (K × K))) + (hS : ∀ z ∈ S, (f.map (Polynomial.evalRingHom z.1)).eval z.2 = 0 ∧ + (g.map (Polynomial.evalRingHom z.1)).eval z.2 = 0) : + S.card ≤ f.natDegree*Dg+g.natDegree*Df := by + classical + have hne : f.resultant g ≠ 0 := + resultant_ne_zero_of_isRelPrime (K := FractionRing K[X]) hc + calc + S.card = (S.image Prod.fst).card := (Finset.card_image_of_injOn hinj).symm + _ ≤ (f.resultant g).natDegree := by + apply Polynomial.card_le_degree_of_subset_roots + intro x hx + obtain ⟨z,hz,rfl⟩ := Finset.mem_image.mp hx + exact (Polynomial.mem_roots hne).mpr (resultant_eval_zero f g z.1 z.2 + (hS z hz).1 (hS z hz).2 hdeg) + _ ≤ _ := resultant_degree_bound f g Df Dg hf hg +omit [NormalizedGCDMonoid K] in + +lemma no_common_point_of_degree_zero (f g : (K[X])[X]) (hc : IsRelPrime f g) + (hf : f.natDegree = 0) (hg : g.natDegree = 0) (x y : K) + (hfx : (f.map (Polynomial.evalRingHom x)).eval y = 0) + (hgx : (g.map (Polynomial.evalRingHom x)).eval y = 0) : False := by + have hef := Polynomial.eq_C_of_natDegree_eq_zero hf + have heg := Polynomial.eq_C_of_natDegree_eq_zero hg + have hfr : (f.coeff 0).IsRoot x := by + rw [hef] at hfx + simpa only [Polynomial.map_C, Polynomial.eval_C, Polynomial.coe_evalRingHom, Polynomial.IsRoot] using hfx + have hgr : (g.coeff 0).IsRoot x := by + rw [heg] at hgx + simpa only [Polynomial.map_C, Polynomial.eval_C, Polynomial.coe_evalRingHom, Polynomial.IsRoot] using hgx + have hfd := map_dvd (Polynomial.C : K[X] →+* (K[X])[X]) + (Polynomial.dvd_iff_isRoot.mpr hfr) + have hgd := map_dvd (Polynomial.C : K[X] →+* (K[X])[X]) + (Polynomial.dvd_iff_isRoot.mpr hgr) + have hu : IsUnit (Polynomial.C (Polynomial.X-Polynomial.C x) : (K[X])[X]) := by + apply hc + · rwa [← hef] at hfd + · rwa [← heg] at hgd + exact Polynomial.not_isUnit_X_sub_C x (Polynomial.isUnit_C.mp hu) + +theorem graph_branches_card_le (f g : (K[X])[X]) (Df Dg : ℕ) + (hc : IsRelPrime f g) + (hf : ∀ i, (f.coeff i).natDegree ≤ Df) + (hg : ∀ i, (g.coeff i).natDegree ≤ Dg) + (hfo : f.natDegree ≤ Df) (hgo : g.natDegree ≤ Dg) + (S : Finset (K × K)) (hinj : Set.InjOn Prod.fst (S : Set (K × K))) + (hS : ∀ z ∈ S, (f.map (Polynomial.evalRingHom z.1)).eval z.2 = 0 ∧ + (g.map (Polynomial.evalRingHom z.1)).eval z.2 = 0) : + S.card ≤ 2*Df*Dg := by + by_cases hdeg : f.natDegree ≠ 0 ∨ g.natDegree ≠ 0 + · apply (common_points_card_le f g Df Dg hc hf hg hdeg S hinj hS).trans + nlinarith + · push Not at hdeg + have he : S = ∅ := by + apply Finset.eq_empty_iff_forall_notMem.mpr + intro z hz + exact no_common_point_of_degree_zero f g hc hdeg.1 hdeg.2 z.1 z.2 + (hS z hz).1 (hS z hz).2 + simp [he] + +end SharpLogRamsey.ParametricBezout + +end + +section + +namespace SharpLogRamsey.GenericCoordinates +open MvPolynomial Finset +open scoped BigOperators +variable {K : Type*} [Field K] [Infinite K] +noncomputable section + +lemma exists_eval_ne_zero {σ : Type*} (F : MvPolynomial σ K) (hF : F ≠ 0) : + ∃ x : σ → K, eval x F ≠ 0 := by + by_contra! h + apply hF + exact MvPolynomial.funext (by simpa using h) + +lemma exists_first (T : Finset (Fin 3 → K)) (hT : ∀ v ∈ T, v ≠ 0) : + ∃ a b : K, ∀ v ∈ T, v 0+a*v 1+b*v 2 ≠ 0 := by + classical + let f (v : Fin 3 → K) : MvPolynomial (Fin 2) K := + C (v 0)+C (v 1)*X 0+C (v 2)*X 1 + have hf : ∀ v ∈ T, f v ≠ 0 := by + intro v hv H + have h0 := congrArg (eval (fun _ => (0:K))) H + have h1 := congrArg (eval ![1,0]) H + have h2 := congrArg (eval ![0,1]) H + simp [f] at h0 h1 h2 + apply hT v hv + ext i + fin_cases i <;> simp_all + obtain ⟨x,hx⟩ := exists_eval_ne_zero (∏ v ∈ T, f v) (Finset.prod_ne_zero_iff.mpr hf) + refine ⟨x 0,x 1,?_⟩ + intro v hv H + apply hx + rw [map_prod] + apply Finset.prod_eq_zero hv + simp [f,H,mul_comm] + +lemma exists_second (a b : K) (T : Finset (Fin 3 → K)) + (hT : ∀ v ∈ T, v ≠ 0) + (hk : ∀ v ∈ T, v 0+a*v 1+b*v 2 = 0) : + ∃ c : K, ∀ v ∈ T, v 1+c*v 2 ≠ 0 := by + classical + let f (v : Fin 3 → K) : MvPolynomial Unit K := C (v 1)+C (v 2)*X () + have hf : ∀ v ∈ T, f v ≠ 0 := by + intro v hv H + have h1 := congrArg (eval (fun _ => (0:K))) H + have h2 := congrArg (eval (fun _ => (1:K))) H + simp [f] at h1 h2 + have h0 := hk v hv + apply hT v hv + ext i + fin_cases i <;> simp_all + obtain ⟨x,hx⟩ := exists_eval_ne_zero (∏ v ∈ T, f v) (Finset.prod_ne_zero_iff.mpr hf) + refine ⟨x (),?_⟩ + intro v hv H + apply hx + rw [map_prod] + apply Finset.prod_eq_zero hv + simp [f,H,mul_comm] + +def shear (a b c : K) : (Fin 3 → K) ≃ₗ[K] (Fin 3 → K) where + toFun x := ![x 0+a*x 1+b*x 2, x 1+c*x 2, x 2] + invFun x := ![x 0-a*x 1+(a*c-b)*x 2, x 1-c*x 2, x 2] + left_inv x := by ext i; fin_cases i <;> simp ; ring + right_inv x := by ext i; fin_cases i <;> simp ; ring + map_add' x y := by ext i; fin_cases i <;> simp <;> ring + map_smul' r x := by ext i; fin_cases i <;> simp <;> ring + +abbrev first (a b : K) : (Fin 3 → K) →ₗ[K] K := + LinearMap.proj 0+a • LinearMap.proj 1+b • LinearMap.proj 2 +omit [Infinite K] in + +lemma first_apply (a b : K) (x : Fin 3 → K) : first a b x = x 0+a*x 1+b*x 2 := by simp [first] + +def line (x v : Fin 3 → K) : Set (Fin 3 → K) := Set.range (fun r : K => x+r • v) +def direction (t : (Fin 3 → K) →ₗ[K] K) (v : Fin 3 → K) : Fin 3 → K := (t v)⁻¹ • v +def base (t : (Fin 3 → K) →ₗ[K] K) (x v : Fin 3 → K) : Fin 3 → K := + x-t x • direction t v +omit [Infinite K] in + +lemma map_direction (t : (Fin 3 → K) →ₗ[K] K) (v : Fin 3 → K) (hv : t v ≠ 0) : + t (direction t v) = 1 := by simp [direction,hv] +omit [Infinite K] in +lemma map_base (t : (Fin 3 → K) →ₗ[K] K) (x v : Fin 3 → K) (hv : t v ≠ 0) : + t (base t x v) = 0 := by simp [base,map_direction t v hv] +omit [Infinite K] in + +lemma line_normalize (t : (Fin 3 → K) →ₗ[K] K) (x v : Fin 3 → K) (hv : t v ≠ 0) : + line (base t x v) (direction t v) = line x v := by + ext y + constructor + · rintro ⟨r,rfl⟩ + refine ⟨(r-t x)*(t v)⁻¹,?_⟩ + ext i + simp [base,direction] + ring + · rintro ⟨r,rfl⟩ + refine ⟨t x+r*t v,?_⟩ + ext i + simp [base,direction] + field_simp + ; ring + +theorem exists_separating_coordinates {ι : Type*} [Fintype ι] + (x v : ι → Fin 3 → K) (hv : ∀ i, v i ≠ 0) + (hd : Function.Injective (fun i => line (x i) (v i))) : + ∃ a b c : K, (∀ i, first a b (v i) ≠ 0) ∧ + Function.Injective (fun i => + Polynomial.C ((shear a b c (base (first a b) (x i) (v i))) 1)+ + Polynomial.C ((shear a b c (direction (first a b) (v i))) 1)*Polynomial.X) := by + classical + obtain ⟨a,b,hab⟩ := exists_first (Finset.univ.image v) (by + intro w hw + obtain ⟨i,hi,rfl⟩ := Finset.mem_image.mp hw + exact hv i) + have ht : ∀ i, first a b (v i) ≠ 0 := by + intro i + exact hab (v i) (Finset.mem_image.mpr ⟨i,Finset.mem_univ _,rfl⟩) + let u := fun i => direction (first a b) (v i) + let z := fun i => base (first a b) (x i) (v i) + have hdistinct : ∀ i j, i ≠ j → z i ≠ z j ∨ u i ≠ u j := by + intro i j hij + by_contra! H + apply hij + apply hd + change line (x i) (v i) = line (x j) (v j) + rw [← line_normalize (first a b) (x i) (v i) (ht i), + ← line_normalize (first a b) (x j) (v j) (ht j)] + exact congrArg₂ line H.1 H.2 + let I := {ij : ι × ι // ij.1 ≠ ij.2} + let w : I → Fin 3 → K := fun ij => + if z ij.val.1 ≠ z ij.val.2 then z ij.val.1-z ij.val.2 else u ij.val.1-u ij.val.2 + have hw : ∀ i, w i ≠ 0 := by + intro i + change (if z i.val.1 ≠ z i.val.2 then z i.val.1-z i.val.2 else u i.val.1-u i.val.2) ≠ 0 + by_cases H : z i.val.1 ≠ z i.val.2 + · rw [ite_eq_left H]; exact sub_ne_zero.mpr H + · rw [ite_eq_right H]; exact sub_ne_zero.mpr ((hdistinct _ _ i.property).resolve_left H) + have hk : ∀ i, first a b (w i) = 0 := by + intro i + change first a b (if z i.val.1 ≠ z i.val.2 then z i.val.1-z i.val.2 else u i.val.1-u i.val.2) = 0 + by_cases H : z i.val.1 ≠ z i.val.2 + · rw [ite_eq_left H,map_sub,map_base _ _ _ (ht _),map_base _ _ _ (ht _),sub_self] + · rw [ite_eq_right H,map_sub,map_direction _ _ (ht _),map_direction _ _ (ht _),sub_self] + obtain ⟨c,hc⟩ := exists_second a b (Finset.univ.image w) (by + intro q hq + obtain ⟨i,hi,rfl⟩ := Finset.mem_image.mp hq + exact hw i) (by + intro q hq + obtain ⟨i,hi,rfl⟩ := Finset.mem_image.mp hq + exact hk i) + refine ⟨a,b,c,ht,?_⟩ + intro i j H + by_contra hij + have h0 := congrArg (fun p : Polynomial K => p.coeff 0) H + have h1 := congrArg (fun p : Polynomial K => p.coeff 1) H + simp only [Polynomial.coeff_add,Polynomial.coeff_C,Polynomial.coeff_C_mul, + Polynomial.coeff_X_zero,mul_zero,add_zero,Polynomial.coeff_X_one,mul_one, + zero_add,ite_true,ite_false,Nat.one_ne_zero] at h0 h1 + have Hc := hc (w ⟨(i,j),hij⟩) (Finset.mem_image.mpr ⟨⟨(i,j),hij⟩,Finset.mem_univ _,rfl⟩) + apply Hc + change (if z i ≠ z j then z i-z j else u i-u j) 1+ + c*(if z i ≠ z j then z i-z j else u i-u j) 2 = 0 + by_cases Hz : z i ≠ z j + · rw [ite_eq_left Hz] + change z i 1+c*z i 2 = z j 1+c*z j 2 at h0 + simp only [Pi.sub_apply] + linear_combination h0 + · rw [ite_eq_right Hz] + change u i 1+c*u i 2 = u j 1+c*u j 2 at h1 + simp only [Pi.sub_apply] + linear_combination h1 + +end +end SharpLogRamsey.GenericCoordinates + +end + +section + +namespace SharpLogRamsey.PolynomialCoordinates +open MvPolynomial +variable {K : Type*} [Field K] +noncomputable section + +end +end SharpLogRamsey.PolynomialCoordinates +end +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/SourceRadialActivation.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/SourceRadialActivation.lean new file mode 100644 index 0000000000000000000000000000000000000000..27063e83e60719263971472e13f631bc2b8b8f5d --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/SourceRadialActivation.lean @@ -0,0 +1,77 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Spatial.PreparedSpatialRadial + +namespace OAI + +section +namespace SharpLogRamsey.SourceRadialTests +open Filter Real +open scoped Topology +noncomputable section + +theorem radial_activation {σ P g a : ℝ} + (hP : 10000*(2:ℝ)^99 ≤ P) (ha : 0≤a) (ha2 : a≤2) + (hk : exp (σ+P/100-2*g) exp (σ^δ/200)) atTop atTop := + tendsto_exp_atTop.comp ((tendsto_rpow_atTop hδ).atTop_div_const (by norm_num : (0:ℝ)<200)) + filter_upwards [ht.eventually_ge_atTop (140000*exp C)] with σ hσ P g N D hP hN hgu hD + apply radial_exception_scale (by norm_num) hN hgu hD + have hh : 140000*exp C≤exp (P/200) := hσ.trans + (exp_le_exp.mpr (div_le_div_of_nonneg_right hP (by norm_num))) + simpa only [show (2:ℝ)*70000=140000 by norm_num] using hh + +theorem radial_pair_scale {σ P g N : ℝ} (hσ : 0≤σ) + (hN : 0 σ^δ/10000) atTop atTop := by + simpa only [div_eq_mul_inv,mul_comm] using + (tendsto_rpow_atTop hδ).const_mul_atTop (by norm_num : (0:ℝ) < 10000⁻¹) + have hp := ScaleSelection.eventually_polynomial_le_exp_rpow 3 4 1 1 (by norm_num) (by norm_num) + filter_upwards [hgt.eventually_ge_atTop 100000,hp, + eventually_ge_atTop (2:ℝ),eventually_ge_atTop (2000*exp (C/20)), + eventually_ge_atTop (2*C+2)] with σ hg hp hσ hc hd g a N Kp hgl hgu hal hau hNl hNu hK + dsimp only + let M := ⌈a*(N:ℝ)/exp σ⌉₊ + have hg0 : 0 ≤ g := by linarith + have hg' : 100000 ≤ g := hg.trans hgl + have hb := threshold_bounds hσ hg0 hal hau hNl + dsimp only at hb + change exp (σ/2+19*g/20)/2 ≤ (M:ℝ) ∧ _ at hb + have hM4 : 4 ≤ M := by + have he := add_one_le_exp (σ/2+19*g/20) + have hh : (4:ℝ) ≤ M := by linarith [hb.1] + exact_mod_cast hh + have hMN : M ≤ N := by + apply Nat.ceil_le.mpr + apply (div_le_iff₀ (exp_pos _)).mpr + have hq : a ≤ exp σ := hau.trans (by linarith [add_one_le_exp σ]) + have hh := mul_le_mul_of_nonneg_right hq (Nat.cast_nonneg N : (0:ℝ) ≤ N) + simpa only [mul_comm] using hh + have hh := rich_tests hg' hb.1 hb.2.2.2 (Nat.cast_nonneg N) hK + have hchar := characteristic_test hc hgu hb.2.2.2 + have hp' : 3*σ^4 ≤ exp σ := by simpa only [Real.rpow_ofNat,Real.rpow_one,one_mul] using hp + have hfail := failure_test hσ hgu (Nat.cast_nonneg N) hNu hb.2.2.1 hp' + (show 4*σ+2*C-5*σ^2 ≤ -2 by nlinarith [sq_nonneg (σ-1)]) + refine ⟨hM4,hMN,hh.1,hchar,hfail,?_⟩ + exact_mod_cast hh.2 + +theorem list_threshold {σ g a : ℝ} {N J : ℕ} + (hσ : 2 ≤ σ) (hg : 100000 ≤ g) + (ha : exp (-g/20) ≤ a) (ha2 : a ≤ 2) + (hN : exp (3*σ/2+g)/2 ≤ (N:ℝ)) + (hJ : (J:ℝ) ≤ exp (σ/2-2*g/15)) : + 2*J ≤ ⌈a*(N:ℝ)/exp σ⌉₊ := by + have hm := (threshold_bounds hσ (by linarith) ha ha2 hN).1 + have he : exp (σ/2+19*g/20)=exp (σ/2-2*g/15)*exp (13*g/12) := by + rw [←exp_add]; congr 1; ring + have hc : 4 ≤ exp (13*g/12) := by linarith [add_one_le_exp (13*g/12)] + have hh := mul_le_mul_of_nonneg_left hc (exp_pos (σ/2-2*g/15)).le + rw [he] at hm + have hh' : 2*(J:ℝ) ≤ (⌈a*(N:ℝ)/exp σ⌉₊:ℝ) := by nlinarith only [hJ,hh,hm] + exact_mod_cast hh' + +end +end SharpLogRamsey.SourceRadialTests + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/SourceStrongRadial.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/SourceStrongRadial.lean new file mode 100644 index 0000000000000000000000000000000000000000..e51570a05b8afa8ae1d113394f45c0e28233e209 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/SourceStrongRadial.lean @@ -0,0 +1,101 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.SourceRadialScalar + +namespace OAI + +section +namespace SharpLogRamsey.SourceRadialTests +open Filter Real +open scoped Topology +noncomputable section + +theorem eventually_strong_tests (δ C : ℝ) (hδ : 0<δ) : + ∀ᶠ σ : ℝ in atTop,∀ (P g : ℝ) (N Kp p : ℕ), + σ^δ≤P → P≤σ/40 → σ/2-4*P≤g → g≤σ/2+C → + 0

AffineIncidence.carrier (coord a (P i)) + (coord a (Q i)-coord a (P i))) := by + intro i j hij + dsimp only at hij + apply hd + have hm (R : Projectivization K (Fin 4 → K)) (haR : Avoids a R) + (hr : R.submodule ≤ W i) : R.submodule ≤ W j := by + have ht := (coord_mem_line a (W i) (hW i) (P i) (Q i) R + (hPQ i) (hP i) (hQ i) (haP i) (haQ i) haR).mp hr + have hh : coord a R ∈ AffineIncidence.carrier (coord a (P i)) + (coord a (Q i)-coord a (P i)) := by + obtain ⟨t,ht⟩ := ht + exact ⟨t,ht.symm⟩ + rw [hij] at hh + apply (coord_mem_line a (W j) (hW j) (P j) (Q j) R + (hPQ j) (hP j) (hQ j) (haP j) (haQ j) haR).mpr + obtain ⟨t,ht⟩ := hh + exact ⟨t,ht.symm⟩ + rw [← span_pair_of_line (W i) (hW i) (P i) (Q i) (hPQ i) (hP i) (hQ i)] + exact span_pair_of_line (W j) (hW j) (P i) (Q i) (hPQ i) + (hm _ (haP i) (hP i)) (hm _ (haQ i) (hQ i)) + +end +end SharpLogRamsey.ProjectiveLineChart +end + +section + +namespace SharpLogRamsey.RichProjectiveLines +open scoped BigOperators +open Finset Classical +open SharpLogRamsey.ProjectiveBaseChange SharpLogRamsey.ProjectiveAffineChart + SharpLogRamsey.RationalAffineChart SharpLogRamsey.ProjectiveLineChart +noncomputable section +variable {K E ι : Type*} [Field K] [Field E] [Algebra K E] + [Infinite E] [IsAlgClosed E] [Fintype ι] + +theorem card_lines_square + (S : Finset (Projectivization K (Fin 4 → K))) + (W : ι → Submodule K (Fin 4 → K)) + (hW : ∀ i, Module.finrank K (W i) = 2) (hd : Function.Injective W) + (hM : ∀ i, 2 ≤ (S.filter (fun P => P.submodule ≤ W i)).card) : + Fintype.card ι ≤ S.card^2 := by + classical + have htwo (i : ι) : ∃ P Q : Projectivization K (Fin 4 → K), + P ∈ S ∧ Q ∈ S ∧ P.submodule ≤ W i ∧ Q.submodule ≤ W i ∧ P ≠ Q := by + obtain ⟨P,hP,Q,hQ,hPQ⟩ := Finset.one_lt_card.mp (show + 1 < (S.filter (fun P => P.submodule ≤ W i)).card by have := hM i; omega) + exact ⟨P,Q,(mem_filter.mp hP).1,(mem_filter.mp hQ).1, + (mem_filter.mp hP).2,(mem_filter.mp hQ).2,hPQ⟩ + choose P Q hPS hQS hP hQ hPQ using htwo + let f (i : ι) : S × S := (⟨P i,hPS i⟩,⟨Q i,hQS i⟩) + have hf : Function.Injective f := by + intro i j hij + have hp : P i = P j := congrArg (fun x : S × S => x.1.val) hij + have hq : Q i = Q j := congrArg (fun x : S × S => x.2.val) hij + apply hd + rw [← span_pair_of_line (W i) (hW i) (P i) (Q i) (hPQ i) (hP i) (hQ i), + ← span_pair_of_line (W j) (hW j) (P j) (Q j) (hPQ j) (hP j) (hQ j),hp,hq] + simpa only [Fintype.card_prod, Fintype.card_coe, pow_two] using + Fintype.card_le_of_injective f hf + +theorem card_mul_le {q : ℕ} [CharP E q] (h2 : (2:E) ≠ 0) + (S : Finset (Projectivization K (Fin 4 → K))) (hS : S.Nonempty) + (W : ι → Submodule K (Fin 4 → K)) + (hW : ∀ i, Module.finrank K (W i) = 2) (hd : Function.Injective W) + (M Kp h C : ℕ) (hM2 : 2 ≤ M) (p : ℝ) (hp : 0 < p) (hp1 : p ≤ 1) + (hM : ∀ i, M ≤ (S.filter (fun P => P.submodule ≤ W i)).card) + (hcap : ∀ f : (Fin 4 → K) →ₗ[K] K, f ≠ 0 → + (S.filter (fun P => f P.rep = 0)).card ≤ Kp) + (hprob : (Fintype.card ι:ℝ)*Real.exp (-p*M/12) < 1/2) + (hsize : 2*p*S.card < ((h+1)^3:ℕ)) (hdeg : (3*h:ℕ) ≤ p*M/2) + (hchar : 3*h < q) (hMD : 18*h < M) (hKM : 8*Kp ≤ M^2) + (hD : h^2*M ≤ C*S.card) : + Fintype.card ι*M ≤ (6+72*C)*S.card := by + classical + obtain ⟨a,ha⟩ := RationalAffineChart.exists_avoiding (E := E) S + have htwo (i : ι) : ∃ P Q : Projectivization K (Fin 4 → K), + P ∈ S ∧ Q ∈ S ∧ P.submodule ≤ W i ∧ Q.submodule ≤ W i ∧ P ≠ Q := by + have hc : 1 < (S.filter (fun P => P.submodule ≤ W i)).card := by + have := hM i + omega + obtain ⟨P,hP,Q,hQ,hPQ⟩ := Finset.one_lt_card.mp hc + exact ⟨P,Q,(mem_filter.mp hP).1,(mem_filter.mp hQ).1, + (mem_filter.mp hP).2,(mem_filter.mp hQ).2,hPQ⟩ + choose P Q hPS hQS hP hQ hPQ using htwo + let x (i : ι) := coord a (P i) + let v (i : ι) := coord a (Q i)-coord a (P i) + let T := S.image (coord (K := K) a) + have hTc : T.card = S.card := card_image_of_injOn (fun P hP Q hQ hh => + coord_injOn a (ha P hP) (ha Q hQ) hh) + have hA (i : ι) : AffineIncidence.onLine x v T i = + (S.filter (fun P => P.submodule ≤ W i)).image (coord (K := K) a) := by + ext z + simp only [AffineIncidence.onLine,T,mem_filter,mem_image] + constructor + · rintro ⟨⟨R,hRS,rfl⟩,t,ht⟩ + refine ⟨R,⟨hRS,?_⟩,rfl⟩ + apply (coord_mem_line a (W i) (hW i) (P i) (Q i) R + (hPQ i) (hP i) (hQ i) (ha _ (hPS i)) (ha _ (hQS i)) (ha R hRS)).mpr + exact ⟨t,ht.symm⟩ + · rintro ⟨R,⟨hRS,hRW⟩,rfl⟩ + refine ⟨⟨R,hRS,rfl⟩,?_⟩ + obtain ⟨t,ht⟩ := (coord_mem_line a (W i) (hW i) (P i) (Q i) R + (hPQ i) (hP i) (hQ i) (ha _ (hPS i)) (ha _ (hQS i)) (ha R hRS)).mp hRW + exact ⟨t,ht.symm⟩ + have hAc (i : ι) : (AffineIncidence.onLine x v T i).card = + (S.filter (fun P => P.submodule ≤ W i)).card := by + rw [hA] + apply card_image_of_injOn + intro P hP Q hQ hh + exact coord_injOn a (ha P (mem_filter.mp hP).1) (ha Q (mem_filter.mp hQ).1) hh + have H := RichAffineLines.card_mul_le h2 T (hS.image _) x v + (fun i => line_coord_ne a (P i) (Q i) (ha _ (hPS i)) (ha _ (hQS i)) (hPQ i)) + (carriers_injective a W hW hd P Q hPQ hP hQ (fun i => ha _ (hPS i)) (fun i => ha _ (hQS i))) + M Kp h C p hp hp1 (fun i => by rw [hAc]; exact hM i) + (plane_cap_transfer S a ha Kp hcap) hprob + (by rw [hTc]; exact hsize) hdeg hchar hMD hKM (by rw [hTc]; exact hD) + simpa only [hTc] using H + +end +end SharpLogRamsey.RichProjectiveLines +end + +section + +namespace SharpLogRamsey.RichLineScales +open scoped BigOperators +noncomputable section + +theorem choose_parameters (N M q : ℕ) (hM : 0 < M) (hMN : M ≤ N) + (hsmall : 198*Real.sqrt ((N:ℝ)/M) < M) + (hchar : 33*Real.sqrt ((N:ℝ)/M) < q) + (hprob : (N:ℝ)^2*Real.exp (-5*Real.sqrt ((N:ℝ)/M)) < 1/2) : + ∃ h : ℕ, ∃ p : ℝ, 0 < p ∧ p ≤ 1 ∧ + (N:ℝ)^2*Real.exp (-p*M/12) < 1/2 ∧ + 2*p*N < ((h+1)^3:ℕ) ∧ (3*h:ℕ) ≤ p*M/2 ∧ + 3*h < q ∧ 18*h < M ∧ h^2*M ≤ 121*N := by + have hm : (0:ℝ) < M := by exact_mod_cast hM + have hmn : (M:ℝ) ≤ N := by exact_mod_cast hMN + let r := Real.sqrt ((N:ℝ)/M) + have hr0 : 0 ≤ r := Real.sqrt_nonneg _ + have hr1 : 1 ≤ r := by + have := Real.sqrt_le_sqrt ((le_div_iff₀ hm).mpr (by linarith : 1*(M:ℝ) ≤ N)) + simpa only [Real.sqrt_one] using this + have hr : r^2*(M:ℝ) = N := by + rw [Real.sq_sqrt (by positivity), div_mul_cancel₀ _ hm.ne'] + let h : ℕ := ⌈10*r⌉₊ + have hhlo : 10*r ≤ (h:ℝ) := Nat.le_ceil _ + have hhhi : (h:ℝ) ≤ 11*r := by + have H := Nat.ceil_lt_add_one (by positivity : (0:ℝ) ≤ 10*r) + change (h:ℝ) < 10*r+1 at H + linarith + have hhpos : (0:ℝ) < h := by linarith + have hhm : 18*(h:ℝ) < M := by + change 198*r < M at hsmall + linarith + have hhq : 3*(h:ℝ) < q := by + change 33*r < q at hchar + linarith + let p : ℝ := 6*h/M + have hp : 0 < p := div_pos (by positivity) hm + have hpm : p*M = 6*h := by dsimp [p]; rw [div_mul_cancel₀ _ hm.ne'] + have hp1 : p ≤ 1 := (div_le_iff₀ hm).mpr (by linarith) + have hhsq : (h:ℝ)^2 ≤ 121*r^2 := by + have := mul_le_mul hhhi hhhi (by positivity) (by positivity) + nlinarith + have hdsq : (h:ℝ)^2*(M:ℝ) ≤ 121*N := by + have := mul_le_mul_of_nonneg_right hhsq hm.le + nlinarith [hr] + have hhbig : 12*r^2 < (h:ℝ)^2 := by + have := mul_self_le_mul_self (by positivity : (0:ℝ) ≤ 10*r) hhlo + nlinarith [sq_nonneg (r-1)] + refine ⟨h,p,hp,hp1,?_,?_,?_,?_,?_,?_⟩ + · apply lt_of_le_of_lt _ hprob + apply mul_le_mul_of_nonneg_left _ (sq_nonneg _) + apply Real.exp_le_exp.mpr + rw [neg_mul, hpm] + change -(6*(h:ℝ))/12 ≤ -5*r + linarith + · have hhN : 12*(N:ℝ) < (h:ℝ)^2*M := by + have := mul_lt_mul_of_pos_right hhbig hm + nlinarith [hr] + have hsize' : 2*p*N < (h:ℝ)^3 := by + have h1 : 2*p*N*M < (h:ℝ)^3*M := by + calc + _ = 12*(h:ℝ)*N := by nlinarith [congrArg (fun x : ℝ => 2*(N:ℝ)*x) hpm] + _ < (h:ℝ)*((h:ℝ)^2*M) := by nlinarith [mul_lt_mul_of_pos_left hhN hhpos] + _ = _ := by ring + exact (mul_lt_mul_iff_left₀ hm).mp (by simpa only [mul_comm _ (M:ℝ)] using h1) + have hnext : (h:ℝ)^3 < ((h:ℝ)+1)^3 := by nlinarith [sq_nonneg (h:ℝ)] + exact_mod_cast hsize'.trans hnext + · simp only [Nat.cast_mul, Nat.cast_ofNat] + rw [hpm] + linarith + · exact_mod_cast hhq + · exact_mod_cast hhm + · exact_mod_cast hdsq + +end +end SharpLogRamsey.RichLineScales +end + +section + +namespace SharpLogRamsey.RichProjectiveCount +open scoped BigOperators +open Finset Classical +noncomputable section +variable {K E ι : Type*} [Field K] [Field E] [Algebra K E] + [Infinite E] [IsAlgClosed E] [Fintype ι] + +theorem card_mul_le {q : ℕ} [CharP E q] (h2 : (2:E) ≠ 0) + (S : Finset (Projectivization K (Fin 4 → K))) (hS : S.Nonempty) + (W : ι → Submodule K (Fin 4 → K)) + (hW : ∀ i, Module.finrank K (W i) = 2) (hd : Function.Injective W) + (M Kp : ℕ) (hM2 : 2 ≤ M) (hMN : M ≤ S.card) + (hM : ∀ i, M ≤ (S.filter (fun P => P.submodule ≤ W i)).card) + (hcap : ∀ f : (Fin 4 → K) →ₗ[K] K, f ≠ 0 → + (S.filter (fun P => f P.rep = 0)).card ≤ Kp) + (hsmall : 198*Real.sqrt ((S.card:ℝ)/M) < M) + (hchar : 33*Real.sqrt ((S.card:ℝ)/M) < q) + (hprob : (S.card:ℝ)^2*Real.exp (-5*Real.sqrt ((S.card:ℝ)/M)) < 1/2) + (hKM : 8*Kp ≤ M^2) : Fintype.card ι*M ≤ 8718*S.card := by + obtain ⟨h,p,hp,hp1,hprob',hsize,hdeg,hchar',hMD,hD⟩ := + RichLineScales.choose_parameters S.card M q (by omega) hMN hsmall hchar hprob + have hc := RichProjectiveLines.card_lines_square S W hW hd (fun i => hM2.trans (hM i)) + have hprob'' : (Fintype.card ι:ℝ)*Real.exp (-p*M/12) < 1/2 := by + apply lt_of_le_of_lt _ hprob' + apply mul_le_mul_of_nonneg_right _ (Real.exp_pos _).le + exact_mod_cast hc + exact RichProjectiveLines.card_mul_le (E := E) h2 S hS W hW hd M Kp h 121 hM2 + p hp hp1 hM hcap hprob'' hsize hdeg hchar' hMD hKM hD + +end +end SharpLogRamsey.RichProjectiveCount +end + +section + +namespace SharpLogRamsey.RichFiniteProjective +open scoped BigOperators +open Finset Classical +noncomputable section +variable {q : ℕ} [Fact q.Prime] {ι : Type*} [Fintype ι] + +theorem card_mul_le (hq : 3 ≤ q) + (S : Finset (Projectivization (ZMod q) (Fin 4 → ZMod q))) (hS : S.Nonempty) + (W : ι → Submodule (ZMod q) (Fin 4 → ZMod q)) + (hW : ∀ i, Module.finrank (ZMod q) (W i) = 2) (hd : Function.Injective W) + (M Kp : ℕ) (hM2 : 2 ≤ M) (hMN : M ≤ S.card) + (hM : ∀ i, M ≤ (S.filter (fun P => P.submodule ≤ W i)).card) + (hcap : ∀ f : (Fin 4 → ZMod q) →ₗ[ZMod q] ZMod q, f ≠ 0 → + (S.filter (fun P => f P.rep = 0)).card ≤ Kp) + (hsmall : 198*Real.sqrt ((S.card:ℝ)/M) < M) + (hchar : 33*Real.sqrt ((S.card:ℝ)/M) < q) + (hprob : (S.card:ℝ)^2*Real.exp (-5*Real.sqrt ((S.card:ℝ)/M)) < 1/2) + (hKM : 8*Kp ≤ M^2) : Fintype.card ι*M ≤ 8718*S.card := by + apply RichProjectiveCount.card_mul_le (E := AlgebraicClosure (ZMod q)) + (q := q) _ S hS W hW hd M Kp hM2 hMN hM (by + intro functional nonzero + convert! (preTransparency := .all) hcap functional nonzero) hsmall hchar hprob hKM + intro hh + have hdiv : q ∣ 2 := (CharP.cast_eq_zero_iff (AlgebraicClosure (ZMod q)) q 2).mp + (by simpa only [Nat.cast_ofNat] using hh) + have := Nat.le_of_dvd (by decide : 0 < 2) hdiv + omega + +end +end SharpLogRamsey.RichFiniteProjective +end + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/SparsePencilBounds.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/SparsePencilBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..574e09ca92e4e7935beb2f8cd9edbf70eb9005f2 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/SparsePencilBounds.lean @@ -0,0 +1,83 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Selection.SparseProductSharp + +namespace OAI + +section +namespace SharpLogRamsey.Incidence +open Finset +open scoped BigOperators + +lemma geom_sum_le_twice_pow (q : ℝ) (hq : 2≤q) (n : ℕ) : + (∑ i∈range (n+1),q^i)≤2*q^n := by + induction n with + | zero => simp + | succ n ih => + rw [sum_range_succ] + have hh : 2*q^n≤q^(n+1) := by + rw [pow_succ] + simpa [mul_comm] using mul_le_mul_of_nonneg_left hq (show 0≤q^n by positivity) + linarith + +lemma scalar_pencil_card (q s : ℝ) (hq : 2≤q) (hs : 0.trans hh + simpa only [Nat.cast_sum,Nat.cast_pow] using + scalar_pencil_card (Nat.card K) S'.card hq hs (n+2) (by omega) hsq +end +end SharpLogRamsey.Incidence + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/TestProjectiveTail.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/TestProjectiveTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..c1d1eff4c44f9ea6379b9d082e970954c3e869b8 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/TestProjectiveTail.lean @@ -0,0 +1,41 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Learning.TestPointTail + +namespace OAI + +section +namespace SharpLogRamsey.PreparedProjectiveGeometry +open Finset MeasureTheory SharpRamseyFive.PoissonScore SharpLogRamsey.PointScore +open scoped Classical BigOperators NNReal +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + +theorem projective_point_tail + (S O : Finset (Projectivization K V)) (x : Projectivization K V) (c L : ℝ≥0) + (A : Finset (Projectivization K (Module.Dual K V))) + (hA : ∀ H∈A,x.submodule ≤ LinearMap.ker H.rep) + (R : ℕ) (b : ℝ) (p : ℕ) (hp : Even p) (t M : ℝ) (ht : 0 ω (r,d)))^p + ∂batchMeasure (fun i : Fin R × RadialLine x => L*radialWeight (S\(O∪{x})) x c i.2))≤M) : + (batchMeasure (fun _ : Fin R × S => L*c)).real + {ω | (∀ r (y : S),y.1=x → ω (r,y)=0) ∧ + t ≤ |pointScore (fun y : S => y.1∈O) + (fun (H : A) (y : S) => y.1.submodule ≤ LinearMap.ker H.1.rep) b ω|} + ≤ M/t^p := by + apply point_score_tail (fun _ : Fin R × S => L*c) + (fun y : S => y.1∈O) (fun y : S => y.1=x) + (fun (H : A) (y : S) => y.1.submodule ≤ LinearMap.ker H.1.rep) + (outsideDirection S O x) (fun H : A => lines x H) + (fun H y => outsideDirection_incidence S O x H (hA H H.2) y) b + (fun k => L*radialWeight (S\(O∪{x})) x c k.2) _ p hp t M ht hM hm + intro k + exact actual_radial_rate S O x L c k + +end +end SharpLogRamsey.PreparedProjectiveGeometry + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/TestRadialWeights.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/TestRadialWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..7e9e0b58d8472e9c1676254d6459f0787b3d5a6f --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/TestRadialWeights.lean @@ -0,0 +1,147 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Entropy.StrongDegreeBudget +import OAI.Combinatorics.SharpRamsey.Geometry.PencilGeometry + +namespace OAI + +section +namespace SharpLogRamsey.PreparedProjectiveGeometry +open Finset SharpRamseyFive.PoissonScore +open scoped Classical BigOperators NNReal +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedTestRadialWeights_1 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedTestRadialWeights_2 : Fintype (Projectivization K (Module.Dual K V)) := Fintype.ofFinite _ + +def radialWeight (S : Finset (Projectivization K V)) (x : Projectivization K V) + (c : ℝ≥0) (W : RadialLine x) : ℝ≥0 := c*(radialFiber S x W).card + +omit [Finite K] [FiniteDimensional K V] in +lemma radialWeight_coe (S : Finset (Projectivization K V)) (x : Projectivization K V) + (c : ℝ≥0) (W : RadialLine x) : + (radialWeight S x c W : ℝ)=strength S x c W := by + simp only [radialWeight,strength,NNReal.coe_mul,NNReal.coe_natCast] + +lemma radialWeight_mass (S : Finset (Projectivization K V)) (x : Projectivization K V) + (c : ℝ≥0) (H : Projectivization K (Module.Dual K V)) + (hxH : x.submodule≤LinearMap.ker H.rep) : + mass (radialWeight S x c) (lines x H)= + (c:ℝ)*(S.filter (fun y => y≠x ∧ y.submodule≤LinearMap.ker H.rep)).card := by + simp only [mass,radialWeight_coe,strength] + exact hyperplane_mass S x H hxH c + +lemma radialWeight_intersection (S : Finset (Projectivization K V)) (x : Projectivization K V) + (c : ℝ≥0) (H J : Projectivization K (Module.Dual K V)) + (hxH : x.submodule≤LinearMap.ker H.rep) (hxJ : x.submodule≤LinearMap.ker J.rep) : + mass (radialWeight S x c) (lines x H∩lines x J)=overlap S x c H J := by + simp only [mass,radialWeight_coe,strength,overlap] + exact intersection_mass S x H J hxH hxJ c + +omit [Finite K] [FiniteDimensional K V] in +lemma family_filter_card (A : Finset (Projectivization K (Module.Dual K V))) + (P : Projectivization K (Module.Dual K V)→Prop) : + (univ.filter (fun H : A => P H)).card=(A.filter P).card := by + rw [←Fintype.card_coe,←Fintype.card_coe] + apply Fintype.card_congr + exact { + toFun := fun H => ⟨H.1.1,mem_filter.mpr ⟨H.1.2,(mem_filter.mp H.2).2⟩⟩ + invFun := fun H => ⟨⟨H.1,(mem_filter.mp H.2).1⟩,mem_filter.mpr ⟨mem_univ _,(mem_filter.mp H.2).2⟩⟩ + left_inv := fun H => rfl + right_inv := fun H => rfl } + +lemma family_one_direction (hdim : Module.finrank K V≤4) + (A : Finset (Projectivization K (Module.Dual K V))) (x : Projectivization K V) + (W : RadialLine x) : + (univ.filter (fun H : A => W∈lines x H)).card≤Nat.card K+1 := by + have hh := one_direction_card (K:=K) (V:=V) hdim A x W + refine Nat.le_trans ?_ hh + apply Finset.card_le_card_of_injOn (fun H : A => H.val) + · intro H hH + exact mem_filter.mpr ⟨H.2,(mem_filter.mp hH).2⟩ + · intro H hH J hJ he + exact Subtype.ext he + +lemma family_two_directions (hdim : Module.finrank K V≤4) + (A : Finset (Projectivization K (Module.Dual K V))) (x : Projectivization K V) + (D E : RadialLine x) (hne : D≠E) : + (univ.filter (fun H : A => D∈lines x H ∧ E∈lines x H)).card≤1 := by + have hh := two_directions_card (K:=K) (V:=V) hdim A x D E hne + refine Nat.le_trans ?_ hh + apply Finset.card_le_card_of_injOn (fun H : A => H.val) + · intro H hH + exact mem_filter.mpr ⟨H.2,(mem_filter.mp hH).2⟩ + · intro H hH J hJ he + exact Subtype.ext he + +lemma family_pair_card (A : Finset (Projectivization K (Module.Dual K V))) + (S : Finset (Projectivization K V)) (x : Projectivization K V) (c : ℝ≥0) (a : ℝ) + (hA : ∀ H∈A,x.submodule≤LinearMap.ker H.rep) : + (univ.filter (fun z : SharpRamseyFive.WeightedPrograms.DistinctPairs A => + a ≤ mass (radialWeight S x c) (lines x z.1∩lines x z.2))).card= + (largePairs S x c a A).card := by + rw [←Fintype.card_coe,←Fintype.card_coe] + apply Fintype.card_congr + refine { + toFun := fun z => ⟨(z.1.1.1,z.1.2.1.1),?_⟩ + invFun := fun z => ⟨⟨⟨z.1.1,?_⟩,⟨⟨z.1.2,?_⟩,?_⟩⟩,?_⟩ + left_inv := ?_ + right_inv := ?_ } + · apply mem_filter.mpr + refine ⟨mem_product.mpr ⟨z.1.1.2,z.1.2.1.2⟩,?_,?_⟩ + · intro he + exact z.1.2.2 (Subtype.ext he.symm) + · rw [←radialWeight_intersection S x c _ _ (hA _ z.1.1.2) (hA _ z.1.2.1.2)] + exact (mem_filter.mp z.2).2 + · exact (mem_product.mp (mem_filter.mp z.2).1).1 + · exact (mem_product.mp (mem_filter.mp z.2).1).2 + · intro he + exact (mem_filter.mp z.2).2.1 (congrArg Subtype.val he).symm + · apply mem_filter.mpr + refine ⟨mem_univ _,?_⟩ + rw [radialWeight_intersection S x c _ _ + (hA _ (mem_product.mp (mem_filter.mp z.2).1).1) + (hA _ (mem_product.mp (mem_filter.mp z.2).1).2)] + exact (mem_filter.mp z.2).2.2 + · intro z + rfl + · intro z + rfl + +lemma family_neighbor_card (A : Finset (Projectivization K (Module.Dual K V))) + (S : Finset (Projectivization K V)) (x : Projectivization K V) (c : ℝ≥0) (a : ℝ) + (hA : ∀ H∈A,x.submodule≤LinearMap.ker H.rep) (H : A) : + (univ.filter (fun J : {J : A // J≠H} => + a ≤ mass (radialWeight S x c) (lines x J∩lines x H))).card= + (largeNeighbors S x c a A H).card := by + rw [←Fintype.card_coe,←Fintype.card_coe] + apply Fintype.card_congr + refine { + toFun := fun J => ⟨J.1.1.1,?_⟩ + invFun := fun J => ⟨⟨⟨J.1,?_⟩,?_⟩,?_⟩ + left_inv := ?_ + right_inv := ?_ } + · apply mem_filter.mpr + refine ⟨J.1.1.2,?_,?_⟩ + · intro he + exact J.1.2 (Subtype.ext he.symm) + · rw [←radialWeight_intersection S x c _ _ (hA _ H.2) (hA _ J.1.1.2),inter_comm] + exact (mem_filter.mp J.2).2 + · exact (mem_filter.mp J.2).1 + · intro he + exact (mem_filter.mp J.2).2.1 (congrArg Subtype.val he).symm + · apply mem_filter.mpr + refine ⟨mem_univ _,?_⟩ + rw [inter_comm,radialWeight_intersection S x c _ _ (hA _ H.2) (hA _ (mem_filter.mp J.2).1)] + exact (mem_filter.mp J.2).2.2 + · intro J + rfl + · intro J + rfl + +end +end SharpLogRamsey.PreparedProjectiveGeometry + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/TestRowPencils.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/TestRowPencils.lean new file mode 100644 index 0000000000000000000000000000000000000000..d09e3621c548ea343c86df4c4f2150d80ab88768 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/TestRowPencils.lean @@ -0,0 +1,114 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Learning.TestRowSize + +namespace OAI + +section +namespace SharpLogRamsey.PreparedRow +open Finset MeasureTheory PreparedProjectiveGeometry +open SharpLogRamsey.PointScore SharpLogRamsey.Incidence +open scoped BigOperators Classical NNReal +noncomputable section +variable {K V I : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedTestRowPencils_1 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedTestRowPencils_2 : Fintype (Projectivization K (Module.Dual K V)) := Fintype.ofFinite _ +local instance flat_JoinedTestRowPencils_3 : Fintype (Projectivization K V) := by + have : Finite V := Module.finite_of_finite K + exact Fintype.ofFinite _ + +abbrev pencil (x : Projectivization K V) : Finset (Projectivization K (Module.Dual K V)) := + univ.filter (fun H => x.submodule ≤ LinearMap.ker H.rep) + +abbrev outsideMass (S O : Finset (Projectivization K V)) (x : Projectivization K V) + (c : ℝ≥0) (H : Projectivization K (Module.Dual K V)) : ℝ := + (c:ℝ)*((S\(O∪{x})).filter (fun y => y≠x ∧ y.submodule ≤ LinearMap.ker H.rep)).card + +structure SecondPencil (j R : ℕ) (S O : Finset (Projectivization K V)) + (x : Projectivization K V) (c L : ℝ≥0) + (A : Finset (Projectivization K (Module.Dual K V))) (f B C : ℝ) + (T : Finset I) (a : I → ℝ) : Prop where + low : ∀ H∈A,3/4≤outsideMass S O x c H + upp : ∀ H∈A,outsideMass S O x c H≤2 + deviation : ∀ H∈A,|outsideMass S O x c H-(1-f)|≤1 + squares : (∑ H∈A,(outsideMass S O x c H-(1-f))^2)≤C*B*Real.exp ((L:ℝ)/100) + cardinal : ((∑ i∈range j,Nat.card K^i):ℝ)≤C*B^2 + positive : ∀ i∈T,0 L*c)).real + {ω | x∉sample S ω ∧ t≤|score S O (pencil x\E) + (fun H y => y.submodule≤LinearMap.ker H.rep) (Real.exp (-(L:ℝ)*(1-f))) ω|}≤ + B^2*Real.exp (-(3/5:ℝ)*((L:ℝ)*R))/t^2 := by + have hh := actual_point_second_tail j hdim S O x c L (pencil x\E) + (fun H hH => (mem_filter.mp (mem_sdiff.mp hH).1).2) f B C hf hB hC R hL hR + hc.low hc.upp hc.deviation hc.squares hc.cardinal T a hc.positive hc.cover hc.pairs + hc.diagonalBudget hc.powerBudget hc.sumBudget hc.twoBudget t ht + apply le_trans (measureReal_mono (h₂:=measure_ne_top _ _) ?_) hh + intro ω hω + exact ⟨unsampled S ω x hω.1,hω.2⟩ + +lemma score_high_tail + (j R p h : ℕ) (hj : 2≤j) (hj3 : j≤3) (hdim : Module.finrank K V≤j+1) + (S O : Finset (Projectivization K V)) (x : Projectivization K V) (c L : ℝ≥0) + (E : Finset (Projectivization K (Module.Dual K V))) (f B : ℝ) + (hf : f≤1/25) (hp : 0 L*c)).real + {ω | x∉sample S ω ∧ t≤|score S O (pencil x\E) + (fun H y => y.submodule≤LinearMap.ker H.rep) (Real.exp (-(L:ℝ)*(1-f))) ω|}≤ + B^p*Real.exp (-(1/10:ℝ)*(p*((L:ℝ)*R)))/t^p := by + have hh := actual_point_high_tail j hj hj3 hdim S O x c L (pencil x\E) + (fun H hH => (mem_filter.mp (mem_sdiff.mp hH).1).2) f B hf hp hpe R hL + hc.low hc.upp hc.deviation hB hc.cardinal hc.directions T a hc.nonnegative + hc.cover hc.pairs hc.neighbors hc.strong hc.squares hc.certificateBudget hc.shiftBudget + hc.pBudget hc.pSumBudget h hc.hPositive hR hc.hSize hc.hError t ht + apply le_trans (measureReal_mono (h₂:=measure_ne_top _ _) ?_) hh + intro ω hω + exact ⟨unsampled S ω x hω.1,hω.2⟩ + +end +end SharpLogRamsey.PreparedRow + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/TotalDegreeCombination.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/TotalDegreeCombination.lean new file mode 100644 index 0000000000000000000000000000000000000000..66c555d6d0cd1cf8a520f2e71e9fa3b80a17e758 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/TotalDegreeCombination.lean @@ -0,0 +1,473 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.HessianTangent + +namespace OAI + +/-! Incidence bounds for rich lines and finite point configurations. -/ + +section +section +section +open Finset Finsupp +open scoped BigOperators +open MvPolynomial Finsupp +open scoped BigOperators +open MvPolynomial +open scoped BigOperators +open Finset MvPolynomial UniqueFactorizationMonoid +namespace SharpLogRamsey.CoprimeCombination +variable {σ ι K : Type*} [Fintype ι] [Field K] [Infinite K] +omit [Infinite K] in +lemma totalDegree_combination_le (Q : ι → MvPolynomial σ K) (c : ι → K) (D : ℕ) + (h : ∀ i, (Q i).totalDegree ≤ D) : + (∑ i, c i • Q i).totalDegree ≤ D := by + apply MvPolynomial.totalDegree_finsetSum_le + intro i hi + exact (MvPolynomial.totalDegree_smul_le _ _).trans (h i) +end SharpLogRamsey.CoprimeCombination + +namespace SharpLogRamsey.NonplaneCertificate +open MvPolynomial FlatnessCore PolynomialGeometry +variable {K : Type*} [Field K] +noncomputable section + +abbrev Index := (Option (Fin 2) ≃ Fin 3) × Fin 2 × Fin 2 + +noncomputable def flatFamily (G : MvPolynomial (Fin 3) K) (i : Index) : + MvPolynomial (Fin 3) K := + renameEquiv K i.1 (flatnessPolynomial ((renameEquiv K i.1).symm G) i.2.1 i.2.2) + +lemma squarefree_equiv {A B : Type*} [Monoid A] [Monoid B] + (e : A ≃* B) {f : A} (h : Squarefree f) : Squarefree (e f) := by + intro x hx + have H : e.symm x*e.symm x ∣ f := by + simpa only [map_mul,e.symm_apply_apply] using map_dvd e.symm hx + have H' := (h _ H).map e + simpa only [e.apply_symm_apply] using H' + +lemma totalDegree_equiv_le {α β : Type*} (e : α ≃ β) (F : MvPolynomial α K) : + (renameEquiv K e F).totalDegree ≤ F.totalDegree := totalDegree_rename_le _ _ + +lemma pderiv_equiv {α β : Type*} (e : α ≃ β) (F : MvPolynomial α K) (i : α) : + pderiv (e i) (renameEquiv K e F) = renameEquiv K e (pderiv i F) := + pderiv_rename e.injective i F + +lemma nonplane_witness {p : ℕ} [CharP K p] [IsAlgClosed K] + (G F : MvPolynomial (Fin 3) K) (hG : G ≠ 0) (hdeg : G.totalDegree < p) + (hs : Squarefree G) (hF : Irreducible F) (hdiv : F ∣ G) + (hn : ∀ L : MvPolynomial (Fin 3) K, L ∣ G → L.totalDegree ≤ 1 → IsUnit L) : + ∃ i : Index, ¬F ∣ flatFamily G i := by + obtain ⟨i,hi⟩ := exists_nonzero_pderiv F + (totalDegree_pos_of_irreducible F hF) + ((totalDegree_le_of_dvd_of_isDomain hdiv hG).trans_lt hdeg) + let e : Option (Fin 2) ≃ Fin 3 := (finSuccEquiv' i).symm + let E := renameEquiv K e + have hen : e none = i := finSuccEquiv'_symm_none i + have hdn : pderiv none (E.symm F) ≠ 0 := by + have he := pderiv_equiv e.symm F i + have hnone : e.symm i = none := by rw [← hen]; simp + rw [hnone] at he + change pderiv none (E.symm F) = E.symm (pderiv i F) at he + rw [he] + exact fun h => hi (E.symm.injective (h.trans (map_zero E.symm).symm)) + obtain ⟨a,b,hab⟩ := GlobalFlatness.nonplane_factor_not_flat + (E.symm G) (E.symm F) + ((totalDegree_equiv_le e.symm G).trans_lt hdeg) + (squarefree_equiv E.symm.toMulEquiv hs) + ((MulEquiv.irreducible_iff E.symm).mpr hF) (map_dvd E.symm hdiv) hdn + (fun L hd hdl => by + have hL := hn (E L) (by simpa only [E.apply_symm_apply] using map_dvd E hd) + ((totalDegree_equiv_le e L).trans hdl) + exact (isUnit_map_iff E L).mp hL) + refine ⟨⟨e,a,b⟩,fun hd => hab ?_⟩ + have H := map_dvd E.symm hd + change E.symm F ∣ E.symm (E (flatnessPolynomial (E.symm G) a b)) at H + simpa only [E.symm_apply_apply] using H + +lemma totalDegree_partial_le {α : Type*} (F : MvPolynomial α K) (i : α) : + (pderiv i F).totalDegree ≤ F.totalDegree := by + by_cases h : pderiv i F = 0 + · simp [h] + · exact (totalDegree_pderiv_lt F i h).le + +lemma totalDegree_tangent_le (G : MvPolynomial (Option (Fin 2)) K) (a : Fin 2) + (i : Option (Fin 2)) : + (scaledTangent (fun i => pderiv i G) a i).totalDegree ≤ G.totalDegree := by + cases i with + | none => simpa [scaledTangent] using totalDegree_partial_le G (some a) + | some i => + by_cases hi : i = a + · simpa [scaledTangent,hi] using totalDegree_partial_le G none + · simp [scaledTangent,hi] + +lemma totalDegree_flatness_le (G : MvPolynomial (Option (Fin 2)) K) (a b : Fin 2) : + (flatnessPolynomial G a b).totalDegree ≤ 3*G.totalDegree := by + apply totalDegree_finsetSum_le + intro j hj + apply totalDegree_finsetSum_le + intro i hi + have H := totalDegree_mul (pderiv i (pderiv j G)*scaledTangent (fun i => pderiv i G) a i) + (scaledTangent (fun i => pderiv i G) b j) + have H' := totalDegree_mul (pderiv i (pderiv j G)) (scaledTangent (fun i => pderiv i G) a i) + have H'' := (totalDegree_partial_le (pderiv j G) i).trans (totalDegree_partial_le G j) + have H1 := totalDegree_tangent_le G a i + have H2 := totalDegree_tangent_le G b j + omega + +lemma totalDegree_family_le (G : MvPolynomial (Fin 3) K) (i : Index) : + (flatFamily G i).totalDegree ≤ 3*G.totalDegree := by + exact (totalDegree_equiv_le _ _).trans ((totalDegree_flatness_le _ _ _).trans + (Nat.mul_le_mul_left _ (totalDegree_equiv_le _ _))) + +theorem exists_coprime_flat_combination {p : ℕ} [CharP K p] [IsAlgClosed K] + (G : MvPolynomial (Fin 3) K) (hG : G ≠ 0) (hdeg : G.totalDegree < p) + (hs : Squarefree G) + (hn : ∀ L : MvPolynomial (Fin 3) K, L ∣ G → L.totalDegree ≤ 1 → IsUnit L) : + ∃ c : Index → K, IsRelPrime G (∑ i, c i • flatFamily G i) ∧ + (∑ i, c i • flatFamily G i).totalDegree ≤ 3*G.totalDegree := by + obtain ⟨c,hc⟩ := CoprimeCombination.exists_coprime_combination G hG (flatFamily G) + (fun F hF hd => nonplane_witness G F hG hdeg hs hF hd hn) + exact ⟨c,hc,CoprimeCombination.totalDegree_combination_le _ _ _ (totalDegree_family_le G)⟩ +end +end SharpLogRamsey.NonplaneCertificate + +open scoped BigOperators +open Finset MvPolynomial +namespace SharpLogRamsey.LineFlatness +variable {K σ R : Type*} [Field K] [Fintype σ] [DecidableEq σ] + [CommRing R] [Algebra K R] + +lemma deriv_aeval (D : Derivation K R R) (x : σ → R) (F : MvPolynomial σ K) : + D (MvPolynomial.aeval x F) = + ∑ i, MvPolynomial.aeval x (MvPolynomial.pderiv i F) * D (x i) := by + induction F using MvPolynomial.induction_on with + | C c => simp + | add f g hf hg => simp [hf,hg,add_mul,Finset.sum_add_distrib] + | mul_X f j hf => + simp only [map_mul,MvPolynomial.aeval_X,Derivation.leibniz,smul_eq_mul, + map_add,MvPolynomial.pderiv_X] + simp only [ + add_mul,Finset.sum_add_distrib] + rw [hf,Finset.mul_sum] + congr 1 + · simp [Pi.single_apply] + · apply Finset.sum_congr rfl + intro i hi + ring + +lemma deriv2_aeval (D E : Derivation K R R) (x : σ → R) (F : MvPolynomial σ K) : + D (E (MvPolynomial.aeval x F)) = + (∑ j, ∑ i, MvPolynomial.aeval x (MvPolynomial.pderiv i + (MvPolynomial.pderiv j F)) * D (x i) * E (x j)) + + ∑ j, MvPolynomial.aeval x (MvPolynomial.pderiv j F) * D (E (x j)) := by + rw [deriv_aeval E,map_sum] + simp only [Derivation.leibniz,smul_eq_mul,Finset.sum_add_distrib] + rw [add_comm] + congr 1 + apply Finset.sum_congr rfl + intro j hj + rw [deriv_aeval D,Finset.mul_sum] + apply Finset.sum_congr rfl + intro i hi + ring + +noncomputable def restrictLine (x v : σ → K) (F : MvPolynomial σ K) : Polynomial K := + aeval (fun i => Polynomial.C (x i) + Polynomial.C (v i) * Polynomial.X) F +omit [Fintype σ] [DecidableEq σ] in + +lemma eval_restrictLine (x v : σ → K) (F : MvPolynomial σ K) (t : K) : + (restrictLine x v F).eval t = eval (fun i => x i + v i*t) F := by + induction F using MvPolynomial.induction_on with + | C c => simp [restrictLine] + | add f g hf hg => simp_all [restrictLine] + | mul_X f i hf => simp_all [restrictLine] + +lemma derivative_restrictLine (x v : σ → K) (F : MvPolynomial σ K) : + Polynomial.derivative (restrictLine x v F) = + ∑ i, restrictLine x v (pderiv i F) * Polynomial.C (v i) := by + have H := deriv_aeval Polynomial.derivative' + (fun i => Polynomial.C (x i) + Polynomial.C (v i) * Polynomial.X) F + simpa [restrictLine] using H + +lemma line_tangent (x v : σ → K) (F : MvPolynomial σ K) + (h : restrictLine x v F = 0) : + ∑ i, eval x (pderiv i F)*v i = 0 := by + have H := congrArg (Polynomial.eval (0 : K)) (derivative_restrictLine x v F) + simpa [h,Polynomial.eval_finsetSum,eval_restrictLine] using H.symm + +lemma line_hessian (x v : σ → K) (F : MvPolynomial σ K) + (h : restrictLine x v F = 0) : + ∑ j, ∑ i, eval x (pderiv i (pderiv j F))*v i*v j = 0 := by + have H := deriv2_aeval Polynomial.derivative' Polynomial.derivative' + (fun i => Polynomial.C (x i) + Polynomial.C (v i) * Polynomial.X) F + change Polynomial.derivative (Polynomial.derivative (restrictLine x v F)) = _ at H + simp only [show ∀ i, Polynomial.derivative' + (Polynomial.C (x i) + Polynomial.C (v i) * Polynomial.X) = Polynomial.C (v i) + from fun i => by simp, show ∀ i, Polynomial.derivative' (Polynomial.C (v i)) = 0 + from fun i => by simp,mul_zero,sum_const_zero,add_zero] at H + change Polynomial.derivative (Polynomial.derivative (restrictLine x v F)) = + ∑ j, ∑ i, restrictLine x v (pderiv i (pderiv j F)) * Polynomial.C (v i) * Polynomial.C (v j) at H + have E := congrArg (Polynomial.eval (0 : K)) H + simpa [h,Polynomial.eval_finsetSum,eval_restrictLine] using E.symm +omit [Fintype σ] in + +lemma pderiv_swap (F : MvPolynomial σ K) (i j : σ) : + pderiv i (pderiv j F) = pderiv j (pderiv i F) := by + induction F using MvPolynomial.induction_on with + | C c => simp + | add f g hf hg => simp [hf,hg] + | mul_X f k hf => + by_cases hi : k = i <;> by_cases hj : k = j <;> + simp [pderiv_X,Pi.single_apply,apply_ite,hi,hj,hf,add_comm,add_left_comm] + all_goals split_ifs <;> simp_all + +lemma quadratic_vandermonde (v : Fin 3 → Fin 2 → K) : + (Matrix.of (fun (i j : Fin 3) => ![(v i 0)^2, v i 0*v i 1, (v i 1)^2] j)).det = + (v 0 0*v 1 1-v 0 1*v 1 0) * (v 0 0*v 2 1-v 0 1*v 2 0) * + (v 1 0*v 2 1-v 1 1*v 2 0) := by + rw [Matrix.det_fin_three] + simp only [Matrix.of_apply] + dsimp + ring + +theorem binary_quadratic_three (v : Fin 3 → Fin 2 → K) (A B C : K) + (h01 : v 0 0*v 1 1-v 0 1*v 1 0 ≠ 0) + (h02 : v 0 0*v 2 1-v 0 1*v 2 0 ≠ 0) + (h12 : v 1 0*v 2 1-v 1 1*v 2 0 ≠ 0) + (hv : ∀ i, A*(v i 0)^2+B*(v i 0*v i 1)+C*(v i 1)^2 = 0) : + A = 0 ∧ B = 0 ∧ C = 0 := by + let M : Matrix (Fin 3) (Fin 3) K := + Matrix.of (fun i j => ![(v i 0)^2,v i 0*v i 1,(v i 1)^2] j) + have hdet : IsUnit M.det := by + rw [isUnit_iff_ne_zero,quadratic_vandermonde] + exact mul_ne_zero (mul_ne_zero h01 h02) h12 + have hm : M.mulVec ![A,B,C] = 0 := by + ext i + simpa [M,Matrix.mulVec,dotProduct,Fin.sum_univ_succ,mul_comm,add_assoc] using hv i + have E := congrArg (Matrix.mulVec M⁻¹) hm + rw [Matrix.mulVec_mulVec,Matrix.nonsing_inv_mul M hdet, + Matrix.one_mulVec,Matrix.mulVec_zero] at E + exact ⟨congrFun E 0,congrFun E 1,congrFun E 2⟩ + +noncomputable def hessian (x : σ → K) (F : MvPolynomial σ K) (u v : σ → K) : K := + ∑ j, ∑ i, eval x (pderiv i (pderiv j F))*u i*v j +omit [DecidableEq σ] in + +lemma hessian_smul_left (x : σ → K) (F : MvPolynomial σ K) (a : K) (u v : σ → K) : + hessian x F (a • u) v = a*hessian x F u v := by + simp only [hessian,Pi.smul_apply,smul_eq_mul,Finset.mul_sum] + congr 1; ext j + congr 1; ext i + ring +omit [DecidableEq σ] in + +lemma hessian_smul_right (x : σ → K) (F : MvPolynomial σ K) (a : K) (u v : σ → K) : + hessian x F u (a • v) = a*hessian x F u v := by + simp only [hessian,Pi.smul_apply,smul_eq_mul,Finset.mul_sum] + congr 1; ext j + congr 1; ext i + ring +omit [DecidableEq σ] in + +lemma hessian_add_left (x : σ → K) (F : MvPolynomial σ K) (u v w : σ → K) : + hessian x F (u+v) w = hessian x F u w+hessian x F v w := by + simp [hessian,mul_add,add_mul,sum_add_distrib] +omit [DecidableEq σ] in + +lemma hessian_add_right (x : σ → K) (F : MvPolynomial σ K) (u v w : σ → K) : + hessian x F u (v+w) = hessian x F u v+hessian x F u w := by + simp [hessian,mul_add,sum_add_distrib] + +lemma hessian_symm (x : σ → K) (F : MvPolynomial σ K) (u v : σ → K) : + hessian x F u v = hessian x F v u := by + unfold hessian + rw [Finset.sum_comm] + apply sum_congr rfl + intro i hi + apply sum_congr rfl + intro j hj + rw [pderiv_swap F i j] + ring + +def scaledTangent (g : Option (Fin 2) → K) (a : Fin 2) : Option (Fin 2) → K := + fun o => o.elim (-g (some a)) (fun i => if i = a then g none else 0) + +lemma tangent_expansion (g v : Option (Fin 2) → K) + (hv : ∑ i, g i*v i = 0) : + g none • v = v (some 0) • scaledTangent g 0 + v (some 1) • scaledTangent g 1 := by + ext i + cases i with + | none => + simp only [Fintype.sum_option,Fin.sum_univ_two] at hv + simp only [Pi.smul_apply,Pi.add_apply,smul_eq_mul,scaledTangent,Option.elim_none] + linear_combination hv + | some i => fin_cases i <;> simp [scaledTangent,mul_comm] + +lemma tangent_projection_independent (g : Option (Fin 2) → K) (hg : g none ≠ 0) + (v : Fin 2 → Option (Fin 2) → K) (hv : ∀ a, ∑ i, g i*v a i = 0) + (hli : LinearIndependent K v) : + LinearIndependent K (fun a i => v a (some i)) := by + rw [Fintype.linearIndependent_iff] at hli ⊢ + intro c hc + apply hli c + ext i + have h0 := congrFun hc 0 + have h1 := congrFun hc 1 + simp only [Fin.sum_univ_two,Pi.add_apply,Pi.smul_apply,smul_eq_mul,Pi.zero_apply] at h0 h1 ⊢ + cases i with + | some i => fin_cases i <;> assumption + | none => + apply (mul_left_cancel₀ hg) + rw [mul_zero] + have h2 := hv 0 + have h3 := hv 1 + simp only [Fintype.sum_option,Fin.sum_univ_two] at h2 h3 + linear_combination c 0*h2+c 1*h3-g (some 0)*h0-g (some 1)*h1 + +lemma tangent_projection_det (g : Option (Fin 2) → K) (hg : g none ≠ 0) + (u v : Option (Fin 2) → K) (hu : ∑ i, g i*u i = 0) (hv : ∑ i, g i*v i = 0) + (hli : LinearIndependent K ![u,v]) : + u (some 0)*v (some 1)-u (some 1)*v (some 0) ≠ 0 := by + have hl := tangent_projection_independent g hg ![u,v] + (fun i => by fin_cases i <;> assumption) hli + let M : Matrix (Fin 2) (Fin 2) K := Matrix.of (fun i j => ![u,v] i (some j)) + have hM : IsUnit M := Matrix.linearIndependent_rows_iff_isUnit.mp hl + have hD := (Matrix.isUnit_iff_isUnit_det M).mp hM + simpa [M,Matrix.det_fin_two,isUnit_iff_ne_zero] using hD + +theorem three_lines_flat (F : MvPolynomial (Option (Fin 2)) K) + (x : Option (Fin 2) → K) (v : Fin 3 → Option (Fin 2) → K) + (h2 : (2 : K) ≠ 0) (hz : eval x (pderiv none F) ≠ 0) + (hlines : ∀ i, restrictLine x (v i) F = 0) + (h01 : LinearIndependent K ![v 0,v 1]) + (h02 : LinearIndependent K ![v 0,v 2]) + (h12 : LinearIndependent K ![v 1,v 2]) : + ∀ a b, hessian x F (scaledTangent (fun i => eval x (pderiv i F)) a) + (scaledTangent (fun i => eval x (pderiv i F)) b) = 0 := by + let g : Option (Fin 2) → K := fun i => eval x (pderiv i F) + let t := scaledTangent g + have ht (i : Fin 3) : ∑ a, g a*v i a = 0 := line_tangent x (v i) F (hlines i) + have hH (i : Fin 3) : hessian x F (v i) (v i) = 0 := line_hessian x (v i) F (hlines i) + have he (i : Fin 3) := tangent_expansion g (v i) (ht i) + have hq (i : Fin 3) : + hessian x F (t 0) (t 0)*(v i (some 0))^2 + + (2*hessian x F (t 0) (t 1))*(v i (some 0)*v i (some 1)) + + hessian x F (t 1) (t 1)*(v i (some 1))^2 = 0 := by + have E : hessian x F (g none • v i) (g none • v i) = 0 := by + rw [hessian_smul_left,hessian_smul_right,hH,mul_zero,mul_zero] + rw [he,hessian_add_left,hessian_add_right,hessian_add_right] at E + simp only [hessian_smul_left,hessian_smul_right] at E + rw [hessian_symm x F (t 1) (t 0)] at E + linear_combination E + obtain ⟨h00,h01',h11⟩ := binary_quadratic_three + (fun i a => v i (some a)) _ _ _ + (tangent_projection_det g hz _ _ (ht 0) (ht 1) h01) + (tangent_projection_det g hz _ _ (ht 0) (ht 2) h02) + (tangent_projection_det g hz _ _ (ht 1) (ht 2) h12) hq + have h01z := (mul_eq_zero.mp h01').resolve_left h2 + intro a b + fin_cases a <;> fin_cases b + · exact h00 + · exact h01z + · exact (hessian_symm x F (t 1) (t 0)).trans h01z + · exact h11 + +lemma three_lines_all_tangents (F : MvPolynomial (Option (Fin 2)) K) + (x : Option (Fin 2) → K) (v : Fin 3 → Option (Fin 2) → K) + (h2 : (2 : K) ≠ 0) (hz : eval x (pderiv none F) ≠ 0) + (hlines : ∀ i, restrictLine x (v i) F = 0) + (h01 : LinearIndependent K ![v 0,v 1]) + (h02 : LinearIndependent K ![v 0,v 2]) + (h12 : LinearIndependent K ![v 1,v 2]) + (u w : Option (Fin 2) → K) + (hu : ∑ i, eval x (pderiv i F)*u i = 0) + (hw : ∑ i, eval x (pderiv i F)*w i = 0) : hessian x F u w = 0 := by + let g := fun i => eval x (pderiv i F) + have H := three_lines_flat F x v h2 hz hlines h01 h02 h12 + apply mul_left_cancel₀ (mul_ne_zero hz hz) + rw [mul_zero] + calc + _ = hessian x F (g none • u) (g none • w) := by + rw [hessian_smul_left,hessian_smul_right]; ring + _ = 0 := by + rw [tangent_expansion g u hu,tangent_expansion g w hw, + hessian_add_left,hessian_add_right,hessian_add_right] + simp only [hessian_smul_left,hessian_smul_right,g,H,mul_zero,add_zero] + +variable {τ : Type*} [Fintype τ] [DecidableEq τ] +omit [DecidableEq σ] [DecidableEq τ] in +lemma hessian_rename (e : σ ≃ τ) (F : MvPolynomial σ K) (x u v : τ → K) : + hessian x (renameEquiv K e F) u v = hessian (x ∘ e) F (u ∘ e) (v ∘ e) := by + unfold hessian + rw [← e.sum_comp] + apply sum_congr rfl + intro j hj + rw [← e.sum_comp] + apply sum_congr rfl + intro i hi + simp only [renameEquiv_apply,pderiv_rename e.injective,eval_rename,Function.comp_apply] +omit [Fintype σ] [DecidableEq σ] [Fintype τ] [DecidableEq τ] in + +lemma restrictLine_rename (e : σ ≃ τ) (F : MvPolynomial σ K) (x v : τ → K) : + restrictLine x v (renameEquiv K e F) = restrictLine (x ∘ e) (v ∘ e) F := by + simp only [restrictLine,renameEquiv_apply,aeval_rename,Function.comp_def] +omit [DecidableEq σ] [DecidableEq τ] in + +lemma tangent_rename (e : σ ≃ τ) (F : MvPolynomial σ K) (x v : τ → K) : + (∑ i, eval x (pderiv i (renameEquiv K e F))*v i) = + ∑ i, eval (x ∘ e) (pderiv i F)*(v ∘ e) i := by + rw [← e.sum_comp] + apply sum_congr rfl + intro i hi + simp only [renameEquiv_apply,pderiv_rename e.injective,eval_rename,Function.comp_apply] +omit [Fintype σ] [DecidableEq σ] [Fintype τ] [DecidableEq τ] in + +lemma independent_rename (e : σ ≃ τ) (u v : τ → K) + (h : LinearIndependent K ![u,v]) : LinearIndependent K ![u ∘ e,v ∘ e] := by + let E := LinearEquiv.funCongrLeft K K e + have H := h.map' E.toLinearMap E.ker + change LinearIndependent K (fun i => ![u,v] i ∘ e) at H + convert H using 1 + ext i j + fin_cases i <;> rfl + +theorem three_lines_tangent_zero (F : MvPolynomial (Fin 3) K) + (x : Fin 3 → K) (v : Fin 3 → Fin 3 → K) + (h2 : (2 : K) ≠ 0) (hn : ∃ i, eval x (pderiv i F) ≠ 0) + (hlines : ∀ i, restrictLine x (v i) F = 0) + (h01 : LinearIndependent K ![v 0,v 1]) + (h02 : LinearIndependent K ![v 0,v 2]) + (h12 : LinearIndependent K ![v 1,v 2]) + (u w : Fin 3 → K) (hu : ∑ i, eval x (pderiv i F)*u i = 0) + (hw : ∑ i, eval x (pderiv i F)*w i = 0) : hessian x F u w = 0 := by + obtain ⟨i,hi⟩ := hn + let e : Option (Fin 2) ≃ Fin 3 := (finSuccEquiv' i).symm + have hen : e none = i := finSuccEquiv'_symm_none i + have hc (z : Fin 3 → K) : (z ∘ e) ∘ e.symm = z := by ext j; simp + have hz : eval (x ∘ e) (pderiv none (renameEquiv K e.symm F)) ≠ 0 := by + have he := pderiv_rename e.symm.injective i F + have hnone : e.symm i = none := by rw [← hen]; simp + rw [hnone] at he + simpa only [renameEquiv_apply,he,eval_rename,hc] using hi + have H := three_lines_all_tangents (renameEquiv K e.symm F) (x ∘ e) + (fun j => v j ∘ e) h2 hz + (fun j => by simpa only [restrictLine_rename,hc] using hlines j) + (independent_rename e _ _ h01) (independent_rename e _ _ h02) + (independent_rename e _ _ h12) (u ∘ e) (w ∘ e) + (by simpa only [tangent_rename,hc] using hu) + (by simpa only [tangent_rename,hc] using hw) + simpa only [hessian_rename,hc] using H + +end SharpLogRamsey.LineFlatness + +namespace SharpLogRamsey.RichLinePolynomial +open MvPolynomial Finset +open FlatnessCore NonplaneCertificate +variable {K : Type*} [Field K] + +end SharpLogRamsey.RichLinePolynomial +end +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/Triple.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/Triple.lean new file mode 100644 index 0000000000000000000000000000000000000000..9a82700ec34f6458a9e9fe46a450f5f1d56c9b0f --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/Triple.lean @@ -0,0 +1,479 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.ScaledTangentDot + +namespace OAI + +/-! Incidence bounds for rich lines and finite point configurations. -/ + +section +section +section +section +namespace SharpLogRamsey.PolynomialCoordinates +open MvPolynomial +variable {K : Type*} [Field K] +noncomputable section +abbrev Triple := Polynomial (Polynomial (Polynomial K)) + +def encode : MvPolynomial (Fin 3) K ≃ₐ[K] Triple (K := K) := + (renameEquiv K (Equiv.swap 0 2)).trans ((finSuccEquiv K 2).trans + (Polynomial.mapAlgEquiv ((finSuccEquiv K 1).trans + (Polynomial.mapAlgEquiv (uniqueAlgEquiv K (Fin 1)))))) + +@[simp] lemma encode_C (a : K) : encode (C a) = Polynomial.C (Polynomial.C (Polynomial.C a)) := by + simp [encode,finSuccEquiv_apply,uniqueAlgEquiv_apply] + +@[simp] lemma encode_X (i : Fin 3) : encode (X i : MvPolynomial (Fin 3) K) = + ![Polynomial.C (Polynomial.C Polynomial.X), Polynomial.C Polynomial.X, Polynomial.X] i := by + have h2 : finSuccEquiv K 2 (X 2) = Polynomial.C (X 1) := + finSuccEquiv_X_succ (j := 1) + have h1 : finSuccEquiv K 2 (X 1) = Polynomial.C (X 0) := + finSuccEquiv_X_succ (j := 0) + have h11 : finSuccEquiv K 1 (X 1) = Polynomial.C (X 0) := + finSuccEquiv_X_succ (j := 0) + fin_cases i <;> simp [encode,h2,h1,h11,finSuccEquiv_X_zero, + uniqueAlgEquiv_apply,Equiv.swap_apply_def] + +lemma encode_natDegree (F : MvPolynomial (Fin 3) K) : + (encode F).natDegree ≤ F.totalDegree := by + simp only [encode,AlgEquiv.trans_apply,Polynomial.coe_mapAlgEquiv] + rw [Polynomial.natDegree_map_eq_of_injective (AlgEquiv.injective _),natDegree_finSuccEquiv] + exact (degreeOf_le_totalDegree _ _).trans (totalDegree_rename_le _ _) + +lemma coeff_degree_le {n : ℕ} (F : MvPolynomial (Fin (n+1)) K) (i : ℕ) : + ((finSuccEquiv K n F).coeff i).totalDegree ≤ F.totalDegree := by + by_cases h : (finSuccEquiv K n F).coeff i = 0 + · simp [h] + · exact (Nat.le_add_right _ _).trans (totalDegree_coeff_finSuccEquiv_add_le F i h) + +lemma encode_coeff_natDegree (F : MvPolynomial (Fin 3) K) (i : ℕ) : + ((encode F).coeff i).natDegree ≤ F.totalDegree := by + simp only [encode,AlgEquiv.trans_apply,Polynomial.coe_mapAlgEquiv,Polynomial.coeff_map] + change (Polynomial.map (uniqueAlgEquiv K (Fin 1)).toRingHom + (finSuccEquiv K 1 (((finSuccEquiv K 2) ((renameEquiv K (Equiv.swap 0 2)) F)).coeff i))).natDegree ≤ F.totalDegree + rw [Polynomial.natDegree_map_eq_of_injective (AlgEquiv.injective _),natDegree_finSuccEquiv] + exact (degreeOf_le_totalDegree _ _).trans + ((coeff_degree_le _ i).trans (totalDegree_rename_le _ _)) + +def changeHom (a b c : K) : MvPolynomial (Fin 3) K →ₐ[K] MvPolynomial (Fin 3) K := + aeval ![X 0-C a*X 1+C (a*c-b)*X 2, X 1-C c*X 2, X 2] +def unchangeHom (a b c : K) : MvPolynomial (Fin 3) K →ₐ[K] MvPolynomial (Fin 3) K := + aeval ![X 0+C a*X 1+C b*X 2, X 1+C c*X 2, X 2] + +lemma unchange_change (a b c : K) (F : MvPolynomial (Fin 3) K) : + unchangeHom a b c (changeHom a b c F) = F := by + induction F using MvPolynomial.induction_on with + | C r => simp [changeHom,unchangeHom] + | add f g hf hg => simp only [map_add,hf,hg] + | mul_X f i hf => + simp only [map_mul,hf] + congr 1 + fin_cases i <;> simp [changeHom,unchangeHom] ; ring +lemma change_unchange (a b c : K) (F : MvPolynomial (Fin 3) K) : + changeHom a b c (unchangeHom a b c F) = F := by + induction F using MvPolynomial.induction_on with + | C r => simp [changeHom,unchangeHom] + | add f g hf hg => simp only [map_add,hf,hg] + | mul_X f i hf => + simp only [map_mul,hf] + congr 1 + fin_cases i <;> simp [changeHom,unchangeHom] ; ring + +def change (a b c : K) : MvPolynomial (Fin 3) K ≃ₐ[K] MvPolynomial (Fin 3) K := + AlgEquiv.ofAlgHom (changeHom a b c) (unchangeHom a b c) + (AlgHom.ext (change_unchange a b c)) + (AlgHom.ext (unchange_change a b c)) + +lemma totalDegree_aeval_linear {σ τ : Type*} (x : τ → MvPolynomial σ K) + (hx : ∀ i, (x i).totalDegree ≤ 1) (F : MvPolynomial τ K) : + (MvPolynomial.aeval x F).totalDegree ≤ F.totalDegree := by + classical + conv_lhs => rw [F.as_sum] + rw [map_sum] + apply MvPolynomial.totalDegree_finsetSum_le + intro d hd + rw [MvPolynomial.aeval_monomial] + apply le_trans (MvPolynomial.totalDegree_mul _ _) + simp only [MvPolynomial.algebraMap_eq, MvPolynomial.totalDegree_C,zero_add] + calc + _ ≤ ∑ i ∈ d.support, (x i ^ d i).totalDegree := MvPolynomial.totalDegree_finsetProd _ _ + _ ≤ ∑ i ∈ d.support, d i := by + apply Finset.sum_le_sum + intro i hi + apply (MvPolynomial.totalDegree_pow _ _).trans + simpa [Nat.mul_comm] using Nat.mul_le_mul_right (d i) (hx i) + _ ≤ F.totalDegree := MvPolynomial.le_totalDegree hd + +lemma change_degree (a b c : K) (F : MvPolynomial (Fin 3) K) : + (change a b c F).totalDegree ≤ F.totalDegree := by + apply totalDegree_aeval_linear + intro i + fin_cases i + · apply (totalDegree_add _ _).trans + apply max_le + · apply (totalDegree_sub _ _).trans + apply max_le (by simp) + exact (totalDegree_mul _ _).trans (by simp only [totalDegree_C,totalDegree_X]; omega) + · exact (totalDegree_mul _ _).trans (by simp only [totalDegree_C,totalDegree_X]; omega) + · apply (totalDegree_sub _ _).trans + apply max_le (by simp) + exact (totalDegree_mul _ _).trans (by simp only [totalDegree_C,totalDegree_X]; omega) + · simp + +lemma eval_change (a b c : K) (w : Fin 3 → K) (F : MvPolynomial (Fin 3) K) : + eval w (change a b c F) = + eval ![w 0-a*w 1+(a*c-b)*w 2,w 1-c*w 2,w 2] F := by + change eval w (changeHom a b c F) = _ + induction F using MvPolynomial.induction_on with + | C r => simp [changeHom] + | add f g hf hg => simp only [map_add,hf,hg] + | mul_X f i hf => + simp only [map_mul,hf] + congr 1 + fin_cases i <;> simp [changeHom] + +lemma eval_encode (y z : Polynomial K) (r : K) (F : MvPolynomial (Fin 3) K) : + (((encode F).map (Polynomial.evalRingHom y)).eval z).eval r = + eval ![r,y.eval r,z.eval r] F := by + induction F using MvPolynomial.induction_on with + | C a => simp + | add f g hf hg => simp only [map_add,Polynomial.map_add,Polynomial.eval_add,hf,hg] + | mul_X f i hf => + simp only [map_mul,Polynomial.map_mul,Polynomial.eval_mul,hf] + congr 1 + fin_cases i <;> simp + +end +end SharpLogRamsey.PolynomialCoordinates + +end + +namespace SharpLogRamsey.CommonLines +open GenericCoordinates PolynomialCoordinates +variable {K : Type*} [Field K] [Infinite K] +noncomputable section + +lemma coprime_equiv {R S : Type*} [CommRing R] [CommRing S] + (e : R ≃+* S) {F G : R} (h : IsRelPrime F G) : IsRelPrime (e F) (e G) := by + intro a haf hag + have hu := h (by simpa using map_dvd e.symm haf) (by simpa using map_dvd e.symm hag) + simpa using hu.map e +omit [Infinite K] in + +lemma eval_change_shear (a b c : K) (w : Fin 3 → K) (F : MvPolynomial (Fin 3) K) : + MvPolynomial.eval (shear a b c w) (change a b c F) = MvPolynomial.eval w F := by + rw [eval_change] + apply congrArg (fun z : Fin 3 → K => MvPolynomial.eval z F) + ext i + fin_cases i <;> simp [shear] ; ring + +lemma graph_zero (a b c : K) (x v : Fin 3 → K) (hv : first a b v ≠ 0) + (F : MvPolynomial (Fin 3) K) (hF : ∀ r : K, MvPolynomial.eval (x+r • v) F = 0) : + let U := direction (first a b) v + let B := base (first a b) x v + let Y := Polynomial.C ((shear a b c B) 1)+Polynomial.C ((shear a b c U) 1)*Polynomial.X + let Z := Polynomial.C ((shear a b c B) 2)+Polynomial.C ((shear a b c U) 2)*Polynomial.X + ((encode (change a b c F)).map (Polynomial.evalRingHom Y)).eval Z = 0 := by + dsimp only + apply Polynomial.funext + intro r + rw [Polynomial.eval_zero,eval_encode] + let U := direction (first a b) v + let B := base (first a b) x v + have h0 : (shear a b c (B+r • U)) 0 = r := by + change first a b (B+r • U) = r + rw [map_add,map_smul,map_base _ _ _ hv,map_direction _ _ hv] + simp + have he : ![r, + (Polynomial.C ((shear a b c B) 1)+Polynomial.C ((shear a b c U) 1)*Polynomial.X).eval r, + (Polynomial.C ((shear a b c B) 2)+Polynomial.C ((shear a b c U) 2)*Polynomial.X).eval r] = + shear a b c (B+r • U) := by + ext i + fin_cases i + · exact h0.symm + · change (Polynomial.C ((shear a b c B) 1)+Polynomial.C ((shear a b c U) 1)*Polynomial.X).eval r = + (shear a b c (B+r • U)) 1 + simp only [Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_C, Polynomial.eval_X, + map_add, map_smul, Pi.add_apply, Pi.smul_apply, smul_eq_mul, mul_comm] + · change (Polynomial.C ((shear a b c B) 2)+Polynomial.C ((shear a b c U) 2)*Polynomial.X).eval r = + (shear a b c (B+r • U)) 2 + simp only [Polynomial.eval_add, Polynomial.eval_mul, Polynomial.eval_C, Polynomial.eval_X, + map_add, map_smul, Pi.add_apply, Pi.smul_apply, smul_eq_mul, mul_comm] + rw [he,eval_change_shear] + have hp : B+r • U ∈ line x v := by + rw [← line_normalize (first a b) x v hv] + exact ⟨r,rfl⟩ + obtain ⟨s,hs⟩ := hp + rw [← hs] + exact hF s + +theorem card_le {ι : Type*} [Fintype ι] + (F G : MvPolynomial (Fin 3) K) (hc : IsRelPrime F G) + (x v : ι → Fin 3 → K) (hv : ∀ i, v i ≠ 0) + (hd : Function.Injective (fun i => line (x i) (v i))) + (hF : ∀ i (r : K), MvPolynomial.eval (x i+r • v i) F = 0) + (hG : ∀ i (r : K), MvPolynomial.eval (x i+r • v i) G = 0) : + Fintype.card ι ≤ 2*F.totalDegree*G.totalDegree := by + classical + obtain ⟨a,b,c,ht,hsep⟩ := exists_separating_coordinates x v hv hd + let Y := fun i => Polynomial.C ((shear a b c (base (first a b) (x i) (v i))) 1)+ + Polynomial.C ((shear a b c (direction (first a b) (v i))) 1)*Polynomial.X + let Z := fun i => Polynomial.C ((shear a b c (base (first a b) (x i) (v i))) 2)+ + Polynomial.C ((shear a b c (direction (first a b) (v i))) 2)*Polynomial.X + let e : MvPolynomial (Fin 3) K ≃ₐ[K] Polynomial (Polynomial (Polynomial K)) := + (change a b c).trans (encode (K := K)) + let S := Finset.univ.image (fun i => (Y i,Z i)) + have hpair : Function.Injective (fun i => (Y i,Z i)) := by + intro i j H + exact hsep (congrArg Prod.fst H) + have hcard : S.card = Fintype.card ι := by simp [S,Finset.card_image_of_injective _ hpair] + rw [← hcard] + apply ParametricBezout.graph_branches_card_le (e F) (e G) F.totalDegree G.totalDegree + · exact coprime_equiv (S := Polynomial (Polynomial (Polynomial K))) e.toRingEquiv hc + · intro i + exact (encode_coeff_natDegree (change a b c F) i).trans (change_degree a b c F) + · intro i + exact (encode_coeff_natDegree (change a b c G) i).trans (change_degree a b c G) + · exact (encode_natDegree (change a b c F)).trans (change_degree a b c F) + · exact (encode_natDegree (change a b c G)).trans (change_degree a b c G) + · intro y hy z hz H + obtain ⟨i,hi,rfl⟩ := Finset.mem_image.mp hy + obtain ⟨j,hj,rfl⟩ := Finset.mem_image.mp hz + exact congrArg (fun i => (Y i,Z i)) (hsep H) + · intro z hz + obtain ⟨i,hi,rfl⟩ := Finset.mem_image.mp hz + exact ⟨graph_zero a b c (x i) (v i) (ht i) F (hF i), + graph_zero a b c (x i) (v i) (ht i) G (hG i)⟩ + +end +end SharpLogRamsey.CommonLines + +end + +section + +namespace SharpLogRamsey.AffineIncidence +open Finset +open scoped BigOperators +variable {K : Type*} [Field K] {ι : Type*} [Fintype ι] +noncomputable section + +def carrier (x v : Fin 3 → K) : Set (Fin 3 → K) := Set.range (fun r : K => x+r • v) + +lemma parametrization_injective (x v : Fin 3 → K) (hv : v ≠ 0) : + Function.Injective (fun r : K => x+r • v) := by + intro a b H + exact (smul_left_injective K hv) (add_left_cancel H) + +lemma rebase (x v y : Fin 3 → K) (hy : y ∈ carrier x v) : + carrier y v = carrier x v := by + obtain ⟨s,rfl⟩ := hy + ext z + constructor + · rintro ⟨r,rfl⟩ + refine ⟨s+r,?_⟩ + simp only [add_smul] + abel + · rintro ⟨r,rfl⟩ + refine ⟨r-s,?_⟩ + simp only [sub_smul] + abel + +lemma scale (x v : Fin 3 → K) (a : K) (ha : a ≠ 0) : + carrier x (a • v) = carrier x v := by + ext z + constructor + · rintro ⟨r,rfl⟩ + exact ⟨r*a,by simp [mul_smul]⟩ + · rintro ⟨r,rfl⟩ + exact ⟨r/a,by simp [smul_smul,ha]⟩ +omit [Fintype ι] in + +lemma independent_at_intersection (x v : ι → Fin 3 → K) + (hv : ∀ i, v i ≠ 0) (hd : Function.Injective (fun i => carrier (x i) (v i))) + (i j : ι) (hij : i ≠ j) (y : Fin 3 → K) + (hi : y ∈ carrier (x i) (v i)) (hj : y ∈ carrier (x j) (v j)) : + LinearIndependent K ![v i,v j] := by + rw [linearIndependent_fin2] + refine ⟨hv j,?_⟩ + intro a ha + have ha0 : a ≠ 0 := by intro h; subst a; simp only [zero_smul] at ha; exact hv i ha.symm + apply hij + apply hd + change carrier (x i) (v i) = carrier (x j) (v j) + change a • v j = v i at ha + rw [← rebase (x i) (v i) y hi,← rebase (x j) (v j) y hj,← ha,scale y (v j) a ha0] +omit [Fintype ι] in + +lemma intersection_subsingleton (x v : ι → Fin 3 → K) + (hv : ∀ i, v i ≠ 0) (hd : Function.Injective (fun i => carrier (x i) (v i))) + (i j : ι) (hij : i ≠ j) : + (carrier (x i) (v i) ∩ carrier (x j) (v j)).Subsingleton := by + intro y hy z hz + have hlin := independent_at_intersection x v hv hd i j hij y hy.1 hy.2 + have hzi : z ∈ carrier y (v i) := by rw [rebase (x i) (v i) y hy.1]; exact hz.1 + have hzj : z ∈ carrier y (v j) := by rw [rebase (x j) (v j) y hy.2]; exact hz.2 + obtain ⟨a,ha⟩ := hzi + obtain ⟨b,hb⟩ := hzj + have he : a • v i = b • v j := add_left_cancel (ha.trans hb.symm) + have hc := hlin.eq_coords_of_eq (f := ![a,0]) (g := ![0,b]) + (by simpa using he) 0 + have ha0 : a = 0 := hc + simpa [ha0] using ha +omit [Fintype ι] in + +lemma points_intersection_le [DecidableEq K] (x v : ι → Fin 3 → K) + (hv : ∀ i, v i ≠ 0) (hd : Function.Injective (fun i => carrier (x i) (v i))) + (A : ι → Finset (Fin 3 → K)) (hA : ∀ i, (A i : Set _) ⊆ carrier (x i) (v i)) + (i j : ι) (hij : i ≠ j) : (A i ∩ A j).card ≤ 1 := by + apply card_le_one.mpr + intro y hy z hz + exact intersection_subsingleton x v hv hd i j hij + ⟨hA i (mem_inter.mp hy).1,hA j (mem_inter.mp hy).2⟩ + ⟨hA i (mem_inter.mp hz).1,hA j (mem_inter.mp hz).2⟩ + +variable (x v : ι → Fin 3 → K) +def pencil (y : Fin 3 → K) : Finset ι := by + classical + exact univ.filter (fun i => y ∈ carrier (x i) (v i)) +def onLine (S : Finset (Fin 3 → K)) (i : ι) : Finset (Fin 3 → K) := by + classical + exact S.filter (fun y => y ∈ carrier (x i) (v i)) +def richPoints (S : Finset (Fin 3 → K)) (i : ι) : Finset (Fin 3 → K) := by + classical + exact (onLine x v S i).filter (fun y => 2 < (pencil x v y).card) +def poorPoints (S : Finset (Fin 3 → K)) (i : ι) : Finset (Fin 3 → K) := by + classical + exact (onLine x v S i).filter (fun y => (pencil x v y).card ≤ 2) + +lemma split_points (S : Finset (Fin 3 → K)) (i : ι) : + (richPoints x v S i).card+(poorPoints x v S i).card = (onLine x v S i).card := by + classical + simpa [richPoints,poorPoints,not_lt] using + card_filter_add_card_filter_not (s := onLine x v S i) (p := fun y => 2 < (pencil x v y).card) + +lemma poor_total (S : Finset (Fin 3 → K)) : + (∑ i, (poorPoints x v S i).card) ≤ 2*S.card := by + classical + have he : (∑ i, (poorPoints x v S i).card) = + ∑ y ∈ S, if (pencil x v y).card ≤ 2 then (pencil x v y).card else 0 := by + simp only [poorPoints,onLine,filter_filter] + simp only [card_filter] + rw [sum_comm] + apply sum_congr rfl + intro y hy + by_cases H : (pencil x v y).card ≤ 2 + · simp only [H,and_true,ite_true] + rw [show (pencil x v y).card = ∑ i, if y ∈ carrier (x i) (v i) then 1 else 0 by + simp only [pencil,card_filter]] + · simp only [H,and_false,ite_false,sum_const_zero] + rw [he] + calc + _ ≤ ∑ _y ∈ S, 2 := by + apply sum_le_sum + intro y hy + split_ifs with H + · exact H + · omega + _ = 2*S.card := by simp [Nat.mul_comm] + +theorem pruning_bound (S : Finset (Fin 3 → K)) (M D : ℕ) + (hM : ∀ i, M ≤ (onLine x v S i).card) : + let bad := Finset.univ.filter (fun i => (richPoints x v S i).card ≤ D) + bad.card*(M-D) ≤ 2*S.card := by + classical + dsimp only + calc + _ = ∑ i ∈ univ.filter (fun i => (richPoints x v S i).card ≤ D), (M-D) := by simp + _ ≤ ∑ i ∈ univ.filter (fun i => (richPoints x v S i).card ≤ D), (poorPoints x v S i).card := by + apply sum_le_sum + intro i hi + have h := (mem_filter.mp hi).2 + have hs := split_points x v S i + have hm := hM i + omega + _ ≤ ∑ i, (poorPoints x v S i).card := sum_le_sum_of_subset (filter_subset _ _) + _ ≤ 2*S.card := poor_total x v S + +end +end SharpLogRamsey.AffineIncidence + +end + +namespace SharpLogRamsey.NonplaneRichLines +open Finset MvPolynomial +open AffineIncidence +variable {K : Type*} [Field K] [Infinite K] +noncomputable section +omit [Infinite K] in + +lemma eval_of_restrict_zero (x v : Fin 3 → K) (F : MvPolynomial (Fin 3) K) + (h : LineFlatness.restrictLine x v F = 0) (y : Fin 3 → K) + (hy : y ∈ carrier x v) : eval y F = 0 := by + obtain ⟨t,rfl⟩ := hy + have H := congrArg (fun p : Polynomial K => p.eval t) h + rw [RichLinePolynomial.restriction_eval] at H + have he : (fun i => x i+v i*t) = x+t • v := by ext i; simp [mul_comm] + simpa only [he,Polynomial.eval_zero] using H + +lemma restrict_zero_rebase (x v y : Fin 3 → K) (F : MvPolynomial (Fin 3) K) + (h : LineFlatness.restrictLine x v F = 0) (hy : y ∈ carrier x v) : + LineFlatness.restrictLine y v F = 0 := by + apply Polynomial.funext + intro r + rw [RichLinePolynomial.restriction_eval,Polynomial.eval_zero] + apply eval_of_restrict_zero x v F h + rw [← rebase x v y hy] + exact ⟨r,by ext i; simp [mul_comm]⟩ + +variable {ι : Type*} [Fintype ι] + +lemma three_lines_at_rich (F : MvPolynomial (Fin 3) K) + (x v : ι → Fin 3 → K) (hv : ∀ i, v i ≠ 0) + (hd : Function.Injective (fun i => carrier (x i) (v i))) + (hF : ∀ i, LineFlatness.restrictLine (x i) (v i) F = 0) + (y : Fin 3 → K) (hy : 2 < (pencil x v y).card) : + ∃ w : Fin 3 → Fin 3 → K, + (∀ i, LineFlatness.restrictLine y (w i) F = 0) ∧ + LinearIndependent K ![w 0,w 1] ∧ LinearIndependent K ![w 0,w 2] ∧ + LinearIndependent K ![w 1,w 2] := by + classical + obtain ⟨a,b,c,ha,hb,hc,hab,hac,hbc⟩ := two_lt_card_iff.mp hy + have ha' : y ∈ carrier (x a) (v a) := (mem_filter.mp ha).2 + have hb' : y ∈ carrier (x b) (v b) := (mem_filter.mp hb).2 + have hc' : y ∈ carrier (x c) (v c) := (mem_filter.mp hc).2 + refine ⟨![v a,v b,v c],?_,?_,?_,?_⟩ + · intro i + fin_cases i + · exact restrict_zero_rebase (x a) (v a) y F (hF a) ha' + · exact restrict_zero_rebase (x b) (v b) y F (hF b) hb' + · exact restrict_zero_rebase (x c) (v c) y F (hF c) hc' + · exact independent_at_intersection x v hv hd a b hab y ha' hb' + · exact independent_at_intersection x v hv hd a c hac y ha' hc' + · exact independent_at_intersection x v hv hd b c hbc y hb' hc' +omit [Infinite K] in + +lemma many_parameters (x v : ι → Fin 3 → K) (hv : ∀ i, v i ≠ 0) + (S : Finset (Fin 3 → K)) (i : ι) : + ∃ T : Finset K, T.card = (richPoints x v S i).card ∧ + ∀ t ∈ T, 2 < (pencil x v (fun j => x i j+v i j*t)).card := by + classical + let f : K → Fin 3 → K := fun t => x i+t • v i + let T := (richPoints x v S i).preimage f (parametrization_injective _ _ (hv i)).injOn + refine ⟨T,?_,?_⟩ + · rw [card_preimage] + congr 1 + apply filter_eq_self.mpr + intro y hy + exact (mem_filter.mp (mem_filter.mp hy).1).2 + · intro t ht + have H := (mem_filter.mp (mem_preimage.mp ht)).2 + have he : f t = (fun j => x i j+v i j*t) := by ext j; simp [f,mul_comm] + simpa only [he] using H + +end +end SharpLogRamsey.NonplaneRichLines +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/VectorMap.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/VectorMap.lean new file mode 100644 index 0000000000000000000000000000000000000000..e3acc4b94b5445043d639b8befc0466536051be8 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/VectorMap.lean @@ -0,0 +1,458 @@ +import Mathlib + +namespace OAI + +/-! Incidence bounds for rich lines and finite point configurations. -/ + +section +section +namespace SharpLogRamsey.ProjectiveBaseChange +open scoped BigOperators +open Finset Classical +noncomputable section +variable {K E : Type*} [Field K] [Field E] [Algebra K E] {n : ℕ} +def vectorMap : (Fin n → K) →ₗ[K] (Fin n → E) where + toFun v i := algebraMap K E (v i) + map_add' x y := by ext i; simp + map_smul' c x := by ext i; simp [Algebra.smul_def] + +@[simp] lemma vectorMap_apply (v : Fin n → K) (i : Fin n) : + vectorMap (K := K) (E := E) v i = algebraMap K E (v i) := rfl + +lemma vectorMap_injective : Function.Injective (vectorMap (K := K) (E := E) (n := n)) := by + intro v w h + ext i + exact (algebraMap K E).injective (congrFun h i) + +def vectorSemi : (Fin n → K) →ₛₗ[algebraMap K E] (Fin n → E) where + toFun v i := algebraMap K E (v i) + map_add' x y := by ext i; simp + map_smul' c x := by ext i; simp + +@[simp] lemma vectorSemi_apply (v : Fin n → K) (i : Fin n) : + vectorSemi (K := K) (E := E) v i = algebraMap K E (v i) := rfl + +lemma vectorSemi_injective : Function.Injective (vectorSemi (K := K) (E := E) (n := n)) := + vectorMap_injective + +def pointMap : Projectivization K (Fin n → K) → Projectivization E (Fin n → E) := + Projectivization.map vectorSemi vectorSemi_injective + +lemma pointMap_injective : Function.Injective (pointMap (K := K) (E := E) (n := n)) := by + intro P Q h + induction P using Projectivization.ind with | h p hp => + induction Q using Projectivization.ind with | h q hq => + simp only [pointMap, Projectivization.map_mk, Projectivization.mk_eq_mk_iff'] at h ⊢ + obtain ⟨c,hc⟩ := h + obtain ⟨i,hi⟩ : ∃ i, q i ≠ 0 := by simpa only [ne_eq, funext_iff, Pi.zero_apply, not_forall] using hq + have hqi : algebraMap K E (q i) ≠ 0 := (map_ne_zero (algebraMap K E)).mpr hi + have hci : c = algebraMap K E (p i / q i) := by + have he := congrFun hc i + simp only [Pi.smul_apply, smul_eq_mul, vectorSemi_apply] at he + rw [map_div₀] + exact (eq_div_iff hqi).mpr he + refine ⟨p i / q i, ?_⟩ + ext j + apply (algebraMap K E).injective + have he := congrFun hc j + simpa only [hci, map_mul, Pi.smul_apply, smul_eq_mul, vectorSemi_apply] using he + +lemma coordinate_decomposition (v : Fin n → K) : + (∑ i, v i • Pi.single i (1 : K)) = v := by + ext j + simp [Finset.sum_apply, Pi.single_apply] + +def extendDual (f : (Fin n → K) →ₗ[K] K) : (Fin n → E) →ₗ[E] E := + ∑ i, algebraMap K E (f (Pi.single i 1)) • LinearMap.proj i + +lemma extendDual_map (f : (Fin n → K) →ₗ[K] K) (v : Fin n → K) : + extendDual (E := E) f (vectorMap v) = algebraMap K E (f v) := by + have hf : f v = ∑ i, v i*f (Pi.single i 1) := by + conv_lhs => rw [← coordinate_decomposition v] + simp + rw [hf, map_sum] + simp only [extendDual, LinearMap.sum_apply, LinearMap.smul_apply, LinearMap.proj_apply, + smul_eq_mul, vectorMap_apply, map_mul] + apply Finset.sum_congr rfl + intro i _ + ring + +def extendSpace (W : Submodule K (Fin n → K)) : Submodule E (Fin n → E) := + Submodule.span E (vectorMap '' (W : Set (Fin n → K))) + +theorem mem_extendSpace (W : Submodule K (Fin n → K)) (v : Fin n → K) : + vectorMap (E := E) v ∈ extendSpace (E := E) W ↔ v ∈ W := by + constructor + · intro hv + by_contra hn + obtain ⟨f,hf,hfW⟩ := W.exists_dual_map_eq_bot_of_notMem hn inferInstance + have hW : extendSpace (E := E) W ≤ LinearMap.ker (extendDual (E := E) f) := by + apply Submodule.span_le.mpr + rintro _ ⟨w,hw,rfl⟩ + change extendDual f (vectorMap w) = 0 + rw [extendDual_map] + have hh : f w = 0 := by + have hm : f w ∈ W.map f := Submodule.mem_map.mpr ⟨w,hw,rfl⟩ + simpa only [hfW, Submodule.mem_bot] using hm + simp [hh] + have he := hW hv + rw [LinearMap.mem_ker, extendDual_map] at he + exact hf ((algebraMap K E).injective (by simpa using he)) + · intro hv + exact Submodule.subset_span ⟨v,hv,rfl⟩ + +theorem rational_hyperplane (f : (Fin n → E) →ₗ[E] E) (hf : f ≠ 0) : + ∃ g : (Fin n → K) →ₗ[K] K, g ≠ 0 ∧ + ∀ v, f (vectorMap (K := K) v) = 0 → g v = 0 := by + have hex : ∃ i : Fin n, f (Pi.single i 1) ≠ 0 := by + by_contra! h + apply hf + apply LinearMap.ext + intro v + rw [← coordinate_decomposition v, map_sum] + simp [h] + obtain ⟨i,hi⟩ := hex + obtain ⟨z,hz⟩ := Module.Projective.exists_dual_ne_zero K hi + let g : (Fin n → K) →ₗ[K] K := z.comp ((f.restrictScalars K).comp vectorMap) + refine ⟨g, ?_, ?_⟩ + · intro hg + apply hz + have hh := LinearMap.congr_fun hg (Pi.single i 1) + have hsingle : vectorMap (K := K) (E := E) (Pi.single i 1) = Pi.single i 1 := by + ext j + by_cases hj : j = i <;> simp [vectorMap, hj] + change z (f (vectorMap (Pi.single i 1))) = 0 at hh + rw [hsingle] at hh + exact hh + · intro v hv + change z (f (vectorMap v)) = 0 + simp [hv] + +end +end SharpLogRamsey.ProjectiveBaseChange +end + +section + +namespace SharpLogRamsey.ProjectiveAffineChart +open scoped BigOperators +open Finset Classical +noncomputable section +variable {E : Type*} [Field E] {n : ℕ} + +def first (a : Fin n → E) : (Fin (n+1) → E) →ₗ[E] E := + LinearMap.proj 0 + ∑ i, a i • LinearMap.proj i.succ + +lemma first_apply (a : Fin n → E) (v : Fin (n+1) → E) : + first a v = v 0 + ∑ i, a i*v i.succ := by simp [first] + +def lift (a x : Fin n → E) : Fin (n+1) → E := + Fin.cons (1-∑ i, a i*x i) x + +@[simp] lemma lift_zero (a x : Fin n → E) : lift a x 0 = 1-∑ i, a i*x i := rfl +@[simp] lemma lift_succ (a x : Fin n → E) (i : Fin n) : lift a x i.succ = x i := rfl +@[simp] lemma first_lift (a x : Fin n → E) : first a (lift a x) = 1 := by + rw [first_apply] + simp + +lemma lift_ne_zero (a x : Fin n → E) : lift a x ≠ 0 := by + intro h + have hh := first_lift a x + rw [h, map_zero] at hh + exact zero_ne_one hh + +def chart (a : Fin n → E) (P : Projectivization E (Fin (n+1) → E)) : Fin n → E := + fun i => (first a P.rep)⁻¹ * P.rep i.succ + +lemma normalize_eq_lift (a : Fin n → E) (P : Projectivization E (Fin (n+1) → E)) + (hP : first a P.rep ≠ 0) : + (first a P.rep)⁻¹ • P.rep = lift a (chart a P) := by + ext i + refine Fin.cases ?_ (fun j => ?_) i + · change (first a P.rep)⁻¹ * P.rep 0 = 1-∑ j, a j*((first a P.rep)⁻¹*P.rep j.succ) + have ht : ∑ j, a j*((first a P.rep)⁻¹*P.rep j.succ) = + (first a P.rep)⁻¹ * ∑ j, a j*P.rep j.succ := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro j _ + ring + rw [ht] + have hh : (first a P.rep)⁻¹ * (P.rep 0 + ∑ j, a j*P.rep j.succ) = 1 := by + rw [← first_apply, inv_mul_cancel₀ hP] + linear_combination hh + · rfl + +lemma mk_lift_chart (a : Fin n → E) (P : Projectivization E (Fin (n+1) → E)) + (hP : first a P.rep ≠ 0) : + Projectivization.mk E (lift a (chart a P)) (lift_ne_zero _ _) = P := by + calc + _ = Projectivization.mk E P.rep P.rep_nonzero := by + apply (Projectivization.mk_eq_mk_iff' E _ _ _ _).mpr + exact ⟨(first a P.rep)⁻¹, normalize_eq_lift a P hP⟩ + _ = P := P.mk_rep + +lemma chart_injOn (a : Fin n → E) : + Set.InjOn (chart a) {P | first a P.rep ≠ 0} := by + intro P hP Q hQ he + rw [← mk_lift_chart a P hP, ← mk_lift_chart a Q hQ] + congr 1 + exact congrArg (lift a) he + +lemma lift_mem_iff (a : Fin n → E) (P : Projectivization E (Fin (n+1) → E)) + (hP : first a P.rep ≠ 0) (W : Submodule E (Fin (n+1) → E)) : + lift a (chart a P) ∈ W ↔ P.submodule ≤ W := by + have hp := congrArg Projectivization.submodule (mk_lift_chart a P hP) + rw [Projectivization.submodule_mk] at hp + rw [← hp, Submodule.span_singleton_le_iff_mem] + +theorem lift_mem_span_pair (a x y z : Fin n → E) : + lift a z ∈ Submodule.span E {lift a x, lift a y} ↔ + ∃ t : E, z = x+t • (y-x) := by + rw [Submodule.mem_span_pair] + constructor + · rintro ⟨u,v,hh⟩ + have huv := congrArg (first a) hh + simp only [map_add, map_smul, first_lift, smul_eq_mul, mul_one] at huv + refine ⟨v, ?_⟩ + ext i + have hi := congrFun hh i.succ + simp only [Pi.add_apply, Pi.smul_apply, lift_succ, smul_eq_mul] at hi ⊢ + simp only [Pi.sub_apply] + linear_combination -hi + x i * huv + · rintro ⟨t,rfl⟩ + refine ⟨1-t,t,?_⟩ + ext i + refine Fin.cases ?_ (fun j => ?_) i + · simp only [Pi.add_apply, Pi.smul_apply, lift_zero, smul_eq_mul] + simp only [Pi.sub_apply] + simp_rw [mul_add, mul_sub] + rw [Finset.sum_add_distrib, Finset.sum_sub_distrib] + have he : ∑ j, a j*(t*y j) = t*∑ j, a j*y j := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro j _ + ring + have hx : ∑ j, a j*(t*x j) = t*∑ j, a j*x j := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro j _ + ring + rw [he,hx] + ring + · simp only [Pi.add_apply, Pi.smul_apply, lift_succ, Pi.sub_apply, smul_eq_mul] + ring + +theorem exists_avoiding [Infinite E] (S : Finset (Projectivization E (Fin (n+1) → E))) : + ∃ a : Fin n → E, ∀ P ∈ S, first a P.rep ≠ 0 := by + classical + let F (v : Fin (n+1) → E) : MvPolynomial (Fin n) E := + MvPolynomial.C (v 0) + ∑ i, MvPolynomial.C (v i.succ)*MvPolynomial.X i + have hF (v : Fin (n+1) → E) (hv : v ≠ 0) : F v ≠ 0 := by + intro h + have h0 := congrArg (MvPolynomial.eval (fun _ => (0:E))) h + simp [F] at h0 + have hs (i : Fin n) : v i.succ = 0 := by + have hi := congrArg (MvPolynomial.eval (Pi.single i (1:E))) h + simpa [F, h0, Pi.single_apply] using hi + apply hv + ext i + exact Fin.cases h0 hs i + have hprod : (∏ P ∈ S, F P.rep) ≠ 0 := Finset.prod_ne_zero_iff.mpr (fun P _ => hF P.rep P.rep_nonzero) + have hex : ∃ a : Fin n → E, MvPolynomial.eval a (∏ P ∈ S, F P.rep) ≠ 0 := by + by_contra! hh + apply hprod + apply MvPolynomial.funext + intro a + simpa using hh a + obtain ⟨a,ha⟩ := hex + refine ⟨a, ?_⟩ + intro P hPS hP + apply ha + rw [map_prod] + apply Finset.prod_eq_zero hPS + simpa [F, first_apply, mul_comm] using hP + +end +end SharpLogRamsey.ProjectiveAffineChart +end + +section + +namespace SharpLogRamsey.AffinePlaneCoefficients +open scoped BigOperators +open MvPolynomial Finset Classical +noncomputable section +variable {E : Type*} [Field E] {n : ℕ} + +theorem degree_one_form (F : MvPolynomial (Fin n) E) (hF : F.totalDegree ≤ 1) : + F = C (F.coeff 0)+∑ i, C (F.coeff (Finsupp.single i 1))*X i := by + classical + apply MvPolynomial.ext + intro d + by_cases hd : d = 0 + · subst d + simp [coeff_C_mul, coeff_X] + by_cases hi : ∃ i, d = Finsupp.single i 1 + · obtain ⟨i,rfl⟩ := hi + simp only [AddMonoidAlgebra.coeff_add, Finsupp.add_apply, coeff_C, + ite_eq_right (Ne.symm hd), zero_add, coeff_sum, + coeff_C_mul, coeff_X] + have he (j : Fin n) : ((Finsupp.single j 1 : Fin n →₀ ℕ) = Finsupp.single i 1) ↔ j = i := + (Finsupp.single_left_injective (by decide : (1:ℕ) ≠ 0)).eq_iff + simp_rw [he] + simp + · have hc : F.coeff d = 0 := by + apply coeff_eq_zero_of_totalDegree_lt + have hdeg : d.sum (fun (_ : Fin n) k => k) ≠ 0 := by + exact fun hh => hd ((Finsupp.degree_eq_zero_iff d).mp hh) + have hne : d.sum (fun (_ : Fin n) k => k) ≠ 1 := by + exact fun hh => hi ((Finsupp.sum_eq_one_iff d).mp hh) + have hh : 1 < d.sum (fun (_ : Fin n) k => k) := by omega + exact hF.trans_lt hh + rw [hc] + simp only [AddMonoidAlgebra.coeff_add, Finsupp.add_apply, coeff_C, + ite_eq_right (Ne.symm hd), zero_add, coeff_sum, coeff_C_mul, coeff_X] + apply Eq.symm + apply Finset.sum_eq_zero + intro i _ + rw [ite_eq_right (fun hh => hi ⟨i,hh.symm⟩), mul_zero] + +lemma eval_degree_one (F : MvPolynomial (Fin n) E) (hF : F.totalDegree ≤ 1) + (x : Fin n → E) : + eval x F = F.coeff 0+∑ i, F.coeff (Finsupp.single i 1)*x i := by + conv_lhs => rw [degree_one_form F hF] + simp + +end +end SharpLogRamsey.AffinePlaneCoefficients +end + +section + +namespace SharpLogRamsey.RationalAffineChart +open scoped BigOperators +open Finset Classical +open SharpLogRamsey.ProjectiveBaseChange SharpLogRamsey.ProjectiveAffineChart +noncomputable section +variable {K E : Type*} [Field K] [Field E] [Algebra K E] {n : ℕ} + +lemma map_submodule (P : Projectivization K (Fin n → K)) : + (pointMap (E := E) P).submodule = Submodule.span E {vectorMap (E := E) P.rep} := by + conv_lhs => rw [← P.mk_rep] + simp only [pointMap, Projectivization.map_mk, Projectivization.submodule_mk] + rfl + +lemma map_submodule_le (P : Projectivization K (Fin n → K)) + (W : Submodule K (Fin n → K)) : + (pointMap (E := E) P).submodule ≤ extendSpace (E := E) W ↔ P.submodule ≤ W := by + rw [map_submodule, Submodule.span_singleton_le_iff_mem, mem_extendSpace, + Projectivization.submodule_eq, Submodule.span_singleton_le_iff_mem] + +abbrev coord (a : Fin n → E) (P : Projectivization K (Fin (n+1) → K)) : Fin n → E := + chart a (pointMap (E := E) P) + +def Avoids (a : Fin n → E) (P : Projectivization K (Fin (n+1) → K)) : Prop := + first a (pointMap (E := E) P).rep ≠ 0 + +lemma coord_injOn (a : Fin n → E) : Set.InjOn (coord (K := K) a) (Avoids (K := K) a) := by + intro P hP Q hQ hh + apply pointMap_injective (E := E) + exact chart_injOn a hP hQ hh + +lemma lift_coord_mem (a : Fin n → E) (P : Projectivization K (Fin (n+1) → K)) + (hP : Avoids a P) (W : Submodule K (Fin (n+1) → K)) : + lift a (coord a P) ∈ extendSpace (E := E) W ↔ P.submodule ≤ W := by + rw [lift_mem_iff a _ hP, map_submodule_le] + +lemma lift_coord_kernel (a : Fin n → E) (P : Projectivization K (Fin (n+1) → K)) + (hP : Avoids a P) (f : (Fin (n+1) → E) →ₗ[E] E) : + f (lift a (coord a P)) = 0 ↔ f (vectorMap (E := E) P.rep) = 0 := by + change lift a (coord a P) ∈ f.ker ↔ vectorMap (E := E) P.rep ∈ f.ker + rw [lift_mem_iff a _ hP, map_submodule, Submodule.span_singleton_le_iff_mem] + +lemma exists_avoiding [Infinite E] (S : Finset (Projectivization K (Fin (n+1) → K))) : + ∃ a : Fin n → E, ∀ P ∈ S, Avoids a P := by + classical + obtain ⟨a,ha⟩ := ProjectiveAffineChart.exists_avoiding (S.image (pointMap (E := E))) + exact ⟨a,fun P hP => ha _ (mem_image.mpr ⟨P,hP,rfl⟩)⟩ + +def homogeneousPlane (a : Fin n → E) (F : MvPolynomial (Fin n) E) : + (Fin (n+1) → E) →ₗ[E] E := + F.coeff 0 • first a + + ∑ i, F.coeff (Finsupp.single i 1) • LinearMap.proj i.succ + +lemma homogeneousPlane_lift (a x : Fin n → E) (F : MvPolynomial (Fin n) E) + (hF : F.totalDegree ≤ 1) : + homogeneousPlane a F (lift a x) = MvPolynomial.eval x F := by + rw [AffinePlaneCoefficients.eval_degree_one F hF] + simp [homogeneousPlane] + +lemma homogeneousPlane_ne_zero [Infinite E] (a : Fin n → E) (F : MvPolynomial (Fin n) E) + (hF : F.totalDegree = 1) : homogeneousPlane a F ≠ 0 := by + intro hh + have hpoly : F = 0 := by + apply MvPolynomial.funext + intro x + rw [← homogeneousPlane_lift a x F hF.le, hh] + simp + rw [hpoly, MvPolynomial.totalDegree_zero] at hF + exact Nat.zero_ne_one hF + +theorem plane_cap_transfer [Infinite E] + (S : Finset (Projectivization K (Fin (n+1) → K))) (a : Fin n → E) + (ha : ∀ P ∈ S, Avoids a P) (Kp : ℕ) + (hcap : ∀ g : (Fin (n+1) → K) →ₗ[K] K, g ≠ 0 → + (S.filter (fun P => g P.rep = 0)).card ≤ Kp) + (F : MvPolynomial (Fin n) E) (hF : F.totalDegree = 1) : + ((S.image (coord (K := K) a)).filter (fun x => MvPolynomial.eval x F = 0)).card ≤ Kp := by + classical + obtain ⟨g,hg,hfg⟩ := rational_hyperplane (K := K) (homogeneousPlane a F) (homogeneousPlane_ne_zero a F hF) + let Z := S.filter (fun P => g P.rep = 0) + have hsub : ((S.image (coord (K := K) a)).filter (fun x => MvPolynomial.eval x F = 0)) ⊆ + Z.image (coord (K := K) a) := by + intro x hx + obtain ⟨P,hPS,rfl⟩ := mem_image.mp (mem_filter.mp hx).1 + refine mem_image.mpr ⟨P,mem_filter.mpr ⟨hPS,?_⟩,rfl⟩ + apply hfg + apply (lift_coord_kernel a P (ha P hPS) _).mp + rw [homogeneousPlane_lift a _ F hF.le] + exact (mem_filter.mp hx).2 + exact (Finset.card_le_card hsub).trans ((Finset.card_image_le).trans (hcap g hg)) + +end +end SharpLogRamsey.RationalAffineChart +end + +section + +namespace SharpLogRamsey.ProjectiveLineChart +open scoped BigOperators +open Finset Classical +open SharpLogRamsey.ProjectiveBaseChange SharpLogRamsey.ProjectiveAffineChart + SharpLogRamsey.RationalAffineChart +noncomputable section +variable {K E : Type*} [Field K] [Field E] [Algebra K E] {n : ℕ} + +lemma extendSpace_span_pair (u v : Fin n → K) : + extendSpace (E := E) (Submodule.span K {u,v}) = + Submodule.span E {vectorMap (E := E) u, vectorMap (E := E) v} := by + apply le_antisymm + · apply Submodule.span_le.mpr + rintro _ ⟨w,hw,rfl⟩ + obtain ⟨a,b,rfl⟩ := Submodule.mem_span_pair.mp hw + apply Submodule.mem_span_pair.mpr + refine ⟨algebraMap K E a,algebraMap K E b,?_⟩ + ext i + simp [Algebra.smul_def] + · apply Submodule.span_le.mpr + intro w hw + rcases hw with rfl | rfl + · exact (mem_extendSpace _ _).mpr (Submodule.subset_span (Set.mem_insert _ _)) + · exact (mem_extendSpace _ _).mpr (Submodule.subset_span (Set.mem_insert_of_mem _ rfl)) + +end +end SharpLogRamsey.ProjectiveLineChart +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Geometry/Weight.lean b/lean/OAI/Combinatorics/SharpRamsey/Geometry/Weight.lean new file mode 100644 index 0000000000000000000000000000000000000000..e0fbea0e1cc5fe4aaabc383dbe479b1dd57766d0 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Geometry/Weight.lean @@ -0,0 +1,448 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.Card + +namespace OAI + +/-! Incidence bounds for rich lines and finite point configurations. -/ + +section +section +section +section +open scoped BigOperators Classical +open Finset +namespace SharpLogRamsey.Sampling +variable {V : Type*} [Fintype V] [DecidableEq V] +noncomputable def weight (p : ℝ) (f : V → Bool) : ℝ := + ∏ v, if f v then p else 1-p + +def selected (f : V → Bool) : Finset V := univ.filter (fun v => f v = true) +omit [DecidableEq V] in + +theorem mem_selected (f : V → Bool) (v : V) : v ∈ selected f ↔ f v = true := by + simp [selected] +omit [DecidableEq V] in + +theorem weight_nonneg {p : ℝ} (hp : 0 ≤ p) (hp1 : p ≤ 1) (f : V → Bool) : + 0 ≤ weight p f := by + apply prod_nonneg + intro v _ + split <;> linarith + +theorem sum_weight (p : ℝ) : ∑ f : V → Bool, weight p f = 1 := by + simp_rw [weight] + rw [← Fintype.prod_sum (fun (_v : V) (b : Bool) => if b then p else 1-p)] + simp + +theorem containment_moment (p : ℝ) (A : Finset V) : + (∑ f : V → Bool, weight p f * (if A ⊆ selected f then 1 else 0)) = p^A.card := by + have hi (f : V → Bool) : + (if A ⊆ selected f then (1 : ℝ) else 0) = + ∏ v : V, if v ∈ A then (if f v then 1 else 0) else 1 := by + by_cases h : A ⊆ selected f + · rw [ite_eq_left h] + symm + apply prod_eq_one + intro v _ + by_cases hv : v ∈ A + · simp [hv, (mem_selected f v).mp (h hv)] + · simp [hv] + · rw [ite_eq_right h] + obtain ⟨v, hv, hfv⟩ := not_subset.mp h + symm + apply prod_eq_zero (mem_univ v) + simp only [mem_selected, Bool.not_eq_true] at hfv + simp [hv, hfv] + simp_rw [hi, weight, ← prod_mul_distrib] + rw [← Fintype.prod_sum (fun (v : V) (b : Bool) => + (if b then p else 1-p) * (if v ∈ A then (if b then (1:ℝ) else 0) else 1))] + calc + _ = ∏ v : V, if v ∈ A then p else 1 := by + apply prod_congr rfl + intro v _ + by_cases hv : v ∈ A <;> simp [hv] + _ = p^A.card := by simp + +noncomputable def count (F : Finset (Finset V)) (S : Finset V) : ℕ := + (F.filter (· ⊆ S)).card + +theorem family_moment (p : ℝ) (F : Finset (Finset V)) {a : ℕ} + (hF : ∀ A ∈ F, A.card = a) : + (∑ f : V → Bool, weight p f * count F (selected f)) = p^a * F.card := by + have hc (S : Finset V) : (count F S : ℝ) = ∑ A ∈ F, if A ⊆ S then 1 else 0 := by + simp [count, sum_boole] + simp_rw [hc, mul_sum] + rw [sum_comm] + simp_rw [containment_moment] + rw [sum_congr rfl (fun A hA => by rw [hF A hA])] + simp [mul_comm] + +theorem size_moment (p : ℝ) : + (∑ f : V → Bool, weight p f * (selected f).card) = p * Fintype.card V := by + have hc (f : V → Bool) : ((selected f).card : ℝ) = + ∑ v : V, if ({v} : Finset V) ⊆ selected f then 1 else 0 := by + simp [selected, sum_boole] + simp_rw [hc, mul_sum] + rw [sum_comm] + simp_rw [containment_moment] + simp [mul_comm] + +theorem exists_ge_mean {p : ℝ} (hp : 0 ≤ p) (hp1 : p ≤ 1) + (X : (V → Bool) → ℝ) : ∃ f, (∑ g, weight p g * X g) ≤ X f := by + obtain ⟨f, _, hf⟩ := exists_max_image (univ : Finset (V → Bool)) X univ_nonempty + refine ⟨f, ?_⟩ + calc + (∑ g, weight p g * X g) ≤ ∑ g, weight p g * X f := by + exact sum_le_sum (fun g _ => mul_le_mul_of_nonneg_left (hf g (mem_univ g)) + (weight_nonneg hp hp1 g)) + _ = X f := by rw [← sum_mul, sum_weight, one_mul] + +end SharpLogRamsey.Sampling + +namespace SharpLogRamsey.RichSampling +open Sampling Finset +open scoped BigOperators +variable {V : Type*} [Fintype V] [DecidableEq V] +noncomputable section + +lemma moment (p b : ℝ) (A : Finset V) : + (∑ f : V → Bool, weight p f * b^(A ∩ selected f).card) = + (1-p+p*b)^A.card := by + have hi (f : V → Bool) : b^(A ∩ selected f).card = + ∏ v : V, if v ∈ A ∧ f v = true then b else 1 := by + rw [← prod_filter] + simp only [prod_const] + congr 2 + ext v + simp [selected] + simp_rw [hi,weight,← prod_mul_distrib] + rw [← Fintype.prod_sum (fun (v : V) (a : Bool) => + (if a then p else 1-p)*(if v ∈ A ∧ a = true then b else 1))] + calc + _ = ∏ v : V, if v ∈ A then 1-p+p*b else 1 := by + apply prod_congr rfl + intro v hv + by_cases H : v ∈ A <;> simp [H] ; ring + _ = _ := by simp + +lemma exp_neg_half_le : Real.exp (-(1/2:ℝ)) ≤ 2/3 := by + have h := Real.add_one_le_exp (1/2:ℝ) + have he : Real.exp (-(1/2:ℝ))*Real.exp (1/2:ℝ) = 1 := by rw [← Real.exp_add]; norm_num + have hm := mul_le_mul_of_nonneg_left h (Real.exp_pos (-(1/2:ℝ))).le + nlinarith + +lemma lower_tail (p M : ℝ) (hp : 0 ≤ p) (hp1 : p ≤ 1) + (A : Finset V) (hM : M ≤ A.card) : + (∑ f : V → Bool, weight p f * + (if ((A ∩ selected f).card : ℝ) ≤ p*M/2 then 1 else 0)) ≤ + Real.exp (-p*M/12) := by + have hpoint (f : V → Bool) : + (if ((A ∩ selected f).card : ℝ) ≤ p*M/2 then (1:ℝ) else 0) ≤ + Real.exp (p*M/4)*Real.exp (-(1/2:ℝ))^(A ∩ selected f).card := by + rw [← Real.exp_nat_mul,← Real.exp_add] + split_ifs with H + · rw [Real.one_le_exp_iff] + linarith + · exact (Real.exp_pos _).le + have hb0 : 0 ≤ 1-p+p*Real.exp (-(1/2:ℝ)) := + add_nonneg (by linarith) (mul_nonneg hp (Real.exp_pos _).le) + have hb : 1-p+p*Real.exp (-(1/2:ℝ)) ≤ Real.exp (-p/3) := by + have H := mul_le_mul_of_nonneg_left exp_neg_half_le hp + have E := Real.add_one_le_exp (-p/3) + linarith + calc + _ ≤ ∑ f : V → Bool, weight p f * + (Real.exp (p*M/4)*Real.exp (-(1/2:ℝ))^(A ∩ selected f).card) := + sum_le_sum (fun f hf => mul_le_mul_of_nonneg_left (hpoint f) (weight_nonneg hp hp1 f)) + _ = Real.exp (p*M/4)*(1-p+p*Real.exp (-(1/2:ℝ)))^A.card := by + rw [← moment p (Real.exp (-(1/2:ℝ))) A,mul_sum] + apply sum_congr rfl + intro f hf + ring + _ ≤ Real.exp (p*M/4)*(Real.exp (-p/3))^A.card := + mul_le_mul_of_nonneg_left (pow_le_pow_left₀ hb0 hb _) (Real.exp_pos _).le + _ = Real.exp (p*M/4+(A.card:ℝ)*(-p/3)) := by rw [Real.exp_add,Real.exp_nat_mul] + _ ≤ Real.exp (-p*M/12) := by + apply Real.exp_le_exp.mpr + nlinarith [mul_le_mul_of_nonneg_left hM hp] + +theorem exists_sample [Nonempty V] (p M : ℝ) (hp : 0 < p) (hp1 : p ≤ 1) + (L : Finset (Finset V)) (hM : ∀ A ∈ L, M ≤ A.card) + (hprob : (L.card:ℝ)*Real.exp (-p*M/12) < 1/2) : + ∃ S : Finset V, (S.card:ℝ) ≤ 2*p*Fintype.card V ∧ + ∀ A ∈ L, p*M/2 < ((A ∩ S).card:ℝ) := by + classical + let N : ℝ := Fintype.card V + have hN : 0 < N := by dsimp [N]; exact_mod_cast (Fintype.card_pos (α := V)) + let bad := fun f : V → Bool => ∑ A ∈ L, + if ((A ∩ selected f).card:ℝ) ≤ p*M/2 then (1:ℝ) else 0 + let X := fun f : V → Bool => ((selected f).card:ℝ)+2*p*N*bad f + have hb : (∑ f : V → Bool, weight p f*bad f) ≤ + L.card*Real.exp (-p*M/12) := by + simp only [bad,mul_sum] + rw [sum_comm] + calc + _ ≤ ∑ _A ∈ L, Real.exp (-p*M/12) := + sum_le_sum (fun A hA => lower_tail p M hp.le hp1 A (hM A hA)) + _ = _ := by simp + have hmean : (∑ f, weight p f*X f) < 2*p*N := by + have he : (∑ f, weight p f*X f) = p*N+2*p*N*(∑ f, weight p f*bad f) := by + simp only [X,mul_add,sum_add_distrib] + rw [size_moment,mul_sum] + congr 1 + apply sum_congr rfl + intro f hf + ring + rw [he] + have hlt := hb.trans_lt hprob + have hpos : 0 < p*N := mul_pos hp hN + nlinarith + obtain ⟨f,hf⟩ := exists_ge_mean hp.le hp1 (fun f => -X f) + simp only [mul_neg,Finset.sum_neg_distrib] at hf + have hX : X f < 2*p*N := by linarith + have hb0 : 0 ≤ bad f := by apply sum_nonneg; intro A hA; split_ifs <;> norm_num + refine ⟨selected f,?_,?_⟩ + · have hcoef : 0 ≤ 2*p*N := by positivity + change ((selected f).card:ℝ) ≤ 2*p*N + dsimp only [X] at hX + nlinarith [mul_nonneg hcoef hb0] + · intro A hA + by_contra H + have ha : ((A ∩ selected f).card:ℝ) ≤ p*M/2 := le_of_not_gt H + have hb1 : 1 ≤ bad f := by + have H := single_le_sum (s := L) (f := fun B => + if ((B ∩ selected f).card:ℝ) ≤ p*M/2 then (1:ℝ) else 0) + (fun B hB => by split_ifs <;> norm_num) hA + simpa only [ite_eq_left ha] using H + have hcoef : 0 ≤ 2*p*N := by positivity + have hcard : 0 ≤ ((selected f).card:ℝ) := Nat.cast_nonneg _ + dsimp only [X] at hX + nlinarith [mul_le_mul_of_nonneg_left hb1 hcoef] + +end +end SharpLogRamsey.RichSampling + +end + +section + +namespace SharpLogRamsey.Interpolation +open Finset MvPolynomial +open scoped BigOperators +variable {K : Type*} [Field K] +noncomputable section + +abbrev Box (n h : ℕ) := Fin n → Fin (h+1) +def exponent {n h : ℕ} (d : Box n h) : Fin n →₀ ℕ := + Finsupp.equivFunOnFinite.symm (fun i => (d i).val) + +lemma exponent_injective (n h : ℕ) : Function.Injective (exponent (n := n) (h := h)) := by + intro d e H + ext i + exact congrArg (fun f : Fin n →₀ ℕ => f i) H + +lemma exponent_degree_le {n h : ℕ} (d : Box n h) : (exponent d).degree ≤ n*h := by + change (exponent d).sum (fun _ e => e) ≤ n*h + rw [Finsupp.sum_fintype] + · calc + ∑ i, (exponent d) i ≤ ∑ _i : Fin n, h := by + apply sum_le_sum + intro i hi + exact Nat.le_of_lt_succ (d i).isLt + _ = n*h := by simp + · simp + +lemma monomials_independent (n h : ℕ) : + LinearIndependent K (fun d : Box n h => monomial (exponent d) (1:K)) := + (basisMonomials (Fin n) K).linearIndependent.comp exponent (exponent_injective n h) + +theorem exists_vanishing (n h : ℕ) (S : Finset (Fin n → K)) + (hS : S.card < (h+1)^n) : + ∃ F : MvPolynomial (Fin n) K, F ≠ 0 ∧ F.totalDegree ≤ n*h ∧ + ∀ x ∈ S, eval x F = 0 := by + classical + let v : Box n h → (S → K) := fun d x => eval x.val (monomial (exponent d) (1:K)) + have hn : ¬LinearIndependent K v := by + intro H + have H' := H.fintype_card_le_finrank + have he : Fintype.card (Box n h) = (h+1)^n := by simp [Box] + have hf : Module.finrank K (S → K) = S.card := by simp + rw [he,hf] at H' + omega + obtain ⟨c,hc,d,hd⟩ := Fintype.not_linearIndependent_iff.mp hn + refine ⟨∑ d, c d • monomial (exponent d) (1:K),?_,?_,?_⟩ + · intro H + exact hd ((Fintype.linearIndependent_iff.mp (monomials_independent (K := K) n h)) c H d) + · apply totalDegree_finsetSum_le + intro d hd + apply (totalDegree_smul_le _ _).trans + exact (totalDegree_monomial_le _ _).trans (exponent_degree_le d) + · intro x hx + have H := congrFun hc ⟨x,hx⟩ + simpa [v,Algebra.smul_def] using H + +end +end SharpLogRamsey.Interpolation + +end + +namespace SharpLogRamsey.SamplePolynomial +open Finset MvPolynomial AffineIncidence +open scoped BigOperators +variable {K V ι : Type*} [Field K] [Fintype V] [Nonempty V] [Fintype ι] +noncomputable section + +lemma degree_le_of_dvd {F G : MvPolynomial (Fin 3) K} (hF : F ≠ 0) (h : G ∣ F) : + G.totalDegree ≤ F.totalDegree := by + obtain ⟨H,rfl⟩ := h + have hG : G ≠ 0 := left_ne_zero_of_mul hF + have hH : H ≠ 0 := right_ne_zero_of_mul hF + rw [totalDegree_mul_of_isDomain hG hH] + omega + +omit [Fintype ι] in + +lemma squarefree_reduction (F : MvPolynomial (Fin 3) K) (hF : F ≠ 0) + (x v : ι → Fin 3 → K) (hzero : ∀ i, LineFlatness.restrictLine (x i) (v i) F = 0) : + ∃ G : MvPolynomial (Fin 3) K, G ≠ 0 ∧ Squarefree G ∧ + G.totalDegree ≤ F.totalDegree ∧ + ∀ i, LineFlatness.restrictLine (x i) (v i) G = 0 := by + obtain ⟨G,n,hG,hGF,hFG⟩ := exists_squarefree_dvd_pow_of_ne_zero hF + refine ⟨G,ne_zero_of_dvd_ne_zero hF hGF,hG,degree_le_of_dvd hF hGF,?_⟩ + intro i + have H := map_dvd (aeval (fun j => Polynomial.C (x i j)+Polynomial.C (v i j)*Polynomial.X)) hFG + change LineFlatness.restrictLine (x i) (v i) F ∣ + (aeval (fun j => Polynomial.C (x i j)+Polynomial.C (v i j)*Polynomial.X)) (G^n) at H + rw [hzero i,map_pow] at H + exact eq_zero_of_pow_eq_zero (zero_dvd_iff.mp H) + +theorem exists_polynomial (points : V → Fin 3 → K) (hinj : Function.Injective points) + (x v : ι → Fin 3 → K) (hv : ∀ i, v i ≠ 0) + (A : ι → Finset V) (hA : ∀ i a, a ∈ A i → points a ∈ carrier (x i) (v i)) + (p M : ℝ) (hp : 0 < p) (hp1 : p ≤ 1) (hM : ∀ i, M ≤ (A i).card) + (hprob : (Fintype.card ι:ℝ)*Real.exp (-p*M/12) < 1/2) + (h : ℕ) (hsize : 2*p*Fintype.card V < ((h+1)^3:ℕ)) (hdeg : (3*h:ℕ) ≤ p*M/2) : + ∃ F : MvPolynomial (Fin 3) K, F ≠ 0 ∧ Squarefree F ∧ F.totalDegree ≤ 3*h ∧ + ∀ i, LineFlatness.restrictLine (x i) (v i) F = 0 := by + classical + let L := univ.image A + have hL : (L.card:ℝ)*Real.exp (-p*M/12) < 1/2 := by + have hc : L.card ≤ Fintype.card ι := (card_image_le).trans_eq (card_univ) + exact (mul_le_mul_of_nonneg_right (by exact_mod_cast hc) (Real.exp_pos _).le).trans_lt hprob + obtain ⟨S,hS,hall⟩ := RichSampling.exists_sample p M hp hp1 L + (by intro B hB; obtain ⟨i,hi,rfl⟩ := mem_image.mp hB; exact hM i) hL + let T := S.image points + have hT : T.card < (h+1)^3 := by + have he : T.card = S.card := card_image_of_injective S hinj + rw [he] + exact_mod_cast hS.trans_lt hsize + obtain ⟨F,hF,hFd,hFT⟩ := Interpolation.exists_vanishing 3 h T hT + have hzero (i : ι) : LineFlatness.restrictLine (x i) (v i) F = 0 := by + let B := (A i ∩ S).image points + let f : K → Fin 3 → K := fun t => x i+t • v i + let R := B.preimage f (parametrization_injective _ _ (hv i)).injOn + have hR : R.card = (A i ∩ S).card := by + rw [card_preimage] + have he : B.filter (fun y => y ∈ Set.range f) = B := by + apply filter_eq_self.mpr + intro y hy + obtain ⟨a,ha,rfl⟩ := mem_image.mp hy + exact hA i a (mem_inter.mp ha).1 + rw [he,card_image_of_injective _ hinj] + have hr : F.totalDegree < R.card := by + rw [hR] + have H := (show (3*h:ℕ) ≤ p*M/2 from hdeg).trans_lt (hall (A i) (mem_image.mpr ⟨i,mem_univ i,rfl⟩)) + have H' : 3*h < (A i ∩ S).card := by exact_mod_cast H + exact hFd.trans_lt H' + apply RichLinePolynomial.restriction_zero_of_many (x i) (v i) F R hr + intro t ht + have H : f t ∈ B := mem_preimage.mp ht + obtain ⟨a,ha,he⟩ := mem_image.mp H + have he' : points a = (fun j => x i j+v i j*t) := by + rw [he] + ext j + simp [f,mul_comm] + rw [← he'] + exact hFT (points a) (mem_image.mpr ⟨a,(mem_inter.mp ha).2,rfl⟩) + obtain ⟨G,hG,hGs,hGd,hGz⟩ := squarefree_reduction F hF x v hzero + exact ⟨G,hG,hGs,hGd.trans hFd,hGz⟩ + +end +end SharpLogRamsey.SamplePolynomial + +end + +namespace SharpLogRamsey.RichAffineLines +open Finset MvPolynomial AffineIncidence +open scoped BigOperators Classical +variable {K ι : Type*} [Field K] [Infinite K] [IsAlgClosed K] [Fintype ι] +noncomputable section + +theorem card_mul_le {q : ℕ} [CharP K q] (h2 : (2:K) ≠ 0) + (S : Finset (Fin 3 → K)) (hS : S.Nonempty) + (x v : ι → Fin 3 → K) (hv : ∀ i, v i ≠ 0) + (hd : Function.Injective (fun i => carrier (x i) (v i))) + (M Kp h C : ℕ) (p : ℝ) (hp : 0 < p) (hp1 : p ≤ 1) + (hM : ∀ i, M ≤ (onLine x v S i).card) + (hcap : ∀ L : MvPolynomial (Fin 3) K, L.totalDegree = 1 → + (S.filter (fun y => eval y L = 0)).card ≤ Kp) + (hprob : (Fintype.card ι:ℝ)*Real.exp (-p*M/12) < 1/2) + (hsize : 2*p*S.card < ((h+1)^3:ℕ)) (hdeg : (3*h:ℕ) ≤ p*M/2) + (hchar : 3*h < q) (hMD : 18*h < M) (hKM : 8*Kp ≤ M^2) + (hD : h^2*M ≤ C*S.card) : + Fintype.card ι*M ≤ (6+72*C)*S.card := by + classical + let : Nonempty S := hS.to_subtype + let A : ι → Finset S := fun i => univ.filter (fun y => y.val ∈ carrier (x i) (v i)) + have hAc (i : ι) : (A i).card = (onLine x v S i).card := by + apply card_bij (fun y _ => y.val) + · intro y hy + exact mem_filter.mpr ⟨y.property,(mem_filter.mp hy).2⟩ + · intro a ha b hb H + exact Subtype.ext H + · intro y hy + exact ⟨⟨y,(mem_filter.mp hy).1⟩,mem_filter.mpr ⟨mem_univ _,(mem_filter.mp hy).2⟩,rfl⟩ + obtain ⟨F,hF,hFs,hFd,hFz⟩ := SamplePolynomial.exists_polynomial + (fun y : S => y.val) Subtype.val_injective x v hv A + (fun i y hy => (mem_filter.mp hy).2) p M hp hp1 + (fun i => by rw [Nat.cast_le]; rw [hAc i]; exact hM i) hprob h + (by simpa only [Fintype.card_coe] using hsize) hdeg + have H := SurfaceRichLines.card_le F hF (hFd.trans_lt hchar) hFs h2 + x v hv hd hFz S M Kp hM (fun L _ H => hcap L H) (by omega) hKM + have HM : 0 < M := by omega + have HM' : 0 < M-3*F.totalDegree := by omega + have HD' : M ≤ 2*(M-3*F.totalDegree) := by omega + have H1 : (2*S.card/M)*M ≤ 2*S.card := Nat.div_mul_le_self _ _ + have H2 : (2*S.card/(M-3*F.totalDegree))*M ≤ 4*S.card := by + calc + _ ≤ (2*S.card/(M-3*F.totalDegree))*(2*(M-3*F.totalDegree)) := Nat.mul_le_mul_left _ HD' + _ = 2*((2*S.card/(M-3*F.totalDegree))*(M-3*F.totalDegree)) := by ring + _ ≤ 2*(2*S.card) := Nat.mul_le_mul_left _ (Nat.div_mul_le_self _ _) + _ = _ := by ring + have H3 : 8*F.totalDegree^2*M ≤ 72*C*S.card := by + calc + _ ≤ 8*(3*h)^2*M := Nat.mul_le_mul_right M (Nat.mul_le_mul_left _ (Nat.pow_le_pow_left hFd _)) + _ = 72*(h^2*M) := by ring + _ ≤ 72*(C*S.card) := Nat.mul_le_mul_left _ hD + _ = _ := by ring + have HX := Nat.mul_le_mul_right M H + nlinarith + +end +end SharpLogRamsey.RichAffineLines +end + +section + +namespace SharpLogRamsey.ProjectiveBaseChange +open scoped BigOperators +open Finset Classical +noncomputable section +variable {K E : Type*} [Field K] [Field E] [Algebra K E] {n : ℕ} + +end +end SharpLogRamsey.ProjectiveBaseChange +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Learning/DescriptionHeaders.lean b/lean/OAI/Combinatorics/SharpRamsey/Learning/DescriptionHeaders.lean new file mode 100644 index 0000000000000000000000000000000000000000..b6301c78928d89a80726fa64bf32b173aeb67de9 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Learning/DescriptionHeaders.lean @@ -0,0 +1,97 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Spatial.SpatialCover +import OAI.Combinatorics.SharpRamsey.Spatial.SpatialPrepared + +namespace OAI + +section +namespace SharpLogRamsey.DescriptionHeaders +open Finset Real +open scoped Classical BigOperators +noncomputable section +variable {K V : Type*} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + +theorem card_submodule_le : + Nat.card (Submodule K V)≤(Nat.card K)^(Module.finrank K V)^2 := by + let : Finite V := Module.finite_of_finite K + let : Finite (V→ₗ[K]V) := Finite.of_injective DFunLike.coe DFunLike.coe_injective + have hs : Function.Surjective (LinearMap.range : (V→ₗ[K]V)→Submodule K V) := by + intro W + obtain ⟨Q,hQ⟩ := W.exists_isCompl + exact ⟨W.projection Q hQ,W.range_projection hQ⟩ + apply (Nat.card_le_card_of_surjective _ hs).trans_eq + let : Fintype K := Fintype.ofFinite K + let : Fintype (V→ₗ[K]V) := Fintype.ofFinite _ + simpa only [Nat.card_eq_fintype_card,Module.finrank_linearMap,pow_two] using + (Module.card_eq_pow_finrank (K:=K) (V:=V→ₗ[K]V)) + +variable {α : Type*} [Fintype α] + +def headers (J N : ℕ) : Finset (List (α×ℕ)) := + (range (J+1)).biUnion (fun m => + (univ : Finset (Fin m→α×Fin (N+1))).image + (fun v => List.ofFn (fun i => ((v i).1,((v i).2:ℕ))))) + +lemma mem_headers_iff (J N : ℕ) (bs : List (α×ℕ)) : + bs∈headers J N ↔ bs.length≤J ∧ ∀ h∈bs,h.2≤N := by + constructor + · intro hb + obtain ⟨m,hm,hv⟩ := mem_biUnion.mp hb + obtain ⟨v,_,rfl⟩ := mem_image.mp hv + constructor + · simpa only [List.length_ofFn] using Nat.le_of_lt_succ (mem_range.mp hm) + · intro h hh + obtain ⟨i,rfl⟩ := List.mem_ofFn.mp hh + exact Nat.le_of_lt_succ (v i).2.isLt + · rintro ⟨hlen,hsize⟩ + let v : Fin bs.length→α×Fin (N+1) := fun i => + ((bs.get i).1,⟨(bs.get i).2,Nat.lt_succ_of_le (hsize _ (List.get_mem _ _))⟩) + refine mem_biUnion.mpr ⟨bs.length,mem_range.mpr (by omega),mem_image.mpr ⟨v,mem_univ _,?_⟩⟩ + simpa only [v] using List.ofFn_get bs + +lemma card_headers_le (J N : ℕ) : + (headers (α:=α) J N).card≤(J+1)*(Fintype.card α*(N+1)+1)^J := by + apply (card_biUnion_le).trans + calc + _ ≤ ∑ m∈range (J+1),(Fintype.card α*(N+1))^m := by + apply sum_le_sum + intro m _ + exact (card_image_le).trans_eq (by simp) + _ ≤ ∑ _m∈range (J+1),(Fintype.card α*(N+1)+1)^J := by + apply sum_le_sum + intro m hm + exact (Nat.pow_le_pow_left (Nat.le_succ _) m).trans + (Nat.pow_le_pow_right (by omega) (Nat.le_of_lt_succ (mem_range.mp hm))) + _ = _ := by simp + +variable {X : Type*} [Fintype X] + +omit [Fintype α] [Fintype X] in +lemma sized_entries_le (S : Finset X) (U : α→Finset X) (bs : List α) : + ∀ h∈GreedyPreparation.sized S U bs,h.2≤S.card := by + induction bs generalizing S with + | nil => simp [GreedyPreparation.sized] + | cons b bs ih => + intro h hh + rcases List.mem_cons.mp hh with rfl|hh + · exact card_le_card inter_subset_left + · exact (ih _ _ hh).trans (card_le_card sdiff_subset) + +omit [Fintype X] in +lemma sized_header (S : Finset X) (U : α→Finset X) (bs : List α) (J N : ℕ) + (hJ : bs.length≤J) (hN : S.card≤N) : + GreedyPreparation.sized S U bs∈headers J N := by + apply (mem_headers_iff _ _ _).mpr + constructor + · have hh := congrArg List.length (GreedyPreparation.sized_planes S U bs) + simpa only [List.length_map] using hh.le.trans hJ + · intro h hh + exact (sized_entries_le S U bs h hh).trans hN + +end +end SharpLogRamsey.DescriptionHeaders + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Learning/EnumeratedCover.lean b/lean/OAI/Combinatorics/SharpRamsey/Learning/EnumeratedCover.lean new file mode 100644 index 0000000000000000000000000000000000000000..8c86cfa8285d35eede92646c01d1a4aedf5534b0 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Learning/EnumeratedCover.lean @@ -0,0 +1,63 @@ +import Mathlib + +namespace OAI + +section +namespace SharpLogRamsey.DescriptionEnumeration +open Finset Real +open scoped Classical BigOperators +noncomputable section +variable {α : Type*} + +lemma choose_exp_bound {N n : ℕ} (hn : 0 S + | b::bs => residual (S \ U b) U bs + +def cells (S : Finset α) (U : β → Finset α) : List β → List (Finset α) + | [] => [] + | b::bs => (S ∩ U b)::cells (S \ U b) U bs + +inductive Complete (F : Finset β) (U : β → Finset α) (m : ℕ) : Finset α → List β → Prop + | nil (S : Finset α) (h : ∀ b ∈ F, (S ∩ U b).card < m) : Complete F U m S [] + | cons (S : Finset α) (b : β) (bs : List β) (hb : b ∈ F) + (hrich : m ≤ (S ∩ U b).card) + (hmax : ∀ c ∈ F, (S ∩ U c).card ≤ (S ∩ U b).card) + (tail : Complete F U m (S \ U b) bs) : Complete F U m S (b::bs) + +theorem exists_complete (F : Finset β) (U : β → Finset α) (m : ℕ) (hm : 0 < m) + (S : Finset α) : ∃ bs, Complete F U m S bs := by + induction hn : S.card using Nat.strong_induction_on generalizing S with + | h n ih => + by_cases hall : ∀ b ∈ F, (S ∩ U b).card < m + · exact ⟨[],Complete.nil S hall⟩ + · have hex : ∃ c ∈ F, m ≤ (S ∩ U c).card := by + push Not at hall + exact hall + obtain ⟨c,hc,hcm⟩ := hex + obtain ⟨b,hb,hmax⟩ := exists_max_image F (fun b => (S ∩ U b).card) ⟨c,hc⟩ + have hrich := hcm.trans (hmax c hc) + have hsmall : (S \ U b).card < n := by + have he := card_sdiff_add_card_inter S (U b) + omega + obtain ⟨bs,hbs⟩ := ih (S \ U b).card hsmall (S \ U b) rfl + exact ⟨b::bs,Complete.cons S b bs hb hrich hmax hbs⟩ + +lemma residual_subset (S : Finset α) (U : β → Finset α) (bs : List β) : + residual S U bs ⊆ S := by + induction bs generalizing S with + | nil => exact subset_rfl + | cons b bs ih => exact (ih _).trans sdiff_subset + +lemma mem_cells_subset (S : Finset α) (U : β → Finset α) (bs : List β) + (C : Finset α) (hC : C ∈ cells S U bs) : C ⊆ S := by + induction bs generalizing S with + | nil => simp [cells] at hC + | cons b bs ih => + simp only [cells,List.mem_cons] at hC + rcases hC with rfl | hC + · exact inter_subset_left + · exact (ih _ hC).trans sdiff_subset + +lemma cells_length (S : Finset α) (U : β → Finset α) (bs : List β) : + (cells S U bs).length = bs.length := by + induction bs generalizing S with + | nil => rfl + | cons b bs ih => simp [cells,ih] + +theorem card_partition (S : Finset α) (U : β → Finset α) (bs : List β) : + ((cells S U bs).map Finset.card).sum + (residual S U bs).card = S.card := by + induction bs generalizing S with + | nil => simp [cells,residual] + | cons b bs ih => + simp only [cells,residual,List.map_cons,List.sum_cons] + have ht := ih (S \ U b) + have he := card_sdiff_add_card_inter S (U b) + omega + +lemma disjoint_cells (S : Finset α) (U : β → Finset α) (bs : List β) : + (cells S U bs).Pairwise Disjoint := by + induction bs generalizing S with + | nil => simp [cells] + | cons b bs ih => + rw [cells,List.pairwise_cons] + refine ⟨?_,ih _⟩ + intro C hC + have hc := mem_cells_subset (S \ U b) U bs C hC + apply disjoint_left.mpr + intro x hx hxc + exact (mem_sdiff.mp (hc hxc)).2 (mem_inter.mp hx).2 + +lemma complete_small_residual {F : Finset β} {U : β → Finset α} {m : ℕ} + {S : Finset α} {bs : List β} (h : Complete F U m S bs) : + ∀ b ∈ F, (residual S U bs ∩ U b).card < m := by + induction h with + | nil S ht => exact ht + | cons S b bs hb hrich hmax htail ih => exact ih + +lemma complete_length_bound {F : Finset β} {U : β → Finset α} {m : ℕ} + {S : Finset α} {bs : List β} (h : Complete F U m S bs) : + bs.length*m+(residual S U bs).card ≤ S.card := by + induction h with + | nil S ht => simp [residual] + | cons S b bs hb hrich hmax htail ih => + simp only [List.length_cons,Nat.add_mul,one_mul,residual] + have he := card_sdiff_add_card_inter S (U b) + omega + +lemma complete_cells_rich {F : Finset β} {U : β → Finset α} {m : ℕ} + {S : Finset α} {bs : List β} (h : Complete F U m S bs) : + ∀ C ∈ cells S U bs, m ≤ C.card := by + induction h with + | nil S ht => simp [cells] + | cons S b bs hb hrich hmax htail ih => + intro C hC + simp only [cells,List.mem_cons] at hC + rcases hC with rfl | hc + · exact hrich + · exact ih C hc + +lemma complete_cells_bounded {F : Finset β} {U : β → Finset α} {m : ℕ} + {S : Finset α} {bs : List β} (h : Complete F U m S bs) + (B : ℕ) (hB : ∀ b ∈ F, (S ∩ U b).card ≤ B) : + ∀ C ∈ cells S U bs, C.card ≤ B := by + induction h with + | nil S ht => simp [cells] + | cons S b bs hb hrich hmax htail ih => + intro C hC + simp only [cells,List.mem_cons] at hC + rcases hC with rfl | hc + · exact hB b hb + · apply ih (fun c hc => (card_le_card ?_).trans (hB c hc)) C hc + exact inter_subset_inter_right sdiff_subset + +theorem complete_nonincreasing {F : Finset β} {U : β → Finset α} {m : ℕ} + {S : Finset α} {bs : List β} (h : Complete F U m S bs) : + (cells S U bs).Pairwise (fun C D => D.card ≤ C.card) := by + induction h with + | nil S ht => simp [cells] + | cons S b bs hb hrich hmax htail ih => + rw [cells,List.pairwise_cons] + refine ⟨?_,ih⟩ + apply complete_cells_bounded htail + intro c hc + apply (card_le_card (inter_subset_inter_right (sdiff_subset (s:=S) (t:=U b)))).trans + exact hmax c hc + +end +end SharpLogRamsey.GreedyPreparation + +namespace SharpLogRamsey.GreedyPreparation +open Finset +open scoped Classical +noncomputable section +variable {α β : Type*} + +def removed (S : Finset α) (U : β → Finset α) (bs : List β) : Finset α := + S \ residual S U bs + +def own (S : Finset α) (U : β → Finset α) : List β → α → Finset α + | [], _ => ∅ + | b::bs, x => if x ∈ U b then S ∩ U b else own (S \ U b) U bs x + +lemma residual_eq (S : Finset α) (U : β → Finset α) (bs : List β) : + residual S U bs = S \ bs.toFinset.biUnion U := by + induction bs generalizing S with + | nil => simp [residual] + | cons b bs ih => + rw [residual,ih] + ext x + simp only [mem_sdiff,List.toFinset_cons,mem_biUnion,mem_insert] + aesop + +lemma removed_subset (S : Finset α) (U : β → Finset α) (bs : List β) : + removed S U bs ⊆ S := sdiff_subset + +lemma removed_eq (S : Finset α) (U : β → Finset α) (bs : List β) : + removed S U bs = S ∩ bs.toFinset.biUnion U := by + rw [removed,residual_eq] + ext x + simp only [mem_sdiff,mem_inter] + tauto + +lemma removed_cons (S : Finset α) (U : β → Finset α) (b : β) (bs : List β) : + removed S U (b::bs) = (S ∩ U b) ∪ removed (S \ U b) U bs := by + simp only [removed_eq,List.toFinset_cons,biUnion_insert] + ext x + simp only [mem_union,mem_inter,mem_sdiff] + tauto + +lemma cell_subset_removed (S : Finset α) (U : β → Finset α) (bs : List β) + (C : Finset α) (hC : C ∈ cells S U bs) : C ⊆ removed S U bs := by + induction bs generalizing S with + | nil => simp [cells] at hC + | cons b bs ih => + rw [removed_cons] + simp only [cells,List.mem_cons] at hC + rcases hC with rfl | hc + · exact subset_union_left + · exact (ih _ hc).trans subset_union_right + +lemma own_empty_or_cell (S : Finset α) (U : β → Finset α) (bs : List β) (x : α) : + own S U bs x = ∅ ∨ own S U bs x ∈ cells S U bs := by + induction bs generalizing S with + | nil => exact Or.inl rfl + | cons b bs ih => + rw [own] + split_ifs with hx + · exact Or.inr (by simp [cells]) + · rcases ih (S \ U b) with hh | hh + · exact Or.inl hh + · exact Or.inr (by simp only [cells,List.mem_cons]; exact Or.inr hh) + +lemma own_subset_removed (S : Finset α) (U : β → Finset α) (bs : List β) (x : α) : + own S U bs x ⊆ removed S U bs := by + rcases own_empty_or_cell S U bs x with hh | hh + · rw [hh]; exact empty_subset _ + · exact cell_subset_removed S U bs _ hh + +lemma own_card_le (S : Finset α) (U : β → Finset α) (bs : List β) (x : α) + (B : ℕ) (hB : ∀ C ∈ cells S U bs, C.card ≤ B) : + (own S U bs x).card ≤ B := by + rcases own_empty_or_cell S U bs x with hh | hh + · simp [hh] + · exact hB _ hh + +lemma removed_card (S : Finset α) (U : β → Finset α) (bs : List β) : + (removed S U bs).card + (residual S U bs).card = S.card := + card_sdiff_add_card_eq_card (residual_subset S U bs) + +lemma removed_card_eq_sum (S : Finset α) (U : β → Finset α) (bs : List β) : + (removed S U bs).card = ((cells S U bs).map Finset.card).sum := by + have h := removed_card S U bs + have h' := card_partition S U bs + omega + +theorem preparation (F : Finset β) (U : β → Finset α) (m : ℕ) (hm : 0 < m) + (S : Finset α) : + (∃ S' : Finset α, S' ⊆ S ∧ S.card ≤ 2*S'.card ∧ + ∀ b ∈ F, (S' ∩ U b).card < m) ∨ + (∃ bs : List β, Complete F U m S bs ∧ S.card ≤ 2*(removed S U bs).card ∧ + bs.length*m ≤ S.card ∧ + (cells S U bs).Pairwise (fun C D => D.card ≤ C.card)) := by + obtain ⟨bs,hbs⟩ := exists_complete F U m hm S + by_cases hh : S.card ≤ 2*(removed S U bs).card + · refine Or.inr ⟨bs,hbs,hh,?_,complete_nonincreasing hbs⟩ + have := complete_length_bound hbs + omega + · refine Or.inl ⟨residual S U bs,residual_subset S U bs,?_,complete_small_residual hbs⟩ + have := removed_card S U bs + omega + +lemma removed_inter_card_le (S : Finset α) (U : β → Finset α) (bs : List β) + (L : Finset α) (hL : ∀ b ∈ bs, (U b ∩ L).card ≤ 1) : + (removed S U bs ∩ L).card ≤ bs.length := by + induction bs generalizing S with + | nil => simp [removed,residual] + | cons b bs ih => + rw [removed_cons,union_inter_distrib_right] + apply (card_union_le _ _).trans + have h1 : (S ∩ U b ∩ L).card ≤ 1 := + (card_le_card (inter_subset_inter_right inter_subset_right)).trans (hL b (by simp)) + have h2 := ih (S \ U b) (fun c hc => hL c (by simp [hc])) + simpa only [List.length_cons] using Nat.add_le_add h1 h2 |>.trans_eq (Nat.add_comm 1 bs.length) + +lemma outside_first_inter_empty (S : Finset α) (U : β → Finset α) (b : β) + (bs : List β) (L : Finset α) (hL : L ⊆ U b) (x : α) (hx : x ∈ L) : + ((removed S U (b::bs) \ own S U (b::bs) x) ∩ L) = ∅ := by + rw [own,ite_eq_left (hL hx),removed_cons] + apply eq_empty_iff_forall_notMem.mpr + intro y hy + obtain ⟨hy,hyL⟩ := mem_inter.mp hy + obtain ⟨hy,hyn⟩ := mem_sdiff.mp hy + rcases mem_union.mp hy with hh | hh + · exact hyn hh + · have hyS := removed_subset (S \ U b) U bs hh + exact (mem_sdiff.mp hyS).2 (hL hyL) + +lemma outside_inter_prefix (S : Finset α) (U : β → Finset α) (pre : List β) + (b : β) (post : List β) (L : Finset α) (hL : L ⊆ U b) + (x : α) (hx : x ∈ L) (hpre : ∀ c ∈ pre, x ∉ U c) + (hline : ∀ c ∈ pre, (U c ∩ L).card ≤ 1) : + ((removed S U (pre ++ b::post) \ own S U (pre ++ b::post) x) ∩ L).card ≤ pre.length := by + induction pre generalizing S with + | nil => simp only [List.nil_append,outside_first_inter_empty S U b post L hL x hx,card_empty,List.length_nil] + exact le_rfl + | cons c pre ih => + simp only [List.cons_append,own,ite_eq_right (hpre c (by simp))] + rw [removed_cons] + have hsubset : (((S ∩ U c) ∪ removed (S \ U c) U (pre ++ b::post)) \ + own (S \ U c) U (pre ++ b::post) x) ∩ L ⊆ + (S ∩ U c ∩ L) ∪ ((removed (S \ U c) U (pre ++ b::post) \ + own (S \ U c) U (pre ++ b::post) x) ∩ L) := by + intro y hy + simp only [mem_inter,mem_union,mem_sdiff] at hy ⊢ + tauto + apply (card_le_card hsubset).trans ((card_union_le _ _).trans ?_) + have h1 : (S ∩ U c ∩ L).card ≤ 1 := + (card_le_card (inter_subset_inter_right inter_subset_right)).trans (hline c (by simp)) + have h2 := ih (S \ U c) (fun e he => hpre e (by simp [he])) + (fun e he => hline e (by simp [he])) + simp only [List.length_cons] + omega + +end +end SharpLogRamsey.GreedyPreparation + +namespace SharpLogRamsey.GreedyPreparation +open Finset +open scoped Classical BigOperators +noncomputable section +variable {α β : Type*} + +lemma residual_append (S : Finset α) (U : β → Finset α) (a b : List β) : + residual S U (a++b) = residual (residual S U a) U b := by + induction a generalizing S with + | nil => rfl + | cons x xs ih => simpa only [List.cons_append,residual] using ih (S \ U x) + +lemma residual_nil (S : Finset α) (U : β → Finset α) : residual S U [] = S := rfl + +lemma removed_append (S : Finset α) (U : β → Finset α) (a b : List β) : + removed S U (a++b) = removed S U a ∪ removed (residual S U a) U b := by + rw [removed,residual_append,removed,removed] + have h1 := residual_subset S U a + have h2 := residual_subset (residual S U a) U b + ext x + simp only [mem_sdiff,mem_union] + constructor + · intro hx + by_cases hr : x ∈ residual S U a + · exact Or.inr ⟨hr,hx.2⟩ + · exact Or.inl ⟨hx.1,hr⟩ + · rintro (hx|hx) + · exact ⟨hx.1,fun hn => hx.2 (h2 hn)⟩ + · exact ⟨h1 hx.1,hx.2⟩ + +lemma own_append (S : Finset α) (U : β → Finset α) (a b : List β) (x : α) + (ha : ∀ c ∈ a, x ∉ U c) : own S U (a++b) x = own (residual S U a) U b x := by + induction a generalizing S with + | nil => rfl + | cons c cs ih => + simp only [List.cons_append,own,ite_eq_right (ha c (by simp)),residual] + exact ih (S \ U c) (fun d hd => ha d (by simp [hd])) + +lemma cells_get (S : Finset α) (U : β → Finset α) (bs : List β) + (i : ℕ) (hi : i < bs.length) : + (cells S U bs)[i]'(by rw [cells_length]; exact hi) = + residual S U (bs.take i) ∩ U bs[i] := by + induction bs generalizing S i with + | nil => simp at hi + | cons b bs ih => + cases i with + | zero => rfl + | succ i => + simp only [cells,List.getElem_cons_succ,List.take_succ_cons,residual] + exact ih (S \ U b) i (by simpa using hi) + +def indexedCell (S : Finset α) (U : β → Finset α) (bs : List β) + (i : Fin bs.length) : Finset α := residual S U (bs.take i.val) ∩ U bs[i.val] + +lemma indexedCell_eq (S : Finset α) (U : β → Finset α) (bs : List β) + (i : Fin bs.length) : indexedCell S U bs i = + (cells S U bs)[i.val]'(by rw [cells_length]; exact i.isLt) := + (cells_get S U bs i.val i.isLt).symm + +lemma indexedCell_antitone {F : Finset β} {U : β → Finset α} {m : ℕ} + {S : Finset α} {bs : List β} (h : Complete F U m S bs) : + Antitone (fun i : Fin bs.length => (indexedCell S U bs i).card) := by + intro i j hij + change (indexedCell S U bs j).card ≤ (indexedCell S U bs i).card + rw [indexedCell_eq,indexedCell_eq] + by_cases he : i = j + · subst j; exact le_rfl + · have hlt : i.val < j.val := by + have hne : i.val ≠ j.val := fun hh => he (Fin.ext hh) + exact lt_of_le_of_ne hij hne + exact (List.pairwise_iff_getElem.mp (complete_nonincreasing h)) + i.val j.val (by rw [cells_length]; exact i.isLt) + (by rw [cells_length]; exact j.isLt) hlt + +lemma indexedCell_sum (S : Finset α) (U : β → Finset α) (bs : List β) : + ∑ i : Fin bs.length, (indexedCell S U bs i).card = (removed S U bs).card := by + rw [removed_card_eq_sum] + induction bs generalizing S with + | nil => simp [cells] + | cons b bs ih => + change (∑ i : Fin (bs.length+1), (indexedCell S U (b::bs) i).card) = _ + rw [Fin.sum_univ_succ] + simp only [indexedCell,Fin.val_zero,List.take_zero,residual,List.getElem_cons_zero, + Fin.val_succ,List.take_succ_cons,List.getElem_cons_succ,cells,List.map_cons,List.sum_cons] + congr 1 + exact ih (S \ U b) + +lemma residual_after_first_disjoint (S : Finset α) (U : β → Finset α) + (b : β) (post : List β) (L : Finset α) (hL : L ⊆ U b) : + Disjoint (removed (S \ U b) U post) L := by + apply disjoint_left.mpr + intro x hx hxL + exact (mem_sdiff.mp (removed_subset (S \ U b) U post hx)).2 (hL hxL) + +lemma removed_line_le_prefix_cell (S : Finset α) (U : β → Finset α) + (pre : List β) (b : β) (post : List β) (L : Finset α) (hL : L ⊆ U b) + (hpre : ∀ c ∈ pre, (U c ∩ L).card ≤ 1) : + (removed S U (pre++b::post) ∩ L).card ≤ + pre.length + (residual S U pre ∩ U b ∩ L).card := by + rw [removed_append,removed_cons,union_inter_distrib_right, + union_inter_distrib_right] + have he : removed (residual S U pre \ U b) U post ∩ L = ∅ := + disjoint_iff_inter_eq_empty.mp (residual_after_first_disjoint _ U b post L hL) + rw [he,union_empty] + exact (card_union_le _ _).trans (Nat.add_le_add_right + (removed_inter_card_le S U pre L hpre) _) + +lemma first_containing (U : β → Finset α) (bs : List β) (L : Finset α) + (hex : ∃ b ∈ bs, L ⊆ U b) : + ∃ pre b post, bs=pre++b::post ∧ L ⊆ U b ∧ ∀ c ∈ pre, ¬ L ⊆ U c := by + induction bs with + | nil => simp at hex + | cons b bs ih => + by_cases hb : L ⊆ U b + · exact ⟨[],b,bs,rfl,hb,by simp⟩ + · have hex' : ∃ c ∈ bs, L ⊆ U c := by + obtain ⟨c,hc,hcL⟩ := hex + simp only [List.mem_cons] at hc + rcases hc with rfl | hc + · exact (hb hcL).elim + · exact ⟨c,hc,hcL⟩ + obtain ⟨pre,c,post,he,hc,hpre⟩ := ih hex' + refine ⟨b::pre,c,post,by simp [he],hc,?_⟩ + intro d hd + simp only [List.mem_cons] at hd + rcases hd with rfl | hd + · exact hb + · exact hpre d hd + +end +end SharpLogRamsey.GreedyPreparation + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Learning/HighRankPrepared.lean b/lean/OAI/Combinatorics/SharpRamsey/Learning/HighRankPrepared.lean new file mode 100644 index 0000000000000000000000000000000000000000..741a60c8254ba3bca5a0bf9398fa2b48ab5cbf9f --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Learning/HighRankPrepared.lean @@ -0,0 +1,110 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.HighRankReplacement +import OAI.Combinatorics.SharpRamsey.Windows.GoodPopulation +import OAI.Combinatorics.SharpRamsey.Reciprocal.PreparedReciprocal +import OAI.Combinatorics.SharpRamsey.Marking.HighRankConflict + +namespace OAI + +section +namespace SharpLogRamsey.Selection.Windows +open Finset Real Filter ExposureModel ActualHighRank HighRankBudgets +open scoped Classical BigOperators Topology +noncomputable section +local instance flat_ActualHighRankPrepared_1 (w : ℕ) : DecidableEq (Block w) := Classical.decEq _ + +local instance flat_ActualHighRankPrepared_2 {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Fin (d+1)→K)) := + Finite.of_injective ((↑) : Module.Dual K (Fin (d+1)→K)→((Fin (d+1)→K)→K)) DFunLike.coe_injective +local instance flat_ActualHighRankPrepared_3 {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Fin (d+1)→K)) := Fintype.ofFinite _ +local instance flat_ActualHighRankPrepared_4 {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Fin (d+1)→K))) := Fintype.ofFinite _ + +theorem eventually_prepared_high {η : ℝ} (hη : 0<η) (d : ℕ) (hd : 2≤d) : + ∀ᶠ σ : ℝ in atTop, ∀ (K Ω Θ : Type) [Field K] [Fintype K] [Fintype Ω] [Fintype Θ], + log (Nat.card K:ℝ)=σ → + ∀ (w n k : ℕ) (p : Law Ω) (θ : Ω→Θ) + (G : Ω→Slot w (n+k)→Projectivization K (Module.Dual K (Fin (d+1)→K))×Projectivization K (Fin (d+1)→K)) + (S : Θ→Slot w (n+k)→Finset (Projectivization K (Module.Dual K (Fin (d+1)→K))×Projectivization K (Fin (d+1)→K))) + (D J : ℝ) (r r' : ℕ), σ^beta η≤D → D≤σ^(1-η/2) → (d:ℝ)*σ≤J → + 2≤r → r≤d → d+2≤r+r' → + (∀ ω,p.mass ω≠0→∀ i,G ω i∈S (θ ω) i) → + (∀ ω,p.mass ω≠0→∀ i,(G ω i).1.rep (G ω i).2.rep=0) → + (∀ ω,p.mass ω≠0→∀ i j,position i0) J (D*σ^beta η) a z.2 + M.representative z (i,false)∉bad → + 0<(goodMiddle w n k p θ G t z bad i).card → + Nonempty (Replacement q (fun y j=>y (goodTarget w n k p θ G t z bad i j)) + (fun code=>rawDomain (h:=rawRows σ η) code r (rawThreshold σ η)) + (highPrefactor d*(Nat.card K:ℝ)^d*exp (((d:ℝ)+1)*scaleK σ η D)) + (4*(rawRows σ η:ℝ)*(log 2+(d:ℝ)*σ))) := by + filter_upwards [eventually_replacement hη d hd] with σ he + intro K Ω Θ _ _ _ _ hlog w n k p θ G S D J r r' hDl hDu hJ hr hrd hrr hS hf hcon hcap t hp z hz i + dsimp only + let M:=model w n k p θ G t + let q:=M.tupleLaw z.1 + let a:=σ^(-2000*beta η)/(Nat.card K:ℝ) + let bad:=badIndices q (M.embedding z.1) (M.owner z.1) (fun _ _=>0) J (D*σ^beta η) a z.2 + let rep:=M.representative z (i,false) + let T:=goodTarget w n k p θ G t z bad i + intro hrep hlen + have hc:=prepared_context_property n k p θ G (fun _=>embedding w (n+k)) + (fun _=>owner w (n+k)) t hp z hz (fun θ=>∀ i,Caps σ r r' (S θ i)) hcap + have entropy_good j (hj : j∉bad) : (d:ℝ)*σ-entropy (q.marginal j)≤D*σ^beta η := by + have hh:=((not_badIndices q (M.embedding z.1) (M.owner z.1) + (fun _ _=>0) J (D*σ^beta η) a z.2 j).mp hj).1 + exact (sub_le_sub_right hJ _).trans hh + have targetgood j : T j∉bad := goodTarget_not_bad w n k p θ G t z bad i j + have targetbefore j : position (M.origin z.1 rep)embedding w (n+k)) (fun _=>owner w (n+k)) t hp z hz y hy + apply he K _ hlog _ hlen (q.marginal rep) (S z.1.1 (M.origin z.1 rep)) q + (fun y j=>y (T j)) (fun j=>S z.1.1 (M.origin z.1 (T j))) D hDl hDu r r' hr hrd hrr + · exact prepared_marginal_domain n k p θ G (fun _=>embedding w (n+k)) + (fun _=>owner w (n+k)) t hp z hz S hS rep + · exact hc _ + · exact entropy_good rep hrep + · intro y hy j + obtain ⟨ω,hω,hθ,hG⟩:=hsrc y hy + have hvalue : G ω (M.origin z.1 (T j))=y (T j) := hG (T j) + simpa only [hθ,hvalue] using hS ω hω (M.origin z.1 (T j)) + · intro y hy j + obtain ⟨ω,hω,hθ,hG⟩:=hsrc y hy + have hvalue : G ω (M.origin z.1 (T j))=y (T j) := hG (T j) + simpa only [hvalue] using hf ω hω (M.origin z.1 (T j)) + · intro j + exact hc _ + · intro j + exact entropy_good (T j) (targetgood j) + · intro j + have hi : (pairInformation q rep (T j):ℝ)≤a := by + have hh:=good_charge_reversed q (M.embedding z.1) (M.owner z.1) + (fun _ _=>0) (by simp) J (D*σ^beta η) a z.2 (T j) rep (targetgood j) + (target_other w n k p θ G t z (i,false) i + ((goodMiddle w n k p θ G t z bad i).orderEmbOfFin rfl j)) + simpa only [NNReal.coe_zero,add_zero] using hh + have hh:=high_original_conflict q rep (T j) (by + intro y hy hzero + obtain ⟨ω,hω,hθ,hG⟩:=hsrc y hy + have hc':=hcon ω hω (M.origin z.1 rep) (M.origin z.1 (T j)) (targetbefore j) + rw [hG,hG] at hc' + exact hc' hzero) + exact hh.trans (by + calc + 2*(pairInformation q rep (T j):ℝ) ≤ 2*a := mul_le_mul_of_nonneg_left hi (by norm_num) + _ = _ := by dsimp [a]; ring) + +end +end SharpLogRamsey.Selection.Windows + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Learning/LearningScalar.lean b/lean/OAI/Combinatorics/SharpRamsey/Learning/LearningScalar.lean new file mode 100644 index 0000000000000000000000000000000000000000..7ce4d83bb36cb00a96086a3a9769ea641c5d0446 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Learning/LearningScalar.lean @@ -0,0 +1,169 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Parameters.SourceTrainingScales + +namespace OAI + +section +namespace SharpLogRamsey.LearningScalar +open Real +noncomputable section + +lemma power_ratio_bound {B t P c : ℝ} (p : ℕ) (hB : 0≤B) (ht : 0 ω i) = ω := by + funext i + by_cases hi : i∈S + · simp [extend,hi] + · simp [extend,hi,hω i hi] + +omit [Fintype ι] in +lemma restrict_extend (S : Finset ι) (ω : S → ℕ) : + (fun i : S => extend S ω i)=ω := by + funext i + simp [extend,i.2] + +theorem extend_hasLaw (S : Finset ι) (rate : ι → ℝ≥0) : + HasLaw (extend S) (Measure.pi (fun i => poissonMeasure (if i∈S then rate i else 0))) + (Measure.pi (fun i : S => poissonMeasure (rate i))) := by + refine ⟨(measurable_of_countable _).aemeasurable,?_⟩ + apply Measure.ext_of_singleton + intro z + rw [Measure.map_apply (measurable_of_countable _) (measurableSet_singleton z)] + by_cases hz : ∀ i,i∉S → z i=0 + · have he : extend S ⁻¹' {z}={fun i : S => z i} := by + ext ω + simp only [Set.mem_preimage,Set.mem_singleton_iff] + constructor + · intro h + calc + ω = fun i : S => extend S ω i := (restrict_extend S ω).symm + _ = fun i : S => z i := by rw [h] + · rintro rfl + exact extend_restrict S z hz + rw [he,Measure.pi_singleton,Measure.pi_singleton] + calc + _ = ∏ i ∈ S, poissonMeasure (rate i) {z i} := + prod_coe_sort S (fun i => poissonMeasure (rate i) {z i}) + _ = ∏ i ∈ S, poissonMeasure (if i∈S then rate i else 0) {z i} := by + apply prod_congr rfl + intro i hi + rw [ite_eq_left hi] + _ = _ := prod_subset (subset_univ S) (fun i _ hi => by + simp only [ite_eq_right hi,hz i hi,poissonMeasure_singleton] + norm_num) + · obtain ⟨i,hiS,hzi⟩ := not_forall.mp hz |>.imp (fun i h => by simpa using h) + have he : extend S ⁻¹' {z}=∅ := by + apply Set.eq_empty_iff_forall_notMem.mpr + intro ω hω + have hh := congrFun (Set.mem_singleton_iff.mp hω) i + exact hzi (by simpa [extend,hiS] using hh.symm) + rw [he,measure_empty,Measure.pi_singleton] + symm + apply prod_eq_zero (mem_univ i) + simp only [ite_eq_right hiS,poissonMeasure_singleton] + have hn : z i≠0 := hzi + simp [hn] + +lemma sum_extend (S : Finset ι) (ω : S → ℕ) : + (∑ i,extend S ω i)=∑ i : S,ω i := by + classical + rw [←sum_subset (subset_univ S) (fun i _ hi => by simp [extend,hi])] + rw [←sum_coe_sort] + apply sum_congr rfl + intro i _ + simp [extend,i.2] + +end +end SharpLogRamsey.PoissonSupport + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparationInvariance.lean b/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparationInvariance.lean new file mode 100644 index 0000000000000000000000000000000000000000..fa2638004834644ef66e5bbfe4007e84bea115f2 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparationInvariance.lean @@ -0,0 +1,57 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Learning.PreparedGeometry + +namespace OAI + +section +namespace SharpLogRamsey.GreedyPreparation +open Finset +open scoped Classical +noncomputable section +variable {α β : Type*} + +lemma own_inter_right (S T : Finset α) (U : β→Finset α) (bs : List β) (x : α) : + own (S∩T) U bs x=own S U bs x∩T := by + induction bs generalizing S with + | nil => simp [own] + | cons b bs ih => + simp only [own] + split_ifs with hx + · ext y; simp only [mem_inter]; tauto + · rw [←sdiff_inter_right_comm,ih] + +lemma own_removed (S : Finset α) (U : β→Finset α) (bs : List β) (x : α) : + own (removed S U bs) U bs x=own S U bs x := by + rw [removed_eq,own_inter_right] + apply inter_eq_left.mpr + have hh := own_subset_removed S U bs x + rw [removed_eq] at hh + exact hh.trans inter_subset_right + +lemma residual_inter (S T : Finset α) (U : β→Finset α) (bs : List β) : + residual (S∩T) U bs=residual S U bs∩T := by + rw [residual_eq,residual_eq] + exact (sdiff_inter_right_comm _ _ _).symm + +lemma indexedCell_inter (S T : Finset α) (U : β→Finset α) (bs : List β) (i : Fin bs.length) : + indexedCell (S∩T) U bs i=indexedCell S U bs i∩T := by + simp only [indexedCell,residual_inter] + ext y; simp only [mem_inter]; tauto + +lemma indexedCell_removed (S : Finset α) (U : β→Finset α) (bs : List β) (i : Fin bs.length) : + indexedCell (removed S U bs) U bs i=indexedCell S U bs i := by + rw [removed_eq,indexedCell_inter] + apply inter_eq_left.mpr + have hh : indexedCell S U bs i⊆removed S U bs := by + apply cell_subset_removed + rw [indexedCell_eq] + exact List.getElem_mem _ + rw [removed_eq] at hh + exact hh.trans inter_subset_right + +end +end SharpLogRamsey.GreedyPreparation + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedDecoder.lean b/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedDecoder.lean new file mode 100644 index 0000000000000000000000000000000000000000..197d5d7f16a1f7ffc0aab509c660565ede9e7705 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedDecoder.lean @@ -0,0 +1,153 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Learning.TestActualRow +import OAI.Combinatorics.SharpRamsey.Learning.GreedyIndexed + +namespace OAI + +section +namespace SharpLogRamsey.GreedyPreparation +open Finset +open scoped Classical +noncomputable section +variable {α β : Type*} [Fintype α] + +omit [Fintype α] in + +lemma own_inter (S T : Finset α) (U : β → Finset α) (bs : List β) (x : α) : + own (S∩T) U bs x=S∩own T U bs x := by + induction bs generalizing T with + | nil => simp [own] + | cons b bs ih => + by_cases hx : x∈U b + · simp [own,hx,inter_assoc] + · simp only [own,ite_eq_right hx] + rw [show (S∩T)\U b=S∩(T\U b) by ext y; simp only [mem_sdiff,mem_inter]; tauto,ih] + +lemma own_public (S : Finset α) (U : β → Finset α) (bs : List β) (x : α) : + own S U bs x=S∩own univ U bs x := by + simpa using own_inter S univ U bs x + +def sized (S : Finset α) (U : β → Finset α) : List β → List (β×ℕ) + | [] => [] + | b::bs => (b,(S∩U b).card)::sized (S\U b) U bs + +def publicSize (U : β → Finset α) : List (β×ℕ) → α → ℕ + | [],_ => 0 + | (b,m)::bs,x => if x∈U b then m else publicSize U bs x + +omit [Fintype α] in +lemma sized_planes (S : Finset α) (U : β → Finset α) (bs : List β) : + (sized S U bs).map Prod.fst=bs := by + induction bs generalizing S with + | nil => rfl + | cons b bs ih => simp [sized,ih] + +omit [Fintype α] in +lemma publicSize_eq (S : Finset α) (U : β → Finset α) (bs : List β) (x : α) : + publicSize U (sized S U bs) x=(own S U bs x).card := by + induction bs generalizing S with + | nil => simp [sized,publicSize,own] + | cons b bs ih => + by_cases hx : x∈U b + · simp [sized,publicSize,own,hx] + · simp [sized,publicSize,own,hx,ih] + +end +end SharpLogRamsey.GreedyPreparation + +namespace SharpLogRamsey.PreparedDecoder +open Finset SharpLogRamsey.PreparedRow SharpLogRamsey.PointScore +open SharpLogRamsey.GreedyPreparation +open scoped Classical BigOperators +noncomputable section +variable {A H B : Type*} [Fintype A] [Fintype H] + +def counts (S : Finset A) {R : ℕ} (ω : Schedule S R) : Fin R×A → ℕ := + fun rx => extend S ω rx.1 rx.2 + +def publicSample {R : ℕ} (ω : Fin R×A → ℕ) : Finset A := + univ.filter (fun x => ∃ r,ω (r,x)≠0) + +def publicScore (own : A → Prop) (T : Finset H) (inc : H → A → Prop) + (b : ℝ) {R : ℕ} (ω : Fin R×A → ℕ) : ℝ := + ∑ h∈T,∏ r, + (if ∀ y,own y ∧ inc h y → ω (r,y)=0 then (1:ℝ) else 0)* + ((if ∀ y,¬own y ∧ inc h y → ω (r,y)=0 then (1:ℝ) else 0)-b) + +lemma publicSample_eq (S : Finset A) {R : ℕ} (ω : Schedule S R) : + publicSample (counts S ω)=sample S ω := by + ext x + by_cases hx : x∈S + · constructor + · intro hh + exact mem_filter.mpr ⟨hx,(mem_filter.mp hh).2⟩ + · intro hh + exact mem_filter.mpr ⟨mem_univ _,(mem_filter.mp hh).2⟩ + · constructor + · intro hh + obtain ⟨r,hr⟩ := (mem_filter.mp hh).2 + exact False.elim (hr (by simp [counts,extend,hx])) + · intro hh + exact False.elim (hx (mem_filter.mp hh).1) + +omit [Fintype A] in +lemma empty_counts (S : Finset A) (Q : A → Prop) {R : ℕ} (ω : Schedule S R) (r : Fin R) : + (∀ y,Q y → counts S ω (r,y)=0) ↔ (∀ y : S,Q y.1 → ω (r,y)=0) := by + constructor + · intro h y hy + simpa only [counts,extend,dite_eq_left y.2] using h y.1 hy + · intro h y hy + by_cases hs : y∈S + · simpa only [counts,extend,dite_eq_left hs] using h ⟨y,hs⟩ hy + · simp [counts,extend,hs] + +omit [Fintype H] in +lemma publicScore_eq (S O : Finset A) (Q : A → Prop) + (hQ : ∀ y∈S,(y∈O ↔ Q y)) (T : Finset H) (inc : H → A → Prop) + (b : ℝ) {R : ℕ} (ω : Schedule S R) : + publicScore Q T inc b (counts S ω)=score S O T inc b ω := by + rw [publicScore,score_eq] + apply sum_congr rfl + intro h _ + apply prod_congr rfl + intro r _ + simp only [empty_counts,pointEmpty] + have he₁ : (∀ y : S,Q y.1 ∧ inc h y.1 → ω (r,y)=0) ↔ + (∀ y : S,y.1∈O ∧ inc h y.1 → ω (r,y)=0) := by + simp only [←hQ _ (Subtype.prop _)] + have he₂ : (∀ y : S,¬Q y.1 ∧ inc h y.1 → ω (r,y)=0) ↔ + (∀ y : S,y.1∉O ∧ inc h y.1 → ω (r,y)=0) := by + simp only [←hQ _ (Subtype.prop _)] + simp only [he₁,he₂] + split_ifs <;> rfl + +def decode (U : B → Finset A) (bs : List (B×ℕ)) (N z : ℕ) + (T : A → Finset H) (inc : H → A → Prop) (L q : ℝ) + {R : ℕ} (ω : Fin R×A → ℕ) : Finset A := + LearningRow.test (publicSample ω) + (fun x => publicScore (fun y => y∈own univ U (bs.map Prod.fst) x) + (T x) inc (Real.exp (-L*(1-(publicSize U bs x:ℝ)/(N:ℝ)))) ω) z q + +omit [Fintype H] in +theorem decode_equals_source (S₀ S : Finset A) (hS : S⊆S₀) + (U : B → Finset A) (bs : List B) (T : A → Finset H) (inc : H → A → Prop) + (L q : ℝ) (z : ℕ) {R : ℕ} (ω : Schedule S R) : + decode U (sized S₀ U bs) S.card z T inc L q (counts S ω)= + LearningRow.test (sample S ω) + (fun x => score S (own S₀ U bs x) (T x) inc + (Real.exp (-L*(1-((own S₀ U bs x).card:ℝ)/(S.card:ℝ)))) ω) z q := by + rw [decode,publicSample_eq,sized_planes] + congr 1 + funext x + rw [publicSize_eq] + apply publicScore_eq + intro y hy + rw [own_public,mem_inter] + exact and_iff_right (hS hy) + +end +end SharpLogRamsey.PreparedDecoder + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedDescription.lean b/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedDescription.lean new file mode 100644 index 0000000000000000000000000000000000000000..3021885556c638a75236dd7f96d4318a0ed9d507 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedDescription.lean @@ -0,0 +1,121 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Learning.PreparedDecoder +import OAI.Combinatorics.SharpRamsey.Learning.PreparedPointProposals + +namespace OAI + +section +namespace SharpLogRamsey.PreparedDescription +open Finset MeasureTheory PreparedRow GreedyPreparation +open scoped Classical BigOperators NNReal +noncomputable section +variable {K V I B : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedPreparedDescription_1 (R : ℕ) : DecidableEq (Fin R × Projectivization K V) := Classical.decEq _ +local instance flat_JoinedPreparedDescription_2 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedPreparedDescription_3 : Fintype (Projectivization K (Module.Dual K V)) := Fintype.ofFinite _ +local instance flat_JoinedPreparedDescription_4 : Fintype (Projectivization K V) := by + have : Finite V := Module.finite_of_finite K + exact Fintype.ofFinite _ + +def good (S : Finset (Projectivization K V)) + (plane : B→Finset (Projectivization K V)) (bs : List (B×ℕ)) (L cap size : ℝ) + {R : ℕ} (ω : Fin R×Projectivization K V→ℕ) : Prop := + ∃ z≤Fintype.card (Projectivization K (Module.Dual K V)), + let W := PreparedDecoder.decode plane bs S.card z pencil inc L (Nat.card K) ω + cap≤(S∩W).card ∧ (W.card:ℝ)≤ size + +lemma good_of_source (S₀ S : Finset (Projectivization K V)) (hS : S⊆S₀) + (plane : B→Finset (Projectivization K V)) (bs : List B) + (E : Finset (Projectivization K (Module.Dual K V))) (L cap size : ℝ) + {R : ℕ} (ω : Schedule S R) + (hcap : cap≤(S∩rowTest S (own S₀ plane bs) E + (fun x => Real.exp (-L*(1-((own S₀ plane bs x).card:ℝ)/(S.card:ℝ)))) ω).card) + (hsize : ((rowTest S (own S₀ plane bs) E + (fun x => Real.exp (-L*(1-((own S₀ plane bs x).card:ℝ)/(S.card:ℝ)))) ω).card:ℝ)≤ size) : + good S plane (sized S₀ plane bs) L cap size (ambientCounts S ω) := by + refine ⟨(emptySet S E inc ω).card,card_le_univ _,?_⟩ + dsimp only + have he := PreparedDecoder.decode_equals_source S₀ S hS plane bs pencil inc L + (Nat.card K) (emptySet S E inc ω).card ω + change _ = rowTest S (own S₀ plane bs) E _ ω at he + change cap≤(S∩PreparedDecoder.decode _ _ _ _ _ _ _ _ (PreparedDecoder.counts S ω)).card ∧ + ((PreparedDecoder.decode _ _ _ _ _ _ _ _ (PreparedDecoder.counts S ω)).card:ℝ)≤ size + rw [he] + exact ⟨hcap,hsize⟩ + +theorem geometric_proposal_probability + (n R p h M : ℕ) (hn : n≤1) (hdim : Module.finrank K V=n+3) + (S₀ S U Ds Da : Finset (Projectivization K V)) (hS : S.Nonempty) + (hS₀ : S⊆S₀) (hSU : S⊆U) (hDa : Ds⊆Da) + (plane : B→Finset (Projectivization K V)) (bs : List B) + (E E₀ : Finset (Projectivization K (Module.Dual K V))) (hE₀ : E₀.Nonempty) (hE₀E : E₀⊆E) + (c L : ℝ≥0) (hc : (c:ℝ)=(Nat.card K:ℝ)/(S.card:ℝ)) + (hf : ∀ x,((own S₀ plane bs x).card:ℝ)/(S.card:ℝ)≤1/25) + (B₀ C bE δ u zmin W tS tA : ℝ) + (hδ : 0≤δ) (hu : 0 ((O x).card:ℝ)/(S.card:ℝ) + have hr := geometric_row_probability n R p h hn hdim S Ds Da hS hDa O E E₀ hE₀ hE₀E + c L hc f hf B₀ C bE δ u zmin W tS tA hδ hu hzmin htS htA hC hL hR hp hpe hB hQ + hα hsmall hW hZ herror T a hs ha + dsimp only at hr + let P := {ω : Schedule S R | ∃ z≤Fintype.card (Projectivization K (Module.Dual K V)), + let W₀ := PreparedDecoder.decode plane (sized S₀ plane bs) S.card z pencil inc L (Nat.card K) (ambientCounts S ω) + (S.card:ℝ)-(Ds.card:ℝ)-tS-(10*(δ+u))*(S.card:ℝ)≤(S∩W₀).card ∧ + (W₀.card:ℝ)≤2*((R:ℝ)*S.card*(L*c:ℝ≥0))+(Da.card:ℝ)+tA+100*(Nat.card K:ℝ)^(n+3)/zmin} + have hp' : Real.exp (-bE)/2-W*Real.exp (-((L:ℝ)*R)*δ)/(u*zmin)- + (S.card:ℝ)*(B₀^2*Real.exp (-(3/5:ℝ)*((L:ℝ)*R))/(zmin/(10*(Nat.card K:ℝ)))^2)/tS- + (Fintype.card (Projectivization K V):ℝ)*(B₀^p*Real.exp (-(1/10:ℝ)*(p*((L:ℝ)*R)))/(zmin/(10*(Nat.card K:ℝ)))^p)/tA- + Real.exp (-((R:ℝ)*S.card*(L*c:ℝ≥0))/3)≤ + (PoissonSchedules.scheduleLaw (fun _ : Fin R×S => L*c)).real P := by + apply hr.trans + apply measureReal_mono (h₂:=measure_ne_top _ _) + intro ω hω + exact good_of_source S₀ S hS₀ plane bs E L _ _ ω hω.2.1 hω.2.2 + have hcut := total_cutoff_intersection S R M (L*c) P hM + have hprop := ambient_proposal_success S U hS hSU R M (by omega) (L*c) + (good S plane (sized S₀ plane bs) L + ((S.card:ℝ)-(Ds.card:ℝ)-tS-(10*(δ+u))*(S.card:ℝ)) + (2*((R:ℝ)*S.card*(L*c:ℝ≥0))+(Da.card:ℝ)+tA+100*(Nat.card K:ℝ)^(n+3)/zmin)) + apply le_trans _ hprop + apply mul_le_mul_of_nonneg_left _ (by positivity) + change _≤(PoissonSchedules.scheduleLaw (fun _ : Fin R×S => L*c)).real {ω | (∑ i,ω i)≤M ∧ ω∈P} + linarith + +end +end SharpLogRamsey.PreparedDescription + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedGeometry.lean b/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..0b763e43a248f873382516369dbf378b2f3b399f --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedGeometry.lean @@ -0,0 +1,136 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Learning.PreparedDecoder +import OAI.Combinatorics.SharpRamsey.Learning.PreparedVariance + +namespace OAI + +section +namespace SharpLogRamsey.GreedyPreparation +open Finset +open scoped Classical +noncomputable section +variable {A B : Type*} + +lemma own_empty_or_index (S : Finset A) (U : B→Finset A) (bs : List B) (x : A) : + own S U bs x=∅ ∨ ∃ i : Fin bs.length,own S U bs x=indexedCell S U bs i := by + rcases own_empty_or_cell S U bs x with he|he + · exact Or.inl he + · right + obtain ⟨i,hi⟩ := List.mem_iff_get.mp he + have hil : i.val mass (indexedCell S U bs i) c) + (fun i => ((indexedCell S U bs i).card:ℝ)/(S.card:ℝ)) + +lemma not_bad (S : Finset (Projectivization K V)) + (U : J→Finset (Projectivization K V)) (bs : List J) (c : ℝ≥0) + (H : Projectivization K (Module.Dual K V)) (hH : H∉badHyperplanes S U bs c) + (x : Projectivization K V) : + |mass S c H-1|≤1/10 ∧ + |mass (own S U bs x) c H-((own S U bs x).card:ℝ)/(S.card:ℝ)|≤1/50 := by + have hh : ¬(1/10 < |mass S c H-1| ∨ ∃ i : Fin bs.length, + 1/50 < |mass (indexedCell S U bs i) c H-((indexedCell S U bs i).card:ℝ)/(S.card:ℝ)|) := by + simpa only [badHyperplanes,exceptional,mem_filter,mem_univ,true_and] using hH + obtain ⟨hl,hc⟩ := not_or.mp hh + refine ⟨le_of_not_gt hl,?_⟩ + rcases own_empty_or_index S U bs x with he|⟨i,he⟩ + · simp [he,mass] + · rw [he] + exact le_of_not_gt (fun hi => hc ⟨i,hi⟩) + +omit [Finite K] [FiniteDimensional K V] in +lemma cell_sum_le (S : Finset (Projectivization K V)) + (U : J→Finset (Projectivization K V)) (bs : List J) : + (∑ i : Fin bs.length,(indexedCell S U bs i).card)≤S.card := by + rw [indexedCell_sum] + exact card_le_card (removed_subset S U bs) + +lemma pencil_exception_count (S : Finset (Projectivization K V)) + (U : J→Finset (Projectivization K V)) (bs : List J) (c : ℝ≥0) + (x : Projectivization K V) : + (∑ H∈pencil x,weights S (indexedCell S U bs) c (some none) H)= + ((pencil x∩badHyperplanes S U bs c).card:ℝ) := by + simp only [weights,←sum_filter] + change (∑ H∈(pencil x).filter (fun H => H∈badHyperplanes S U bs c),(1:ℝ))=_ + rw [filter_mem_eq_inter] + simp + +theorem regular_preparation {n : ℕ} (hdim : Module.finrank K V=n+3) + (S : Finset (Projectivization K V)) (hS : S.Nonempty) + (U : J→Finset (Projectivization K V)) (bs : List J) (c : ℝ≥0) + (hc : (c:ℝ)=(Nat.card K:ℝ)/(S.card:ℝ)) (hcsmall : (c:ℝ)≤1/100) + (hcell : ∀ i : Fin bs.length,((indexedCell S U bs i).card:ℝ)/(S.card:ℝ)≤1/25) + (T : ℝ) (hT : 0≤T) + (hmean : (∑ k∈range (n+2),(Nat.card K:ℝ)^k)/(∑ k∈range (n+3),(Nat.card K:ℝ)^k)* + (10408*((Nat.card K:ℝ)^(n+3)/(S.card:ℝ)))≤T/2) : + let E := badHyperplanes S U bs c + ∃ D : Finset (Projectivization K V), + (D.card:ℝ)*(T/2)^2≤10408*(Nat.card K:ℝ)^(2*n+4)/(S.card:ℝ) ∧ + (E.card:ℝ)≤10400*((Nat.card K:ℝ)^(n+3)/(S.card:ℝ)) ∧ + (∑ H∈E,mass S c H)≤20804*((Nat.card K:ℝ)^(n+3)/(S.card:ℝ)) ∧ + (∀ x,((own S U bs x).card:ℝ)/(S.card:ℝ)≤1/25) ∧ + ∀ x,x∉D → + ((pencil x∩E).card:ℝ) (hn H hH).1) (fun H hH => (hn H hH).2) hfull hown + +end +end SharpLogRamsey.PreparedGeometry + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedIncidence.lean b/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedIncidence.lean new file mode 100644 index 0000000000000000000000000000000000000000..68659c0d5aed7ccb860be4290ae9e8ecbc124f99 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedIncidence.lean @@ -0,0 +1,102 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Learning.PreparedSource + +namespace OAI + +section +namespace SharpLogRamsey.Selection.ExposureModel +open Finset Real ReciprocalBands +open scoped Classical BigOperators +noncomputable section +variable {K V Ω Θ ι C : Type} [Field K] [AddCommGroup V] [Module K V] + [Finite K] [FiniteDimensional K V] [Fintype Ω] [Fintype Θ] + [Fintype ι] [DecidableEq ι] [Fintype C] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] +variable (n k : ℕ) (p : Law Ω) (θ : Ω→Θ) + (G : Ω→ι→Projectivization K (Module.Dual K V)×Projectivization K V) + (e : Θ→C×Fin (n+k)↪ι) (own : Θ→ι→Option C) (t : Fin k) + (hp : ∀ z,0<(contextual n k p θ G e own t).remaining z) + (z : (contextual n k p θ G e own t).FreshHistory) + (hz : ((contextual n k p θ G e own t).freshLaw hp).mass z≠0) + (pos : ι→ℕ) + (hcon : ∀ ω,p.mass ω≠0→∀ i j,pos ipos i + goodFirst (q.marginal i) (P*exp (((d:ℝ)+1)*log (Nat.card K)-u)) + ((d:ℝ)*log (Nat.card K)) κ (1/50) ay.1 ∧ + goodSecond (q.marginal j) (P*exp v) ((d:ℝ)*log (Nat.card K)) κ (1/50) ay.2 ∧ + ay.1.rep ay.2.rep=0))≤(20000*((d:ℝ)+1)^2+8)*a := by + let M:=contextual n k p θ G e own t + apply integer_band_event_le (M.tupleLaw z.1) i j P κ gap u v a d r hdim hP hr + hu hv hsmall hκ + (prepared_consistency n k p θ G e own t hp z hz pos hcon i j hij) + exact good_charge_either (M.tupleLaw z.1) (M.embedding z.1) (M.owner z.1) + _ (reciprocalCharges_symm _ _ _ _ _ _) J D a z.2 i j hgood + +theorem prepared_open_event + (i j : (contextual n k p θ G e own t).Index z.1) + (hij : pos ((contextual n k p θ G e own t).origin z.1 i)< + pos ((contextual n k p θ G e own t).origin z.1 j)) + (P κ gap u v J D a : ℝ) (d r : ℕ) + (hdim : Module.finrank K V=d+1) (hP : 00) J D a z.2 ∧ + j∈otherRepresentatives (M.embedding z.1) (M.owner z.1) z.2 i) ∨ + (j∉badIndices (M.tupleLaw z.1) (M.embedding z.1) (M.owner z.1) (fun _ _=>0) J D a z.2 ∧ + i∈otherRepresentatives (M.embedding z.1) (M.owner z.1) z.2 j)) : + let q:=(contextual n k p θ G e own t).tupleLaw z.1 + ((q.marginal i).fst.prod (q.marginal j).snd).event (univ.filter (fun ay=> + goodFirst (q.marginal i) (P*exp (((d:ℝ)+1)*log (Nat.card K)-u)) + ((d:ℝ)*log (Nat.card K)) κ (1/50) ay.1 ∧ + goodSecond (q.marginal j) (P*exp v) ((d:ℝ)*log (Nat.card K)) κ (1/50) ay.2 ∧ + ay.1.rep ay.2.rep=0))≤(20000*((d:ℝ)+1)^2)*a := by + let M:=contextual n k p θ G e own t + apply open_band_event_le (M.tupleLaw z.1) i j P κ gap u v a d r hdim hP hr + hu hv hsmall hκ + (prepared_consistency n k p θ G e own t hp z hz pos hcon i j hij) + have hh:=good_charge_either (M.tupleLaw z.1) (M.embedding z.1) (M.owner z.1) + (fun _ _=>0) (by intros; rfl) J D a z.2 i j hgood + simpa only [NNReal.coe_zero,add_zero] using hh + +end +end SharpLogRamsey.Selection.ExposureModel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedOverlapBounds.lean b/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedOverlapBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..cc9df69c79013de8827bc82984157fb4c0543223 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedOverlapBounds.lean @@ -0,0 +1,102 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Learning.PreparedResidualBounds + +namespace OAI + +section +namespace SharpLogRamsey.PreparedProjectiveGeometry +open Finset +open scoped Classical BigOperators +noncomputable section +variable {K V I : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedPreparedOverlapBounds_1 : Finite (Projectivization K V) := by + let : Finite V := Module.finite_of_finite K + infer_instance +local instance flat_JoinedPreparedOverlapBounds_2 : Fintype (Projectivization K V) := Fintype.ofFinite _ +local instance flat_JoinedPreparedOverlapBounds_3 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedPreparedOverlapBounds_4 : Fintype (Projectivization K (Module.Dual K V)) := Fintype.ofFinite _ +local instance flat_JoinedPreparedOverlapBounds_5 : Finite (Submodule K V) := by + let : Finite V := Module.finite_of_finite K + exact Finite.of_injective (fun W : Submodule K V => (W : Set V)) SetLike.coe_injective +local instance flat_JoinedPreparedOverlapBounds_6 : Fintype (Submodule K V) := Fintype.ofFinite _ + +lemma pairs_of_radial_bound (hdim : Module.finrank K V=4) + (S : Finset (Projectivization K V)) (x : Projectivization K V) (c a K₀ : ℝ) + (hr : ((richRadials S x c a).card:ℝ)*a^100≤K₀) + (A : Finset (Projectivization K (Module.Dual K V))) + (hA : ∀ H∈A,x.submodule≤LinearMap.ker H.rep) : + ((largePairs S x c a A).card:ℝ)*a^200≤K₀*((Nat.card K:ℝ)+1)^2*a^100 := by + have hh : ((largePairs S x c a A).card:ℝ)≤ + (richRadials S x c a).card*((Nat.card K:ℝ)+1)^2 := by + exact_mod_cast largePairs_card hdim S x c a A hA + have h100 : 0≤a^100 := by + have heven : Even (100 : ℕ) := by decide + exact heven.pow_nonneg a + have he : a^200=a^100*a^100 := by rw [← pow_add] + calc + ((largePairs S x c a A).card:ℝ)*a^200 = + ((largePairs S x c a A).card:ℝ)*(a^100*a^100) := by rw [he] + _ ≤ ((richRadials S x c a).card*((Nat.card K:ℝ)+1)^2)*(a^100*a^100) := + mul_le_mul_of_nonneg_right hh (mul_nonneg h100 h100) + _ = ((richRadials S x c a).card*a^100)*(((Nat.card K:ℝ)+1)^2*a^100) := by ac_rfl + _ ≤ K₀*(((Nat.card K:ℝ)+1)^2*a^100) := + mul_le_mul_of_nonneg_right hr (mul_nonneg (sq_nonneg _) h100) + _ = K₀*((Nat.card K:ℝ)+1)^2*a^100 := by rw [mul_assoc] + +lemma neighbors_empty_of_radials (hdim : Module.finrank K V=4) + (S : Finset (Projectivization K V)) (x : Projectivization K V) (c a : ℝ) + (hr : (richRadials S x c a).card=0) + (A : Finset (Projectivization K (Module.Dual K V))) + (hA : ∀ H∈A,x.submodule≤LinearMap.ker H.rep) + (H : Projectivization K (Module.Dual K V)) (hH : H∈A) : + largeNeighbors S x c a A H=∅ := by + apply card_eq_zero.mp + have hh := neighbors_card hdim S x c a A hA H (hA H hH) + have hz : (richRadials S x c a∩lines x H).card=0 := by + have hp := card_le_card (inter_subset_left : richRadials S x c a∩lines x H⊆richRadials S x c a) + omega + rw [hz,zero_mul] at hh + omega + +theorem list_overlap_exceptions (hdim : Module.finrank K V=4) + (F : Finset (Submodule K V)) (m : ℕ) + (S : Finset (Projectivization K V)) (bs : List (Submodule K V)) + (h : GreedyPreparation.Complete F planePoints m S bs) + (c K₀ : ℝ) (hc : 0 GreedyPreparation.removed S planePoints bs \ + (GreedyPreparation.own S planePoints bs x∪{x}) + let r := fun x i => (richRadials (X x) x c (a i)).card + have hcrude (x : Projectivization K V) (i : I) (_hi : i∈T) : + (r x i:ℝ)*a i≤c*(GreedyPreparation.removed S planePoints bs).card := by + apply (richRadials_mul_le (X x) x c (a i) hc.le).trans + exact mul_le_mul_of_nonneg_left (Nat.cast_le.mpr (card_le_card sdiff_subset)) hc.le + have hpair (i : I) (hi : i∈T) + (hk : K₀ γ)).real P- + Real.exp (-((R:ℝ)*S.card*γ)/3)≤ + (PoissonSchedules.scheduleLaw (fun _ : Fin R×S => γ)).real + {ω | (∑ i,ω i)≤M ∧ ω∈P} := by + let μ := PoissonSchedules.scheduleLaw (fun _ : Fin R×S => γ) + have ht := PoissonTail.total_tail (fun _ : Fin R×S => γ) + rw [constant_mean S R γ] at ht + have hbad : μ.real {ω | M<∑ i,ω i}≤Real.exp (-((R:ℝ)*S.card*γ)/3) := by + apply le_trans (measureReal_mono (h₂:=measure_ne_top _ _) ?_) ht + intro ω hω + exact hM.trans (by exact_mod_cast hω.le) + have hs : P⊆{ω | (∑ i,ω i)≤M ∧ ω∈P}∪{ω | M<∑ i,ω i} := by + intro ω hω + by_cases hc : (∑ i,ω i)≤M + · exact Or.inl ⟨hc,hω⟩ + · exact Or.inr (Nat.lt_of_not_ge hc) + have hu := (measureReal_mono (μ:=μ) (h₂:=measure_ne_top _ _) hs).trans + (measureReal_union_le _ _) + linarith + +def ambientCounts (S : Finset A) {R : ℕ} (ω : Schedule S R) : Fin R×A → ℕ := + fun rx => extend S ω rx.1 rx.2 + +def coordinateSupport (S : Finset A) (R : ℕ) : Finset (Fin R×A) := univ ×ˢ S + +def ambientRate (S : Finset A) (R : ℕ) (γ : ℝ≥0) (rx : Fin R×A) : ℝ≥0 := + if rx.2∈S then γ else 0 + +omit [Fintype A] in +lemma ambientCounts_restrict (S : Finset A) {R : ℕ} (z : Fin R×A → ℕ) + (hz : ∀ rx,rx.2∉S → z rx=0) : + ambientCounts S (fun rx : Fin R×S => z (rx.1,rx.2))=z := by + funext rx + by_cases hx : rx.2∈S + · simp [ambientCounts,extend,hx] + · simp [ambientCounts,extend,hx,hz rx hx] + +omit [Fintype A] in +lemma restrict_ambientCounts (S : Finset A) {R : ℕ} (ω : Schedule S R) : + (fun rx : Fin R×S => ambientCounts S ω (rx.1,rx.2))=ω := by + funext rx + simp [ambientCounts,extend,rx.2.2] + +theorem ambientCounts_hasLaw (S : Finset A) (R : ℕ) (γ : ℝ≥0) : + HasLaw (ambientCounts S) (PoissonSchedules.scheduleLaw (ambientRate S R γ)) + (PoissonSchedules.scheduleLaw (fun _ : Fin R×S => γ)) := by + refine ⟨(measurable_of_countable _).aemeasurable,?_⟩ + apply Measure.ext_of_singleton + intro z + rw [Measure.map_apply (measurable_of_countable _) (measurableSet_singleton z)] + by_cases hz : ∀ rx,rx.2∉S → z rx=0 + · have he : ambientCounts S ⁻¹' {z}={fun rx : Fin R×S => z (rx.1,rx.2)} := by + ext ω + simp only [Set.mem_preimage,Set.mem_singleton_iff] + constructor + · intro h + calc + ω = fun rx : Fin R×S => ambientCounts S ω (rx.1,rx.2) := (restrict_ambientCounts S ω).symm + _ = _ := by rw [h] + · rintro rfl + exact ambientCounts_restrict S z hz + rw [he,PoissonSchedules.scheduleLaw,PoissonSchedules.scheduleLaw, + Measure.pi_singleton,Measure.pi_singleton,Fintype.prod_prod_type,Fintype.prod_prod_type] + apply prod_congr rfl + intro r _ + calc + _ = ∏ x∈S,poissonMeasure γ {z (r,x)} := prod_coe_sort S _ + _ = ∏ x∈S,poissonMeasure (ambientRate S R γ (r,x)) {z (r,x)} := by + apply prod_congr rfl + intro x hx + rw [ambientRate,ite_eq_left hx] + _ = _ := prod_subset (subset_univ S) (fun x _ hx => by + simp only [ambientRate,ite_eq_right hx,hz (r,x) hx,poissonMeasure_singleton] + norm_num) + · obtain ⟨rx,hx,hn⟩ := not_forall.mp hz |>.imp (fun rx h => by simpa using h) + have he : ambientCounts S ⁻¹' {z}=∅ := by + apply Set.eq_empty_iff_forall_notMem.mpr + intro ω hω + have hh := congrFun (Set.mem_singleton_iff.mp hω) rx + exact hn (by simpa [ambientCounts,extend,hx] using hh.symm) + rw [he,measure_empty,PoissonSchedules.scheduleLaw,Measure.pi_singleton] + symm + apply prod_eq_zero (mem_univ rx) + simp [ambientRate,hx,poissonMeasure_singleton,hn] + +lemma sum_ambientCounts (S : Finset A) {R : ℕ} (ω : Schedule S R) : + (∑ rx,ambientCounts S ω rx)=∑ rx,ω rx := by + rw [Fintype.sum_prod_type,Fintype.sum_prod_type] + apply sum_congr rfl + intro r _ + change (∑ x,PoissonSupport.extend S (fun x => ω (r,x)) x)=_ + exact PoissonSupport.sum_extend S _ + +omit [Fintype A] in +lemma ambient_rate_uniform (S : Finset A) (hS : S.Nonempty) (R : ℕ) (hR : 0 γ)).real + {ω | (∑ i,ω i)≤M ∧ P (ambientCounts S ω)} ≤ + PublicTables.acceptProb + (PreparedProposals.proposal (coordinateSupport U R) ((R:ℝ≥0)*S.card*γ) M) + (PreparedProposals.accepts (coordinateSupport S R) M P) := by + have hu : U.Nonempty := hS.mono hSU + have hcS : (coordinateSupport S R).Nonempty := by + exact Finset.Nonempty.product (by exact ⟨⟨0,hR⟩,mem_univ _⟩) hS + have hcU : (coordinateSupport U R).Nonempty := hcS.mono (product_subset_product_right hSU) + have hcSU : coordinateSupport S R⊆coordinateSupport U R := product_subset_product_right hSU + have hh := PreparedProposals.proposal_success (coordinateSupport S R) (coordinateSupport U R) + ((R:ℝ≥0)*S.card*γ) M hcS hcU hcSU P + rw [PreparedProposals.true_success_probability,ambient_rate_uniform S hS R hR γ] at hh + have he : ((coordinateSupport S R).card:ℝ)/((coordinateSupport U R).card:ℝ)= + (S.card:ℝ)/(U.card:ℝ) := by + simp only [coordinateSupport,card_product,card_univ,Fintype.card_fin,Nat.cast_mul] + have hr : (R:ℝ)≠0 := by exact_mod_cast hR.ne' + field_simp + rw [he] at hh + have hlaw := ambientCounts_hasLaw S R γ + have hm := congrArg (fun μ : Measure (Fin R×A→ℕ) => + μ.real {z | FiniteSchedules.total z≤M ∧ P z}) hlaw.map_eq + rw [map_measureReal_apply (measurable_of_countable _) ((Set.to_countable _).measurableSet)] at hm + have hp : ambientCounts S ⁻¹' {z | FiniteSchedules.total z≤M ∧ P z}= + {ω | (∑ i,ω i)≤M ∧ P (ambientCounts S ω)} := by + ext ω + simp only [Set.mem_preimage,Set.mem_ofPred_eq,FiniteSchedules.total,sum_ambientCounts] + rw [hp] at hm + exact hm.symm ▸ hh + +end +end SharpLogRamsey.PreparedRow + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedProposals.lean b/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedProposals.lean new file mode 100644 index 0000000000000000000000000000000000000000..ed15c784f7ac0c39e6c5ebe2a3ef6911182f2995 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedProposals.lean @@ -0,0 +1,406 @@ +import Mathlib + +namespace OAI + +section +open scoped BigOperators Classical +open Finset +namespace SharpLogRamsey.PublicTables + +structure Law (Ω : Type*) [Fintype Ω] where + mass : Ω → ℝ + nonneg : ∀ x, 0 ≤ mass x + total : ∑ x, mass x = 1 + +universe u + +def Table (Ω : Type u) : ℕ → Type u + | 0 => PUnit + | n+1 => Ω × Table Ω n + +instance instFintypeTable (Ω : Type*) [Fintype Ω] (n : ℕ) : Fintype (Table Ω n) := by + induction n with + | zero => exact inferInstanceAs (Fintype PUnit) + | succ n ih => exact inferInstanceAs (Fintype (Ω × Table Ω n)) + +variable {Ω : Type*} [Fintype Ω] + +noncomputable def tableWeight (p : Law Ω) : (n : ℕ) → Table Ω n → ℝ + | 0, _ => 1 + | n+1, z => p.mass z.1 * tableWeight p n z.2 + +noncomputable def first (A : Ω → Prop) [DecidablePred A] : (n : ℕ) → Table Ω n → Option Ω + | 0, _ => none + | n+1, z => if A z.1 then some z.1 else first A n z.2 + +noncomputable def outcome (A : Ω → Prop) [DecidablePred A] (f : Ω → ℝ) + (n : ℕ) (z : Table Ω n) : ℝ := + (first A n z).elim 0 f + +noncomputable def integral (p : Law Ω) (A : Ω → Prop) [DecidablePred A] + (f : Ω → ℝ) (n : ℕ) : ℝ := ∑ z, tableWeight p n z * outcome A f n z + +noncomputable def accepted (p : Law Ω) (A : Ω → Prop) [DecidablePred A] + (f : Ω → ℝ) : ℝ := ∑ x, if A x then p.mass x*f x else 0 + +noncomputable def acceptProb (p : Law Ω) (A : Ω → Prop) [DecidablePred A] : ℝ := + accepted p A (fun _ => 1) + +theorem tableWeight_nonneg (p : Law Ω) (n : ℕ) (z : Table Ω n) : + 0 ≤ tableWeight p n z := by + induction n with + | zero => simp [tableWeight] + | succ n ih => exact mul_nonneg (p.nonneg z.1) (ih z.2) + +theorem tableWeight_total (p : Law Ω) (n : ℕ) : ∑ z, tableWeight p n z = 1 := by + induction n with + | zero => + change (∑ z : PUnit, (1 : ℝ)) = 1 + simp + | succ n ih => + change (∑ z : Ω × Table Ω n, p.mass z.1 * tableWeight p n z.2) = 1 + rw [Fintype.sum_prod_type] + simp_rw [← mul_sum,ih,mul_one] + exact p.total + +theorem acceptProb_nonneg (p : Law Ω) (A : Ω → Prop) [DecidablePred A] : + 0 ≤ acceptProb p A := by + apply sum_nonneg + intro x hx + split <;> simp_all [p.nonneg x] + +theorem acceptProb_le_one (p : Law Ω) (A : Ω → Prop) [DecidablePred A] : + acceptProb p A ≤ 1 := by + rw [← p.total] + apply sum_le_sum + intro x hx + split <;> simp_all [p.nonneg x] + +theorem rejectProb (p : Law Ω) (A : Ω → Prop) [DecidablePred A] : + (∑ x, if A x then 0 else p.mass x) = 1-acceptProb p A := by + have he (x : Ω) : (if A x then 0 else p.mass x) = + p.mass x-(if A x then p.mass x*1 else 0) := by split_ifs <;> ring + simp_rw [he] + rw [sum_sub_distrib,p.total] + rfl + +theorem integral_succ (p : Law Ω) (A : Ω → Prop) [DecidablePred A] + (f : Ω → ℝ) (n : ℕ) : + integral p A f (n+1) = accepted p A f + (1-acceptProb p A)*integral p A f n := by + have ho (z : Table Ω (n+1)) : outcome A f (n+1) z = + if A z.1 then f z.1 else outcome A f n z.2 := by + change (if A z.1 then some z.1 else first A n z.2).elim 0 f = _ + split_ifs <;> rfl + simp only [integral, tableWeight, ho] + change (∑ z : Ω × Table Ω n, p.mass z.1 * tableWeight p n z.2 * + (if A z.1 then f z.1 else outcome A f n z.2)) = _ + rw [Fintype.sum_prod_type] + have he (x : Ω) : (∑ z : Table Ω n, p.mass x*tableWeight p n z* + (if A x then f x else outcome A f n z)) = + (if A x then p.mass x*f x else 0) + + (if A x then 0 else p.mass x)*integral p A f n := by + by_cases hx : A x + · simp only [hx,ite_true,zero_mul,add_zero] + calc + _ = (p.mass x*f x)*∑ z : Table Ω n, tableWeight p n z := by + rw [mul_sum]; apply sum_congr rfl; intro z hz; ring + _ = _ := by rw [tableWeight_total,mul_one] + · simp only [hx,ite_false,zero_add] + unfold integral + rw [mul_sum] + apply sum_congr rfl + intro z hz + ring + simp_rw [he] + rw [sum_add_distrib,← sum_mul,rejectProb] + rfl + +theorem integral_formula (p : Law Ω) (A : Ω → Prop) [DecidablePred A] + (f : Ω → ℝ) (n : ℕ) : + integral p A f n = (∑ i ∈ range n, (1-acceptProb p A)^i)*accepted p A f := by + induction n with + | zero => simp [integral,outcome,first,Table] + | succ n ih => + rw [integral_succ,ih] + have he : (∑ i ∈ range (n+1), (1-acceptProb p A)^i) = + 1+(1-acceptProb p A)*(∑ i ∈ range n, (1-acceptProb p A)^i) := by + rw [sum_range_succ'] + simp_rw [pow_succ'] + rw [← mul_sum] + simp [add_comm] + rw [he] + ring + +theorem geometric_normalization (a : ℝ) (n : ℕ) : + a*(∑ i ∈ range n, (1-a)^i) = 1-(1-a)^n := by + induction n with + | zero => simp + | succ n ih => + rw [sum_range_succ,mul_add,ih,pow_succ] + ring + +theorem first_accepted_law (p : Law Ω) (A : Ω → Prop) [DecidablePred A] + (f : Ω → ℝ) (n : ℕ) (ha : 0 < acceptProb p A) : + integral p A f n = (1-(1-acceptProb p A)^n)* + (accepted p A f / acceptProb p A) := by + rw [integral_formula,← geometric_normalization] + field_simp + +theorem produced_domination (p : Law Ω) (A : Ω → Prop) [DecidablePred A] + (f : Ω → ℝ) (hf : ∀ x, 0 ≤ f x) (n : ℕ) (ha : 0 < acceptProb p A) : + integral p A f n ≤ accepted p A f / acceptProb p A := by + rw [first_accepted_law p A f n ha] + have hn : 0 ≤ accepted p A f := by + apply sum_nonneg + intro x hx + split <;> simp_all [mul_nonneg (p.nonneg x) (hf x)] + have hc : 1-(1-acceptProb p A)^n ≤ 1 := by + have h := pow_nonneg (sub_nonneg.mpr (acceptProb_le_one p A)) n + linarith + simpa using mul_le_mul_of_nonneg_right hc (div_nonneg hn ha.le) + +theorem production_probability (p : Law Ω) (A : Ω → Prop) [DecidablePred A] (n : ℕ) : + integral p A (fun _ => 1) n = 1-(1-acceptProb p A)^n := by + rw [integral_formula] + simpa only [acceptProb,mul_comm] using geometric_normalization (acceptProb p A) n + +end SharpLogRamsey.PublicTables + +namespace SharpLogRamsey.PublicTables +open MeasureTheory Finset +open scoped Classical BigOperators +noncomputable section +variable {X Y : Type*} [MeasurableSpace X] [Fintype Y] + +def Law.fromMeasure (μ : Measure X) [IsProbabilityMeasure μ] (f : X → Y) + (hf : ∀ y,MeasurableSet (f ⁻¹' {y})) : Law Y where + mass y := μ.real (f ⁻¹' {y}) + nonneg _ := measureReal_nonneg + total := by + have h := sum_measureReal_preimage_singleton (μ:=μ) univ (fun y _ => hf y) + simpa using h + +lemma acceptProb_fromMeasure (μ : Measure X) [IsProbabilityMeasure μ] (f : X → Y) + (hf : ∀ y,MeasurableSet (f ⁻¹' {y})) (A : Y → Prop) : + acceptProb (Law.fromMeasure μ f hf) A=μ.real {x | A (f x)} := by + unfold acceptProb accepted Law.fromMeasure + simp only [mul_one] + rw [←sum_filter] + have h := sum_measureReal_preimage_singleton (μ:=μ) (univ.filter A) (fun y _ => hf y) + simpa using h + +end +end SharpLogRamsey.PublicTables + +namespace SharpLogRamsey.FiniteSchedules +open Finset MeasureTheory +open scoped Classical BigOperators +noncomputable section +variable {ι : Type*} [Fintype ι] + +def clip (M : ℕ) (ω : ι → ℕ) : ι → Fin (M+2) := fun i => + ⟨min (ω i) (M+1),by omega⟩ + +def total (ω : ι → ℕ) : ℕ := ∑ i,ω i + +lemma coordinate_le_total (ω : ι → ℕ) (i : ι) : ω i ≤ total ω := + single_le_sum (fun _ _ => Nat.zero_le _) (mem_univ i) + +lemma clip_eq_iff (M : ℕ) (ω : ι → ℕ) (z : ι → Fin (M+2)) + (hz : total (fun i => (z i:ℕ))≤M) : + clip M ω=z ↔ ω=(fun i => (z i:ℕ)) := by + constructor + · intro h + funext i + have he : min (ω i) (M+1)=(z i:ℕ) := congrArg Fin.val (congrFun h i) + have hi := (coordinate_le_total (fun i => (z i:ℕ)) i).trans hz + omega + · rintro rfl + funext i + apply Fin.ext + have hi := (coordinate_le_total (fun i => (z i:ℕ)) i).trans hz + change min (z i:ℕ) (M+1)=(z i:ℕ) + omega + +lemma clip_preimage (M : ℕ) (z : ι → Fin (M+2)) + (hz : total (fun i => (z i:ℕ))≤M) : + clip M ⁻¹' {z}={fun i => (z i:ℕ)} := by + ext ω + exact clip_eq_iff M ω z hz + +lemma clip_total_iff (M : ℕ) (ω : ι → ℕ) : + total (fun i => (clip M ω i:ℕ))≤M ↔ total ω≤M := by + constructor + · intro h + have he := (clip_eq_iff M ω (clip M ω) h).mp rfl + exact (congrArg total he).le.trans h + · intro h + unfold total clip + have hi : ∀ i,min (ω i) (M+1)=ω i := fun i => by + have hh := (coordinate_le_total ω i).trans h + omega + simp_rw [hi] + exact h + +lemma acceptance_preimage (M : ℕ) (P : (ι → ℕ) → Prop) : + {ω | total (fun i => (clip M ω i:ℕ))≤M ∧ P (fun i => (clip M ω i:ℕ))}= + {ω | total ω≤M ∧ P ω} := by + ext ω + constructor + · rintro ⟨h,hp⟩ + have he := (clip_eq_iff M ω (clip M ω) h).mp rfl + exact ⟨(clip_total_iff M ω).mp h,he ▸ hp⟩ + · rintro ⟨h,hp⟩ + have hc := (clip_total_iff M ω).mpr h + have he := (clip_eq_iff M ω (clip M ω) hc).mp rfl + exact ⟨hc,he ▸ hp⟩ + +end +end SharpLogRamsey.FiniteSchedules + +namespace SharpLogRamsey.PoissonLikelihood +open MeasureTheory ProbabilityTheory Finset +open scoped Classical BigOperators NNReal +noncomputable section +variable {ι : Type*} [Fintype ι] + +def law (rate : ι → ℝ≥0) : Measure (ι → ℕ) := + Measure.pi (fun i => poissonMeasure (rate i)) + +instance probability (rate : ι → ℝ≥0) : IsProbabilityMeasure (law rate) := by + unfold law + infer_instance + +theorem singleton_formula (rate : ι → ℝ≥0) (ω : ι → ℕ) : + (law rate).real {ω} = Real.exp (-(∑ i,(rate i:ℝ))) * + (∏ i,(rate i:ℝ)^(ω i))/(∏ i,((ω i).factorial:ℝ)) := by + simp only [law,Measure.real,Measure.pi_singleton,ENNReal.toReal_prod, + poissonMeasure_singleton,ENNReal.toReal_ofReal (show 0 ≤ Real.exp (-(rate _ : ℝ)) * + (rate _ : ℝ)^ω _ /((ω _).factorial:ℝ) from by positivity)] + rw [prod_div_distrib,prod_mul_distrib,←Real.exp_sum,sum_neg_distrib] + +theorem singleton_ratio (proposal hidden : ι → ℝ≥0) (c : ℝ) (ω : ι → ℕ) + (htotal : (∑ i,(proposal i:ℝ))=∑ i,(hidden i:ℝ)) + (hp : ∀ i,(proposal i:ℝ)^ω i=c^ω i*(hidden i:ℝ)^ω i) : + (law proposal).real {ω}=c^(∑ i,ω i)*(law hidden).real {ω} := by + rw [singleton_formula,singleton_formula,htotal] + simp_rw [hp] + rw [prod_mul_distrib,prod_pow_eq_pow_sum] + ring + +def uniformRate (S : Finset ι) (a : ℝ≥0) (i : ι) : ℝ≥0 := + if i∈S then a/(S.card:ℝ≥0) else 0 + +lemma sum_uniformRate (S : Finset ι) (a : ℝ≥0) (hS : S.Nonempty) : + (∑ i,(uniformRate S a i:ℝ))=a := by + have hn : (S.card:ℝ)≠0 := by exact_mod_cast ne_of_gt (card_pos.mpr hS) + simp only [uniformRate,apply_ite,NNReal.coe_div,NNReal.coe_natCast,NNReal.coe_zero] + rw [←sum_filter] + simp only [filter_mem_eq_inter,univ_inter,sum_const,nsmul_eq_mul] + field_simp + +theorem uniform_singleton_ratio (S U : Finset ι) (a : ℝ≥0) (hS : S.Nonempty) + (hU : U.Nonempty) (hSU : S ⊆ U) (ω : ι → ℕ) (hω : ∀ i,i∉S → ω i=0) : + (law (uniformRate U a)).real {ω}= + ((S.card:ℝ)/(U.card:ℝ))^(∑ i,ω i)*(law (uniformRate S a)).real {ω} := by + have hn : (S.card:ℝ)≠0 := by exact_mod_cast ne_of_gt (card_pos.mpr hS) + have hu : (U.card:ℝ)≠0 := by exact_mod_cast ne_of_gt (card_pos.mpr hU) + apply singleton_ratio + · rw [sum_uniformRate U a hU,sum_uniformRate S a hS] + · intro i + by_cases hi : i∈S + · simp only [uniformRate,ite_eq_left hi,ite_eq_left (hSU hi),NNReal.coe_div,NNReal.coe_natCast] + rw [←mul_pow] + congr 1 + field_simp + · rw [hω i hi] + simp + +end +end SharpLogRamsey.PoissonLikelihood + +namespace SharpLogRamsey.PreparedProposals +open MeasureTheory ProbabilityTheory Finset +open SharpLogRamsey.PoissonLikelihood SharpLogRamsey.FiniteSchedules SharpLogRamsey.PublicTables +open scoped Classical BigOperators NNReal +noncomputable section +variable {ι : Type*} [Fintype ι] + +def accepts (S : Finset ι) (M : ℕ) (P : (ι → ℕ) → Prop) + (z : ι → Fin (M+2)) : Prop := + total (fun i => (z i:ℕ))≤M ∧ (∀ i,i∉S → (z i:ℕ)=0) ∧ P (fun i => (z i:ℕ)) + +def proposal (U : Finset ι) (a : ℝ≥0) (M : ℕ) : Law (ι → Fin (M+2)) := + Law.fromMeasure (law (uniformRate U a)) (clip M) + (fun _ => (Set.to_countable _).measurableSet) + +lemma proposal_mass (U : Finset ι) (a : ℝ≥0) (M : ℕ) (z : ι → Fin (M+2)) + (hz : total (fun i => (z i:ℕ))≤M) : + (proposal U a M).mass z=(law (uniformRate U a)).real {fun i => (z i:ℕ)} := by + change (law _).real (clip M ⁻¹' {z})=_ + rw [clip_preimage M z hz] + +theorem atom_domination (S U : Finset ι) (a : ℝ≥0) (M : ℕ) + (hS : S.Nonempty) (hU : U.Nonempty) (hSU : S⊆U) (P : (ι → ℕ) → Prop) + (z : ι → Fin (M+2)) (hz : accepts S M P z) : + ((S.card:ℝ)/(U.card:ℝ))^M*(proposal S a M).mass z ≤ (proposal U a M).mass z := by + rw [proposal_mass S a M z hz.1,proposal_mass U a M z hz.1, + uniform_singleton_ratio S U a hS hU hSU _ hz.2.1] + apply mul_le_mul_of_nonneg_right _ measureReal_nonneg + apply pow_le_pow_of_le_one (by positivity) _ hz.1 + apply (div_le_one (by exact_mod_cast card_pos.mpr hU)).mpr + exact_mod_cast card_le_card hSU + +lemma accepts_probability (S : Finset ι) (a : ℝ≥0) (M : ℕ) (P : (ι → ℕ) → Prop) : + acceptProb (proposal S a M) (accepts S M P)= + (law (uniformRate S a)).real {ω | total ω≤M ∧ (∀ i,i∉S → ω i=0) ∧ P ω} := by + rw [proposal,acceptProb_fromMeasure] + rw [show {x | accepts S M P (clip M x)}= + {ω | total ω≤M ∧ (∀ i,i∉S → ω i=0) ∧ P ω} by + exact acceptance_preimage M (fun ω => (∀ i,i∉S → ω i=0) ∧ P ω)] + +theorem proposal_success (S U : Finset ι) (a : ℝ≥0) (M : ℕ) + (hS : S.Nonempty) (hU : U.Nonempty) (hSU : S⊆U) (P : (ι → ℕ) → Prop) : + ((S.card:ℝ)/(U.card:ℝ))^M * + (law (uniformRate S a)).real {ω | total ω≤M ∧ (∀ i,i∉S → ω i=0) ∧ P ω} ≤ + acceptProb (proposal U a M) (accepts S M P) := by + rw [←accepts_probability] + unfold acceptProb accepted + simp only [mul_one] + rw [mul_sum] + apply sum_le_sum + intro z _ + by_cases hz : accepts S M P z + · simp only [ite_eq_left hz] + exact atom_domination S U a M hS hU hSU P z hz + · simp [hz] + +lemma hidden_support_ae (S : Finset ι) (a : ℝ≥0) : + ∀ᵐ ω ∂law (uniformRate S a),∀ i,i∉S → ω i=0 := by + apply ae_all_iff.mpr + intro i + by_cases hi : i∈S + · filter_upwards [] with ω using (fun h => False.elim (h hi)) + · have hp := measurePreserving_eval (fun j => poissonMeasure (uniformRate S a j)) i + have hx : ∀ᵐ n ∂poissonMeasure (uniformRate S a i),n=0 := by + rw [uniformRate,ite_eq_right hi] + apply (ae_iff_prob_eq_one (measurable_of_countable (fun n : ℕ => n=0))).mpr + change (poissonMeasure 0) {0}=1 + rw [poissonMeasure_singleton] + norm_num + exact (hp.quasiMeasurePreserving.ae hx).mono (fun ω h _ => h) + +lemma true_success_probability (S : Finset ι) (a : ℝ≥0) (M : ℕ) (P : (ι → ℕ) → Prop) : + (law (uniformRate S a)).real {ω | total ω≤M ∧ (∀ i,i∉S → ω i=0) ∧ P ω}= + (law (uniformRate S a)).real {ω | total ω≤M ∧ P ω} := by + apply measureReal_congr + filter_upwards [hidden_support_ae S a] with ω hω + apply propext + tauto + +end +end SharpLogRamsey.PreparedProposals + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedResidualBounds.lean b/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedResidualBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..7938069313c106fbeb697de47a71940aac5b6bc4 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedResidualBounds.lean @@ -0,0 +1,56 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.PreparedRadialBounds + +namespace OAI + +section +namespace SharpLogRamsey.PreparedRadialResidual +open Finset PreparedProjectiveGeometry +open scoped Classical BigOperators +noncomputable section +variable {q : ℕ} [Fact q.Prime] +local instance flat_JoinedPreparedResidualBounds_1 : Finite (Submodule (ZMod q) (Fin 4→ZMod q)) := + Finite.of_injective (fun W : Submodule (ZMod q) (Fin 4→ZMod q) => (W : Set (Fin 4→ZMod q))) + SetLike.coe_injective +local instance flat_JoinedPreparedResidualBounds_2 : Fintype (Submodule (ZMod q) (Fin 4→ZMod q)) := Fintype.ofFinite _ +local instance flat_JoinedPreparedResidualBounds_3 : Fintype (Projectivization (ZMod q) (Fin 4→ZMod q)) := Fintype.ofFinite _ + +theorem residual_radial_pairs (hq : 3≤q) + (S : Finset (Projectivization (ZMod q) (Fin 4→ZMod q))) (hS : S.Nonempty) + (X : Projectivization (ZMod q) (Fin 4→ZMod q)→Finset (Projectivization (ZMod q) (Fin 4→ZMod q))) + (hX : ∀ x,X x⊆S) (c a : ℝ) (hc : 0 f P.rep=0)).card≤Kp) + (hsmall : 198*Real.sqrt ((S.card:ℝ)/⌈a/c⌉₊)<⌈a/c⌉₊) + (hchar : 33*Real.sqrt ((S.card:ℝ)/⌈a/c⌉₊) z.1∈planePoints z.2.1 ∧ M≤(X z.1∩planePoints z.2.1).card)).card + have hp : P*M≤8718*(q+1)*S.card := + residual_pairs hq S hS X hX M Kp hM2 hMN hcap hsmall hchar hprob hKM + have hp' : (P:ℝ)*(M:ℝ)≤8718*((q:ℝ)+1)*S.card := by exact_mod_cast hp + have hsum : (∑ x,((richRadials (X x) x c a).card:ℝ))≤P := by + exact_mod_cast sum_richRadials_le_pairs X c a M + (fun x W hw => rich_threshold (X x) x W a c hc hw) + have haM : a≤c*M := by + have hh := Nat.le_ceil (a/c) + exact (div_le_iff₀ hc).mp hh |>.trans_eq (mul_comm _ _) + have hh1 := mul_le_mul_of_nonneg_right hsum ha + have hh2 := mul_le_mul_of_nonneg_left haM (Nat.cast_nonneg P) + have hh3 := mul_le_mul_of_nonneg_left hp' hc.le + have hh : (∑ x,((richRadials (X x) x c a).card:ℝ))*a≤ + 8718*((q:ℝ)+1)*(c*S.card) := by nlinarith + simpa only [pow_two, mul_assoc] using mul_le_mul_of_nonneg_right hh ha + +end +end SharpLogRamsey.PreparedRadialResidual + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedShortRow.lean b/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedShortRow.lean new file mode 100644 index 0000000000000000000000000000000000000000..e0d23d4ab03c1e0482fdcfd192caeaa6f026124d --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedShortRow.lean @@ -0,0 +1,136 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Learning.PreparedDescription +import OAI.Combinatorics.SharpRamsey.Learning.LearningScalar +import OAI.Combinatorics.SharpRamsey.Geometry.SparsePencilBounds + +namespace OAI + +section +namespace SharpLogRamsey.PreparedDescription +open Finset MeasureTheory PreparedRow GreedyPreparation Real +open scoped Classical BigOperators NNReal +noncomputable section +variable {K V I B : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedPreparedShortRow_1 (R : ℕ) : DecidableEq (Fin R × Projectivization K V) := Classical.decEq _ +local instance flat_JoinedPreparedShortRow_2 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedPreparedShortRow_3 : Fintype (Projectivization K (Module.Dual K V)) := Fintype.ofFinite _ +local instance flat_JoinedPreparedShortRow_4 : Fintype (Projectivization K V) := by + letI : Finite V := Module.finite_of_finite K + exact Fintype.ofFinite _ + +lemma good_mono (S : Finset (Projectivization K V)) + (plane : B→Finset (Projectivization K V)) (bs : List (B×ℕ)) + {L cap cap' size size' : ℝ} {R : ℕ} {ω : Fin R×Projectivization K V→ℕ} + (hc : cap'≤cap) (hs : size ≤ size') (h : good S plane bs L cap size ω) : + good S plane bs L cap' size' ω := by + obtain ⟨z,hz,hcap,hsize⟩ := h + exact ⟨z,hz,hc.trans hcap,hsize.trans hs⟩ + +omit [Field K] [Finite K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] in +lemma acceptProb_mono {Ω : Type*} [Fintype Ω] (p : PublicTables.Law Ω) + (A A' : Ω→Prop) (h : ∀ x,A x→A' x) : + PublicTables.acceptProb p A≤PublicTables.acceptProb p A' := by + unfold PublicTables.acceptProb PublicTables.accepted + apply sum_le_sum + intro x _ + by_cases hx : A x + · simp only [hx,h x hx,ite_true] + exact le_rfl + · simp only [hx,ite_false] + split_ifs <;> simp [p.nonneg x] + +theorem short_proposal + (n R p h M : ℕ) (hn : n≤1) (hdim : Module.finrank K V=n+3) + (S₀ S U Ds Da : Finset (Projectivization K V)) (hS : S.Nonempty) + (hS₀ : S⊆S₀) (hSU : S⊆U) (hDa : Ds⊆Da) + (plane : B→Finset (Projectivization K V)) (bs : List B) + (E E₀ : Finset (Projectivization K (Module.Dual K V))) (hE₀ : E₀.Nonempty) (hE₀E : E₀⊆E) + (c L : ℝ≥0) (hc : (c:ℝ)=(Nat.card K:ℝ)/(S.card:ℝ)) + (hf : ∀ x,((own S₀ plane bs x).card:ℝ)/(S.card:ℝ)≤1/25) + (σ P B₀ C b e W : ℝ) (hσ : 1≤σ) (hqexp : exp σ=(Nat.card K:ℝ)) + (hP : 100000000000000≤P) (hPu : P≤σ) (hPL : P=(L:ℝ)*R) + (hBdef : B₀=(Nat.card K:ℝ)^(n+2)/(S.card:ℝ)) + (hb : 0≤b) (he : 0≤e) (hloss : b+e≤P/1000000) + (hpP : 10000*σ≤(p:ℝ)*P) + (hDs : (Ds.card:ℝ)≤S.card*exp (-P/200)+(S.card:ℝ)/10000) + (hDaSize : (Da.card:ℝ)≤2*S.card+S.card*exp (5*P)) + (hN : 2*(Nat.card K:ℝ)*P≤S.card) + (hC : 0≤C) (hL : 10000≤(L:ℝ)) (hR : 400≤R) (hp : 0y i) a ha + obtain ⟨ω,hω,hθ,hG⟩:=contextual_fresh_source n k p θ G e own t hp z hz y hy + exact ⟨ω,hω,hθ,(hG i).trans he⟩ + +lemma prepared_marginal_domain (S : Θ→ι→Finset β) + (hS : ∀ ω,p.mass ω≠0→∀ i,G ω i∈S (θ ω) i) + (i : (contextual n k p θ G e own t).Index z.1) : + ∀ a,a∉S z.1.1 ((contextual n k p θ G e own t).origin z.1 i)→ + (((contextual n k p θ G e own t).tupleLaw z.1).marginal i).mass a=0 := by + intro a ha + by_contra h + obtain ⟨ω,hω,hθ,hG⟩:=prepared_marginal_source n k p θ G e own t hp z hz i a h + have hh:=hS ω hω ((contextual n k p θ G e own t).origin z.1 i) + rw [hθ,hG] at hh + exact ha hh + +lemma prepared_marginal_property (P : Θ→ι→β→Prop) + (hP : ∀ ω,p.mass ω≠0→∀ i,P (θ ω) i (G ω i)) + (i : (contextual n k p θ G e own t).Index z.1) : + ∀ a,(((contextual n k p θ G e own t).tupleLaw z.1).marginal i).mass a≠0→ + P z.1.1 ((contextual n k p θ G e own t).origin z.1 i) a := by + intro a ha + obtain ⟨ω,hω,hθ,hG⟩:=prepared_marginal_source n k p θ G e own t hp z hz i a ha + simpa only [hθ,hG] using hP ω hω ((contextual n k p θ G e own t).origin z.1 i) + +lemma prepared_pair_property (P : Θ→ι→ι→β→β→Prop) + (hP : ∀ ω,p.mass ω≠0→∀ i j,P (θ ω) i j (G ω i) (G ω j)) + (i j : (contextual n k p θ G e own t).Index z.1) : + ∀ y,((contextual n k p θ G e own t).tupleLaw z.1).mass y≠0→ + P z.1.1 ((contextual n k p θ G e own t).origin z.1 i) + ((contextual n k p θ G e own t).origin z.1 j) (y i) (y j) := by + intro y hy + obtain ⟨ω,hω,hθ,hG⟩:=contextual_fresh_source n k p θ G e own t hp z hz y hy + simpa only [hθ,hG i,hG j] using hP ω hω ((contextual n k p θ G e own t).origin z.1 i) + ((contextual n k p θ G e own t).origin z.1 j) + +end +end SharpLogRamsey.Selection.ExposureModel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedSparse.lean b/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedSparse.lean new file mode 100644 index 0000000000000000000000000000000000000000..7478d02139a268631bbffc5bfcc60c950ee8a212 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedSparse.lean @@ -0,0 +1,80 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Learning.PreparedGeometry + +namespace OAI + +section +namespace SharpLogRamsey.PreparedGeometry +open Finset PreparedRow PreparedTypical GreedyPreparation +open scoped BigOperators Classical NNReal +noncomputable section + +lemma half_small {α : Type*} (T : Finset α) (w : α→ℝ) (τ : ℝ) + (hτ : 0<τ) (hw : ∀ x∈T,0≤w x) (hm : (∑ x∈T,w x)≤τ*T.card) : + (T.card:ℝ)/2≤((T.filter (fun x => w x≤2*τ)).card:ℝ) := by + let A := T.filter (fun x => w x≤2*τ) + let B := T\A + have hb : ∀ x∈B,2*τ≤w x := by + intro x hx + have hh := mem_sdiff.mp hx + exact (lt_of_not_ge (fun he => hh.2 (mem_filter.mpr ⟨hh.1,he⟩))).le + have hsum : 2*τ*(B.card:ℝ)≤∑ x∈T,w x := by + calc + _ = ∑ x∈B,2*τ := by simp [mul_comm] + _ ≤ ∑ x∈B,w x := sum_le_sum hb + _ ≤ ∑ x∈T,w x := sum_le_sum_of_subset_of_nonneg sdiff_subset (fun x hx _ => hw x hx) + have hc : B.card+A.card=T.card := card_sdiff_add_card_eq_card (filter_subset _ _) + have hc' : (B.card:ℝ)+(A.card:ℝ)=T.card := by exact_mod_cast hc + change (T.card:ℝ)/2≤(A.card:ℝ) + nlinarith [hsum.trans hm] + +variable {K V J : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedPreparedSparse_1 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedPreparedSparse_2 : Fintype (Projectivization K (Module.Dual K V)) := Fintype.ofFinite _ +local instance flat_JoinedPreparedSparse_3 : Fintype (Projectivization K V) := by + letI : Finite V := Module.finite_of_finite K + exact Fintype.ofFinite _ + +theorem sparse_training (S : Finset (Projectivization K V)) + (U : J→Finset (Projectivization K V)) (bs : List J) (c : ℝ≥0) + (T : Finset (Projectivization K (Module.Dual K V))) (hT : T.Nonempty) + (τ : ℝ) (hτ : 0<τ) (hτsmall : 2*τ<9/10) + (hSparse : (∑ H∈T,mass S c H)≤τ*T.card) : + let E₀ := T.filter (fun H => mass S c H≤2*τ) + E₀.Nonempty ∧ (T.card:ℝ)/2≤(E₀.card:ℝ) ∧ + E₀⊆badHyperplanes S U bs c ∧ ∀ H∈E₀,mass S c H≤2*τ := by + dsimp only + have hh := half_small T (mass S c) τ hτ (by intro H _; unfold mass; positivity) hSparse + refine ⟨?_,hh,?_,?_⟩ + · apply card_pos.mp + have hp : (0:ℝ) mass S c H≤2*τ)).card := lt_of_lt_of_le (by linarith) hh + exact_mod_cast this + · intro H hH + have hb := (mem_filter.mp hH).2 + have habs : 1/10 < |mass S c H-1| := by + rw [abs_of_neg (by linarith)] + linarith + simp only [badHyperplanes,RegularPencils.exceptional,mem_filter,mem_univ,true_and] + exact Or.inl habs + · intro H hH + exact (mem_filter.mp hH).2 + +omit [Finite K] [FiniteDimensional K V] in + +lemma sparse_training_exponent (S : Finset (Projectivization K V)) + (c L : ℝ≥0) (R : ℕ) (H : Projectivization K (Module.Dual K V)) + (τ : ℝ) (hH : mass S c H≤2*τ) : + ((L*c:ℝ≥0):ℝ)*R*((S.filter (inc H)).card:ℝ)≤2*τ*((L:ℝ)*R) := by + have hh := mul_le_mul_of_nonneg_left hH (show 0≤(L:ℝ)*R by positivity) + unfold mass at hh + simp only [inc,NNReal.coe_mul] + nlinarith [hh] + +end +end SharpLogRamsey.PreparedGeometry + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedTypical.lean b/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedTypical.lean new file mode 100644 index 0000000000000000000000000000000000000000..0029f6a270883d37cd313fb3ebdd1e7d9d914d7b --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedTypical.lean @@ -0,0 +1,141 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.TestRowPencils + +namespace OAI + +section +namespace SharpLogRamsey.PreparedTypical +open Finset PreparedRow +open scoped Classical BigOperators NNReal +noncomputable section +variable {A : Type*} + +lemma outside_count (S O : Finset A) (hO : O⊆S) (x : A) (R : A→Prop) : + (((S\(O∪{x})).filter R).card:ℝ) ≤ (S.filter R).card-(O.filter R).card ∧ + (S.filter R).card-(O.filter R).card-1 ≤ (((S\(O∪{x})).filter R).card:ℝ) := by + have he : (S\(O∪{x})).filter R = ((S.filter R)\(O.filter R)).erase x := by + ext y + simp only [mem_filter,mem_sdiff,mem_union,mem_singleton,mem_erase] + aesop + have ho : O.filter R⊆S.filter R := filter_subset_filter R hO + have hk := card_sdiff_add_card_eq_card ho + have hn : (((S.filter R)\(O.filter R)).erase x).card ≤ ((S.filter R)\(O.filter R)).card := + card_le_card (erase_subset _ _) + have hl : ((S.filter R)\(O.filter R)).card ≤ (((S.filter R)\(O.filter R)).erase x).card+1 := by + by_cases hx : x∈((S.filter R)\(O.filter R)) + · rw [card_erase_of_mem hx]; omega + · rw [erase_eq_of_notMem hx]; omega + rw [he] + have hk' : (((S.filter R)\(O.filter R)).card:ℝ)+(O.filter R).card=(S.filter R).card := by exact_mod_cast hk + have hn' : ((((S.filter R)\(O.filter R)).erase x).card:ℝ)≤((S.filter R)\(O.filter R)).card := by exact_mod_cast hn + have hl' : (((S.filter R)\(O.filter R)).card:ℝ)≤(((S.filter R)\(O.filter R)).erase x).card+1 := by exact_mod_cast hl + constructor <;> linarith + +lemma outside_scalar (c f l o r : ℝ) (_hc : 0≤c) (hc1 : c≤1/100) + (hf0 : 0≤f) (hf : f≤1/25) + (hl : |l-1|≤1/10) (ho : |o-f|≤1/50) + (hr₁ : r≤l-o) (hr₂ : l-o-c≤r) : + 3/4≤r ∧ r≤2 ∧ |r-(1-f)|≤13/100 := by + rw [abs_le] at hl ho ⊢ + constructor + · linarith + constructor + · linarith + constructor <;> linarith + +lemma outside_square (c f l o r : ℝ) (hc : 0≤c) + (hr₁ : r≤l-o) (hr₂ : l-o-c≤r) : + (r-(1-f))^2≤3*((l-1)^2+(o-f)^2+c^2) := by + have he₁ : 0≤l-o-r := by linarith + have he₂ : l-o-r≤c := by linarith + have hes : (l-o-r)^2≤c^2 := by nlinarith + nlinarith [sq_nonneg ((l-1)+(o-f)),sq_nonneg ((l-1)+(l-o-r)), + sq_nonneg ((o-f)-(l-o-r))] + +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedPreparedTypical_1 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedPreparedTypical_2 : Fintype (Projectivization K (Module.Dual K V)) := Fintype.ofFinite _ + +def mass (S : Finset (Projectivization K V)) (c : ℝ≥0) + (H : Projectivization K (Module.Dual K V)) : ℝ := + (c:ℝ)*((S.filter (fun y => y.submodule≤LinearMap.ker H.rep)).card:ℝ) + +omit [Finite K] [FiniteDimensional K V] in +lemma outside_mass_between (S O : Finset (Projectivization K V)) (hO : O⊆S) + (x : Projectivization K V) (c : ℝ≥0) (H : Projectivization K (Module.Dual K V)) : + outsideMass S O x c H≤ mass S c H-mass O c H ∧ + mass S c H-mass O c H-c≤ outsideMass S O x c H := by + have he : (S\(O∪{x})).filter (fun y => y≠x ∧ y.submodule≤LinearMap.ker H.rep) = + (S\(O∪{x})).filter (fun y => y.submodule≤LinearMap.ker H.rep) := by + ext y + simp only [mem_filter,mem_sdiff,mem_union,mem_singleton] + aesop + have hh := outside_count S O hO x (fun y => y.submodule≤LinearMap.ker H.rep) + simp only [outsideMass,he,mass] + constructor + · have ht := mul_le_mul_of_nonneg_left hh.1 c.coe_nonneg + linarith + · have ht := mul_le_mul_of_nonneg_left hh.2 c.coe_nonneg + linarith + +omit [Finite K] [FiniteDimensional K V] in +theorem typical_point (S O : Finset (Projectivization K V)) (hO : O⊆S) + (x : Projectivization K V) (c : ℝ≥0) (H : Projectivization K (Module.Dual K V)) + (f : ℝ) (hc : (c:ℝ)≤1/100) (hf0 : 0≤f) (hf : f≤1/25) + (hl : |mass S c H-1|≤1/10) (ho : |mass O c H-f|≤1/50) : + 3/4≤ outsideMass S O x c H ∧ outsideMass S O x c H≤2 ∧ + |outsideMass S O x c H-(1-f)|≤13/100 := by + have hh := outside_mass_between S O hO x c H + exact outside_scalar c f _ _ _ c.coe_nonneg hc hf0 hf hl ho hh.1 hh.2 + +theorem typical_squares (S O : Finset (Projectivization K V)) (hO : O⊆S) + (x : Projectivization K V) (c : ℝ≥0) + (T : Finset (Projectivization K (Module.Dual K V))) (hT : T⊆pencil x) + (f U W : ℝ) + (hl : ∀ H∈T,|mass S c H-1|≤1/10) + (ho : ∀ H∈T,|mass O c H-f|≤1/50) + (hU : (∑ H∈pencil x,min 1 ((mass S c H-1)^2))≤U) + (hW : (∑ H∈pencil x,min 1 ((mass O c H-f)^2))≤W) : + (∑ H∈T,(outsideMass S O x c H-(1-f))^2)≤ + 3*(U+W+(T.card:ℝ)*(c:ℝ)^2) := by + have hl' : (∑ H∈T,(mass S c H-1)^2)≤U := by + calc + _ = ∑ H∈T,min 1 ((mass S c H-1)^2) := by + apply sum_congr rfl + intro H hH + have ht := hl H hH + rw [min_eq_right] + have hs := mul_self_le_mul_self (abs_nonneg (mass S c H-1)) ht + nlinarith [sq_abs (mass S c H-1)] + _ ≤ ∑ H∈pencil x,min 1 ((mass S c H-1)^2) := + sum_le_sum_of_subset_of_nonneg hT (fun _ _ _ => le_min (by norm_num) (sq_nonneg _)) + _ ≤ U := hU + have ho' : (∑ H∈T,(mass O c H-f)^2)≤W := by + calc + _ = ∑ H∈T,min 1 ((mass O c H-f)^2) := by + apply sum_congr rfl + intro H hH + have ht := ho H hH + rw [min_eq_right] + have hs := mul_self_le_mul_self (abs_nonneg (mass O c H-f)) ht + nlinarith [sq_abs (mass O c H-f)] + _ ≤ ∑ H∈pencil x,min 1 ((mass O c H-f)^2) := + sum_le_sum_of_subset_of_nonneg hT (fun _ _ _ => le_min (by norm_num) (sq_nonneg _)) + _ ≤ W := hW + calc + _ ≤ ∑ H∈T,3*((mass S c H-1)^2+(mass O c H-f)^2+(c:ℝ)^2) := by + apply sum_le_sum + intro H _ + have hh := outside_mass_between S O hO x c H + exact outside_square c f _ _ _ c.coe_nonneg hh.1 hh.2 + _ = 3*((∑ H∈T,(mass S c H-1)^2)+(∑ H∈T,(mass O c H-f)^2)+(T.card:ℝ)*(c:ℝ)^2) := by + simp only [←mul_sum,sum_add_distrib,sum_const,nsmul_eq_mul] + _ ≤ _ := by linarith + +end +end SharpLogRamsey.PreparedTypical + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedVariance.lean b/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedVariance.lean new file mode 100644 index 0000000000000000000000000000000000000000..48befcb2fd377a0cb3fcd46f640e51dc34756821 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Learning/PreparedVariance.lean @@ -0,0 +1,331 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Learning.TestActualRow +import OAI.Combinatorics.SharpRamsey.Learning.PreparedTypical + +namespace OAI + +section +namespace SharpLogRamsey.RegularPencils +open Finset +open scoped Classical BigOperators +open SharpLogRamsey.Incidence +noncomputable section +variable {A : Type*} [Fintype A] + +lemma sum_center_shift (f : A → ℝ) (μ a : ℝ) : + (∑ x,(f x-a)^2) ≤ 2*∑ x,(f x-μ)^2 + + 2*(Fintype.card A:ℝ)*(μ-a)^2 := by + calc + _ ≤ ∑ x, (2*(f x-μ)^2+2*(μ-a)^2) := by + apply sum_le_sum + intro x _ + nlinarith [sq_nonneg ((f x-μ)-(μ-a))] + _ = _ := by rw [sum_add_distrib,←mul_sum]; simp; ring + +lemma indicator_sum (C : Finset A) (c : ℝ) : + (∑ x,if x ∈ C then c else 0) = (C.card:ℝ)*c := by + rw [←sum_filter] + simp + +lemma indicator_square_sum (C : Finset A) (c : ℝ) : + (∑ x,(if x ∈ C then c else 0)^2) = (C.card:ℝ)*c^2 := by + simp_rw [ite_pow,zero_pow (by decide : 2≠0)] + exact indicator_sum C (c^2) + +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [Finite K] [FiniteDimensional K V] +variable [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K V))] + +theorem cell_total_variance {n : ℕ} (hdim : Module.finrank K V=n+3) + (C : Finset (Projectivization K V)) (N : ℝ) (hN : 0 if x∈C then (Nat.card K:ℝ)/N else 0) H - + (C.card:ℝ)/N)^2) ≤ 4*(Nat.card K:ℝ)^(n+3)*(C.card:ℝ)/N^2 := by + let q : ℝ := Nat.card K + let Q : ℝ := ∑ i ∈ range (n+3),q^i + let u : ℝ := ∑ i ∈ range (n+2),q^i + let w : Projectivization K V → ℝ := fun x => if x∈C then q/N else 0 + have hq : 1≤q := by + dsimp [q] + exact_mod_cast (Nat.one_le_iff_ne_zero.mpr (Nat.card_pos (α:=K)).ne') + have hq0 : 0 weightedIncidences SharpLogRamsey.Incidence.Incident w H) μ ((C.card:ℝ)/N) + rw [hvcard] at hmain + change (∑ H,(weightedIncidences SharpLogRamsey.Incidence.Incident w H-(C.card:ℝ)/N)^2) ≤ _ + calc + _ ≤ 2*(∑ H,(weightedIncidences SharpLogRamsey.Incidence.Incident w H-μ)^2)+2*Q*(μ-(C.card:ℝ)/N)^2 := hmain + _ ≤ 2*(q^(n+1)*((C.card:ℝ)*(q/N)^2))+2*((C.card:ℝ)/N^2) := by nlinarith + _ ≤ 4*q^(n+3)*(C.card:ℝ)/N^2 := by + rw [hexact] + have hh := mul_le_mul_of_nonneg_right hpow (show 0≤(C.card:ℝ)/N^2 by positivity) + have hh' : (C.card:ℝ)/N^2 ≤ q^(n+3)*(C.card:ℝ)/N^2 := by + simpa only [one_mul,mul_div_assoc] using hh + calc + _ ≤ 2*(q^(n+3)*(C.card:ℝ)/N^2)+ + 2*(q^(n+3)*(C.card:ℝ)/N^2) := by gcongr + _ = _ := by ring + +end +end SharpLogRamsey.RegularPencils + +namespace SharpLogRamsey.RegularPencils +open Finset +open scoped Classical BigOperators +noncomputable section +variable {A ι : Type*} [Fintype A] [Fintype ι] + +def exceptional (l : A → ℝ) (c : ι → A → ℝ) (f : ι → ℝ) : Finset A := + univ.filter (fun H => 1/10 < |l H-1| ∨ ∃ i,1/50 < |c i H-f i|) + +lemma exceptional_indicator (l : A → ℝ) (c : ι → A → ℝ) (f : ι → ℝ) (H : A) : + (if H∈exceptional l c f then (1:ℝ) else 0) ≤ + 100*(l H-1)^2+2500*∑ i,(c i H-f i)^2 := by + split_ifs with he + · rcases (mem_filter.mp he).2 with hl | ⟨i,hi⟩ + · have hs : (1/10:ℝ)^2 < (l H-1)^2 := by nlinarith [sq_abs (l H-1)] + have hp : 0 ≤ ∑ i,(c i H-f i)^2 := sum_nonneg (fun _ _ => sq_nonneg _) + nlinarith + · have hs : (1/50:ℝ)^2 < (c i H-f i)^2 := by nlinarith [sq_abs (c i H-f i)] + have hi' := single_le_sum (f:=fun i => (c i H-f i)^2) + (fun _ _ => sq_nonneg _) (mem_univ i) + nlinarith [sq_nonneg (l H-1)] + · positivity + +theorem exceptional_card (l : A → ℝ) (c : ι → A → ℝ) (f : ι → ℝ) + (V W : ℝ) (hl : ∑ H,(l H-1)^2 ≤ V) + (hc : ∑ i,∑ H,(c i H-f i)^2 ≤ W) : + ((exceptional l c f).card:ℝ) ≤ 100*V+2500*W := by + have hh := sum_le_sum (s:=univ) (fun H _ => exceptional_indicator l c f H) + simp only [sum_add_distrib,←mul_sum] at hh + rw [sum_comm] at hh + have hi : (∑ H,if H∈exceptional l c f then (1:ℝ) else 0) = + ((exceptional l c f).card:ℝ) := by rw [←sum_filter]; simp + rw [hi] at hh + linarith + +theorem exceptional_mass (l : A → ℝ) (c : ι → A → ℝ) (f : ι → ℝ) + (V W : ℝ) (hl : ∑ H,(l H-1)^2 ≤ V) + (hc : ∑ i,∑ H,(c i H-f i)^2 ≤ W) : + (∑ H∈exceptional l c f,l H) ≤ 201*V+5000*W := by + have hcard := exceptional_card l c f V W hl hc + calc + _ ≤ ∑ H∈exceptional l c f,(2+(l H-1)^2) := by + apply sum_le_sum + intro H _ + nlinarith [sq_nonneg (l H-3/2)] + _ = 2*((exceptional l c f).card:ℝ)+∑ H∈exceptional l c f,(l H-1)^2 := by + rw [sum_add_distrib]; simp; ring + _ ≤ 2*((exceptional l c f).card:ℝ)+V := by + gcongr + exact (sum_le_sum_of_subset_of_nonneg (subset_univ _) (fun _ _ _ => sq_nonneg _)).trans hl + _ ≤ _ := by linarith + +lemma clip_nonneg (x : ℝ) : 0 ≤ min 1 (x^2) := le_min (by norm_num) (sq_nonneg _) +lemma clip_le_one (x : ℝ) : min 1 (x^2) ≤ 1 := min_le_left _ _ +lemma clip_sum (x : A → ℝ) : (∑ H,min 1 ((x H)^2)) ≤ ∑ H,(x H)^2 := + sum_le_sum (fun _ _ => min_le_right _ _) + +end +end SharpLogRamsey.RegularPencils + +namespace SharpLogRamsey.PreparedVariance +open Finset PreparedRow PreparedTypical Incidence RegularPencils +open scoped Classical BigOperators NNReal +noncomputable section +variable {K V I : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] [Fintype I] +local instance flat_JoinedPreparedVariance_1 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedPreparedVariance_2 : Fintype (Projectivization K (Module.Dual K V)) := Fintype.ofFinite _ +local instance flat_JoinedPreparedVariance_3 : Fintype (Projectivization K V) := by + letI : Finite V := Module.finite_of_finite K + exact Fintype.ofFinite _ + +lemma mass_weighted (C : Finset (Projectivization K V)) (c : ℝ≥0) + (H : Projectivization K (Module.Dual K V)) : + mass C c H=weightedIncidences SharpLogRamsey.Incidence.Incident (fun x => if x∈C then (c:ℝ) else 0) H := by + dsimp [mass,weightedIncidences] + have he : (∑ x : Projectivization K V,if SharpLogRamsey.Incidence.Incident x H then (if x∈C then (c:ℝ) else 0) else 0)= + ∑ x∈C.filter (fun y => y.submodule≤LinearMap.ker H.rep),(c:ℝ) := by + rw [sum_filter] + calc + _ = ∑ x,if x∈C then (if x.submodule≤LinearMap.ker H.rep then (c:ℝ) else 0) else 0 := by + apply sum_congr rfl + intro x _ + simp only [incident_iff_submodule] + split_ifs <;> rfl + _ = _ := by rw [←sum_filter]; simp + rw [he] + simp [mul_comm] + +lemma actual_cell_variance {n : ℕ} (hdim : Module.finrank K V=n+3) + (C : Finset (Projectivization K V)) (N : ℝ) (hN : 0 mass (C i) c) + (fun i => ((C i).card:ℝ)/(S.card:ℝ)) + let Q := (Nat.card K:ℝ)^(n+3)/(S.card:ℝ) + (∑ H : Projectivization K (Module.Dual K V),(mass S c H-1)^2)≤4*Q ∧ + (∑ i,∑ H : Projectivization K (Module.Dual K V), + (mass (C i) c H-((C i).card:ℝ)/(S.card:ℝ))^2)≤4*Q ∧ + (E.card:ℝ)≤10400*Q ∧ (∑ H∈E,mass S c H)≤20804*Q := by + dsimp only + have hN : (0:ℝ) hi i) + _ = (4*(Nat.card K:ℝ)^(n+3)/(S.card:ℝ)^2)*(∑ i,((C i).card:ℝ)) := by + rw [mul_sum] + apply sum_congr rfl + intro i _ + ring + _ ≤ (4*(Nat.card K:ℝ)^(n+3)/(S.card:ℝ)^2)*(S.card:ℝ) := by + apply mul_le_mul_of_nonneg_left _ (by positivity) + exact_mod_cast hC + _ = _ := by field_simp + refine ⟨hs,htotal,?_,?_⟩ + · have h := exceptional_card (mass S c) (fun i => mass (C i) c) + (fun i => ((C i).card:ℝ)/(S.card:ℝ)) _ _ hs htotal + linarith + · have h := exceptional_mass (mass S c) (fun i => mass (C i) c) + (fun i => ((C i).card:ℝ)/(S.card:ℝ)) _ _ hs htotal + linarith + +def weights (S : Finset (Projectivization K V)) (C : I→Finset (Projectivization K V)) + (c : ℝ≥0) : Option (Option I)→Projectivization K (Module.Dual K V)→ℝ + | none,H => min 1 ((mass S c H-1)^2) + | some none,H => if H∈exceptional (mass S c) (fun i => mass (C i) c) + (fun i => ((C i).card:ℝ)/(S.card:ℝ)) then 1 else 0 + | some (some i),H => min 1 ((mass (C i) c H-((C i).card:ℝ)/(S.card:ℝ))^2) + +lemma weights_nonneg (S : Finset (Projectivization K V)) (C : I→Finset (Projectivization K V)) + (c : ℝ≥0) (i : Option (Option I)) (H : Projectivization K (Module.Dual K V)) : + 0≤weights S C c i H := by + cases i with + | none => exact clip_nonneg _ + | some i => cases i with + | none => dsimp [weights]; split_ifs <;> norm_num + | some i => exact clip_nonneg _ + +lemma weights_le_one (S : Finset (Projectivization K V)) (C : I→Finset (Projectivization K V)) + (c : ℝ≥0) (i : Option (Option I)) (H : Projectivization K (Module.Dual K V)) : + weights S C c i H≤1 := by + cases i with + | none => exact clip_le_one _ + | some i => cases i with + | none => dsimp [weights]; split_ifs <;> norm_num + | some i => exact clip_le_one _ + +lemma weights_total {n : ℕ} (hdim : Module.finrank K V=n+3) + (S : Finset (Projectivization K V)) (hS : S.Nonempty) + (C : I→Finset (Projectivization K V)) (hC : (∑ i,(C i).card)≤S.card) + (c : ℝ≥0) (hc : (c:ℝ)=(Nat.card K:ℝ)/(S.card:ℝ)) : + (∑ i,∑ H,weights S C c i H)≤10408*((Nat.card K:ℝ)^(n+3)/(S.card:ℝ)) := by + have hh := actual_exceptions hdim S hS C hC c hc + dsimp only at hh + have hs := clip_sum (fun H => mass S c H-1) + have hi := sum_le_sum (s:=univ) (fun i _ => clip_sum (fun H => mass (C i) c H-((C i).card:ℝ)/(S.card:ℝ))) + simp only [Fintype.sum_option,weights] + have he : (∑ H,if H∈exceptional (mass S c) (fun i => mass (C i) c) + (fun i => ((C i).card:ℝ)/(S.card:ℝ)) then (1:ℝ) else 0)= + ((exceptional (mass S c) (fun i => mass (C i) c) + (fun i => ((C i).card:ℝ)/(S.card:ℝ))).card:ℝ) := by rw [←sum_filter]; simp + rw [he] + linarith [hh.1,hh.2.1,hh.2.2.1] + +theorem exists_regular {n : ℕ} (hdim : Module.finrank K V=n+3) + (S : Finset (Projectivization K V)) (hS : S.Nonempty) + (C : I→Finset (Projectivization K V)) (hC : (∑ i,(C i).card)≤S.card) + (c : ℝ≥0) (hc : (c:ℝ)=(Nat.card K:ℝ)/(S.card:ℝ)) + (T : ℝ) (hT : 0≤T) + (hmean : (∑ k∈range (n+2),(Nat.card K:ℝ)^k)/(∑ k∈range (n+3),(Nat.card K:ℝ)^k)* + (10408*((Nat.card K:ℝ)^(n+3)/(S.card:ℝ)))≤T/2) : + ∃ D : Finset (Projectivization K V), + (D.card:ℝ)*(T/2)^2≤10408*(Nat.card K:ℝ)^(2*n+4)/(S.card:ℝ) ∧ + ∀ x∉D,∀ i,(∑ H∈pencil x,weights S C c i H) univ.filter (fun x : Projectivization K V => + T≤∑ H,if SharpLogRamsey.Incidence.Incident x H then weights S C c i H else 0)) + have hp : (0:ℝ)≤(∑ k∈range (n+2),(Nat.card K:ℝ)^k)/(∑ k∈range (n+3),(Nat.card K:ℝ)^k) := by positivity + have hmass := weights_total hdim S hS C hC c hc + have hm (i : Option (Option I)) : + (∑ k∈range (n+2),(Nat.card K:ℝ)^k)/(∑ k∈range (n+3),(Nat.card K:ℝ)^k)*∑ H,weights S C c i H≤T/2 := by + apply le_trans _ hmean + apply mul_le_mul_of_nonneg_left _ hp + apply le_trans _ hmass + exact single_le_sum (fun j _ => sum_nonneg (fun H _ => weights_nonneg S C c j H)) (mem_univ i) + have hd := pencil_family_tail hdim (weights S C c) (weights_nonneg S C c) (weights_le_one S C c) T hT hm + refine ⟨D,?_,?_⟩ + · apply hd.trans + calc + _ ≤ (Nat.card K:ℝ)^(n+1)*(10408*((Nat.card K:ℝ)^(n+3)/(S.card:ℝ))) := + mul_le_mul_of_nonneg_left hmass (by positivity) + _ = _ := by rw [show 2*n+4=(n+1)+(n+3) by omega,pow_add]; ring + · intro x hx i + have hn : ¬T≤∑ H,if SharpLogRamsey.Incidence.Incident x H then weights S C c i H else 0 := by + intro he + exact hx (mem_biUnion.mpr ⟨i,mem_univ _,mem_filter.mpr ⟨mem_univ _,he⟩⟩) + have he : (∑ H∈pencil x,weights S C c i H)= + ∑ H,if SharpLogRamsey.Incidence.Incident x H then weights S C c i H else 0 := by + rw [pencil,sum_filter] + apply sum_congr rfl + intro H _ + simp only [incident_iff_submodule] + rw [he] + exact lt_of_not_ge hn + +end +end SharpLogRamsey.PreparedVariance + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Learning/PublicDecoderCover.lean b/lean/OAI/Combinatorics/SharpRamsey/Learning/PublicDecoderCover.lean new file mode 100644 index 0000000000000000000000000000000000000000..a3e386f4ce23d5fd6f7f8f4939f18cbdf5648102 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Learning/PublicDecoderCover.lean @@ -0,0 +1,61 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Selection.UniversalTables + +namespace OAI + +section +namespace SharpLogRamsey.PublicTables +open Finset Real +open scoped Classical BigOperators +noncomputable section +variable {Ω ι X : Type*} [Fintype Ω] [Fintype ι] [Fintype X] + +omit [Fintype X] in + +theorem decoder_cover (p : Law Ω) (A : ι→Ω→Prop) (a H cap size : ℝ) + (Q : ℕ) (decode : Ω→Fin (Q+1)→Finset X) (support : ι→Finset X) + (ha : 0≤a) (hcard : (Fintype.card ι:ℝ)≤exp H) (hH : H+1≤exp a) + (hp : ∀ i,exp (-a)≤acceptProb p (A i)) + (hgood : ∀ i z,A i z → ∃ h,cap≤((support i)∩decode z h).card ∧ + ((decode z h).card:ℝ)≤ size) : + ∃ m : Finset (Ω×Fin (Q+1)), + m.card≤⌈exp (2*a)⌉₊*(Q+1) ∧ + (∀ z∈m,((decode z.1 z.2).card:ℝ)≤ size) ∧ + (∀ i,∃ z∈m,cap≤((support i)∩decode z.1 z.2).card) ∧ + log ((m.card:ℝ)+1)≤2*a+log 3+log ((Q:ℝ)+1) := by + obtain ⟨r,hr,hits,hlen⟩ := exists_cover p A a H ha hcard hH hp + let m := (r×ˢ(univ:Finset (Fin (Q+1)))).filter (fun z => ((decode z.1 z.2).card:ℝ)≤ size) + have hm : m.card≤⌈exp (2*a)⌉₊*(Q+1) := by + apply (card_filter_le _ _).trans + rw [card_product,card_univ,Fintype.card_fin] + exact Nat.mul_le_mul_right _ hr + refine ⟨m,hm,?_,?_,?_⟩ + · intro z hz + exact (mem_filter.mp hz).2 + · intro i + obtain ⟨z,hzr,hzi⟩ := hits i + obtain ⟨h,hcap,hsize⟩ := hgood i z hzi + exact ⟨(z,h),mem_filter.mpr ⟨mem_product.mpr ⟨hzr,mem_univ _⟩,hsize⟩,hcap⟩ + · have hh : (m.card:ℝ)+1≤((⌈exp (2*a)⌉₊:ℝ)+1)*((Q:ℝ)+1) := by + have hh : (m.card:ℝ)≤(⌈exp (2*a)⌉₊:ℝ)*((Q:ℝ)+1) := by exact_mod_cast hm + nlinarith [(show (0:ℝ)≤Q by positivity)] + calc + _ ≤ log (((⌈exp (2*a)⌉₊:ℝ)+1)*((Q:ℝ)+1)) := log_le_log (by positivity) hh + _ = log ((⌈exp (2*a)⌉₊:ℝ)+1)+log ((Q:ℝ)+1) := log_mul (by positivity) (by positivity) + _ ≤ _ := by linarith only [hlen] + +omit [Fintype Ω] [Fintype ι] [Fintype X] in +lemma sampling_exponent {n u : ℝ} (hn : 0 if ¬pass SharpLogRamsey.Incidence.Incident q z y then 1 else 0) m + +omit [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] in +lemma kernel_eq_uniform (S : Finset (Projectivization K V)) : + kernel S = uniformMass S := by + funext x + simp only [kernel, uniformMass, one_div] + +lemma Call.loss_bound {S : Finset (Projectivization K V)} (c : Call S) + {n : ℕ} (hdim : Module.finrank K V = n+3) + (y : Projectivization K (Module.Dual K V)) : + c.loss n y ≤ 12*(Nat.card K:ℝ) * + (∑ x, kernel S x * (if SharpLogRamsey.Incidence.Incident x y then 1 else 0)) := by + have h := (scheduled_from_original hdim S c.source c.proposal + (c.source_nonempty.mono c.source_original) c.source_nonempty + c.source_original c.source_proposal c.targetOriginal c.target c.domain + c.target_nonempty c.target_original c.target_domain c.target_fraction + 2 c.overhead (by norm_num) c.source_fraction c.proposal_ratio + (by convert c.sparse using 1; ring)).2.2 y + norm_num only [show (1000:ℝ)*2=2000 by norm_num, + show (6:ℝ)*2=12 by norm_num] at h + simpa only [Call.loss, sum_filter, kernel_eq_uniform, mul_ite, mul_one, mul_zero] using h + +def loss {Ξ : Type*} [Fintype Ξ] (ρ : Selection.Law Ξ) + {S : Finset (Projectivization K V)} (ready : Ξ → Option (Call S)) + (n : ℕ) (y : Projectivization K (Module.Dual K V)) : ℝ := + ∑ ξ, ρ.mass ξ * (ready ξ).elim 0 (fun c => c.loss n y) + +lemma loss_bound {Ξ : Type*} [Fintype Ξ] (ρ : Selection.Law Ξ) + {S : Finset (Projectivization K V)} (ready : Ξ → Option (Call S)) + {n : ℕ} (hdim : Module.finrank K V = n+3) + (y : Projectivization K (Module.Dual K V)) : + loss ρ ready n y ≤ 12*(Nat.card K:ℝ) * + (∑ x, kernel S x * (if SharpLogRamsey.Incidence.Incident x y then 1 else 0)) := by + let B := 12*(Nat.card K:ℝ) * + (∑ x, kernel S x * (if SharpLogRamsey.Incidence.Incident x y then 1 else 0)) + have hB : 0 ≤ B := by + dsimp [B] + apply mul_nonneg (by positivity) + exact sum_nonneg (fun x _ => mul_nonneg (kernel_nonneg _ _) (by split_ifs <;> norm_num)) + unfold loss + calc + _ ≤ ∑ ξ, ρ.mass ξ * B := by + apply sum_le_sum + intro ξ _ + apply mul_le_mul_of_nonneg_left _ (ρ.nonneg ξ) + cases hc : ready ξ with + | none => exact hB + | some c => exact c.loss_bound hdim y + _ = B := by rw [←sum_mul,ρ.total,one_mul] + +end +end SharpLogRamsey.ReadyTests + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Learning/RegularPreparationBounds.lean b/lean/OAI/Combinatorics/SharpRamsey/Learning/RegularPreparationBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..96419878d0c8a79cd5620307ccbe7c40847133ce --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Learning/RegularPreparationBounds.lean @@ -0,0 +1,142 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.SparsePencilBounds +import OAI.Combinatorics.SharpRamsey.Learning.PreparedSparse + +namespace OAI + +section +namespace SharpLogRamsey.PreparedGeometry +open Finset PreparedRow PreparedTypical GreedyPreparation +open scoped BigOperators Classical NNReal +noncomputable section + +lemma geometric_ratio_le (q : ℝ) (hq : 0 pow_nonneg hq.le i) + nlinarith + apply (div_le_div_iff₀ hp hq).mpr + linarith + +variable {K V J : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedRegularPreparationBounds_1 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedRegularPreparationBounds_2 : Fintype (Projectivization K (Module.Dual K V)) := Fintype.ofFinite _ +local instance flat_JoinedRegularPreparationBounds_3 : Fintype (Projectivization K V) := by + letI : Finite V := Module.finite_of_finite K + exact Fintype.ofFinite _ + +theorem source_regular_preparation {n : ℕ} (hdim : Module.finrank K V=n+3) + (S : Finset (Projectivization K V)) (hS : S.Nonempty) + (U : J→Finset (Projectivization K V)) (bs : List J) (c : ℝ≥0) + (hc : (c:ℝ)=(Nat.card K:ℝ)/(S.card:ℝ)) (hcsmall : (c:ℝ)≤ 1/100) + (hcell : ∀ i : Fin bs.length,((indexedCell S U bs i).card:ℝ)/(S.card:ℝ)≤ 1/25) + (L : ℝ) (hL : 0≤ L) : + let B := (Nat.card K:ℝ)^(n+2)/(S.card:ℝ) + let E := badHyperplanes S U bs c + ∃ D : Finset (Projectivization K V), + (D.card:ℝ)≤ (S.card:ℝ)/10000*Real.exp (-L/500) ∧ + (E.card:ℝ)≤ 10400*(Nat.card K:ℝ)*B ∧ + (∑ H∈E,mass S c H)≤ 20804*(Nat.card K:ℝ)*B ∧ + (∀ x,((own S U bs x).card:ℝ)/(S.card:ℝ)≤ 1/25) ∧ + ∀ x,x∉D → + ((pencil x∩E).card:ℝ)<50000*B*Real.exp (L/1000) ∧ + (∀ H∈pencil x\E, + 3/4≤ outsideMass S (own S U bs x) x c H ∧ + outsideMass S (own S U bs x) x c H≤ 2 ∧ + |outsideMass S (own S U bs x) x c H- + (1-((own S U bs x).card:ℝ)/(S.card:ℝ))|≤ 13/100) ∧ + (∑ H∈pencil x\E,(outsideMass S (own S U bs x) x c H- + (1-((own S U bs x).card:ℝ)/(S.card:ℝ)))^2)≤ 400000*B*Real.exp (L/1000) := by + let q : ℝ := Nat.card K + let s : ℝ := S.card + let B : ℝ := q^(n+2)/s + let e : ℝ := Real.exp (L/1000) + have hq : 2≤ q := by + change (2:ℝ)≤ Nat.card K + have hh : 2≤ Nat.card K := by have := (Finite.one_lt_card : 1 hFc,hFl⟩ + · refine ⟨∅,by simp,?_,by simpa using hL⟩ + exact fun hh => False.elim (hg hh) + choose F hF using hex + refine ⟨univ.biUnion F,?_,?_,?_⟩ + · intro W hW + obtain ⟨j,_,hj⟩ := mem_biUnion.mp hW + exact (hF j).1 W hj + · intro S T hSA hTB hg he + let j : I := (⟨S.card,by omega⟩,⟨T.card,by omega⟩) + obtain ⟨W,hW,hcap⟩ := (hF j).2.1 hg S T rfl rfl he + exact ⟨W,mem_biUnion.mpr ⟨j,mem_univ _,hW⟩,hcap⟩ + · have hh := union_log_bound (univ : Finset I) F L hL (fun j _ => (hF j).2.2) + simp only [card_univ,I,Fintype.card_prod,Fintype.card_fin] at hh + exact hh + +end +end SharpLogRamsey.PublicFamilies + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Learning/TestActualMoment.lean b/lean/OAI/Combinatorics/SharpRamsey/Learning/TestActualMoment.lean new file mode 100644 index 0000000000000000000000000000000000000000..01a2b567af4511606ea2afa82a3026c2c48992c4 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Learning/TestActualMoment.lean @@ -0,0 +1,158 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.TestRadialWeights + +namespace OAI + +section +namespace SharpLogRamsey.PreparedProjectiveGeometry +open Finset SharpLogRamsey.CertificateGeometry +open scoped Classical BigOperators +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedTestActualMoment_1 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedTestActualMoment_2 : Fintype (Projectivization K (Module.Dual K V)) := Fintype.ofFinite _ + +theorem one_direction_rank_card (m : ℕ) (hdim : Module.finrank K V ≤ m+2) + (A : Finset (Projectivization K (Module.Dual K V))) (x : Projectivization K V) + (W : RadialLine x) : + (A.filter (fun H => W∈lines x H)).card ≤ ∑ i∈range m,Nat.card K^i := by + have hd := Subspace.finrank_add_finrank_dualAnnihilator_eq W.1 + have hw := W.2.1 + have hm : Module.finrank K W.1.dualAnnihilator ≤ m := by omega + calc + _ ≤ Fintype.card {H : Projectivization K (Module.Dual K V) // W.1≤LinearMap.ker H.rep} := by + rw [←Fintype.card_coe] + apply Fintype.card_le_of_injective (fun H : {H // H∈A.filter (fun H => W∈lines x H)} => + (⟨H.1,(mem_lines _ _ _).mp (mem_filter.mp H.2).2⟩ : + {H : Projectivization K (Module.Dual K V) // W.1≤LinearMap.ker H.rep})) + intro H J he + apply Subtype.ext + exact congrArg (fun z => z.1) he + _ = ∑ i∈range (Module.finrank K W.1.dualAnnihilator),Nat.card K^i := card_through _ + _ ≤ _ := sum_le_sum_of_subset (range_mono hm) + +theorem pencil_rank_card (m : ℕ) (hdim : Module.finrank K V ≤ m+1) + (A : Finset (Projectivization K (Module.Dual K V))) (x : Projectivization K V) + (hA : ∀ H∈A,x.submodule≤LinearMap.ker H.rep) : + A.card ≤ ∑ i∈range m,Nat.card K^i := by + have hd := Subspace.finrank_add_finrank_dualAnnihilator_eq x.submodule + have hx := x.finrank_submodule + have hm : Module.finrank K x.submodule.dualAnnihilator ≤ m := by omega + calc + _ ≤ Fintype.card {H : Projectivization K (Module.Dual K V) // x.submodule≤LinearMap.ker H.rep} := by + rw [←Fintype.card_coe] + apply Fintype.card_le_of_injective (fun H : A => + (⟨H.1,hA H H.2⟩ : {H : Projectivization K (Module.Dual K V) // x.submodule≤LinearMap.ker H.rep})) + intro H J he + apply Subtype.ext + exact congrArg (fun z => z.1) he + _ = ∑ i∈range (Module.finrank K x.submodule.dualAnnihilator),Nat.card K^i := card_through _ + _ ≤ _ := sum_le_sum_of_subset (range_mono hm) + +end +end SharpLogRamsey.PreparedProjectiveGeometry +namespace SharpLogRamsey.PreparedProjectiveGeometry +open Finset MeasureTheory SharpRamseyFive.PoissonScore +open SharpRamseyFive.WeightedPrograms (DistinctPairs) +open scoped Classical BigOperators NNReal +noncomputable section +variable {K V I : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedTestActualMoment_3 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedTestActualMoment_4 : Fintype (Projectivization K (Module.Dual K V)) := Fintype.ofFinite _ + +lemma family_one_direction_rank (m : ℕ) (hdim : Module.finrank K V ≤ m+2) + (A : Finset (Projectivization K (Module.Dual K V))) (x : Projectivization K V) + (W : RadialLine x) : + (univ.filter (fun H : A => W∈lines x H)).card ≤ ∑ i∈range m,Nat.card K^i := by + have hh := one_direction_rank_card (K:=K) (V:=V) m hdim A x W + refine Nat.le_trans ?_ hh + apply Finset.card_le_card_of_injOn (fun H : A => H.val) + · intro H hH + exact mem_filter.mpr ⟨H.2,(mem_filter.mp hH).2⟩ + · intro H hH J hJ he + exact Subtype.ext he + +theorem actual_projective_high_moment + (j : ℕ) (hj : 2 ≤ j) (hj3 : j ≤ 3) (hdim : Module.finrank K V ≤ j+1) + (S : Finset (Projectivization K V)) (x : Projectivization K V) (c L : ℝ≥0) + (A : Finset (Projectivization K (Module.Dual K V))) + (hA : ∀ H∈A,x.submodule ≤ LinearMap.ker H.rep) + (f B : ℝ) (hf : f ≤ 1/25) {p : ℕ} (hp : 0 y≠x ∧ y.submodule ≤ LinearMap.ker H.rep)).card) + (hupp : ∀ H∈A,(c:ℝ)*(S.filter (fun y => y≠x ∧ y.submodule ≤ LinearMap.ker H.rep)).card ≤ 2) + (hdelta : ∀ H∈A,|(c:ℝ)*(S.filter (fun y => y≠x ∧ y.submodule ≤ LinearMap.ker H.rep)).card-(1-f)| ≤ 13/100) + (hB : Real.exp (3*((L:ℝ)*R)) ≤ B) + (hcard : ((∑ i∈range j,Nat.card K^i):ℝ) ≤ 4*B^2) + (hdir : ((∑ i∈range (j-1),Nat.card K^i):ℝ) ≤ 4*B) + (T : Finset I) (a : I → ℝ) (ha : ∀ i∈T,0 ≤ a i) + (hcover : ∀ H∈A,∀ J∈A,H≠J → 0 y≠x ∧ y.submodule ≤ LinearMap.ker H.rep)).card-(1-f))^2) ≤ B*Real.exp (((L:ℝ)*R)/100)) + (hpoly : SharpLogRamsey.MomentBudgetBridge.certificateOverhead p T.card ((L:ℝ)*R) ≤ Real.exp (2*((L:ℝ)*R)/25)) + (hshift : SharpLogRamsey.MomentBudgetBridge.shiftOverhead p T.card ≤ Real.exp (2*((L:ℝ)*R)/25)) + (hp2 : (p:ℝ)^2 ≤ Real.exp (((L:ℝ)*R)/10)) + (hps : 2*(p:ℝ)+3 ≤ Real.exp (((L:ℝ)*R)/10)) + (h : ℕ) (hh : 0 ω (r,d)))^p ∂batchMeasure (fun i : Fin R × RadialLine x => L*radialWeight S x c i.2)) + ≤ B^p*Real.exp (-(1/10:ℝ)*(p*((L:ℝ)*R))) := by + have hm H (hH : H∈A) := radialWeight_mass S x c H (hA H hH) + have hi H (hH : H∈A) J (hJ : J∈A) := radialWeight_intersection S x c H J (hA H hH) (hA J hJ) + apply SharpLogRamsey.HighMoment.prepared_pencil_high_moment + (radialWeight S x c) (fun H : A => lines x H) hp R own L (1-f) B + hL (by linarith) _ _ _ hB _ (∑ i∈range (j-1),Nat.card K^i) (by exact_mod_cast hdir) _ _ + T a ha _ _ _ _ _ hpoly hshift hp2 hps h hh hR hsize herr + · intro H + rw [hm H H.2] + exact hlow H H.2 + · intro H + rw [hm H H.2] + exact hupp H H.2 + · intro H + rw [hm H H.2] + exact (hdelta H H.2).trans (by norm_num) + · rw [Fintype.card_coe] + exact (Nat.cast_le.mpr (pencil_rank_card j hdim A x hA)).trans (by exact_mod_cast hcard) + · intro W + exact family_one_direction_rank (j-1) (by omega) A x W + · intro D E hne + exact family_two_directions (by omega) A x D E hne + · intro z hz + have he : SharpRamseyFive.WeightedPrograms.strength (fun H : A => lines x H) + (radialWeight S x c) z=overlap S x c z.1 z.2 := hi z.1 z.1.2 z.2 z.2.1.2 + rw [he] at hz ⊢ + exact hcover z.1 z.1.2 z.2 z.2.1.2 (fun he => z.2.2 (Subtype.ext he.symm)) hz + · intro i hiT + have hc := family_pair_card A S x c (a i) hA + change ((univ.filter (fun z : DistinctPairs A => + a i ≤ mass (radialWeight S x c) (lines x z.1∩lines x z.2))).card:ℝ)*a i^200 ≤ _ + rw [hc] + exact hcount i hiT + · intro H i hiT + rw [family_neighbor_card A S x c (a i) hA H] + exact hrow H H.2 i hiT + · intro H + rw [family_neighbor_card A S x c (1/(100*(p:ℝ))) hA H] + exact hstrong H H.2 + · calc + _ = ∑ H∈A,((c:ℝ)*(S.filter (fun y => y≠x ∧ y.submodule ≤ LinearMap.ker H.rep)).card-(1-f))^2 := by + rw [←Finset.sum_coe_sort A (fun H => ((c:ℝ)*(S.filter (fun y => y≠x ∧ y.submodule ≤ LinearMap.ker H.rep)).card-(1-f))^2)] + apply sum_congr rfl + intro H _ + rw [hm H H.2] + _ ≤ _ := hsq + +end +end SharpLogRamsey.PreparedProjectiveGeometry + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Learning/TestActualRow.lean b/lean/OAI/Combinatorics/SharpRamsey/Learning/TestActualRow.lean new file mode 100644 index 0000000000000000000000000000000000000000..20e4b2b919f98ac96f69f01c6fd2307b6804bcf5 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Learning/TestActualRow.lean @@ -0,0 +1,163 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Learning.TestRowBounds + +namespace OAI + +section +namespace SharpLogRamsey.PreparedRow +open Finset MeasureTheory LearningRow +open scoped BigOperators Classical NNReal +noncomputable section +variable {K V I : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedTestActualRow_1 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedTestActualRow_2 : Fintype (Projectivization K (Module.Dual K V)) := Fintype.ofFinite _ +local instance flat_JoinedTestActualRow_3 : Fintype (Projectivization K V) := by + letI : Finite V := Module.finite_of_finite K + exact Fintype.ofFinite _ + +abbrev inc (H : Projectivization K (Module.Dual K V)) (x : Projectivization K V) : Prop := + x.submodule≤LinearMap.ker H.rep + +lemma pencil_inter_count (Z : Finset (Projectivization K (Module.Dual K V))) (x : Projectivization K V) : + (pencil x∩Z).card=(Z.filter (fun H => inc H x)).card := by + congr 1 + ext H + simp only [pencil,inc,mem_filter,mem_univ,true_and,mem_inter] + tauto + +lemma pencil_degree (Z : Finset (Projectivization K (Module.Dual K V))) (x : Projectivization K V) : + PencilContrast.degree Incidence.Incident Z x=((pencil x∩Z).card:ℝ) := by + rw [pencil_inter_count] + simp only [PencilContrast.degree,Incidence.incident_iff_submodule,inc,card_filter, + Nat.cast_sum,Nat.cast_ite,Nat.cast_one,Nat.cast_zero] + +def rowTest (S : Finset (Projectivization K V)) (O : Projectivization K V→Finset (Projectivization K V)) + (E : Finset (Projectivization K (Module.Dual K V))) (b : Projectivization K V→ℝ) + {R : ℕ} (ω : Schedule S R) : Finset (Projectivization K V) := + test (sample S ω) (fun x => score S (O x) (pencil x) inc (b x) ω) + (emptySet S E inc ω).card (Nat.card K) + +theorem geometric_row_probability + (n R p h : ℕ) (hn : n≤1) (hdim : Module.finrank K V=n+3) + (S Ds Da : Finset (Projectivization K V)) (hS : S.Nonempty) (hDa : Ds⊆Da) + (O : Projectivization K V→Finset (Projectivization K V)) + (E E₀ : Finset (Projectivization K (Module.Dual K V))) (hE₀ : E₀.Nonempty) (hE₀E : E₀⊆E) + (c L : ℝ≥0) (hc : (c:ℝ)=(Nat.card K:ℝ)/(S.card:ℝ)) + (f : Projectivization K V→ℝ) (hf : ∀ x,f x≤1/25) + (B C bE δ u zmin W tS tA : ℝ) + (hδ : 0≤δ) (hu : 0 L*c)).real {ω | + ((sample S ω).card:ℝ)≤2*μmean ∧ + (S.card:ℝ)-(Ds.card:ℝ)-tS-(10*(δ+u))*(S.card:ℝ)≤ + (S∩rowTest S O E (fun x => Real.exp (-(L:ℝ)*(1-f x))) ω).card ∧ + ((rowTest S O E (fun x => Real.exp (-(L:ℝ)*(1-f x))) ω).card:ℝ)≤ + 2*μmean+(Da.card:ℝ)+tA+100*q^(n+3)/zmin} := by + dsimp only + let q : ℝ := Nat.card K + let b : Projectivization K V→ℝ := fun x => Real.exp (-(L:ℝ)*(1-f x)) + let μ := PoissonSchedules.scheduleLaw (fun _ : Fin R×S => L*c) + let μmean : ℝ := (R:ℝ)*S.card*(L*c:ℝ≥0) + let z := fun ω : Schedule S R => ((emptySet S E inc ω).card:ℝ) + let zx := fun (ω : Schedule S R) x => ((pencil x∩emptySet S E inc ω).card:ℝ) + let typ := fun (ω : Schedule S R) x => score S (O x) (pencil x\E) inc (b x) ω + let full := fun (ω : Schedule S R) x => score S (O x) (pencil x) inc (b x) ω + let t := zmin/(10*q) + let εs := B^2*Real.exp (-(3/5:ℝ)*((L:ℝ)*R))/t^2 + let εa := B^p*Real.exp (-(1/10:ℝ)*(p*((L:ℝ)*R)))/t^p + let FS := fun x => {ω : Schedule S R | x∉Ds ∧ x∉sample S ω ∧ t≤|typ ω x|} + let FA := fun x => {ω : Schedule S R | x∉Da ∧ x∉sample S ω ∧ t≤|typ ω x|} + let G := {ω : Schedule S R | zmin≤z ω ∧ + (∑ H∈emptySet S E inc ω,(q/(S.card:ℝ))*((S.filter (inc H)).card:ℝ))≤(δ+u)*z ω} + have hq : 0 (q/(S.card:ℝ))*((S.filter (inc H)).card:ℝ)) ((L:ℝ)*R) bE δ u zmin W + hE₀ hE₀E (by positivity) hδ hu hzmin (by intro H _; positivity) + (by intro H _; rw [NNReal.coe_mul,hc]; ring) hsmall hW hZ + have hfs : ∀ x∈S,μ.real (FS x)≤εs := by + intro x _ + by_cases hx : x∈Ds + · have he : FS x=∅ := by ext ω; simp [FS,hx] + rw [he,measureReal_empty] + dsimp [εs] + positivity + · have hh := score_second_tail (n+2) R hd S (O x) x c L E (f x) B C + (by linarith [hf x]) hB0 hC (by linarith) (by omega) T a (hs x hx) t ht + exact (measureReal_mono (h₂:=measure_ne_top μ _) (fun ω hω => hω.2)).trans hh + have hfa : ∀ x,μ.real (FA x)≤εa := by + intro x + by_cases hx : x∈Da + · have he : FA x=∅ := by ext ω; simp [FA,hx] + rw [he,measureReal_empty] + dsimp [εa] + have hBp : 0≤B^p := pow_nonneg hB0 p + positivity + · have hh := score_high_tail (n+2) R p h (by omega) (by omega) hd S (O x) x c L E + (f x) B (hf x) hp hpe hL hR hB T a (ha x hx) t ht + exact (measureReal_mono (h₂:=measure_ne_top μ _) (fun ω hω => hω.2)).trans hh + have halpha (x : Projectivization K V) := alpha_bounds (L:ℝ) (f x) R L.coe_nonneg (hf x) hα + have herrors : ∀ ω∈G,∀ x,x∉Ds → x∉sample S ω → + |(full ω x-typ ω x)-(1-b x)^R*zx ω x|≤z ω/(100*q) := by + intro ω hω x hx _ + exact (exceptional_error S (O x) (pencil x) E inc (b x) ω + (halpha x).1 (halpha x).2.1).trans ((herror x hx).trans + (div_le_div_of_nonneg_right hω.1 (by positivity))) + have htypS : ∀ ω∈G,∀ x∈S,x∉Ds → x∉sample S ω → ω∉FS x → |typ ω x|≤z ω/(10*q) := by + intro ω hω x _ hx hsample hFS + have hh : |typ ω x| hFS ⟨hx,hsample,hh⟩) + exact hh.le.trans (div_le_div_of_nonneg_right hω.1 (by positivity)) + have htypA : ∀ ω∈G,∀ x,x∉Da → x∉sample S ω → ω∉FA x → |typ ω x|≤z ω/(10*q) := by + intro ω hω x hx hsample hFA + have hh : |typ ω x| hFA ⟨hx,hsample,hh⟩) + exact hh.le.trans (div_le_div_of_nonneg_right hω.1 (by positivity)) + have hZnonempty (ω : Schedule S R) (hω : ω∈G) : (emptySet S E inc ω).Nonempty := by + apply card_pos.mp + have hh : (0:ℝ)<(emptySet S E inc ω).card := hzmin.trans_le hω.1 + exact_mod_cast hh + have hes : ∀ ω∈G,((S.filter (fun x => z ω/(10*q) zx ω x<(4/5)*z ω/q)).card:ℝ)≤100*q^(n+3)/zmin := by + intro ω hω + have hh := PencilContrast.ambient_small_degree hdim (emptySet S E inc ω) (hZnonempty ω hω) hQ + simp only [pencil_degree] at hh + apply hh.trans + exact div_le_div_of_nonneg_left (by positivity) hzmin hω.1 + have hh := row_success_probability μ S Ds Da (sample S) full typ zx z + (fun x => (1-b x)^R) q tS tA (10*(δ+u)*(S.card:ℝ)) (100*q^(n+3)/zmin) + (2*μmean) εs εa (Real.exp (-μmean/3)) + (Real.exp (-bE)/2-W*Real.exp (-((L:ℝ)*R)*δ)/(u*zmin)) G FS FA + (fun x _ => (Set.to_countable _).measurableSet) (fun x => (Set.to_countable _).measurableSet) + hq htS htA hgood hfs hfa (sample_size_tail S R (L*c)) + (fun ω hω => hzmin.trans_le hω.1) (fun ω _ x => Nat.cast_nonneg _) + (fun x => (halpha x).2.2) herrors htypS hDa htypA hes hea + exact hh + +end +end SharpLogRamsey.PreparedRow + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Learning/TestLearningIncidence.lean b/lean/OAI/Combinatorics/SharpRamsey/Learning/TestLearningIncidence.lean new file mode 100644 index 0000000000000000000000000000000000000000..92562918d09b75eea9fc91f0fb9d5f809a56e88d --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Learning/TestLearningIncidence.lean @@ -0,0 +1,227 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Entropy.TestPointMoments + +namespace OAI + +section +namespace SharpLogRamsey.ProjectiveDuality +open Finset +open scoped Classical BigOperators +open SharpLogRamsey.Incidence +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [Finite K] [FiniteDimensional K V] +variable [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K V))] +local instance flat_JoinedTestLearningIncidence_1 : Fintype (Projectivization K (Module.Dual K (Module.Dual K V))) := by + let : Finite (Module.Dual K (Module.Dual K V)) := Module.finite_of_finite K + exact Fintype.ofFinite _ + +theorem dual_variance_le {n : ℕ} (hdim : Module.finrank K V=n+3) + (w : Projectivization K (Module.Dual K V) → ℝ) : + (∑ x : Projectivization K V, + ((∑ H, if SharpLogRamsey.Incidence.Incident x H then w H else 0) - + (∑ i ∈ range (n+2), (Nat.card K:ℝ)^i) / + (∑ i ∈ range (n+3), (Nat.card K:ℝ)^i) * ∑ H, w H)^2) ≤ + (Nat.card K:ℝ)^(n+1) * ∑ H,w H^2 := by + have hh := projective_variance_le + (show Module.finrank K (Module.Dual K V)=n+3 from Subspace.dual_finrank_eq.trans hdim) w + rw [← (bidual (K:=K) (V:=V)).sum_comp] at hh + simpa only [weightedIncidences,incident_bidual] using hh + +end +end SharpLogRamsey.ProjectiveDuality + +namespace SharpLogRamsey.RegularPencils +open Finset +open scoped Classical BigOperators +open SharpLogRamsey.Incidence SharpLogRamsey.ProjectiveDuality +noncomputable section +variable {A : Type*} [Fintype A] + +lemma square_tail_card (f : A → ℝ) (μ t V : ℝ) (ht : 0 ≤ t) + (hv : ∑ x,(f x-μ)^2 ≤ V) : + ((univ.filter (fun x => μ+t ≤ f x)).card:ℝ)*t^2 ≤ V := by + calc + _ = ∑ x ∈ univ.filter (fun x => μ+t ≤ f x), t^2 := by simp + _ ≤ ∑ x ∈ univ.filter (fun x => μ+t ≤ f x), (f x-μ)^2 := by + apply sum_le_sum + intro x hx + have hh := (mem_filter.mp hx).2 + nlinarith + _ ≤ ∑ x,(f x-μ)^2 := sum_le_sum_of_subset_of_nonneg (subset_univ _) + (fun _ _ _ => sq_nonneg _) + _ ≤ _ := hv + +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [Finite K] [FiniteDimensional K V] +variable [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K V))] + +theorem pencil_weight_tail {n : ℕ} (hdim : Module.finrank K V=n+3) + (w : Projectivization K (Module.Dual K V) → ℝ) + (hw : ∀ H, 0≤w H) (hw1 : ∀ H,w H≤1) + (T : ℝ) (hT : 0≤T) + (hmean : (∑ i ∈ range (n+2),(Nat.card K:ℝ)^i) / + (∑ i ∈ range (n+3),(Nat.card K:ℝ)^i) * ∑ H,w H ≤ T/2) : + ((univ.filter (fun x : Projectivization K V => + T ≤ ∑ H,if SharpLogRamsey.Incidence.Incident x H then w H else 0)).card:ℝ) * (T/2)^2 ≤ + (Nat.card K:ℝ)^(n+1) * ∑ H,w H := by + let μ := (∑ i ∈ range (n+2),(Nat.card K:ℝ)^i) / + (∑ i ∈ range (n+3),(Nat.card K:ℝ)^i) * ∑ H,w H + have hnorm : ∑ H,w H^2 ≤ ∑ H,w H := by + apply sum_le_sum + intro H _ + nlinarith [hw H,hw1 H] + have hv := (dual_variance_le hdim w).trans + (mul_le_mul_of_nonneg_left hnorm (by positivity)) + have ht := square_tail_card (fun x : Projectivization K V => + ∑ H,if SharpLogRamsey.Incidence.Incident x H then w H else 0) μ (T/2) _ (by positivity) hv + apply le_trans (mul_le_mul_of_nonneg_right (Nat.cast_le.mpr (card_le_card ?_)) + (sq_nonneg _)) ht + intro x hx + apply mem_filter.mpr + refine ⟨mem_univ _,?_⟩ + have hh := (mem_filter.mp hx).2 + dsimp [μ] + linarith + +theorem pencil_family_tail {ι : Type*} [Fintype ι] {n : ℕ} + (hdim : Module.finrank K V=n+3) + (w : ι → Projectivization K (Module.Dual K V) → ℝ) + (hw : ∀ i H,0≤w i H) (hw1 : ∀ i H,w i H≤1) + (T : ℝ) (hT : 0≤T) + (hmean : ∀ i,(∑ k ∈ range (n+2),(Nat.card K:ℝ)^k) / + (∑ k ∈ range (n+3),(Nat.card K:ℝ)^k) * ∑ H,w i H ≤ T/2) : + ((univ.biUnion (fun i => univ.filter (fun x : Projectivization K V => + T ≤ ∑ H,if SharpLogRamsey.Incidence.Incident x H then w i H else 0))).card:ℝ) * (T/2)^2 ≤ + (Nat.card K:ℝ)^(n+1) * ∑ i,∑ H,w i H := by + calc + _ ≤ (∑ i,((univ.filter (fun x : Projectivization K V => + T ≤ ∑ H,if SharpLogRamsey.Incidence.Incident x H then w i H else 0)).card:ℝ)) * (T/2)^2 := by + apply mul_le_mul_of_nonneg_right _ (sq_nonneg _) + exact_mod_cast (card_biUnion_le : _ ≤ ∑ i,_) + _ = ∑ i,((univ.filter (fun x : Projectivization K V => + T ≤ ∑ H,if SharpLogRamsey.Incidence.Incident x H then w i H else 0)).card:ℝ)*(T/2)^2 := by rw [sum_mul] + _ ≤ ∑ i,(Nat.card K:ℝ)^(n+1) * ∑ H,w i H := + sum_le_sum (fun i _ => pencil_weight_tail hdim (w i) (hw i) (hw1 i) T hT (hmean i)) + _ = _ := by rw [mul_sum] + +end +end SharpLogRamsey.RegularPencils +namespace SharpLogRamsey.PencilContrast +open Finset +open scoped Classical BigOperators +open SharpLogRamsey.Incidence SharpLogRamsey.ProjectiveDuality +noncomputable section +variable {A B : Type*} + +def degree (R : A → B → Prop) (Z : Finset B) (x : A) : ℝ := + ∑ H∈Z,if R x H then 1 else 0 + +lemma sum_degree (R : A → B → Prop) (S : Finset A) (Z : Finset B) : + (∑ x∈S,degree R Z x) = ∑ H∈Z,∑ x∈S,if R x H then (1:ℝ) else 0 := by + exact sum_comm + +theorem support_large_degree (R : A → B → Prop) (S : Finset A) (Z : Finset B) + (q N z a b : ℝ) (hq : 0 < q) (hN : 0 < N) (hz : 0 < z) (hb : 0 < b) + (hh : (∑ H∈Z,(q/N)*∑ x∈S,if R x H then (1:ℝ) else 0) ≤ a*z) : + ((S.filter (fun x => b*z/q ≤ degree R Z x)).card:ℝ) ≤ (a/b)*N := by + have hid : (∑ H∈Z,(q/N)*∑ x∈S,if R x H then (1:ℝ) else 0) = + (q/N)*∑ x∈S,degree R Z x := by rw [←mul_sum,sum_degree] + rw [hid] at hh + have hsum : (∑ x∈S,degree R Z x) ≤ a*z*N/q := by + apply (le_div_iff₀ hq).mpr + have ht := (div_le_iff₀ hN).mp (show q*(∑ x∈S,degree R Z x)/N ≤ a*z from by + simpa only [div_mul_eq_mul_div] using hh) + nlinarith + have hmark : ((S.filter (fun x => b*z/q ≤ degree R Z x)).card:ℝ)*(b*z/q) ≤ + ∑ x∈S,degree R Z x := by + calc + _ = ∑ x∈S.filter (fun x => b*z/q ≤ degree R Z x),b*z/q := by simp + _ ≤ ∑ x∈S.filter (fun x => b*z/q ≤ degree R Z x),degree R Z x := + sum_le_sum (fun _ hx => (mem_filter.mp hx).2) + _ ≤ _ := sum_le_sum_of_subset_of_nonneg (filter_subset _ _) + (fun x _ _ => sum_nonneg (fun _ _ => by split_ifs <;> norm_num)) + have hfin := hmark.trans hsum + apply (le_of_mul_le_mul_right ?_ (show 0 < b*z/q by positivity)) + calc + _ ≤ a*z*N/q := hfin + _ = ((a/b)*N)*(b*z/q) := by field_simp + +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [Finite K] [FiniteDimensional K V] +variable [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K V))] + +theorem ambient_small_degree {n : ℕ} (hdim : Module.finrank K V=n+3) + (Z : Finset (Projectivization K (Module.Dual K V))) (hZ : Z.Nonempty) + (hQ : (10:ℝ) ≤ ∑ i∈range (n+3),(Nat.card K:ℝ)^i) : + ((univ.filter (fun x : Projectivization K V => + degree SharpLogRamsey.Incidence.Incident Z x < (4/5:ℝ)*(Z.card:ℝ)/(Nat.card K:ℝ))).card:ℝ) ≤ + 100*(Nat.card K:ℝ)^(n+3)/(Z.card:ℝ) := by + let q : ℝ := Nat.card K + let Q : ℝ := ∑ i∈range (n+3),q^i + let u : ℝ := ∑ i∈range (n+2),q^i + let z : ℝ := Z.card + let μ : ℝ := u/Q*z + have hq : 0 < q := by dsimp [q]; exact_mod_cast Nat.card_pos (α:=K) + have hz : 0 < z := by dsimp [z]; exact_mod_cast card_pos.mpr hZ + have hQ0 : 0 < Q := by dsimp [Q,q]; linarith + have hgeom : Q=q*u+1 := by dsimp [Q,u]; rw [geom_sum_succ] + have hmean : (9/10:ℝ)*z/q ≤ μ := by + apply (div_le_iff₀ hq).mpr + change (9/10:ℝ)*z ≤ u/Q*z*q + rw [show u/Q*z*q=(u*z*q)/Q by ring,le_div_iff₀ hQ0] + change (10:ℝ) ≤ Q at hQ + have hh : 9*Q ≤ 10*(Q-1) := by linarith + have ht := mul_le_mul_of_nonneg_right hh hz.le + have hgz := congrArg (fun a : ℝ => a*z) hgeom + nlinarith + let w : Projectivization K (Module.Dual K V) → ℝ := fun H => if H∈Z then 1 else 0 + have hs : ∑ H,w H = z := by dsimp [w,z]; rw [←sum_filter]; simp + have hs2 : ∑ H,w H^2 = z := by + have hi : ∀ H,w H^2=w H := by intro H; dsimp [w]; split_ifs <;> norm_num + simp_rw [hi]; exact hs + have hdeg (x : Projectivization K V) : + (∑ H,if SharpLogRamsey.Incidence.Incident x H then w H else 0)=degree SharpLogRamsey.Incidence.Incident Z x := by + dsimp [w,degree] + calc + _ = ∑ H,if H∈Z then (if SharpLogRamsey.Incidence.Incident x H then (1:ℝ) else 0) else 0 := by + apply sum_congr rfl + intro H _ + split_ifs <;> rfl + _ = _ := by rw [←sum_filter]; simp + have hv := dual_variance_le hdim w + simp_rw [hdeg,hs,hs2] at hv + change (∑ x,(degree SharpLogRamsey.Incidence.Incident Z x-μ)^2) ≤ q^(n+1)*z at hv + let E := univ.filter (fun x : Projectivization K V => degree SharpLogRamsey.Incidence.Incident Z x<(4/5:ℝ)*z/q) + have he : (E.card:ℝ)*(z/(10*q))^2 ≤ q^(n+1)*z := by + calc + _ = ∑ _x∈E,(z/(10*q))^2 := by simp + _ ≤ ∑ x∈E,(degree SharpLogRamsey.Incidence.Incident Z x-μ)^2 := by + apply sum_le_sum + intro x hx + have hh := (mem_filter.mp hx).2 + have hgap : z/(10*q) ≤ μ-degree SharpLogRamsey.Incidence.Incident Z x := by + have hi : (9/10:ℝ)*z/q-(4/5:ℝ)*z/q=z/(10*q) := by ring + linarith + nlinarith [show 0 ≤ z/(10*q) by positivity] + _ ≤ ∑ x,(degree SharpLogRamsey.Incidence.Incident Z x-μ)^2 := + sum_le_sum_of_subset_of_nonneg (subset_univ _) (fun _ _ _ => sq_nonneg _) + _ ≤ _ := hv + change (E.card:ℝ) ≤ 100*q^(n+3)/z + apply (le_of_mul_le_mul_right ?_ (sq_pos_of_pos (show 0 < z/(10*q) by positivity))) + calc + _ ≤ q^(n+1)*z := he + _ = (100*q^(n+3)/z)*(z/(10*q))^2 := by + rw [show n+3=(n+1)+2 by omega,pow_add] + field_simp + ring + +end +end SharpLogRamsey.PencilContrast + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Learning/TestLearningRowBase.lean b/lean/OAI/Combinatorics/SharpRamsey/Learning/TestLearningRowBase.lean new file mode 100644 index 0000000000000000000000000000000000000000..b8a52047fbb0182cf69306f559a022af820cab80 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Learning/TestLearningRowBase.lean @@ -0,0 +1,700 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Entropy.TestPointMoments + +namespace OAI + +section +open scoped BigOperators NNReal +open MeasureTheory ProbabilityTheory Finset +open scoped Classical +namespace SharpLogRamsey.PoissonSchedules +variable {ι : Type*} [Fintype ι] + +noncomputable def scheduleLaw (r : ι → ℝ≥0) : Measure (ι → ℕ) := + Measure.pi fun i => poissonMeasure (r i) + +instance schedule_probability (r : ι → ℝ≥0) : IsProbabilityMeasure (scheduleLaw r) := by + unfold scheduleLaw + infer_instance + +theorem coordinate_independence (r : ι → ℝ≥0) : + iIndepFun (fun i (x : ι → ℕ) => x i) (scheduleLaw r) := by + exact iIndepFun_pi (X:=fun _ => id) (fun _ => aemeasurable_id) + +def hitLedger (A : Finset ι) : Set (ι → ℕ) := {x | ∀ i ∈ A, x i ≠ 0} + +def emptyLedger (A : Finset ι) : Set (ι → ℕ) := {x | ∀ i ∈ A, x i = 0} + +theorem measurable_hitLedger (A : Finset ι) : MeasurableSet (hitLedger A) := by + exact (Set.to_countable (hitLedger A)).measurableSet + +theorem measurable_emptyLedger (A : Finset ι) : MeasurableSet (emptyLedger A) := by + exact (Set.to_countable (emptyLedger A)).measurableSet + +theorem poisson_zero_real (r : ℝ≥0) : (poissonMeasure r).real {0} = Real.exp (-r) := by + simpa using poissonMeasure_real_singleton r 0 + +theorem poisson_nonzero_real (r : ℝ≥0) : + (poissonMeasure r).real ({0}ᶜ) = 1-Real.exp (-r) := by + rw [measureReal_compl (measurableSet_singleton 0),poisson_zero_real] + simp + +theorem hitLedger_probability (r : ι → ℝ≥0) (A : Finset ι) : + (scheduleLaw r).real (hitLedger A) = ∏ i ∈ A, (1-Real.exp (-(r i : ℝ))) := by + have he : hitLedger A = (A : Set ι).pi (fun _ => ({0}ᶜ : Set ℕ)) := by + ext x; simp [hitLedger,Set.mem_pi] + rw [he,measureReal_def,scheduleLaw,Measure.pi_pi_finset,ENNReal.toReal_prod] + apply prod_congr rfl + intro i hi + exact poisson_nonzero_real (r i) + +theorem emptyLedger_probability (r : ι → ℝ≥0) (A : Finset ι) : + (scheduleLaw r).real (emptyLedger A) = Real.exp (-(∑ i ∈ A, (r i : ℝ))) := by + have he : emptyLedger A = (A : Set ι).pi (fun _ => ({0} : Set ℕ)) := by + ext x; simp [emptyLedger,Set.mem_pi] + rw [he,measureReal_def,scheduleLaw,Measure.pi_pi_finset,ENNReal.toReal_prod] + calc + _ = ∏ i ∈ A, Real.exp (-(r i : ℝ)) := prod_congr rfl (fun i hi => poisson_zero_real (r i)) + _ = _ := by rw [← Real.exp_sum,sum_neg_distrib] + +theorem hitLedger_le_mean_product (r : ι → ℝ≥0) (A : Finset ι) : + (scheduleLaw r).real (hitLedger A) ≤ ∏ i ∈ A, (r i : ℝ) := by + rw [hitLedger_probability] + apply prod_le_prod₀ + · intro i hi + have h := Real.exp_le_one_iff.mpr (neg_nonpos.mpr (r i).coe_nonneg) + linarith + · intro i hi + have h := Real.add_one_le_exp (-(r i : ℝ)) + linarith + +theorem static_certificate_bound {κ : Type*} [Fintype κ] + (r : ι → ℝ≥0) (ledger : κ → Finset ι) + (E : Set (ι → ℕ)) (hcert : ∀ x ∈ E, ∃ c, x ∈ hitLedger (ledger c)) : + (scheduleLaw r).real E ≤ ∑ c, ∏ i ∈ ledger c, (r i : ℝ) := by + calc + _ ≤ (scheduleLaw r).real (⋃ c, hitLedger (ledger c)) := by + apply measureReal_mono (h₂:=measure_ne_top _ _) + intro x hx + obtain ⟨c,hc⟩ := hcert x hx + exact Set.mem_iUnion.mpr ⟨c,hc⟩ + _ ≤ ∑ c, (scheduleLaw r).real (hitLedger (ledger c)) := measureReal_iUnion_fintype_le _ + _ ≤ _ := sum_le_sum fun c hc => hitLedger_le_mean_product r (ledger c) + +end SharpLogRamsey.PoissonSchedules +namespace SharpLogRamsey.EmptyExceptional +open MeasureTheory ProbabilityTheory Finset +open scoped BigOperators Classical NNReal +open SharpLogRamsey.PoissonSchedules SharpLogRamsey.BoundedProbability +noncomputable section +variable {ι H : Type*} + +def emptySum (E : Finset H) (D : H → Finset ι) (w : H → ℝ) (ω : ι → ℕ) : ℝ := + ∑ h∈E,if ω∈emptyLedger (D h) then w h else 0 + +def emptySet (E : Finset H) (D : H → Finset ι) (ω : ι → ℕ) : Finset H := + E.filter (fun h => ω∈emptyLedger (D h)) + +lemma emptySum_eq (E : Finset H) (D : H → Finset ι) (w : H → ℝ) (ω : ι → ℕ) : + emptySum E D w ω = ∑ h∈emptySet E D ω,w h := by + rw [emptySum,emptySet,sum_filter] + +lemma emptySum_one (E : Finset H) (D : H → Finset ι) (ω : ι → ℕ) : + emptySum E D (fun _ => 1) ω = ((emptySet E D ω).card:ℝ) := by + rw [emptySum_eq]; simp + +lemma emptySum_nonneg (E : Finset H) (D : H → Finset ι) (w : H → ℝ) + (hw : ∀ h∈E,0 ≤ w h) (ω : ι → ℕ) : 0 ≤ emptySum E D w ω := by + apply sum_nonneg + intro h hh + split_ifs + · exact hw h hh + · rfl + +lemma emptySum_le_sum (E : Finset H) (D : H → Finset ι) (w : H → ℝ) + (hw : ∀ h∈E,0 ≤ w h) (ω : ι → ℕ) : emptySum E D w ω ≤ ∑ h∈E,w h := by + apply sum_le_sum + intro h hh + split_ifs + · rfl + · exact hw h hh + +variable [Fintype ι] + +lemma integrable_emptySum (r : ι → ℝ≥0) (E : Finset H) (D : H → Finset ι) (w : H → ℝ) : + Integrable (emptySum E D w) (scheduleLaw r) := by + apply integrable_finsetSum + intro h _ + exact (integrable_const (w h)).indicator (measurable_emptyLedger (D h)) + +lemma integral_emptySum (r : ι → ℝ≥0) (E : Finset H) (D : H → Finset ι) (w : H → ℝ) : + (∫ ω,emptySum E D w ω ∂scheduleLaw r) = + ∑ h∈E,w h*Real.exp (-(∑ i∈D h,(r i:ℝ))) := by + simp only [emptySum] + rw [integral_finsetSum] + · apply sum_congr rfl + intro h _ + change (∫ ω,(emptyLedger (D h)).indicator (fun _ => w h) ω ∂scheduleLaw r) = _ + rw [integral_indicator_const _ (measurable_emptyLedger _),smul_eq_mul,emptyLedger_probability] + ring + · intro h _ + exact (integrable_const (w h)).indicator (measurable_emptyLedger (D h)) + +theorem many_empty (r : ι → ℝ≥0) (E : Finset H) (hE : E.Nonempty) + (D : H → Finset ι) (b : ℝ) (hb : ∀ h∈E,∑ i∈D h,(r i:ℝ) ≤ b) : + Real.exp (-b)/2 ≤ (scheduleLaw r).real {ω | + (E.card:ℝ)*Real.exp (-b)/2 ≤ emptySum E D (fun _ => 1) ω} := by + apply mass_above_half _ _ (integrable_emptySum r E D _) _ _ + · exact_mod_cast card_pos.mpr hE + · exact (Real.exp_pos _).le + · intro ω + simpa using emptySum_le_sum E D (fun _ => 1) (by intros; norm_num) ω + · rw [integral_emptySum] + calc + _ = ∑ _h∈E,Real.exp (-b) := by simp + _ ≤ _ := sum_le_sum (fun h hh => by simp only [one_mul]; exact Real.exp_le_exp.mpr (neg_le_neg (hb h hh))) + · exact (Set.to_countable _).measurableSet + +theorem heavy_empty_expectation (r : ι → ℝ≥0) (E : Finset H) + (D : H → Finset ι) (l : H → ℝ) (P δ W : ℝ) (hP : 0 ≤ P) + (hl : ∀ h∈E,0 ≤ l h) (hmass : ∀ h∈E,∑ i∈D h,(r i:ℝ)=P*l h) + (hW : ∑ h∈E,l h ≤ W) : + (∫ ω,emptySum (E.filter (fun h => δ ≤ l h)) D l ω ∂scheduleLaw r) ≤ + W*Real.exp (-P*δ) := by + rw [integral_emptySum] + calc + _ ≤ ∑ h∈E.filter (fun h => δ ≤ l h),l h*Real.exp (-P*δ) := by + apply sum_le_sum + intro h hh + have hh' := mem_filter.mp hh + apply mul_le_mul_of_nonneg_left _ (hl h hh'.1) + apply Real.exp_le_exp.mpr + rw [hmass h hh'.1] + nlinarith [mul_le_mul_of_nonneg_left hh'.2 hP] + _ ≤ ∑ h∈E,l h*Real.exp (-P*δ) := + sum_le_sum_of_subset_of_nonneg (filter_subset _ _) (fun h hh _ => + mul_nonneg (hl h hh) (Real.exp_pos _).le) + _ ≤ _ := by rw [←sum_mul]; exact mul_le_mul_of_nonneg_right hW (Real.exp_pos _).le + +omit [Fintype ι] in + +lemma empty_weight_split (E : Finset H) (D : H → Finset ι) (l : H → ℝ) + (δ : ℝ) (hδ : 0 ≤ δ) (ω : ι → ℕ) : + emptySum E D l ω ≤ δ*emptySum E D (fun _ => 1) ω+ + emptySum (E.filter (fun h => δ ≤ l h)) D l ω := by + simp only [emptySum,sum_filter] + rw [mul_sum,←sum_add_distrib] + apply sum_le_sum + intro h _ + by_cases he : ω∈emptyLedger (D h) <;> by_cases hh : δ ≤ l h <;> simp [he,hh] + · exact hδ + · exact (lt_of_not_ge hh).le + +end +end SharpLogRamsey.EmptyExceptional +namespace SharpLogRamsey.EmptyExceptional +open MeasureTheory ProbabilityTheory Finset +open scoped BigOperators Classical NNReal +open SharpLogRamsey.PoissonSchedules SharpLogRamsey.BoundedProbability +noncomputable section +variable {ι H : Type*} [Fintype ι] + +omit [Fintype ι] in +lemma emptySum_mono (D : H → Finset ι) (w : H → ℝ) {E F : Finset H} + (hEF : E⊆F) (hw : ∀ h∈F,0 ≤ w h) (ω : ι → ℕ) : + emptySum E D w ω ≤ emptySum F D w ω := by + apply sum_le_sum_of_subset_of_nonneg hEF + intro h hh _ + split_ifs + · exact hw h hh + · rfl + +theorem empty_good_event (r : ι → ℝ≥0) (E E₀ : Finset H) (hE₀ : E₀.Nonempty) + (hsub : E₀⊆E) (D : H → Finset ι) (l : H → ℝ) (P b δ u zmin W : ℝ) + (hP : 0 ≤ P) (hδ : 0 ≤ δ) (hu : 0 < u) (hz : 0 < zmin) + (hl : ∀ h∈E,0 ≤ l h) (hmass : ∀ h∈E,∑ i∈D h,(r i:ℝ)=P*l h) + (hb : ∀ h∈E₀,∑ i∈D h,(r i:ℝ) ≤ b) + (hW : ∑ h∈E,l h ≤ W) (hzmin : zmin ≤ (E₀.card:ℝ)*Real.exp (-b)/2) : + Real.exp (-b)/2 - W*Real.exp (-P*δ)/(u*zmin) ≤ + (scheduleLaw r).real {ω | zmin ≤ emptySum E D (fun _ => 1) ω ∧ + emptySum E D l ω ≤ (δ+u)*emptySum E D (fun _ => 1) ω} := by + let Y := emptySum (E.filter (fun h => δ ≤ l h)) D l + let G := {ω | (E₀.card:ℝ)*Real.exp (-b)/2 ≤ emptySum E₀ D (fun _ => 1) ω} + let B := {ω | u*zmin ≤ Y ω} + have hmany : Real.exp (-b)/2 ≤ (scheduleLaw r).real G := many_empty r E₀ hE₀ D b hb + have hev := heavy_empty_expectation r E D l P δ W hP hl hmass hW + have hmark := real_markov (scheduleLaw r) Y (integrable_emptySum r _ D l) + (emptySum_nonneg _ D l (fun h hh => hl h (mem_filter.mp hh).1)) + (u*zmin) (mul_pos hu hz).le (Set.to_countable _).measurableSet + have hbad : (scheduleLaw r).real B ≤ W*Real.exp (-P*δ)/(u*zmin) := by + apply (le_div_iff₀ (mul_pos hu hz)).mpr + simpa only [mul_comm] using hmark.trans hev + have hcover : G\B ⊆ {ω | zmin ≤ emptySum E D (fun _ => 1) ω ∧ + emptySum E D l ω ≤ (δ+u)*emptySum E D (fun _ => 1) ω} := by + intro ω hh + have hn : Y ω < u*zmin := lt_of_not_ge hh.2 + have hc := emptySum_mono D (fun _ => (1:ℝ)) hsub (fun _ _ => by norm_num) ω + have hsmall : zmin ≤ emptySum E D (fun _ => 1) ω := hzmin.trans (hh.1.trans hc) + refine ⟨hsmall,?_⟩ + have hs := empty_weight_split E D l δ hδ ω + have hh' := mul_le_mul_of_nonneg_left hsmall hu.le + change emptySum E D l ω ≤ δ*emptySum E D (fun _ => 1) ω+Y ω at hs + nlinarith + have hdiff := good_minus_bad (scheduleLaw r) G B + have hmono := measureReal_mono (h₂:=measure_ne_top (scheduleLaw r) _) hcover + linarith + +end +end SharpLogRamsey.EmptyExceptional +namespace SharpLogRamsey.LearningRow +open Finset +open scoped Classical BigOperators +noncomputable section +variable {A : Type*} [Fintype A] + +def test (sample : Finset A) (score : A → ℝ) (z q : ℝ) : Finset A := + univ.filter (fun x => x∈sample ∨ score x ω∈E x) + +omit [MeasurableSpace Ω] [Fintype A] in +lemma eventCount_eq_card (S : Finset A) (E : A → Set Ω) (ω : Ω) : + eventCount S E ω=(failures S E ω).card := by + simp only [eventCount,failures,←sum_filter] + simp + +theorem row_success_probability (μ : Measure Ω) [IsProbabilityMeasure μ] + (S Ds Da : Finset A) (sample : Ω → Finset A) (score typ zx : Ω → A → ℝ) + (z : Ω → ℝ) (α : A → ℝ) (q tS tA eS eA M εS εA εM ρ : ℝ) + (E : Set Ω) (FS FA : A → Set Ω) + (hFS : ∀ x∈S,MeasurableSet (FS x)) (hFA : ∀ x,MeasurableSet (FA x)) + (hq : 0 z ω/(10*q) zx ω x<(4/5)*z ω/q)).card:ℝ)≤eA) : + ρ-(S.card:ℝ)*εS/tS-(Fintype.card A:ℝ)*εA/tA-εM ≤ + μ.real {ω | (sample ω).card≤M ∧ + (S.card:ℝ)-(Ds.card:ℝ)-tS-eS≤(S∩test (sample ω) (score ω) (z ω) q).card ∧ + ((test (sample ω) (score ω) (z ω) q).card:ℝ)≤M+(Da.card:ℝ)+tA+eA} := by + let BS : Set Ω := {ω | tS≤eventCount S FS ω} + let BA : Set Ω := {ω | tA≤eventCount univ FA ω} + let BM : Set Ω := {ω | M<(sample ω).card} + have hbs : μ.real BS≤(S.card:ℝ)*εS/tS := eventCount_tail μ S FS hFS εS tS htS hfS + have hba : μ.real BA≤(Fintype.card A:ℝ)*εA/tA := by + simpa using eventCount_tail μ univ FA (fun x _ => hFA x) εA tA htA (fun x _ => hfA x) + have hb : μ.real (BS∪BA∪BM)≤(S.card:ℝ)*εS/tS+(Fintype.card A:ℝ)*εA/tA+εM := by + have h1 := measureReal_union_le (μ:=μ) BS BA + have h2 := measureReal_union_le (μ:=μ) (BS∪BA) BM + linarith + have hc : E\(BS∪BA∪BM) ⊆ {ω | (sample ω).card≤M ∧ + (S.card:ℝ)-(Ds.card:ℝ)-tS-eS≤(S∩test (sample ω) (score ω) (z ω) q).card ∧ + ((test (sample ω) (score ω) (z ω) q).card:ℝ)≤M+(Da.card:ℝ)+tA+eA} := by + intro ω hω + have hnS : ω∉BS := fun h => hω.2 (Or.inl (Or.inl h)) + have hnA : ω∉BA := fun h => hω.2 (Or.inl (Or.inr h)) + have hnM : ω∉BM := fun h => hω.2 (Or.inr h) + have hsmallS : ((failures S FS ω).card:ℝ) z ω/(10*q) hfs (mem_filter.mpr ⟨hx,hf⟩)) + have hzx' : zx ω x≤z ω/(10*q) := by + by_contra hh + exact hes (mem_filter.mpr ⟨hx,lt_of_not_ge hh⟩) + exact capture_score _ _ _ _ _ _ hq (hz ω hω.1) (hzx ω hω.1 x) hzx' + (by linarith [(ha x).1]) (ha x).2 (herrors ω hω.1 x hds hsample) htyp) + have hh' : (S.card:ℝ)≤(S∩test (sample ω) (score ω) (z ω) q).card+ + (Ds.card:ℝ)+(failures S FS ω).card+(S.filter (fun x => z ω/(10*q) zx ω x<(4/5)*z ω/q)) (score ω) (z ω) q (by + intro x hda' hfa hea hsample + have hds : x∉Ds := fun hx => hda' (hda hx) + have htyp := ht ω hω.1 x hda' hsample (fun hf => hfa (mem_filter.mpr ⟨mem_univ _,hf⟩)) + have hzx' : (4/5)*z ω/q≤zx ω x := by + by_contra hh + exact hea (mem_filter.mpr ⟨mem_univ _,lt_of_not_ge hh⟩) + exact (exclude_score _ _ _ _ _ _ hq (hz ω hω.1) hzx' (ha x).1 + (herrors ω hω.1 x hds hsample) htyp).le) + have hh' : ((test (sample ω) (score ω) (z ω) q).card:ℝ)≤(sample ω).card+ + (Da.card:ℝ)+(failures univ FA ω).card+ + (univ.filter (fun x => zx ω x<(4/5)*z ω/q)).card := by exact_mod_cast hh + linarith [hea ω hω.1] + have hg := good_minus_bad μ E (BS∪BA∪BM) + have hh := measureReal_mono (h₂:=measure_ne_top μ _) hc + linarith + +end +end SharpLogRamsey.LearningRow +namespace SharpLogRamsey.PoissonTail +open MeasureTheory ProbabilityTheory Finset +open SharpLogRamsey.BoundedProbability SharpLogRamsey.PoissonGrouping +open scoped BigOperators NNReal Classical +noncomputable section + +lemma weighted_power_hasSum (r : ℝ≥0) (a : ℝ) : + HasSum (fun n : ℕ => Real.exp (-(r:ℝ))*(r:ℝ)^n/(n.factorial:ℝ)*a^n) + (Real.exp ((r:ℝ)*(a-1))) := by + have h := (NormedSpace.expSeries_div_hasSum_exp ((r:ℝ)*a)).mul_left (Real.exp (-(r:ℝ))) + convert! h using 1 + · funext n + rw [mul_pow] + ring + · rw [←Real.exp_eq_exp_ℝ,←Real.exp_add] + congr 1 + ring + +lemma integrable_power (r : ℝ≥0) (a : ℝ) : + Integrable (fun n : ℕ => a^n) (poissonMeasure r) := by + rw [integrable_poissonMeasure_iff] + simpa only [Real.norm_eq_abs,abs_pow] using (weighted_power_hasSum r |a|).summable + +lemma integral_power (r : ℝ≥0) (a : ℝ) : + (∫ n : ℕ,a^n ∂poissonMeasure r)=Real.exp ((r:ℝ)*(a-1)) := by + rw [integral_poissonMeasure' (integrable_power r a)] + simpa only [smul_eq_mul] using (weighted_power_hasSum r a).tsum_eq + +theorem double_mean_tail (r : ℝ≥0) : + (poissonMeasure r).real {n : ℕ | 2*(r:ℝ)≤n} ≤ Real.exp (-(r:ℝ)/3) := by + have hlog : 2/3 < Real.log 2 := by linarith [Real.log_two_gt_d9] + have hE : {n : ℕ | 2*(r:ℝ)≤n} ⊆ + {n : ℕ | Real.exp (2*(r:ℝ)*Real.log 2) ≤ (2:ℝ)^n} := by + intro n hn + change Real.exp (2*(r:ℝ)*Real.log 2) ≤ (2:ℝ)^n + have he : (2:ℝ)^n=Real.exp ((n:ℝ)*Real.log 2) := by + rw [Real.exp_nat_mul,Real.exp_log (by norm_num : (0:ℝ)<2)] + rw [he] + change 2*(r:ℝ)≤(n:ℝ) at hn + apply Real.exp_le_exp.mpr + nlinarith + have hm := real_markov (poissonMeasure r) (fun n : ℕ => (2:ℝ)^n) + (integrable_power r 2) (fun _ => by positivity) + (Real.exp (2*(r:ℝ)*Real.log 2)) (Real.exp_pos _).le + (Set.to_countable _).measurableSet + rw [integral_power] at hm + have ht : (poissonMeasure r).real {n : ℕ | Real.exp (2*(r:ℝ)*Real.log 2)≤(2:ℝ)^n} ≤ + Real.exp ((r:ℝ)-2*(r:ℝ)*Real.log 2) := by + rw [Real.exp_sub] + apply (le_div_iff₀ (Real.exp_pos _)).mpr + simpa only [sub_self, sub_zero,show (2:ℝ)-1=1 by norm_num,mul_one,mul_comm] using hm + apply (measureReal_mono (h₂:=measure_ne_top _ _) hE).trans (ht.trans ?_) + apply Real.exp_le_exp.mpr + nlinarith [r.coe_nonneg] + +theorem total_tail {ι : Type*} [Fintype ι] (rate : ι → ℝ≥0) : + (law rate).real {ω | 2*(∑ i,(rate i:ℝ)) ≤ (∑ i,ω i : ℕ)} ≤ + Real.exp (-(∑ i,(rate i:ℝ))/3) := by + have h := sum_hasLaw rate univ + have hm := h.measurePreserving (measurable_of_countable _) + have he : (law rate).real {ω | 2*(∑ i,(rate i:ℝ)) ≤ (∑ i,ω i : ℕ)} = + (poissonMeasure (∑ i,rate i)).real {n : ℕ | 2*(∑ i,(rate i:ℝ))≤n} := by + unfold Measure.real + rw [←hm.measure_preimage (Set.to_countable _).measurableSet.nullMeasurableSet] + rfl + rw [he] + simpa using double_mean_tail (∑ i,rate i) + +end +end SharpLogRamsey.PoissonTail + +namespace SharpLogRamsey.ExceptionalScore +open Finset +open scoped Classical BigOperators +noncomputable section +variable {A H R : Type*} [Fintype R] + +def empty (S : Finset A) (ω : R → A → ℕ) (r : R) : Prop := ∀ x∈S,ω r x=0 + +def term (O X : Finset A) (b : ℝ) (ω : R → A → ℕ) : ℝ := + ∏ r,if empty O ω r then (if empty X ω r then 1-b else -b) else 0 + +def fullyEmpty (S : Finset A) (ω : R → A → ℕ) : Prop := ∀ r,empty S ω r + +omit [Fintype R] in +lemma empty_mono {S T : Finset A} (h : S ⊆ T) (ω : R → A → ℕ) (r : R) + (he : empty T ω r) : empty S ω r := fun x hx => he x (h hx) + +omit [Fintype R] in +lemma factor_abs_le (O X : Finset A) (b : ℝ) (ω : R → A → ℕ) (r : R) + (hb : 0 ≤ b) (hb1 : b ≤ 1) : + |if empty O ω r then (if empty X ω r then 1-b else -b) else 0| ≤ 1 := by + split_ifs <;> rw [abs_le] <;> constructor <;> linarith + +lemma term_empty (O X : Finset A) (b : ℝ) (ω : R → A → ℕ) + (ho : fullyEmpty O ω) (hx : fullyEmpty X ω) : + term O X b ω = (1-b)^(Fintype.card R) := by + simp only [term,ite_eq_left (ho _),ite_eq_left (hx _),prod_const,card_univ] + +lemma term_hit (O X : Finset A) (b : ℝ) (ω : R → A → ℕ) + (hb : 0 ≤ b) (hb1 : b ≤ 1) (hh : ¬fullyEmpty (O∪X) ω) : + |term O X b ω| ≤ b := by + classical + have hw : ∃ r,¬empty (O∪X) ω r := by simpa only [fullyEmpty,not_forall] using hh + obtain ⟨r,hr⟩ := hw + have hr' : ¬empty O ω r ∨ ¬empty X ω r := by + by_contra h + push Not at h + apply hr + intro x hx + rcases mem_union.mp hx with hx|hx + · exact h.1 x hx + · exact h.2 x hx + have hf : |if empty O ω r then (if empty X ω r then 1-b else -b) else 0| ≤ b := by + rcases hr' with ho|hx + · simp only [ite_eq_right ho,abs_zero]; exact hb + · split_ifs <;> simp_all only [abs_neg,abs_of_nonneg hb,le_refl,abs_zero] + rw [term,abs_prod] + calc + _ = |if empty O ω r then (if empty X ω r then 1-b else -b) else 0| * + ∏ j∈univ.erase r,|if empty O ω j then (if empty X ω j then 1-b else -b) else 0| := + (mul_prod_erase _ _ (mem_univ r)).symm + _ ≤ b*1 := mul_le_mul hf (prod_le_one₀ (fun _ _ => abs_nonneg _) + (fun j _ => factor_abs_le O X b ω j hb hb1)) (prod_nonneg (fun _ _ => abs_nonneg _)) hb + _ = b := mul_one _ + +omit [Fintype R] in + +lemma fullyEmpty_decomposition (S O X : Finset A) (x : A) (ω : R → A → ℕ) + (ho : O ⊆ S) (hx : X=S\(O∪{x})) (hc : ∀ r,ω r x=0) : + fullyEmpty S ω ↔ fullyEmpty (O∪X) ω := by + subst X + constructor + · intro h r + apply empty_mono (union_subset ho (sdiff_subset)) ω r (h r) + · intro h r y hy + by_cases hyo : y∈O + · exact h r y (mem_union_left _ hyo) + · by_cases hyx : y=x + · simpa only [hyx] using hc r + · exact h r y (mem_union_right _ (mem_sdiff.mpr ⟨hy,by simp [hyo,hyx]⟩)) + +theorem exceptional_error (E : Finset H) (S O X : H → Finset A) + (b : ℝ) (ω : R → A → ℕ) (hb : 0 ≤ b) (hb1 : b ≤ 1) + (hdec : ∀ H∈E,fullyEmpty (S H) ω ↔ fullyEmpty (O H∪X H) ω) : + |(∑ H∈E,term (O H) (X H) b ω) - + (1-b)^(Fintype.card R)*(E.filter (fun H => fullyEmpty (S H) ω)).card| ≤ + b*(E.card:ℝ) := by + have heq : (1-b)^(Fintype.card R)*(E.filter (fun H => fullyEmpty (S H) ω)).card = + ∑ H∈E,if fullyEmpty (S H) ω then (1-b)^(Fintype.card R) else 0 := by + rw [←sum_filter]; simp [mul_comm] + rw [heq,←sum_sub_distrib] + calc + _ ≤ ∑ H∈E,|term (O H) (X H) b ω- + (if fullyEmpty (S H) ω then (1-b)^(Fintype.card R) else 0)| := abs_sum_le_sum_abs _ _ + _ ≤ ∑ _H∈E,b := by + apply sum_le_sum + intro H hH + by_cases he : fullyEmpty (S H) ω + · have hu := (hdec H hH).mp he + have ho : fullyEmpty (O H) ω := fun r => empty_mono (subset_union_left) ω r (hu r) + have hx : fullyEmpty (X H) ω := fun r => empty_mono (subset_union_right) ω r (hu r) + rw [ite_eq_left he,term_empty _ _ _ _ ho hx,sub_self,abs_zero] + exact hb + · rw [ite_eq_right he,sub_zero] + exact term_hit _ _ _ _ hb hb1 (fun h => he ((hdec H hH).mpr h)) + _ = _ := by simp [mul_comm] + +end +end SharpLogRamsey.ExceptionalScore + +namespace SharpLogRamsey.PreparedMass +open Finset +open scoped Classical BigOperators +noncomputable section +variable {A H : Type*} + +def count (S : Finset A) (R : A → Prop) : ℕ := (S.filter R).card + +def outside (S O : Finset A) (x : A) : Finset A := S\(O∪{x}) + +lemma count_split (S O : Finset A) (x : A) (R : A → Prop) (ho : O ⊆ S) : + count S R = count O R+count (outside S O x) R+ + (if x∈S ∧ x∉O ∧ R x then 1 else 0) := by + classical + have he : S.filter R = (O.filter R) ∪ (outside S O x).filter R ∪ + (({x} : Finset A).filter (fun y => y∈S ∧ y∉O ∧ R y)) := by + ext y + simp only [mem_filter,mem_union,mem_singleton, outside,mem_sdiff] + constructor + · rintro ⟨hy,hr⟩ + by_cases hyo : y∈O + · exact Or.inl (Or.inl ⟨hyo,hr⟩) + · by_cases hyx : y=x + · exact Or.inr ⟨hyx,hy,hyo,hr⟩ + · exact Or.inl (Or.inr ⟨⟨hy,not_or.mpr ⟨hyo,hyx⟩⟩,hr⟩) + · rintro ((⟨hy,hr⟩|⟨⟨hy,_⟩,hr⟩)|⟨_,hy,_,hr⟩) + · exact ⟨ho hy,hr⟩ + · exact ⟨hy,hr⟩ + · exact ⟨hy,hr⟩ + have hd : Disjoint (O.filter R) ((outside S O x).filter R) := by + apply disjoint_left.mpr + intro y hy hz + have hh := (mem_sdiff.mp (mem_filter.mp hz).1).2 + exact hh (mem_union_left _ (mem_filter.mp hy).1) + have hd2 : Disjoint (O.filter R ∪ (outside S O x).filter R) + (({x} : Finset A).filter (fun y => y∈S ∧ y∉O ∧ R y)) := by + apply disjoint_left.mpr + intro y hy hz + obtain ⟨hyx,_,hyo,_⟩ := mem_filter.mp hz + have hyx' : y=x := mem_singleton.mp hyx + rcases mem_union.mp hy with hy|hy + · exact hyo (mem_filter.mp hy).1 + · exact (mem_sdiff.mp (mem_filter.mp hy).1).2 (by simp only [mem_union,mem_singleton]; exact Or.inr hyx') + unfold count + rw [he,card_union_of_disjoint hd2,card_union_of_disjoint hd] + simp only [filter_singleton] + split_ifs <;> simp + +lemma normalized_split (S O : Finset A) (x : A) (R : A → Prop) (ho : O ⊆ S) + (q N : ℝ) : + (q/N)*(count S R:ℝ)=(q/N)*(count O R:ℝ)+(q/N)*(count (outside S O x) R:ℝ)+ + (if x∈S ∧ x∉O ∧ R x then q/N else 0) := by + rw [count_split S O x R ho] + push_cast + split_ifs <;> ring + +theorem typical_range (full cell removed f : ℝ) + (hf : 0 ≤ f) (hf4 : f ≤ 1/25) + (hl : |full-1| ≤ 1/10) (hc : |cell-f| ≤ 1/50) + (hr : 0 ≤ removed) (hr1 : removed ≤ 1/100) : + 3/4 ≤ full-cell-removed ∧ full-cell-removed < 2 ∧ + |(full-cell-removed)-(1-f)| ≤ 13/100 := by + rw [abs_le] at hl hc ⊢ + refine ⟨?_,?_,?_,?_⟩ <;> linarith + +theorem typical_square_sum (T : Finset H) (full cell removed : H → ℝ) (f E e : ℝ) + (hfull : (∑ H∈T,(full H-1)^2) ≤ E) + (hcell : (∑ H∈T,(cell H-f)^2) ≤ E) + (hr : ∀ H∈T,0 ≤ removed H) (hre : ∀ H∈T,removed H ≤ e) : + (∑ H∈T,((full H-cell H-removed H)-(1-f))^2) ≤ + 6*E+3*(T.card:ℝ)*e^2 := by + have hp : ∀ H∈T,removed H^2 ≤ e^2 := by + intro H hH + nlinarith [sq_nonneg (e-removed H),hr H hH,hre H hH] + calc + _ ≤ ∑ H∈T,(3*(full H-1)^2+3*(cell H-f)^2+3*e^2) := by + apply sum_le_sum + intro H hH + have h1 := sq_nonneg ((full H-1)+(cell H-f)) + have h2 := sq_nonneg ((full H-1)+removed H) + have h3 := sq_nonneg ((cell H-f)-removed H) + nlinarith [hp H hH] + _ = 3*(∑ H∈T,(full H-1)^2)+3*(∑ H∈T,(cell H-f)^2)+3*(T.card:ℝ)*e^2 := by + rw [sum_add_distrib,sum_add_distrib,←mul_sum,←mul_sum] + simp; ring + _ ≤ _ := by linarith + +end +end SharpLogRamsey.PreparedMass + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Learning/TestPointTail.lean b/lean/OAI/Combinatorics/SharpRamsey/Learning/TestPointTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..5b99c92cf88604ee2576421f79925c59dadfbbe5 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Learning/TestPointTail.lean @@ -0,0 +1,625 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Learning.TestActualMoment + +namespace OAI + +section +open MeasureTheory ProbabilityTheory +open scoped BigOperators NNReal +namespace SharpLogRamsey.PoissonGrouping +open Classical +noncomputable section +variable {ι κ : Type*} [Fintype ι] [Fintype κ] + +def law (rate : ι → ℝ≥0) : Measure (ι → ℕ) := + Measure.pi fun i => poissonMeasure (rate i) + +instance probability (rate : ι → ℝ≥0) : IsProbabilityMeasure (law rate) := by + unfold law + infer_instance + +lemma sum_hasLaw (rate : ι → ℝ≥0) (S : Finset ι) : + HasLaw (fun ω : ι → ℕ => ∑ i ∈ S, ω i) (poissonMeasure (∑ i ∈ S, rate i)) (law rate) := by + have hi : iIndepFun (fun i (ω : ι → ℕ) => ω i) (law rate) := + iIndepFun_pi (fun _ => aemeasurable_id) + have he (i : ι) : HasLaw (fun ω : ι → ℕ => ω i) (poissonMeasure (rate i)) (law rate) := + (measurePreserving_eval (fun i => poissonMeasure (rate i)) i).hasLaw + induction S using Finset.induction_on with + | empty => + simp only [Finset.sum_empty] + refine ⟨by fun_prop, ?_⟩ + rw [Measure.map_const, measure_univ, one_smul] + symm + apply Measure.ext_of_singleton + intro n + rw [poissonMeasure_singleton] + cases n <;> simp + | @insert i S hiS ih => + have ih' : HasLaw (∑ j ∈ S, fun ω : ι → ℕ => ω j) + (poissonMeasure (∑ j ∈ S, rate j)) (law rate) := by + convert ih using 1 + ext ω + simp + simp only [Finset.sum_insert hiS] + convert (hi.indepFun_finsetSum_of_notMem (fun i => measurable_pi_apply i) hiS).symm.hasLaw_add_poissonMeasure + (he i) ih' using 1 + ext ω + simp + +def regroup (g : ι → κ) (ω : ι → ℕ) : (k : κ) → {i // g i = k} → ℕ := + fun _ i => ω i + +lemma regroup_hasLaw (rate : ι → ℝ≥0) (g : ι → κ) : + HasLaw (regroup g) (Measure.pi fun k => law (fun i : {i // g i = k} => rate i)) (law rate) := by + refine ⟨by exact (measurable_of_countable _).aemeasurable, ?_⟩ + apply Measure.ext_of_singleton + intro z + rw [Measure.map_apply (by fun_prop) (measurableSet_singleton z)] + have hpre : regroup g ⁻¹' {z} = {fun i => z (g i) ⟨i, rfl⟩} := by + ext ω + simp only [Set.mem_preimage, Set.mem_singleton_iff] + constructor + · intro h + funext i + exact congrFun (congrFun h (g i)) ⟨i, rfl⟩ + · rintro rfl + funext k i + obtain ⟨i, rfl⟩ := i + rfl + rw [hpre] + simp only [law, Measure.pi_singleton] + have hf := Fintype.prod_fiberwise g (fun i => (poissonMeasure (rate i)) {z (g i) ⟨i, rfl⟩}) + convert hf.symm using 1 + apply Finset.prod_congr rfl + intro k _ + apply Finset.prod_congr rfl + intro i _ + obtain ⟨i, rfl⟩ := i + rfl + +def groupedCount (g : ι → κ) (ω : ι → ℕ) (k : κ) : ℕ := + ∑ i : {i // g i = k}, ω i + +theorem groupedCount_hasLaw (rate : ι → ℝ≥0) (g : ι → κ) : + HasLaw (groupedCount g) + (law (fun k => ∑ i : {i // g i = k}, rate i)) (law rate) := by + have hs (k : κ) : HasLaw (fun ω : {i // g i = k} → ℕ => ∑ i, ω i) + (poissonMeasure (∑ i : {i // g i = k}, rate i)) + (law (fun i : {i // g i = k} => rate i)) := sum_hasLaw _ Finset.univ + have hp := measurePreserving_pi _ _ (fun k => (hs k).measurePreserving (by fun_prop)) + exact hp.hasLaw.comp (regroup_hasLaw rate g) + +end +end SharpLogRamsey.PoissonGrouping + +namespace SharpLogRamsey.PoissonGrouping +open Finset MeasureTheory ProbabilityTheory +open scoped Classical BigOperators NNReal +noncomputable section +variable {ι κ : Type*} [Fintype ι] [Fintype κ] + +omit [Fintype κ] in +lemma groupedCount_eq_zero (g : ι → κ) (ω : ι → ℕ) (k : κ) : + groupedCount g ω k=0 ↔ ∀ i,g i=k → ω i=0 := by + simp only [groupedCount,Finset.sum_eq_zero_iff,Finset.mem_univ,true_implies] + exact ⟨fun h i hi => h ⟨i,hi⟩,fun h i => h i i.2⟩ + +omit [Fintype κ] in +lemma grouped_empty_iff (g : ι → κ) (ω : ι → ℕ) (S : Finset κ) : + (∀ k∈S,groupedCount g ω k=0) ↔ ∀ i,g i∈S → ω i=0 := by + simp only [groupedCount_eq_zero] + constructor + · intro h i hi + exact h (g i) hi i rfl + · intro h k hk i he + exact h i (he ▸ hk) + +theorem grouped_moment (rate : ι → ℝ≥0) (g : ι → κ) (f : (κ → ℕ) → ℝ) (p : ℕ) : + (∫ ω,f (groupedCount g ω)^p ∂law rate) = + ∫ ω,f ω^p ∂law (fun k => ∑ i : {i // g i=k},rate i) := by + exact (groupedCount_hasLaw rate g).integral_comp + (measurable_of_countable (fun ω => f ω^p)).aestronglyMeasurable + +end +end SharpLogRamsey.PoissonGrouping + +namespace SharpLogRamsey.PointScore +open Finset MeasureTheory ProbabilityTheory +open SharpRamseyFive.PoissonScore SharpLogRamsey.PoissonGrouping +open scoped Classical BigOperators NNReal +noncomputable section +variable {A D H : Type*} [Fintype A] [Fintype D] [Fintype H] + +def pointEmpty {R : ℕ} (P : A → Prop) (ω : Fin R × A → ℕ) (r : Fin R) : ℝ := + if ∀ y,P y → ω (r,y)=0 then 1 else 0 + +def pointScore {R : ℕ} (own : A → Prop) (inc : H → A → Prop) (b : ℝ) + (ω : Fin R × A → ℕ) : ℝ := + ∑ h,∏ r,pointEmpty (fun y => own y ∧ inc h y) ω r * + (pointEmpty (fun y => ¬own y ∧ inc h y) ω r-b) + +def held {R : ℕ} (own center : A → Prop) (i : Fin R × A) : Prop := own i.2 ∨ center i.2 + +def outsideGroup {R : ℕ} (own center : A → Prop) (g : {y // ¬(own y ∨ center y)} → D) + (i : {i : Fin R × A // ¬held own center i}) : Fin R × D := + (i.1.1,g ⟨i.1.2,i.2⟩) + +def ownBit {R : ℕ} (own center : A → Prop) (inc : H → A → Prop) + (a : {i : Fin R × A // held own center i} → ℕ) (h : H) (r : Fin R) : Bool := + decide (∀ y,∀ ho : own y,inc h y → a ⟨(r,y),Or.inl ho⟩=0) + +omit [Fintype D] [Fintype H] in +lemma grouped_empty {R : ℕ} (own center : A → Prop) (g : {y // ¬(own y ∨ center y)} → D) + (T : Finset D) (a : {i : Fin R × A // ¬held own center i} → ℕ) (r : Fin R) : + (∀ d∈T,groupedCount (outsideGroup own center g) a (r,d)=0) ↔ + ∀ y : {y // ¬(own y ∨ center y)},g y∈T → a ⟨(r,y),y.2⟩=0 := by + classical + simp only [PoissonGrouping.groupedCount_eq_zero] + constructor + · intro hh y hy + exact hh (g y) hy ⟨(r,y),y.2⟩ rfl + · intro hh d hd i hi + have hr : i.1.1=r := congrArg Prod.fst hi + have hg : g ⟨i.1.2,i.2⟩=d := congrArg Prod.snd hi + have hh' := hh ⟨i.1.2,i.2⟩ (hg ▸ hd) + convert hh' using 1 + apply congrArg a + apply Subtype.ext + exact Prod.ext hr rfl + +omit [Fintype D] in +lemma source_score_eq_grouped {R : ℕ} (own center : A → Prop) (inc : H → A → Prop) + (g : {y // ¬(own y ∨ center y)} → D) (lines : H → Finset D) + (hinc : ∀ h y,inc h y.1 ↔ g y∈lines h) (b : ℝ) (ω : Fin R × A → ℕ) + (hcenter : ∀ r y,center y → ω (r,y)=0) : + pointScore own inc b ω = + ∑ h,scoreTerm (lines h) b (ownBit own center inc (fun i => ω i.1) h) + (fun r d => groupedCount (outsideGroup own center g) (fun i => ω i.1) (r,d)) := by + classical + apply sum_congr rfl + intro h _ + apply prod_congr rfl + intro r _ + have ho : pointEmpty (fun y => own y ∧ inc h y) ω r = + if ownBit own center inc (fun i => ω i.1) h r then (1:ℝ) else 0 := by + simp only [pointEmpty,ownBit] + congr 1 + exact propext (by aesop) + have he : (∀ y,¬own y ∧ inc h y → ω (r,y)=0) ↔ + ∀ d∈lines h,groupedCount (outsideGroup own center g) (fun i => ω i.1) (r,d)=0 := by + rw [grouped_empty] + constructor + · intro hh y hy + exact hh y ⟨fun ho => y.2 (Or.inl ho),(hinc h y).mpr hy⟩ + · intro hh y hy + by_cases hc : center y + · exact hcenter r y hc + · have hn : ¬(own y ∨ center y) := by tauto + exact hh ⟨y,hn⟩ ((hinc h ⟨y,hn⟩).mp hy.2) + have hx : pointEmpty (fun y => ¬own y ∧ inc h y) ω r = + emptyIndicator (lines h) (fun d => groupedCount (outsideGroup own center g) (fun i => ω i.1) (r,d)) := by + simp only [pointEmpty,emptyIndicator,emptyEvent,Set.indicator_apply,Set.mem_pi, + Finset.mem_coe,Set.mem_singleton_iff,he] + change _ = if ownBit own center inc (fun i => ω i.1) h r then _ else 0 + rw [ho,hx] + unfold centeredFactor + split_ifs <;> simp + +end +end SharpLogRamsey.PointScore + +open MeasureTheory +open scoped BigOperators Classical +namespace SharpLogRamsey.BoundedProbability +noncomputable section +variable {Ω : Type*} [MeasurableSpace Ω] (μ : Measure Ω) [IsProbabilityMeasure μ] + +theorem mass_above_half (Y : Ω → ℝ) (hY : Integrable Y μ) + (m a : ℝ) (hm : 0 < m) (ha : 0 ≤ a) + (hupper : ∀ ω,Y ω ≤ m) (hlower : m*a ≤ ∫ ω,Y ω ∂μ) + (hE : MeasurableSet {ω | m*a/2 ≤ Y ω}) : + a/2 ≤ μ.real {ω | m*a/2 ≤ Y ω} := by + let E := {ω | m*a/2 ≤ Y ω} + have hi : Integrable (E.indicator (fun _ : Ω => m)) μ := (integrable_const _).indicator hE + have hp : ∀ ω,Y ω ≤ m*a/2+E.indicator (fun _ : Ω => m) ω := by + intro ω + by_cases he : ω∈E + · rw [Set.indicator_of_mem he] + nlinarith [hupper ω] + · rw [Set.indicator_of_notMem he] + exact le_trans (le_of_lt (not_le.mp he)) (by simp) + have hh := integral_mono hY ((integrable_const _).add hi) hp + simp only [Pi.add_apply] at hh + rw [integral_add (integrable_const _) hi,integral_const, + integral_indicator_const _ hE] at hh + simp only [probReal_univ,smul_eq_mul] at hh + apply (le_of_mul_le_mul_left ?_ hm) + nlinarith + +theorem real_markov (Y : Ω → ℝ) (hY : Integrable Y μ) (hy : ∀ ω,0 ≤ Y ω) + (t : ℝ) (_ht : 0 ≤ t) (hE : MeasurableSet {ω | t ≤ Y ω}) : + t*μ.real {ω | t ≤ Y ω} ≤ ∫ ω,Y ω ∂μ := by + have hi := (integrable_const t).indicator hE (μ:=μ) + have hp : ∀ ω,({ω | t ≤ Y ω}.indicator (fun _ : Ω => t)) ω ≤ Y ω := by + intro ω + by_cases he : t ≤ Y ω + · simp [he] + · simpa [he] using hy ω + have hh := integral_mono hi hY hp + rw [integral_indicator_const _ hE] at hh + simpa only [smul_eq_mul,mul_comm] using hh + +lemma good_minus_bad (E B : Set Ω) : μ.real E-μ.real B ≤ μ.real (E\B) := by + have hh : μ.real E ≤ μ.real (E\B)+μ.real B := by + apply le_trans (measureReal_mono (h₂:=measure_ne_top _ _) ?_) (measureReal_union_le _ _) + intro ω hω + by_cases hB : ω∈B + · exact Or.inr hB + · exact Or.inl ⟨hω,hB⟩ + linarith + +end +end SharpLogRamsey.BoundedProbability + +namespace SharpLogRamsey.BoundedProbability +open MeasureTheory Finset +open scoped Classical BigOperators +noncomputable section +variable {Ω A B I : Type*} [MeasurableSpace Ω] + [MeasurableSpace A] [MeasurableSpace B] + +theorem product_event_le (μ : Measure A) (ν : Measure B) + [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] + (E : Set (A×B)) (hE : MeasurableSet E) (ε : ℝ) (hε : 0 ≤ ε) + (h : ∀ a,ν.real (Prod.mk a ⁻¹' E) ≤ ε) : (μ.prod ν).real E ≤ ε := by + apply (ENNReal.le_ofReal_iff_toReal_le (measure_ne_top _ _) hε).mp + rw [Measure.prod_apply hE] + calc + _ ≤ ∫⁻ _a,ENNReal.ofReal ε ∂μ := lintegral_mono (fun a => + (ENNReal.le_ofReal_iff_toReal_le (measure_ne_top _ _) hε).mpr (h a)) + _ = _ := by simp + +theorem even_moment_tail (μ : Measure Ω) [IsProbabilityMeasure μ] + (f : Ω → ℝ) (p : ℕ) (hp : Even p) (t M : ℝ) (ht : 0 < t) + (hi : Integrable (fun ω => f ω^p) μ) + (hE : MeasurableSet {ω | t ≤ |f ω|}) + (hm : (∫ ω,f ω^p ∂μ) ≤ M) : + μ.real {ω | t ≤ |f ω|} ≤ M/t^p := by + have hh : t^p*μ.real {ω | t ≤ |f ω|} ≤ ∫ ω,f ω^p ∂μ := by + have hi' := (integrable_const (t^p)).indicator hE (μ:=μ) + have hpt : ∀ ω,({ω | t ≤ |f ω|}.indicator (fun _ => t^p)) ω ≤ f ω^p := by + intro ω + by_cases he : t ≤ |f ω| + · rw [Set.indicator_of_mem (show ω∈{ω | t ≤ |f ω|} from he),←hp.pow_abs (f ω)] + exact pow_le_pow_left₀ ht.le he p + · rw [Set.indicator_of_notMem (show ω∉{ω | t ≤ |f ω|} from he)] + exact hp.pow_nonneg (f ω) + have hle := integral_mono hi' hi hpt + rw [integral_indicator_const _ hE,smul_eq_mul] at hle + simpa only [mul_comm] using hle + exact (le_div_iff₀ (pow_pos ht p)).mpr (by simpa only [mul_comm] using hh.trans hm) + +def eventCount (S : Finset I) (E : I → Set Ω) (ω : Ω) : ℝ := + ∑ i∈S,if ω∈E i then 1 else 0 + +omit [MeasurableSpace Ω] in +lemma eventCount_nonneg (S : Finset I) (E : I → Set Ω) (ω : Ω) : + 0 ≤ eventCount S E ω := sum_nonneg (fun _ _ => by split_ifs <;> norm_num) + +lemma integrable_eventCount (μ : Measure Ω) [IsProbabilityMeasure μ] + (S : Finset I) (E : I → Set Ω) (hE : ∀ i∈S,MeasurableSet (E i)) : + Integrable (eventCount S E) μ := by + apply integrable_finsetSum + intro i hi + exact (integrable_const 1).indicator (hE i hi) + +lemma integral_eventCount (μ : Measure Ω) [IsProbabilityMeasure μ] + (S : Finset I) (E : I → Set Ω) (hE : ∀ i∈S,MeasurableSet (E i)) : + (∫ ω,eventCount S E ω ∂μ) = ∑ i∈S,μ.real (E i) := by + unfold eventCount + rw [integral_finsetSum _ (fun i hi => (integrable_const 1).indicator (hE i hi))] + apply sum_congr rfl + intro i hi + have he : (fun ω : Ω => if ω∈E i then (1:ℝ) else 0) = (E i).indicator (fun _ => 1) := rfl + rw [he,integral_indicator_const _ (hE i hi)] + simp + +theorem eventCount_tail (μ : Measure Ω) [IsProbabilityMeasure μ] + (S : Finset I) (E : I → Set Ω) (hE : ∀ i∈S,MeasurableSet (E i)) + (ε t : ℝ) (ht : 0 < t) (he : ∀ i∈S,μ.real (E i) ≤ ε) : + μ.real {ω | t ≤ eventCount S E ω} ≤ (S.card:ℝ)*ε/t := by + have hi := integrable_eventCount μ S E hE + have hme : Measurable (eventCount S E) := by + apply Finset.measurable_sum + intro i hi + exact measurable_const.indicator (hE i hi) + have hm := real_markov μ (eventCount S E) hi (eventCount_nonneg S E) t ht.le + (measurableSet_le measurable_const hme) + rw [integral_eventCount μ S E hE] at hm + have hs : (∑ i∈S,μ.real (E i)) ≤ (S.card:ℝ)*ε := by + calc + _ ≤ ∑ _i∈S,ε := sum_le_sum he + _ = _ := by simp + exact (le_div_iff₀ ht).mpr (by simpa only [mul_comm] using hm.trans hs) + +end +end SharpLogRamsey.BoundedProbability + +namespace SharpLogRamsey.PoissonConditioning +open MeasureTheory ProbabilityTheory +open SharpLogRamsey.BoundedProbability +open scoped Classical BigOperators NNReal +noncomputable section +variable {ι : Type*} [Fintype ι] + +theorem own_outside_tail (rate : ι → ℝ≥0) (own : ι → Prop) + (f : ({i // own i} → ℕ) → ({i // ¬own i} → ℕ) → ℝ) + (score : (ι → ℕ) → ℝ) (unsampled : (ι → ℕ) → Prop) + (heq : ∀ ω,unsampled ω → score ω=f (fun i => ω i) (fun i => ω i)) + (p : ℕ) (hp : Even p) (t M : ℝ) (ht : 0 < t) (hM : 0 ≤ M) + (hi : ∀ a,Integrable (fun b => f a b^p) + (Measure.pi (fun i : {i // ¬own i} => poissonMeasure (rate i)))) + (hm : ∀ a,(∫ b,f a b^p ∂Measure.pi (fun i : {i // ¬own i} => poissonMeasure (rate i))) ≤ M) : + (Measure.pi (fun i => poissonMeasure (rate i))).real + {ω | unsampled ω ∧ t ≤ |score ω|} ≤ M/t^p := by + let e := MeasurableEquiv.piEquivPiSubtypeProd (fun _ : ι => ℕ) own + let ν₁ := Measure.pi (fun i : {i // own i} => poissonMeasure (rate i)) + let ν₂ := Measure.pi (fun i : {i // ¬own i} => poissonMeasure (rate i)) + let E : Set (({i // own i} → ℕ) × ({i // ¬own i} → ℕ)) := {ab | t ≤ |f ab.1 ab.2|} + have hE : MeasurableSet E := Set.to_countable _ |>.measurableSet + have hp' := measurePreserving_piEquivPiSubtypeProd (fun i => poissonMeasure (rate i)) own + have hh : (ν₁.prod ν₂).real E ≤ M/t^p := by + apply product_event_le ν₁ ν₂ E hE (M/t^p) (by positivity) + intro a + exact even_moment_tail ν₂ (f a) p hp t M ht (hi a) + (Set.to_countable _ |>.measurableSet) (hm a) + have hsub : {ω | unsampled ω ∧ t ≤ |score ω|} ⊆ e ⁻¹' E := by + intro ω hω + change t ≤ |f (fun i => ω i) (fun i => ω i)| + rw [←heq ω hω.1] + exact hω.2 + apply (measureReal_mono (h₂:=measure_ne_top _ _) hsub).trans + have he : (Measure.pi (fun i => poissonMeasure (rate i))).real (e ⁻¹' E) = + (ν₁.prod ν₂).real E := by + unfold Measure.real + rw [hp'.measure_preimage hE.nullMeasurableSet] + rw [he] + exact hh + +end +end SharpLogRamsey.PoissonConditioning + +namespace SharpLogRamsey.PointScore +open Finset MeasureTheory ProbabilityTheory +open SharpRamseyFive.PoissonScore SharpLogRamsey.PoissonGrouping +open SharpLogRamsey.PoissonConditioning +open scoped Classical BigOperators NNReal +noncomputable section +variable {A D H : Type*} [Fintype A] [Fintype D] [Fintype H] + +omit [Fintype A] [Fintype D] [Fintype H] in +lemma centeredFactor_abs (T : Finset D) (b : ℝ) (ω : D → ℕ) : + |centeredFactor T b ω|≤1+|b| := by + unfold centeredFactor emptyIndicator + rw [Set.indicator_apply] + split_ifs + · exact (abs_sub _ _).trans (by simp) + · simp only [zero_sub,abs_neg] + linarith [abs_nonneg b] + +omit [Fintype A] [Fintype D] in +lemma radial_score_abs {R : ℕ} (lines : H → Finset D) (b : ℝ) + (own : H → Fin R → Bool) (ω : Fin R × D → ℕ) : + |∑ h,scoreTerm (lines h) b (own h) (fun r d => ω (r,d))| ≤ + (Fintype.card H:ℝ)*(1+|b|)^R := by + calc + _ ≤ ∑ h,|scoreTerm (lines h) b (own h) (fun r d => ω (r,d))| := abs_sum_le_sum_abs _ _ + _ ≤ ∑ _h : H,(1+|b|)^R := by + apply sum_le_sum + intro h _ + unfold scoreTerm + rw [abs_prod] + calc + _ ≤ ∏ _r : Fin R,(1+|b|) := by + apply prod_le_prod₀ (fun _ _ => abs_nonneg _) + intro r _ + split_ifs + · exact centeredFactor_abs _ _ _ + · simp only [abs_zero]; positivity + _ = _ := by simp + _ = _ := by simp + +omit [Fintype A] [Fintype D] in +lemma integrable_radial_power {R : ℕ} (lines : H → Finset D) (b : ℝ) + (own : H → Fin R → Bool) (p : ℕ) {Ω : Type*} [MeasurableSpace Ω] + [Countable Ω] [MeasurableSingletonClass Ω] (μ : Measure Ω) [IsProbabilityMeasure μ] + (g : Ω → Fin R × D → ℕ) : + Integrable (fun ω => (∑ h,scoreTerm (lines h) b (own h) (fun r d => g ω (r,d)))^p) μ := by + apply Integrable.of_bound (measurable_of_countable _).aestronglyMeasurable + (((Fintype.card H:ℝ)*(1+|b|)^R)^p) + filter_upwards [] with ω + rw [Real.norm_eq_abs,abs_pow] + exact pow_le_pow_left₀ (abs_nonneg _) (radial_score_abs lines b own (g ω)) p + +theorem point_score_tail {R : ℕ} (rate : Fin R × A → ℝ≥0) + (own center : A → Prop) (inc : H → A → Prop) + (g : {y // ¬(own y ∨ center y)} → D) (lines : H → Finset D) + (hinc : ∀ h y,inc h y.1 ↔ g y∈lines h) (b : ℝ) + (radialRate : Fin R × D → ℝ≥0) + (hrate : ∀ k,(∑ i : {i : {i : Fin R × A // ¬held own center i} // + outsideGroup own center g i=k},rate i.1.1)=radialRate k) + (p : ℕ) (hp : Even p) (t M : ℝ) (ht : 0 ω (r,d)))^p + ∂batchMeasure radialRate)≤M) : + (batchMeasure rate).real {ω | (∀ r y,center y → ω (r,y)=0) ∧ + t≤|pointScore own inc b ω|} ≤ M/t^p := by + let f := fun (a : {i : Fin R × A // held own center i} → ℕ) + (c : {i : Fin R × A // ¬held own center i} → ℕ) => + ∑ h,scoreTerm (lines h) b (ownBit own center inc a h) + (fun r d => groupedCount (outsideGroup own center g) c (r,d)) + apply own_outside_tail rate (held own center) f (pointScore own inc b) + (fun ω => ∀ r y,center y → ω (r,y)=0) + (fun ω hc => source_score_eq_grouped own center inc g lines hinc b ω hc) + p hp t M ht hM + · intro a + exact integrable_radial_power lines b (ownBit own center inc a) p _ + (groupedCount (outsideGroup own center g)) + · intro a + have hh := grouped_moment (fun i : {i : Fin R × A // ¬held own center i} => rate i.1) + (outsideGroup own center g) + (fun ω => ∑ h,scoreTerm (lines h) b (ownBit own center inc a h) (fun r d => ω (r,d))) p + change (∫ c,(f a c)^p ∂law (fun i : {i : Fin R × A // ¬held own center i} => rate i.1))≤M + apply hh.le.trans + convert! hm (ownBit own center inc a) using 1 + congr 2 + funext k + convert! hrate k using 1 + congr 1 + ext i + simp only [mem_univ] + +end +end SharpLogRamsey.PointScore + +namespace SharpLogRamsey.PreparedProjectiveGeometry +open Finset +open scoped Classical BigOperators NNReal +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + +def direction (x : Projectivization K V) (y : {y : Projectivization K V // y≠x}) : + RadialLine x := ⟨x.submodule ⊔ y.1.submodule,finrank_join x y.1 y.2.symm,le_sup_left⟩ + +omit [Finite K] in +lemma direction_eq_iff (x : Projectivization K V) + (y : {y : Projectivization K V // y≠x}) (W : RadialLine x) : + direction x y=W ↔ y.1.submodule ≤ W.1 := by + constructor + · intro h + rw [←h] + exact le_sup_right + · intro h + exact Subtype.ext (radial_unique x y y.2.symm W h) + +lemma direction_mem_lines (x : Projectivization K V) + (y : {y : Projectivization K V // y≠x}) (H : Projectivization K (Module.Dual K V)) + (hx : x.submodule ≤ LinearMap.ker H.rep) : + direction x y∈lines x H ↔ y.1.submodule ≤ LinearMap.ker H.rep := by + rw [mem_lines] + change x.submodule ⊔ y.1.submodule ≤ LinearMap.ker H.rep ↔ _ + simp only [sup_le_iff,hx,true_and] + +omit [Finite K] in +theorem direction_fiber_card (S : Finset (Projectivization K V)) (x : Projectivization K V) + (hx : x∉S) (W : RadialLine x) : + Fintype.card {y : S // direction x ⟨y.1,fun h => hx (h ▸ y.2)⟩=W}= + (radialFiber S x W).card := by + let e : {y : S // direction x ⟨y.1,fun h => hx (h ▸ y.2)⟩=W} ≃ radialFiber S x W := + { toFun := fun y => ⟨y.1.1,by + rw [mem_radialFiber] + exact ⟨y.1.2,fun h => hx (h ▸ y.1.2), + (direction_eq_iff x _ W).mp y.2⟩⟩ + invFun := fun y => ⟨⟨y.1,(mem_radialFiber S x y W).mp y.2 |>.1⟩,by + apply (direction_eq_iff x _ W).mpr + exact (mem_radialFiber S x y W).mp y.2 |>.2.2⟩ + left_inv := fun y => by apply Subtype.ext; apply Subtype.ext; rfl + right_inv := fun y => by apply Subtype.ext; rfl } + exact (Fintype.card_congr e).trans (Fintype.card_coe _) + +end +end SharpLogRamsey.PreparedProjectiveGeometry + +namespace SharpLogRamsey.PointScore +open Finset +open SharpLogRamsey.PoissonGrouping +open scoped Classical BigOperators NNReal +noncomputable section +variable {A D : Type*} [Fintype A] [Fintype D] + +def outsideBatchFiber {R : ℕ} (own center : A → Prop) + (g : {y // ¬(own y ∨ center y)} → D) (r : Fin R) (d : D) : + {i : {i : Fin R × A // ¬held own center i} // outsideGroup own center g i=(r,d)} ≃ + {y : {y // ¬(own y ∨ center y)} // g y=d} where + toFun i := ⟨⟨i.1.1.2,i.1.2⟩,congrArg Prod.snd i.2⟩ + invFun y := ⟨⟨(r,y.1.1),y.1.2⟩,Prod.ext rfl y.2⟩ + left_inv i := by + apply Subtype.ext + apply Subtype.ext + exact Prod.ext (congrArg Prod.fst i.2).symm rfl + right_inv y := by rfl + +omit [Fintype D] in +lemma outside_uniform_rate {R : ℕ} (own center : A → Prop) + (g : {y // ¬(own y ∨ center y)} → D) (u : ℝ≥0) (k : Fin R × D) : + (∑ _i : {i : {i : Fin R × A // ¬held own center i} // outsideGroup own center g i=k},u)= + u*Fintype.card {y : {y // ¬(own y ∨ center y)} // g y=k.2} := by + simp only [sum_const,card_univ,nsmul_eq_mul] + rw [Fintype.card_congr (outsideBatchFiber own center g k.1 k.2)] + exact mul_comm _ _ + +end +end SharpLogRamsey.PointScore + +namespace SharpLogRamsey.PreparedProjectiveGeometry +open Finset +open SharpLogRamsey.PointScore +open scoped Classical BigOperators NNReal +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + +def outsideDirection (S O : Finset (Projectivization K V)) (x : Projectivization K V) + (y : {y : S // ¬(y.1∈O ∨ y.1=x)}) : RadialLine x := + direction x ⟨y.1.1,fun h => y.2 (Or.inr h)⟩ + +def outsideDirectionFiber (S O : Finset (Projectivization K V)) (x : Projectivization K V) + (W : RadialLine x) : + {y : {y : S // ¬(y.1∈O ∨ y.1=x)} // outsideDirection S O x y=W} ≃ + radialFiber (S\(O∪{x})) x W where + toFun y := ⟨y.1.1.1,by + apply (mem_radialFiber _ _ _ _).mpr + refine ⟨mem_sdiff.mpr ⟨y.1.1.2,?_⟩,fun h => y.1.2 (Or.inr h),?_⟩ + · simpa only [mem_union,mem_singleton] using y.1.2 + · exact (direction_eq_iff x _ W).mp y.2⟩ + invFun y := ⟨⟨⟨y.1,(mem_sdiff.mp ((mem_radialFiber _ _ _ _).mp y.2).1).1⟩,by + simpa only [mem_union,mem_singleton] using + (mem_sdiff.mp ((mem_radialFiber _ _ _ _).mp y.2).1).2⟩,by + apply (direction_eq_iff x _ W).mpr + exact ((mem_radialFiber _ _ _ _).mp y.2).2.2⟩ + left_inv y := by apply Subtype.ext; apply Subtype.ext; apply Subtype.ext; rfl + right_inv y := by apply Subtype.ext; rfl + +omit [Finite K] in +lemma outsideDirection_card (S O : Finset (Projectivization K V)) (x : Projectivization K V) + (W : RadialLine x) : + Fintype.card {y : {y : S // ¬(y.1∈O ∨ y.1=x)} // outsideDirection S O x y=W}= + (radialFiber (S\(O∪{x})) x W).card := + (Fintype.card_congr (outsideDirectionFiber S O x W)).trans (Fintype.card_coe _) + +lemma outsideDirection_incidence (S O : Finset (Projectivization K V)) (x : Projectivization K V) + (H : Projectivization K (Module.Dual K V)) (hxH : x.submodule≤LinearMap.ker H.rep) + (y : {y : S // ¬(y.1∈O ∨ y.1=x)}) : + y.1.1.submodule≤LinearMap.ker H.rep ↔ outsideDirection S O x y∈lines x H := + by + exact (direction_mem_lines x ⟨y.1.1,fun h => y.2 (Or.inr h)⟩ H hxH).symm + +omit [Finite K] in +theorem actual_radial_rate (S O : Finset (Projectivization K V)) (x : Projectivization K V) + {R : ℕ} (L c : ℝ≥0) (k : Fin R × RadialLine x) : + (∑ _i : {i : {i : Fin R × S // ¬held (fun y : S => y.1∈O) (fun y : S => y.1=x) i} // + outsideGroup (fun y : S => y.1∈O) (fun y : S => y.1=x) (outsideDirection S O x) i=k},L*c)= + L*(c*(radialFiber (S\(O∪{x})) x k.2).card) := by + rw [outside_uniform_rate,mul_assoc] + congr 2 + have hc := outsideDirection_card S O x k.2 + simp only [←Nat.card_eq_fintype_card] at hc ⊢ + exact_mod_cast hc + +end +end SharpLogRamsey.PreparedProjectiveGeometry + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Learning/TestRowBounds.lean b/lean/OAI/Combinatorics/SharpRamsey/Learning/TestRowBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..0e085c84f1fefae2f7ac6fb475ff960d06647ff4 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Learning/TestRowBounds.lean @@ -0,0 +1,68 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.TestRowPencils + +namespace OAI + +section +namespace SharpLogRamsey.PreparedRow +open Finset MeasureTheory +open scoped BigOperators Classical NNReal +noncomputable section +variable {A H : Type*} [Fintype A] [Fintype H] + +omit [Fintype A] [Fintype H] in +lemma degree_eq_card (inc : H→A→Prop) (Z : Finset H) (x : A) : + PencilContrast.degree (fun x H => inc H x) Z x=(Z.filter (fun H => inc H x)).card := by + simp only [PencilContrast.degree,card_filter,Nat.cast_sum,Nat.cast_ite,Nat.cast_one,Nat.cast_zero] + +omit [Fintype A] [Fintype H] in +lemma support_empty_large (S : Finset A) (Z : Finset H) (inc : H→A→Prop) + (q a : ℝ) (hq : 0 (Z.card:ℝ)/(10*q)<((Z.filter (fun H => inc H x)).card:ℝ))).card:ℝ)≤ + (10*a)*(S.card:ℝ) := by + have hSc : (0:ℝ) inc H x) S Z q S.card Z.card a + (1/10) hq hSc hZc (by norm_num) (by + convert hb using 1 + simp only [card_filter,Nat.cast_sum,Nat.cast_ite,Nat.cast_one,Nat.cast_zero]) + have hs : S.filter (fun x => (Z.card:ℝ)/(10*q)<((Z.filter (fun H => inc H x)).card:ℝ))⊆ + S.filter (fun x => (1/10:ℝ)*(Z.card:ℝ)/q≤PencilContrast.degree (fun x H => inc H x) Z x) := by + intro x hx + refine mem_filter.mpr ⟨(mem_filter.mp hx).1,?_⟩ + rw [degree_eq_card] + convert (mem_filter.mp hx).2.le using 1 + first | with_unfolding_all rfl | ring + have hc : ((S.filter (fun x => (Z.card:ℝ)/(10*q)<((Z.filter (fun H => inc H x)).card:ℝ))).card:ℝ)≤ + (S.filter (fun x => (1/10:ℝ)*(Z.card:ℝ)/q≤PencilContrast.degree (fun x H => inc H x) Z x)).card := by + exact_mod_cast card_le_card hs + convert hc.trans hh using 1 + first | with_unfolding_all rfl | ring + +lemma alpha_bounds (L f : ℝ) (R : ℕ) (hL : 0≤L) (hf : f≤1/25) + (hR : (R:ℝ)*Real.exp (-(24/25:ℝ)*L)≤1/10) : + 0≤Real.exp (-L*(1-f)) ∧ Real.exp (-L*(1-f))≤1 ∧ + 9/10≤(1-Real.exp (-L*(1-f)))^R ∧ (1-Real.exp (-L*(1-f)))^R≤1 := by + let b := Real.exp (-L*(1-f)) + have hb : 0≤b := (Real.exp_pos _).le + have hb1 : b≤1 := by + apply Real.exp_le_one_iff.mpr + nlinarith + have hbe : b≤Real.exp (-(24/25:ℝ)*L) := by + apply Real.exp_le_exp.mpr + nlinarith + have hbR : (R:ℝ)*b≤1/10 := + (mul_le_mul_of_nonneg_left hbe (Nat.cast_nonneg R)).trans hR + have hber : 1-(R:ℝ)*b≤(1-b)^R := by + have hh := one_add_mul_sub_le_pow (show (-1:ℝ)≤1-b by linarith) R + convert hh using 1 + first | with_unfolding_all rfl | ring + exact ⟨hb,hb1,by linarith,pow_le_one₀ (by linarith) (by linarith)⟩ + +end +end SharpLogRamsey.PreparedRow + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Learning/TestRowEmpty.lean b/lean/OAI/Combinatorics/SharpRamsey/Learning/TestRowEmpty.lean new file mode 100644 index 0000000000000000000000000000000000000000..02fe3fa99a2b300877df0ea764f76aa39deac1c2 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Learning/TestRowEmpty.lean @@ -0,0 +1,77 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Learning.TestRowScore + +namespace OAI + +section +namespace SharpLogRamsey.PreparedRow +open Finset MeasureTheory ProbabilityTheory SharpLogRamsey.PoissonSchedules +open SharpLogRamsey.EmptyExceptional +open scoped BigOperators Classical NNReal +noncomputable section +variable {A H : Type*} + +def coordinates (S : Finset A) (R : ℕ) (inc : H → A → Prop) (h : H) : + Finset (Fin R × S) := univ ×ˢ univ.filter (fun y : S => inc h y.1) + +lemma coordinates_empty (S : Finset A) (R : ℕ) (inc : H → A → Prop) + (ω : Schedule S R) (h : H) : + ω∈emptyLedger (coordinates S R inc h) ↔ empty S inc ω h := by + simp only [emptyLedger,coordinates,empty,mem_product,mem_univ,mem_filter,true_and] + constructor + · intro he r y hy + exact he (r,y) hy + · intro he i hi + exact he i.1 i.2 hi + +lemma sub_inc_card (S : Finset A) (inc : H → A → Prop) (h : H) : + (univ.filter (fun y : S => inc h y.1)).card=(S.filter (inc h)).card := by + apply card_bij (fun y _ => y.1) + · intro y hy + exact mem_filter.mpr ⟨y.2,(mem_filter.mp hy).2⟩ + · intro y _ z _ he + exact Subtype.ext he + · intro y hy + exact ⟨⟨y,(mem_filter.mp hy).1⟩,mem_filter.mpr ⟨mem_univ _,(mem_filter.mp hy).2⟩,rfl⟩ + +lemma coordinates_mass (S : Finset A) (R : ℕ) (inc : H → A → Prop) (h : H) + (γ : ℝ≥0) : + (∑ _i∈coordinates S R inc h,(γ:ℝ))=(γ:ℝ)*R*((S.filter (inc h)).card:ℝ) := by + simp only [sum_const,nsmul_eq_mul,coordinates,card_product,card_univ,Fintype.card_fin, + sub_inc_card,Nat.cast_mul] + ring + +lemma empty_count (S : Finset A) (E : Finset H) (R : ℕ) (inc : H → A → Prop) + (ω : Schedule S R) : + emptySum E (coordinates S R inc) (fun _ => 1) ω=(emptySet S E inc ω).card := by + simp only [emptySum,coordinates_empty,emptySet,card_filter,Nat.cast_sum,Nat.cast_ite, + Nat.cast_one,Nat.cast_zero] + +lemma empty_weight (S : Finset A) (E : Finset H) (R : ℕ) (inc : H → A → Prop) + (l : H → ℝ) (ω : Schedule S R) : + emptySum E (coordinates S R inc) l ω=∑ h∈emptySet S E inc ω,l h := by + simp only [emptySum,coordinates_empty,emptySet,sum_filter] + +theorem actual_empty_good (S : Finset A) (E E₀ : Finset H) (R : ℕ) + (inc : H → A → Prop) (γ : ℝ≥0) (l : H → ℝ) (P b δ u zmin W : ℝ) + (hE₀ : E₀.Nonempty) (hsub : E₀⊆E) (hP : 0≤P) (hδ : 0≤δ) + (hu : 0 γ)).real {ω | + zmin≤(emptySet S E inc ω).card ∧ + (∑ h∈emptySet S E inc ω,l h)≤(δ+u)*(emptySet S E inc ω).card} := by + have he := empty_good_event (fun _ : Fin R×S => γ) E E₀ hE₀ hsub + (coordinates S R inc) l P b δ u zmin W hP hδ hu hz hl + (fun h hh => (coordinates_mass S R inc h γ).trans (hmass h hh)) + (fun h hh => (coordinates_mass S R inc h γ).trans_le (hb h hh)) hW hzmin + simpa only [empty_count,empty_weight,sum_const,nsmul_eq_mul,mul_one] using he + +end +end SharpLogRamsey.PreparedRow + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Learning/TestRowScore.lean b/lean/OAI/Combinatorics/SharpRamsey/Learning/TestRowScore.lean new file mode 100644 index 0000000000000000000000000000000000000000..dd49c175ada11d4ba50d3f84e9b66aeae2270a0c --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Learning/TestRowScore.lean @@ -0,0 +1,132 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Learning.TestLearningRowBase +import OAI.Combinatorics.SharpRamsey.Learning.TestLearningIncidence + +namespace OAI + +section +namespace SharpLogRamsey.PreparedRow +open Finset MeasureTheory ProbabilityTheory SharpLogRamsey.PointScore +open scoped BigOperators Classical +noncomputable section +variable {A H : Type*} [Fintype A] [Fintype H] + +abbrev Schedule (S : Finset A) (R : ℕ) := Fin R × S → ℕ + +def extend (S : Finset A) {R : ℕ} (ω : Schedule S R) (r : Fin R) (x : A) : ℕ := + if hx : x∈S then ω (r,⟨x,hx⟩) else 0 + +def sample (S : Finset A) {R : ℕ} (ω : Schedule S R) : Finset A := + S.filter (fun x => ∃ r,extend S ω r x≠0) + +def empty (S : Finset A) {R : ℕ} (inc : H → A → Prop) + (ω : Schedule S R) (h : H) : Prop := ∀ r (y : S),inc h y → ω (r,y)=0 + +def emptySet (S : Finset A) (E : Finset H) {R : ℕ} + (inc : H → A → Prop) (ω : Schedule S R) : Finset H := E.filter (empty S inc ω) + +def score (S O : Finset A) (T : Finset H) {R : ℕ} + (inc : H → A → Prop) (b : ℝ) (ω : Schedule S R) : ℝ := + pointScore (fun y : S => y.1∈O) (fun (h : T) (y : S) => inc h.1 y.1) b ω + +omit [Fintype A] [Fintype H] in +lemma unsampled (S : Finset A) {R : ℕ} (ω : Schedule S R) (x : A) + (hx : x∉sample S ω) : ∀ r (y : S),y.1=x → ω (r,y)=0 := by + intro r y hy + subst x + have hn : ¬∃ r,extend S ω r y.1≠0 := fun h => hx (mem_filter.mpr ⟨y.2,h⟩) + have hh : extend S ω r y.1=0 := Classical.not_not.mp (fun h => hn ⟨r,h⟩) + simpa only [extend,dite_eq_left y.2] using hh + +omit [Fintype A] [Fintype H] in +lemma sample_subset (S : Finset A) {R : ℕ} (ω : Schedule S R) : sample S ω⊆S := filter_subset _ _ + +omit [Fintype A] [Fintype H] in +lemma score_eq (S O : Finset A) (T : Finset H) {R : ℕ} + (inc : H → A → Prop) (b : ℝ) (ω : Schedule S R) : + score S O T inc b ω = ∑ h∈T, ∏ r, + pointEmpty (fun y : S => y.1∈O ∧ inc h y.1) ω r * + (pointEmpty (fun y : S => y.1∉O ∧ inc h y.1) ω r-b) := by + exact sum_coe_sort T (fun h : H => ∏ r, + pointEmpty (fun y : S => y.1∈O ∧ inc h y.1) ω r * + (pointEmpty (fun y : S => y.1∉O ∧ inc h y.1) ω r-b)) + +omit [Fintype A] [Fintype H] in +lemma score_partition (S O : Finset A) (T E : Finset H) {R : ℕ} + (inc : H → A → Prop) (b : ℝ) (ω : Schedule S R) : + score S O T inc b ω = score S O (T\E) inc b ω+score S O (T∩E) inc b ω := by + simp only [score_eq] + have hh := (sum_sdiff (inter_subset_left (s₁:=T) (s₂:=E)) (f:=fun h => ∏ r, + pointEmpty (fun y : S => y.1∈O ∧ inc h y.1) ω r * + (pointEmpty (fun y : S => y.1∉O ∧ inc h y.1) ω r-b))) + have he : T \ (T∩E)=T\E := by ext h; simp only [mem_sdiff,mem_inter]; tauto + simpa only [he] using hh.symm + +omit [Fintype A] [Fintype H] in +lemma empty_iff (S : Finset A) {R : ℕ} (inc : H → A → Prop) + (ω : Schedule S R) (h : H) : + empty S inc ω h ↔ SharpLogRamsey.ExceptionalScore.fullyEmpty + (univ.filter (fun y : S => inc h y.1)) (fun r y => ω (r,y)) := by + simp only [empty,ExceptionalScore.fullyEmpty,ExceptionalScore.empty,mem_filter,mem_univ,true_and] + +omit [Fintype A] [Fintype H] in + +lemma score_exceptional_term (S O : Finset A) (T : Finset H) {R : ℕ} + (inc : H → A → Prop) (b : ℝ) (ω : Schedule S R) : + score S O T inc b ω = ∑ h∈T,ExceptionalScore.term + (univ.filter (fun y : S => y.1∈O ∧ inc h y.1)) + (univ.filter (fun y : S => y.1∉O ∧ inc h y.1)) b (fun r y => ω (r,y)) := by + rw [score_eq] + apply sum_congr rfl + intro h _ + apply prod_congr rfl + intro r _ + simp only [pointEmpty,ExceptionalScore.empty,mem_filter,mem_univ,true_and] + split_ifs <;> simp_all + +omit [Fintype A] [Fintype H] in +lemma own_outside_union (S O : Finset A) (inc : H → A → Prop) (h : H) : + (univ.filter (fun y : S => y.1∈O ∧ inc h y.1)) ∪ + (univ.filter (fun y : S => y.1∉O ∧ inc h y.1)) = + univ.filter (fun y : S => inc h y.1) := by + ext y + simp only [mem_union,mem_filter,mem_univ,true_and] + tauto + +omit [Fintype A] [Fintype H] in + +theorem exceptional_error (S O : Finset A) (T E : Finset H) {R : ℕ} + (inc : H → A → Prop) (b : ℝ) (ω : Schedule S R) (hb : 0≤b) (hb1 : b≤1) : + |(score S O T inc b ω-score S O (T\E) inc b ω)- + (1-b)^R*((T∩emptySet S E inc ω).card:ℝ)|≤b*((T∩E).card:ℝ) := by + classical + have hp := score_partition S O T E inc b ω + have hcard : (T∩emptySet S E inc ω)=(T∩E).filter (empty S inc ω) := by + ext h + simp only [emptySet,mem_inter,mem_filter] + tauto + have hh := ExceptionalScore.exceptional_error (T∩E) + (fun h => univ.filter (fun y : S => inc h y.1)) + (fun h => univ.filter (fun y : S => y.1∈O ∧ inc h y.1)) + (fun h => univ.filter (fun y : S => y.1∉O ∧ inc h y.1)) b (fun r y => ω (r,y)) hb hb1 (by + intro h _ + simp only [ExceptionalScore.fullyEmpty,ExceptionalScore.empty,mem_union, + mem_filter,mem_univ,true_and] + constructor + · intro he r y hy + exact he r y (hy.elim And.right And.right) + · intro he r y hy + by_cases ho : y.1∈O + · exact he r y (Or.inl ⟨ho,hy⟩) + · exact he r y (Or.inr ⟨ho,hy⟩)) + rw [←score_exceptional_term S O (T∩E) inc b ω] at hh + simp only [Fintype.card_fin,←empty_iff] at hh + rw [hp,add_sub_cancel_left,hcard] + exact hh + +end +end SharpLogRamsey.PreparedRow + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Learning/TestRowSize.lean b/lean/OAI/Combinatorics/SharpRamsey/Learning/TestRowSize.lean new file mode 100644 index 0000000000000000000000000000000000000000..5416f9547c762b0f273ef0ee3ea8adaa78aea8a5 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Learning/TestRowSize.lean @@ -0,0 +1,55 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Learning.TestRowEmpty + +namespace OAI + +section +namespace SharpLogRamsey.PreparedRow +open Finset MeasureTheory ProbabilityTheory SharpLogRamsey.PoissonSchedules +open scoped BigOperators Classical NNReal +noncomputable section +variable {A : Type*} + +lemma sample_card_le_total (S : Finset A) (R : ℕ) (ω : Schedule S R) : + (sample S ω).card≤∑ i : Fin R×S,ω i := by + have hs (x : A) (hx : x∈sample S ω) : 1≤∑ r,extend S ω r x := by + obtain ⟨r,hr⟩ := (mem_filter.mp hx).2 + have hh := single_le_sum (fun r _ => Nat.zero_le (extend S ω r x)) (mem_univ r) + exact (Nat.one_le_iff_ne_zero.mpr hr).trans hh + calc + _ = ∑ x∈sample S ω,1 := by simp + _ ≤ ∑ x∈sample S ω,∑ r,extend S ω r x := sum_le_sum hs + _ ≤ ∑ x∈S,∑ r,extend S ω r x := + sum_le_sum_of_subset_of_nonneg (sample_subset S ω) (fun _ _ _ => Nat.zero_le _) + _ = ∑ x : S,∑ r,ω (r,x) := by + rw [←sum_coe_sort S (fun x : A => ∑ r,extend S ω r x)] + apply sum_congr rfl + intro x _ + apply sum_congr rfl + intro r _ + exact dite_eq_left x.2 + _ = ∑ i : Fin R×S,ω i := by rw [Fintype.sum_prod_type,sum_comm] + +lemma constant_mean (S : Finset A) (R : ℕ) (γ : ℝ≥0) : + (∑ _i : Fin R×S,(γ:ℝ))=(R:ℝ)*S.card*γ := by + simp only [sum_const,card_univ,Fintype.card_prod,Fintype.card_fin,Fintype.card_coe, + nsmul_eq_mul,Nat.cast_mul] + +theorem sample_size_tail (S : Finset A) (R : ℕ) (γ : ℝ≥0) : + (scheduleLaw (fun _ : Fin R×S => γ)).real + {ω | 2*((R:ℝ)*S.card*γ)<((sample S ω).card:ℝ)}≤ + Real.exp (-((R:ℝ)*S.card*γ)/3) := by + have hh := SharpLogRamsey.PoissonTail.total_tail (fun _ : Fin R×S => γ) + rw [constant_mean S R γ] at hh + apply le_trans (measureReal_mono (h₂:=measure_ne_top _ _) ?_) hh + intro ω hω + change 2*((R:ℝ)*S.card*γ)<((sample S ω).card:ℝ) at hω + change 2*((R:ℝ)*S.card*γ)≤((∑ i : Fin R×S,ω i : ℕ):ℝ) + exact hω.le.trans (Nat.cast_le.mpr (sample_card_le_total S R ω)) + +end +end SharpLogRamsey.PreparedRow + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Learning/ValidationCover.lean b/lean/OAI/Combinatorics/SharpRamsey/Learning/ValidationCover.lean new file mode 100644 index 0000000000000000000000000000000000000000..2ef8bb166a979f1669c8be5c02b1e88ff0f3f1dc --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Learning/ValidationCover.lean @@ -0,0 +1,147 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Selection.UniversalTables +import OAI.Combinatorics.SharpRamsey.Validation.ValidationSchedule + +namespace OAI + +section +namespace SharpLogRamsey.Validation +open Finset Real Incidence +open scoped Classical BigOperators +noncomputable section +variable {K V : Type*} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +variable [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + +def CoverInput (W : Finset (Projectivization K V)) + (U : Finset (Projectivization K (Module.Dual K V))) (N t : ℕ) (C b : ℝ) + (z : Finset (Projectivization K V) × Finset (Projectivization K (Module.Dual K V))) : Prop := + z.1.Nonempty ∧ z.1 ⊆ W ∧ (N:ℝ) ≤ C*z.1.card ∧ + (W.card:ℝ) ≤ exp b*z.1.card ∧ z.2 ⊆ U ∧ z.2.card=t ∧ + (incidenceCount z.1 z.2:ℝ) ≤ (z.1.card:ℝ)*z.2.card/(10000*Nat.card K) + +omit [Finite K] [FiniteDimensional K V] in +lemma coverInput_card (W : Finset (Projectivization K V)) + (U : Finset (Projectivization K (Module.Dual K V))) (N t : ℕ) (C b : ℝ) : + (Fintype.card {z // CoverInput W U N t C b z}:ℝ) ≤ + exp (((Fintype.card (Projectivization K V):ℝ)+ + Fintype.card (Projectivization K (Module.Dual K V)))*log 2) := by + have hc := Fintype.card_subtype_le (CoverInput W U N t C b) + have hc' : (Fintype.card {z // CoverInput W U N t C b z}:ℝ) ≤ + (2:ℝ)^Fintype.card (Projectivization K V)* + (2:ℝ)^Fintype.card (Projectivization K (Module.Dual K V)) := by + simpa only [Fintype.card_prod,Fintype.card_finset,Nat.cast_mul,Nat.cast_pow,Nat.cast_ofNat] using (show (Fintype.card {x // CoverInput W U N t C b x}:ℝ) ≤ Fintype.card (Finset (Projectivization K V) × Finset (Projectivization K (Module.Dual K V))) by exact_mod_cast hc) + apply hc'.trans_eq + rw [add_mul,exp_add,exp_nat_mul,exp_nat_mul,exp_log (by norm_num : (0:ℝ)<2)] + +lemma row_ratio_exp {x w b : ℝ} (_hx : 0 + implementAccept i.1.1 (GoodCap SharpLogRamsey.Incidence.Incident q U i.1.2 M) + have hprob : ∀ i, exp (-a) ≤ PublicTables.acceptProb (rowLaw W hW h) (A i) := by + intro i + obtain ⟨hx,hxw,hcap,hratio,htu',hct,hsp⟩ := i.2 + have hxr : (0:ℝ) < i.1.1.card := by exact_mod_cast card_pos.mpr hx + have htt : i.1.2.Nonempty := card_pos.mp (by omega) + have hsize := scheduleLength_size hq htr hut hNr hxr hC hcap hprod + (pow_nonneg hq.le (n+3)) + have hsp' : (∑ y∈i.1.2,∑ x∈univ.filter (fun x => SharpLogRamsey.Incidence.Incident x y),uniformMass i.1.1 x) ≤ + (i.1.2.card:ℝ)/(10000*q) := by + rw [uniform_incidence_sum] + apply (div_le_iff₀ hxr).mpr + apply hsp.trans_eq + dsimp [q] + ring + have hg := projective_ideal_acceptance hdim i.1.1 hx U i.1.2 htt h hh M hM hsize hsp' + change _ ≤ PublicTables.acceptProb (rowLaw W hW h) + (implementAccept i.1.1 (GoodCap SharpLogRamsey.Incidence.Incident q U i.1.2 M)) + rw [proposal_acceptance _ _ hx hW hxw] + have hr := row_ratio_exp hxr hw hratio h + have hprod' := mul_le_mul hr hg (by norm_num : (0:ℝ) ≤ 9/10) (by positivity) + apply le_trans _ hprod' + have he : exp (-((h:ℝ)*b+log 2))= exp (-((h:ℝ)*b))/2 := by + rw [neg_add,exp_add,exp_neg (log 2),exp_log (by norm_num : (0:ℝ)<2)] + ring + calc + exp (-a) ≤ exp (-((h:ℝ)*b+log 2)) := by + apply exp_le_exp.mpr + have hh' : 0 ≤ log (H+1) := log_nonneg (by linarith) + dsimp [a]; linarith + _ ≤ _ := by rw [he]; nlinarith [exp_pos (-((h:ℝ)*b))] + obtain ⟨rows,hcard,hcovers,hlen⟩ := PublicTables.exists_cover (rowLaw W hW h) A a H ha + (coverInput_card W U N t C b) hea hprob + let goodrows := rows.filter (fun z => ((cap SharpLogRamsey.Incidence.Incident q U z).card:ℝ) ≤ M) + let caps := goodrows.image (cap SharpLogRamsey.Incidence.Incident q U) + refine ⟨caps,?_,?_,?_⟩ + · intro E hE + obtain ⟨z,hz,rfl⟩ := mem_image.mp hE + exact ⟨filter_subset _ _,(mem_filter.mp hz).2⟩ + · intro z hz + obtain ⟨r,hr,hacc⟩ := hcovers ⟨z,hz⟩ + have hg : GoodCap SharpLogRamsey.Incidence.Incident q U z.2 M r := hacc.2 + refine ⟨cap SharpLogRamsey.Incidence.Incident q U r,mem_image.mpr ⟨r,mem_filter.mpr ⟨hr,hg.1⟩,rfl⟩,?_⟩ + have hc := cap_capture hz.2.2.2.2.1 hg + rw [hz.2.2.2.2.2.1] at hc + nlinarith only [hc] + · have hc : caps.card ≤ ⌈exp (2*a)⌉₊ := + (card_image_le.trans (card_filter_le _ _)).trans hcard + apply le_trans _ hlen + apply log_le_log (by positivity) + exact_mod_cast Nat.add_le_add_right hc 1 + +end +end SharpLogRamsey.Validation + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Main.lean b/lean/OAI/Combinatorics/SharpRamsey/Main.lean new file mode 100644 index 0000000000000000000000000000000000000000..7f055ba49c2d72958422e3ec7077904b4817168b --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Main.lean @@ -0,0 +1,18 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Construction.PrimeConstruction +import OAI.Combinatorics.SharpRamsey.Bounds.FromConstruction + +namespace OAI + +/-! Sharp logarithmic exponents for fixed off-diagonal Ramsey numbers. -/ + +section +namespace SharpLogRamsey + +theorem main (s : ℕ) (hs : 6 ≤ s) : MainBounds s ∧ MainLimit s := + main_of_primeConstruction s hs (LowerTransfer.prime_construction (s-1) (by omega)) +end SharpLogRamsey + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/ActualClassLaw.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/ActualClassLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..b37eb1b54bf9bd133a53200ed76c7ec57ad6aafe --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/ActualClassLaw.lean @@ -0,0 +1,81 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.OrderedClassLaw + +namespace OAI + +section +namespace SharpLogRamsey.Marking +open Finset Selection +open scoped Classical BigOperators +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] [Finite K] + {Ω Γ : Type*} [Fintype Ω] [Fintype Γ] + +theorem actual_ordered_class {N n : ℕ} (hdim : Module.finrank K V=n+3) + {gap : ℝ} (hgap : 0≤gap) + (p : Law Ω) (C : Ω→Γ) (F : Ω→Fin N→ProjectivePair (K:=K) (V:=V)) + (D : Γ→Fin N→Finset (ProjectivePair (K:=K) (V:=V))) (Jprev : ℝ) + (hcons : ∀ x,p.mass x≠0→ScanConsistent ((List.ofFn (F x)).map toScan)) + (hinc : ∀ x,p.mass x≠0→∀ i,Incidence.Incident (F x i).1 (F x i).2) + (hD : ∀ x,p.mass x≠0→∀ i,F x i∈D (C x) i) + (hprev : ∀ c i,Real.log (D c i).card≤Jprev) + (m : ℕ) + (hm : ((2*(n+3)+(n+3)^2)*m:ℕ)+expensiveBudget K V+ + expensiveBudget K (Module.Dual K V)≤(N:ℝ)) : + ∃ (c : SlotClass (n+2)) (E : Finset (TwoMessage (K:=K) (V:=V) Γ N)) + (hE : 0<(p.map (sourceMessage C F)).event E) + (S : TwoMessage (K:=K) (V:=V) Γ N→Finset (Fin N)) (hmn : m≤N), + let θ:=sourceMessage C F + let p':=p.onContextEvent θ E hE + let e:=chosenOrder S hmn + let G:=orderedTuple S hmn θ F + 1/((2*(n+3)+(n+3)^2:ℕ):ℝ)≤(p.map θ).event E ∧ + (∀ z,(p'.map θ).mass z≠0→(S z).card=m) ∧ + (∀ x,p'.mass x≠0→ScanConsistent ((List.ofFn (G x)).map toScan)) ∧ + (∀ x,p'.mass x≠0→∀ i,Incidence.Incident (G x i).1 (G x i).2) ∧ + (∀ x,p'.mass x≠0→∀ i, + G x i∈cheapBoth (θ x) (e (θ x) i) ∧ + ValidSlotClass (n+2) gap (cheapBoth (θ x) (e (θ x) i)) c) ∧ + (∑ z,(p'.map θ).mass z*((m:ℝ)*jointJ K (n+2)-entropy ((p'.cond θ z).map G)))≤ + excessCost p C F Jprev (jointJ K (n+2))/(p.map θ).event E := by + obtain ⟨c,E,hE,S,hprob,hdis,hcard,hgeom,hdef⟩ := + actual_geometric_class hdim hgap p C F D Jprev hcons hinc hD hprev m hm + have hEn : E.Nonempty := by + by_contra he + rw [not_nonempty_iff_eq_empty.mp he] at hE + simp only [Law.event,sum_empty,lt_self_iff_false] at hE + obtain ⟨z,hz⟩ := hEn + have hmn : m≤N := by + have hh:=card_le_univ (S z) + simpa only [Fintype.card_fin,hcard z hz] using hh + let θ:=sourceMessage C F + let p':=p.onContextEvent θ E hE + have hcard' z (hz : (p'.map θ).mass z≠0) : (S z).card=m := by + apply hcard z + by_contra hn + have he:=p.onContextEvent_map_mass θ E hE z + rw [ite_eq_right hn] at he + exact hz he + refine ⟨c,E,hE,S,hmn,hprob,hcard',?_,?_,?_,?_⟩ + · intro x hx + exact scanConsistent_ordered (F x) + (hcons x ((p.onContextEvent_support θ E hE x hx).1)) (chosenOrder S hmn (θ x)) + · intro x hx i + exact hinc x ((p.onContextEvent_support θ E hE x hx).1) _ + · intro x hx i + obtain ⟨hx,he⟩:=p.onContextEvent_support θ E hE x hx + exact hgeom x hx he _ (chosenOrder_mem S hmn (θ x) (hcard _ he) i) + · calc + _ = selectedDeficit p' θ F S (jointJ K (n+2)) := + ordered_deficit p' θ F S hmn hcard' _ + _ ≤ _ := hdef + +end +end SharpLogRamsey.Marking + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/AtomEscape.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/AtomEscape.lean new file mode 100644 index 0000000000000000000000000000000000000000..10c04aac23b7694216e47f617bb1e17663653058 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/AtomEscape.lean @@ -0,0 +1,531 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.RawLowerTail + +namespace OAI + +/-! High-rank geometric supports and entropy estimates. -/ + +section +open scoped BigOperators Classical +open Finset +namespace SharpLogRamsey.HighRankBudgets +open Filter Real +open scoped Topology BigOperators +noncomputable section +lemma atom_escape {q C K : ℝ} {r : ℕ} (hq : 0 4*C*σ^(-(1999*beta η))) atTop (𝓝 0) := by + simpa using (tendsto_rpow_neg_atTop (show 0<1999*beta η by positivity)).const_mul (4*C) + have h₅ : Tendsto (fun σ : ℝ => C*σ^(-(2*beta η))) atTop (𝓝 0) := by + simpa using (tendsto_rpow_neg_atTop (show 0<2*beta η by positivity)).const_mul C + have h₆ : Tendsto (fun σ : ℝ => C*σ^(-(4*beta η))) atTop (𝓝 0) := by + simpa using (tendsto_rpow_neg_atTop (show 0<4*beta η by positivity)).const_mul C + have h₇ := eventually_exp_K_over_q hη (2*C) 1 (ε/7) (by positivity) (by norm_num) hε7 + filter_upwards [h₁,h₂,h₃,h₄.eventually (gt_mem_nhds hε7), + h₅.eventually (gt_mem_nhds hε7),h₆.eventually (gt_mem_nhds hε7),h₇] + with σ h₁ h₂ h₃ h₄ h₅ h₆ h₇ D hD + simp only [Real.rpow_zero,mul_one] at h₂ h₃ + have h₁ := h₁ D hD + have h₇ := h₇ D hD + simp only [one_mul] at h₇ + unfold error + linarith +end +end SharpLogRamsey.HighRankBudgets + +namespace SharpLogRamsey.SimultaneousExtraction +open scoped BigOperators +open Finset Classical +noncomputable section +variable {Ω : Type*} [Fintype Ω] + +lemma markov_complement (p : Ω → ℝ) (hp : ∀ z, 0 ≤ p z) (ht : ∑ z, p z=1) + (f g : Ω → ℝ) (hf : ∀ z, 0 ≤ f z) (hg : ∀ z, 0 ≤ g z) + (A B : ℝ) (hA : 0 f z ≤ A ∧ g z ≤ B), p z := by + have H (z : Ω) : p z*(1-f z/A-g z/B) ≤ + if f z ≤ A ∧ g z ≤ B then p z else 0 := by + by_cases h : f z ≤ A ∧ g z ≤ B + · rw [ite_eq_left h] + have h0 : 0 ≤ f z/A := div_nonneg (hf z) hA.le + have h1 : 0 ≤ g z/B := div_nonneg (hg z) hB.le + nlinarith [hp z] + · rw [ite_eq_right h] + have he : 1 ≤ f z/A+g z/B := by + by_cases he : f z ≤ A + · have hh : B < g z := lt_of_not_ge (fun hh => h ⟨he,hh⟩) + have hh' : 1 ≤ g z/B := (one_le_div hB).mpr hh.le + linarith [div_nonneg (hf z) hA.le] + · have hh' : 1 ≤ f z/A := (one_le_div hA).mpr (le_of_not_ge he) + linarith [div_nonneg (hg z) hB.le] + exact mul_nonpos_of_nonneg_of_nonpos (hp z) (by linarith) + have HH := sum_le_sum (fun z (_ : z∈univ) => H z) + simpa only [sum_filter, mul_sub, mul_one, mul_div_assoc, sum_sub_distrib, + sum_div, ht] using HH + +theorem simultaneous_mass (p : Ω → ℝ) (hp : ∀ z, 0 ≤ p z) (ht : ∑ z, p z=1) + (f g : Ω → ℝ) (hf : ∀ z, 0 ≤ f z) (hg : ∀ z, 0 ≤ g z) + (E S A B : ℝ) (hA : 0 f z ≤ A ∧ g z ≤ B), p z := by + have H := markov_complement p hp ht f g hf hg A B hA hB + have H₁ := div_le_div_of_nonneg_right hE hA.le + have H₂ := div_le_div_of_nonneg_right hS hB.le + linarith + +def retained {k ℓ : ℕ} (S : Finset (Fin ℓ)) (h : k ≤ S.card) : Fin k ↪o Fin ℓ := + (Fin.castLEOrderEmb h).comp (S.orderEmbOfFin rfl) + +lemma retained_mem {k ℓ : ℕ} (S : Finset (Fin ℓ)) (h : k ≤ S.card) (i : Fin k) : + retained S h i ∈ S := by + exact S.orderEmbOfFin_mem rfl _ + +theorem coverage_selection {ℓ : ℕ} (good : Fin ℓ → Prop) + (h : ((univ.filter (fun i => ¬good i)).card:ℝ) ≤ (ℓ:ℝ)/2) : + ∃ e : Fin (ℓ/2) ↪o Fin ℓ, ∀ i, good (e i) := by + let S := univ.filter good + have he : S.card+(univ.filter (fun i => ¬good i)).card=ℓ := by + simpa [S] using card_filter_add_card_filter_not (s := (univ : Finset (Fin ℓ))) good + have hh : ℓ/2 ≤ S.card := by + have h' : (ℓ:ℝ) ≤ 2*S.card := by + have he' : (S.card:ℝ)+(univ.filter (fun i => ¬good i)).card=ℓ := by exact_mod_cast he + linarith + have hh' : ℓ ≤ 2*S.card := by exact_mod_cast h' + omega + refine ⟨retained S hh, fun i => ?_⟩ + exact (mem_filter.mp (retained_mem S hh i)).2 +end +end SharpLogRamsey.SimultaneousExtraction + +namespace SharpLogRamsey.HighRankAssembly +open scoped BigOperators +open Finset Classical HighRankDecoder HighRankCoverageProbability FiniteEventBounds +open FiniteMarginals +noncomputable section +variable {K Ω : Type*} [Field K] [Fintype K] [Fintype Ω] +variable {d : ℕ} +local notation "V" => (Fin (d+1) → K) +local notation "A" => Projectivization K (Module.Dual K V) +local notation "B" => Projectivization K V +local notation "q" => (Nat.card K : ℝ) +local instance flat_JoinedHighRankAssembly_6 : Fintype B := Fintype.ofFinite _ +local instance flat_JoinedHighRankAssembly_7 : Finite (Module.Dual K V) := + Finite.of_injective ((↑) : Module.Dual K V → (V → K)) DFunLike.coe_injective +local instance flat_JoinedHighRankAssembly_8 : Fintype A := Fintype.ofFinite _ + +theorem low_hit_with_cutoff (hd : 2 ≤ d) + (w : Ω → ℝ) (hw : ∀ z, 0 ≤ w z) (ht : ∑ z, w z = 1) + (a : Ω → A) (M : ℝ) (hM : ∀ b, marginal w a b ≤ M) + (p : B × A → ℝ) (hp : ∀ t, 0 ≤ p t) + (good : B → Prop) (N : ℝ) (hN0 : 0 ≤ N) + (hN : ∀ y, good y → (∑ c, p (y,c)) ≤ N) : + (∑ t, p t * indicator + ((∑ z ∈ univ.filter (fun z => (a z).rep t.1.rep = 0), w z) < 2/(5*q))) ≤ + (∑ y ∈ univ.filter (fun y => ¬good y), ∑ c, p (y,c)) + + 100*q^(d+1)*M*N := by + let p' : B × A → ℝ := fun t => if good t.1 then p t else 0 + have hdim : Module.finrank K V = (d-2)+3 := by simp; omega + have HH := HighRankLowHit.low_hit_mass hdim w hw ht a M hM p' N hN0 (by + intro y + by_cases hy : good y + · simpa [p',hy] using hN y hy + · simpa [p',hy] using hN0) + have he : (d-2)+3 = d+1 := by omega + rw [he] at HH + have H : (∑ t, p t * indicator + ((∑ z ∈ univ.filter (fun z => (a z).rep t.1.rep = 0), w z) < 2/(5*q))) ≤ + (∑ y ∈ univ.filter (fun y => ¬good y), ∑ c, p (y,c)) + + (∑ t, p' t * indicator + ((∑ z ∈ univ.filter (fun z => (a z).rep t.1.rep = 0), w z) < 2/(5*q))) := by + rw [Fintype.sum_prod_type, Fintype.sum_prod_type, sum_filter, ← sum_add_distrib] + apply sum_le_sum + intro y _ + by_cases hy : good y + · simp [p',hy] + · simp only [hy,not_false_eq_true,ite_true,ite_false,p',zero_mul,sum_const_zero,add_zero] + apply sum_le_sum + intro c _ + unfold indicator + split_ifs <;> simp [hp] + exact H.trans (add_le_add_right HH _) + +theorem coverage_source (hd : 2 ≤ d) + (w : Ω → ℝ) (hw : ∀ z, 0 ≤ w z) (ht : ∑ z, w z = 1) + (a : Ω → A) (b : Ω → B) (p : B × A → ℝ) + (hp : ∀ t, 0 ≤ p t) (hpt : ∑ t, p t = 1) + (hincident : ∀ t, p t ≠ 0 → t.2.rep t.1.rep = 0) + (U : Finset B) (hsupp : ∀ t, p t ≠ 0 → t.1 ∈ U) + (good : B → Prop) (h r r' T : ℕ) + (hr : 2 ≤ r) (hrd : r ≤ d) (hrank : d+2 ≤ r+r') (hhd : 2*d ≤ h) + (C κ Ebad Eheavy I : ℝ) (hC : 0 ≤ C) + (hfirst : ∀ x, marginal w a x ≤ C*Real.exp κ/q^r') + (hsecond : ∀ y, marginal w b y ≤ C*Real.exp κ/q^r) + (htarget : ∀ y, good y → (∑ c, p (y,c)) ≤ C*Real.exp κ/q^r) + (hcard : (U.card:ℝ) ≤ C*q^r) + (hbad : (∑ y ∈ univ.filter (fun y => ¬good y), ∑ c, p (y,c)) ≤ Ebad) + (hheavy : (∑ t ∈ U ×ˢ univ, if Real.exp κ/q^d < p t then p t else 0) ≤ Eheavy) + (hconflict : (∑ t, p t*conflictMass w (fun z => (a z).rep) b t.1 t.2) ≤ I) + (hT : (T:ℝ) ≤ (h:ℝ)/(10*q)+1) + (hescape : 20*C*Real.exp κ ≤ q) : + (∑ t, p t*mean2 (ProductLaw.weight w : (Fin h → Ω) → ℝ) + (ProductLaw.weight w : (Fin h → Ω) → ℝ) + (fun z₁ z₂ => indicator (¬Admitted (fun z => (a z).rep) b z₁ z₂ r T t.1 t.2))) ≤ + Ebad + 100*C^2*Real.exp (2*κ)/q + + (d*Real.exp (-3*(h:ℝ)/(20*d*q)) + Real.exp (1-(h:ℝ)/(10*q))) + + 2*h*I + Eheavy + 2*C*Real.exp κ/q := by + have hq : 2 ≤ q := by exact_mod_cast Finite.one_lt_card (α := K) + have hq0 : 0 < q := by linarith + obtain ⟨e⟩ := HighRankBudgets.block_embedding h d r hrd + have hdim : Module.finrank K V = d+1 := by simp + have HC := HighRankAveraged.averaged_coverage w hw ht p hp hpt hincident U hsupp + (fun z => (a z).rep) b h d r (h/d) T hdim hr hrd e + (C*Real.exp κ/q^r) (Real.exp κ/q^d) (by positivity) (by positivity) + (by intro y; simpa [marginal, sum_filter] using hsecond y) hT + have HL := (low_hit_with_cutoff hd w hw ht a (C*Real.exp κ/q^r') hfirst + p hp good (C*Real.exp κ/q^r) (by positivity) htarget).trans + (add_le_add hbad (HighRankBudgets.low_hit_budget (by linarith : 1 ≤ q) hrank)) + have HG := HighRankBudgets.growth_tail hq + (show 0 ≤ C*Real.exp κ/q^r by positivity) hrd (by omega : 0 < d) hhd + (HighRankBudgets.atom_escape hq0 hr hescape) + have HX : (if r < d then (U.card:ℝ)*(2*q^(d-r-1))*(Real.exp κ/q^d) else 0) ≤ + 2*C*Real.exp κ/q := by + split_ifs with hrd' + · have he : q^d = q^r*q^(d-r-1)*q := by + rw [← pow_add, ← pow_succ] + congr 1 + omega + calc + _ ≤ (C*q^r)*(2*q^(d-r-1))*(Real.exp κ/q^d) := by gcongr + _ = _ := by rw [he]; field_simp + · positivity + have HI := mul_le_mul_of_nonneg_left hconflict (show 0 ≤ 2*(h:ℝ) by positivity) + linarith only [HC,HL,HG,HX,HI,hheavy] + +theorem size_source (w : Ω → ℝ) (hw : ∀ z, 0 ≤ w z) (ht : ∑ z, w z = 1) + (a : Ω → A) (b : Ω → B) {h r T : ℕ} (hr : 0 < r) (hrd : r ≤ d) + (X : Finset B) (hsupp : ∀ y, y ∉ X → marginal w b y = 0) + (C κ u : ℝ) (hC : 0 < C) (hu : 0 < u) (huA : u ≤ 2*C*Real.exp κ) + (hu20 : u ≤ 1/20) (hCu : 20*Real.exp (1/2)*u ≤ 1) + (hcap : ∀ y ∈ X, marginal w b y ≤ C*Real.exp κ/q^r) + (hcard : (X.card : ℝ) ≤ C*q^r) + (hT : (h:ℝ)/(10*q) ≤ T) (hTn : d+2 ≤ T) (z₁ : Fin h → Ω) : + (∑ z₂ : Fin h → Ω, ProductLaw.weight w z₂ * + ((HighRankSize.domain (fun z => (a z).rep) b z₁ z₂ r T).card : ℝ)) ≤ + (10*(d+1)*C*Real.exp κ/u)^(d+1)*C*(1+2^(d+2))*(2*q^d) := by + have HU : u ≤ 2*(C*Real.exp κ) := by nlinarith only [huA] + have HS := HighRankSize.expected_domain (n := d+1) (by omega) hr (by omega) + w hw ht (fun z => (a z).rep) b z₁ X hsupp (C*Real.exp κ) u + (by positivity) hu HU hu20 hCu + (by simpa only [Nat.card_eq_fintype_card] using hcap) + (by simpa only [Nat.card_eq_fintype_card] using hT) hTn + simp only [← Nat.card_eq_fintype_card, Nat.cast_add, Nat.cast_one] at HS + have hn : d+1-r-1 = d-r := by omega + have hp : q^r*q^(d-r)=q^d := by rw [← pow_add]; congr 1; omega + apply HS.trans + calc + _ ≤ (10*(d+1)*(C*Real.exp κ)/u)^(d+1)*(C*q^r)*(1+2^(d+1+1))*(2*q^(d+1-r-1)) := by + gcongr + _ = _ := by + rw [hn] + rw [show d+1+1=d+2 by omega] + calc + _ = (10*(d+1)*C*Real.exp κ/u)^(d+1)*C*(1+2^(d+2))*(2*(q^r*q^(d-r))) := by ring + _ = _ := by rw [hp] + +omit [Fintype Ω] in + +lemma domain_raw_rows (a : Ω → A) (b : Ω → B) {h : ℕ} + (z₁ z₂ : Fin h → Ω) (r T : ℕ) : + HighRankSize.domain (fun z : A × B => z.1.rep) Prod.snd + (fun i => (a (z₁ i), b (z₁ i))) (fun i => (a (z₂ i), b (z₂ i))) r T = + HighRankSize.domain (fun z => (a z).rep) b z₁ z₂ r T := rfl +end +end SharpLogRamsey.HighRankAssembly + +namespace SharpLogRamsey.SimultaneousExtraction +open scoped BigOperators Classical +open Finset +noncomputable section +variable {Ω R F : Type*} [Fintype Ω] [Fintype R] [Fintype F] + +def independentWeight (p : Ω → ℝ) (w : R → ℝ) (u : Ω × R) : ℝ := p u.1*w u.2 + +lemma independent_total (p : Ω → ℝ) (w : R → ℝ) + (hp : ∑ x, p x = 1) (hw : ∑ z, w z = 1) : + ∑ u, independentWeight p w u = 1 := by + simp [independentWeight, Fintype.sum_prod_type, ← mul_sum, hp, hw] + +def missed {ℓ : ℕ} (f : Ω → Fin ℓ → F) (D : R → Finset F) (u : Ω × R) : ℕ := + (univ.filter (fun i => f u.1 i ∉ D u.2)).card + +omit [Fintype F] in +lemma missed_mean {ℓ : ℕ} (p : Ω → ℝ) (w : R → ℝ) + (f : Ω → Fin ℓ → F) (D : R → Finset F) : + (∑ u, independentWeight p w u * (missed f D u : ℝ)) = + ∑ i, ∑ x, p x * ∑ z, w z * (if f x i ∉ D z then 1 else 0) := by + have he (u : Ω × R) : (missed f D u : ℝ) = + ∑ i : Fin ℓ, if f u.1 i ∉ D u.2 then (1:ℝ) else 0 := by + rw [← sum_filter] + simp only [missed, sum_const, nsmul_eq_mul, mul_one] + simp_rw [he, mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro i _ + rw [Fintype.sum_prod_type] + simp [independentWeight] + +omit [Fintype F] in +lemma domain_size_mean (p : Ω → ℝ) (w : R → ℝ) (hp : ∑ x, p x = 1) + (D : R → Finset F) : + (∑ u, independentWeight p w u * ((D u.2).card : ℝ)) = + ∑ z, w z * ((D z).card : ℝ) := by + simp [independentWeight, Fintype.sum_prod_type, mul_assoc, ← mul_sum, + ← sum_mul, hp] + +omit [Fintype F] in + +theorem tuple_extraction {ℓ : ℕ} (hℓ : 0 < ℓ) + (p : Ω → ℝ) (hp : ∀ x, 0 ≤ p x) (hpt : ∑ x, p x = 1) + (w : R → ℝ) (hw : ∀ z, 0 ≤ w z) (hwt : ∑ z, w z = 1) + (f : Ω → Fin ℓ → F) (D : R → Finset F) (ε S : ℝ) (hS : 0 < S) + (hcoverage : ∀ i, (∑ x, p x * ∑ z, w z * + (if f x i ∉ D z then (1:ℝ) else 0)) ≤ ε) + (hsize : (∑ z, w z * ((D z).card : ℝ)) ≤ S) : + 1-2*ε-1/4 ≤ + ∑ u ∈ univ.filter (fun u : Ω × R => + ((D u.2).card : ℝ) ≤ 4*S ∧ + ∃ e : Fin (ℓ/2) ↪o Fin ℓ, ∀ i, f u.1 (e i) ∈ D u.2), + independentWeight p w u := by + have hℓ' : (0:ℝ) < ℓ := by exact_mod_cast hℓ + have hmean : (∑ u, independentWeight p w u * (missed f D u : ℝ)) ≤ ℓ*ε := by + rw [missed_mean] + simpa using sum_le_sum (fun i (_ : i∈univ) => hcoverage i) + have HS := simultaneous_mass (independentWeight p w) + (fun u => mul_nonneg (hp u.1) (hw u.2)) (independent_total p w hpt hwt) + (fun u => (missed f D u : ℝ)) (fun u => ((D u.2).card : ℝ)) + (fun _ => Nat.cast_nonneg _) (fun _ => Nat.cast_nonneg _) + (ℓ*ε) S (ℓ/2) (4*S) (by positivity) (by positivity) hmean + (by rw [domain_size_mean p w hpt]; exact hsize) + have he : 1-(ℓ:ℝ)*ε/((ℓ:ℝ)/2)-S/(4*S) = 1-2*ε-1/4 := by + field_simp [hℓ'.ne',hS.ne'] + rw [he] at HS + apply HS.trans + apply sum_le_sum_of_subset_of_nonneg + · intro u hu + obtain ⟨_,hf,hs⟩ := mem_filter.mp hu + refine mem_filter.mpr ⟨mem_univ _, hs, ?_⟩ + apply coverage_selection (fun i => f u.1 i ∈ D u.2) + convert hf using 1 + congr 1 + congr 1 + ext i + simp + · intro u _ _ + exact mul_nonneg (hp u.1) (hw u.2) +end +end SharpLogRamsey.SimultaneousExtraction + +namespace SharpLogRamsey.HighRankAssembly +open scoped BigOperators Classical +open Finset HighRankDecoder HighRankCoverageProbability FiniteEventBounds +open FiniteMarginals SimultaneousExtraction +noncomputable section +variable {K Ω Ξ : Type*} [Field K] [Fintype K] [Fintype Ω] [Fintype Ξ] +variable {d : ℕ} +local instance flat_JoinedHighRankAssembly_9 : Finite (Module.Dual K (Fin (d+1) → K)) := + Finite.of_injective ((↑) : Module.Dual K (Fin (d+1) → K) → ((Fin (d+1) → K) → K)) DFunLike.coe_injective +local instance flat_JoinedHighRankAssembly_10 : Fintype (Projectivization K (Fin (d+1) → K)) := Fintype.ofFinite _ +local instance flat_JoinedHighRankAssembly_11 : Fintype (Projectivization K (Module.Dual K (Fin (d+1) → K))) := Fintype.ofFinite _ +local notation "A" => Projectivization K (Module.Dual K (Fin (d+1) → K)) +local notation "B" => Projectivization K (Fin (d+1) → K) +local notation "q" => (Nat.card K : ℝ) + +omit [Fintype Ξ] in +lemma row_pair_total (w : Ω → ℝ) (ht : ∑ z, w z = 1) (h : ℕ) : + (∑ z : (Fin h → Ω) × (Fin h → Ω), ProductLaw.weight w z.1*ProductLaw.weight w z.2) = 1 := by + have hnt : ∑ z : Fin h → Ω, ProductLaw.weight w z = 1 := by + convert ProductLaw.total (ι := Fin h) w ht using 1 + congr! + exact independent_total (ProductLaw.weight w) (ProductLaw.weight w) hnt hnt + +lemma decoder_miss_mean (w : Ω → ℝ) (a : Ω → A) (b : Ω → B) + (p : Ξ → ℝ) (f : Ξ → B × A) (h r T : ℕ) : + (∑ x, p x * ∑ z : (Fin h → Ω) × (Fin h → Ω), + (ProductLaw.weight w z.1*ProductLaw.weight w z.2) * + (if f x ∉ HighRankSize.domain (fun z => (a z).rep) b z.1 z.2 r T then (1:ℝ) else 0)) = + ∑ t, marginal p f t * mean2 (ProductLaw.weight w : (Fin h → Ω) → ℝ) + (ProductLaw.weight w : (Fin h → Ω) → ℝ) + (fun z₁ z₂ => indicator (¬Admitted (fun z => (a z).rep) b z₁ z₂ r T t.1 t.2)) := by + rw [sum_marginal] + apply sum_congr rfl + intro x _ + congr 1 + simp [HighRankSize.domain, mean2, Fintype.sum_prod_type, indicator, mul_sum] + +omit [Fintype Ξ] in +lemma row_pair_size (w : Ω → ℝ) (hw : ∀ z, 0 ≤ w z) (ht : ∑ z, w z = 1) + (a : Ω → A) (b : Ω → B) (h r T : ℕ) (S : ℝ) + (hS : ∀ z₁ : Fin h → Ω, (∑ z₂ : Fin h → Ω, ProductLaw.weight w z₂ * + ((HighRankSize.domain (fun z => (a z).rep) b z₁ z₂ r T).card:ℝ)) ≤ S) : + (∑ z : (Fin h → Ω) × (Fin h → Ω), + (ProductLaw.weight w z.1*ProductLaw.weight w z.2) * + ((HighRankSize.domain (fun z => (a z).rep) b z.1 z.2 r T).card:ℝ)) ≤ S := by + rw [Fintype.sum_prod_type] + calc + _ = ∑ z₁ : Fin h → Ω, ProductLaw.weight w z₁ * + ∑ z₂ : Fin h → Ω, ProductLaw.weight w z₂ * + ((HighRankSize.domain (fun z => (a z).rep) b z₁ z₂ r T).card:ℝ) := by + simp only [mul_sum, mul_assoc] + _ ≤ ∑ z₁ : Fin h → Ω, ProductLaw.weight w z₁ *S := + sum_le_sum (fun z₁ _ => mul_le_mul_of_nonneg_left (hS z₁) (ProductLaw.nonneg w hw z₁)) + _ = S := by + have hnt : ∑ z : Fin h → Ω, ProductLaw.weight w z = 1 := by + convert ProductLaw.total (ι := Fin h) w ht using 1 + congr! + rw [← sum_mul, hnt, one_mul] + +theorem extraction_source (hd : 2 ≤ d) {ℓ : ℕ} (hℓ : 0 < ℓ) + (w : Ω → ℝ) (hw : ∀ z, 0 ≤ w z) (ht : ∑ z, w z = 1) + (a : Ω → A) (b : Ω → B) + (p : Ξ → ℝ) (hp : ∀ x, 0 ≤ p x) (hpt : ∑ x, p x = 1) + (f : Ξ → Fin ℓ → B × A) + (U : Fin ℓ → Finset B) (good : Fin ℓ → B → Prop) + (h r r' T : ℕ) (hr : 2 ≤ r) (hrd : r ≤ d) + (hrank : d+2 ≤ r+r') (hhd : 2*d ≤ h) + (C κ u Ebad Eheavy I : ℝ) (hC : 0 < C) + (hu : 0 < u) (huA : u ≤ 2*C*Real.exp κ) + (hu20 : u ≤ 1/20) (hCu : 20*Real.exp (1/2)*u ≤ 1) + (hfirst : ∀ x, marginal w a x ≤ C*Real.exp κ/q^r') + (hsecond : ∀ y, marginal w b y ≤ C*Real.exp κ/q^r) + (X : Finset B) (hX : ∀ y, y ∉ X → marginal w b y = 0) + (hXcard : (X.card:ℝ) ≤ C*q^r) + (hincident : ∀ i t, marginal p (fun x => f x i) t ≠ 0 → t.2.rep t.1.rep = 0) + (hsupp : ∀ i t, marginal p (fun x => f x i) t ≠ 0 → t.1 ∈ U i) + (htarget : ∀ i y, good i y → (∑ c, marginal p (fun x => f x i) (y,c)) ≤ C*Real.exp κ/q^r) + (hcard : ∀ i, ((U i).card:ℝ) ≤ C*q^r) + (hbad : ∀ i, (∑ y ∈ univ.filter (fun y => ¬good i y), + ∑ c, marginal p (fun x => f x i) (y,c)) ≤ Ebad) + (hheavy : ∀ i, (∑ t ∈ (U i) ×ˢ univ, + if Real.exp κ/q^d < marginal p (fun x => f x i) t + then marginal p (fun x => f x i) t else 0) ≤ Eheavy) + (hconflict : ∀ i, (∑ t, marginal p (fun x => f x i) t * + conflictMass w (fun z => (a z).rep) b t.1 t.2) ≤ I) + (hTlo : (h:ℝ)/(10*q) ≤ T) (hThi : (T:ℝ) ≤ (h:ℝ)/(10*q)+1) + (hTn : d+2 ≤ T) (hescape : 20*C*Real.exp κ ≤ q) : + let S := (10*(d+1)*C*Real.exp κ/u)^(d+1)*C*(1+2^(d+2))*(2*q^d) + let E := Ebad + 100*C^2*Real.exp (2*κ)/q + + (d*Real.exp (-3*(h:ℝ)/(20*d*q)) + Real.exp (1-(h:ℝ)/(10*q))) + + 2*h*I + Eheavy + 2*C*Real.exp κ/q + let W := fun z : (Fin h → Ω) × (Fin h → Ω) => ProductLaw.weight w z.1*ProductLaw.weight w z.2 + let D := fun z : (Fin h → Ω) × (Fin h → Ω) => HighRankSize.domain (fun z => (a z).rep) b z.1 z.2 r T + 1-2*E-1/4 ≤ + ∑ v ∈ univ.filter (fun v : Ξ × ((Fin h → Ω) × (Fin h → Ω)) => + ((D v.2).card:ℝ) ≤ 4*S ∧ + ∃ e : Fin (ℓ/2) ↪o Fin ℓ, ∀ i, f v.1 (e i) ∈ D v.2), + p v.1*W v.2 := by + dsimp only + let W := fun z : (Fin h → Ω) × (Fin h → Ω) => ProductLaw.weight w z.1*ProductLaw.weight w z.2 + let D := fun z : (Fin h → Ω) × (Fin h → Ω) => HighRankSize.domain (fun z => (a z).rep) b z.1 z.2 r T + have hW : ∀ z, 0 ≤ W z := fun z => mul_nonneg (ProductLaw.nonneg w hw z.1) (ProductLaw.nonneg w hw z.2) + have hWt : ∑ z, W z = 1 := row_pair_total w ht h + have hq : 0 < q := by exact_mod_cast Nat.card_pos (α := K) + have hpos : 0 < ((10*(d+1)*C*Real.exp κ/u)^(d+1)*C*(1+2^(d+2))*(2*q^d)) := by + positivity + have HX := tuple_extraction hℓ p hp hpt W hW hWt f D + (Ebad + 100*C^2*Real.exp (2*κ)/q + + (d*Real.exp (-3*(h:ℝ)/(20*d*q)) + Real.exp (1-(h:ℝ)/(10*q))) + + 2*h*I + Eheavy + 2*C*Real.exp κ/q) + ((10*(d+1)*C*Real.exp κ/u)^(d+1)*C*(1+2^(d+2))*(2*q^d)) hpos + refine (HX ?_ ?_).trans ?_ + · intro i + have HC := coverage_source hd w hw ht a b (marginal p (fun x => f x i)) + (marginal_nonneg p hp _) (by rw [marginal_total]; exact hpt) + (hincident i) (U i) (hsupp i) (good i) h r r' T hr hrd hrank hhd C κ Ebad Eheavy I hC.le + hfirst hsecond (htarget i) (hcard i) (hbad i) (hheavy i) (hconflict i) hThi hescape + have Hmean := (decoder_miss_mean w a b p (fun x => f x i) h r T).le.trans HC + convert Hmean using 1 + congr! + · apply row_pair_size w hw ht a b h r T + intro z₁ + exact size_source w hw ht a b (by omega) hrd X hX C κ u hC hu huA hu20 hCu + (fun y _ => hsecond y) hXcard hTlo hTn z₁ + · apply le_of_eq + congr! +end +end SharpLogRamsey.HighRankAssembly + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/CardVectorLifts.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/CardVectorLifts.lean new file mode 100644 index 0000000000000000000000000000000000000000..e21a8b19907700805101dcd699f47b108fa6576e --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/CardVectorLifts.lean @@ -0,0 +1,464 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.HighRank + +namespace OAI + +/-! High-rank geometric supports and entropy estimates. -/ + +section +open scoped BigOperators Classical +open Finset +section +namespace SharpLogRamsey.RichUnion +noncomputable section +open Module +section ProjectiveLifts +variable {K : Type*} [Field K] [Fintype K] {n : ℕ} +theorem card_vectorLifts (X : Finset (Projectivization K (Fin n → K))) : + (vectorLifts X).card = X.card * (Fintype.card K - 1) := by + classical + let e₁ := (Projectivization.nonZeroEquivProjectivizationProdUnits K (Fin n → K)).subtypeEquiv + (p := fun v => Projectivization.mk K v.1 v.2 ∈ X) + (q := fun z => z.1 ∈ X) (fun _ => Iff.rfl) + let e₂ : {z : Projectivization K (Fin n → K) × Kˣ // z.1 ∈ X} ≃ X × Kˣ := + { toFun := fun z => (⟨z.1.1, z.2⟩, z.1.2) + invFun := fun z => ⟨(z.1.1, z.2), z.1.2⟩ + left_inv := fun _ => rfl + right_inv := fun _ => rfl } + have h := Fintype.card_congr (e₁.trans e₂) + simpa [vectorLifts, Fintype.card_units, Fintype.card_subtype] using h + +def projectiveIn (X : Finset (Projectivization K (Fin n → K))) + (W : Submodule K (Fin n → K)) : Finset (Projectivization K (Fin n → K)) := by + classical + exact X.filter (fun a => a.submodule ≤ W) +omit [Fintype K] in + +@[simp] theorem mem_projectiveIn (X : Finset (Projectivization K (Fin n → K))) + (W : Submodule K (Fin n → K)) (a : Projectivization K (Fin n → K)) : + a ∈ projectiveIn X W ↔ a ∈ X ∧ a.submodule ≤ W := by + classical + simp [projectiveIn] + +theorem vectorLifts_projectiveIn (X : Finset (Projectivization K (Fin n → K))) + (W : Submodule K (Fin n → K)) : + vectorLifts (projectiveIn X W) = inSubspace (vectorLifts X) W := by + ext v + simp only [mem_vectorLifts, mem_projectiveIn, Projectivization.submodule_mk, + Submodule.span_singleton_le_iff_mem, mem_inSubspace] + exact exists_and_right + +def projectivePoints (W : Submodule K (Fin n → K)) : + Finset (Projectivization K (Fin n → K)) := by + classical + letI := Fintype.ofFinite (Projectivization K (Fin n → K)) + exact Finset.univ.filter (fun a => a.submodule ≤ W) + +@[simp] theorem mem_projectivePoints (W : Submodule K (Fin n → K)) + (a : Projectivization K (Fin n → K)) : + a ∈ projectivePoints W ↔ a.submodule ≤ W := by + classical + simp [projectivePoints] + +def projectiveUnion (𝓥 : Set (Submodule K (Fin n → K))) : + Finset (Projectivization K (Fin n → K)) := by + classical + letI := Fintype.ofFinite (Projectivization K (Fin n → K)) + exact Finset.univ.filter (fun a => ∃ W ∈ 𝓥, a.submodule ≤ W) + +@[simp] theorem mem_projectiveUnion (𝓥 : Set (Submodule K (Fin n → K))) + (a : Projectivization K (Fin n → K)) : + a ∈ projectiveUnion 𝓥 ↔ ∃ W ∈ 𝓥, a.submodule ≤ W := by + classical + simp [projectiveUnion] + +def projectiveSubmoduleEquiv (W : Submodule K (Fin n → K)) : + Projectivization K W ≃ {a : Projectivization K (Fin n → K) // a.submodule ≤ W} := by + let f : Projectivization K W → {a : Projectivization K (Fin n → K) // a.submodule ≤ W} := + fun a => ⟨Projectivization.map W.subtype W.injective_subtype a, by + induction a using Projectivization.ind with + | h v hv => + rw [Projectivization.map_mk, Projectivization.submodule_mk, + Submodule.span_singleton_le_iff_mem] + exact v.property⟩ + apply Equiv.ofBijective f + constructor + · intro a b h + exact Projectivization.map_injective W.subtype W.injective_subtype + (congrArg Subtype.val h) + · rintro ⟨a, ha⟩ + have hmem : a.rep ∈ W := ha (by + rw [Projectivization.submodule_eq] + exact Submodule.mem_span_singleton_self _) + let v : W := ⟨a.rep, hmem⟩ + have hv : v ≠ 0 := fun h => a.rep_nonzero (congrArg Subtype.val h) + refine ⟨Projectivization.mk K v hv, ?_⟩ + apply Subtype.ext + exact a.mk_rep + +theorem card_projectivePoints (W : Submodule K (Fin n → K)) : + (projectivePoints W).card = Nat.card (Projectivization K W) := by + classical + let := Fintype.ofFinite (Projectivization K (Fin n → K)) + rw [Nat.card_congr (projectiveSubmoduleEquiv W), Nat.card_eq_fintype_card, + Fintype.card_subtype] + rfl + +theorem card_projectivePoints_mul (W : Submodule K (Fin n → K)) : + (projectivePoints W).card * (Fintype.card K - 1) = Nat.card W - 1 := by + rw [card_projectivePoints, ← Nat.card_eq_fintype_card] + exact (Projectivization.card K W).symm + +theorem rich_union_projective (hn : 0 < n) + (X : Finset (Projectivization K (Fin n → K))) + (𝓥 : Set (Submodule K (Fin n → K))) (δ : ℝ) + (hδ : 0 < δ) (hδ1 : δ ≤ 1) (hne : ∀ W ∈ 𝓥, W ≠ ⊥) + (hrich : ∀ W ∈ 𝓥, δ*(projectivePoints W).card ≤ (projectiveIn X W).card) : + ((projectiveUnion 𝓥).card : ℝ) ≤ (5*n/δ)^n * X.card := by + classical + have hq : 0 < Fintype.card K - 1 := Nat.sub_pos_of_lt Fintype.one_lt_card + have hqR : (0 : ℝ) < (Fintype.card K - 1 : ℕ) := by exact_mod_cast hq + have hv : ∀ W ∈ 𝓥, δ*((Nat.card W : ℝ)-1) ≤ + (inSubspace (vectorLifts X) W).card := by + intro W hW + rw [← vectorLifts_projectiveIn, card_vectorLifts] + have hN : 1 ≤ Nat.card W := Nat.card_pos + have hcard := card_projectivePoints_mul W + have hcardR : ((projectivePoints W).card : ℝ)*(Fintype.card K-1 : ℕ) = + (Nat.card W : ℝ)-1 := by + exact_mod_cast hcard + rw [Nat.cast_mul, ← hcardR] + nlinarith [mul_le_mul_of_nonneg_right (hrich W hW) hqR.le] + have hcover : ∀ y ∈ vectorLifts (projectiveUnion 𝓥), ∃ W ∈ 𝓥, y ∈ W := by + intro y hy + obtain ⟨hy0, hY⟩ := (mem_vectorLifts _ _).mp hy + obtain ⟨W, hW, hyW⟩ := (mem_projectiveUnion _ _).mp hY + rw [Projectivization.submodule_mk, Submodule.span_singleton_le_iff_mem] at hyW + exact ⟨W, hW, hyW⟩ + have h := rich_union_vector hn (vectorLifts X) (vectorLifts (projectiveUnion 𝓥)) + 𝓥 δ hδ hδ1 hne hv hcover + rw [card_vectorLifts, card_vectorLifts, Nat.cast_mul, Nat.cast_mul] at h + exact (mul_le_mul_iff_left₀ hqR).mp (by simpa [mul_assoc] using h) + +end ProjectiveLifts +end +end SharpLogRamsey.RichUnion +end +section + +namespace SharpLogRamsey.HighRankGeometry +open scoped BigOperators +open SharpLogRamsey.RichUnion +noncomputable section +variable {K : Type*} [Field K] [Fintype K] {n : ℕ} + +lemma sum_powers_le_twice {q : ℝ} (hq : 2 ≤ q) {r : ℕ} (hr : 0 < r) : + ∑ i ∈ Finset.range r, q^i ≤ 2*q^(r-1) := by + obtain ⟨m, rfl⟩ := Nat.exists_eq_succ_of_ne_zero (Nat.ne_of_gt hr) + simp only [Nat.succ_sub_one] + clear hr + induction m with + | zero => simp + | succ m ih => + rw [Finset.sum_range_succ] + have hqm : 0 ≤ q^m := pow_nonneg (by linarith) _ + have hmul : 2*q^m ≤ q^(m+1) := by rw [pow_succ]; nlinarith + simp only [Nat.succ_eq_add_one] at ih + linarith + +lemma projective_card_le (W : Submodule K (Fin n → K)) {r : ℕ} + (hr : 0 < r) (hdim : Module.finrank K W = r) : + ((projectivePoints W).card : ℝ) ≤ 2*(Fintype.card K : ℝ)^(r-1) := by + rw [card_projectivePoints, Projectivization.card_of_finrank K W hdim] + simp only [Nat.cast_sum, Nat.cast_pow, Nat.card_eq_fintype_card] + exact sum_powers_le_twice (by exact_mod_cast Fintype.one_lt_card (α := K)) hr + +lemma subspace_mass_le (mass : Projectivization K (Fin n → K) → ℝ) + (X : Finset (Projectivization K (Fin n → K))) + (hsupport : ∀ x, x ∉ X → mass x = 0) (M : ℝ) + (hcap : ∀ x ∈ X, mass x ≤ M) (W : Submodule K (Fin n → K)) : + ∑ x ∈ projectivePoints W, mass x ≤ M*(projectiveIn X W).card := by + classical + have hsub : projectiveIn X W ⊆ projectivePoints W := by + intro x hx + exact (mem_projectivePoints W x).mpr ((mem_projectiveIn _ _ _).mp hx).2 + have he : ∑ x ∈ projectiveIn X W, mass x = ∑ x ∈ projectivePoints W, mass x := by + apply Finset.sum_subset hsub + intro x hx hnot + apply hsupport x + intro hxX + exact hnot ((mem_projectiveIn X W x).mpr ⟨hxX, (mem_projectivePoints W x).mp hx⟩) + rw [← he] + calc + _ ≤ ∑ _x ∈ projectiveIn X W, M := Finset.sum_le_sum (fun x hx => + hcap x ((mem_projectiveIn _ _ _).mp hx).1) + _ = _ := by simp [mul_comm] + +theorem threshold_rich (mass : Projectivization K (Fin n → K) → ℝ) + (X : Finset (Projectivization K (Fin n → K))) + (hsupport : ∀ x, x ∉ X → mass x = 0) + (A u : ℝ) (hA : 0 < A) (hu : 0 < u) + (r : ℕ) (hr : 0 < r) + (hcap : ∀ x ∈ X, mass x ≤ A/(Fintype.card K : ℝ)^r) + (W : Submodule K (Fin n → K)) (hrank : Module.finrank K W = r) + (hhit : u ≤ (Fintype.card K : ℝ)*∑ x ∈ projectivePoints W, mass x) : + (u/(2*A))*((projectivePoints W).card : ℝ) ≤ (projectiveIn X W).card := by + have hq : (0 : ℝ) < Fintype.card K := by exact_mod_cast Fintype.card_pos + have hp : (0 : ℝ) < (Fintype.card K : ℝ)^(r-1) := pow_pos hq _ + have hr' : r = (r-1)+1 := by omega + have hm := mul_le_mul_of_nonneg_left (subspace_mass_le mass X hsupport _ hcap W) hq.le + have hm' : u*(Fintype.card K : ℝ)^(r-1) ≤ A*(projectiveIn X W).card := by + have hu' := hhit.trans hm + rw [hr', pow_succ] at hu' + have he : (Fintype.card K : ℝ)*(A/((Fintype.card K : ℝ)^(r-1)*(Fintype.card K : ℝ))* + (projectiveIn X W).card) = (A*(projectiveIn X W).card)/(Fintype.card K : ℝ)^(r-1) := by + have algebra (a b c d : ℝ) (ha : a ≠ 0) (hb : b ≠ 0) : + a*(c/(b*a)*d) = c*d/b := by field_simp + exact algebra _ _ _ _ (ne_of_gt hq) (ne_of_gt hp) + rw [he] at hu' + exact (le_div_iff₀ hp).mp hu' + have hc := projective_card_le W hr hrank + apply (mul_le_mul_iff_right₀ (show 0 < 2*A by positivity)).mp + calc + (2*A)*((u/(2*A))*((projectivePoints W).card : ℝ)) = u*(projectivePoints W).card := by + have algebra (a b c : ℝ) (ha : a ≠ 0) : a*(b/a*c) = b*c := by + rw [← mul_assoc, mul_div_cancel₀ _ ha] + exact algebra _ _ _ (ne_of_gt (show 0 < 2*A by positivity)) + _ ≤ u*(2*(Fintype.card K : ℝ)^(r-1)) := mul_le_mul_of_nonneg_left hc hu.le + _ ≤ (2*A)*(projectiveIn X W).card := by nlinarith + +theorem high_rank_tail (hn : 0 < n) + (mass : Projectivization K (Fin n → K) → ℝ) + (X Y : Finset (Projectivization K (Fin n → K))) + (hsupport : ∀ x, x ∉ X → mass x = 0) + (A u : ℝ) (hA : 0 < A) (hu : 0 < u) (huA : u ≤ 2*A) + (r : ℕ) (hr : 0 < r) + (hcap : ∀ x ∈ X, mass x ≤ A/(Fintype.card K : ℝ)^r) + (W : Projectivization K (Fin n → K) → Submodule K (Fin n → K)) + (hrank : ∀ y ∈ Y, Module.finrank K (W y) = r) + (hy : ∀ y ∈ Y, y.submodule ≤ W y) + (hhit : ∀ y ∈ Y, u ≤ (Fintype.card K : ℝ)*∑ x ∈ projectivePoints (W y), mass x) : + (Y.card : ℝ) ≤ (10*(n : ℝ)*A/u)^n*X.card := by + classical + let 𝓥 : Set (Submodule K (Fin n → K)) := W '' (Y : Set _) + have hδ : 0 < u/(2*A) := by positivity + have hδ1 : u/(2*A) ≤ 1 := (div_le_one (by positivity)).mpr huA + have hne : ∀ U ∈ 𝓥, U ≠ ⊥ := by + rintro U ⟨y, hyY, rfl⟩ hz + have h := hrank y hyY + rw [hz, finrank_bot] at h + omega + have hrich : ∀ U ∈ 𝓥, (u/(2*A))*((projectivePoints U).card : ℝ) ≤ + (projectiveIn X U).card := by + rintro U ⟨y, hyY, rfl⟩ + exact threshold_rich mass X hsupport A u hA hu r hr hcap (W y) (hrank y hyY) (hhit y hyY) + have hh := rich_union_projective hn X 𝓥 (u/(2*A)) hδ hδ1 hne hrich + have hsub : Y ⊆ projectiveUnion 𝓥 := by + intro y hyY + exact (mem_projectiveUnion 𝓥 y).mpr ⟨W y, ⟨y, hyY, rfl⟩, hy y hyY⟩ + calc + _ ≤ ((projectiveUnion 𝓥).card : ℝ) := by exact_mod_cast Finset.card_le_card hsub + _ ≤ (5*(n : ℝ)/(u/(2*A)))^n*X.card := hh + _ = _ := by congr 2; field_simp; ring + +end +end SharpLogRamsey.HighRankGeometry +end + +section + +namespace SharpLogRamsey.FiniteSamplingBounds +open scoped BigOperators +open Finset Classical +noncomputable section +variable {Ω : Type*} [Fintype Ω] + +noncomputable def rowTail (w : Ω → ℝ) (E : Finset Ω) (h T : ℕ) : ℝ := + ∑ z : Fin h → Ω, if T ≤ hitCount E z then rowWeight w z else 0 + +lemma rowTail_nonneg (w : Ω → ℝ) (hw : ∀ x, 0 ≤ w x) (E : Finset Ω) (h T : ℕ) : + 0 ≤ rowTail w E h T := by + apply Finset.sum_nonneg + intro z _ + split_ifs + · exact rowWeight_nonneg w hw z + · exact le_rfl + +lemma rowTail_le_one (w : Ω → ℝ) (hw : ∀ x, 0 ≤ w x) (ht : ∑ x, w x = 1) + (E : Finset Ω) (h T : ℕ) : rowTail w E h T ≤ 1 := by + rw [← rowWeight_total w ht h] + apply Finset.sum_le_sum + intro z _ + split_ifs <;> try rfl + exact rowWeight_nonneg w hw z + +lemma rowTail_moment (w : Ω → ℝ) (hw : ∀ x, 0 ≤ w x) + (ht : ∑ x, w x = 1) (E : Finset Ω) (h T : ℕ) (b : ℝ) (hb : 1 ≤ b) : + b^T*rowTail w E h T ≤ (1+(b-1)*(∑ x ∈ E, w x))^h := by + classical + rw [← rowMoment w ht E h b, rowTail, Finset.mul_sum] + apply Finset.sum_le_sum + intro z _ + split_ifs with hz + · rw [mul_comm (b^T)] + exact mul_le_mul_of_nonneg_left (pow_le_pow_right₀ hb hz) (rowWeight_nonneg w hw z) + · simp only [mul_zero] + exact mul_nonneg (rowWeight_nonneg w hw z) (pow_nonneg (by linarith) _) + +theorem rowTail_small (w : Ω → ℝ) (hw : ∀ x, 0 ≤ w x) + (ht : ∑ x, w x = 1) (E : Finset Ω) (h T : ℕ) + (q a : ℝ) (hq : 0 < q) (ha : 0 < a) (ha1 : a ≤ 1/20) + (hp : ∑ x ∈ E, w x ≤ a/q) (hT : (h : ℝ)/(10*q) ≤ T) : + rowTail w E h T ≤ (20*Real.exp (1/2)*a)^T := by + let b : ℝ := 1/(20*a) + have hb : 1 ≤ b := (le_div_iff₀ (by positivity)).mpr (by linarith) + have hb0 : 0 < b := by linarith + have hp0 : 0 ≤ ∑ x ∈ E, w x := Finset.sum_nonneg (fun x _ => hw x) + have hv0 : 0 ≤ (b-1)*(∑ x ∈ E, w x) := mul_nonneg (by linarith) hp0 + have hM := rowTail_moment w hw ht E h T b hb + have hExp : (1+(b-1)*(∑ x ∈ E, w x))^h ≤ + Real.exp ((h : ℝ)*((b-1)*(∑ x ∈ E, w x))) := by + rw [Real.exp_nat_mul] + apply pow_le_pow_left₀ (show 0 ≤ 1+(b-1)*(∑ x ∈ E, w x) by linarith) + simpa only [add_comm] using Real.add_one_le_exp ((b-1)*(∑ x ∈ E, w x)) + have he : (h : ℝ)*((b-1)*(∑ x ∈ E, w x)) ≤ (T : ℝ)/2 := by + have h1 : (b-1)*(∑ x ∈ E, w x) ≤ b*(a/q) := by + exact mul_le_mul (by linarith) hp hp0 hb0.le + have h2 : b*(a/q) = 1/(20*q) := by dsimp [b]; field_simp + rw [h2] at h1 + have hh := mul_le_mul_of_nonneg_left h1 (Nat.cast_nonneg h) + have ht' : (h : ℝ)/(20*q) ≤ (T : ℝ)/2 := by + have heq : (h : ℝ)/(20*q) = ((h : ℝ)/(10*q))/2 := by ring + rw [heq] + exact div_le_div_of_nonneg_right hT (by norm_num) + have hh' : (h : ℝ)*((b-1)*(∑ x ∈ E, w x)) ≤ (h : ℝ)/(20*q) := by + simpa only [mul_one_div] using hh + exact hh'.trans ht' + have hM' : b^T*rowTail w E h T ≤ Real.exp ((T : ℝ)/2) := + hM.trans (hExp.trans (Real.exp_le_exp.mpr he)) + have hdiv : rowTail w E h T ≤ Real.exp ((T : ℝ)/2)/b^T := + (le_div_iff₀ (pow_pos hb0 T)).mpr (by simpa only [mul_comm] using hM') + convert hdiv using 1 + have hexp : Real.exp ((T : ℝ)/2) = (Real.exp (1/2))^T := by + rw [← Real.exp_nat_mul] + congr 1 + ring + rw [hexp, ← div_pow] + congr 1 + dsimp [b] + field_simp + +lemma rowTail_zero (w : Ω → ℝ) (hw : ∀ x, 0 ≤ w x) (E : Finset Ω) + (h T : ℕ) (hT : 0 < T) (hp : ∑ x ∈ E, w x = 0) : + rowTail w E h T = 0 := by + classical + apply Finset.sum_eq_zero + intro z _ + split_ifs with hz + · have hc : 0 < (univ.filter (fun i => z i ∈ E)).card := by + change 0 < hitCount E z + omega + obtain ⟨i,hi⟩ := Finset.card_pos.mp hc + have hxi : z i ∈ E := (mem_filter.mp hi).2 + have hwi : w (z i) = 0 := by + apply le_antisymm _ (hw _) + rw [← hp] + exact Finset.single_le_sum (fun x _ => hw x) hxi + exact Finset.prod_eq_zero (mem_univ i) hwi + · rfl + +end +end SharpLogRamsey.FiniteSamplingBounds +end + +section + +namespace SharpLogRamsey.DyadicTail +open scoped BigOperators +open Finset Classical +noncomputable section + +lemma exists_band {a u : ℝ} (ha : 0 < a) (hu : 0 < u) (hau : a ≤ u) : + ∃ j : ℕ, u*(1/2 : ℝ)^(j+1) < a ∧ a ≤ u*(1/2 : ℝ)^j := by + have hex : ∃ j : ℕ, u*(1/2 : ℝ)^j < a := by + obtain ⟨j,hj⟩ := exists_pow_lt_of_lt_one (div_pos ha hu) (by norm_num : (1/2 : ℝ) < 1) + exact ⟨j,(by simpa only [mul_comm] using (lt_div_iff₀ hu).mp hj)⟩ + have hn : Nat.find hex ≠ 0 := by + intro hz + have hh := Nat.find_spec hex + rw [hz, pow_zero, mul_one] at hh + exact (not_lt_of_ge hau) hh + obtain ⟨j,hj⟩ := Nat.exists_eq_succ_of_ne_zero hn + refine ⟨j, ?_, ?_⟩ + · simpa only [hj, Nat.succ_eq_add_one] using Nat.find_spec hex + · exact le_of_not_gt (fun h => by have hh := Nat.find_min' hex h; omega) + +lemma finite_geometric (J : Finset ℕ) : ∑ j ∈ J, (1/2 : ℝ)^j ≤ 2 := by + have hs : Summable (fun j : ℕ => (1/2 : ℝ)^j) := + summable_geometric_of_lt_one (by norm_num) (by norm_num) + have hh := hs.sum_le_tsum J (fun j _ => pow_nonneg (by norm_num : (0 : ℝ) ≤ 1/2) j) + simpa only [tsum_geometric_of_lt_one (by norm_num : (0 : ℝ) ≤ 1/2) + (by norm_num : (1/2 : ℝ) < 1), show (1-(1/2 : ℝ))⁻¹ = 2 by norm_num] using hh + +variable {Y : Type*} [Fintype Y] + +theorem small_tail_sum (a w : Y → ℝ) (u C M : ℝ) (n T : ℕ) + (hu : 0 < u) (hC : 0 ≤ C) (hM : 0 ≤ M) (hCu : C*u ≤ 1) + (ha : ∀ x, 0 < a x ∧ a x ≤ u) (hw : ∀ x, w x ≤ (C*a x)^T) + (hT : n+1 ≤ T) + (htail : ∀ v, 0 < v → v ≤ u → + ((univ.filter (fun x : Y => v ≤ a x)).card : ℝ) ≤ M*(u/v)^n) : + ∑ x, w x ≤ M*2^(n+1) := by + classical + choose level hlower hupper using fun x => exists_band (ha x).1 hu (ha x).2 + let J : Finset ℕ := univ.image level + have hband (j : ℕ) : + ∑ x ∈ univ.filter (fun x : Y => level x = j), w x ≤ M*2^n*(1/2 : ℝ)^j := by + let δ : ℝ := (1/2 : ℝ)^j + have hδ : 0 < δ := pow_pos (by norm_num) _ + have hδ1 : δ ≤ 1 := pow_le_one₀ (by norm_num) (by norm_num) + have hv : 0 < u*δ/2 := by positivity + have hvu : u*δ/2 ≤ u := by nlinarith + have hcnt := htail (u*δ/2) hv hvu + have hsub : univ.filter (fun x : Y => level x = j) ⊆ + univ.filter (fun x : Y => u*δ/2 ≤ a x) := by + intro x hx + have hh := hlower x + rw [(mem_filter.mp hx).2, pow_succ] at hh + exact mem_filter.mpr ⟨mem_univ _, by dsimp [δ]; linarith⟩ + have hc' : ((univ.filter (fun x : Y => level x = j)).card : ℝ) ≤ + ((univ.filter (fun x : Y => u*δ/2 ≤ a x)).card : ℝ) := by + exact_mod_cast Finset.card_le_card hsub + have hc := hc'.trans hcnt + have hweight : ∀ x ∈ univ.filter (fun x : Y => level x = j), w x ≤ δ^(n+1) := by + intro x hx + have ha' : a x ≤ u*δ := by simpa only [(mem_filter.mp hx).2] using hupper x + have hca : C*a x ≤ δ := by nlinarith [mul_le_mul_of_nonneg_left ha' hC] + exact (hw x).trans ((pow_le_pow_left₀ (mul_nonneg hC (ha x).1.le) hca T).trans + (pow_le_pow_of_le_one hδ.le hδ1 hT)) + calc + _ ≤ ∑ _x ∈ univ.filter (fun x : Y => level x = j), δ^(n+1) := + Finset.sum_le_sum hweight + _ = ((univ.filter (fun x : Y => level x = j)).card : ℝ)*δ^(n+1) := by simp + _ ≤ (M*(u/(u*δ/2))^n)*δ^(n+1) := mul_le_mul_of_nonneg_right hc (pow_nonneg hδ.le _) + _ = M*2^n*δ := by + have he : u/(u*δ/2) = 2/δ := by field_simp + rw [he, div_pow, pow_succ] + field_simp + _ = _ := rfl + have hsum : ∑ x, w x = ∑ j ∈ J, ∑ x ∈ univ.filter (fun x : Y => level x = j), w x := by + symm + exact Finset.sum_fiberwise_of_maps_to (fun x _ => mem_image.mpr ⟨x, mem_univ _, rfl⟩) w + rw [hsum] + calc + _ ≤ ∑ j ∈ J, M*2^n*(1/2 : ℝ)^j := Finset.sum_le_sum (fun j _ => hband j) + _ = M*2^n*(∑ j ∈ J, (1/2 : ℝ)^j) := by rw [Finset.mul_sum] + _ ≤ M*2^n*2 := mul_le_mul_of_nonneg_left (finite_geometric J) (by positivity) + _ = _ := by rw [pow_succ]; ring + +end +end SharpLogRamsey.DyadicTail +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/ClassConditioning.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/ClassConditioning.lean new file mode 100644 index 0000000000000000000000000000000000000000..d859916d1f27257a4f27f13bf0ac2822a28c5d4d --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/ClassConditioning.lean @@ -0,0 +1,139 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Entropy.MarkingTwoEntropy + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped BigOperators Classical +noncomputable section +variable {Ω Γ α ι : Type*} [Fintype Ω] [Fintype Γ] [Fintype α] [Fintype ι] + +omit [Fintype α] [Fintype ι] in +def Law.onContextEvent (p : Law Ω) (θ : Ω→Γ) (E : Finset Γ) + (hE : 0<(p.map θ).event E) : Law Ω where + mass x := if θ x∈E then p.mass x/(p.map θ).event E else 0 + nonneg x := by + split_ifs + · exact div_nonneg (p.nonneg x) (le_of_lt hE) + · exact le_refl 0 + total := by + simp only [←sum_filter,←sum_div] + change p.event (univ.filter (fun x=>θ x∈E))/(p.map θ).event E=1 + rw [←Law.event_map] + exact div_self (ne_of_gt hE) + +omit [Fintype α] [Fintype ι] in +lemma Law.onContextEvent_map_mass (p : Law Ω) (θ : Ω→Γ) (E : Finset Γ) + (hE : 0<(p.map θ).event E) (z : Γ) : + ((p.onContextEvent θ E hE).map θ).mass z = + if z∈E then (p.map θ).mass z/(p.map θ).event E else 0 := by + change (∑ x with θ x=z, if θ x∈E then p.mass x/(p.map θ).event E else 0)=_ + by_cases hz : z∈E + · rw [ite_eq_left hz] + change _=(∑ x with θ x=z,p.mass x)/(p.map θ).event E + rw [sum_div] + apply sum_congr rfl + intro x hx + rw [ite_eq_left (by simpa only [(mem_filter.mp hx).2] using hz)] + · rw [ite_eq_right hz] + apply sum_eq_zero + intro x hx + exact ite_eq_right (by simpa only [(mem_filter.mp hx).2] using hz) + +omit [Fintype α] [Fintype ι] in +lemma Law.onContextEvent_support (p : Law Ω) (θ : Ω→Γ) (E : Finset Γ) + (hE : 0<(p.map θ).event E) (x : Ω) (hx : (p.onContextEvent θ E hE).mass x≠0) : + p.mass x≠0 ∧ θ x∈E := by + change (if θ x∈E then p.mass x/(p.map θ).event E else 0)≠0 at hx + split_ifs at hx with he + · exact ⟨(div_ne_zero_iff.mp hx).1,he⟩ + · exact False.elim (hx rfl) + +omit [Fintype α] [Fintype ι] in + +lemma Law.onContextEvent_cond (p : Law Ω) (θ : Ω→Γ) (E : Finset Γ) + (hE : 0<(p.map θ).event E) (z : Γ) + (hz : ((p.onContextEvent θ E hE).map θ).mass z≠0) : + (p.onContextEvent θ E hE).cond θ z=p.cond θ z := by + have hm := p.onContextEvent_map_mass θ E hE z + have hzE : z∈E := by by_contra hn; rw [hm,ite_eq_right hn] at hz; exact hz rfl + have hp : (p.map θ).mass z≠0 := by + rw [hm,ite_eq_left hzE] at hz + exact (div_ne_zero_iff.mp hz).1 + ext x + rw [Law.cond_mass _ _ _ hz,Law.cond_mass _ _ _ hp,hm,ite_eq_left hzE] + by_cases hx : θ x=z + · simp only [Law.onContextEvent,hx,ite_eq_left hzE,ite_true] + field_simp + · simp only [ite_eq_right hx,zero_div] + +omit [Fintype α] [Fintype ι] in +lemma Law.onContextEvent_domination (p q : Law Ω) (θ : Ω→Γ) (E : Finset Γ) + (hE : 0<(p.map θ).event E) (C : ℝ) + (hC : ∀ x,p.mass x≤C*q.mass x) : + ∀ x,(p.onContextEvent θ E hE).mass x≤(C/(p.map θ).event E)*q.mass x := by + intro x + have hh := div_le_div_of_nonneg_right (hC x) (le_of_lt hE) + change (if θ x∈E then p.mass x/(p.map θ).event E else 0)≤_ + have hh' : p.mass x/(p.map θ).event E≤(C/(p.map θ).event E)*q.mass x := by + calc + _ ≤ (C*q.mass x)/(p.map θ).event E := hh + _ = _ := by ring + split_ifs + · exact hh' + · exact (div_nonneg (p.nonneg x) (le_of_lt hE)).trans hh' + +omit [Fintype α] [Fintype ι] in +lemma Law.onContextEvent_expectation (p : Law Ω) (θ : Ω→Γ) (E : Finset Γ) + (hE : 0<(p.map θ).event E) (g : Γ→ℝ) + (hg : ∀ z,(p.map θ).mass z≠0→0≤g z) : + (∑ z, ((p.onContextEvent θ E hE).map θ).mass z*g z) ≤ + (∑ z,(p.map θ).mass z*g z)/(p.map θ).event E := by + rw [sum_div] + apply sum_le_sum + intro z _ + rw [p.onContextEvent_map_mass θ E hE] + by_cases hz : z∈E + · rw [ite_eq_left hz] + apply le_of_eq + ring + · rw [ite_eq_right hz,zero_mul] + apply div_nonneg _ (le_of_lt hE) + by_cases hp : (p.map θ).mass z=0 + · simp [hp] + · exact mul_nonneg ((p.map θ).nonneg z) (hg z hp) + +theorem selectedDeficit_onContextEvent (p : Law Ω) (θ : Ω→Γ) (E : Finset Γ) + (hE : 0<(p.map θ).event E) (F : Ω→ι→α) (S : Γ→Finset ι) (J : ℝ) + (hδ : ∀ z,(p.map θ).mass z≠0→ + 0≤(S z).card*J-entropy (((p.cond θ z).map F).restrict (S z))) : + selectedDeficit (p.onContextEvent θ E hE) θ F S J≤ + selectedDeficit p θ F S J/(p.map θ).event E := by + have he : selectedDeficit (p.onContextEvent θ E hE) θ F S J= + ∑ z,((p.onContextEvent θ E hE).map θ).mass z* + ((S z).card*J-entropy (((p.cond θ z).map F).restrict (S z))) := by + apply sum_congr rfl + intro z _ + by_cases hz : ((p.onContextEvent θ E hE).map θ).mass z=0 + · simp only [hz,zero_mul] + · rw [p.onContextEvent_cond θ E hE z hz] + rw [he] + exact p.onContextEvent_expectation θ E hE _ hδ + +theorem selectedDeficit_onContextEvent_le (p : Law Ω) (θ : Ω→Γ) (E : Finset Γ) + (hE : 0<(p.map θ).event E) (F : Ω→ι→α) (S : Γ→Finset ι) (J B : ℝ) + (hδ : ∀ z,(p.map θ).mass z≠0→ + 0≤(S z).card*J-entropy (((p.cond θ z).map F).restrict (S z))) + (hB : selectedDeficit p θ F S J≤B) : + selectedDeficit (p.onContextEvent θ E hE) θ F S J≤B/(p.map θ).event E := + (selectedDeficit_onContextEvent p θ E hE F S J hδ).trans + (div_le_div_of_nonneg_right hB hE.le) + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/ClassSelection.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/ClassSelection.lean new file mode 100644 index 0000000000000000000000000000000000000000..bc483ed50cb1cb2be59c9f4c28ef4dca4297754d --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/ClassSelection.lean @@ -0,0 +1,82 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.ClassConditioning + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped BigOperators Classical +noncomputable section +variable {Ω Γ ι κ : Type*} [Fintype Ω] [Fintype Γ] [Fintype κ] [Nonempty κ] + +def classSlots (U : Γ→Finset ι) (colour : Γ→ι→κ) (z : Γ) (c : κ) : Finset ι := + (U z).filter (fun i=>colour z i=c) + +theorem exists_fixed_class (p : Law Ω) (θ : Ω→Γ) (U : Γ→Finset ι) + (colour : Γ→ι→κ) (n : ℕ) + (hcard : ∀ x,p.mass x≠0→Fintype.card κ*n≤(U (θ x)).card) : + ∃ c : κ,1/(Fintype.card κ:ℝ)≤ + (p.map θ).event (univ.filter (fun z=>n≤(classSlots U colour z c).card)) := by + have hex z (hz : (p.map θ).mass z≠0) : + ∃ c : κ,n≤(classSlots U colour z c).card := by + obtain ⟨x,hx,rfl⟩ := p.map_support θ z hz + obtain ⟨c,_,hc⟩ := exists_le_card_fiber_of_mul_le_card_of_maps_to + (s:=U (θ x)) (t:=univ) (f:=colour (θ x)) (n:=n) + (fun _ _=>mem_univ _) univ_nonempty (by simpa using hcard x hx) + exact ⟨c,hc⟩ + let win : Γ→κ := fun z=>if hz : (p.map θ).mass z≠0 then Classical.choose (hex z hz) + else Classical.choice inferInstance + have hw z (hz : (p.map θ).mass z≠0) : n≤(classSlots U colour z (win z)).card := by + simp only [win,dite_eq_left hz] + exact Classical.choose_spec (hex z hz) + have hp : (0:ℝ)n≤(classSlots U colour z c).card), + (fun z=>fixedSubset (classSlots U colour z c) n),hc,?_⟩ + intro z hz + obtain ⟨hs,hn⟩ := fixedSubset_spec (classSlots U colour z c) n (mem_filter.mp hz).2 + refine ⟨hn,hs.trans (filter_subset _ _),?_⟩ + intro i hi + exact (mem_filter.mp (hs hi)).2 + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/ClassStep.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/ClassStep.lean new file mode 100644 index 0000000000000000000000000000000000000000..6c7f96ab595d74a9cb927323344bbf471b00d9f9 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/ClassStep.lean @@ -0,0 +1,68 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Reciprocal.ReciprocalStep +import OAI.Combinatorics.SharpRamsey.Marking.HighRankStep + +namespace OAI + +section +namespace SharpLogRamsey.Marking +open Finset Real Filter Selection Selection.Windows ActualHighRank SourceScales +open scoped Classical BigOperators Topology +noncomputable section +local instance stepFiniteDual {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Fin (d+1)→K)) := + Finite.of_injective ((↑) : Module.Dual K (Fin (d+1)→K)→((Fin (d+1)→K)→K)) DFunLike.coe_injective +local instance stepFiniteDouble {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Module.Dual K (Fin (d+1)→K))) := + Finite.of_injective ((↑) : Module.Dual K (Module.Dual K (Fin (d+1)→K))→(Module.Dual K (Fin (d+1)→K)→K)) DFunLike.coe_injective +local instance stepProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Fin (d+1)→K)) := Fintype.ofFinite _ +local instance stepDualProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Fin (d+1)→K))) := Fintype.ofFinite _ +local instance stepDoubleProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Module.Dual K (Fin (d+1)→K)))) := Fintype.ofFinite _ + +def stepPrefactor (d : ℕ) : ℝ:=max 8000000 (highPrefactor d) + +theorem eventually_class_step (i : ℕ) (η c C C0 : ℝ) + (hη : 0 < η) (hηu : η ≤ 1) (hc : 0 < c) (hC : 0 < C) (hC0 : 0 < C0) : + ∀ᶠ σ : ℝ in atTop, ∀ (q : ℕ) [Fact q.Prime], 3 ≤ q → exp σ=(q:ℝ) → + ∀ (Ω Θ : Type) [Fintype Ω] [Fintype Θ] (m : ℕ) (p : Law Ω) (θ : Ω→Θ) + (F : Ω→Fin m→ProjectivePair (K:=ZMod q) (V:=Fin (i+4)→ZMod q)) + (S : Θ→Fin m→Finset (ProjectivePair (K:=ZMod q) (V:=Fin (i+4)→ZMod q))) + (D J M budget : ℝ) (R : ℕ) (cl : SlotClass (i+3)), + Admissible σ η D R → c*(q:ℝ)*σ^(1+η) ≤ m → (m:ℝ) ≤ C*q*σ^(1+η) → + ((i+3:ℕ):ℝ)*σ ≤ J → 0 ≤ M → M ≤ C0*σ → + (∀ z j,log (S z j).card ≤ J) → + (∀ x,p.mass x≠0→∀ j,F x j∈S (θ x) j) → + (∀ x,p.mass x≠0→∀ j,Incidence.Incident (F x j).1 (F x j).2) → + (∀ x,p.mass x≠0→ScanConsistent ((List.ofFn (F x)).map toScan)) → + (∀ x,p.mass x≠0→∀ j,ValidSlotClass (i+3) (scaleKstar σ η D) (S (θ x) j) cl) → + (∀ z j,((S z j).card:ℝ) ≤ 64*(q:ℝ)^(i+3)) → + (∑ z,(p.map θ).mass z*((m:ℝ)*J-entropy ((p.cond θ z).map F))) ≤ budget → + budget ≤ C0*(m:ℝ)*D*σ^(-beta η) → + (∀ x,p.mass x≠0→∀ W : Submodule (ZMod q) (Fin (i+4)→ZMod q), + ((univ.filter (fun j : Fin m=>covectorTuple (F x) j∈ + orthogonalRectangle Projectivization.rep Projectivization.rep W)).card:ℝ) ≤ M) → + ∃ m' : ℕ, (m:ℝ)/64 ≤ m' ∧ + Nonempty (ContextOutput p F m' (stepPrefactor (i+3)*(q:ℝ)^(i+3)*exp (16*scaleKstar σ η D)) + (D*σ^(-η/3)*(m:ℝ)) 4) := by + filter_upwards [eventually_reciprocal_step i η c C C0 hη hηu hc hC hC0, + eventually_high_step η c C0 hη hc hC0 (i+3) (by omega)] with σ hrec hhigh + intro q _ hq he Ω Θ _ _ m p θ F S D J M budget R cl had hmlo hmhi hJ hM hMup + hSJ hS hf hcon hclass hsize hbudget hbud hocc + cases cl with + | inl cl => + obtain ⟨w,m',_,_,hm,⟨e⟩⟩:=hrec q hq he (Fin (i+4)→ZMod q) + (by simp) Ω Θ m p θ F S D J M budget R cl.1 cl.2 had hmlo hmhi hJ hM hMup + hSJ hS hf hcon hclass hsize hbudget hbud hocc + refine ⟨m',by linarith [show (0:ℝ) ≤ m by positivity],⟨e.mono ?_ (le_refl _) (by norm_num)⟩⟩ + gcongr + exact le_max_left _ _ + | inr cl => + obtain ⟨m',hm,⟨e⟩⟩:=hhigh q he Ω Θ m p θ F S D J budget R cl.1 cl.2 had hmlo + hJ hSJ hS hf hcon hclass hsize hbudget hbud + refine ⟨m',hm,⟨e.mono ?_ (le_refl _) (le_refl _)⟩⟩ + gcongr + exact le_max_right _ _ +end +end SharpLogRamsey.Marking + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/ClassTransport.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/ClassTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..5aa9aea79d78c13a33193881a4f3ed105bfe26d8 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/ClassTransport.lean @@ -0,0 +1,135 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.ActualClassLaw +import OAI.Combinatorics.SharpRamsey.Marking.UniformSupports + +namespace OAI + +section +namespace SharpLogRamsey.ReciprocalBands +open Real + +lemma reflected_integer_band {d r : ℕ} (hr : r≤d+1) {σ K u : ℝ} + (h : IntegerBand r σ K u) : + IntegerBand (d+1-r) σ K (((d:ℝ)+1)*σ-u) := by + unfold IntegerBand at h ⊢ + rw [Nat.cast_sub hr,Nat.cast_add,Nat.cast_one] + convert h using 1 + rw [show ((d:ℝ)+1)*σ-u-((d:ℝ)+1-r)*σ= -(u-r*σ) by ring,abs_neg] + +lemma reflected_open_band {d r : ℕ} (hr : r≤d+2) {σ K u : ℝ} + (h : OpenBand r σ K u) : + OpenBand (d+2-r) σ K (((d:ℝ)+1)*σ-u) := by + unfold OpenBand at h ⊢ + rw [Nat.cast_sub hr,Nat.cast_add,Nat.cast_ofNat] + constructor <;> nlinarith [h.1,h.2] + +end SharpLogRamsey.ReciprocalBands + +namespace SharpLogRamsey.Marking +open Finset Selection ReciprocalBands +open scoped Classical BigOperators +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + +abbrev CovectorPair := Projectivization K (Module.Dual K V) × Projectivization K V + +def covectorTuple {ι : Type*} (F : ι→ProjectivePair (K:=K) (V:=V)) : + ι → (CovectorPair (K:=K) (V:=V)) := fun i => (F i).swap + +def covectorDomain (D : Finset (ProjectivePair (K:=K) (V:=V))) : + Finset (CovectorPair (K:=K) (V:=V)) := D.map (Equiv.prodComm _ _).toEmbedding + +lemma covectorDomain_mem (D : Finset (ProjectivePair (K:=K) (V:=V))) + (f : ProjectivePair (K:=K) (V:=V)) : f.swap ∈covectorDomain D ↔ f∈D := by + simp [covectorDomain] + +lemma covectorDomain_card (D : Finset (ProjectivePair (K:=K) (V:=V))) : + (covectorDomain D).card=D.card := card_map _ + +lemma covectorDomain_first (D : Finset (ProjectivePair (K:=K) (V:=V))) : + (covectorDomain D).image Prod.fst=D.image Prod.snd := by + ext a + simp [covectorDomain] + +lemma covectorDomain_second (D : Finset (ProjectivePair (K:=K) (V:=V))) : + (covectorDomain D).image Prod.snd=D.image Prod.fst := by + ext a + simp [covectorDomain] + +lemma covectorTuple_consistent {N : ℕ} (F : Fin N→ProjectivePair (K:=K) (V:=V)) + [FiniteDimensional K V] + (h : ScanConsistent ((List.ofFn F).map toScan)) : + ∀ (i j : Fin N),icovectorTuple (F x)))=entropy (p.map F) := by + rw [show (fun x=>covectorTuple (F x))=covectorTuple∘F from rfl,←Law.map_map] + apply entropy_map_eq_of_injective + intro f g he + funext i + exact Prod.swap_injective (congrFun he i) + +end +end SharpLogRamsey.Marking + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/CostContraction.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/CostContraction.lean new file mode 100644 index 0000000000000000000000000000000000000000..71d8870ce7f3f76a080bf750941c56441deefce8 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/CostContraction.lean @@ -0,0 +1,124 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Trees.TreeHeight +import OAI.Combinatorics.SharpRamsey.Parameters.BookScales +import OAI.Combinatorics.SharpRamsey.Execution.OutputCost + +namespace OAI + +section +namespace SharpLogRamsey.SourceScales +open Real Filter +open scoped Topology +noncomputable section + +lemma eventually_monomial_le_power (C a b ε : ℝ) (hab : a < b) (hε : 0 < ε) : + ∀ᶠ x : ℝ in atTop, C*x^a ≤ ε*x^b := by + have ht : Tendsto (fun x : ℝ => C*x^(a-b)) atTop (𝓝 0) := by + convert (tendsto_rpow_neg_atTop (sub_pos.mpr hab)).const_mul C using 1 <;> simp + filter_upwards [ht.eventually (gt_mem_nhds hε), eventually_gt_atTop (0:ℝ)] with x hx hx0 + calc + _ = (C*x^(a-b))*x^b := by rw [mul_assoc, ←rpow_add hx0]; congr 2; ring + _ ≤ _ := mul_le_mul_of_nonneg_right hx.le (rpow_nonneg hx0.le _) + +lemma P_upper_D {σ η D : ℝ} {R : ℕ} (hσ : 1 ≤ σ) (hη : 0 < η) + (had : Admissible σ η D R) : scaleP σ η D R ≤ 4*D*σ^(9*beta η) := by + have hb := beta_pos hη + have hpow : 1 ≤ σ^beta η := one_le_rpow hσ hb.le + have hD : 0 ≤ D := (rpow_nonneg (by linarith : 0 ≤ σ) _).trans had.D_lower + have hR : (R:ℝ) ≤ 4*σ^beta η := by linarith [had.R_upper] + calc + _ ≤ (D*σ^(8*beta η))*(4*σ^beta η) := + mul_le_mul_of_nonneg_left hR (by positivity) + _ = _ := by + have hp : σ^(8*beta η)*σ^beta η = σ^(9*beta η) := by + rw [←rpow_add (by linarith : 0 < σ)] + congr 1 + ring + linear_combination (4*D)*hp + +theorem eventually_literal_cost_contraction (η A B C c : ℝ) + (hη : 0 < η) (hA : 0 ≤ A) (hB : 0 ≤ B) (hC : 0 ≤ C) (hc : 0 < c) : + ∀ᶠ σ : ℝ in atTop, ∀ q D P h w k : ℝ, + exp σ = q → 1 ≤ D → 0 ≤ P → P ≤ 4*D*σ^(9*beta η) → + 0 ≤ h → h ≤ σ^beta η → 0 ≤ w → w*D ≤ C*σ^(1+η/2) → + c*q*σ^(1+η) ≤ k → + A*q*P*h*(σ+w*P)+B*w*σ ≤ D*σ^(-η/3)*k := by + have hb := beta_pos hη + have hgap1 : 1+10*beta η < 1+2*η/3 := by unfold beta; linarith + have hgap2 : 1+η/2+19*beta η < 1+2*η/3 := by unfold beta; linarith + have ht := ScaleSelection.eventually_polynomial_exp_neg_rpow_lt + (B*C) (1-η/6) 1 1 (c/3) (by norm_num) (by norm_num) (by positivity) + filter_upwards [eventually_monomial_le_power (4*A) (1+10*beta η) (1+2*η/3) + (c/3) hgap1 (by positivity), + eventually_monomial_le_power (16*A*C) (1+η/2+19*beta η) (1+2*η/3) + (c/3) hgap2 (by positivity), ht, eventually_ge_atTop (1:ℝ)] + with σ h1 h2 h3 hσ q D P h w k hq hD hP hPup hh hhu hw hwD hk + have hσ0 : 0 < σ := by linarith + have hq0 : 0 < q := hq ▸ exp_pos _ + have hD0 : 0 < D := by linarith + have hw' : w ≤ C*σ^(1+η/2) := by nlinarith + have hf1 : A*q*P*h*σ ≤ (4*A)*σ^(1+10*beta η)*q*D := by + calc + _ ≤ A*q*(4*D*σ^(9*beta η))*(σ^beta η)*σ := by gcongr + _ = _ := by + have hp : σ^(9*beta η)*σ^beta η*σ = σ^(1+10*beta η) := by + calc + _ = σ^(9*beta η+beta η)*σ^(1:ℝ) := by rw [rpow_add hσ0, rpow_one] + _ = _ := by rw [←rpow_add hσ0]; congr 1; ring + linear_combination (A*q*4*D)*hp + have hf2 : A*q*P*h*(w*P) ≤ (16*A*C)*σ^(1+η/2+19*beta η)*q*D := by + calc + _ ≤ A*q*(4*D*σ^(9*beta η))*(σ^beta η)*(w*(4*D*σ^(9*beta η))) := by gcongr + _ = (16*A*q*D)*(w*D)*(σ^(9*beta η)*σ^beta η*σ^(9*beta η)) := by ring + _ ≤ (16*A*q*D)*(C*σ^(1+η/2))*(σ^(9*beta η)*σ^beta η*σ^(9*beta η)) := by gcongr + _ = _ := by + have hp : σ^(1+η/2)*(σ^(9*beta η)*σ^beta η*σ^(9*beta η)) = + σ^(1+η/2+19*beta η) := by + rw [←rpow_add hσ0, ←rpow_add hσ0, ←rpow_add hσ0] + congr 1 + ring + linear_combination (16*A*q*D*C)*hp + have hf3 : B*w*σ ≤ (c/3)*σ^(1+2*η/3)*q*D := by + have he3 : B*C*σ^(1-η/6)*exp (-σ) ≤ c/3 := by + simpa only [rpow_one, one_mul, neg_one_mul] using h3.le + have h31 : B*C*σ^(1-η/6) ≤ (c/3)*q := by + have hh := mul_le_mul_of_nonneg_right he3 (exp_nonneg σ) + rw [mul_assoc (B*C*σ^(1-η/6)), ←exp_add, neg_add_cancel, exp_zero, mul_one] at hh + simpa only [hq] using hh + have h32 := mul_le_mul_of_nonneg_right h31 (rpow_nonneg hσ0.le (1+2*η/3)) + have he : σ^(1-η/6)*σ^(1+2*η/3) = σ^(2+η/2) := by + rw [←rpow_add hσ0] + congr 1 + ring + rw [mul_assoc (B*C), he] at h32 + calc + _ ≤ B*(C*σ^(1+η/2))*σ := + mul_le_mul (mul_le_mul_of_nonneg_left hw' hB) le_rfl hσ0.le + (mul_nonneg hB (mul_nonneg hC (rpow_nonneg hσ0.le _))) + _ = B*C*σ^(2+η/2) := by + have hp : σ^(1+η/2)*σ = σ^(2+η/2) := by + calc + _ = σ^(1+η/2)*σ^(1:ℝ) := by rw [rpow_one] + _ = _ := by rw [←rpow_add hσ0]; congr 1; ring + linear_combination (B*C)*hp + _ ≤ (c/3)*q*σ^(1+2*η/3) := h32 + _ ≤ (c/3)*σ^(1+2*η/3)*q*D := by + nlinarith [mul_le_mul_of_nonneg_left hD + (by positivity : 0 ≤ (c/3)*q*σ^(1+2*η/3))] + have h1' := mul_le_mul_of_nonneg_right h1 (mul_nonneg hq0.le hD0.le) + have h2' := mul_le_mul_of_nonneg_right h2 (mul_nonneg hq0.le hD0.le) + have hk' := mul_le_mul_of_nonneg_left hk (mul_nonneg hD0.le (rpow_nonneg hσ0.le (-η/3))) + have he : D*σ^(-η/3)*(c*q*σ^(1+η)) = c*σ^(1+2*η/3)*q*D := by + have hp : σ^(-η/3)*σ^(1+η)=σ^(1+2*η/3) := by + rw [←rpow_add hσ0] + congr 1 + ring + linear_combination (D*c*q)*hp + rw [he] at hk' + nlinarith only [hf1,hf2,hf3,h1',h2',hk'] +end +end SharpLogRamsey.SourceScales + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/ExcessCost.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/ExcessCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..61f47416f1c9229c6bb9d1d08762568545dbe257 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/ExcessCost.lean @@ -0,0 +1,99 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.RootCost + +namespace OAI + +section +namespace SharpLogRamsey.Marking +open Finset Real Selection ActualPivot +open scoped Classical BigOperators +noncomputable section +variable {K V : Type} [Field K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] [Finite K] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] + +omit [FiniteDimensional K V] [Finite K] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma twoMask_log_card {N d : ℕ} (hdim : Module.finrank K V=d+3) : + log (Fintype.card (TwoMask (K:=K) (V:=V) N):ℝ)= + 2*(N:ℝ)*log (3*((d:ℝ)+4)) := by + unfold TwoMask + rw [Fintype.card_prod] + simp only [Fintype.card_fun,Fintype.card_fin,rankMask_card,Subspace.dual_finrank_eq, + hdim,Nat.cast_mul,Nat.cast_pow,Nat.cast_ofNat] + rw [log_mul (by positivity) (by positivity),log_pow] + push_cast + ring_nf + +omit [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma twoExpensive_linear {d : ℕ} (hdim : Module.finrank K V=d+3) + {σ : ℝ} (hlog : log (Nat.card K:ℝ)=σ) (hσ : 1≤σ) : + expensiveBudget K V+expensiveBudget K (Module.Dual K V)≤ + (64*((d:ℝ)+4)^3)*(Nat.card K:ℝ)*σ := by + have hdim' : Module.finrank K V=(d+2)+1:=hdim + have hdual : Module.finrank K (Module.Dual K V)=(d+2)+1 := by + rw [Subspace.dual_finrank_eq,hdim] + have ha:=projective_log_card_add_one hdim' (by rwa [hlog]) + have hb:=projective_log_card_add_one hdual (by rwa [hlog]) + rw [hlog] at ha hb + unfold expensiveBudget + simp only [Subspace.dual_finrank_eq,hdim] + simp only [Points] at * + push_cast at ha hb ⊢ + have hfactor : 0≤32*((d:ℝ)+3+1)^2*(Nat.card K:ℝ):=by positivity + have ha':=mul_le_mul_of_nonneg_left ha hfactor + have hb':=mul_le_mul_of_nonneg_left hb hfactor + nlinarith only [ha',hb'] + +variable {Ω Γ : Type} [Fintype Ω] [Fintype Γ] + +omit [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +theorem excessCost_linear {N d : ℕ} (hdim : Module.finrank K V=d+3) + (p : Law Ω) (C : Ω→Γ) (F : Ω→Fin N→ProjectivePair (K:=K) (V:=V)) + (σ Λ Δ A B Jprev : ℝ) (hlog : log (Nat.card K:ℝ)=σ) (hσ : 1≤σ) + (hΔ : 0≤Δ) (hB : 0≤B) (hC : entropy (p.map C)≤Λ) + (hF : (N:ℝ)*((d+2:ℕ):ℝ)*σ-A*N≤entropy (p.map F)) + (hJ : Jprev-jointJ K (d+2)≤Δ+B) : + excessCost p C F Jprev (jointJ K (d+2))≤ + Λ+(N:ℝ)*(log 64+2*log (3*((d:ℝ)+4))+A+B)+ + (64*((d:ℝ)+4)^3)*(Nat.card K:ℝ)*σ*Δ := by + let E : ℝ:=∑ x,p.mass x*((bothExpensive (twoMask (Nat.card K) (F x))).card:ℝ) + have hE0 : 0≤E:=sum_nonneg (fun x _=>mul_nonneg (p.nonneg x) (Nat.cast_nonneg _)) + have hEN : E≤N := by + calc + _ ≤ ∑ x,p.mass x*(N:ℝ) := by + apply sum_le_sum + intro x _ + apply mul_le_mul_of_nonneg_left _ (p.nonneg x) + exact_mod_cast (show (bothExpensive (twoMask (Nat.card K) (F x))).card≤N by + simpa only [Fintype.card_fin] using card_le_univ (bothExpensive (twoMask (Nat.card K) (F x)))) + _ = _ := by rw [←sum_mul,p.total,one_mul] + have hEE : E≤(64*((d:ℝ)+4)^3)*(Nat.card K:ℝ)*σ := by + calc + _ ≤ ∑ x,p.mass x*(expensiveBudget K V+expensiveBudget K (Module.Dual K V)) := by + exact sum_le_sum (fun x _=>mul_le_mul_of_nonneg_left (two_expensive_bound (F x)) (p.nonneg x)) + _ = _ := by rw [←sum_mul,p.total,one_mul] + _ ≤ _ := twoExpensive_linear hdim hlog hσ + have hJ0 : jointJ K (d+2)=log 64+((d+2:ℕ):ℝ)*σ := by + have hq : (0:ℝ)⟨f.dualPoint,f.point,f.incident⟩ + invFun := fun f=>⟨f.2.1,f.1,f.2.2⟩ + left_inv := fun f=>by cases f; rfl + right_inv := fun f=>by cases f; rfl } + rw [←Nat.card_eq_fintype_card,Nat.card_congr e,Nat.card_sigma] + simp_rw [Incidence.card_incident_points hdim] + simp only [sum_const,card_univ,smul_eq_mul] + rw [←Nat.card_eq_fintype_card,Projectivization.card_of_finrank K (Module.Dual K V) + (Subspace.dual_finrank_eq.trans hdim)] + + def reversedFlagPairs {N : ℕ} (F : Fin N→Flag K V) : + Fin N→Marking.ProjectivePair (K:=K) (V:=V) := fun i=>flagPair (F i.rev) + +omit [FiniteDimensional K V] [Finite K] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] in +lemma reversedFlagPairs_injective {N : ℕ} : + Function.Injective (reversedFlagPairs (K:=K) (V:=V) (N:=N)) := by + intro F G h + funext i + apply flagPair_injective + simpa only [reversedFlagPairs,Fin.rev_rev] using congrFun h i.rev + +variable {Ω Γ : Type*} [Fintype Ω] [Fintype Γ] + +theorem source_marking_upper {N n : ℕ} (hdim : Module.finrank K V=n+3) + (p : Selection.Law Ω) (C : Ω→Γ) (F : Ω→Fin N→Flag K V) + (D : Γ→Fin N→Finset (Flag K V)) (Δ Λ : ℝ) (hΔ : 0≤Δ) + (hcons : ∀ x,p.mass x≠0→ Consistent (F x)) + (hD : ∀ x,p.mass x≠0→∀ i,F x i∈D (C x) i) + (hprev : ∀ c i,Real.log (D c i).card≤Real.log (64*(Nat.card K:ℝ)^(n+2))+Δ) + (hC : Selection.entropy (p.map C)≤Λ) : + Selection.entropy (p.map F) ≤ Λ+ + N*Real.log ((Module.finrank K V+1)*3:ℝ)+N*Real.log (64*(Nat.card K:ℝ)^(n+2))+ + (32*(Module.finrank K V+1)^2*(Nat.card K:ℝ)* + Real.log (Fintype.card (Marking.Points (K:=K) (V:=V))+1:ℝ))*Δ := by + let e : Flag K V ↪ Marking.ProjectivePair (K:=K) (V:=V) := + ⟨flagPair,flagPair_injective⟩ + let F' := fun x=>reversedFlagPairs (F x) + let D' := fun (c : Γ) (i : Fin N)=>(D c i.rev).map e + have hc (x : Ω) (hx : p.mass x≠0) : + Marking.ScanConsistent ((List.ofFn (F' x)).map Marking.toScan) := by + have h := Marking.backwardScan_consistent (F x) (hcons x hx) + simpa only [List.map_ofFn,F',reversedFlagPairs,flagPair,Marking.toScan, + Marking.backwardScan,Function.comp_def] using h + have hi (x : Ω) (_hx : p.mass x≠0) (i : Fin N) : + Incidence.Incident (F' x i).1 (F' x i).2 := (F x i.rev).incident + have hd (x : Ω) (hx : p.mass x≠0) (i : Fin N) : F' x i∈D' (C x) i := + mem_map.mpr ⟨F x i.rev,hD x hx i.rev,rfl⟩ + have hp (c : Γ) (i : Fin N) : Real.log (D' c i).card≤ + Real.log (64*(Nat.card K:ℝ)^(n+2))+Δ := by + simpa only [D',card_map] using hprev c i.rev + have H := Marking.actual_entropy_upper hdim p C F' D' + (Real.log (64*(Nat.card K:ℝ)^(n+2))+Δ) hc hi hd hp + have HE := Marking.expected_expensive_bound p F' + have he : Selection.entropy (p.map F')=Selection.entropy (p.map F) := by + rw [show p.map F'=(p.map F).map reversedFlagPairs from + (Selection.Law.map_map p F reversedFlagPairs).symm] + exact Selection.entropy_map_eq_of_injective _ _ reversedFlagPairs_injective + rw [he] at H + have ht := mul_le_mul_of_nonneg_right HE hΔ + linarith + +theorem described_selection_bound [Nonempty (Flag K V)] {N ℓ n : ℕ} + (hdim : Module.finrank K V=n+3) (hℓ : ℓ≤N) + (p : Selection.Law ((Fin N→Flag K V)×(Fin ℓ→Flag K V))) + (reverse : (Fin ℓ→Flag K V)→(Fin ℓ→Flag K V)) + (C : ((Fin N→Flag K V)×(Fin ℓ→Flag K V))→Γ) + (D : Γ→Fin ℓ→Finset (Flag K V)) (Δ Λ dom : ℝ) (hΔ : 0≤Δ) (hdom0 : 0 D if i∈badIndices p e own c J D a f then (1:ℝ) else 0) + (by intros; split_ifs <;> norm_num) (by + intro b x f y + simp only [badIndices_update_self p e own hown c J D a b x y f]) + simpa only [sum_boole,filter_mem_eq_inter,univ_inter,Nat.cast_sum] using hh + +omit [Fintype X] in + +theorem badIndices_card (p : Law (ι→β)) (e : B×X ↪ ι) (own : ι→Option B) + (c : ι→ι→NNReal) (J D a : ℝ) (hD : 0 J-entropy (p.marginal i) + let I := fun i => (maximumInformation p i (otherRepresentatives e own f i):ℝ) + let C := fun i => (maximumCharge c i (otherRepresentatives e own f i):ℝ) + have hδ (i : ι) : 0≤δ i := sub_nonneg.mpr (hJ i) + have hI (i : ι) : 0≤I i := NNReal.coe_nonneg _ + have hC (i : ι) : 0≤C i := NNReal.coe_nonneg _ + have hcost (i : ι) : 0≤δ i/D+I i/a+C i/a := + add_nonneg (add_nonneg (div_nonneg (hδ i) hD.le) (div_nonneg (hI i) ha.le)) + (div_nonneg (hC i) ha.le) + have hib (i : ι) (hi : i∈badIndices p e own c J D a f) : + 1≤δ i/D+I i/a+C i/a := by + rcases (mem_filter.mp hi).2 with hd | ⟨j,hj,hh⟩ + · have hh : 1≤δ i/D := (le_div_iff₀ hD).mpr (by simpa only [one_mul] using hd.le) + linarith only [hh,div_nonneg (hI i) ha.le,div_nonneg (hC i) ha.le] + · have hi' : (pairInformation p i j:ℝ)≤I i := by + exact_mod_cast (Finset.le_sup (f:=pairInformation p i) hj) + have hc' : (c i j:ℝ)≤C i := by + exact_mod_cast (Finset.le_sup (f:=c i) hj) + have hh' : 1≤(I i+C i)/a := (le_div_iff₀ ha).mpr (by linarith) + rw [add_div] at hh' + linarith only [hh',div_nonneg (hδ i) hD.le] + calc + _ = ∑ _i∈badIndices p e own c J D a f,(1:ℝ) := by simp + _ ≤ ∑ i∈badIndices p e own c J D a f,(δ i/D+I i/a+C i/a) := sum_le_sum hib + _ ≤ ∑ i,(δ i/D+I i/a+C i/a) := + sum_le_sum_of_subset_of_nonneg (subset_univ _) (fun i _ _ => hcost i) + _ = (∑ i,δ i)/D+(∑ i,I i)/a+(∑ i,C i)/a := by + simp only [sum_add_distrib,←sum_div] + _ ≤ _ := add_le_add (add_le_add + (div_le_div_of_nonneg_right (marginal_deficit_sum p J) hD.le) le_rfl) le_rfl + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/GoodRealization.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/GoodRealization.lean new file mode 100644 index 0000000000000000000000000000000000000000..f0460d366b38c7ad46a949f4e347d3796f3849ae --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/GoodRealization.lean @@ -0,0 +1,130 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Selection.LiveRealization +import OAI.Combinatorics.SharpRamsey.Windows.GoodPopulation + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical BigOperators +noncomputable section +variable {A B J : Type*} [Fintype A] [Fintype B] [Fintype J] [DecidableEq J] +lemma Law.marginal_fst_map (q : Law (J→A×B)) (i : J) : + (q.marginal i).fst=q.map (fun y=>(y i).1) := by + rw [←Law.map_fst,Law.marginal,Law.map_comp] + rfl +lemma Law.marginal_snd_map (q : Law (J→A×B)) (i : J) : + (q.marginal i).snd=q.map (fun y=>(y i).2) := by + rw [←Law.map_snd,Law.marginal,Law.map_comp] + rfl +lemma Law.map_bad_sum (q : Law A) (f : A→B) (S : Finset B) : + (∑ y,q.mass y*(if f y∈S then (0:ℝ) else 1))=(q.map f).event (univ\S) := by + rw [←q.sum_map f (fun b=>if b∈S then (0:ℝ) else 1)] + have hs : univ\S=univ.filter (fun b=>b∉S) := by ext b; simp + rw [Law.event,hs] + simp only [sum_filter,ite_not,mul_ite,mul_zero,mul_one] +end +end SharpLogRamsey.Selection + +namespace SharpLogRamsey.Selection.Windows +open Finset Real ExposureModel ChronologicalTree FreshExecution TreeDecoder BinaryTree ActualPivot +open scoped Classical BigOperators +noncomputable section +variable {K V Ω Θ : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] + [Fintype Ω] [Fintype Θ] {d : ℕ} {b τ P H : ℝ} +local instance goodBanks : Fintype (Banks (K:=K) (V:=V) b) := inferInstance +local instance goodDec (j : ℕ) : DecidableEq (Fin j) := Classical.decEq _ +variable (w n k : ℕ) (p : Law Ω) (θ : Ω→Θ) + (G : Ω→Slot w (n+k)→Projectivization K (Module.Dual K V)×Projectivization K V) (t : Fin k) + (z : (model w n k p θ G t).FreshHistory) +local instance goodBlockDec : DecidableEq (Block w) := Classical.decEq _ + +theorem good_population_realization + (hdim : Module.finrank K V=d+3) + (book : Book (K:=K) (V:=V) (Nat.card K) b τ P H (d+3)) + (hb : 0≤b) (hτ : 0<τ) (hτsmall : τ≤1/40000) + (bad : Finset ((model w n k p θ G t).Index z.1)) + (live : Finset (Fin w)) (fallback : Fin w) + (hgood : ∀ i∈live,∀ c,((model w n k p θ G t).representative z (i,c))∉bad) + (GA : (model w n k p θ G t).Index z.1→Finset (Projectivization K (Module.Dual K V))) + (GB : (model w n k p θ G t).Index z.1→Finset (Projectivization K V)) + (MA MB κA κB : (model w n k p θ G t).Index z.1→ℝ) + (X : ∀ i,i∉bad→AuxiliarySupport (((model w n k p θ G t).tupleLaw z.1).marginal i).fst + (GA i) (MA i) (κA i)) + (Y : ∀ i,i∉bad→AuxiliarySupport (((model w n k p θ G t).tupleLaw z.1).marginal i).snd + (GB i) (MB i) (κB i)) + (hMA : ∀ i,0banksLaw (K:=K) (V:=V) b)).mass a* + ∑ ω,e.μ.mass ω*((∑ i∈live,((goodMiddle w n k p θ G t z bad i).card:ℝ))- + (fullOutput (fun y x=>SharpLogRamsey.Incidence.Incident x y) + (fun i=>book.chronoChoose hdim hτ.le hτsmall (e.supports ω i)) + (fun _=>chronoRead b) + (fun i=>List.ofFn (fun j=>e.source ω (goodTarget w n k p θ G t z bad i j))) a + (liveTree live fallback) (univ,univ)).length))≤ + (∑ i∈live,((goodMiddle w n k p θ G t z bad i).card:ℝ))* + treeError (Nat.card K) τ (liveTree live fallback).height ε ε ε δA δB := by + let M:=model w n k p θ G t + let early:=fun i=>M.representative z (i,false) + let late:=fun i=>M.representative z (i,true) + apply book.live_realization hdim hb hτ hτsmall (M.tupleLaw z.1) live fallback + (fun i=>(M.tupleLaw z.1|>.marginal (early i)).fst) + (fun i=>(M.tupleLaw z.1|>.marginal (late i)).snd) + (fun i=>GA (early i)) (fun i=>GB (late i)) + (fun i=>MA (early i)) (fun i=>MB (late i)) (fun i=>κA (early i)) (fun i=>κB (late i)) + (fun i=>X (early i) (hgood i i.property false)) + (fun i=>Y (late i) (hgood i i.property true)) + (fun i _=>hMA (early i)) (fun i _=>hMB (late i)) hprod + (fun i=>(goodMiddle w n k p θ G t z bad i).card) + (fun y i j=>y (goodTarget w n k p θ G t z bad i j)) + (fun y hy i _ j=>hR y hy _) (fun i j=>GA (goodTarget w n k p θ G t z bad i j)) + (fun i j=>GB (goodTarget w n k p θ G t z bad i j)) ε ε ε δA δB hε hε hε + · intro i hi j hj hij + apply hinc _ _ (representative_before w n k p θ G t z i j hij false true) + exact Or.inl ⟨hgood i hi false,representative_other w n k p θ G t z (j,true) (i,false) (by simp)⟩ + · intro i hi + apply hinc _ _ (representatives_straddle w n k p θ G t z i) + exact Or.inl ⟨hgood i hi false,representative_other w n k p θ G t z (i,true) (i,false) (by simp)⟩ + · intro i _ j m _ him + rw [←Law.marginal_fst_map (M.tupleLaw z.1) (goodTarget w n k p θ G t z bad i j)] + apply hinc + · exact target_before_later w n k p θ G t z i m him _ + · exact Or.inl ⟨goodTarget_not_bad w n k p θ G t z bad i j,target_other w n k p θ G t z (m,true) i _⟩ + · intro i _ j m _ hmi + rw [←Law.marginal_snd_map (M.tupleLaw z.1) (goodTarget w n k p θ G t z bad i j)] + apply hinc + · exact earlier_before_target w n k p θ G t z m i hmi _ + · exact Or.inr ⟨goodTarget_not_bad w n k p θ G t z bad i j,target_other w n k p θ G t z (m,false) i _⟩ + · intro i _ j + rw [Law.map_bad_sum,←Law.marginal_fst_map] + exact hbadA _ (goodTarget_not_bad w n k p θ G t z bad i j) + · intro i _ j + rw [Law.map_bad_sum,←Law.marginal_snd_map] + exact hbadB _ (goodTarget_not_bad w n k p θ G t z bad i j) +end +end SharpLogRamsey.Selection.Windows + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/GoodRound.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/GoodRound.lean new file mode 100644 index 0000000000000000000000000000000000000000..f5e2852bd226bc83fec4d14fdc9b94e3d061145c --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/GoodRound.lean @@ -0,0 +1,68 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.GoodIndices + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical BigOperators NNReal +noncomputable section +variable {β B ι : Type*} [Fintype β] [Fintype B] [Fintype ι] [DecidableEq B] [DecidableEq ι] + +def roundBad {m : ℕ} (p : Law (ι→β)) (e : B×Fin m ↪ ι) (own : ι→Option B) + (c : ι→ι→NNReal) (J D a : ℝ) : ℝ := + (∑ f : B→Fin m,((badIndices p e own c J D a f).card:ℝ))/Fintype.card (B→Fin m) + +def roundSelectedBad {m : ℕ} (p : Law (ι→β)) (e : B×Fin m ↪ ι) (own : ι→Option B) + (c : ι→ι→NNReal) (J D a : ℝ) : ℝ := + (∑ f : B→Fin m, + ((freshRepresentatives e f∩badIndices p e own c J D a f).card:ℝ))/Fintype.card (B→Fin m) + +theorem roundBad_le {m : ℕ} (hm : 0 < m) (p : Law (ι→β)) (e : B×Fin m ↪ ι) + (own : ι→Option B) (c : ι→ι→NNReal) (J D a : ℝ) (hD : 0 < D) (ha : 0 < a) + (hJ : ∀ i,entropy (p.marginal i)≤J) : + roundBad p e own c J D a≤tupleDeficit J p/D+roundInformation p e own/a+ + (∑ i,∑ j,(c i j:ℝ))/((m:ℝ)*a) := by + let : Nonempty (Fin m) := ⟨⟨0,hm⟩⟩ + have hm' : (0:ℝ) < m := by exact_mod_cast hm + have hN : (0:ℝ) < Fintype.card (B→Fin m) := by exact_mod_cast Fintype.card_pos + have HC : (∑ f : B→Fin m,∑ i, + (maximumCharge c i (otherRepresentatives e own f i):ℝ))/Fintype.card (B→Fin m)≤ + (∑ i,∑ j,(c i j:ℝ))/(m:ℝ) := by + apply (div_le_div_iff₀ hN hm').mpr + have hh := collision_all_indices e own c + simp only [Fintype.card_fin] at hh + nlinarith only [hh] + calc + _ ≤ (∑ f : B→Fin m,(tupleDeficit J p/D+ + (∑ i,(maximumInformation p i (otherRepresentatives e own f i):ℝ))/a+ + (∑ i,(maximumCharge c i (otherRepresentatives e own f i):ℝ))/a))/ + Fintype.card (B→Fin m) := by + apply div_le_div_of_nonneg_right _ hN.le + exact sum_le_sum (fun f _ => badIndices_card p e own c J D a hD ha hJ f) + _ = tupleDeficit J p/D+roundInformation p e own/a+ + ((∑ f : B→Fin m,∑ i, + (maximumCharge c i (otherRepresentatives e own f i):ℝ))/Fintype.card (B→Fin m))/a := by + simp only [sum_add_distrib,sum_const,card_univ,nsmul_eq_mul,←sum_div,roundInformation] + field_simp + _ ≤ tupleDeficit J p/D+roundInformation p e own/a+ + ((∑ i,∑ j,(c i j:ℝ))/(m:ℝ))/a := + add_le_add le_rfl (div_le_div_of_nonneg_right HC ha.le) + _ = _ := by rw [div_div] + +theorem roundSelectedBad_le {m : ℕ} (p : Law (ι→β)) (e : B×Fin m ↪ ι) + (own : ι→Option B) (hown : ∀ b x,own (e (b,x))=some b) + (c : ι→ι→NNReal) (J D a : ℝ) : + (m:ℝ)*roundSelectedBad p e own c J D a≤roundBad p e own c J D a := by + unfold roundSelectedBad roundBad + rw [←mul_div_assoc] + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) + simpa only [Fintype.card_fin] using selected_bad_absorption p e own hown c J D a + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/GoodRows.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/GoodRows.lean new file mode 100644 index 0000000000000000000000000000000000000000..39e234094b275aedbde55639d5b374c33a1b4157 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/GoodRows.lean @@ -0,0 +1,109 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.HighRankEndpoints +import OAI.Combinatorics.SharpRamsey.Marking.AtomEscape + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset Real +open scoped Classical BigOperators +noncomputable section + +variable {A B X Y : Type*} [Fintype A] [Fintype B] [Fintype X] [Fintype Y] + +lemma Law.event_filter_mean (p : Law X) (P : X→Prop) : + p.event (univ.filter P)=∑ x,p.mass x*(if P x then 1 else 0) := by + simp only [Law.event,sum_filter] + apply sum_congr rfl + intro x _ + split_ifs <;> simp + +lemma Law.onEvent_mean_le_two (p : Law X) (E : Finset X) (hE : (1:ℝ)/2≤p.event E) + (f : X→ℝ) (hf : ∀ x,0≤f x) : + ∑ x : E,(p.onEvent E (by linarith)).mass x*f x≤2*∑ x,p.mass x*f x := by + rw [p.onEvent_mean] + apply (div_le_iff₀ (by linarith : 0mul_nonneg (p.nonneg x) (hf x)) + calc + _ ≤ ∑ x,p.mass x*f x := sum_le_univ_sum_of_nonneg (fun x=>mul_nonneg (p.nonneg x) (hf x)) + _ ≤ _ := by nlinarith + +lemma Law.map_mass_eq_marginal (p : Law X) (f : X→Y) (y : Y) : + (p.map f).mass y=FiniteMarginals.marginal p.mass f y := by + simp only [Law.map,FiniteMarginals.marginal,sum_filter] + +lemma Law.onEvent_map_le_two (p : Law X) (E : Finset X) (hE : (1:ℝ)/2≤p.event E) + (f : X→Y) (y : Y) : + ((p.onEvent E (by linarith)).map (fun x : E=>f x)).mass y≤2*(p.map f).mass y := by + have hh:=p.onEvent_mean_le_two E hE (fun x=>if f x=y then 1 else 0) (by intro x; split_ifs <;> positivity) + simpa only [Law.map,sum_filter,mul_ite,mul_one,mul_zero] using hh + +lemma good_pair_event (p : Law (A×B)) (PA : A→Prop) (PB : B→Prop) (εA εB : ℝ) + (hA : p.fst.event (univ.filter (fun a=>¬PA a))≤εA) + (hB : p.snd.event (univ.filter (fun b=>¬PB b))≤εB) : + 1-εA-εB≤p.event (univ.filter (fun z=>PA z.1∧PB z.2)) := by + have he : 1-p.event (univ.filter (fun z=>PA z.1∧PB z.2)) = + p.event (univ.filter (fun z=>¬(PA z.1∧PB z.2))) := by + simp only [Law.event,sum_filter] + rw [←p.total,←sum_sub_distrib] + apply sum_congr rfl + intro z _ + by_cases h : PA z.1∧PB z.2 <;> simp [h] + have hh:=p.event_not_and (fun z=>PA z.1) (fun z=>PB z.2) + have ha : p.event (univ.filter (fun z=>¬PA z.1))=p.fst.event (univ.filter (fun a=>¬PA a)) := by + have hh:=p.sum_map Prod.fst (fun a=>if ¬PA a then 1 else 0) + rw [Law.map_fst] at hh + simpa only [Law.event,sum_filter,mul_ite,mul_one,mul_zero] using hh.symm + have hb : p.event (univ.filter (fun z=>¬PB z.2))=p.snd.event (univ.filter (fun b=>¬PB b)) := by + have hh:=p.sum_map Prod.snd (fun b=>if ¬PB b then 1 else 0) + rw [Law.map_snd] at hh + simpa only [Law.event,sum_filter,mul_ite,mul_one,mul_zero] using hh.symm + rw [ha,hb] at hh + linarith + +lemma Law.onEvent_map_cap (p : Law X) (E : Finset X) (hE : (1:ℝ)/2≤p.event E) + (f : X→Y) (U : ℝ) (hU : 0≤U) + (hcap : ∀ x∈E,(p.map f).mass (f x)≤U) (y : Y) : + ((p.onEvent E (by linarith)).map (fun x : E=>f x)).mass y≤2*U := by + by_cases hy : ((p.onEvent E (by linarith)).map (fun x : E=>f x)).mass y=0 + · rw [hy]; positivity + obtain ⟨x,hx,he⟩:=(p.onEvent E (by linarith)).map_support (fun x : E=>f x) y hy + have hh:=p.onEvent_map_le_two E hE f y + rw [←he] at hh ⊢ + exact hh.trans (mul_le_mul_of_nonneg_left (hcap x x.property) (by norm_num)) + +theorem high_good_rows (p : Law (A×B)) (MA MB L κ UA UB ε : ℝ) + (hUA : 0≤UA) (hUB : 0≤UB) (hε : ε≤1/4) + (hA : p.fst.event (univ.filter (fun a=>¬highGoodFirst p MA L κ UA a))≤ε) + (hB : p.snd.event (univ.filter (fun b=>¬highGoodSecond p MB L κ UB b))≤ε) : + let E:=univ.filter (fun z : A×B=>highGoodFirst p MA L κ UA z.1∧highGoodSecond p MB L κ UB z.2) + ∃ hE : (1:ℝ)/2≤p.event E, + (∀ a,FiniteMarginals.marginal (p.onEvent E (by linarith)).mass (fun z=>z.val.1) a≤2*UA) ∧ + (∀ b,FiniteMarginals.marginal (p.onEvent E (by linarith)).mass (fun z=>z.val.2) b≤2*UB) ∧ + (∀ f : A×B→ℝ,(∀ z,0≤f z)→ + (∑ z : E,(p.onEvent E (by linarith)).mass z*f z)≤2*∑ z,p.mass z*f z) := by + let E:=univ.filter (fun z : A×B=>highGoodFirst p MA L κ UA z.1∧highGoodSecond p MB L κ UB z.2) + have hE : (1:ℝ)/2≤p.event E := by + have hh:=good_pair_event p _ _ ε ε hA hB + change 1-ε-ε≤p.event E at hh + linarith + refine ⟨hE,?_,?_,fun f hf=>p.onEvent_mean_le_two E hE f hf⟩ + · intro a + rw [←Law.map_mass_eq_marginal] + apply p.onEvent_map_cap E hE Prod.fst UA hUA + intro z hz + rw [Law.map_fst] + exact (mem_filter.mp hz).2.1.2 + · intro b + rw [←Law.map_mass_eq_marginal] + apply p.onEvent_map_cap E hE Prod.snd UB hUB + intro z hz + rw [Law.map_snd] + exact (mem_filter.mp hz).2.2.2 +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/HighGoodHistory.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/HighGoodHistory.lean new file mode 100644 index 0000000000000000000000000000000000000000..35796ffaa13ee3f35a4256aa6dd936bdfb96658f --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/HighGoodHistory.lean @@ -0,0 +1,90 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.AtomEscape +import OAI.Combinatorics.SharpRamsey.Windows.GoodPopulation +import OAI.Combinatorics.SharpRamsey.Exposure.ZeroExposure + +namespace OAI + +section +namespace SharpLogRamsey.Selection.Windows +open Finset Real ExposureModel +open scoped Classical BigOperators +noncomputable section +local instance flat_ActualHighGoodHistory_1 (w : ℕ) : DecidableEq (Block w) := Classical.decEq _ +variable {Ω Θ β : Type} [Fintype Ω] [Fintype Θ] [Fintype β] + +lemma one_goodMiddle_count (n k : ℕ) (p : Law Ω) (θ : Ω→Θ) + (G : Ω→Slot 1 (n+k)→β) (t : Fin k) + (z : (model 1 n k p θ G t).FreshHistory) + (bad : Finset ((model 1 n k p θ G t).Index z.1)) : + 2*(n+k)≤(goodMiddle 1 n k p θ G t z bad 0).card+bad.card := by + have h:=goodPopulation_predeletion 1 n k p θ G t z bad ∅ + simpa using h + +theorem high_good_history_half (n k : ℕ) (hn : 0(model 1 n k p θ G t).representative z (0,false)∉bad z ∧ + ((2*(n+k):ℕ):ℝ)/2≤(goodMiddle 1 n k p θ G t z (bad z) 0).card)) := by + let M:=model 1 n k p θ G t + let μ:=M.freshLaw hp + let N : ℕ:=2*(n+k) + let f:=fun z : M.FreshHistory=>((bad z).card:ℝ) + let g:=fun z : M.FreshHistory=>((M.freshSelected z∩bad z).card:ℝ) + have hn0 : (0:ℝ)Nat.cast_nonneg _) (fun z=>Nat.cast_nonneg _) A (A/n) ((N:ℝ)/2) (1/2) + (by positivity) (by norm_num) hb hs' + have hA0 : 0≤A := (sum_nonneg (fun z _=>mul_nonneg (μ.nonneg z) (by positivity))).trans hb + have hleft : (1:ℝ)/2≤1-A/((N:ℝ)/2)-(A/n)/(1/2) := by + have h1 : A/((N:ℝ)/2)≤1/10 := by + apply (div_le_iff₀ (by positivity : 0<(N:ℝ)/2)).mpr + change A≤(N:ℝ)/20 at hA + linarith + have h2 : (A/n)/(1/2)≤2/5 := by + apply (div_le_iff₀ (by norm_num : (0:ℝ)<1/2)).mpr + apply (div_le_iff₀ hn0).mpr + change A≤(N:ℝ)/20 at hA + linarith + linarith + apply (hleft.trans hprob).trans + apply Law.event_mono + intro z hz + obtain ⟨hf,hg⟩:=(mem_filter.mp hz).2 + have hg0 : (M.freshSelected z∩bad z).card=0 := by + have hlt : ((M.freshSelected z∩bad z).card:ℝ)<1 := by dsimp [g] at hg; linarith + have : (M.freshSelected z∩bad z).card<1 := by exact_mod_cast hlt + omega + apply mem_filter.mpr + refine ⟨mem_univ _,?_,?_⟩ + · intro hrep + have hr : M.representative z (0,false)∈M.freshSelected z := by + rw [←representative_selected] + exact mem_map.mpr ⟨(0,false),mem_univ _,rfl⟩ + have hi:=mem_inter.mpr ⟨hr,hrep⟩ + rw [card_eq_zero.mp hg0] at hi + simp at hi + · have hc:=one_goodMiddle_count n k p θ G t z (bad z) + have hc' : (N:ℝ)≤(goodMiddle 1 n k p θ G t z (bad z) 0).card+f z := by + dsimp only [N, f] + exact_mod_cast hc + linarith +end +end SharpLogRamsey.Selection.Windows + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRank.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRank.lean new file mode 100644 index 0000000000000000000000000000000000000000..b1d11665137db367e33ea699d015b7b7528fbf20 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRank.lean @@ -0,0 +1,430 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.ProjectiveTransport +import OAI.Combinatorics.SharpRamsey.Parameters.EndpointScales + +namespace OAI + +/-! High-rank geometric supports and entropy estimates. -/ + +section +open scoped BigOperators Classical +open Finset +section + +namespace SharpLogRamsey +namespace RichUnion + +noncomputable section + +open Module MvPolynomial + +section LinearAlgebra +variable {K A B C : Type*} [Field K] + [AddCommGroup A] [Module K A] [FiniteDimensional K A] + [AddCommGroup B] [Module K B] [AddCommGroup C] [Module K C] + +theorem rank_le_of_ker_le (f : A →ₗ[K] B) (g : A →ₗ[K] C) + (h : LinearMap.ker f ≤ LinearMap.ker g) : + finrank K (LinearMap.range g) ≤ finrank K (LinearMap.range f) := by + have hf := f.finrank_range_add_finrank_ker + have hg := g.finrank_range_add_finrank_ker + have hk := Submodule.finrank_mono h + omega + +theorem finrank_finset_sup_le {ι : Type*} [FiniteDimensional K B] + (S : Finset ι) (W : ι → Submodule K B) : + finrank K (S.sup W : Submodule K B) ≤ ∑ i ∈ S, finrank K (W i) := by + classical + induction S using Finset.induction_on with + | empty => simp + | @insert i S hi ih => + rw [Finset.sup_insert, Finset.sum_insert hi] + exact (Submodule.finrank_add_le_finrank_add_finrank _ _).trans (Nat.add_le_add_left ih _) + +end LinearAlgebra + +section Evaluation +variable {K : Type*} [Field K] {n : ℕ} + +def evalOn (Z : Finset (Fin n → K)) : MvPolynomial (Fin n) K →ₗ[K] (Z → K) where + toFun p z := MvPolynomial.eval z.1 p + map_add' p q := by ext z; simp + map_smul' a p := by ext z; simp + +@[simp] theorem evalOn_apply (Z : Finset (Fin n → K)) + (p : MvPolynomial (Fin n) K) (z : Z) : + evalOn Z p z = MvPolynomial.eval z.1 p := rfl + +def evalSpace (Z : Finset (Fin n → K)) (m : ℕ) : Submodule K (Z → K) := + (MvPolynomial.restrictDegree (Fin n) K m).map (evalOn Z) + +def diagonal (Z : Finset (Fin n → K)) (e : Fin n →₀ ℕ) : (Z → K) →ₗ[K] (Z → K) where + toFun v z := (MvPolynomial.eval z.1 (MvPolynomial.monomial e (1 : K))) * v z + map_add' v w := by ext z; simp [mul_add] + map_smul' a v := by ext z; simp [mul_comm, mul_assoc] + +theorem evalSpace_full [Fintype K] (Z : Finset (Fin n → K)) : + evalSpace Z (Fintype.card K - 1) = ⊤ := by + classical + apply top_unique + intro f _ + let g : (Fin n → K) → K := fun v => if hv : v ∈ Z then f ⟨v, hv⟩ else 0 + have hg : g ∈ (MvPolynomial.restrictDegree (Fin n) K (Fintype.card K - 1)).map + (MvPolynomial.evalₗ K (Fin n)) := by + rw [MvPolynomial.map_restrict_dom_evalₗ] + trivial + rcases hg with ⟨p, hp, he⟩ + refine ⟨p, hp, ?_⟩ + ext z + have hz := congrFun he z.1 + simpa [g, z.property] using hz + +theorem evalSpace_box_partition (Z : Finset (Fin n → K)) (a c q : ℕ) + (ha : 0 < a) (hq : 0 < q) (hqc : q ≤ a*c) : + evalSpace Z (q-1) ≤ + Finset.univ.sup (fun b : Fin n → Fin c => + (evalSpace Z (a-1)).map (diagonal Z + (Finsupp.equivFunOnFinite.symm (fun i => a * (b i).val)))) := by + classical + rw [evalSpace, MvPolynomial.restrictDegree, MvPolynomial.restrictSupport_eq_span, + Submodule.map_span] + apply Submodule.span_le.mpr + rintro _ ⟨_, ⟨s, hs, rfl⟩, rfl⟩ + let b : Fin n → Fin c := fun i => ⟨s i / a, by + apply (Nat.div_lt_iff_lt_mul ha).mpr + have hi := hs i + rw [mul_comm] + omega⟩ + let v : Fin n →₀ ℕ := Finsupp.equivFunOnFinite.symm (fun i => a * (b i).val) + let r : Fin n →₀ ℕ := Finsupp.equivFunOnFinite.symm (fun i => s i % a) + have hsr : s = v + r := by + ext i + change s i = a * (s i / a) + s i % a + simpa [Nat.add_comm] using (Nat.mod_add_div (s i) a).symm + have hinc : (evalSpace Z (a-1)).map (diagonal Z v) ≤ + Finset.univ.sup (fun b : Fin n → Fin c => + (evalSpace Z (a-1)).map (diagonal Z + (Finsupp.equivFunOnFinite.symm (fun i => a * (b i).val)))) := + Finset.le_sup (f := fun b : Fin n → Fin c => + (evalSpace Z (a-1)).map (diagonal Z + (Finsupp.equivFunOnFinite.symm (fun i => a * (b i).val)))) (Finset.mem_univ b) + apply hinc + refine Submodule.mem_map.mpr ⟨evalOn Z (MvPolynomial.monomial r 1), ?_, ?_⟩ + · refine Submodule.mem_map.mpr ⟨MvPolynomial.monomial r 1, ?_, rfl⟩ + rw [MvPolynomial.restrictDegree, MvPolynomial.monomial_mem_restrictSupport] + left + intro i + have := Nat.mod_lt (s i) ha + change s i % a ≤ a-1 + omega + · ext z + simp only [diagonal, LinearMap.coe_mk, AddHom.coe_mk, evalOn_apply] + rw [hsr, ← MvPolynomial.eval_mul, MvPolynomial.monomial_mul_monomial] + simp + +theorem card_le_boxes_mul_eval_rank [Fintype K] (Z : Finset (Fin n → K)) + (a c : ℕ) (ha : 0 < a) (hqc : Fintype.card K ≤ a*c) : + Z.card ≤ c^n * finrank K (evalSpace Z (a-1)) := by + classical + let W : (Fin n → Fin c) → Submodule K (Z → K) := fun b => + (evalSpace Z (a-1)).map (diagonal Z + (Finsupp.equivFunOnFinite.symm (fun i => a * (b i).val))) + have htop : (⊤ : Submodule K (Z → K)) ≤ Finset.univ.sup W := by + rw [← evalSpace_full Z] + exact evalSpace_box_partition Z a c (Fintype.card K) ha Fintype.card_pos hqc + have hdim := Submodule.finrank_mono htop + have hsum := finrank_finset_sup_le Finset.univ W + have hle : (∑ b : Fin n → Fin c, finrank K (W b)) ≤ + c^n * finrank K (evalSpace Z (a-1)) := by + calc + _ ≤ ∑ _b : Fin n → Fin c, finrank K (evalSpace Z (a-1)) := + Finset.sum_le_sum (fun b _ => Submodule.finrank_map_le _ _) + _ = _ := by simp + simpa using hdim.trans (hsum.trans hle) + +theorem totalDegree_aeval_linear {r : ℕ} + (φ : Fin n → MvPolynomial (Fin r) K) + (hφ : ∀ i, (φ i).totalDegree ≤ 1) (p : MvPolynomial (Fin n) K) : + (MvPolynomial.aeval φ p).totalDegree ≤ p.totalDegree := by + classical + conv_lhs => rw [p.as_sum] + rw [map_sum] + apply MvPolynomial.totalDegree_finsetSum_le + intro s hs + rw [MvPolynomial.aeval_monomial] + apply (MvPolynomial.totalDegree_mul _ _).trans + simp only [MvPolynomial.algebraMap_eq, MvPolynomial.totalDegree_C, zero_add] + apply (MvPolynomial.totalDegree_finsetProd _ _).trans + calc + ∑ i ∈ s.support, ((φ i) ^ s i).totalDegree + ≤ ∑ i ∈ s.support, s i := by + apply Finset.sum_le_sum + intro i hi + exact (MvPolynomial.totalDegree_pow _ _).trans (by simpa using Nat.mul_le_mul_left (s i) (hφ i)) + _ ≤ p.totalDegree := MvPolynomial.le_totalDegree hs + +def linearCoordinates {r : ℕ} (f : (Fin r → K) →ₗ[K] (Fin n → K)) + (j : Fin n) : MvPolynomial (Fin r) K := + ∑ i : Fin r, MvPolynomial.C (f (Pi.single i 1) j) * MvPolynomial.X i + +theorem totalDegree_linearCoordinates {r : ℕ} + (f : (Fin r → K) →ₗ[K] (Fin n → K)) (j : Fin n) : + (linearCoordinates f j).totalDegree ≤ 1 := by + apply MvPolynomial.totalDegree_finsetSum_le + intro i hi + simpa using MvPolynomial.totalDegree_mul + (MvPolynomial.C (f (Pi.single i 1) j)) (MvPolynomial.X i) + +theorem eval_linearCoordinates {r : ℕ} + (f : (Fin r → K) →ₗ[K] (Fin n → K)) (x : Fin r → K) (j : Fin n) : + MvPolynomial.eval x (linearCoordinates f j) = f x j := by + classical + have hx : x = ∑ i : Fin r, x i • Pi.single i (1 : K) := by + ext j + simp [Pi.single_apply] + simp only [linearCoordinates, map_sum, map_mul, MvPolynomial.eval_C, MvPolynomial.eval_X] + conv_rhs => rw [hx] + simp only [map_sum, map_smul, Finset.sum_apply, Pi.smul_apply, smul_eq_mul] + apply Finset.sum_congr rfl + intro i hi + exact mul_comm _ _ + +theorem eval_aeval_linearCoordinates {r : ℕ} + (f : (Fin r → K) →ₗ[K] (Fin n → K)) (x : Fin r → K) + (p : MvPolynomial (Fin n) K) : + MvPolynomial.eval x (MvPolynomial.aeval (linearCoordinates f) p) = + MvPolynomial.eval (f x) p := by + apply MvPolynomial.induction_on p + · intro a + simp + · intro a b ha hb + simp only [map_add, ha, hb] + · intro p i hp + simp only [map_mul, MvPolynomial.aeval_X, MvPolynomial.eval_X, hp, eval_linearCoordinates] + +theorem totalDegree_le_of_restrictDegree (p : MvPolynomial (Fin n) K) (m : ℕ) + (hp : p ∈ MvPolynomial.restrictDegree (Fin n) K m) : + p.totalDegree ≤ n*m := by + classical + rw [MvPolynomial.totalDegree] + apply Finset.sup_le + intro s hs + rw [Finsupp.sum_fintype _ _ (by simp)] + calc + ∑ i : Fin n, s i ≤ ∑ _i : Fin n, m := + Finset.sum_le_sum (fun i _ => (MvPolynomial.mem_restrictDegree _ _ _).mp hp s hs i) + _ = n*m := by simp + +theorem card_roots_mul_le [Fintype K] [DecidableEq K] {r : ℕ} (p : MvPolynomial (Fin r) K) + (hp : p ≠ 0) : + (Finset.univ.filter (fun x : Fin r → K => MvPolynomial.eval x p = 0)).card * + Fintype.card K ≤ p.totalDegree * (Fintype.card K)^r := by + classical + have h := MvPolynomial.schwartz_zippel_totalDegree hp (Finset.univ : Finset K) + simp only [Finset.card_univ] at h + simp at h + have hq : (0 : ℚ≥0) < Fintype.card K := by exact_mod_cast Fintype.card_pos (α := K) + have h' := (div_le_div_iff₀ (pow_pos hq r) hq).mp h + exact_mod_cast h' + +def inSubspace (X : Finset (Fin n → K)) (W : Submodule K (Fin n → K)) : + Finset (Fin n → K) := by + classical + exact X.filter (fun x => x ∈ W) + +@[simp] theorem mem_inSubspace (X : Finset (Fin n → K)) + (W : Submodule K (Fin n → K)) (x : Fin n → K) : + x ∈ inSubspace X W ↔ x ∈ X ∧ x ∈ W := by + classical + simp [inSubspace] + +theorem vanish_on_rich_subspace [Fintype K] + (X : Finset (Fin n → K)) (W : Submodule K (Fin n → K)) (m : ℕ) + (hrich : n*m * Nat.card W < (inSubspace X W).card * Fintype.card K) + (p : MvPolynomial (Fin n) K) (hp : p ∈ MvPolynomial.restrictDegree (Fin n) K m) + (hx : ∀ x ∈ X, MvPolynomial.eval x p = 0) : + ∀ y ∈ W, MvPolynomial.eval y p = 0 := by + classical + let r := finrank K W + let e : (Fin r → K) ≃ₗ[K] W := (Module.finBasis K W).equivFun.symm + let f : (Fin r → K) →ₗ[K] (Fin n → K) := W.subtype.comp e.toLinearMap + let P := MvPolynomial.aeval (linearCoordinates f) p + have hPdeg : P.totalDegree ≤ n*m := + (totalDegree_aeval_linear _ (totalDegree_linearCoordinates f) p).trans + (totalDegree_le_of_restrictDegree p m hp) + have hcard : Nat.card W = Fintype.card K ^ r := by + rw [Nat.card_eq_fintype_card, Module.card_eq_pow_finrank (K := K) (V := W)] + have hcount : (Finset.univ.filter (fun v : Fin r → K => f v ∈ X)).card = + (inSubspace X W).card := by + apply Finset.card_bij (fun v _ => f v) + · intro v hv + exact (mem_inSubspace _ _ _).mpr ⟨(Finset.mem_filter.mp hv).2, (e v).property⟩ + · intro v hv w hw h + exact e.injective (Subtype.ext h) + · intro y hy + rcases (mem_inSubspace _ _ _).mp hy with ⟨hyX, hyW⟩ + refine ⟨e.symm ⟨y, hyW⟩, ?_, ?_⟩ + · apply Finset.mem_filter.mpr + refine ⟨Finset.mem_univ _, ?_⟩ + simpa [f] using hyX + · simp [f] + have hP : P = 0 := by + by_contra hne + have hSZ := card_roots_mul_le P hne + have hsub : Finset.univ.filter (fun v : Fin r → K => f v ∈ X) ⊆ + Finset.univ.filter (fun v : Fin r → K => MvPolynomial.eval v P = 0) := by + intro v hv + refine Finset.mem_filter.mpr ⟨Finset.mem_univ _, ?_⟩ + change MvPolynomial.eval v (MvPolynomial.aeval (linearCoordinates f) p) = 0 + rw [eval_aeval_linearCoordinates] + exact hx (f v) (Finset.mem_filter.mp hv).2 + have hle := (Nat.mul_le_mul_right (Fintype.card K) (Finset.card_le_card hsub)).trans + (hSZ.trans (Nat.mul_le_mul_right _ hPdeg)) + rw [hcount, ← hcard] at hle + exact (not_lt_of_ge hle) hrich + intro y hy + have he : f (e.symm ⟨y, hy⟩) = y := by simp [f] + have hz := eval_aeval_linearCoordinates f (e.symm ⟨y, hy⟩) p + rw [he] at hz + rw [← hz] + change MvPolynomial.eval _ P = 0 + rw [hP, map_zero] + +theorem evalSpace_rank_le_of_rich [Fintype K] + (X Y : Finset (Fin n → K)) (𝓥 : Set (Submodule K (Fin n → K))) (m : ℕ) + (hrich : ∀ W ∈ 𝓥, n*m * Nat.card W < + (inSubspace X W).card * Fintype.card K) + (hcover : ∀ y ∈ Y, ∃ W ∈ 𝓥, y ∈ W) : + finrank K (evalSpace Y m) ≤ X.card := by + classical + let A := MvPolynomial.restrictDegree (Fin n) K m + let f := (evalOn X).domRestrict A + let g := (evalOn Y).domRestrict A + have hker : LinearMap.ker f ≤ LinearMap.ker g := by + intro p hp + rw [LinearMap.mem_ker] at hp ⊢ + ext y + change MvPolynomial.eval y.1 p.1 = 0 + obtain ⟨W, hW, hy⟩ := hcover y.1 y.property + apply vanish_on_rich_subspace X W m (hrich W hW) p.1 p.property _ y.1 hy + intro x hx + exact congrFun hp ⟨x, hx⟩ + have h := rank_le_of_ker_le f g hker + have hf : finrank K (LinearMap.range f) ≤ X.card := by + simpa using Submodule.finrank_le (LinearMap.range f) + apply (le_trans ?_ hf) + rw [show evalSpace Y m = LinearMap.range g from + (LinearMap.range_domRestrict A (evalOn Y)).symm] + exact h + +theorem card_union_le_boxes [Fintype K] + (X Y : Finset (Fin n → K)) (𝓥 : Set (Submodule K (Fin n → K))) + (a c : ℕ) (ha : 0 < a) (hqc : Fintype.card K ≤ a*c) + (hrich : ∀ W ∈ 𝓥, n*(a-1) * Nat.card W < + (inSubspace X W).card * Fintype.card K) + (hcover : ∀ y ∈ Y, ∃ W ∈ 𝓥, y ∈ W) : + Y.card ≤ c^n * X.card := + (card_le_boxes_mul_eval_rank Y a c ha hqc).trans + (Nat.mul_le_mul_left _ (evalSpace_rank_le_of_rich X Y 𝓥 (a-1) hrich hcover)) + +theorem exists_box_parameters (n q : ℕ) (hn : 0 < n) (δ : ℝ) + (hδ : 0 < δ) (hδ1 : δ ≤ 1) : + ∃ a c : ℕ, 0 < a ∧ q ≤ a*c ∧ + (n*(a-1) : ℕ) ≤ δ*q/4 ∧ (c : ℝ) ≤ 5*n/δ := by + let a := ⌊δ*q/(4*n)⌋₊ + 1 + let c := ⌊4*n/δ⌋₊ + 1 + have hnR : (0 : ℝ) < n := by exact_mod_cast hn + have hden : (0 : ℝ) < 4*n := by positivity + have ha : 0 < a := Nat.succ_pos _ + have haR : (0 : ℝ) < a := by exact_mod_cast ha + have hat : δ*q < (4*n)*(a : ℝ) := by + have h := Nat.lt_floor_add_one (δ*q/(4*n)) + have h : δ*q/(4*n) < (a : ℝ) := by simpa [a] using h + nlinarith [(div_lt_iff₀ hden).mp h] + have hct : 4*(n : ℝ) < δ*c := by + have h := Nat.lt_floor_add_one (4*n/δ) + have h : 4*n/δ < (c : ℝ) := by simpa [c] using h + nlinarith [(div_lt_iff₀ hδ).mp h] + have hqc : q ≤ a*c := by + have hmul := mul_lt_mul_of_pos_left hct haR + have h : (q : ℝ) < (a : ℝ)*(c : ℝ) := by nlinarith + exact_mod_cast h.le + have had : (n*(a-1) : ℕ) ≤ δ*q/4 := by + have h := Nat.floor_le (show 0 ≤ δ*(q : ℝ)/(4*n) by positivity) + have := (le_div_iff₀ hden).mp h + simp only [a, Nat.add_sub_cancel, Nat.cast_mul] + nlinarith + have hc : (c : ℝ) ≤ 5*n/δ := by + have h := Nat.floor_le (show 0 ≤ 4*(n : ℝ)/δ by positivity) + have hn1 : (1 : ℝ) ≤ n := by exact_mod_cast hn + simp only [c, Nat.cast_add, Nat.cast_one] + apply (le_div_iff₀ hδ).mpr + have := (le_div_iff₀ hδ).mp h + nlinarith + exact ⟨a, c, ha, hqc, had, hc⟩ + +theorem rich_union_vector [Fintype K] (hn : 0 < n) + (X Y : Finset (Fin n → K)) (𝓥 : Set (Submodule K (Fin n → K))) + (δ : ℝ) (hδ : 0 < δ) (hδ1 : δ ≤ 1) + (hne : ∀ W ∈ 𝓥, W ≠ ⊥) + (hrich : ∀ W ∈ 𝓥, δ*((Nat.card W : ℝ)-1) ≤ (inSubspace X W).card) + (hcover : ∀ y ∈ Y, ∃ W ∈ 𝓥, y ∈ W) : + (Y.card : ℝ) ≤ (5*n/δ)^n * X.card := by + classical + obtain ⟨a, c, ha, hqc, hdeg, hc⟩ := exists_box_parameters n (Fintype.card K) hn δ hδ hδ1 + have hrich' : ∀ W ∈ 𝓥, n*(a-1) * Nat.card W < + (inSubspace X W).card * Fintype.card K := by + intro W hW + have : Nontrivial W := Submodule.nontrivial_iff_ne_bot.mpr (hne W hW) + have hN : (2 : ℝ) ≤ Nat.card W := by + rw [Nat.card_eq_fintype_card] + exact_mod_cast Fintype.one_lt_card (α := W) + have hq : (0 : ℝ) < Fintype.card K := by exact_mod_cast Fintype.card_pos (α := K) + have hlow := hrich W hW + have hmul := mul_le_mul_of_nonneg_right hlow hq.le + have hupper := mul_le_mul_of_nonneg_right hdeg (show (0 : ℝ) ≤ Nat.card W by positivity) + have hstrict : ((n*(a-1) : ℕ) : ℝ) * Nat.card W < + ((inSubspace X W).card : ℝ) * Fintype.card K := by + have hpos : 0 < δ*(Fintype.card K : ℝ) := mul_pos hδ hq + nlinarith + exact_mod_cast hstrict + have h := card_union_le_boxes X Y 𝓥 a c ha hqc hrich' hcover + have hR : (Y.card : ℝ) ≤ (c : ℝ)^n * X.card := by exact_mod_cast h + exact hR.trans (mul_le_mul_of_nonneg_right (pow_le_pow_left₀ (by positivity) hc n) (by positivity)) + +end Evaluation +end +end RichUnion +end SharpLogRamsey + +namespace SharpLogRamsey.RichUnion +noncomputable section +open Module + +section ProjectiveLifts +variable {K : Type*} [Field K] [Fintype K] {n : ℕ} + +def vectorLifts (X : Finset (Projectivization K (Fin n → K))) : Finset (Fin n → K) := by + classical + exact (Finset.univ.filter (fun v : {v : Fin n → K // v ≠ 0} => + Projectivization.mk K v.1 v.2 ∈ X)).map (Function.Embedding.subtype _) + +@[simp] theorem mem_vectorLifts (X : Finset (Projectivization K (Fin n → K))) + (v : Fin n → K) : v ∈ vectorLifts X ↔ + ∃ hv : v ≠ 0, Projectivization.mk K v hv ∈ X := by + classical + simp only [vectorLifts, Finset.mem_map, Finset.mem_filter, Finset.mem_univ, true_and, + Function.Embedding.subtype_apply] + constructor + · rintro ⟨⟨v, hv⟩, hX, rfl⟩ + exact ⟨hv, hX⟩ + · rintro ⟨hv, hX⟩ + exact ⟨⟨v, hv⟩, hX, rfl⟩ + +end ProjectiveLifts +end +end SharpLogRamsey.RichUnion +end +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankBudgets.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankBudgets.lean new file mode 100644 index 0000000000000000000000000000000000000000..cb49ec5acd512e6b45d187478cc6dd16bcb3d338 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankBudgets.lean @@ -0,0 +1,121 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.HighRankExtraction + +namespace OAI + +section +namespace SharpLogRamsey.ActualHighRank +open Finset Real Filter HighRankBudgets +open scoped Topology BigOperators +noncomputable section + +def rawRows (σ η : ℝ) : ℕ := ⌈exp σ*σ^beta η⌉₊ +def rawThreshold (σ η : ℝ) : ℕ := ⌈(rawRows σ η:ℝ)/(10*exp σ)⌉₊ +def richDensity : ℝ := 1/(100*exp (1/2)) +def rawError (σ η D : ℝ) (d : ℕ) : ℝ := + 4365*σ^(-2*beta η)+100*1024^2*exp (2*scaleK σ η D)/exp σ+ + (d*exp (-3*(rawRows σ η:ℝ)/(20*d*exp σ))+exp (1-(rawRows σ η:ℝ)/(10*exp σ)))+ + 4*(rawRows σ η)* (2*σ^(-2000*beta η)/exp σ)+2048*exp (scaleK σ η D)/exp σ + +lemma density_positive : 04300*σ^(-2*beta η)) atTop (𝓝 0) := by + convert (tendsto_rpow_neg_atTop (show 0<2*beta η by positivity)).const_mul 4300 using 1 <;> congr 2 <;> ring_nf + filter_upwards [eventually_ge_atTop (1:ℝ), + ht.eventually (eventually_ge_atTop (10*((d:ℝ)+2))), + hs.eventually (eventually_le_nhds (by norm_num : (0:ℝ)<1/4)), + eventually_exp_K_over_q hη 20480 1 1 (by norm_num) (by norm_num) (by norm_num), + eventually_error hη 5000 (1/8) (by norm_num) (by norm_num) d hd] + with σ hσ hx hs he herr D hD hD' + have hq : 1≤exp σ := one_le_exp (by linarith) + have hx0 : 0≤σ^beta η := by positivity + have hlo : exp σ*σ^beta η≤(rawRows σ η:ℝ) := Nat.le_ceil _ + have hlo' : σ^beta η≤(rawRows σ η:ℝ) := (le_mul_of_one_le_left hx0 hq).trans hlo + have hh : 2*d≤rawRows σ η := by exact_mod_cast (show 2*(d:ℝ)≤(rawRows σ η:ℝ) by linarith) + have hTlo : (rawRows σ η:ℝ)/(10*exp σ)≤rawThreshold σ η := Nat.le_ceil _ + have hThi : (rawThreshold σ η:ℝ)≤(rawRows σ η:ℝ)/(10*exp σ)+1 := + (Nat.ceil_lt_add_one (by positivity)).le + have hT : d+2≤rawThreshold σ η := by + have ht : (d:ℝ)+2≤(rawRows σ η:ℝ)/(10*exp σ) := by + apply (le_div_iff₀ (by positivity : 0<10*exp σ)).mpr + nlinarith [mul_le_mul_of_nonneg_left hx (exp_nonneg σ)] + exact_mod_cast ht.trans hTlo + have hκ : 0 ≤ scaleK σ η D := mul_nonneg ((rpow_nonneg (by linarith) _).trans hD) (by positivity) + have hu := density_small + have hue : richDensity≤2048*exp (scaleK σ η D) := by + have he : 1≤exp (scaleK σ η D) := one_le_exp hκ + linarith + have hescape : 20480*exp (scaleK σ η D)≤exp σ := by + have h:=he D hD' + rw [one_mul] at h + exact ((div_lt_one (exp_pos σ)).mp h).le + exact ⟨hσ,hh,hT,hTlo,hThi,hue,hs,hescape,(rawError_le hσ hη hd).trans (herr D hD').le⟩ +end +end SharpLogRamsey.ActualHighRank + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankChoices.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankChoices.lean new file mode 100644 index 0000000000000000000000000000000000000000..1da5e7ce44f90a78414702b55a2686a530a83851 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankChoices.lean @@ -0,0 +1,100 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Windows.WindowChoices +import OAI.Combinatorics.SharpRamsey.Windows.LogWindow +import OAI.Combinatorics.SharpRamsey.Marking.HighRankOrdered + +namespace OAI + +section +namespace SharpLogRamsey.ActualHighRank +open Real Filter SourceScales Selection.Windows +open scoped Topology +noncomputable section + +theorem eventually_high_window (η c : ℝ) (hη : 0 < η) (hc : 0 < c) : + ∀ᶠ σ : ℝ in atTop, ∀ q D : ℝ, ∀ m : ℕ, + exp σ=q → σ^beta η ≤ D → D ≤ σ^(1-η/2) → c*q*σ^(1+η) ≤ m → + let n:=m/8 + let k:=⌊q*D*σ^(3000*beta η)⌋₊ + 2 ≤ n ∧ 0 < k ∧ k ≤ n ∧ 4*(n+k) ≤ m ∧ + (m:ℝ) ≤ 8*(2*(n+k):ℕ) ∧ (m:ℝ)/64 ≤ ((n+k)/2:ℕ) ∧ + (1/2)*q*D*σ^(3000*beta η) ≤ (k:ℝ) := by + have he : 1-η/2+3000*beta η < 1+η:=by unfold beta;linarith + have hs:=eventually_monomial_le_power 16 (1-η/2+3000*beta η) (1+η) c he hc + have hpow : Tendsto (fun σ : ℝ=>σ^(1+η)) atTop atTop:=tendsto_rpow_atTop (by linarith) + filter_upwards [hs,hpow.eventually_ge_atTop (16/c),eventually_ge_atTop (1:ℝ)] + with σ hsmall hlarge hσ q D m heq hDl hDu hm + have hσ0 : 0 < σ:=by linarith + have hq : 2 ≤ q:=by have hh:=add_one_le_exp σ;rw [heq] at hh;linarith + have hq0 : 0 < q:=by linarith + have hD : 1 ≤ D:=(one_le_rpow hσ (beta_pos hη).le).trans hDl + have hp : 1 ≤ σ^(3000*beta η):=one_le_rpow hσ (by unfold beta;positivity) + have hx : 2 ≤ q*D*σ^(3000*beta η):= + (hq.trans (le_mul_of_one_le_right hq0.le hD)).trans + (le_mul_of_one_le_right (by positivity) hp) + have hmp : 16 ≤ m:=by + have hh:=(div_le_iff₀ hc).mp hlarge + have hh' := mul_le_mul_of_nonneg_left (show (1:ℝ) ≤ q by linarith) + (by positivity : 0 ≤ c*σ^(1+η)) + exact_mod_cast (show (16:ℝ) ≤ m by nlinarith only [hm,hh,hh']) + have hk : (⌊q*D*σ^(3000*beta η)⌋₊:ℝ) ≤ q*D*σ^(3000*beta η):=Nat.floor_le (by positivity) + have hk' : 16*(⌊q*D*σ^(3000*beta η)⌋₊:ℝ) ≤ m:=by + calc + _ ≤ 16*(q*D*σ^(3000*beta η)):=by linarith only [hk] + _ ≤ 16*(q*σ^(1-η/2)*σ^(3000*beta η)):=by gcongr + _ = q*(16*σ^(1-η/2+3000*beta η)):=by rw [mul_assoc q,←rpow_add hσ0];ring + _ ≤ q*(c*σ^(1+η)):=mul_le_mul_of_nonneg_left hsmall hq0.le + _ ≤ _:=by nlinarith only [hm] + have hkNat : 16*⌊q*D*σ^(3000*beta η)⌋₊ ≤ m:=by exact_mod_cast hk' + obtain ⟨_,hkpos,_,hklo,_,_⟩:=rounded_window hx hx le_rfl + dsimp only + refine ⟨by omega,hkpos,by omega,by omega,?_,?_,?_⟩ + · exact_mod_cast (show m ≤ 8*(2*(m/8+⌊q*D*σ^(3000*beta η)⌋₊)) by omega) + · have hh : m ≤ 64*((m/8+⌊q*D*σ^(3000*beta η)⌋₊)/2):=by omega + have hh' : (m:ℝ) ≤ 64*((m/8+⌊q*D*σ^(3000*beta η)⌋₊)/2:ℕ):=by exact_mod_cast hh + linarith + · linarith only [hklo] + +theorem eventually_high_cost (η c : ℝ) (d : ℕ) (hη : 0 < η) (hc : 0 < c) : + ∀ᶠ σ : ℝ in atTop, ∀ q D m : ℝ, + exp σ=q → 1 ≤ D → c*q*σ^(1+η) ≤ m → + 4*(rawRows σ η:ℝ)*(log 2+(d:ℝ)*σ) ≤ D*σ^(-η/3)*m := by + have hgap : beta η+1 < 1+2*η/3:=by unfold beta;linarith + filter_upwards [eventually_monomial_le_power (8*((d:ℝ)+1)) (beta η+1) + (1+2*η/3) c hgap hc,eventually_ge_atTop (1:ℝ)] with σ hs hσ q D m he hD hm + have hσ0 : 0 < σ:=by linarith + have hq0 : 0 < q:=he ▸ exp_pos _ + have hrow : (rawRows σ η:ℝ) ≤ 2*q*σ^beta η:=by + simpa only [rawRows,HighRankBudgets.beta,SourceScales.beta,he] using + (HighRankBudgets.row_size (one_le_exp hσ0.le) (one_le_rpow hσ (beta_pos hη).le)).2 + have hl : log (2:ℝ) ≤ σ:= + (log_le_sub_one_of_pos (by norm_num : (0:ℝ) < 2)).trans (by linarith) + have hlast:=mul_le_mul_of_nonneg_left hm (mul_nonneg (by linarith : 0 ≤ D) + (rpow_nonneg hσ0.le (-η/3))) + have hp : σ^(-η/3)*σ^(1+η)=σ^(1+2*η/3):=by rw [←rpow_add hσ0];congr 1;ring + calc + _ ≤ 4*(2*q*σ^beta η)*(((d:ℝ)+1)*σ):=by gcongr;linarith + _ = (8*((d:ℝ)+1)*σ^(beta η+1))*q:=by rw [rpow_add hσ0,rpow_one];ring + _ ≤ c*σ^(1+2*η/3)*q:=mul_le_mul_of_nonneg_right hs hq0.le + _ ≤ D*(c*σ^(1+2*η/3)*q):=le_mul_of_one_le_left (by positivity) hD + _ = D*σ^(-η/3)*(c*q*σ^(1+η)):=by + linear_combination -(D*c*q)*hp + _ ≤ _:=hlast + +theorem eventually_high_domain (η : ℝ) (d : ℕ) (hη : 0 < η) : + ∀ᶠ σ : ℝ in atTop, ∀ D : ℝ, 0 ≤ D → + ((d:ℝ)+1)*scaleK σ η D ≤ 16*scaleKstar σ η D := by + have ht:=tendsto_rpow_atTop (show 0 < 3*beta η by unfold beta;positivity) + filter_upwards [ht.eventually_ge_atTop (((d:ℝ)+1)/16),eventually_gt_atTop (0:ℝ)] + with σ hs hσ D hD + have hh : (d:ℝ)+1 ≤ 16*σ^(3*beta η):=by linarith + have hp : σ^(3*beta η)*σ^(3*beta η)=σ^(6*beta η):=by rw [←rpow_add hσ];congr 1;ring + unfold scaleK scaleKstar + have hk:=mul_le_mul_of_nonneg_right hh (mul_nonneg hD (rpow_nonneg hσ.le (3*beta η))) + nlinarith only [hk,show 16*D*(σ^(3*beta η)*σ^(3*beta η))=16*D*σ^(6*beta η) by rw [hp]] +end +end SharpLogRamsey.ActualHighRank + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankClass.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankClass.lean new file mode 100644 index 0000000000000000000000000000000000000000..749ee3c83f34158f70d6fea644322a48c205c362 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankClass.lean @@ -0,0 +1,86 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.HighRankReplacement +import OAI.Combinatorics.SharpRamsey.Marking.ClassTransport + +namespace OAI + +section +namespace SharpLogRamsey.Marking +open Finset Real ActualHighRank +open scoped Classical BigOperators +noncomputable section + +lemma card_first_fiber {A B : Type*} [Fintype A] [Fintype B] + (S : Finset (A×B)) (a : A) : + (univ.filter (fun b=>(a,b)∈S)).card=(S.filter (fun z=>z.1=a)).card := by + apply card_bij (fun b _=>(a,b)) + · intro b hb + exact mem_filter.mpr ⟨(mem_filter.mp hb).2,rfl⟩ + · intro a ha b hb h + exact Prod.mk.inj h|>.2 + · intro z hz + have he : (a,z.2)=z := by ext <;> simp only [(mem_filter.mp hz).2] + exact ⟨z.2,mem_filter.mpr ⟨mem_univ _,by rw [he]; exact (mem_filter.mp hz).1⟩,he⟩ + +lemma card_second_fiber {A B : Type*} [Fintype A] [Fintype B] + (S : Finset (A×B)) (b : B) : + (univ.filter (fun a=>(a,b)∈S)).card=(S.filter (fun z=>z.2=b)).card := by + apply card_bij (fun a _=>(a,b)) + · intro a ha + exact mem_filter.mpr ⟨(mem_filter.mp ha).2,rfl⟩ + · intro a ha b hb h + exact Prod.mk.inj h|>.1 + · intro z hz + have he : (z.1,b)=z := by ext <;> simp only [(mem_filter.mp hz).2] + exact ⟨z.1,mem_filter.mpr ⟨mem_univ _,by rw [he]; exact (mem_filter.mp hz).1⟩,he⟩ + +variable {K : Type} [Field K] [Fintype K] {d : ℕ} +local instance flat_ActualHighRankClass_1 : Finite (Module.Dual K (Fin (d+1)→K)) := + Finite.of_injective ((↑) : Module.Dual K (Fin (d+1)→K)→((Fin (d+1)→K)→K)) DFunLike.coe_injective +local instance flat_ActualHighRankClass_2 : Finite (Module.Dual K (Module.Dual K (Fin (d+1)→K))) := + Finite.of_injective ((↑) : Module.Dual K (Module.Dual K (Fin (d+1)→K))→(Module.Dual K (Fin (d+1)→K)→K)) DFunLike.coe_injective +local instance flat_ActualHighRankClass_3 : Fintype (Projectivization K (Fin (d+1)→K)) := Fintype.ofFinite _ +local instance flat_ActualHighRankClass_4 : Fintype (Projectivization K (Module.Dual K (Fin (d+1)→K))) := Fintype.ofFinite _ +local instance flat_ActualHighRankClass_5 : Fintype (Projectivization K (Module.Dual K (Module.Dual K (Fin (d+1)→K)))) := Fintype.ofFinite _ +local notation "A" => Projectivization K (Module.Dual K (Fin (d+1)→K)) +local notation "B" => Projectivization K (Fin (d+1)→K) + +theorem covectorDomain_high {gap : ℝ} (S : Finset (B×A)) (r r' : Fin (d+1)) + (h : ValidSlotClass d gap S (.inr (r,r'))) + (hs : (S.card:ℝ)≤64*(Nat.card K:ℝ)^d) : + 2≤r.val ∧ r.val≤d ∧ d+2≤r.val+r'.val ∧ + Caps (log (Nat.card K)) r.val r'.val (covectorDomain S) := by + obtain ⟨hr,hr',hsum,hA,hB,hfB,hfA⟩:=h + have hrd : r.val≤d := Nat.le_of_lt_succ r.is_lt + have hr'd : r'.val≤d := Nat.le_of_lt_succ r'.is_lt + have hq : (0:ℝ)(a,b)∈covectorDomain S)=univ.filter (fun b=>(b,a)∈S) := by + ext b + simp only [mem_filter,mem_univ,true_and] + exact covectorDomain_mem S (b,a) + rw [he,card_second_fiber,←hexp r'.val hr'd] + exact hfA a + · intro b + have he : univ.filter (fun a=>(a,b)∈covectorDomain S)=univ.filter (fun a=>(b,a)∈S) := by + ext a + simp only [mem_filter,mem_univ,true_and] + exact covectorDomain_mem S (b,a) + rw [he,card_first_fiber,←hexp r.val hrd] + exact hfB b + +end +end SharpLogRamsey.Marking + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankConflict.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankConflict.lean new file mode 100644 index 0000000000000000000000000000000000000000..f4b21a370d996e9cd919e9c203f0d7b3f1f372c7 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankConflict.lean @@ -0,0 +1,68 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.GoodRows +import OAI.Combinatorics.SharpRamsey.Trees.GoodChronology + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset Real FiniteEventBounds +open scoped Classical BigOperators +noncomputable section +variable {X A B : Type*} [Fintype X] [Fintype A] [Fintype B] + +theorem original_forbidden_product (p : Law X) (f : X→A) (g : X→B) (R : A→B→Prop) + (hc : ∀ x,p.mass x≠0→¬R (f x) (g x)) : + (∑ x,p.mass x*∑ a,(p.map f).mass a*indicator (R a (g x)))≤ + 2*mutualInfo (p.map (fun x=>(f x,g x))) := by + let joint:=p.map (fun x=>(f x,g x)) + let E:=univ.filter (fun z : A×B=>R z.1 z.2) + have hzero : joint.event E=0 := by + apply sum_eq_zero + intro z hz + by_contra hh + obtain ⟨x,hx,he⟩:=p.map_support (fun x=>(f x,g x)) z hh + have hr := (mem_filter.mp hz).2 + rw [←he] at hr + exact hc x hx hr + have hf : joint.fst=p.map f := by + rw [←Law.map_fst,Law.map_map] + rfl + have hg : joint.snd=p.map g := by + rw [←Law.map_snd,Law.map_map] + rfl + have hh:=mutualInfo_event_transfer joint E + rw [hzero,add_zero,hf,hg] at hh + have he : ((p.map f).prod (p.map g)).event E= + ∑ x,p.mass x*∑ a,(p.map f).mass a*indicator (R a (g x)) := by + simp only [Law.event,E,sum_filter,Law.prod,Fintype.sum_prod_type] + have hz : ∀ a b,(if R a b then (p.map f).mass a*(p.map g).mass b else 0)= + (p.map g).mass b*((p.map f).mass a*indicator (R a b)) := by + intro a b + by_cases h : R a b <;> simp [indicator,h,mul_comm] + simp only [hz] + rw [sum_comm] + simp only [←mul_sum] + exact p.sum_map g _ + rw [he] at hh + exact hh + +variable {K V ι : Type} [Field K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K V))] [Fintype ι] [DecidableEq ι] + +omit [FiniteDimensional K V] in +theorem high_original_conflict (p : Law (ι→Projectivization K (Module.Dual K V)×Projectivization K V)) + (i j : ι) + (hc : ∀ x,p.mass x≠0→(x i).1.rep (x j).2.rep=0→(x j).1.rep (x i).2.rep=0) : + (∑ x,p.mass x*∑ z,(p.marginal i).mass z* + indicator (z.1.rep (x j).2.rep=0∧(x j).1.rep z.2.rep≠0))≤2*(pairInformation p i j:ℝ) := by + exact original_forbidden_product p (fun x=>x i) (fun x=>x j) + (fun z t=>z.1.rep t.2.rep=0∧t.1.rep z.2.rep≠0) + (fun x hx hh=>hh.2 (hc x hx hh.1)) +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankContext.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankContext.lean new file mode 100644 index 0000000000000000000000000000000000000000..97ae6d5cf8a0dc4af3f104bd8aefc8f5bbff07a4 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankContext.lean @@ -0,0 +1,87 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.HighRankSuccess + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset Real +open scoped Classical BigOperators +noncomputable section +variable {X Y Z : Type*} [Fintype X] [Fintype Y] [Fintype Z] + +lemma Law.prod_map_left (p : Law X) (s : Law Y) (f : X→Z) : + (p.prod s).map (fun z=>f z.1)=p.map f := by + ext a + simp only [Law.map,Law.prod,sum_filter,Fintype.sum_prod_type] + apply sum_congr rfl + intro x _ + by_cases h : f x=a + · simp only [h,ite_true,←mul_sum,s.total,mul_one] + · simp only [h,ite_false,sum_const_zero] + +lemma raw_rows_entropy {F Ω : Type*} [Fintype F] [Fintype Ω] (h : ℕ) + (p : Law Ω) (code : Ω→(Fin h→F)×(Fin h→F)) : + entropy (p.map code)≤2*(h:ℝ)*log (Fintype.card F) := by + have hh:=entropy_le_log_card (p.map code) univ (by simp) + simp only [card_univ,Fintype.card_prod,Fintype.card_fun,Fintype.card_fin, + Nat.cast_mul,Nat.cast_pow] at hh + rw [←pow_two,log_pow,log_pow] at hh + convert hh using 1 + ring + +end +end SharpLogRamsey.Selection + +namespace SharpLogRamsey.ActualHighRank +open Finset Real Selection +open scoped Classical BigOperators +noncomputable section +variable {F Ξ Z : Type*} [Fintype F] [Fintype Ξ] [Fintype Z] + +theorem context_replacement {h ℓ : ℕ} (p : Law Ξ) (E : Finset F) (row : Law E) + (f : Ξ→Fin ℓ→F) (DD : ((Fin h→F)×(Fin h→F))→Finset F) (B : ℝ) + (Q : F→F→Prop) + (hQ : ∀ x,p.mass x≠0→∀ i j,irow)).prod (Law.pi (fun _ : Fin h=>row)) + let μ:=p.prod rows + let code:=fun z : Ξ×((Fin h→E)×(Fin h→E))=> + (fun i=>(z.2.1 i).val,fun i=>(z.2.2 i).val) + let G:=univ.filter (fun z=>((DD (code z)).card:ℝ)≤B ∧ + ∃ e : Fin (ℓ/2)↪o Fin ℓ,∀ i,f z.1 (e i)∈DD (code z)) + (1:ℝ)/2≤μ.event G → + ∃ hG : 0<μ.event G, + let ν:=μ.onEvent G hG + ∃ choose : G→Fin (ℓ/2)↪o Fin ℓ, + (∀ (z : G) i,f z.val.1 (choose z i)∈DD (code z)) ∧ + (∀ z : G,((DD (code z)).card:ℝ)≤B) ∧ + (∀ z : G,ν.mass z≠0→∀ i j,istream z.val.1)).mass a≤2*(p.map stream).mass a) ∧ + entropy (ν.map (fun z=>code z))≤2*(h:ℝ)*log (Fintype.card F) := by + intro rows μ code G hG + have hG0 : 0<μ.event G := by linarith + let ν:=μ.onEvent G hG0 + have hx : ∀ z : G,∃ e : Fin (ℓ/2)↪o Fin ℓ,∀ i,f z.val.1 (e i)∈DD (code z) := + fun z=>(mem_filter.mp z.property).2.2 + choose ch hc using hx + refine ⟨hG0,ch,hc,fun z=>(mem_filter.mp z.property).2.1,?_,?_,?_⟩ + · intro z hz i j hij + have hp : p.mass z.val.1≠0 := by + intro hp + apply hz + change p.mass z.val.1*rows.mass z.val.2/μ.event G=0 + rw [hp,zero_mul,zero_div] + exact hQ z.val.1 hp _ _ ((ch z).strictMono hij) + · intro a + have hh:=μ.onEvent_map_le_two G hG (fun z=>stream z.1) a + rw [Law.prod_map_left] at hh + exact hh + · exact raw_rows_entropy h _ _ + +end +end SharpLogRamsey.ActualHighRank + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankEndpoints.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankEndpoints.lean new file mode 100644 index 0000000000000000000000000000000000000000..685e8a3a20cf0f0441a77504045bd6401083033d --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankEndpoints.lean @@ -0,0 +1,130 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Parameters.EndpointScales + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset Real +open scoped Classical BigOperators +noncomputable section +variable {A B : Type*} [Fintype A] [Fintype B] + +lemma Law.support_card_pos (p : Law A) (S : Finset A) + (hs : ∀ a,a∉S→p.mass a=0) : 0hs a (by simp [he])) + linarith [p.total] + +lemma entropy_snd_fiber_lower (p : Law (A×B)) (S : Finset (A×B)) + (hs : ∀ z,z∉S→p.mass z=0) (T : ℝ) (hT : 0(a,b)∈S)).card:ℝ)≤T) : + entropy p-log T≤entropy p.snd := by + have he : ∑ b,p.snd.mass b*entropy (p.condFst b)≤log T := by + calc + _ ≤ ∑ b,p.snd.mass b*log T := by + apply sum_le_sum + intro b _ + by_cases hb : p.snd.mass b=0 + · simp [hb] + have hsup : ∀ a,a∉univ.filter (fun a=>(a,b)∈S)→(p.condFst b).mass a=0 := by + intro a ha + rw [Law.condFst_mass _ _ hb,hs (a,b) (by simpa using ha),zero_div] + have hp : (0:ℝ)<(univ.filter (fun a=>(a,b)∈S)).card := by + exact_mod_cast (p.condFst b).support_card_pos _ hsup + exact mul_le_mul_of_nonneg_left + ((entropy_le_log_card (p.condFst b) _ hsup).trans ((log_le_log_iff hp hT).2 (hcard b))) + (p.snd.nonneg b) + _ = log T := by rw [←sum_mul,p.snd.total,one_mul] + linarith [entropy_chain p] + +lemma entropy_fst_fiber_lower (p : Law (A×B)) (S : Finset (A×B)) + (hs : ∀ z,z∉S→p.mass z=0) (T : ℝ) (hT : 0(a,b)∈S)).card:ℝ)≤T) : + entropy p-log T≤entropy p.fst := by + have hh:=entropy_snd_fiber_lower p.swap (S.image Prod.swap) (by + rintro ⟨b,a⟩ hz + exact hs (a,b) (fun ha=>hz (mem_image.mpr ⟨(a,b),ha,rfl⟩))) T hT (by + intro a + have he : univ.filter (fun b=>(b,a)∈S.image Prod.swap)=univ.filter (fun b=>(a,b)∈S) := by + ext b + simp only [mem_filter,mem_univ,true_and] + constructor + · intro hb + obtain ⟨⟨x,y⟩,hh,heq⟩:=mem_image.mp hb + have hx : x=a := congrArg Prod.snd heq + have hy : y=b := congrArg Prod.fst heq + simpa only [hx,hy] using hh + · intro hb; exact mem_image.mpr ⟨(a,b),hb,rfl⟩ + rw [he] + exact hcard a) + simpa only [entropy_swap,Law.swap_snd] using hh + +def highGoodFirst (p : Law (A×B)) (M L κ U : ℝ) (a : A) : Prop := + goodFirst p M L κ (1/50) a ∧ p.fst.mass a≤U + +def highGoodSecond (p : Law (A×B)) (M L κ U : ℝ) (b : B) : Prop := + goodSecond p M L κ (1/50) b ∧ p.snd.mass b≤U + +lemma Law.event_not_and (p : Law A) (P Q : A→Prop) : + p.event (univ.filter (fun a=>¬(P a∧Q a)))≤ + p.event (univ.filter (fun a=>¬P a))+p.event (univ.filter (fun a=>¬Q a)) := by + simp only [Law.event,sum_filter,←sum_add_distrib] + apply sum_le_sum + intro a _ + by_cases hp : P a <;> by_cases hq : Q a <;> simp [hp,hq,p.nonneg] + +theorem high_second_upper_mass (p : Law (A×B)) (S : Finset (A×B)) + (DB : Finset B) (hs : ∀ z,z∉S→p.mass z=0) + (hb : ∀ b,b∉DB→p.snd.mass b=0) (T L₀ κ : ℝ) (hT : 0(a,b)∈S)).card:ℝ)≤T) : + p.snd.event (univ.filter (fun b=>exp (κ-L₀)(a,b)∈S)).card:ℝ)≤T) : + p.fst.event (univ.filter (fun a=>exp (κ-L₀)(a,b)∈S)).card:ℝ)≤T) : + p.snd.event (univ.filter (fun b=>¬highGoodSecond p M L κ (exp (κ-L₀)) b))≤ + exp (-κ)+(L-entropy p+S.card*exp (-L))/(κ*(1/50))+ + (L₀+log T-entropy p+DB.card*exp (-L₀))/κ := by + unfold highGoodSecond + convert (p.snd.event_not_and (goodSecond p M L κ (1/50)) (fun b=>p.snd.mass b≤exp (κ-L₀))).trans (add_le_add + (badSecond_mass p S hs DB hb M L κ (1/50) hM hB hκ (by norm_num)) + (by simpa only [not_le] using high_second_upper_mass p S DB hs hb T L₀ κ hT hκ hcard)) using 1 + congr 1 + exact filter_congr_decidable _ _ _ + +theorem high_first_bad (p : Law (A×B)) (S : Finset (A×B)) (DA : Finset A) + (hs : ∀ z,z∉S→p.mass z=0) (ha : ∀ a,a∉DA→p.fst.mass a=0) + (M L L₀ κ T : ℝ) (hM : 0(a,b)∈S)).card:ℝ)≤T) : + p.fst.event (univ.filter (fun a=>¬highGoodFirst p M L κ (exp (κ-L₀)) a))≤ + exp (-κ)+(L-entropy p+S.card*exp (-L))/(κ*(1/50))+ + (L₀+log T-entropy p+DA.card*exp (-L₀))/κ := by + unfold highGoodFirst + convert (p.fst.event_not_and (goodFirst p M L κ (1/50)) (fun a=>p.fst.mass a≤exp (κ-L₀))).trans (add_le_add + (badFirst_mass p S hs DA ha M L κ (1/50) hM hA hκ (by norm_num)) + (by simpa only [not_le] using high_first_upper_mass p S DA hs ha T L₀ κ hT hκ hcard)) using 1 + congr 1 + exact filter_congr_decidable _ _ _ +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankExperiment.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankExperiment.lean new file mode 100644 index 0000000000000000000000000000000000000000..687088c239936e9a96953e16099a1854400ef961 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankExperiment.lean @@ -0,0 +1,67 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Entropy.InformationScales +import OAI.Combinatorics.SharpRamsey.Marking.HighRankStream + +namespace OAI + +section +namespace SharpLogRamsey.Selection.Windows +open Finset Real Filter ExposureModel ActualHighRank HighRankBudgets +open scoped Classical BigOperators Topology +noncomputable section +local instance flat_ActualHighRankExperiment_1 (w : ℕ) : DecidableEq (Block w) := Classical.decEq _ +local instance flat_ActualHighRankExperiment_2 {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Fin (d+1)→K)) := + Finite.of_injective ((↑) : Module.Dual K (Fin (d+1)→K)→((Fin (d+1)→K)→K)) DFunLike.coe_injective +local instance flat_ActualHighRankExperiment_3 {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Fin (d+1)→K)) := Fintype.ofFinite _ +local instance flat_ActualHighRankExperiment_4 {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Fin (d+1)→K))) := Fintype.ofFinite _ + +theorem eventually_high_experiment {η : ℝ} (hη : 0<η) (d : ℕ) (hd : 2≤d) + (C c : ℝ) (hC : 0≤C) (hc : 0rawDomain (h:=rawRows σ η) code r (rawThreshold σ η)) + (highPrefactor d*(Nat.card K:ℝ)^d*exp (((d:ℝ)+1)*scaleK σ η D)) + (4*(rawRows σ η:ℝ)*(log 2+(d:ℝ)*σ))) := by + filter_upwards [eventually_high_stream hη d hd, + SourceScales.eventually_information_bad_small η C c (1/20) hη hC hc (by norm_num), + eventually_ge_atTop (1:ℝ)] with σ he hsmall hσ + intro K Ω Θ _ _ _ _ hlog n k hn hk hkn p θ G S D J budget r r' hDl hDu hJ hr hrd hrr + hS hSJ hf hcon hcap hbudget hb hk0 + have hσ0 : 0<σ := by linarith + have hD : 0embedding 1 (n+k)) (fun _=>owner 1 (n+k)) (fun _=>embedding_owner 1 (n+k)) S hS hSJ hbudget + apply he K Ω Θ hlog n k (by omega) hkn p θ G S D J r r' hDl hDu hJ hr hrd hrr + hS hf hcon hcap t (contextual_positive n k (by omega) p θ G + (fun _=>embedding 1 (n+k)) (fun _=>owner 1 (n+k)) t) + (budget/(D*σ^beta η)+2*budget/((k:ℝ)*(σ^(-2000*beta η)/(Nat.card K:ℝ)))) + · have hh:=hsmall (Nat.card K) D (2*(n+k):ℕ) budget k hq hD (by positivity) hb hk0 + simpa only [div_eq_mul_inv,one_div,one_mul,SourceScales.beta,HighRankBudgets.beta] using hh + · exact hbad + · exact hselected +end +end SharpLogRamsey.Selection.Windows + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankOrdered.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankOrdered.lean new file mode 100644 index 0000000000000000000000000000000000000000..7c24fecccbf5f0e629c9302b528b27824b072174 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankOrdered.lean @@ -0,0 +1,95 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Exposure.StreamTransport +import OAI.Combinatorics.SharpRamsey.Marking.HighRankExperiment +import OAI.Combinatorics.SharpRamsey.Marking.HighRankClass + +namespace OAI + +section +namespace SharpLogRamsey.Marking +open Finset Real Filter Selection Selection.Windows ActualHighRank HighRankBudgets +open scoped Classical BigOperators Topology +noncomputable section +local instance flat_ActualHighRankOrdered_1 {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Fin (d+1)→K)) := + Finite.of_injective ((↑) : Module.Dual K (Fin (d+1)→K)→((Fin (d+1)→K)→K)) DFunLike.coe_injective +local instance flat_ActualHighRankOrdered_2 {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Module.Dual K (Fin (d+1)→K))) := + Finite.of_injective ((↑) : Module.Dual K (Module.Dual K (Fin (d+1)→K))→(Module.Dual K (Fin (d+1)→K)→K)) DFunLike.coe_injective +local instance flat_ActualHighRankOrdered_3 {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Fin (d+1)→K)) := Fintype.ofFinite _ +local instance flat_ActualHighRankOrdered_4 {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Fin (d+1)→K))) := Fintype.ofFinite _ +local instance flat_ActualHighRankOrdered_5 {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Module.Dual K (Fin (d+1)→K)))) := Fintype.ofFinite _ + +theorem eventually_high_ordered {η : ℝ} (hη : 0<η) (d : ℕ) (hd : 2≤d) + (C c : ℝ) (hC : 0≤C) (hc : 0(rawDomain (h:=rawRows σ η) code r.val (rawThreshold σ η)).map + (Equiv.prodComm _ _).toEmbedding) + (highPrefactor d*(Nat.card K:ℝ)^d*exp (((d:ℝ)+1)*scaleK σ η D)) + (4*(rawRows σ η:ℝ)*(log 2+(d:ℝ)*σ))) := by + filter_upwards [eventually_high_experiment hη d hd C c hC hc] with σ he + intro K Ω Θ _ _ _ _ hlog n k hn hk hkn p θ F S D J budget gap r r' hDl hDu hJ + hS hSJ hf hcon hclass hsize hbudget hb hk0 + have hpos : ∃ ω,p.mass ω≠0 := by + by_contra hh + have hz : ∀ ω,p.mass ω=0 := by simpa only [not_exists,not_not] using hh + have hh:=p.total + simp only [hz,sum_const_zero] at hh + norm_num at hh + obtain ⟨ω,hω⟩:=hpos + let i0 : Fin (4*(n+k)):=⟨0,by omega⟩ + obtain ⟨hr,hrd,hrr,_⟩:=covectorDomain_high (S (θ ω) i0) r r' (hclass ω hω i0) (hsize _ _) + let G:=fun ω=>singleTuple (covectorTuple (F ω)) + let T:=fun z (i : Slot 1 (n+k))=>covectorDomain (S z i.2) + have hG : ∀ ω,p.mass ω≠0→∀ i,G ω i∈T (θ ω) i := by + intro ω hω i + exact (covectorDomain_mem _ _).mpr (hS ω hω i.2) + have hT : ∀ z i,log (T z i).card≤J := by + intro z i + simpa only [T,covectorDomain_card] using hSJ z i.2 + have hflag : ∀ ω,p.mass ω≠0→∀ i,(G ω i).1.rep (G ω i).2.rep=0 := by + intro ω hω i + exact covectorTuple_flag (F ω) (hf ω hω) i.2 + have hchron : ∀ ω,p.mass ω≠0→∀ i j,position i congr! + obtain ⟨e⟩:=he K Ω Θ hlog n k hn hk hkn p θ G T D J budget r.val r'.val hDl hDu hJ + hr hrd hrr hG hT hflag hchron hcap hbud hb hk0 + exact ⟨e.transport (Equiv.prodComm _ _) Prod.snd F Fin.val + (fun i=>(single_position i).symm) (fun _ _=>rfl)⟩ +end +end SharpLogRamsey.Marking + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankStep.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankStep.lean new file mode 100644 index 0000000000000000000000000000000000000000..2be76f44ea95b0e6d4cd47eba97b8e34a414c5d1 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankStep.lean @@ -0,0 +1,91 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Exposure.RestrictionGeometry +import OAI.Combinatorics.SharpRamsey.Execution.OutputRebase +import OAI.Combinatorics.SharpRamsey.Marking.HighRankChoices + +namespace OAI + +section +namespace SharpLogRamsey.Marking +open Finset Real Filter Selection Selection.Windows ActualHighRank SourceScales +open scoped Classical BigOperators Topology +noncomputable section +local instance flat_ActualHighRankStep_1 {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Fin (d+1)→K)) := + Finite.of_injective ((↑) : Module.Dual K (Fin (d+1)→K)→((Fin (d+1)→K)→K)) DFunLike.coe_injective +local instance flat_ActualHighRankStep_2 {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Module.Dual K (Fin (d+1)→K))) := + Finite.of_injective ((↑) : Module.Dual K (Module.Dual K (Fin (d+1)→K))→(Module.Dual K (Fin (d+1)→K)→K)) DFunLike.coe_injective +local instance flat_ActualHighRankStep_3 {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Fin (d+1)→K)) := Fintype.ofFinite _ +local instance flat_ActualHighRankStep_4 {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Fin (d+1)→K))) := Fintype.ofFinite _ +local instance flat_ActualHighRankStep_5 {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Module.Dual K (Fin (d+1)→K)))) := Fintype.ofFinite _ + +theorem eventually_high_step (η c C0 : ℝ) (hη : 0 < η) (hc : 0 < c) (hC0 : 0 < C0) + (d : ℕ) (hd : 2 ≤ d) : + ∀ᶠ σ : ℝ in atTop, ∀ (q : ℕ) [Fact q.Prime], exp σ=(q:ℝ) → + ∀ (Ω Θ : Type) [Fintype Ω] [Fintype Θ] (m : ℕ) (p : Law Ω) (θ : Ω→Θ) + (F : Ω→Fin m→ProjectivePair (K:=ZMod q) (V:=Fin (d+1)→ZMod q)) + (S : Θ→Fin m→Finset (ProjectivePair (K:=ZMod q) (V:=Fin (d+1)→ZMod q))) + (D J budget : ℝ) (R : ℕ) (r r' : Fin (d+1)), + Admissible σ η D R → c*(q:ℝ)*σ^(1+η) ≤ m → (d:ℝ)*σ ≤ J → + (∀ z j,log (S z j).card ≤ J) → + (∀ x,p.mass x≠0→∀ j,F x j∈S (θ x) j) → + (∀ x,p.mass x≠0→∀ j,Incidence.Incident (F x j).1 (F x j).2) → + (∀ x,p.mass x≠0→ScanConsistent ((List.ofFn (F x)).map toScan)) → + (∀ x,p.mass x≠0→∀ j,ValidSlotClass d (scaleKstar σ η D) (S (θ x) j) (.inr (r,r'))) → + (∀ z j,((S z j).card:ℝ) ≤ 64*(q:ℝ)^d) → + (∑ z,(p.map θ).mass z*((m:ℝ)*J-entropy ((p.cond θ z).map F))) ≤ budget → + budget ≤ C0*(m:ℝ)*D*σ^(-beta η) → + ∃ m' : ℕ, (m:ℝ)/64 ≤ m' ∧ + Nonempty (ContextOutput p F m' (highPrefactor d*(q:ℝ)^d*exp (16*scaleKstar σ η D)) + (D*σ^(-η/3)*(m:ℝ)) 4) := by + filter_upwards [eventually_high_window η c hη hc, + eventually_high_cost η c d hη hc,eventually_high_domain η d hη, + eventually_high_ordered hη d hd (8*C0) (1/2) (by positivity) (by norm_num), + eventually_ge_atTop (1:ℝ)] with σ hwin hcost hdom hout hσ + intro q _ he Ω Θ _ _ m p θ F S D J budget R r r' had hmlo hJ hSJ hS hf hcon hclass hsize hbudget hb + have hσ0 : 0 < σ:=by linarith + have hD : 1 ≤ D:=(one_le_rpow hσ (beta_pos hη).le).trans had.D_lower + have hqlog : log (Nat.card (ZMod q):ℝ)=σ:=by rw [Nat.card_zmod,←he,log_exp] + let n:=m/8 + let k:=⌊(q:ℝ)*D*σ^(3000*beta η)⌋₊ + obtain ⟨hn,hk,hkn,hwm,hmup,hmret,hklow⟩:=hwin (q:ℝ) D m he had.D_lower had.D_upper hmlo + let T : Θ→Finset (Fin m):=fun _=>prefixSet hwm + let e:=chosenOrder T hwm + let G:=orderedTuple T hwm θ F + let S':=fun z j=>S z (e z j) + have hGS : ∀ z j,log (S' z j).card ≤ J:=fun z j=>hSJ z (e z j) + have hG : ∀ x,p.mass x≠0→∀ j,G x j∈S' (θ x) j:=fun x hx j=>hS x hx (e (θ x) j) + have hgf : ∀ x,p.mass x≠0→∀ j,Incidence.Incident (G x j).1 (G x j).2:= + fun x hx j=>hf x hx (e (θ x) j) + have hgcon : ∀ x,p.mass x≠0→ScanConsistent ((List.ofFn (G x)).map toScan):= + fun x hx=>scanConsistent_ordered (F x) (hcon x hx) (e (θ x)) + have hgclass : ∀ x,p.mass x≠0→∀ j,ValidSlotClass d (scaleKstar σ η D) (S' (θ x) j) + (.inr (r,r')):=fun x hx j=>hclass x hx (e (θ x) j) + have hgsize : ∀ z j,((S' z j).card:ℝ) ≤ 64*(Nat.card (ZMod q):ℝ)^d:=by + intro z j + simpa only [Nat.card_zmod] using hsize z (e z j) + have hgbud : (∑ z,(p.map θ).mass z*((4*(n+k):ℕ)*J- + entropy ((p.cond θ z).map G))) ≤ budget := + (prefix_budget hwm p θ F S J hS hSJ).trans hbudget + have hbb : budget ≤ (8*C0)*(2*(n+k):ℕ)*D*σ^(-beta η) := by + have hh:=mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hmup hC0.le) + (mul_nonneg (by linarith : 0 ≤ D) (rpow_nonneg hσ0.le (-beta η))) + nlinarith only [hb,hh] + obtain ⟨out⟩:=hout (ZMod q) Ω Θ hqlog n k hn hk hkn p θ G S' D J budget + (scaleKstar σ η D) r r' had.D_lower had.D_upper hJ hG hGS hgf hgcon hgclass hgsize + hgbud hbb (by simpa only [Nat.card_zmod,HighRankBudgets.beta,SourceScales.beta,k] using hklow) + have hB : highPrefactor d*(Nat.card (ZMod q):ℝ)^d* + exp (((d:ℝ)+1)*HighRankBudgets.scaleK σ η D) ≤ + highPrefactor d*(q:ℝ)^d*exp (16*scaleKstar σ η D) := by + rw [Nat.card_zmod] + apply mul_le_mul_of_nonneg_left (exp_le_exp.mpr (hdom D (by linarith))) + exact mul_nonneg (highPrefactor_pos d).le (pow_nonneg (Nat.cast_nonneg _) _) + have hfinalcost:=hcost (q:ℝ) D (m:ℝ) he hD hmlo + have out':=out.toContextOutput.mono hB hfinalcost (le_refl 4) + have final:=out'.transport (Equiv.refl _) F (fun z=>e (θ z)) (fun _ _=>rfl) + exact ⟨(n+k)/2,hmret,⟨final⟩⟩ +end +end SharpLogRamsey.Marking + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankStream.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankStream.lean new file mode 100644 index 0000000000000000000000000000000000000000..193f931a75d69af74f0e7eca6e3abe3582bbf037 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankStream.lean @@ -0,0 +1,113 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Exposure.HighRankMixture +import OAI.Combinatorics.SharpRamsey.Learning.HighRankPrepared +import OAI.Combinatorics.SharpRamsey.Marking.HighGoodHistory + +namespace OAI + +section +namespace SharpLogRamsey.Selection.Windows +open Finset Real Filter ExposureModel ActualHighRank HighRankBudgets +open scoped Classical BigOperators Topology +noncomputable section +local instance flat_ActualHighRankStream_1 (w : ℕ) : DecidableEq (Block w) := Classical.decEq _ +local instance flat_ActualHighRankStream_2 {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Fin (d+1)→K)) := + Finite.of_injective ((↑) : Module.Dual K (Fin (d+1)→K)→((Fin (d+1)→K)→K)) DFunLike.coe_injective +local instance flat_ActualHighRankStream_3 {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Fin (d+1)→K)) := Fintype.ofFinite _ +local instance flat_ActualHighRankStream_4 {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Fin (d+1)→K))) := Fintype.ofFinite _ +local instance flat_ActualHighRankStream_5 {K : Type} [Field K] {d : ℕ} : DecidableEq (Projectivization K (Module.Dual K (Fin (d+1)→K)) × Projectivization K (Fin (d+1)→K)) := Classical.decEq _ + +theorem eventually_high_stream {η : ℝ} (hη : 0<η) (d : ℕ) (hd : 2≤d) : + ∀ᶠ σ : ℝ in atTop, ∀ (K Ω Θ : Type) [Field K] [Fintype K] [Fintype Ω] [Fintype Θ], + log (Nat.card K:ℝ)=σ → + ∀ (n k : ℕ), 00) J (D*σ^beta η) a + ∀ A : ℝ, A≤((2*(n+k):ℕ):ℝ)/20 → + (∑ z,(M.freshLaw hp).mass z*((bad z).card:ℝ))≤A → + (n:ℝ)*(∑ z,(M.freshLaw hp).mass z*((M.freshSelected z∩bad z).card:ℝ))≤A → + Nonempty (StreamReplacement p G position ((n+k)/2) + (fun code=>rawDomain (h:=rawRows σ η) code r (rawThreshold σ η)) + (highPrefactor d*(Nat.card K:ℝ)^d*exp (((d:ℝ)+1)*scaleK σ η D)) + (4*(rawRows σ η:ℝ)*(log 2+(d:ℝ)*σ))) := by + filter_upwards [eventually_prepared_high hη d hd] with σ he + intro K Ω Θ _ _ _ _ hlog n k hn hkn p θ G S D J r r' hDl hDu hJ hr hrd hrr hS hf hcon hcap t hp + dsimp only + intro A hA hb hs + let M:=model 1 n k p θ G t + let μ:=M.freshLaw hp + let a:=σ^(-2000*beta η)/(Nat.card K:ℝ) + let bad:=M.freshBad (fun _ _ _=>0) J (D*σ^beta η) a + let E:=univ.filter (fun z=>M.representative z (0,false)∉bad z ∧ + ((2*(n+k):ℕ):ℝ)/2≤(goodMiddle 1 n k p θ G t z (bad z) 0).card) + let H:=E.filter (fun z=>μ.mass z≠0) + have hH : (1:ℝ)/2≤μ.event H := by + rw [Law.event_nonzero_filter] + exact high_good_history_half n k hn hkn p θ G t hp bad A hb hs hA + have hzpos (z : H) : μ.mass z.val≠0 := (mem_filter.mp z.property).2 + have hrep (z : H) : M.representative z.val (0,false)∉bad z.val := + (mem_filter.mp (mem_filter.mp z.property).1).2.1 + let ℓ:=fun z : H=>(goodMiddle 1 n k p θ G t z.val (bad z.val) 0).card + have hℓ (z : H) : n+k≤ℓ z := by + have hh:=(mem_filter.mp (mem_filter.mp z.property).1).2.2 + have he : ((2*(n+k):ℕ):ℝ)/2=(n+k:ℕ) := by push_cast; ring + rw [he] at hh + exact_mod_cast hh + let Q:=fun z : M.FreshHistory=>M.Index z.1→Projectivization K (Module.Dual K (Fin (d+1)→K))×Projectivization K (Fin (d+1)→K) + let q : ∀ z,Law (Q z):=fun z=>M.tupleLaw z.1 + let target:=fun (z : H) (y : Q z.val) (i : Fin (ℓ z))=> + y (goodTarget 1 n k p θ G t z.val (bad z.val) 0 i) + let DD:=fun code=>rawDomain (K:=K) (d:=d) (h:=rawRows σ η) code r (rawThreshold σ η) + let B₀:=highPrefactor d*(Nat.card K:ℝ)^d*exp (((d:ℝ)+1)*scaleK σ η D) + let C₀:=4*(rawRows σ η:ℝ)*(log 2+(d:ℝ)*σ) + have hex (z : H) : Nonempty (Replacement (q z.val) (target z) DD B₀ C₀) := by + apply he K Ω Θ hlog 1 n k p θ G S D J r r' hDl hDu hJ hr hrd hrr hS hf hcon hcap t hp z.val + (hzpos z) 0 (hrep z) + exact (by omega : 0Classical.choice (hex z) + have hrestore : (μ.sigma q).map (fun z=>M.restore z.1.1 z.2)=p.map G := by + apply (M.afterDraw hp).restored_map + intro φ + rw [afterDraw_preserves,contextual_preserves,Law.sum_map] + let loc:=fun (z : H) (i : Fin (ℓ z))=>M.origin z.val.1 + (goodTarget 1 n k p θ G t z.val (bad z.val) 0 i) + have hloc : ∀ z,StrictMono (fun i=>position (loc z i)) := by + intro z i j hij + exact goodTarget_before 1 n k p θ G t z.val (bad z.val) 0 i j hij + have hval : ∀ z y i,M.restore z.val.1 y (loc z i)=target z y i := by + intro z y i + exact M.restore_origin z.val.1 y _ + have hm : ∀ z,(n+k)/2≤ℓ z/2 := fun z=>Nat.div_le_div_right (hℓ z) + have hcost : ∀ (Y : Type) [Fintype Y] (ν : Law Y) + (msg : Y→((Fin (rawRows σ η)→Projectivization K (Module.Dual K (Fin (d+1)→K))×Projectivization K (Fin (d+1)→K))× + (Fin (rawRows σ η)→Projectivization K (Module.Dual K (Fin (d+1)→K))×Projectivization K (Fin (d+1)→K)))), + entropy (ν.map msg)≤C₀ := by + intro Y _ ν msg + have hh:=raw_entropy (by simp : Module.finrank K (Fin (d+1)→K)=d+1) ν msg + rwa [hlog] at hh + have mix0 := mix_stream_replacement (Γ:= + ((Fin (rawRows σ η)→Projectivization K (Module.Dual K (Fin (d+1)→K))×Projectivization K (Fin (d+1)→K))× + (Fin (rawRows σ η)→Projectivization K (Module.Dual K (Fin (d+1)→K))×Projectivization K (Fin (d+1)→K)))) + p G position μ Q q + have mix1 := mix0 (fun z=>M.restore z.1) hrestore H hH ℓ target loc hloc hval + have mix2 := mix1 ((n+k)/2) hm DD B₀ C₀ + have hh:=mix2 e hcost + exact hh + +end +end SharpLogRamsey.Selection.Windows + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankSuccess.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankSuccess.lean new file mode 100644 index 0000000000000000000000000000000000000000..f72bd4f4d3b15dd02bde858d417f5caaa1f656c3 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/HighRankSuccess.lean @@ -0,0 +1,120 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.HighRankBudgets + +namespace OAI + +section +namespace SharpLogRamsey.ActualHighRank +open Finset Real Filter Selection HighRankBudgets +open scoped Classical BigOperators Topology +noncomputable section +variable {K Ξ : Type} [Field K] [Fintype K] [Fintype Ξ] {d : ℕ} +local instance flat_ActualHighRankSuccess_1 : Finite (Module.Dual K (Fin (d+1)→K)) := + Finite.of_injective ((↑) : Module.Dual K (Fin (d+1)→K)→((Fin (d+1)→K)→K)) DFunLike.coe_injective +local instance flat_ActualHighRankSuccess_2 : Fintype (Projectivization K (Fin (d+1)→K)) := Fintype.ofFinite _ +local instance flat_ActualHighRankSuccess_3 : Fintype (Projectivization K (Module.Dual K (Fin (d+1)→K))) := Fintype.ofFinite _ +local notation "A" => Projectivization K (Module.Dual K (Fin (d+1)→K)) +local notation "B" => Projectivization K (Fin (d+1)→K) +local notation "q" => (Nat.card K:ℝ) + +def rawDomain {h : ℕ} (z : (Fin h→A×B)×(Fin h→A×B)) (r T : ℕ) : Finset (A×B) := + (HighRankSize.domain (fun z : A×B=>z.1.rep) (fun z : A×B=>z.2) z.1 z.2 r T).image Prod.swap + +def highPrefactor (d : ℕ) : ℝ := + 8*(10*((d:ℝ)+1)*1024/richDensity)^(d+1)*1024*(1+2^(d+2)) + +lemma highPrefactor_pos (d : ℕ) : 0(a,b)∈S)).card:ℝ)≤2*exp (((d:ℝ)-r')*σ)) → + (∀ b,((univ.filter (fun a=>(a,b)∈S)).card:ℝ)≤2*exp (((d:ℝ)-r)*σ)) → + ((d:ℝ)*σ-entropy s≤D*σ^beta η) → + (∀ x,p.mass x≠0→∀ i,f x i∈U i) → + (∀ x,p.mass x≠0→∀ i,(f x i).1.rep (f x i).2.rep=0) → + (∀ i,(((U i).image Prod.fst).card:ℝ)≤1024*(Nat.card K:ℝ)^r') → + (∀ i,(((U i).image Prod.snd).card:ℝ)≤1024*(Nat.card K:ℝ)^r) → + (∀ i,((U i).card:ℝ)≤64*(Nat.card K:ℝ)^d) → + (∀ i a,((univ.filter (fun b=>(a,b)∈U i)).card:ℝ)≤2*exp (((d:ℝ)-r')*σ)) → + (∀ i b,((univ.filter (fun a=>(a,b)∈U i)).card:ℝ)≤2*exp (((d:ℝ)-r)*σ)) → + (∀ i,(d:ℝ)*σ-entropy (p.map (fun x=>f x i))≤D*σ^beta η) → + (∀ i,(∑ x,p.mass x*∑ z,s.mass z*FiniteEventBounds.indicator + (z.1.rep (f x i).2.rep=0 ∧ (f x i).1.rep z.2.rep≠0))≤2*σ^(-2000*beta η)/(Nat.card K:ℝ)) → + let E:=univ.filter (fun z=> + highGoodFirst s (1024*(Nat.card K:ℝ)^r') ((d:ℝ)*σ) (scaleK σ η D) + (exp (scaleK σ η D-(r':ℝ)*σ)) z.1 ∧ + highGoodSecond s (1024*(Nat.card K:ℝ)^r) ((d:ℝ)*σ) (scaleK σ η D) + (exp (scaleK σ η D-(r:ℝ)*σ)) z.2) + ∃ hE : (1:ℝ)/2≤ s.event E, + let row:=s.onEvent E (by linarith) + let h:=rawRows σ η + let W:=fun z : (Fin h→E)×(Fin h→E)=>ProductLaw.weight row.mass z.1*ProductLaw.weight row.mass z.2 + let code:=fun z : (Fin h→E)×(Fin h→E)=>(fun i=>(z.1 i).val,fun i=>(z.2 i).val) + let DD:=fun z=>rawDomain (code z) r (rawThreshold σ η) + (1:ℝ)/2≤∑ v∈univ.filter (fun v : Ξ×((Fin h→E)×(Fin h→E))=> + ((DD v.2).card:ℝ)≤highPrefactor d*(Nat.card K:ℝ)^d*exp (((d:ℝ)+1)*scaleK σ η D) ∧ + ∃ e : Fin (ℓ/2)↪o Fin ℓ,∀ i,f v.1 (e i)∈DD v.2), p.mass v.1*W v.2 := by + filter_upwards [eventual_budgets hη d (by omega)] with σ hσ + intro K Ξ _ _ _ hlog ℓ hℓ s S p f U D hDl hDu r r' hr hrd hrank + hs hSA hSB hS hsfA hsfB hsdef hp hinc hUA hUB hU hufA hufB hdef hcon + have hq : 0<(Nat.card K:ℝ) := by exact_mod_cast Nat.card_pos (α:=K) + have heq : exp σ=(Nat.card K:ℝ) := by rw [←hlog,exp_log hq] + obtain ⟨hσ1,hh,hT,hTlo,hThi,huA,hsmall,hescape,herr⟩:=hσ D hDl hDu + rw [heq] at hTlo hThi hescape + have H:=extraction hd hℓ s S p f U σ (beta η) D hσ1 (by unfold beta; positivity) hlog hDl + (rawRows σ η) r r' (rawThreshold σ η) hr hrd hrank hh richDensity + (2*σ^(-2000*beta η)/(Nat.card K:ℝ)) density_positive huA density_small density_scaled hsmall + hs hSA hSB hS hsfA hsfB hsdef hp hinc hUA hUB hU hufA hufB hdef hcon hTlo hThi hT hescape + dsimp only at H ⊢ + obtain ⟨hE,H⟩:=H + refine ⟨hE,?_⟩ + have herr' : 1/2≤1-2*rawError σ η D d-1/4 := by linarith + apply herr'.trans + unfold rawError at herr' ⊢ + rw [heq] + apply H.trans + apply sum_le_sum_of_subset_of_nonneg + · intro v hv + obtain ⟨hc,e,he⟩:=(mem_filter.mp hv).2 + apply mem_filter.mpr + refine ⟨mem_univ _,?_,e,?_⟩ + · rw [←highSize_eq] + rw [rawDomain, card_image_of_injective _ Prod.swap_injective] + convert hc using 1 <;> try rfl + · intro i + apply mem_image.mpr + exact ⟨(f v.1 (e i)).swap,he i,Prod.swap_swap _⟩ + · intro v _ _ + apply mul_nonneg (p.nonneg _) + apply mul_nonneg <;> apply Finset.prod_nonneg <;> intro j hj <;> exact (s.onEvent _ _).nonneg _ +end +end SharpLogRamsey.ActualHighRank + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/MarkingActual.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/MarkingActual.lean new file mode 100644 index 0000000000000000000000000000000000000000..1695d2c02062f5318fe63b363aa52c5e3a557dc6 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/MarkingActual.lean @@ -0,0 +1,262 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.Popular +import OAI.Combinatorics.SharpRamsey.Marking.MarkingMessage + +namespace OAI + +section +namespace SharpLogRamsey.Marking +open scoped Classical BigOperators +open Finset +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K V))] + +def toScan (f : ProjectivePair (K:=K) (V:=V)) : ScanFlag (K:=K) (V:=V) := + (f.2.rep,f.1) + +def pairStep (W : State (K:=K) (V:=V)) (s : Option (ProjectivePair (K:=K) (V:=V))) : + State (K:=K) (V:=V) := replayStep W (s.map toScan) + +def pairReplay : State (K:=K) (V:=V) → List (Option (ProjectivePair (K:=K) (V:=V))) → + State (K:=K) (V:=V) + | W,[] => W + | W,s::ss => pairReplay (pairStep W s) ss + +def pairCode (q : ℝ) : State (K:=K) (V:=V) → List (ProjectivePair (K:=K) (V:=V)) → + List (RankMask (K:=K) (V:=V) × Option (ProjectivePair (K:=K) (V:=V))) + | _,[] => [] + | W,f::fs => + let s := if IsExpensive W q (toScan f) then some f else none + (maskAt q W (toScan f),s)::pairCode q (pairStep W s) fs + +omit [Fintype (Projectivization K (Module.Dual K V))] in +lemma pairCode_length (q : ℝ) (W : State (K:=K) (V:=V)) + (fs : List (ProjectivePair (K:=K) (V:=V))) : (pairCode q W fs).length=fs.length := by + induction fs generalizing W with + | nil => rfl + | cons f fs ih => simp only [pairCode,List.length_cons,ih] + +omit [Fintype (Projectivization K (Module.Dual K V))] in +lemma pairCode_mask_sent (q : ℝ) (W : State (K:=K) (V:=V)) + (fs : List (ProjectivePair (K:=K) (V:=V))) : + (pairCode q W fs).Forall (fun z => z.1.2=.expensive ↔ z.2.isSome) := by + induction fs generalizing W with + | nil => trivial + | cons f fs ih => + simp only [pairCode,List.forall_cons] + constructor + · simp only [maskAt,flagKind_expensive] + split_ifs <;> simp_all + · exact ih _ + +omit [FiniteDimensional K V] [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K V))] in +lemma pairReplay_eq (W : State (K:=K) (V:=V)) + (ss : List (Option (ProjectivePair (K:=K) (V:=V)))) : + pairReplay W ss = replay W (ss.map (Option.map toScan)) := by + induction ss generalizing W with + | nil => rfl + | cons s ss ih => exact ih _ + +omit [Fintype (Projectivization K (Module.Dual K V))] in +lemma pairCode_eq (q : ℝ) (W : State (K:=K) (V:=V)) + (fs : List (ProjectivePair (K:=K) (V:=V))) : + (pairCode q W fs).map (fun z => (z.1,z.2.map toScan)) = + markingCode q W (fs.map toScan) := by + induction fs generalizing W with + | nil => rfl + | cons f fs ih => + simp only [pairCode,List.map_cons,markingCode] + by_cases h : IsExpensive W q (toScan f) + · simp [sentAt,h,pairStep,ih] + · simp [sentAt,h,pairStep,ih] + +omit [Fintype (Projectivization K (Module.Dual K V))] in +lemma pairCode_count (q : ℝ) (W : State (K:=K) (V:=V)) + (fs : List (ProjectivePair (K:=K) (V:=V))) : + ((pairCode q W fs).filter (fun z => z.1.2=.expensive)).length = + (scan q W (fs.map toScan)).1 := by + induction fs generalizing W with + | nil => rfl + | cons f fs ih => + by_cases h : IsExpensive W q (toScan f) + · simp [pairCode,maskAt,flagKind_expensive,scan,h,pairStep,replayStep,ih] + · simp [pairCode,maskAt,flagKind_expensive,scan,h,pairStep,replayStep,ih] + +lemma pairCode_spec (q : ℝ) (hq : q=(Nat.card K:ℝ)) (W : State (K:=K) (V:=V)) + (fs : List (ProjectivePair (K:=K) (V:=V))) + (hcons : ScanConsistent (fs.map toScan)) + (hinc : ∀ f∈fs, Incidence.Incident f.1 f.2) + (hW : ∀ f∈fs, W f.1 ≤ LinearMap.ker f.2.rep) (n : ℕ) (hn : n simp at hn + | cons f fs ih => + have hp := List.pairwise_cons.mp hcons + cases n with + | zero => + simp only [pairCode,List.getElem_cons_zero,List.take_zero,pairReplay,maskAt] + constructor + · simp only [flagKind_expensive] + · intro hc + have he : ¬IsExpensive W q (toScan f) := + fun he => hc ((flagKind_expensive q W (toScan f)).mpr he) + have he' : ¬IsExpensive W (Nat.card K) (f.2.rep,f.1) := by + simpa only [←hq,toScan] using he + simpa only [←hq,maskAt,toScan] using + cheapDomain_membership W f (hinc f (by simp)) (hW f (by simp)) he' + | succ n => + let s := if IsExpensive W q (toScan f) then some f else none + have HW (g : ProjectivePair (K:=K) (V:=V)) (hg : g∈fs) : + pairStep W s g.1 ≤ LinearMap.ker g.2.rep := by + have hw := hW g (by simp [hg]) + by_cases he : IsExpensive W q (toScan f) + · simp only [s,ite_eq_left he,pairStep,Option.map_some,replayStep] + apply update_annihilates_later W (toScan f) (toScan g) hw + exact hp.1 _ (List.mem_map.mpr ⟨g,hg,rfl⟩) + · simpa only [s,ite_eq_right he,pairStep,Option.map_none,replayStep] using hw + have hh := ih (pairStep W s) hp.2 (fun g hg => hinc g (by simp [hg])) HW n (by simpa using hn) + exact hh + +def codeTuple {N : ℕ} (q : ℝ) (F : Fin N → ProjectivePair (K:=K) (V:=V)) + (i : Fin N) : RankMask (K:=K) (V:=V) × Option (ProjectivePair (K:=K) (V:=V)) := + (pairCode q (fun _ => ⊥) (List.ofFn F))[i.val]'(by rw [pairCode_length,List.length_ofFn]; exact i.isLt) + +def tupleMask {N : ℕ} (q : ℝ) (F : Fin N → ProjectivePair (K:=K) (V:=V)) : + Fin N → RankMask (K:=K) (V:=V) := fun i => (codeTuple q F i).1 + +def expensiveMask {N : ℕ} (M : Fin N → RankMask (K:=K) (V:=V)) : Finset (Fin N) := + univ.filter (fun i => (M i).2=.expensive) + +omit [FiniteDimensional K V] [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K V))] in +lemma mem_expensiveMask {N : ℕ} (M : Fin N → RankMask (K:=K) (V:=V)) (i : Fin N) : + i∈expensiveMask M ↔ (M i).2=.expensive := by + exact Finset.mem_filter.trans (and_iff_right (Finset.mem_univ i)) + +omit [Fintype (Projectivization K (Module.Dual K V))] in +lemma ofFn_codeTuple {N : ℕ} (q : ℝ) (F : Fin N → ProjectivePair (K:=K) (V:=V)) : + List.ofFn (codeTuple q F) = pairCode q (fun _ => ⊥) (List.ofFn F) := by + apply List.ext_getElem + · simp only [List.length_ofFn,pairCode_length] + · intro i h1 h2 + simp only [List.getElem_ofFn,codeTuple] + +omit [Fintype (Projectivization K (Module.Dual K V))] in +lemma expensiveMask_card {N : ℕ} (q : ℝ) (F : Fin N → ProjectivePair (K:=K) (V:=V)) : + (expensiveMask (tupleMask q F)).card = + (scan q (fun _ => ⊥) ((List.ofFn F).map toScan)).1 := by + have hfilter (xs : List (RankMask (K:=K) (V:=V) × Option (ProjectivePair (K:=K) (V:=V)))) : + (xs.filter (fun a => a.1.2=.expensive)).length = + (xs.map (fun a => if a.1.2=.expensive then 1 else 0)).sum := by + induction xs with + | nil => rfl + | cons a xs ih => by_cases h : a.1.2=.expensive <;> simp [h,ih,Nat.add_comm] + rw [←pairCode_count,←ofFn_codeTuple,hfilter, List.map_ofFn,List.sum_ofFn] + rw [expensiveMask,Finset.card_filter] + rfl + +def cheapTuple {Γ : Type*} {N : ℕ} + (θ : (Fin N → Option (ProjectivePair (K:=K) (V:=V))) × + (Γ × (Fin N → RankMask (K:=K) (V:=V)))) (i : Fin N) : + Finset (ProjectivePair (K:=K) (V:=V)) := + projectiveCheapDomain (pairReplay (fun _ => ⊥) ((List.ofFn θ.1).take i.val)) (θ.2.2 i) + +lemma tuple_sent_eq {N : ℕ} (F : Fin N → ProjectivePair (K:=K) (V:=V)) + (hcons : ScanConsistent ((List.ofFn F).map toScan)) + (hinc : ∀ i, Incidence.Incident (F i).1 (F i).2) (i : Fin N) : + (codeTuple (Nat.card K) F i).2 = + Selection.maskedValues (expensiveMask (tupleMask (Nat.card K) F)) F i := by + have hh := pairCode_spec (Nat.card K) rfl (fun _ => ⊥) (List.ofFn F) hcons + (by intro f hf; obtain ⟨j,rfl⟩ := List.mem_ofFn.mp hf; exact hinc j) + (fun _ _ => bot_le) i.val (by simpa only [List.length_ofFn] using i.isLt) + simpa only [Selection.maskedValues,mem_expensiveMask,tupleMask,codeTuple,List.getElem_ofFn] using hh.1 + +lemma cheapTuple_mem {Γ : Type*} {N : ℕ} (c : Γ) + (F : Fin N → ProjectivePair (K:=K) (V:=V)) + (hcons : ScanConsistent ((List.ofFn F).map toScan)) + (hinc : ∀ i, Incidence.Incident (F i).1 (F i).2) (i : Fin N) + (hi : i∉expensiveMask (tupleMask (Nat.card K) F)) : + F i∈cheapTuple (Selection.maskedValues (expensiveMask (tupleMask (Nat.card K) F)) F, + (c,tupleMask (Nat.card K) F)) i := by + have hs : List.ofFn (Selection.maskedValues (expensiveMask (tupleMask (Nat.card K) F)) F) = + (pairCode (Nat.card K) (fun _ => ⊥) (List.ofFn F)).map Prod.snd := by + rw [←ofFn_codeTuple,List.map_ofFn] + exact congrArg List.ofFn (funext (fun j => (tuple_sent_eq F hcons hinc j).symm)) + have hh := pairCode_spec (Nat.card K) rfl (fun _ => ⊥) (List.ofFn F) hcons + (by intro f hf; obtain ⟨j,rfl⟩ := List.mem_ofFn.mp hf; exact hinc j) + (fun _ _ => bot_le) i.val (by simpa only [List.length_ofFn] using i.isLt) + have hc : (codeTuple (Nat.card K) F i).1.2≠.expensive := by + exact fun hc => hi ((mem_expensiveMask _ _).mpr hc) + simp only [cheapTuple,hs,tupleMask] + simpa only [codeTuple,List.getElem_ofFn] using hh.2 hc + +variable [Finite K] +lemma cheapTuple_card {Γ : Type*} {N n : ℕ} (hdim : Module.finrank K V=n+3) + (θ : (Fin N → Option (ProjectivePair (K:=K) (V:=V))) × + (Γ × (Fin N → RankMask (K:=K) (V:=V)))) (i : Fin N) : + ((cheapTuple θ i).card:ℝ) ≤ 64*(Nat.card K:ℝ)^(n+2) := + projectiveCheapDomain_card hdim _ _ + +lemma cheapTuple_log_card {Γ : Type*} {N n : ℕ} (hdim : Module.finrank K V=n+3) + (θ : (Fin N → Option (ProjectivePair (K:=K) (V:=V))) × + (Γ × (Fin N → RankMask (K:=K) (V:=V)))) (i : Fin N) : + Real.log (cheapTuple θ i).card ≤ Real.log (64*(Nat.card K:ℝ)^(n+2)) := by + have hq : (1:ℝ) ≤ Nat.card K := by exact_mod_cast (Finite.one_lt_card : 1 tupleMask (Nat.card K) (F x)) + expensiveMask F D cheapTuple Jprev (Real.log (64*(Nat.card K:ℝ)^(n+2))) hD hprev + (fun x hx i hi => cheapTuple_mem (C x) (F x) (hcons x hx) (hinc x hx) i hi) + (fun θ i _ => cheapTuple_log_card hdim θ i) + convert hh using 1 <;> + try simp only [Fintype.card_fun,Fintype.card_fin,rankMask_card,Nat.cast_pow,Real.log_pow, + Nat.cast_mul,Nat.cast_add,Nat.cast_one,Nat.cast_ofNat] + congr 2 <;> exact Subsingleton.elim _ _ + +omit [Fintype (Projectivization K (Module.Dual K V))] in + +lemma expected_expensive_bound {N : ℕ} (p : Selection.Law Ω) + (F : Ω → Fin N → ProjectivePair (K:=K) (V:=V)) : + (∑ x, p.mass x*((expensiveMask (tupleMask (Nat.card K) (F x))).card:ℝ)) ≤ + 32*(Module.finrank K V+1)^2*(Nat.card K:ℝ)* + Real.log (Fintype.card (Points (K:=K) (V:=V))+1:ℝ) := by + have hq : (0:ℝ) rw [popular_zero W hZ,card_empty,Nat.cast_zero]; norm_num + | succ l => exact popular_card W l hZ + exact (show (((popularJoint W l r).image Prod.fst).card:ℝ) ≤ (popularDomain W l).card by + exact_mod_cast card_le_card hsub).trans (hc.trans (mul_le_mul_of_nonneg_left + (pow_le_pow_right₀ (show (1:ℝ)≤Nat.card K by exact_mod_cast (Finite.one_lt_card : 1 f.1=b)).card:ℝ) ≤ 2*(Nat.card K:ℝ)^(d-r) := by + by_cases hb : ranks W b=r + · have hsub : (popularJoint W l r).filter (fun f => f.1=b) ⊆ + (partnerDomain (W b)).image (Prod.mk b) := by + intro f hf + obtain ⟨hf,hfb⟩ := mem_filter.mp hf + have hm := (popularJoint_mem hf).2.2 + exact mem_image.mpr ⟨f.2,by simpa only [hfb] using hm,by cases f; simp_all⟩ + have hc := card_le_card hsub + rw [card_image_of_injective _ (by intro a a' h; exact Prod.mk.inj h |>.2)] at hc + exact (show (((popularJoint W l r).filter (fun f => f.1=b)).card:ℝ) ≤ + (partnerDomain (W b)).card by exact_mod_cast hc).trans (partner_card hdim (W b) hb hr) + · have he : (popularJoint W l r).filter (fun f => f.1=b)=∅ := by + apply eq_empty_iff_forall_notMem.mpr + intro f hf + obtain ⟨hf,hfb⟩ := mem_filter.mp hf + exact hb (hfb ▸ (popularJoint_mem hf).2.1) + rw [he,card_empty,Nat.cast_zero]; positivity + +lemma cheapPopular_first_card (W : State (K:=K) (V:=V)) + (m : RankMask (K:=K) (V:=V)) (hm : m.2=.popular) : + (((projectiveCheapDomain W m).image Prod.fst).card:ℝ) ≤ 32*(Nat.card K:ℝ)^m.1.val := by + unfold projectiveCheapDomain + split_ifs + · rw [hm] + exact popularJoint_first_card W _ _ (levelFromRank_spec W m.1.val).1 + ((levelFromRank_spec W m.1.val).2 _ le_rfl) + · simp + +lemma cheapPopular_fiber_card {d : ℕ} (hdim : Module.finrank K V=d+1) + (W : State (K:=K) (V:=V)) (m : RankMask (K:=K) (V:=V)) (hm : m.2=.popular) + (b : Projectivization K V) : + (((projectiveCheapDomain W m).filter (fun f => f.1=b)).card:ℝ) ≤ + 2*(Nat.card K:ℝ)^(d-m.1.val) := by + unfold projectiveCheapDomain + split_ifs with hr + · rw [hm] + exact popularJoint_fiber_card hdim W _ (by omega) b + · simp + +lemma cheapPopular_rank_pos (W : State (K:=K) (V:=V)) + (m : RankMask (K:=K) (V:=V)) (hm : m.2=.popular) + (h : (projectiveCheapDomain W m).Nonempty) : + 1 ≤ m.1.val ∧ m.1.val < Module.finrank K V := by + unfold projectiveCheapDomain at h + split_ifs at h with hr + · rw [hm] at h + exact ⟨popularJoint_rank_pos (levelFromRank_spec W m.1.val).1 + ((levelFromRank_spec W m.1.val).2 _ le_rfl) h,hr⟩ + · exact False.elim (not_nonempty_empty h) + +lemma cheapPoor_product {n : ℕ} (hdim : Module.finrank K V=n+3) + (W : State (K:=K) (V:=V)) (m : RankMask (K:=K) (V:=V)) (hm : m.2=.poor) : + (((projectiveCheapDomain W m).image Prod.fst).card:ℝ)* + ((projectiveCheapDomain W m).image Prod.snd).card ≤ 16*(Nat.card K:ℝ)^(n+3) := by + unfold projectiveCheapDomain + split_ifs + · rw [hm] + have h₁ : (incidentPairs (level (ranks W) m.1.val) + (poorDomain W (levelFromRank W m.1.val))).image Prod.fst ⊆ level (ranks W) m.1.val := by + intro b hb + obtain ⟨f,hf,rfl⟩ := mem_image.mp hb + exact (mem_product.mp (mem_filter.mp hf).1).1 + have h₂ : (incidentPairs (level (ranks W) m.1.val) + (poorDomain W (levelFromRank W m.1.val))).image Prod.snd ⊆ + poorDomain W (levelFromRank W m.1.val) := by + intro a ha + obtain ⟨f,hf,rfl⟩ := mem_image.mp ha + exact (mem_product.mp (mem_filter.mp hf).1).2 + have h₁' : (((incidentPairs (level (ranks W) m.1.val) + (poorDomain W (levelFromRank W m.1.val))).image Prod.fst).card:ℝ) ≤ + (level (ranks W) (levelFromRank W m.1.val)).card := by + exact_mod_cast (card_le_card h₁).trans ((levelFromRank_spec W m.1.val).2 _ le_rfl) + have h₂' : (((incidentPairs (level (ranks W) m.1.val) + (poorDomain W (levelFromRank W m.1.val))).image Prod.snd).card:ℝ) ≤ + (poorDomain W (levelFromRank W m.1.val)).card := by exact_mod_cast card_le_card h₂ + exact (mul_le_mul h₁' h₂' (by positivity) (by positivity)).trans (poor_marginal_product hdim W _) + · simp + +end +end SharpLogRamsey.Marking + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/MarkingClassSelection.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/MarkingClassSelection.lean new file mode 100644 index 0000000000000000000000000000000000000000..dd5f5b4d372b5b08f44031dac21920d1576227db --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/MarkingClassSelection.lean @@ -0,0 +1,169 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.ClassSelection + +namespace OAI + +section +namespace SharpLogRamsey.Marking +open Finset +open scoped BigOperators Classical +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] [Finite K] + +def expensiveBudget (K V : Type*) [Field K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] [Fintype (Projectivization K V)] : ℝ := + 32*(Module.finrank K V+1)^2*(Nat.card K:ℝ)* + Real.log (Fintype.card (Points (K:=K) (V:=V))+1:ℝ) + +omit [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma two_expensive_bound {N : ℕ} (F : Fin N→ProjectivePair (K:=K) (V:=V)) : + ((bothExpensive (twoMask (Nat.card K) F)).card:ℝ)≤ + expensiveBudget K V+expensiveBudget K (Module.Dual K V) := by + have hq : (0:ℝ)⊥) ((List.ofFn F).map toScan) + have h₂ := scan_expensive_bound (Nat.card K:ℝ) hq (fun _=>⊥) + ((List.ofFn (reversedPairs F)).map toScan) + have h := bothExpensive_card (Nat.card K) F + have h' : ((bothExpensive (twoMask (Nat.card K) F)).card:ℝ)≤ + (expensiveMask (tupleMask (Nat.card K) F)).card+ + (expensiveMask (tupleMask (Nat.card K) (reversedPairs F))).card := by exact_mod_cast h + rw [expensiveMask_card,expensiveMask_card] at h' + exact h'.trans (add_le_add h₁ h₂) + +variable {Ω Γ κ : Type*} [Fintype Ω] [Fintype Γ] [Fintype κ] [Nonempty κ] + +omit [Fintype κ] [Nonempty κ] in +lemma twoScan_subset_pointwise {N n : ℕ} (hdim : Module.finrank K V=n+3) + (p : Selection.Law Ω) (C : Ω→Γ) (F : Ω→Fin N→ProjectivePair (K:=K) (V:=V)) + (hcons : ∀ x,p.mass x≠0→ScanConsistent ((List.ofFn (F x)).map toScan)) + (hinc : ∀ x,p.mass x≠0→∀ i,Incidence.Incident (F x i).1 (F x i).2) + (z : TwoMessage (K:=K) (V:=V) Γ N) + (hz : (p.map (sourceMessage C F)).mass z≠0) + (S : Finset (Fin N)) (hS : Disjoint S (bothExpensive z.2.2)) : + 0≤S.card*jointJ K (n+2)-Selection.entropy + (((p.cond (sourceMessage C F) z).map F).restrict S) := by + let θ := sourceMessage C F + let ν := (p.cond θ z).map F + have hcoord (i : S) : Selection.entropy ((ν.restrict S).marginal i) ≤ jointJ K (n+2) := by + rw [Selection.Law.marginal_restrict] + have hs : Selection.entropy (ν.marginal (i:Fin N)) ≤ + Real.log (cheapBoth z i).card := by + change Selection.entropy (((p.cond θ z).map F).map (fun f=>f i)) ≤ _ + rw [Selection.Law.map_map] + apply Selection.entropy_mapped_support + intro x hx + obtain ⟨hx,he⟩ := p.cond_support θ z hz x hx + have hi : (i:Fin N)∉bothExpensive (twoMask (Nat.card K) (F x)) := by + have he' : twoMask (Nat.card K) (F x)=z.2.2 := congrArg (fun z=>z.2.2) he + rw [he'] + exact disjoint_left.mp hS i.property + have hh := cheapBoth_mem C F x (hcons x hx) (hinc x hx) i hi + simpa only [Function.comp_apply,←he,θ,sourceMessage] using hh + exact hs.trans (cheapBoth_log_card hdim z i) + have hh := (Selection.entropy_subadditive_pi (ν.restrict S)).trans + (sum_le_sum (fun i _=>hcoord i)) + have he : (∑ _ : S,jointJ K (n+2))=S.card*jointJ K (n+2) := by simp + rw [he] at hh + exact sub_nonneg.mpr hh + +omit [Fintype κ] [Nonempty κ] in + +def conditionedDeficit {N : ℕ} (p : Selection.Law Ω) (C : Ω→Γ) + (F : Ω→Fin N→ProjectivePair (K:=K) (V:=V)) + (E : Finset (TwoMessage (K:=K) (V:=V) Γ N)) + (hE : 0<(p.map (sourceMessage C F)).event E) + (S : TwoMessage (K:=K) (V:=V) Γ N→Finset (Fin N)) (J : ℝ) : ℝ := + Selection.selectedDeficit (p.onContextEvent (sourceMessage C F) E hE) + (sourceMessage C F) F S J + +omit [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +theorem actual_common_class_slots {N : ℕ} + (p : Selection.Law Ω) (C : Ω→Γ) (F : Ω→Fin N→ProjectivePair (K:=K) (V:=V)) + (colour : TwoMessage (K:=K) (V:=V) Γ N→Fin N→κ) (m : ℕ) + (hm : (Fintype.card κ*m:ℕ)+expensiveBudget K V+ + expensiveBudget K (Module.Dual K V)≤(N:ℝ)) : + ∃ (c : κ) (E : Finset (TwoMessage (K:=K) (V:=V) Γ N)) + (_hE : 0<(p.map (sourceMessage C F)).event E) + (S : TwoMessage (K:=K) (V:=V) Γ N→Finset (Fin N)), + 1/(Fintype.card κ:ℝ)≤(p.map (sourceMessage C F)).event E ∧ + (∀ z,Disjoint (S z) (bothExpensive z.2.2)) ∧ + (∀ z∈E,(S z).card=m ∧ ∀ i∈S z,colour z i=c) := by + + let θ:=sourceMessage C F + let U:=fun z : TwoMessage (K:=K) (V:=V) Γ N=>(bothExpensive z.2.2)ᶜ + have hcount x (_hx : p.mass x≠0) : Fintype.card κ*m≤(U (θ x)).card := by + have hb := two_expensive_bound (F x) + have hc : ((U (θ x)).card:ℝ)=(N:ℝ)-(bothExpensive (twoMask (Nat.card K) (F x))).card := by + simp only [U,θ,sourceMessage,Selection.markingMessage,card_compl, + Fintype.card_fin] + rw [Nat.cast_sub (by simpa only [Fintype.card_fin] using + (card_le_univ (bothExpensive (twoMask (Nat.card K) (F x)))))] + have hh : (Fintype.card κ*m:ℕ)≤((U (θ x)).card:ℝ) := by rw [hc]; linarith + exact_mod_cast hh + obtain ⟨c,E,S,hprob,hslots⟩ := Selection.common_class_extraction p θ U colour m hcount + have hp : 0<(p.map θ).event E := lt_of_lt_of_le (one_div_pos.mpr (by + exact_mod_cast (Fintype.card_pos (α:=κ)))) hprob + let S' := fun z=>if z∈E then S z else ∅ + have hS z : Disjoint (S' z) (bothExpensive z.2.2) := by + by_cases hz : z∈E + · simp only [S',ite_eq_left hz] + apply disjoint_left.mpr + intro i hi hie + exact (mem_compl.mp ((hslots z hz).2.1 hi)) hie + · simp [S',hz] + refine ⟨c,E,hp,S',hprob,hS,?_⟩ + intro z hz + simpa only [S',ite_eq_left hz] using ⟨(hslots z hz).1,(hslots z hz).2.2⟩ + +omit [Fintype κ] [Nonempty κ] in + +theorem twoScan_conditioned_deficit {N n : ℕ} (hdim : Module.finrank K V=n+3) + (p : Selection.Law Ω) (C : Ω→Γ) (F : Ω→Fin N→ProjectivePair (K:=K) (V:=V)) + (D : Γ→Fin N→Finset (ProjectivePair (K:=K) (V:=V))) (Jprev : ℝ) + (hcons : ∀ x,p.mass x≠0→ScanConsistent ((List.ofFn (F x)).map toScan)) + (hinc : ∀ x,p.mass x≠0→∀ i,Incidence.Incident (F x i).1 (F x i).2) + (hD : ∀ x,p.mass x≠0→∀ i,F x i∈D (C x) i) + (hprev : ∀ c i,Real.log (D c i).card≤Jprev) + (E : Finset (TwoMessage (K:=K) (V:=V) Γ N)) + (hp : 0<(p.map (sourceMessage C F)).event E) + (S : TwoMessage (K:=K) (V:=V) Γ N→Finset (Fin N)) + (hS : ∀ z,Disjoint (S z) (bothExpensive z.2.2)) : + conditionedDeficit p C F E hp S (jointJ K (n+2)) ≤ + excessCost p C F Jprev (jointJ K (n+2))/(p.map (sourceMessage C F)).event E := by + unfold conditionedDeficit + apply Selection.selectedDeficit_onContextEvent_le + · intro z hz + convert twoScan_subset_pointwise hdim p C F hcons hinc z hz (S z) (hS z) using 1; congr! + · exact (twoScan_subset_deficit hdim p C F D Jprev hcons hinc hD hprev S hS).2 + +theorem actual_common_class {N n : ℕ} (hdim : Module.finrank K V=n+3) + (p : Selection.Law Ω) (C : Ω→Γ) (F : Ω→Fin N→ProjectivePair (K:=K) (V:=V)) + (D : Γ→Fin N→Finset (ProjectivePair (K:=K) (V:=V))) (Jprev : ℝ) + (hcons : ∀ x,p.mass x≠0→ScanConsistent ((List.ofFn (F x)).map toScan)) + (hinc : ∀ x,p.mass x≠0→∀ i,Incidence.Incident (F x i).1 (F x i).2) + (hD : ∀ x,p.mass x≠0→∀ i,F x i∈D (C x) i) + (hprev : ∀ c i,Real.log (D c i).card≤Jprev) + (colour : TwoMessage (K:=K) (V:=V) Γ N→Fin N→κ) (m : ℕ) + (hm : (Fintype.card κ*m:ℕ)+expensiveBudget K V+ + expensiveBudget K (Module.Dual K V)≤(N:ℝ)) : + ∃ (c : κ) (E : Finset (TwoMessage (K:=K) (V:=V) Γ N)) + (hE : 0<(p.map (sourceMessage C F)).event E) + (S : TwoMessage (K:=K) (V:=V) Γ N→Finset (Fin N)), + 1/(Fintype.card κ:ℝ)≤(p.map (sourceMessage C F)).event E ∧ + (∀ z,Disjoint (S z) (bothExpensive z.2.2)) ∧ + (∀ z∈E,(S z).card=m ∧ ∀ i∈S z,colour z i=c) ∧ + conditionedDeficit p C F E hE S (jointJ K (n+2)) ≤ + excessCost p C F Jprev (jointJ K (n+2))/(p.map (sourceMessage C F)).event E := by + obtain ⟨c,E,hp,S,hprob,hS,hslots⟩ := actual_common_class_slots p C F colour m hm + exact ⟨c,E,hp,S,hprob,hS,hslots, + twoScan_conditioned_deficit hdim p C F D Jprev hcons hinc hD hprev E hp S hS⟩ + +end +end SharpLogRamsey.Marking + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/MarkingClassification.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/MarkingClassification.lean new file mode 100644 index 0000000000000000000000000000000000000000..a78a30daa0acb7dbc69b5af812cd8c4e55ba8064 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/MarkingClassification.lean @@ -0,0 +1,92 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.MarkingTwoCaps +import OAI.Combinatorics.SharpRamsey.Reciprocal.ReciprocalBands + +namespace OAI + +section +namespace SharpLogRamsey.Marking +open Finset +open scoped BigOperators Classical +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] [Finite K] + +theorem twoDomain_low_or_high {n : ℕ} (hdim : Module.finrank K V=n+3) + (W : State (K:=K) (V:=V)) (W' : State (K:=K) (V:=Module.Dual K V)) + (m : RankMask (K:=K) (V:=V)) (m' : RankMask (K:=K) (V:=Module.Dual K V)) + (h : (twoDomain W W' m m').Nonempty) : + (((twoDomain W W' m m').image Prod.fst).card:ℝ)* + ((twoDomain W W' m m').image Prod.snd).card ≤ 1024*(Nat.card K:ℝ)^(n+3) ∨ + (m.2=.popular ∧ m'.2=.popular ∧ 1 ≤ m.1.val ∧ m.1.val≤n+2 ∧ + 1 ≤ m'.1.val ∧ m'.1.val≤n+2 ∧ n+3 < m.1.val+m'.1.val) := by + have hdim' : Module.finrank K V=(n+2)+1 := by omega + obtain hp|hp|⟨hp,hp',hr,hr',hs,hs'⟩ := twoDomain_cases hdim' W W' m m' h + · left + exact (twoPoor_product hdim W W' m m' (Or.inl hp)).trans (mul_le_mul_of_nonneg_right (by norm_num : (16:ℝ)≤1024) (by positivity)) + · left + exact (twoPoor_product hdim W W' m m' (Or.inr hp)).trans (mul_le_mul_of_nonneg_right (by norm_num : (16:ℝ)≤1024) (by positivity)) + by_cases hsum : m.1.val+m'.1.val≤n+3 + · left + obtain ⟨ha,hb,-,-⟩ := twoPopular_caps hdim' W W' m m' hp hp' + have hq : (1:ℝ)≤Nat.card K := by exact_mod_cast (Finite.one_lt_card : 1 Iff.rfl)] + exact sum_le_sum (fun i _ => hJ i) + let f := fun x : ι → α => ((fun i:S => x i),(fun i:↥(Sᶜ) => x i)) + have hf : Function.Injective f := by + intro x y hxy + funext i + by_cases hi : i∈S + · exact congr_fun (congrArg Prod.fst hxy) ⟨i,hi⟩ + · exact congr_fun (congrArg Prod.snd hxy) ⟨i,by simpa using hi⟩ + have h1 : (p.map f).fst=p.restrict S := by rw [←Law.map_fst,Law.map_map]; rfl + have h2 : (p.map f).snd=p.restrict Sᶜ := by rw [←Law.map_snd,Law.map_map]; rfl + have ht := entropy_subadditive (p.map f) + rw [entropy_map_eq_of_injective p f hf,h1,h2] at ht + have hs := sum_add_sum_compl S J + exact ⟨sub_nonneg.mpr (hcap S),by linarith [hcap Sᶜ]⟩ + +omit [Fintype Ω] [Fintype α] [Fintype Γ] [Fintype M] [Fintype ι] in +lemma cheap_budget_sum (E S : Finset ι) (J : ℝ) (hS : Disjoint S E) : + (∑ i∈S, if i∈E then (0:ℝ) else J) = S.card*J := by + rw [sum_congr rfl (fun i hi => ite_eq_right (disjoint_left.mp hS hi))] + simp + +omit [Fintype Ω] [Fintype α] [Fintype Γ] [Fintype M] in +lemma cheap_budget_total (E : Finset ι) (J : ℝ) : + (∑ i, if i∈E then (0:ℝ) else J) = ((Fintype.card ι:ℝ)-E.card)*J := by + rw [sum_ite,sum_const_zero,zero_add,sum_const,nsmul_eq_mul] + have hc : (univ.filter (fun i => i∉E)).card=Fintype.card ι-E.card := by + rw [←sdiff_eq_filter,card_sdiff_of_subset (subset_univ _),card_univ] + rw [hc,Nat.cast_sub (card_le_univ _)] + +lemma marking_subset_pointwise (p : Law Ω) (C : Ω → Γ) (mask : Ω → M) + (E : M → Finset ι) (F : Ω → ι → α) + (cheap : ((ι → Option α) × (Γ × M)) → ι → Finset α) (J₀ : ℝ) + (hc : ∀ x, p.mass x≠0 → ∀ i, i∉E (mask x) → + F x i∈cheap (markingMessage C mask E F x) i) + (hcheap : ∀ θ i, i∉E θ.2.2 → Real.log (cheap θ i).card≤J₀) + (z : (ι → Option α) × (Γ × M)) + (hz : (p.map (markingMessage C mask E F)).mass z≠0) + (S : Finset ι) (hS : Disjoint S (E z.2.2)) : + let ν := (p.cond (markingMessage C mask E F) z).map F + 0 ≤ S.card*J₀-entropy (ν.restrict S) ∧ + S.card*J₀-entropy (ν.restrict S) ≤ + ((Fintype.card ι:ℝ)-(E z.2.2).card)*J₀-entropy ν := by + let θ := markingMessage C mask E F + let ν := (p.cond θ z).map F + have hd (i : ι) : entropy (ν.marginal i) ≤ if i∈E z.2.2 then 0 else J₀ := by + have hm : entropy (ν.marginal i) ≤ Real.log (markingDecodedDomains E cheap z i).card := by + change entropy (((p.cond θ z).map F).map (fun f => f i)) ≤ _ + rw [Law.map_map] + apply entropy_mapped_support + intro x hx + obtain ⟨hp,he⟩ := p.cond_support θ z hz x hx + simpa only [Function.comp_apply,←he] using + markingDecodedDomains_mem C mask E F cheap x (hc x hp) i + apply hm.trans + by_cases hi : i∈E z.2.2 + · simp only [markingDecodedDomains,ite_eq_left hi] + cases z.1 i <;> simp + · simpa only [markingDecodedDomains,ite_eq_right hi] using hcheap z i hi + have hh := subset_budget_deficit ν S (fun i => if i∈E z.2.2 then 0 else J₀) hd + rw [cheap_budget_sum _ _ _ hS,cheap_budget_total] at hh + exact hh + +theorem marking_subset_deficit (p : Law Ω) (C : Ω → Γ) (mask : Ω → M) + (E : M → Finset ι) (F : Ω → ι → α) (D : Γ → ι → Finset α) + (cheap : ((ι → Option α) × (Γ × M)) → ι → Finset α) (Jprev J₀ : ℝ) + (hD : ∀ x, p.mass x≠0 → ∀ i, F x i∈D (C x) i) + (hprev : ∀ c i, Real.log (D c i).card≤Jprev) + (hc : ∀ x, p.mass x≠0 → ∀ i, i∉E (mask x) → + F x i∈cheap (markingMessage C mask E F x) i) + (hcheap : ∀ θ i, i∉E θ.2.2 → Real.log (cheap θ i).card≤J₀) + (S : ((ι → Option α) × (Γ × M)) → Finset ι) + (hS : ∀ z, Disjoint (S z) (E z.2.2)) : + let θ := markingMessage C mask E F + let δ := fun z => (S z).card*J₀- + entropy (((p.cond θ z).map F).restrict (S z)) + 0 ≤ ∑ z, (p.map θ).mass z*δ z ∧ + (∑ z, (p.map θ).mass z*δ z) ≤ entropy (p.map C)+Real.log (Fintype.card M)+ + Fintype.card ι*J₀-entropy (p.map F)+ + (∑ x, p.mass x*((E (mask x)).card:ℝ))*(Jprev-J₀) := by + dsimp only + let θ := markingMessage C mask E F + have hpt z hz := marking_subset_pointwise p C mask E F cheap J₀ hc hcheap z hz (S z) (hS z) + constructor + · apply sum_nonneg + intro z _ + by_cases hz : (p.map θ).mass z=0 + · simp only [θ] at hz + simp [hz] + · exact mul_nonneg ((p.map θ).nonneg z) (hpt z hz).1 + · have hp := entropy_context_bound p θ F (fun z => entropy ((p.cond θ z).map F)) + (fun _ _ => le_rfl) + have hm := marking_message_entropy p C mask E F D Jprev hD hprev + have he : (∑ z, (p.map θ).mass z * (((Fintype.card ι:ℝ)-(E z.2.2).card)*J₀)) = + ((Fintype.card ι:ℝ)-∑ x, p.mass x*((E (mask x)).card:ℝ))*J₀ := by + rw [p.sum_map θ] + change (∑ x, p.mass x * (((Fintype.card ι:ℝ)-(E (mask x)).card)*J₀)) = _ + simp_rw [←mul_assoc,mul_sub] + rw [←sum_mul,sum_sub_distrib,←sum_mul,p.total,one_mul] + have hh : ∑ z, (p.map θ).mass z*((S z).card*J₀- + entropy (((p.cond θ z).map F).restrict (S z))) ≤ + ∑ z, (p.map θ).mass z*(((Fintype.card ι:ℝ)-(E z.2.2).card)*J₀- + entropy ((p.cond θ z).map F)) := by + apply sum_le_sum + intro z _ + by_cases hz : (p.map θ).mass z=0 + · simp [hz] + · exact mul_le_mul_of_nonneg_left (hpt z hz).2 ((p.map θ).nonneg z) + simp only [mul_sub,sum_sub_distrib,he] at hh + change _ ≤ _ + dsimp only [θ] at hp hh + simp only [mul_sub,sum_sub_distrib] + linarith + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/MarkingFiniteClasses.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/MarkingFiniteClasses.lean new file mode 100644 index 0000000000000000000000000000000000000000..8b4c41c8cc43c750b0e637d9d6cac385c41a5f8e --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/MarkingFiniteClasses.lean @@ -0,0 +1,83 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.MarkingClassification + +namespace OAI + +section +namespace SharpLogRamsey.Marking +open Finset ReciprocalBands +open scoped Classical +noncomputable section + +abbrev SlotClass (d : ℕ) := (Bool×Fin (d+1))⊕(Fin (d+1)×Fin (d+1)) +lemma slotClass_card (d : ℕ) : Fintype.card (SlotClass d)=2*(d+1)+(d+1)^2 := by + simp only [SlotClass,Fintype.card_sum,Fintype.card_prod,Fintype.card_bool,Fintype.card_fin,pow_two] + +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [Finite K] [FiniteDimensional K V] [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] + +def ValidSlotClass (d : ℕ) (gap : ℝ) + (D : Finset (ProjectivePair (K:=K) (V:=V))) : SlotClass d→Prop + | .inl (integer,r) => ∃ u : ℝ, + Real.log (Nat.card K:ℝ)≤u ∧ u≤(d:ℝ)*Real.log (Nat.card K:ℝ) ∧ + ((D.image Prod.fst).card:ℝ)≤1024*Real.exp (((d:ℝ)+1)*Real.log (Nat.card K:ℝ)-u) ∧ + ((D.image Prod.snd).card:ℝ)≤1024*Real.exp u ∧ + 1≤r.val ∧ (if integer then IntegerBand r.val (Real.log (Nat.card K:ℝ)) gap u + else 2≤r.val ∧ OpenBand r.val (Real.log (Nat.card K:ℝ)) gap u) + | .inr (r,r') => + 1≤r.val ∧ 1≤r'.val ∧ d+1f.1=b)).card:ℝ)≤2*(Nat.card K:ℝ)^(d-r.val)) ∧ + (∀ a,((D.filter (fun f=>f.2=a)).card:ℝ)≤2*(Nat.card K:ℝ)^(d-r'.val)) + +theorem exists_valid_slot_class {n : ℕ} (hdim : Module.finrank K V=n+3) + {gap : ℝ} (hgap : 0≤gap) + (W : State (K:=K) (V:=V)) (W' : State (K:=K) (V:=Module.Dual K V)) + (m : RankMask (K:=K) (V:=V)) (m' : RankMask (K:=K) (V:=Module.Dual K V)) + (h : (twoDomain W W' m m').Nonempty) : + ∃ c : SlotClass (n+2),ValidSlotClass (n+2) gap (twoDomain W W' m m') c := by + obtain hlow|⟨hm,hm',hr,hr',hs,hs',hsum⟩ := twoDomain_low_or_high hdim W W' m m' h + · have hd : Module.finrank K V=(n+2)+1 := by omega + obtain ⟨hu,hu',ha,hb⟩ := twoDomain_reciprocal_caps (by omega : 1≤n+2) hd _ h hlow + have hq : (1:ℝ) x i)) ≤ _ + rw [Law.map_map] + apply entropy_mapped_support + intro x hx + obtain ⟨hp,he⟩ := p.cond_support C c hc x hx + simpa only [Function.comp_apply,he] using hS x hp i + +lemma entropy_context_bound (p : Law Ω) (C : Ω → Γ) (F : Ω → α) (J : Γ → ℝ) + (hJ : ∀ c, (p.map C).mass c ≠ 0 → entropy ((p.cond C c).map F) ≤ J c) : + entropy (p.map F) ≤ entropy (p.map C)+∑ c, (p.map C).mass c*J c := by + have hf : (p.map (fun x => (F x,C x))).fst = p.map F := by + rw [← Law.map_fst,Law.map_map] + rfl + have hh := entropy_map_le (p.map (fun x => (F x,C x))) Prod.fst + rw [Law.map_fst,hf,entropy_cond_chain p C F] at hh + apply hh.trans + apply add_le_add le_rfl + apply sum_le_sum + intro a ha + by_cases hc : (p.map C).mass a = 0 + · simp [hc] + · exact mul_le_mul_of_nonneg_left (hJ a hc) ((p.map C).nonneg a) + +lemma entropy_adjoin_mask {M : Type*} [Fintype M] (p : Law Ω) + (C : Ω → Γ) (mask : Ω → M) : + entropy (p.map (fun x => (C x,mask x))) ≤ + entropy (p.map C)+Real.log (Fintype.card M) := by + have hf : (p.map (fun x => (C x,mask x))).fst = p.map C := by + rw [← Law.map_fst,Law.map_map]; rfl + have hs : (p.map (fun x => (C x,mask x))).snd = p.map mask := by + rw [← Law.map_snd,Law.map_map]; rfl + have hm := entropy_le_log_card (p.map mask) univ (by simp) + have ht := entropy_subadditive (p.map (fun x => (C x,mask x))) + rw [hf,hs] at ht + exact ht.trans (add_le_add le_rfl (by simpa only [card_univ] using hm)) + +def maskedValues (E : Finset ι) (f : ι → α) : ι → Option α := + fun i => if i ∈ E then some (f i) else none + +def maskedDomains (E : Finset ι) (D : ι → Finset α) (i : ι) : Finset (Option α) := + if i ∈ E then (D i).image some else {none} + +omit [Fintype α] [Fintype ι] in +lemma maskedValues_mem (E : Finset ι) (f : ι → α) (D : ι → Finset α) + (hD : ∀ i, f i ∈ D i) (i : ι) : maskedValues E f i ∈ maskedDomains E D i := by + by_cases hi : i ∈ E + · simp only [maskedValues,maskedDomains,ite_eq_left hi] + exact mem_image.mpr ⟨f i,hD i,rfl⟩ + · simp [maskedValues,maskedDomains,hi] + +omit [Fintype α] [Fintype ι] in +lemma maskedDomains_log_card (E : Finset ι) (D : ι → Finset α) (i : ι) : + Real.log (maskedDomains E D i).card = if i ∈ E then Real.log (D i).card else 0 := by + by_cases hi : i ∈ E + · simp [maskedDomains,hi,card_image_of_injective (D i) (Option.some_injective α)] + · simp [maskedDomains,hi] + +end +end SharpLogRamsey.Selection + +namespace SharpLogRamsey.Selection +open scoped BigOperators Classical +open Finset +noncomputable section +variable {Ω α Γ M ι : Type*} [Fintype Ω] [Fintype α] [Fintype Γ] [Fintype M] [Fintype ι] + +def markingMessage (C : Ω → Γ) (mask : Ω → M) (E : M → Finset ι) (F : Ω → ι → α) + (x : Ω) : (ι → Option α) × (Γ × M) := + (maskedValues (E (mask x)) (F x),(C x,mask x)) + +theorem marking_message_entropy (p : Law Ω) (C : Ω → Γ) (mask : Ω → M) + (E : M → Finset ι) (F : Ω → ι → α) (D : Γ → ι → Finset α) (J : ℝ) + (hD : ∀ x, p.mass x ≠ 0 → ∀ i, F x i ∈ D (C x) i) + (hJ : ∀ c i, Real.log (D c i).card ≤ J) : + entropy (p.map (markingMessage C mask E F)) ≤ entropy (p.map C)+ + Real.log (Fintype.card M)+(∑ x, p.mass x*((E (mask x)).card:ℝ))*J := by + let G := fun x => (C x,mask x) + let T := fun x => maskedValues (E (mask x)) (F x) + have hG := entropy_adjoin_mask p C mask + have hcond (c : Γ × M) (hc : (p.map G).mass c ≠ 0) : + entropy ((p.cond G c).map T) ≤ (E c.2).card*J := by + let S := fun c : Γ × M => maskedDomains (E c.2) (D c.1) + have hh := entropy_cond_tuple_domains p G T S (fun x hx i => + maskedValues_mem _ _ _ (hD x hx) i) c hc + apply hh.trans + simp only [S,maskedDomains_log_card] + calc + _ ≤ ∑ i, if i ∈ E c.2 then J else 0 := by + apply sum_le_sum + intro i hi + split_ifs + · exact hJ c.1 i + · exact le_rfl + _ = _ := by simp + have hsum : ∑ c, (p.map G).mass c*((E c.2).card:ℝ)*J = + (∑ x, p.mass x*((E (mask x)).card:ℝ))*J := by + rw [← sum_mul, p.sum_map G (fun c => ((E c.2).card:ℝ))] + change entropy (p.map (fun x => (T x,G x))) ≤ _ + rw [entropy_cond_chain p G T] + calc + _ ≤ (entropy (p.map C)+Real.log (Fintype.card M))+ + ∑ c, (p.map G).mass c*((E c.2).card*J) := by + apply add_le_add hG + apply sum_le_sum + intro c hc + by_cases hn : (p.map G).mass c = 0 + · simp [hn] + · exact mul_le_mul_of_nonneg_left (hcond c hn) ((p.map G).nonneg c) + _ = _ := by simp_rw [← mul_assoc]; rw [hsum] + +def markingDecodedDomains (E : M → Finset ι) + (cheap : ((ι → Option α) × (Γ × M)) → ι → Finset α) + (θ : (ι → Option α) × (Γ × M)) (i : ι) : Finset α := + if i ∈ E θ.2.2 then (θ.1 i).toFinset else cheap θ i + +omit [Fintype Ω] [Fintype α] [Fintype Γ] [Fintype M] [Fintype ι] in +lemma markingDecodedDomains_mem (C : Ω → Γ) (mask : Ω → M) + (E : M → Finset ι) (F : Ω → ι → α) + (cheap : ((ι → Option α) × (Γ × M)) → ι → Finset α) + (x : Ω) + (hcheap : ∀ i, i ∉ E (mask x) → F x i ∈ cheap (markingMessage C mask E F x) i) + (i : ι) : F x i ∈ markingDecodedDomains E cheap (markingMessage C mask E F x) i := by + by_cases hi : i ∈ E (mask x) + · simp [markingDecodedDomains,markingMessage,maskedValues,hi] + · change F x i ∈ if i ∈ E (mask x) then _ else _ + rw [ite_eq_right hi] + exact hcheap i hi + +omit [Fintype α] [Fintype Γ] [Fintype M] in +lemma markingDecodedDomains_entropy (E : M → Finset ι) + (cheap : ((ι → Option α) × (Γ × M)) → ι → Finset α) (J : ℝ) + (hJ : ∀ θ i, i ∉ E θ.2.2 → Real.log (cheap θ i).card ≤ J) + (θ : (ι → Option α) × (Γ × M)) : + (∑ i, Real.log (markingDecodedDomains E cheap θ i).card) ≤ + ((Fintype.card ι:ℝ)-(E θ.2.2).card)*J := by + have h (i : ι) : Real.log (markingDecodedDomains E cheap θ i).card ≤ + if i ∈ E θ.2.2 then 0 else J := by + by_cases hi : i ∈ E θ.2.2 + · simp only [markingDecodedDomains,ite_eq_left hi] + cases θ.1 i <;> simp + · simpa only [markingDecodedDomains,ite_eq_right hi] using hJ θ i hi + have he : (∑ i, if i ∈ E θ.2.2 then (0:ℝ) else J) = + ((Fintype.card ι:ℝ)-(E θ.2.2).card)*J := by + rw [sum_ite, sum_const_zero, zero_add, sum_const, nsmul_eq_mul] + have hcard : (univ.filter (fun i => i ∉ E θ.2.2)).card = Fintype.card ι-(E θ.2.2).card := by + rw [← sdiff_eq_filter,card_sdiff_of_subset (subset_univ _),card_univ] + rw [hcard,Nat.cast_sub (card_le_univ _)] + exact (sum_le_sum (fun i _ => h i)).trans_eq he + +theorem marking_entropy_upper (p : Law Ω) (C : Ω → Γ) (mask : Ω → M) + (E : M → Finset ι) (F : Ω → ι → α) (D : Γ → ι → Finset α) + (cheap : ((ι → Option α) × (Γ × M)) → ι → Finset α) (Jprev J₀ : ℝ) + (hD : ∀ x, p.mass x ≠ 0 → ∀ i, F x i ∈ D (C x) i) + (hprev : ∀ c i, Real.log (D c i).card ≤ Jprev) + (hc : ∀ x, p.mass x ≠ 0 → ∀ i, i ∉ E (mask x) → + F x i ∈ cheap (markingMessage C mask E F x) i) + (hcheap : ∀ θ i, i ∉ E θ.2.2 → Real.log (cheap θ i).card ≤ J₀) : + entropy (p.map F) ≤ entropy (p.map C)+Real.log (Fintype.card M)+ + Fintype.card ι*J₀+(∑ x, p.mass x*((E (mask x)).card:ℝ))*(Jprev-J₀) := by + let θ := markingMessage C mask E F + have hu := entropy_context_bound p θ F + (fun z => ((Fintype.card ι:ℝ)-(E z.2.2).card)*J₀) (fun z hz => + (entropy_cond_tuple_domains p θ F (markingDecodedDomains E cheap) + (fun x hx i => markingDecodedDomains_mem C mask E F cheap x (hc x hx) i) z hz).trans + (markingDecodedDomains_entropy E cheap J₀ hcheap z)) + have hm := marking_message_entropy p C mask E F D Jprev hD hprev + have he : (∑ z, (p.map θ).mass z * (((Fintype.card ι:ℝ)-(E z.2.2).card)*J₀)) = + ((Fintype.card ι:ℝ)-∑ x, p.mass x*((E (mask x)).card:ℝ))*J₀ := by + rw [p.sum_map θ] + change (∑ x, p.mass x * (((Fintype.card ι:ℝ)-(E (mask x)).card)*J₀)) = _ + simp_rw [← mul_assoc,mul_sub] + rw [← sum_mul,sum_sub_distrib,← sum_mul,p.total,one_mul] + rw [he] at hu + dsimp only [θ] at hu + linarith + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/MarkingOrientation.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/MarkingOrientation.lean new file mode 100644 index 0000000000000000000000000000000000000000..db402e0e6370c7e50e2962cde2c8be4b1439aa7f --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/MarkingOrientation.lean @@ -0,0 +1,442 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Reciprocal.LevelLosses + +namespace OAI + +section +open scoped BigOperators Classical +open Finset +namespace SharpLogRamsey.Marking + +section FinitePotential +variable {Y : Type*} [Fintype Y] + +noncomputable def level (r : Y → ℕ) (l : ℕ) : Finset Y := {y | r y = l} +noncomputable def below (r : Y → ℕ) (l : ℕ) : Finset Y := {y | r y ≤ l} +noncomputable def potential (D : ℕ) (r : Y → ℕ) : ℝ := + ∑ l ∈ range (D+1), Real.log ((below r l).card + 1 : ℝ) + +theorem below_antitone {r r' : Y → ℕ} (h : ∀ y, r y ≤ r' y) (l : ℕ) : + below r' l ⊆ below r l := by + intro y hy + simp only [below, mem_filter, mem_univ, true_and] at * + exact (h y).trans hy + +theorem potential_nonneg (D : ℕ) (r : Y → ℕ) : 0 ≤ potential D r := by + apply sum_nonneg + intro l hl + apply Real.log_nonneg + exact le_add_of_nonneg_left (Nat.cast_nonneg _) + +theorem potential_le (D : ℕ) (r : Y → ℕ) : + potential D r ≤ (D+1)*Real.log (Fintype.card Y + 1 : ℝ) := by + calc + _ ≤ ∑ _l ∈ range (D+1), Real.log (Fintype.card Y + 1 : ℝ) := by + apply sum_le_sum + intro l hl + apply Real.log_le_log (by positivity) + exact_mod_cast Nat.add_le_add_right (card_le_univ _) 1 + _ = _ := by simp + +theorem log_drop {n m δ : ℝ} (hn : 1 ≤ n) (hm : 0 ≤ m) + (hδ : 0 ≤ δ) (hdrop : m ≤ n - δ*n) : + δ/2 ≤ Real.log (n+1) - Real.log (m+1) := by + have hn0 : 0 < n+1 := by linarith + have hm0 : 0 < m+1 := by linarith + have hratio : 0 < (m+1)/(n+1) := div_pos hm0 hn0 + have hlog := Real.log_le_sub_one_of_pos hratio + rw [Real.log_div hm0.ne' hn0.ne'] at hlog + have hfrac : (m+1)/(n+1) ≤ 1-δ/2 := by + apply (div_le_iff₀ hn0).mpr + nlinarith [mul_nonneg hδ (sub_nonneg.mpr hn)] + linarith + +theorem potential_drop {D l : ℕ} {r r' : Y → ℕ} {δ : ℝ} + (hl : l ≤ D) (hmono : ∀ y, r y ≤ r' y) + (hn : (below r l).Nonempty) (hδ : 0 ≤ δ) + (hdrop : ((below r' l).card : ℝ) ≤ (below r l).card - δ*(below r l).card) : + δ/2 ≤ potential D r - potential D r' := by + have hle i : Real.log ((below r' i).card + 1 : ℝ) ≤ + Real.log ((below r i).card + 1 : ℝ) := by + apply Real.log_le_log (by positivity) + exact_mod_cast Nat.add_le_add_right (card_le_card (below_antitone hmono i)) 1 + rw [potential, potential, ← sum_sub_distrib] + calc + _ ≤ Real.log ((below r l).card + 1 : ℝ) - Real.log ((below r' l).card + 1 : ℝ) := by + apply log_drop _ (by positivity) hδ hdrop + exact_mod_cast (card_pos.mpr hn) + _ ≤ ∑ i ∈ range (D+1), + (Real.log ((below r i).card + 1 : ℝ) - Real.log ((below r' i).card + 1 : ℝ)) := by + exact single_le_sum (fun i hi => sub_nonneg.mpr (hle i)) (mem_range.mpr (by omega)) + +theorem below_card_le_of_max {r : Y → ℕ} {l : ℕ} + (hmax : ∀ j ≤ l, (level r j).card ≤ (level r l).card) : + (below r l).card ≤ (l+1)*(level r l).card := by + have heq : below r l = (range (l+1)).biUnion (level r) := by + ext y + simp [below, level] + rw [heq] + calc + _ ≤ ∑ j ∈ range (l+1), (level r j).card := card_biUnion_le + _ ≤ ∑ _j ∈ range (l+1), (level r l).card := + sum_le_sum fun j hj => hmax j (by simpa using hj) + _ = _ := by simp +end FinitePotential + +section State +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +variable [Fintype (Projectivization K V)] +abbrev Points := Projectivization K V +abbrev State := Points (K:=K) (V:=V) → Submodule K V +noncomputable def ranks (W : State (K:=K) (V:=V)) (y : Points (K:=K) (V:=V)) : ℕ := + Module.finrank K (W y) + +noncomputable def update (W : State (K:=K) (V:=V)) + (a : Module.Dual K V) (b : Points (K:=K) (V:=V)) : State (K:=K) (V:=V) := + fun y => if a y.rep = 0 then W y ⊔ b.submodule else W y + +omit [FiniteDimensional K V] [Fintype (Projectivization K V)] in +theorem le_update (W : State (K:=K) (V:=V)) (a : Module.Dual K V) + (b y : Points (K:=K) (V:=V)) : W y ≤ update W a b y := by + unfold update + split_ifs + · exact le_sup_left + · exact le_rfl + +omit [Fintype (Projectivization K V)] in +theorem ranks_update_mono (W : State (K:=K) (V:=V)) (a : Module.Dual K V) + (b y : Points (K:=K) (V:=V)) : ranks W y ≤ ranks (update W a b) y := + Submodule.finrank_mono (le_update W a b y) + +omit [Fintype (Projectivization K V)] in +theorem ranks_lt_update (W : State (K:=K) (V:=V)) (a : Module.Dual K V) + (b y : Points (K:=K) (V:=V)) (ha : a y.rep = 0) (hb : ¬ b.submodule ≤ W y) : + ranks W y < ranks (update W a b) y := by + apply Submodule.finrank_lt_finrank_of_lt + rw [update, ite_eq_left ha] + refine lt_of_le_of_ne le_sup_left ?_ + intro he + apply hb + have h : b.submodule ≤ W y ⊔ b.submodule := le_sup_right + rwa [← he] at h + +def Popular (W : State (K:=K) (V:=V)) (q : ℝ) (l : ℕ) + (b : Points (K:=K) (V:=V)) : Prop := + ((level (ranks W) l).card : ℝ)/(16*q) ≤ + ((level (ranks W) l).filter (fun y => b.submodule ≤ W y)).card + +def Poor (W : State (K:=K) (V:=V)) (q : ℝ) (l : ℕ) + (a : Module.Dual K V) : Prop := + (((level (ranks W) l).filter (fun y => a y.rep = 0)).card : ℝ) ≤ + (level (ranks W) l).card/(8*q) + +theorem expensive_drop (W : State (K:=K) (V:=V)) {q : ℝ} (hq : 0 < q) + {l D : ℕ} (hl : l ≤ D) + (hmax : ∀ j ≤ l, (level (ranks W) j).card ≤ (level (ranks W) l).card) + (a : Module.Dual K V) (b : Points (K:=K) (V:=V)) + (hp : ¬ Popular W q l b) (hr : ¬ Poor W q l a) : + (1/(32*(D+1)*q) : ℝ) ≤ + potential D (ranks W) - potential D (ranks (update W a b)) := by + let Z := level (ranks W) l + let H := Z.filter (fun y => a y.rep = 0) + let B := Z.filter (fun y => b.submodule ≤ W y) + have hp' : (B.card:ℝ) < Z.card/(16*q) := lt_of_not_ge hp + have hr' : Z.card/(8*q) < (H.card:ℝ) := lt_of_not_ge hr + have hZ : Z.Nonempty := by + apply card_pos.mp + by_contra! hz + have hz0 : Z.card = 0 := by omega + have hB0 : B.card = 0 := by apply Nat.eq_zero_of_le_zero; rw [← hz0]; exact card_filter_le _ _ + rw [hz0, hB0] at hp' + simp at hp' + have hU := below_card_le_of_max hmax + have hUD : (below (ranks W) l).card ≤ (D+1)*Z.card := + hU.trans (Nat.mul_le_mul_right _ (by omega)) + have hset : below (ranks (update W a b)) l ⊆ below (ranks W) l \ (H \ B) := by + intro y hy + refine mem_sdiff.mpr ⟨below_antitone (ranks_update_mono W a b) l hy, ?_⟩ + intro hb + obtain ⟨hyH, hyB⟩ := mem_sdiff.mp hb + obtain ⟨hyZ, ha⟩ := mem_filter.mp hyH + have ranky : ranks W y = l := by simpa [Z, level] using hyZ + have hby : ¬ b.submodule ≤ W y := fun hb => hyB (mem_filter.mpr ⟨hyZ,hb⟩) + have hgt := ranks_lt_update W a b y ha hby + have hle : ranks (update W a b) y ≤ l := by simpa [below] using hy + omega + have hHB : H \ B ⊆ below (ranks W) l := by + intro y hy + have hz := (mem_filter.mp (mem_sdiff.mp hy).1).1 + simp only [Z, level, mem_filter, mem_univ, true_and] at hz + simpa only [below, mem_filter, mem_univ, true_and] using hz.le + have hcard : (below (ranks (update W a b)) l).card + (H \ B).card ≤ + (below (ranks W) l).card := by + have hc := card_le_card hset + rw [card_sdiff_of_subset hHB] at hc + have hsmall := card_le_card hHB + omega + have hdiff : (H.card:ℝ) - B.card ≤ ((H \ B).card:ℝ) := by + have hc : H.card ≤ (H \ B).card + B.card := card_le_card_sdiff_add_card + have hc' : (H.card:ℝ) ≤ (H \ B).card + B.card := by exact_mod_cast hc + linarith + have hpos : (0:ℝ) < D+1 := by positivity + have hfrac : ((below (ranks W) l).card : ℝ)/(16*(D+1)*q) ≤ + (H.card:ℝ)-B.card := by + have hUD' : ((below (ranks W) l).card : ℝ) ≤ (D+1)*Z.card := by exact_mod_cast hUD + have h1 : ((below (ranks W) l).card : ℝ)/(16*(D+1)*q) ≤ Z.card/(16*q) := by + apply (div_le_iff₀ (by positivity : (0:ℝ) < 16*(D+1)*q)).mpr + field_simp + nlinarith + have h2 : Z.card/(16*q) < (H.card:ℝ)-B.card := by + have he : (Z.card:ℝ)/(8*q) = 2*(Z.card/(16*q)) := by field_simp; ring + linarith + exact h1.trans h2.le + have hbelow : (below (ranks W) l).Nonempty := by + obtain ⟨y,hy⟩ := hZ + refine ⟨y,?_⟩ + have hz : ranks W y = l := by simpa [Z, level] using hy + simp [below,hz] + have Hdrop := potential_drop hl (ranks_update_mono W a b) hbelow + (by positivity : (0:ℝ) ≤ 1/(16*(D+1)*q)) + have hc' : ((below (ranks (update W a b)) l).card : ℝ) + (H \ B).card ≤ + (below (ranks W) l).card := by exact_mod_cast hcard + have Hdrop' := Hdrop (by + rw [one_div_mul_eq_div] + linarith : ((below (ranks (update W a b)) l).card : ℝ) ≤ + (below (ranks W) l).card - 1/(16*(D+1)*q)*(below (ranks W) l).card) + convert Hdrop' using 1; field_simp; ring + +noncomputable def chosenLevel (W : State (K:=K) (V:=V)) + (b : Points (K:=K) (V:=V)) : ℕ := + Classical.choose ((range (ranks W b + 1)).exists_max_image + (fun l => (level (ranks W) l).card) ⟨0, by simp⟩) + +omit [FiniteDimensional K V] in +theorem chosenLevel_spec (W : State (K:=K) (V:=V)) + (b : Points (K:=K) (V:=V)) : + chosenLevel W b ≤ ranks W b ∧ + ∀ j ≤ ranks W b, (level (ranks W) j).card ≤ (level (ranks W) (chosenLevel W b)).card := by + have h := Classical.choose_spec ((range (ranks W b + 1)).exists_max_image + (fun l => (level (ranks W) l).card) ⟨0, by simp⟩) + simpa only [chosenLevel, mem_range, Nat.lt_succ_iff] using h + +def IsExpensive (W : State (K:=K) (V:=V)) (q : ℝ) + (f : Module.Dual K V × Points (K:=K) (V:=V)) : Prop := + ¬ Popular W q (chosenLevel W f.2) f.2 ∧ ¬ Poor W q (chosenLevel W f.2) f.1 + +noncomputable def scan (q : ℝ) : State (K:=K) (V:=V) → + List (Module.Dual K V × Points (K:=K) (V:=V)) → ℕ × State (K:=K) (V:=V) + | W, [] => (0,W) + | W, f :: fs => + if IsExpensive W q f then + let p := scan q (update W f.1 f.2) fs + (p.1+1,p.2) + else scan q W fs + +theorem scan_potential_bound (q : ℝ) (hq : 0 < q) + (W : State (K:=K) (V:=V)) (fs : List (Module.Dual K V × Points (K:=K) (V:=V))) : + ((scan q W fs).1:ℝ) / (32*(Module.finrank K V+1)*q) ≤ + potential (Module.finrank K V) (ranks W) - + potential (Module.finrank K V) (ranks (scan q W fs).2) := by + induction fs generalizing W with + | nil => simp [scan] + | cons f fs ih => + by_cases he : IsExpensive W q f + · simp only [scan, ite_eq_left he] + have hL := chosenLevel_spec W f.2 + have hD : chosenLevel W f.2 ≤ Module.finrank K V := + hL.1.trans (Submodule.finrank_le _) + have hd := expensive_drop W hq hD + (fun j hj => hL.2 _ (hj.trans hL.1)) f.1 f.2 he.1 he.2 + have hi := ih (update W f.1 f.2) + push_cast + rw [add_div] + linarith + · simpa only [scan, ite_eq_right he] using ih W + +theorem scan_expensive_bound (q : ℝ) (hq : 0 < q) + (W : State (K:=K) (V:=V)) (fs : List (Module.Dual K V × Points (K:=K) (V:=V))) : + ((scan q W fs).1:ℝ) ≤ + 32*(Module.finrank K V+1)^2*q*Real.log (Fintype.card (Points (K:=K) (V:=V))+1 : ℝ) := by + have h := scan_potential_bound q hq W fs + have hn := potential_nonneg (Module.finrank K V) (ranks (scan q W fs).2) + have hu := potential_le (Module.finrank K V) (ranks W) + have hden : (0:ℝ) < 32*(Module.finrank K V+1)*q := by positivity + have h' : ((scan q W fs).1:ℝ)/(32*(Module.finrank K V+1)*q) ≤ + (Module.finrank K V+1)*Real.log (Fintype.card (Points (K:=K) (V:=V))+1 : ℝ) := by + linarith + have h'' := (div_le_iff₀ hden).mp h' + convert h'' using 1 + first | rfl | ring + +omit [FiniteDimensional K V] [Fintype (Projectivization K V)] in + +theorem update_le_ker (W : State (K:=K) (V:=V)) + (a a' : Module.Dual K V) (b y : Points (K:=K) (V:=V)) + (hW : W y ≤ LinearMap.ker a') (hcons : a y.rep = 0 → a' b.rep = 0) : + update W a b y ≤ LinearMap.ker a' := by + unfold update + split_ifs with ha + · apply sup_le hW + rw [Projectivization.submodule_eq, Submodule.span_singleton_le_iff_mem] + exact hcons ha + · exact hW + +noncomputable def historyState : List (Module.Dual K V × Points (K:=K) (V:=V)) → State (K:=K) (V:=V) + | [] => fun _ => ⊥ + | f::fs => update (historyState fs) f.1 f.2 + +omit [FiniteDimensional K V] [Fintype (Projectivization K V)] in +theorem historyState_le_ker (fs : List (Module.Dual K V × Points (K:=K) (V:=V))) + (a : Module.Dual K V) (y : Points (K:=K) (V:=V)) + (hcons : ∀ f ∈ fs, f.1 y.rep = 0 → a f.2.rep = 0) : + historyState fs y ≤ LinearMap.ker a := by + induction fs with + | nil => exact bot_le + | cons f fs ih => + apply update_le_ker + · exact ih (fun f hf => hcons f (List.mem_cons_of_mem _ hf)) + · exact hcons f (List.mem_cons_self) + +omit [Fintype (Projectivization K V)] in +theorem historyState_rank_bound (fs : List (Module.Dual K V × Points (K:=K) (V:=V))) + (a : Module.Dual K V) (ha : a ≠ 0) (y : Points (K:=K) (V:=V)) + (hcons : ∀ f ∈ fs, f.1 y.rep = 0 → a f.2.rep = 0) : + ranks (historyState fs) y < Module.finrank K V := by + have hm := Submodule.finrank_mono (historyState_le_ker fs a y hcons) + have hk := Module.Dual.finrank_ker_add_one_of_ne_zero ha + unfold ranks + omega + +end State +end SharpLogRamsey.Marking + +namespace SharpLogRamsey.Marking +open SharpLogRamsey.Incidence +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] +variable [Finite K] [FiniteDimensional K V] +variable [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + +theorem geom_sum_le_twice {q : ℝ} (hq : 2 ≤ q) (r : ℕ) : + (∑ i ∈ range (r+1), q^i) ≤ 2*q^r := by + induction r with + | zero => simp + | succ r ih => + rw [sum_range_succ, pow_succ] + have hp : 0 ≤ q^r := pow_nonneg (by linarith) _ + nlinarith [mul_le_mul_of_nonneg_right hq hp] + +omit [Fintype (Projectivization K (Module.Dual K V))] in +omit [FiniteDimensional K V] in +theorem card_subspace_points_le (W : Submodule K V) {r : ℕ} + (hW : Module.finrank K W = r+1) : + ((univ.filter (fun b : Points (K:=K) (V:=V) => b.submodule ≤ W)).card:ℝ) ≤ + 2*(Nat.card K:ℝ)^r := by + have hc : (univ.filter (fun b : Points (K:=K) (V:=V) => b.submodule ≤ W)).card = + ∑ i ∈ range (r+1), Nat.card K^i := by + rw [← Fintype.card_subtype, ← Nat.card_eq_fintype_card, + ← Nat.card_congr (projectiveSubmoduleEquiv W)] + exact Projectivization.card_of_finrank K W hW + rw [hc, Nat.cast_sum] + push_cast + apply geom_sum_le_twice + exact_mod_cast (Finite.one_lt_card : 1 < Nat.card K) + +theorem joint_bound_of_product {n : ℕ} (hdim : Module.finrank K V = n+3) + (S : Finset (Projectivization K V)) + (T : Finset (Projectivization K (Module.Dual K V))) + (hprod : (S.card:ℝ)*T.card ≤ 16*(Nat.card K:ℝ)^(n+3)) : + (incidenceCount S T:ℝ) ≤ 20*(Nat.card K:ℝ)^(n+2) := by + let q : ℝ := Nat.card K + let p : ℝ := (∑ i ∈ range (n+2), q^i)/(∑ i ∈ range (n+3), q^i) + let a : ℝ := (S.card:ℝ)*T.card + have hq : 0 < q := by + change (0:ℝ) < Nat.card K + have h := (Finite.one_lt_card : 1 < Nat.card K) + exact_mod_cast (lt_trans Nat.zero_lt_one h) + have hv : 0 < ∑ i ∈ range (n+3), q^i := by + apply sum_pos' (fun i hi => pow_nonneg hq.le _) + exact ⟨0, by simp, by simp⟩ + have hp : p ≤ 1/q := by + apply (div_le_div_iff₀ hv hq).mpr + have he : (∑ i ∈ range (n+3), q^i) = q*(∑ i ∈ range (n+2), q^i)+1 := geom_sum_succ + linarith + have ha : 0 ≤ a := by positivity + have hm := mul_le_mul_of_nonneg_right hp ha + have hcap : p*a ≤ 16*q^(n+2) := by + have hd : a/q ≤ 16*q^(n+2) := by + apply (div_le_iff₀ hq).mpr + have he : q^(n+3) = q^(n+2)*q := by rw [← pow_succ] + change a ≤ 16*q^(n+3) at hprod + rw [he] at hprod + nlinarith + have he : (1/q)*a = a/q := by ring + rw [he] at hm + exact hm.trans hd + have hs := projective_mixing_sq hdim S T + change ((incidenceCount S T:ℝ)-p*S.card*T.card)^2 ≤ q^(n+1)*S.card*T.card at hs + simp only [mul_assoc] at hs + change ((incidenceCount S T:ℝ)-p*a)^2 ≤ q^(n+1)*a at hs + have hmul := mul_le_mul_of_nonneg_left hprod (pow_nonneg hq.le (n+1)) + have he : q^(n+1)*(16*q^(n+3)) = (4*q^(n+2))^2 := by + rw [mul_left_comm, ← pow_add, mul_pow, ← pow_mul] + congr 1 <;> ring + change q^(n+1)*a ≤ q^(n+1)*(16*q^(n+3)) at hmul + rw [he] at hmul + have hfour : 0 ≤ 4*q^(n+2) := by positivity + have habs := (sq_le_sq₀ (abs_nonneg ((incidenceCount S T:ℝ)-p*a)) hfour).mp + (by simpa using hs.trans hmul) + have hdev := le_abs_self ((incidenceCount S T:ℝ)-p*a) + linarith + +noncomputable def poorDomain (W : State (K:=K) (V:=V)) (l : ℕ) : + Finset (Projectivization K (Module.Dual K V)) := + univ.filter (fun a => Poor W (Nat.card K) l a.rep) + +theorem poor_marginal_product {n : ℕ} (hdim : Module.finrank K V = n+3) + (W : State (K:=K) (V:=V)) (l : ℕ) : + ((level (ranks W) l).card:ℝ)*(poorDomain W l).card ≤ + 16*(Nat.card K:ℝ)^(n+3) := by + apply sparse_product_bound hdim + have hq : (0:ℝ) < Nat.card K := by + exact_mod_cast (Finite.card_pos : 0 < Nat.card K) + calc + (incidenceCount (level (ranks W) l) (poorDomain W l):ℝ) ≤ + ∑ _a ∈ poorDomain W l, ((level (ranks W) l).card:ℝ)/(8*Nat.card K) := by + rw [incidenceCount, Nat.cast_sum] + apply sum_le_sum + intro a ha + have h := (mem_filter.mp ha).2 + exact h + _ = ((level (ranks W) l).card:ℝ)*(poorDomain W l).card/(8*Nat.card K) := by + simp only [sum_const, nsmul_eq_mul]; ring + _ ≤ ((level (ranks W) l).card:ℝ)*(poorDomain W l).card/(4*Nat.card K) := by + apply div_le_div_of_nonneg_left (by positivity) (by positivity) + linarith + +theorem poor_joint_domain_bound {n : ℕ} (hdim : Module.finrank K V = n+3) + (W : State (K:=K) (V:=V)) {l r : ℕ} + (hmax : (level (ranks W) r).card ≤ (level (ranks W) l).card) : + (incidenceCount (level (ranks W) r) (poorDomain W l):ℝ) ≤ + 20*(Nat.card K:ℝ)^(n+2) := by + apply joint_bound_of_product hdim + calc + _ ≤ ((level (ranks W) l).card:ℝ)*(poorDomain W l).card := + mul_le_mul_of_nonneg_right (by exact_mod_cast hmax) (by positivity) + _ ≤ _ := poor_marginal_product hdim W l + +end SharpLogRamsey.Marking + +namespace SharpLogRamsey.Marking +open SharpLogRamsey.Incidence +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] +variable [Finite K] [FiniteDimensional K V] +variable [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + +noncomputable def popularDomain (W : State (K:=K) (V:=V)) (l : ℕ) : Finset (Points (K:=K) (V:=V)) := + univ.filter (Popular W (Nat.card K) l) + +end SharpLogRamsey.Marking +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/MarkingTwoCaps.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/MarkingTwoCaps.lean new file mode 100644 index 0000000000000000000000000000000000000000..df5b4780e30a19b9f768fd3049415644a9d1b443 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/MarkingTwoCaps.lean @@ -0,0 +1,172 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.MarkingCaps + +namespace OAI + +section +namespace SharpLogRamsey.Marking +open scoped BigOperators Classical +open Finset ProjectiveDuality +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [Finite K] [FiniteDimensional K V] [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] + +def twoDomain (W : State (K:=K) (V:=V)) (W' : State (K:=K) (V:=Module.Dual K V)) + (m : RankMask (K:=K) (V:=V)) (m' : RankMask (K:=K) (V:=Module.Dual K V)) : + Finset (ProjectivePair (K:=K) (V:=V)) := + projectiveCheapDomain W m ∩ (projectiveCheapDomain W' m').map pairDuality.symm.toEmbedding + +omit [Finite K] in +lemma twoDomain_forward (W : State (K:=K) (V:=V)) (W' : State (K:=K) (V:=Module.Dual K V)) + (m : RankMask (K:=K) (V:=V)) (m' : RankMask (K:=K) (V:=Module.Dual K V)) : + twoDomain W W' m m' ⊆ projectiveCheapDomain W m := inter_subset_left + +omit [Finite K] in +lemma twoDomain_reverse (W : State (K:=K) (V:=V)) (W' : State (K:=K) (V:=Module.Dual K V)) + (m : RankMask (K:=K) (V:=V)) (m' : RankMask (K:=K) (V:=Module.Dual K V)) : + (twoDomain W W' m m').map pairDuality.toEmbedding ⊆ projectiveCheapDomain W' m' := by + intro f hf + obtain ⟨g,hg,rfl⟩ := mem_map.mp hf + obtain ⟨h,h',he⟩ := mem_map.mp (mem_inter.mp hg).2 + have he' : pairDuality g=h := by rw [←he]; exact pairDuality.apply_symm_apply h + simpa only [Equiv.coe_toEmbedding,he'] using h' + +omit [Finite K] [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma shadow_reverse_first (D : Finset (ProjectivePair (K:=K) (V:=V))) : + (D.map pairDuality.toEmbedding).image Prod.fst = D.image Prod.snd := by + ext a + simp only [mem_image,mem_map] + constructor + · rintro ⟨f,⟨g,hg,hgf⟩,he⟩ + subst f + exact ⟨g,hg,he⟩ + · rintro ⟨g,hg,rfl⟩ + exact ⟨pairDuality g,⟨g,hg,rfl⟩,rfl⟩ + +omit [Finite K] [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma shadow_reverse_second_card (D : Finset (ProjectivePair (K:=K) (V:=V))) : + ((D.map pairDuality.toEmbedding).image Prod.snd).card = (D.image Prod.fst).card := by + have he : (D.map pairDuality.toEmbedding).image Prod.snd = + (D.image Prod.fst).map bidual.toEmbedding := by + ext b + simp only [mem_image,mem_map] + constructor + · rintro ⟨f,⟨g,hg,hgf⟩,he⟩ + subst f + exact ⟨g.1,⟨g,hg,rfl⟩,he⟩ + · rintro ⟨a,⟨g,hg,hga⟩,he⟩ + subst a + refine ⟨pairDuality g,⟨g,hg,rfl⟩,he⟩ + rw [he,card_map] + +theorem twoPopular_caps {d : ℕ} (hdim : Module.finrank K V=d+1) + (W : State (K:=K) (V:=V)) (W' : State (K:=K) (V:=Module.Dual K V)) + (m : RankMask (K:=K) (V:=V)) (m' : RankMask (K:=K) (V:=Module.Dual K V)) + (hm : m.2=.popular) (hm' : m'.2=.popular) : + let D := twoDomain W W' m m' + ((D.image Prod.fst).card:ℝ) ≤ 32*(Nat.card K:ℝ)^m.1.val ∧ + ((D.image Prod.snd).card:ℝ) ≤ 32*(Nat.card K:ℝ)^m'.1.val ∧ + (∀ b,((D.filter (fun f => f.1=b)).card:ℝ) ≤ 2*(Nat.card K:ℝ)^(d-m.1.val)) ∧ + (∀ a,((D.filter (fun f => f.2=a)).card:ℝ) ≤ 2*(Nat.card K:ℝ)^(d-m'.1.val)) := by + dsimp only + have hd' : Module.finrank K (Module.Dual K V)=d+1 := by rwa [Subspace.dual_finrank_eq] + refine ⟨?_,?_,?_,?_⟩ + · exact (show (((twoDomain W W' m m').image Prod.fst).card:ℝ) ≤ + ((projectiveCheapDomain W m).image Prod.fst).card by + exact_mod_cast card_le_card (image_subset_image (twoDomain_forward W W' m m'))).trans + (cheapPopular_first_card W m hm) + · rw [←shadow_reverse_first] + exact (show ((((twoDomain W W' m m').map pairDuality.toEmbedding).image Prod.fst).card:ℝ) ≤ + ((projectiveCheapDomain W' m').image Prod.fst).card by + exact_mod_cast card_le_card (image_subset_image (twoDomain_reverse W W' m m'))).trans + (cheapPopular_first_card W' m' hm') + · intro b + exact (show (((twoDomain W W' m m').filter (fun f => f.1=b)).card:ℝ) ≤ + ((projectiveCheapDomain W m).filter (fun f => f.1=b)).card by + exact_mod_cast card_le_card (filter_subset_filter _ (twoDomain_forward W W' m m'))).trans + (cheapPopular_fiber_card hdim W m hm b) + · intro a + have hsub : ((twoDomain W W' m m').filter (fun f => f.2=a)).map pairDuality.toEmbedding ⊆ + (projectiveCheapDomain W' m').filter (fun f => f.1=a) := by + intro f hf + obtain ⟨g,hg,rfl⟩ := mem_map.mp hf + obtain ⟨hg,hga⟩ := mem_filter.mp hg + exact mem_filter.mpr ⟨twoDomain_reverse W W' m m' (mem_map.mpr ⟨g,hg,rfl⟩),hga⟩ + have hc := card_le_card hsub + rw [card_map] at hc + exact (show (((twoDomain W W' m m').filter (fun f => f.2=a)).card:ℝ) ≤ + ((projectiveCheapDomain W' m').filter (fun f => f.1=a)).card by exact_mod_cast hc).trans + (cheapPopular_fiber_card hd' W' m' hm' a) + +theorem twoPoor_product {n : ℕ} (hdim : Module.finrank K V=n+3) + (W : State (K:=K) (V:=V)) (W' : State (K:=K) (V:=Module.Dual K V)) + (m : RankMask (K:=K) (V:=V)) (m' : RankMask (K:=K) (V:=Module.Dual K V)) + (hm : m.2=.poor ∨ m'.2=.poor) : + (((twoDomain W W' m m').image Prod.fst).card:ℝ)* + ((twoDomain W W' m m').image Prod.snd).card ≤ 16*(Nat.card K:ℝ)^(n+3) := by + have hf : (((twoDomain W W' m m').image Prod.fst).card:ℝ) ≤ + ((projectiveCheapDomain W m).image Prod.fst).card := by + exact_mod_cast card_le_card (image_subset_image (twoDomain_forward W W' m m')) + have hs : (((twoDomain W W' m m').image Prod.snd).card:ℝ) ≤ + ((projectiveCheapDomain W m).image Prod.snd).card := by + exact_mod_cast card_le_card (image_subset_image (twoDomain_forward W W' m m')) + rcases hm with hm|hm + · exact (mul_le_mul hf hs (by positivity) (by positivity)).trans (cheapPoor_product hdim W m hm) + · have hd' : Module.finrank K (Module.Dual K V)=n+3 := by rwa [Subspace.dual_finrank_eq] + have hf' : ((((twoDomain W W' m m').map pairDuality.toEmbedding).image Prod.fst).card:ℝ) ≤ + ((projectiveCheapDomain W' m').image Prod.fst).card := by + exact_mod_cast card_le_card (image_subset_image (twoDomain_reverse W W' m m')) + have hs' : ((((twoDomain W W' m m').map pairDuality.toEmbedding).image Prod.snd).card:ℝ) ≤ + ((projectiveCheapDomain W' m').image Prod.snd).card := by + exact_mod_cast card_le_card (image_subset_image (twoDomain_reverse W W' m m')) + rw [shadow_reverse_first] at hf' + rw [shadow_reverse_second_card] at hs' + rw [mul_comm] + exact (mul_le_mul hf' hs' (by positivity) (by positivity)).trans (cheapPoor_product hd' W' m' hm) + +omit [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma nonempty_cheap_not_expensive (W : State (K:=K) (V:=V)) + (m : RankMask (K:=K) (V:=V)) (h : (projectiveCheapDomain W m).Nonempty) : m.2≠.expensive := by + intro hm + unfold projectiveCheapDomain at h + split_ifs at h + · rw [hm] at h + exact not_nonempty_empty h + · exact not_nonempty_empty h + +theorem twoDomain_cases {d : ℕ} (hdim : Module.finrank K V=d+1) + (W : State (K:=K) (V:=V)) (W' : State (K:=K) (V:=Module.Dual K V)) + (m : RankMask (K:=K) (V:=V)) (m' : RankMask (K:=K) (V:=Module.Dual K V)) + (h : (twoDomain W W' m m').Nonempty) : + m.2=.poor ∨ m'.2=.poor ∨ + (m.2=.popular ∧ m'.2=.popular ∧ 1 ≤ m.1.val ∧ m.1.val≤d ∧ 1 ≤ m'.1.val ∧ m'.1.val≤d) := by + have hf : (projectiveCheapDomain W m).Nonempty := h.mono (twoDomain_forward W W' m m') + have hr : (projectiveCheapDomain W' m').Nonempty := + (h.map (f:=pairDuality.toEmbedding)).mono (twoDomain_reverse W W' m m') + have hf' := nonempty_cheap_not_expensive W m hf + have hr' := nonempty_cheap_not_expensive W' m' hr + by_cases hp : m.2=.poor + · exact Or.inl hp + by_cases hp' : m'.2=.poor + · exact Or.inr (Or.inl hp') + have hpop : m.2=.popular := by cases h : m.2 <;> simp_all + have hpop' : m'.2=.popular := by cases h : m'.2 <;> simp_all + have h₁ := cheapPopular_rank_pos W m hpop hf + have h₂ := cheapPopular_rank_pos W' m' hpop' hr + have h₁' : m.1.val < d+1 := lt_of_lt_of_eq h₁.2 hdim + have h₂' : m'.1.val < d+1 := lt_of_lt_of_eq h₂.2 (Subspace.dual_finrank_eq.trans hdim) + exact Or.inr (Or.inr ⟨hpop,hpop',h₁.1,by omega,h₂.1,by omega⟩) + +end +end SharpLogRamsey.Marking + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/MarkingTwoScans.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/MarkingTwoScans.lean new file mode 100644 index 0000000000000000000000000000000000000000..e31297afecc4ef4b80d7aed416d37b1dfbc3329a --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/MarkingTwoScans.lean @@ -0,0 +1,176 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.MarkingActual +import OAI.Combinatorics.SharpRamsey.Marking.MarkingDeficit + +namespace OAI + +section +namespace SharpLogRamsey.Marking +open scoped BigOperators Classical +open Finset ProjectiveDuality +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] + +def pairDuality : ProjectivePair (K:=K) (V:=V) ≃ + ProjectivePair (K:=K) (V:=Module.Dual K V) where + toFun f := (f.2,bidual f.1) + invFun f := (bidual.symm f.2,f.1) + left_inv f := by simp + right_inv f := by simp + +def reversedPairs {N : ℕ} (F : Fin N → ProjectivePair (K:=K) (V:=V)) : + Fin N → ProjectivePair (K:=K) (V:=Module.Dual K V) := fun i => pairDuality (F i.rev) + +omit [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma reversedPairs_consistent {N : ℕ} (F : Fin N → ProjectivePair (K:=K) (V:=V)) + (hF : ScanConsistent ((List.ofFn F).map toScan)) : + ScanConsistent ((List.ofFn (reversedPairs F)).map toScan) := by + rw [List.map_ofFn] at hF ⊢ + have hh := List.pairwise_ofFn.mp hF + apply List.pairwise_ofFn.mpr + intro i j hij + change Incidence.Incident (F j.rev).2 (bidual (F i.rev).1) → + Incidence.Incident (F i.rev).2 (bidual (F j.rev).1) + simp only [incident_bidual] + exact hh (Fin.rev_lt_rev.mpr hij) + +omit [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma reversedPairs_incident {N : ℕ} (F : Fin N → ProjectivePair (K:=K) (V:=V)) + (hF : ∀ i, Incidence.Incident (F i).1 (F i).2) (i : Fin N) : + Incidence.Incident (reversedPairs F i).1 (reversedPairs F i).2 := + (incident_bidual _ _).mpr (hF i.rev) + +abbrev TwoMask (N : ℕ) := (Fin N → RankMask (K:=K) (V:=V)) × + (Fin N → RankMask (K:=K) (V:=Module.Dual K V)) + +def twoMask {N : ℕ} (q : ℝ) (F : Fin N → ProjectivePair (K:=K) (V:=V)) : TwoMask (K:=K) (V:=V) N := + (tupleMask q F,tupleMask q (reversedPairs F)) + +def bothExpensive {N : ℕ} (m : TwoMask (K:=K) (V:=V) N) : Finset (Fin N) := + expensiveMask m.1 ∪ (expensiveMask m.2).image Fin.rev + +omit [FiniteDimensional K V] [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma bothExpensive_mem {N : ℕ} (m : TwoMask (K:=K) (V:=V) N) (i : Fin N) : + i∈bothExpensive m ↔ i∈expensiveMask m.1 ∨ i.rev∈expensiveMask m.2 := by + simp only [bothExpensive,mem_union,mem_image] + constructor + · rintro (h|⟨j,hj,hji⟩) + · exact Or.inl h + · right + simpa only [←hji,Fin.rev_rev] using hj + · rintro (h|h) + · exact Or.inl h + · exact Or.inr ⟨i.rev,h,Fin.rev_rev i⟩ + +abbrev TwoMessage (Γ : Type*) (N : ℕ) := + (Fin N → Option (ProjectivePair (K:=K) (V:=V))) × (Γ × TwoMask (K:=K) (V:=V) N) + +def firstMessage {Γ : Type*} {N : ℕ} (z : TwoMessage (K:=K) (V:=V) Γ N) : + (Fin N → Option (ProjectivePair (K:=K) (V:=V))) × + (Γ × (Fin N → RankMask (K:=K) (V:=V))) := + (fun i => if i∈expensiveMask z.2.2.1 then z.1 i else none,(z.2.1,z.2.2.1)) + +def secondMessage {Γ : Type*} {N : ℕ} (z : TwoMessage (K:=K) (V:=V) Γ N) : + (Fin N → Option (ProjectivePair (K:=K) (V:=Module.Dual K V))) × + (Γ × (Fin N → RankMask (K:=K) (V:=Module.Dual K V))) := + (fun i => if i∈expensiveMask z.2.2.2 then (z.1 i.rev).map pairDuality else none,(z.2.1,z.2.2.2)) + +def cheapBoth {Γ : Type*} {N : ℕ} (z : TwoMessage (K:=K) (V:=V) Γ N) (i : Fin N) : + Finset (ProjectivePair (K:=K) (V:=V)) := + cheapTuple (firstMessage z) i ∩ (cheapTuple (secondMessage z) i.rev).map pairDuality.symm.toEmbedding + +omit [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma firstMessage_actual {Ω Γ : Type*} {N : ℕ} (C : Ω → Γ) + (F : Ω → Fin N → ProjectivePair (K:=K) (V:=V)) (x : Ω) (q : ℝ) : + firstMessage (Selection.markingMessage C (fun x => twoMask q (F x)) bothExpensive F x) = + (Selection.maskedValues (expensiveMask (tupleMask q (F x))) (F x), + (C x,tupleMask q (F x))) := by + apply Prod.ext + · funext i + change (if i∈expensiveMask (tupleMask q (F x)) then + Selection.maskedValues (bothExpensive (twoMask q (F x))) (F x) i else none)=_ + by_cases hi : i∈expensiveMask (tupleMask q (F x)) + · have hb : i∈bothExpensive (twoMask q (F x)) := (bothExpensive_mem _ _).mpr (Or.inl hi) + simp only [hi,ite_true,Selection.maskedValues,hb] + · simp only [hi,ite_false,Selection.maskedValues] + · rfl + +omit [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma secondMessage_actual {Ω Γ : Type*} {N : ℕ} (C : Ω → Γ) + (F : Ω → Fin N → ProjectivePair (K:=K) (V:=V)) (x : Ω) (q : ℝ) : + secondMessage (Selection.markingMessage C (fun x => twoMask q (F x)) bothExpensive F x) = + (Selection.maskedValues (expensiveMask (tupleMask q (reversedPairs (F x)))) + (reversedPairs (F x)),(C x,tupleMask q (reversedPairs (F x)))) := by + apply Prod.ext + · funext i + change (if i∈expensiveMask (tupleMask q (reversedPairs (F x))) then + (Selection.maskedValues (bothExpensive (twoMask q (F x))) (F x) i.rev).map pairDuality + else none)=_ + by_cases hi : i∈expensiveMask (tupleMask q (reversedPairs (F x))) + · have hb : i.rev∈bothExpensive (twoMask q (F x)) := by + apply (bothExpensive_mem _ _).mpr + right + simpa only [Fin.rev_rev,twoMask] using hi + simp only [hi,ite_true,Selection.maskedValues,hb,Option.map_some,reversedPairs] + · simp only [hi,ite_false,Selection.maskedValues] + · rfl + +lemma cheapBoth_mem {Ω Γ : Type*} {N : ℕ} (C : Ω → Γ) + (F : Ω → Fin N → ProjectivePair (K:=K) (V:=V)) (x : Ω) + (hcons : ScanConsistent ((List.ofFn (F x)).map toScan)) + (hinc : ∀ i, Incidence.Incident (F x i).1 (F x i).2) (i : Fin N) + (hi : i∉bothExpensive (twoMask (Nat.card K) (F x))) : + F x i∈cheapBoth (Selection.markingMessage C (fun x => twoMask (Nat.card K) (F x)) + bothExpensive F x) i := by + have hn := not_or.mp ((bothExpensive_mem _ _).not.mp hi) + apply mem_inter.mpr + constructor + · change F x i∈cheapTuple (firstMessage _) i + rw [firstMessage_actual] + exact cheapTuple_mem (C x) (F x) hcons hinc i hn.1 + · change F x i∈(cheapTuple (secondMessage _) i.rev).map pairDuality.symm.toEmbedding + rw [secondMessage_actual] + apply mem_map.mpr + refine ⟨reversedPairs (F x) i.rev,?_,?_⟩ + · exact cheapTuple_mem (C x) (reversedPairs (F x)) (reversedPairs_consistent _ hcons) + (reversedPairs_incident _ hinc) i.rev hn.2 + · simp only [Equiv.coe_toEmbedding,reversedPairs,Fin.rev_rev,Equiv.symm_apply_apply] + +variable [Finite K] +lemma cheapBoth_card {Γ : Type*} {N n : ℕ} (hdim : Module.finrank K V=n+3) + (z : TwoMessage (K:=K) (V:=V) Γ N) (i : Fin N) : + ((cheapBoth z i).card:ℝ) ≤ 64*(Nat.card K:ℝ)^(n+2) := by + have h : ((cheapBoth z i).card:ℝ) ≤ (cheapTuple (firstMessage z) i).card := by + exact_mod_cast (card_le_card (inter_subset_left : cheapBoth z i⊆_)) + exact h.trans (cheapTuple_card hdim (firstMessage z) i) + +lemma cheapBoth_log_card {Γ : Type*} {N n : ℕ} (hdim : Module.finrank K V=n+3) + (z : TwoMessage (K:=K) (V:=V) Γ N) (i : Fin N) : + Real.log (cheapBoth z i).card≤Real.log (64*(Nat.card K:ℝ)^(n+2)) := by + by_cases hz : (cheapBoth z i).card=0 + · rw [hz,Nat.cast_zero,Real.log_zero] + have hq : (1:ℝ)≤Nat.card K := by exact_mod_cast (Finite.one_lt_card : 1.trans (Nat.add_le_add_left (card_image_le) _) + +end +end SharpLogRamsey.Marking + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/MultiplicityClass.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/MultiplicityClass.lean new file mode 100644 index 0000000000000000000000000000000000000000..d3c66426e13a1fd695f3afc3dc56267b27633533 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/MultiplicityClass.lean @@ -0,0 +1,97 @@ +import Mathlib + +namespace OAI + +section +namespace SharpLogRamsey.MultiplicityClass +open Finset +open scoped Classical BigOperators +noncomputable section +variable {α β : Type*} + +def weight (S : Finset α) (f : α→β) (y : β) : ℕ := (S.filter (fun x => f x=y)).card + +def domain (U : Finset α) (f : α→β) (h : ℕ) : Finset β := + (U.image f).filter (fun y => h≤weight U f y) + +lemma weight_mono (S U : Finset α) (hSU : S⊆U) (f : α→β) (y : β) : + weight S f y≤weight U f y := card_le_card (filter_subset_filter _ hSU) + +lemma weight_pos (S : Finset α) (f : α→β) (x : α) (hx : x∈S) : + 0 (mem_filter.mp hy).2) + _ ≤ ∑ y∈U.image f,weight U f y := sum_le_sum_of_subset (filter_subset _ _) + _ = U.card := (card_eq_sum_card_fiberwise (fun x hx => mem_image_of_mem f hx)).symm + +theorem exists_class (S U : Finset α) (hS : S.Nonempty) (hSU : S⊆U) + (f : α→β) (q : ℕ) (hq : 1≤q) (hf : ∀ y,weight S f y≤q) : + ∃ (h : ℕ) (T : Finset β), 1≤h ∧ h≤q ∧ T.Nonempty ∧ + T⊆domain U f h ∧ T⊆S.image f ∧ + (S.card:ℝ)≤2*h*(Nat.log 2 q+1:ℕ)*(T.card:ℝ) ∧ + ∀ y∈T,h≤weight S f y ∧ weight S f y<2*h := by + let lab : α→ℕ := fun x => Nat.log 2 (weight S f (f x)) + let N := Nat.log 2 q+1 + have hN : 0 lab x=k) + let T := A.image f + let h := 2^k + have hh : 1≤h := Nat.one_le_pow _ _ (by omega) + have hkq : k≤Nat.log 2 q := by have := mem_range.mp hk; dsimp [N] at this; omega + have hq' : h≤q := + (Nat.pow_le_pow_right (by omega : 0<2) hkq).trans (Nat.pow_log_le_self 2 (by omega)) + have ha : A.Nonempty := by + apply card_pos.mp + have hsp : (0:ℝ) mem_image_of_mem f hx) (2*h) + intro y hy + exact (weight_mono A S (filter_subset _ _) f y).trans (hweights y hy).2.le + have hab' : (A.card:ℝ)≤2*h*(T.card:ℝ) := by exact_mod_cast hab + have hk' : (S.card:ℝ)≤(A.card:ℝ)*N := (div_le_iff₀ (by exact_mod_cast hN)).mp hkcard + have hm := mul_le_mul_of_nonneg_right hab' (Nat.cast_nonneg N) + dsimp [N] at hm hk' + push_cast at hm hk' ⊢ + nlinarith + +end +end SharpLogRamsey.MultiplicityClass + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/OrderedClassLaw.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/OrderedClassLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..14c42a9ef666b54975ae11a956790dde009c97dc --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/OrderedClassLaw.lean @@ -0,0 +1,122 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.MarkingGeometricClass + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical BigOperators +noncomputable section +variable {Ω Γ α β : Type*} [Fintype Ω] [Fintype Γ] [Fintype α] [Fintype β] + +omit [Fintype Γ] in +lemma Law.map_congr_support (p : Law Ω) (f g : Ω→α) + (h : ∀ x,p.mass x≠0→f x=g x) : p.map f=p.map g := by + ext y + change (∑ x with f x=y,p.mass x)=(∑ x with g x=y,p.mass x) + simp only [sum_filter] + apply sum_congr rfl + intro x _ + by_cases hx : p.mass x=0 + · simp only [hx,ite_self] + · rw [h x hx] + +omit [Fintype Ω] [Fintype Γ] [Fintype α] [Fintype β] in + +def chosenOrder {N m : ℕ} (S : Γ→Finset (Fin N)) (hm : m≤N) (z : Γ) : Fin m ↪o Fin N := + if hs : (S z).card=m then (S z).orderEmbOfFin hs else Fin.castLEOrderEmb hm + +omit [Fintype Ω] [Fintype Γ] [Fintype α] [Fintype β] in +lemma chosenOrder_mem {N m : ℕ} (S : Γ→Finset (Fin N)) (hm : m≤N) (z : Γ) + (hs : (S z).card=m) (i : Fin m) : chosenOrder S hm z i∈S z := by + rw [chosenOrder,dite_eq_left hs] + exact orderEmbOfFin_mem _ _ _ + +omit [Fintype Ω] [Fintype Γ] [Fintype α] [Fintype β] in +def orderedTuple {N m : ℕ} (S : Γ→Finset (Fin N)) (hm : m≤N) + (θ : Ω→Γ) (F : Ω→Fin N→α) : Ω→Fin m→α := + fun x i=>F x (chosenOrder S hm (θ x) i) + +omit [Fintype β] in + +theorem ordered_cond_entropy {N m : ℕ} (p : Law Ω) (θ : Ω→Γ) (F : Ω→Fin N→α) + (S : Γ→Finset (Fin N)) (hm : m≤N) (z : Γ) + (hz : (p.map θ).mass z≠0) (hs : (S z).card=m) : + entropy ((p.cond θ z).map (orderedTuple S hm θ F))= + entropy (((p.cond θ z).map F).restrict (S z)) := by + let e := (S z).orderIsoOfFin hs + let relabel : (S z→α)→(Fin m→α) := fun f i=>f (e i) + have hi : Function.Injective relabel := by + intro f g h + funext i + obtain ⟨j,rfl⟩ := e.surjective i + exact congrFun h j + have he : (p.cond θ z).map (orderedTuple S hm θ F)= + (((p.cond θ z).map F).restrict (S z)).map relabel := by + rw [Law.restrict,Law.map_map,Law.map_map] + apply Law.map_congr_support + intro x hx + have hxθ := (p.cond_support θ z hz x hx).2 + funext i + simp only [orderedTuple,hxθ,chosenOrder,dite_eq_left hs,Function.comp_apply,relabel,e] + rfl + rw [he] + exact entropy_map_eq_of_injective _ relabel hi + +omit [Fintype β] in + +theorem ordered_deficit {N m : ℕ} (p : Law Ω) (θ : Ω→Γ) (F : Ω→Fin N→α) + (S : Γ→Finset (Fin N)) (hm : m≤N) + (hs : ∀ z,(p.map θ).mass z≠0→(S z).card=m) (J : ℝ) : + (∑ z,(p.map θ).mass z*((m:ℝ)*J- + entropy ((p.cond θ z).map (orderedTuple S hm θ F))))= + selectedDeficit p θ F S J := by + unfold selectedDeficit + apply sum_congr rfl + intro z _ + by_cases hz : (p.map θ).mass z=0 + · simp only [hz,zero_mul] + · rw [ordered_cond_entropy p θ F S hm z hz (hs z hz),hs z hz] + congr! + +omit [Fintype α] [Fintype β] in + +lemma ordered_support {N m : ℕ} (p : Law Ω) (θ : Ω→Γ) (F : Ω→Fin N→α) + (S : Γ→Finset (Fin N)) (hm : m≤N) (D : Γ→Fin N→Finset α) + (hs : ∀ z,(p.map θ).mass z≠0→(S z).card=m) + (hD : ∀ x,p.mass x≠0→∀ i∈S (θ x),F x i∈D (θ x) i) + (x : Ω) (hx : p.mass x≠0) (i : Fin m) : + orderedTuple S hm θ F x i∈D (θ x) (chosenOrder S hm (θ x) i) := by + apply hD x hx + exact chosenOrder_mem S hm (θ x) (hs _ (ne_of_gt + (lt_of_lt_of_le (lt_of_le_of_ne (p.nonneg x) (Ne.symm hx)) (p.le_map θ x)))) i + +end +end SharpLogRamsey.Selection + +namespace SharpLogRamsey.Marking +open Finset +open scoped Classical +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + +omit [FiniteDimensional K V] in + +lemma scanConsistent_ordered {N m : ℕ} + (F : Fin N→ProjectivePair (K:=K) (V:=V)) + (hF : ScanConsistent ((List.ofFn F).map toScan)) (e : Fin m ↪o Fin N) : + ScanConsistent ((List.ofFn (fun i=>F (e i))).map toScan) := by + unfold ScanConsistent at hF ⊢ + rw [List.map_ofFn] at hF ⊢ + apply List.pairwise_ofFn.mpr + intro i j hij + exact List.pairwise_ofFn.mp hF (e.strictMono hij) + +end +end SharpLogRamsey.Marking + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/Popular.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/Popular.lean new file mode 100644 index 0000000000000000000000000000000000000000..87dc80044542083c9a2ee09523c8bfee146803e0 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/Popular.lean @@ -0,0 +1,518 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.MarkingOrientation + +namespace OAI + +section +open scoped BigOperators Classical +open Finset +namespace SharpLogRamsey.Marking +open SharpLogRamsey.Incidence +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] +variable [Finite K] [FiniteDimensional K V] +variable [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] +omit [Fintype (Projectivization K (Module.Dual K V))] in +theorem popular_zero (W : State (K:=K) (V:=V)) + (hZ : (level (ranks W) 0).Nonempty) : popularDomain W 0 = ∅ := by + apply eq_empty_iff_forall_notMem.mpr + intro b hb + have hp := (mem_filter.mp hb).2 + have hempty : (level (ranks W) 0).filter (fun y => b.submodule ≤ W y) = ∅ := by + apply eq_empty_iff_forall_notMem.mpr + intro y hy + have hr : Module.finrank K (W y) = 0 := by simpa [level,ranks] using (mem_filter.mp hy).1 + have hz : W y = ⊥ := Submodule.finrank_eq_zero.mp hr + have hh := (mem_filter.mp hy).2 + rw [hz] at hh + apply b.rep_nonzero + have hm : b.rep ∈ b.submodule := by + rw [Projectivization.submodule_eq] + exact Submodule.mem_span_singleton_self _ + exact hh hm + unfold Popular at hp + rw [hempty, card_empty, Nat.cast_zero] at hp + have hq : (0:ℝ) < Nat.card K := by exact_mod_cast (Finite.card_pos : 0 < Nat.card K) + have hn : (0:ℝ) < (level (ranks W) 0).card := by exact_mod_cast card_pos.mpr hZ + exact (not_le_of_gt (div_pos hn (by positivity))) hp + +omit [FiniteDimensional K V] [Fintype (Projectivization K (Module.Dual K V))] in +theorem popular_card (W : State (K:=K) (V:=V)) (l : ℕ) + (hZ : (level (ranks W) (l+1)).Nonempty) : + ((popularDomain W (l+1)).card:ℝ) ≤ 32*(Nat.card K:ℝ)^(l+1) := by + let Z := level (ranks W) (l+1) + let B := popularDomain W (l+1) + let q : ℝ := Nat.card K + have hq : 0 < q := by + change (0:ℝ) < Nat.card K + exact_mod_cast (Finite.card_pos : 0 < Nat.card K) + have hZpos : (0:ℝ) < Z.card := by exact_mod_cast card_pos.mpr hZ + have hdouble : ∑ b ∈ B, ((Z.filter (fun y => b.submodule ≤ W y)).card:ℝ) = + ∑ y ∈ Z, ((B.filter (fun b => b.submodule ≤ W y)).card:ℝ) := by + simp only [card_filter, Nat.cast_sum, Nat.cast_ite, Nat.cast_one, Nat.cast_zero] + exact sum_comm + have hcount : (B.card:ℝ) * ((Z.card:ℝ)/(16*q)) ≤ (Z.card:ℝ)*(2*q^l) := by + calc + _ = ∑ _b ∈ B, ((Z.card:ℝ)/(16*q)) := by simp + _ ≤ ∑ b ∈ B, ((Z.filter (fun y => b.submodule ≤ W y)).card:ℝ) := by + apply sum_le_sum + intro b hb + exact (mem_filter.mp hb).2 + _ = ∑ y ∈ Z, ((B.filter (fun b => b.submodule ≤ W y)).card:ℝ) := hdouble + _ ≤ ∑ _y ∈ Z, 2*q^l := by + apply sum_le_sum + intro y hy + have hr : Module.finrank K (W y) = l+1 := by + change y ∈ level (ranks W) (l+1) at hy + exact (mem_filter.mp hy).2 + have hc := card_subspace_points_le (W y) hr + exact (show ((B.filter (fun b => b.submodule ≤ W y)).card:ℝ) ≤ + ((univ.filter (fun b : Points (K:=K) (V:=V) => b.submodule ≤ W y)).card:ℝ) by + exact_mod_cast card_le_card (filter_subset_filter _ (subset_univ B))).trans hc + _ = _ := by simp + have hm := (mul_le_mul_of_nonneg_right hcount (show 0 ≤ 16*q by positivity)) + have he : (B.card:ℝ)*((Z.card:ℝ)/(16*q))*(16*q) = (B.card:ℝ)*Z.card := by + field_simp + rw [he] at hm + change (B.card:ℝ) ≤ 32*q^(l+1) + rw [pow_succ] + have hh : (B.card:ℝ)*Z.card ≤ (32*(q^l*q))*Z.card := by nlinarith + nlinarith + +noncomputable def partnerDomain (W : Submodule K V) : + Finset (Projectivization K (Module.Dual K V)) := + univ.filter (fun a => W ≤ LinearMap.ker a.rep) + +omit [Fintype (Projectivization K V)] in +theorem partner_card {d r : ℕ} (hdim : Module.finrank K V = d+1) + (W : Submodule K V) (hW : Module.finrank K W = r) (hr : r ≤ d) : + ((partnerDomain W).card:ℝ) ≤ 2*(Nat.card K:ℝ)^(d-r) := by + have he : partnerDomain W = univ.filter (fun a => a.submodule ≤ W.dualAnnihilator) := by + ext a + simp only [partnerDomain, mem_filter, mem_univ, true_and, + Projectivization.submodule_eq, Submodule.span_singleton_le_iff_mem, + Submodule.mem_dualAnnihilator] + rfl + rw [he] + apply card_subspace_points_le + have h := Subspace.finrank_add_finrank_dualAnnihilator_eq W + omega + +noncomputable def popularJoint (W : State (K:=K) (V:=V)) (l r : ℕ) : + Finset (Points (K:=K) (V:=V) × Projectivization K (Module.Dual K V)) := + (popularDomain W l).biUnion (fun b => + if ranks W b = r then (partnerDomain (W b)).image (Prod.mk b) else ∅) + +theorem popular_joint_card {d l r : ℕ} (hdim : Module.finrank K V = d+1) + (W : State (K:=K) (V:=V)) (hl : l ≤ r) (hr : r ≤ d) + (hZ : (level (ranks W) l).Nonempty) : + ((popularJoint W l r).card:ℝ) ≤ 64*(Nat.card K:ℝ)^d := by + cases l with + | zero => simp [popularJoint, popular_zero W hZ] + | succ l => + let q : ℝ := Nat.card K + have hq : 1 ≤ q := by + change (1:ℝ) ≤ Nat.card K + exact_mod_cast (Finite.one_lt_card : 1 < Nat.card K).le + have hc : ((popularJoint W (l+1) r).card:ℝ) ≤ + ((popularDomain W (l+1)).card:ℝ)*(2*q^(d-r)) := by + calc + _ ≤ ∑ b ∈ popularDomain W (l+1), + ((if ranks W b = r then (partnerDomain (W b)).image (Prod.mk b) else ∅).card:ℝ) := by + exact_mod_cast (card_biUnion_le (s := popularDomain W (l+1)) + (t := fun b => if ranks W b = r then (partnerDomain (W b)).image (Prod.mk b) else ∅)) + _ ≤ ∑ _b ∈ popularDomain W (l+1), 2*q^(d-r) := by + apply sum_le_sum + intro b hb + split_ifs with h + · rw [card_image_of_injective _ (by intro x y hxy; exact Prod.mk.inj hxy |>.2)] + exact partner_card hdim (W b) h hr + · simp; positivity + _ = _ := by simp + have hpop := popular_card W l hZ + have hh := hc.trans (mul_le_mul_of_nonneg_right hpop (show 0 ≤ 2*q^(d-r) by positivity)) + have hp : q^(l+1+(d-r)) ≤ q^d := pow_le_pow_right₀ hq (by omega) + calc + _ ≤ (32*q^(l+1))*(2*q^(d-r)) := hh + _ = 64*q^(l+1+(d-r)) := by rw [pow_add]; ring + _ ≤ 64*q^d := mul_le_mul_of_nonneg_left hp (by norm_num) + +end SharpLogRamsey.Marking +namespace SharpLogRamsey.Marking +open Finset +open scoped Classical +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] [Fintype (Projectivization K V)] + +inductive ScanKind + | popular | poor | expensive + deriving DecidableEq + +instance flat_ActualMarkingOrientation_1 : Fintype ScanKind := ⟨{.popular,.poor,.expensive}, by + intro k + cases k <;> simp⟩ + +def levelFromRank (W : State (K:=K) (V:=V)) (r : ℕ) : ℕ := + Classical.choose ((range (r+1)).exists_max_image + (fun l => (level (ranks W) l).card) ⟨0,by simp⟩) + +omit [FiniteDimensional K V] in +lemma chosenLevel_from_rank (W : State (K:=K) (V:=V)) (b : Points (K:=K) (V:=V)) : + chosenLevel W b = levelFromRank W (ranks W b) := rfl + +abbrev RankMask := Fin (Module.finrank K V+1) × ScanKind + +abbrev ScanFlag := Module.Dual K V × Points (K:=K) (V:=V) + +def flagKind (q : ℝ) (W : State (K:=K) (V:=V)) (f : ScanFlag (K:=K) (V:=V)) : ScanKind := + if Popular W q (chosenLevel W f.2) f.2 then .popular + else if Poor W q (chosenLevel W f.2) f.1 then .poor else .expensive + +omit [FiniteDimensional K V] in +lemma flagKind_expensive (q : ℝ) (W : State (K:=K) (V:=V)) (f : ScanFlag (K:=K) (V:=V)) : + flagKind q W f = .expensive ↔ IsExpensive W q f := by + unfold flagKind IsExpensive + split_ifs <;> simp_all + +def maskAt (q : ℝ) (W : State (K:=K) (V:=V)) (f : ScanFlag (K:=K) (V:=V)) : + RankMask (K:=K) (V:=V) := + (⟨ranks W f.2, Nat.lt_succ_of_le (Submodule.finrank_le _)⟩, flagKind q W f) + +def sentAt (q : ℝ) (W : State (K:=K) (V:=V)) (f : ScanFlag (K:=K) (V:=V)) : + Option (ScanFlag (K:=K) (V:=V)) := if IsExpensive W q f then some f else none + +def replayStep (W : State (K:=K) (V:=V)) : Option (ScanFlag (K:=K) (V:=V)) → + State (K:=K) (V:=V) + | none => W + | some f => update W f.1 f.2 + +def markingCode (q : ℝ) : State (K:=K) (V:=V) → List (ScanFlag (K:=K) (V:=V)) → + List (RankMask (K:=K) (V:=V) × Option (ScanFlag (K:=K) (V:=V))) + | _, [] => [] + | W, f::fs => (maskAt q W f, sentAt q W f):: + markingCode q (replayStep W (sentAt q W f)) fs + +def replay (W : State (K:=K) (V:=V)) : List (Option (ScanFlag (K:=K) (V:=V))) → + State (K:=K) (V:=V) + | [] => W + | f::fs => replay (replayStep W f) fs + +lemma markingCode_length (q : ℝ) (W : State (K:=K) (V:=V)) + (fs : List (ScanFlag (K:=K) (V:=V))) : (markingCode q W fs).length = fs.length := by + induction fs generalizing W with + | nil => rfl + | cons f fs ih => simp only [markingCode,List.length_cons,ih] + +theorem replay_markingCode (q : ℝ) (W : State (K:=K) (V:=V)) + (fs : List (ScanFlag (K:=K) (V:=V))) : + replay W ((markingCode q W fs).map Prod.snd) = (scan q W fs).2 := by + induction fs generalizing W with + | nil => rfl + | cons f fs ih => + simp only [markingCode,List.map_cons,replay] + rw [ih] + by_cases h : IsExpensive W q f <;> simp [scan,sentAt,replayStep,h] + +def decodedCheap (q : ℝ) (W : State (K:=K) (V:=V)) + (m : RankMask (K:=K) (V:=V)) (f : ScanFlag (K:=K) (V:=V)) : Prop := + ranks W f.2 = m.1.val ∧ + match m.2 with + | .popular => Popular W q (levelFromRank W m.1.val) f.2 + | .poor => Poor W q (levelFromRank W m.1.val) f.1 + | .expensive => False + +lemma decodedCheap_maskAt (q : ℝ) (W : State (K:=K) (V:=V)) + (f : ScanFlag (K:=K) (V:=V)) (hc : ¬IsExpensive W q f) : + decodedCheap q W (maskAt q W f) f := by + unfold decodedCheap maskAt + refine ⟨rfl,?_⟩ + change (match flagKind q W f with + | .popular => Popular W q (chosenLevel W f.2) f.2 + | .poor => Poor W q (chosenLevel W f.2) f.1 + | .expensive => False) + unfold flagKind + split_ifs with h h' + · exact h + · exact h' + · exact hc ⟨h,h'⟩ + +lemma mask_records_transmission (q : ℝ) (W : State (K:=K) (V:=V)) + (f : ScanFlag (K:=K) (V:=V)) : + (sentAt q W f).isSome = true ↔ (maskAt q W f).2 = .expensive := by + simp only [sentAt,maskAt,flagKind_expensive] + split_ifs <;> simp_all + +omit [FiniteDimensional K V] [Fintype (Projectivization K V)] in +lemma rankMask_card : Fintype.card (RankMask (K:=K) (V:=V)) = + (Module.finrank K V+1)*3 := by + rw [Fintype.card_prod,Fintype.card_fin] + rfl + +end +end SharpLogRamsey.Marking +namespace SharpLogRamsey.Marking +open Finset +open scoped Classical +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] [Fintype (Projectivization K V)] + +def ScanConsistent (fs : List (ScanFlag (K:=K) (V:=V))) : Prop := + fs.Pairwise (fun f g => f.1 g.2.rep = 0 → g.1 f.2.rep = 0) + +omit [FiniteDimensional K V] [Fintype (Projectivization K V)] in + +lemma update_annihilates_later (W : State (K:=K) (V:=V)) + (f g : ScanFlag (K:=K) (V:=V)) (hW : W g.2 ≤ LinearMap.ker g.1) + (hfg : f.1 g.2.rep = 0 → g.1 f.2.rep = 0) : + update W f.1 f.2 g.2 ≤ LinearMap.ker g.1 := by + unfold update + split_ifs with h + · apply sup_le hW + rw [Projectivization.submodule_eq,Submodule.span_singleton_le_iff_mem] + exact hfg h + · exact hW + +def validCode (q : ℝ) : State (K:=K) (V:=V) → List (ScanFlag (K:=K) (V:=V)) → + List (RankMask (K:=K) (V:=V) × Option (ScanFlag (K:=K) (V:=V))) → Prop + | _, [], [] => True + | W, f::fs, (m,s)::cs => W f.2 ≤ LinearMap.ker f.1 ∧ + (match s with | none => decodedCheap q W m f | some g => f = g) ∧ + validCode q (replayStep W s) fs cs + | _, _, _ => False + +theorem markingCode_valid (q : ℝ) (W : State (K:=K) (V:=V)) + (fs : List (ScanFlag (K:=K) (V:=V))) (hcons : ScanConsistent fs) + (hW : ∀ f ∈ fs, W f.2 ≤ LinearMap.ker f.1) : + validCode q W fs (markingCode q W fs) := by + induction fs generalizing W with + | nil => trivial + | cons f fs ih => + have hp := List.pairwise_cons.mp hcons + refine ⟨hW f (by simp),?_,?_⟩ + · by_cases h : IsExpensive W q f + · simp [sentAt,h] + · simpa [sentAt,h] using decodedCheap_maskAt q W f h + · apply ih _ hp.2 + intro g hg + have hw := hW g (by simp [hg]) + by_cases h : IsExpensive W q f + · simp only [sentAt,ite_eq_left h,replayStep] + exact update_annihilates_later W f g hw (hp.1 g hg) + · simpa only [sentAt,ite_eq_right h,replayStep] using hw + +theorem markingCode_valid_zero (q : ℝ) (fs : List (ScanFlag (K:=K) (V:=V))) + (hcons : ScanConsistent fs) : + validCode q (fun _ => ⊥) fs (markingCode q (fun _ => ⊥) fs) := + markingCode_valid q _ fs hcons (fun _ _ => bot_le) + +omit [FiniteDimensional K V] in +lemma levelFromRank_spec (W : State (K:=K) (V:=V)) (r : ℕ) : + levelFromRank W r ≤ r ∧ ∀ j ≤ r, + (level (ranks W) j).card ≤ (level (ranks W) (levelFromRank W r)).card := by + have h := Classical.choose_spec ((range (r+1)).exists_max_image + (fun l => (level (ranks W) l).card) ⟨0,by simp⟩) + simpa only [levelFromRank,mem_range,Nat.lt_succ_iff] using h + +end +end SharpLogRamsey.Marking +namespace SharpLogRamsey.Marking +open Finset SharpLogRamsey.Incidence +open scoped BigOperators Classical +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + +abbrev ProjectivePair := Points (K:=K) (V:=V) × Projectivization K (Module.Dual K V) + +def incidentPairs (S : Finset (Points (K:=K) (V:=V))) + (T : Finset (Projectivization K (Module.Dual K V))) : Finset (ProjectivePair (K:=K) (V:=V)) := + (S ×ˢ T).filter (fun f => Incident f.1 f.2) + +omit [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] in +lemma incidentPairs_card (S : Finset (Points (K:=K) (V:=V))) + (T : Finset (Projectivization K (Module.Dual K V))) : + (incidentPairs S T).card = incidenceCount S T := by + simp only [incidentPairs,incidenceCount,card_eq_sum_ones,sum_filter,sum_product] + rw [sum_comm] + +def projectiveCheapDomain (W : State (K:=K) (V:=V)) (m : RankMask (K:=K) (V:=V)) : + Finset (ProjectivePair (K:=K) (V:=V)) := + if m.1.val < Module.finrank K V then + match m.2 with + | .popular => popularJoint W (levelFromRank W m.1.val) m.1.val + | .poor => incidentPairs (level (ranks W) m.1.val) (poorDomain W (levelFromRank W m.1.val)) + | .expensive => ∅ + else ∅ + +omit [Finite K] in +lemma cheapDomain_membership (W : State (K:=K) (V:=V)) (f : ProjectivePair (K:=K) (V:=V)) + (hf : Incident f.1 f.2) (hW : W f.1 ≤ LinearMap.ker f.2.rep) + (hc : ¬IsExpensive W (Nat.card K) (f.2.rep,f.1)) : + f ∈ projectiveCheapDomain W (maskAt (Nat.card K) W (f.2.rep,f.1)) := by + have hr : ranks W f.1 < Module.finrank K V := by + have hle := Submodule.finrank_mono hW + have hh := Module.Dual.finrank_ker_add_one_of_ne_zero f.2.rep_nonzero + unfold ranks + omega + dsimp only [projectiveCheapDomain,maskAt] + rw [ite_eq_left hr] + unfold flagKind + split_ifs with hp hpoor + · apply mem_biUnion.mpr + refine ⟨f.1,?_,?_⟩ + · simpa only [popularDomain,mem_filter,mem_univ,true_and,chosenLevel_from_rank] using hp + · rw [ite_eq_left rfl] + apply mem_image.mpr + exact ⟨f.2,by simpa only [partnerDomain,mem_filter,mem_univ,true_and] using hW,rfl⟩ + · apply mem_filter.mpr + refine ⟨mem_product.mpr ⟨?_,?_⟩,hf⟩ + · simp [level] + · simpa only [poorDomain,mem_filter,mem_univ,true_and,chosenLevel_from_rank] using hpoor + · exact False.elim (hc ⟨hp,hpoor⟩) + +omit [Finite K] [FiniteDimensional K V] in +lemma popularJoint_empty_of_level_empty (W : State (K:=K) (V:=V)) (l r : ℕ) + (he : level (ranks W) r = ∅) : popularJoint W l r = ∅ := by + apply eq_empty_iff_forall_notMem.mpr + intro f hf + obtain ⟨b,hb,hf⟩ := mem_biUnion.mp hf + by_cases hr : ranks W b = r + · have hm : b ∈ level (ranks W) r := by simp [level,hr] + rw [he] at hm + exact notMem_empty _ hm + · simp only [ite_eq_right hr,notMem_empty] at hf + +theorem projectiveCheapDomain_card {n : ℕ} (hdim : Module.finrank K V = n+3) + (W : State (K:=K) (V:=V)) (m : RankMask (K:=K) (V:=V)) : + ((projectiveCheapDomain W m).card:ℝ) ≤ 64*(Nat.card K:ℝ)^(n+2) := by + unfold projectiveCheapDomain + split_ifs with hr + · have hs := levelFromRank_spec W m.1.val + have hrd : m.1.val ≤ n+2 := by omega + cases hk : m.2 with + | expensive => simp + | poor => + rw [incidentPairs_card] + exact (poor_joint_domain_bound hdim W (hs.2 _ le_rfl)).trans (by + have hq : 0 ≤ (Nat.card K:ℝ)^(n+2) := by positivity + nlinarith) + | popular => + by_cases he : level (ranks W) m.1.val = ∅ + · rw [popularJoint_empty_of_level_empty W _ _ he] + simp + · have hne : (level (ranks W) (levelFromRank W m.1.val)).Nonempty := by + apply card_pos.mp + exact (card_pos.mpr (nonempty_iff_ne_empty.mpr he)).trans_le (hs.2 _ le_rfl) + exact popular_joint_card (by omega) W hs.1 hrd hne + · simp + +end +end SharpLogRamsey.Marking +namespace SharpLogRamsey.ProjectiveDuality +open SharpLogRamsey.Incidence +noncomputable section +variable {K V W : Type*} [Field K] [AddCommGroup V] [Module K V] + [AddCommGroup W] [Module K W] + +def mapEquiv (e : V ≃ₗ[K] W) : Projectivization K V ≃ Projectivization K W where + toFun := Projectivization.map e.toLinearMap e.injective + invFun := Projectivization.map e.symm.toLinearMap e.symm.injective + left_inv p := by + induction p using Projectivization.ind with + | h v hv => simp only [Projectivization.map_mk, LinearEquiv.coe_coe, e.symm_apply_apply] + right_inv p := by + induction p using Projectivization.ind with + | h v hv => simp only [Projectivization.map_mk, LinearEquiv.coe_coe, e.apply_symm_apply] + +variable [FiniteDimensional K V] +def bidual : Projectivization K V ≃ Projectivization K (Module.Dual K (Module.Dual K V)) := + mapEquiv (Module.evalEquiv K V) + +lemma incident_bidual (y : Projectivization K V) (b : Projectivization K (Module.Dual K V)) : + Incident b (bidual y) ↔ Incident y b := by + have he : bidual y = Projectivization.mk K ((Module.evalEquiv K V) y.rep) + (by simpa using (Module.evalEquiv K V).injective.ne y.rep_nonzero) := by + conv_lhs => rw [← y.mk_rep] + rfl + rw [Incident, he] + obtain ⟨u, hu⟩ := Projectivization.exists_smul_eq_mk_rep K ((Module.evalEquiv K V) y.rep) + (by simpa using (Module.evalEquiv K V).injective.ne y.rep_nonzero) + rw [← hu] + simp [Units.smul_def, Incident] + +end +end SharpLogRamsey.ProjectiveDuality +namespace SharpLogRamsey +section Flags +variable (K V : Type*) [Field K] [AddCommGroup V] [Module K V] + +def Incident (a : Projectivization K V) + (b : Projectivization K (Module.Dual K V)) : Prop := b.rep a.rep = 0 +structure Flag where + point : Projectivization K V + dualPoint : Projectivization K (Module.Dual K V) + incident : Incident K V point dualPoint +variable {K V} +def Consistent {N : ℕ} (F : Fin N → Flag K V) : Prop := + ∀ i j, i < j → Incident K V (F i).point (F j).dualPoint → + Incident K V (F j).point (F i).dualPoint +end Flags +end SharpLogRamsey + +namespace SharpLogRamsey.Marking +open ProjectiveDuality +open scoped Classical +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + +def forwardScan {N : ℕ} (F : Fin N → Flag K V) : + List (ScanFlag (K:=K) (V:=Module.Dual K V)) := + List.ofFn (fun i => ((bidual (F i).point).rep,(F i).dualPoint)) + +def backwardScan {N : ℕ} (F : Fin N → Flag K V) : List (ScanFlag (K:=K) (V:=V)) := + List.ofFn (fun i => ((F i.rev).dualPoint.rep,(F i.rev).point)) + +theorem forwardScan_consistent {N : ℕ} (F : Fin N → Flag K V) (hF : Consistent F) : + ScanConsistent (forwardScan F) := by + apply List.pairwise_ofFn.mpr + intro i j hij + change Incidence.Incident (F j).dualPoint (bidual (F i).point) → + Incidence.Incident (F i).dualPoint (bidual (F j).point) + simp only [incident_bidual] + exact hF i j hij + +omit [FiniteDimensional K V] in +theorem backwardScan_consistent {N : ℕ} (F : Fin N → Flag K V) (hF : Consistent F) : + ScanConsistent (backwardScan F) := by + apply List.pairwise_ofFn.mpr + intro i j hij + exact hF j.rev i.rev (Fin.rev_lt_rev.mpr hij) + +theorem forward_own_incident {N : ℕ} (F : Fin N → Flag K V) (i : Fin N) : + Incidence.Incident (F i).dualPoint (bidual (F i).point) := + (incident_bidual _ _).mpr (F i).incident + +variable [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + +omit [Fintype (Projectivization K V)] in +theorem forwardScan_valid {N : ℕ} (F : Fin N → Flag K V) (hF : Consistent F) (q : ℝ) : + validCode q (fun _ => ⊥) (forwardScan F) + (markingCode q (fun _ => ⊥) (forwardScan F)) := + markingCode_valid_zero q _ (forwardScan_consistent F hF) + +omit [Fintype (Projectivization K (Module.Dual K V))] in +theorem backwardScan_valid {N : ℕ} (F : Fin N → Flag K V) (hF : Consistent F) (q : ℝ) : + validCode q (fun _ => ⊥) (backwardScan F) + (markingCode q (fun _ => ⊥) (backwardScan F)) := + markingCode_valid_zero q _ (backwardScan_consistent F hF) + +end +end SharpLogRamsey.Marking + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/RawLowerTail.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/RawLowerTail.lean new file mode 100644 index 0000000000000000000000000000000000000000..3c5d8585308d6df849c7f116f8b3baeb39b0aefa --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/RawLowerTail.lean @@ -0,0 +1,461 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.RowSpan + +namespace OAI + +/-! High-rank geometric supports and entropy estimates. -/ + +section +open scoped BigOperators Classical +open Finset +namespace SharpLogRamsey.HighRankCoverageProbability +open scoped BigOperators +open Finset Classical FiniteEventBounds HighRankDecoder +noncomputable section +variable {K V Ω : Type*} [Field K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] [Finite K] [Fintype (Projectivization K V)] [Fintype Ω] +omit [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] + [Finite K] [Fintype (Projectivization K V)] in +lemma raw_lower_tail (w : Ω → ℝ) (hw : ∀ z, 0 ≤ w z) + (ht : ∑ z, w z=1) (Q : Ω → Prop) (q : ℝ) (hq : 0 Q (z i))).card < T)) ≤ + Real.exp (1-(h:ℝ)/(10*q)) := by + have hl := FiniteSamplingBounds.rowLower_highRank w hw ht (univ.filter Q) h T q hq hE hT + convert hl using 1 + simp [FiniteSamplingBounds.rowLower, FiniteSamplingBounds.hitCount, + FiniteSamplingBounds.rowWeight, ProductLaw.weight, indicator, mul_ite] + +theorem fixed_query_bound (w : Ω → ℝ) (hw : ∀ z, 0 ≤ w z) + (ht : ∑ z, w z=1) (a : Ω → Module.Dual K V) (b : Ω → Projectivization K V) + (y : Projectivization K V) (c : Projectivization K (Module.Dual K V)) + (hcy : c.rep y.rep=0) (h r m T : ℕ) (e : Fin r × Fin m ↪ Fin h) (hr : 2 ≤ r) + (M : ℝ) (hM0 : 0 ≤ M) + (hM : ∀ u, (∑ z ∈ univ.filter (fun z => b z=u), w z) ≤ M) + (hE : 2/(5*(Nat.card K:ℝ)) ≤ ∑ z ∈ univ.filter (fun z => a z y.rep=0), w z) + (hT : (T:ℝ) ≤ (h:ℝ)/(10*(Nat.card K:ℝ))+1) : + mean2 (ProductLaw.weight w : (Fin h → Ω) → ℝ) (ProductLaw.weight w : (Fin h → Ω) → ℝ) + (fun z₁ z₂ => indicator (¬Admitted a b z₁ z₂ r T y c)) ≤ + r*(1-(2/(5*(Nat.card K:ℝ))-2*M*(Nat.card K:ℝ)^(r-2)))^m+ + Real.exp (1-(h:ℝ)/(10*(Nat.card K:ℝ)))+2*h*conflictMass w a b y c+ + mean2 (ProductLaw.weight w : (Fin h → Ω) → ℝ) (ProductLaw.weight w : (Fin h → Ω) → ℝ) + (fun z₁ z₂ => indicator + (r < Module.finrank K (hitSpan a b y z₁ ⊔ hitSpan a b y z₂ : Submodule K V) ∧ + hitSpan a b y z₁ ⊔ hitSpan a b y z₂ ≤ LinearMap.ker c.rep)) := by + have hq : (0:ℝ) < Nat.card K := by exact_mod_cast Nat.card_pos + have hH : (∑ z ∈ univ.filter (fun z => a z y.rep=0), w z) = + ∑ z, w z*(if a z y.rep=0 then 1 else 0) := by + simp [sum_filter, mul_ite] + have hH1 : 2/(5*(Nat.card K:ℝ)) ≤ 1 := by + apply hE.trans + rw [← ht] + exact sum_le_sum_of_subset_of_nonneg (filter_subset _ _) (by intros; exact hw _) + have hg := HighRankGrowth.raw_row_span_growth w hw ht a b y h r m e hr + (2/(5*(Nat.card K:ℝ))) M hM0 hM (by rwa [← hH]) hH1 + have hl := raw_lower_tail w hw ht (fun z => a z y.rep=0) (Nat.card K:ℝ) hq h T hE hT + have hc := ProductLaw.row_exists_le (ι := Fin h) w hw ht + (fun z => a z y.rep=0 ∧ c.rep (b z).rep≠0) + simp only [Fintype.card_fin] at hc + apply (raw_coverage_union w hw ht a b y c hcy h r T).trans + refine add_le_add ?_ le_rfl + have hh := add_le_add (add_le_add hg hl) (mul_le_mul_of_nonneg_left hc (by norm_num : (0:ℝ) ≤ 2)) + convert hh using 1 <;> simp only [indicator, conflictMass, mul_assoc] + congr! + +end +end SharpLogRamsey.HighRankCoverageProbability + +namespace SharpLogRamsey.HighRankAveraged +open scoped BigOperators +open Finset Classical FiniteEventBounds HighRankDecoder HighRankCoverageProbability +noncomputable section +variable {K V Ω : Type*} [Field K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] [Finite K] [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K V))] [Fintype Ω] + +theorem excess_average (w : Ω → ℝ) (hw : ∀ z, 0 ≤ w z) (ht : ∑ z, w z=1) + (p : Projectivization K V × Projectivization K (Module.Dual K V) → ℝ) + (hp : ∀ z, 0 ≤ p z) (U : Finset (Projectivization K V)) + (hsupp : ∀ z, p z≠0 → z.1 ∈ U) + (a : Ω → Module.Dual K V) (b : Ω → Projectivization K V) + (h d r : ℕ) (hdim : Module.finrank K V=d+1) (hr : r ≤ d) + (J : ℝ) (hJ : 0 ≤ J) : + (∑ t, p t*mean2 (ProductLaw.weight w : (Fin h → Ω) → ℝ) + (ProductLaw.weight w : (Fin h → Ω) → ℝ) + (fun z₁ z₂ => indicator + (r < Module.finrank K (hitSpan a b t.1 z₁ ⊔ hitSpan a b t.1 z₂ : Submodule K V) ∧ + hitSpan a b t.1 z₁ ⊔ hitSpan a b t.1 z₂ ≤ LinearMap.ker t.2.rep))) ≤ + (∑ t ∈ U ×ˢ univ, if J < p t then p t else 0)+ + (if r hitSpan a b y z₁ ⊔ hitSpan a b y z₂) r, p t := by + convert HighRankExcess.target_event_eq U + (fun y => hitSpan a b y z₁ ⊔ hitSpan a b y z₂) r p hsupp using 1 + congr! + _ ≤ _ := HighRankExcess.target_excess_mass_sharp hdim hr U _ p hp J hJ + apply (mean2_mono _ _ (fun z => ProductLaw.nonneg w hw z) + (fun z => ProductLaw.nonneg w hw z) H).trans + exact le_of_eq (mean2_const _ _ hnt hnt _) + +theorem averaged_coverage (w : Ω → ℝ) (hw : ∀ z, 0 ≤ w z) (ht : ∑ z, w z=1) + (p : Projectivization K V × Projectivization K (Module.Dual K V) → ℝ) + (hp : ∀ t, 0 ≤ p t) (hpt : ∑ t, p t=1) + (hincident : ∀ t, p t≠0 → t.2.rep t.1.rep=0) + (U : Finset (Projectivization K V)) (hsupp : ∀ t, p t≠0 → t.1 ∈ U) + (a : Ω → Module.Dual K V) (b : Ω → Projectivization K V) + (h d r m T : ℕ) (hdim : Module.finrank K V=d+1) (hr : 2 ≤ r) (hrd : r ≤ d) + (e : Fin r × Fin m ↪ Fin h) (M J : ℝ) (hM0 : 0 ≤ M) (hJ : 0 ≤ J) + (hM : ∀ u, (∑ z ∈ univ.filter (fun z => b z=u), w z) ≤ M) + (hT : (T:ℝ) ≤ (h:ℝ)/(10*(Nat.card K:ℝ))+1) : + (∑ t, p t*mean2 (ProductLaw.weight w : (Fin h → Ω) → ℝ) + (ProductLaw.weight w : (Fin h → Ω) → ℝ) + (fun z₁ z₂ => indicator (¬Admitted a b z₁ z₂ r T t.1 t.2))) ≤ + (∑ t, p t*indicator + ((∑ z ∈ univ.filter (fun z => a z t.1.rep=0), w z)<2/(5*(Nat.card K:ℝ))))+ + (r*(1-(2/(5*(Nat.card K:ℝ))-2*M*(Nat.card K:ℝ)^(r-2)))^m+ + Real.exp (1-(h:ℝ)/(10*(Nat.card K:ℝ))))+ + 2*h*(∑ t, p t*conflictMass w a b t.1 t.2)+ + (∑ t ∈ U ×ˢ univ, if J < p t then p t else 0)+ + (if r a z t.1.rep=0), w z + let B : ℝ := r*(1-(2/(5*(Nat.card K:ℝ))-2*M*(Nat.card K:ℝ)^(r-2)))^m+ + Real.exp (1-(h:ℝ)/(10*(Nat.card K:ℝ))) + let R : (Fin h → Ω) → ℝ := ProductLaw.weight w + let X (t : Projectivization K V × Projectivization K (Module.Dual K V)) : ℝ := + mean2 R R (fun z₁ z₂ => indicator + (r < Module.finrank K (hitSpan a b t.1 z₁ ⊔ hitSpan a b t.1 z₂ : Submodule K V) ∧ + hitSpan a b t.1 z₁ ⊔ hitSpan a b t.1 z₂ ≤ LinearMap.ker t.2.rep)) + let F (t : Projectivization K V × Projectivization K (Module.Dual K V)) : ℝ := + mean2 R R (fun z₁ z₂ => indicator (¬Admitted a b z₁ z₂ r T t.1 t.2)) + have hnt : ∑ z, R z=1 := by + convert ProductLaw.total (ι := Fin h) w ht using 1 + congr! + have hn : ∀ z, 0 ≤ R z := fun z => ProductLaw.nonneg w hw z + have hX : ∀ t, 0 ≤ X t := fun t => + mean2_nonneg R R hn hn _ (fun _ _ => indicator_nonneg _) + have hC : ∀ t : Projectivization K V × Projectivization K (Module.Dual K V), 0 ≤ conflictMass w a b t.1 t.2 := by + intro t + apply sum_nonneg + intro z _ + exact mul_nonneg (hw z) (indicator_nonneg _) + have hF : ∀ t, F t ≤ 1 := by + intro t + apply (mean2_mono R R hn hn (fun _ _ => indicator_le_one _)).trans + exact le_of_eq (mean2_const R R hnt hnt 1) + have hq : (2:ℝ) ≤ Nat.card K := by exact_mod_cast (Finite.one_lt_card : 1 < Nat.card K) + have hH : 2/(5*(Nat.card K:ℝ)) ≤ 1 := by + apply (div_le_one (by positivity)).mpr + linarith + have hB : 0 ≤ B := by + dsimp [B] + apply add_nonneg _ (Real.exp_pos _).le + apply mul_nonneg (Nat.cast_nonneg r) + apply pow_nonneg + have hh : 0 ≤ 2*M*(Nat.card K:ℝ)^(r-2) := by positivity + linarith + have hh := average_with_exception p hp hpt G F + (fun t => 2*h*conflictMass w a b t.1 t.2+X t) B hB + (fun t => add_nonneg (mul_nonneg (by positivity) (hC t)) (hX t)) hF + (by + intro t hpt hG + have H := fixed_query_bound w hw ht a b t.1 t.2 (hincident t hpt) + h r m T e hr M hM0 hM hG hT + dsimp [F, B, R, X] + exact H.trans_eq (by ring)) + have he := excess_average w hw ht p hp U hsupp a b h d r hdim hrd J hJ + have hsum : (∑ t, p t*(2*h*conflictMass w a b t.1 t.2+X t)) = + 2*h*(∑ t, p t*conflictMass w a b t.1 t.2)+∑ t, p t*X t := by + simp_rw [mul_add, sum_add_distrib] + congr 1 + rw [mul_sum] + apply sum_congr rfl + intro t _ + ring + rw [hsum] at hh + have herr : (∑ t, p t*indicator (¬G t)) = + ∑ t, p t*indicator + ((∑ z ∈ univ.filter (fun z => a z t.1.rep=0), w z)<2/(5*(Nat.card K:ℝ))) := by + simp only [G, not_le] + rw [herr] at hh + dsimp [F, B, X, R] at hh + linarith + +end +end SharpLogRamsey.HighRankAveraged + +namespace SharpLogRamsey.Incidence +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] +section Projective +variable [Finite K] [FiniteDimensional K V] +variable [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + +theorem low_incidence_target_mass {n : ℕ} (hdim : Module.finrank K V = n+3) + (w : Projectivization K V → ℝ) (hw : ∀ x, 0 ≤ w x) (ht : ∑ x, w x = 1) + (M : ℝ) (hM : ∀ x, w x ≤ M) + (v : Projectivization K (Module.Dual K V) → ℝ) (N : ℝ) + (hN0 : 0 ≤ N) (hN : ∀ y, v y ≤ N) : + (∑ y ∈ univ.filter (fun y => weightedIncidences SharpLogRamsey.Incidence.Incident w y < + 2/(5*(Nat.card K:ℝ))), v y) ≤ 100*(Nat.card K:ℝ)^(n+3)*M*N := by + let q : ℝ := Nat.card K + let u : ℝ := ∑ i ∈ range (n+2), q^i + let p : ℝ := u/(∑ i ∈ range (n+3), q^i) + let B := univ.filter (fun y => weightedIncidences SharpLogRamsey.Incidence.Incident w y < 2/(5*q)) + have hq : 2 ≤ q := by + change (2:ℝ) ≤ Nat.card K + exact_mod_cast (Finite.one_lt_card : 1 < Nat.card K) + have hq0 : 0 < q := by linarith + have hu : 1 ≤ u := by + have hs := single_le_sum (f := fun i => q^i) + (fun i _ => pow_nonneg hq0.le i) (show 0 ∈ range (n+2) by simp) + simpa [u] using hs + have hvpos : 0 < ∑ i ∈ range (n+3), q^i := by + rw [geom_sum_succ] + change 0 < q*u+1 + positivity + have hp : 1/(2*q) ≤ p := by + change 1/(2*q) ≤ u/(∑ i ∈ range (n+3), q^i) + apply (div_le_div_iff₀ (by positivity) hvpos).mpr + rw [geom_sum_succ] + change 1*(q*u+1) ≤ u*(2*q) + nlinarith + have hnorm : (∑ x, w x^2) ≤ M := by + calc + _ ≤ ∑ x, M*w x := by + apply sum_le_sum + intro x _ + nlinarith [mul_le_mul_of_nonneg_right (hM x) (hw x)] + _ = M := by rw [← mul_sum, ht, mul_one] + have hvar := (projective_variance_le hdim w).trans + (mul_le_mul_of_nonneg_left hnorm (show 0 ≤ q^(n+1) by positivity)) + change (∑ y, (weightedIncidences SharpLogRamsey.Incidence.Incident w y-p*(∑ x, w x))^2) ≤ q^(n+1)*M at hvar + rw [ht, mul_one] at hvar + have hc : (B.card:ℝ)*(1/(10*q))^2 ≤ q^(n+1)*M := by + calc + _ = ∑ _y ∈ B, (1/(10*q))^2 := by simp + _ ≤ ∑ y ∈ B, (weightedIncidences SharpLogRamsey.Incidence.Incident w y-p)^2 := by + apply sum_le_sum + intro y hy + have hb : weightedIncidences SharpLogRamsey.Incidence.Incident w y < 2/(5*q) := (mem_filter.mp hy).2 + have hg : 1/(10*q) ≤ p-weightedIncidences SharpLogRamsey.Incidence.Incident w y := by + have he : 1/(2*q)-2/(5*q) = 1/(10*q) := by field_simp; ring + linarith + have hi : 0 ≤ 1/(10*q) := by positivity + nlinarith + _ ≤ ∑ y, (weightedIncidences SharpLogRamsey.Incidence.Incident w y-p)^2 := by + apply sum_le_sum_of_subset_of_nonneg (subset_univ B) + intro y _ _ + positivity + _ ≤ _ := hvar + have hmult := mul_le_mul_of_nonneg_right hc (show 0 ≤ 100*q^2 by positivity) + have hcancel : (B.card:ℝ)*(1/(10*q))^2*(100*q^2) = B.card := by + field_simp + ring + rw [hcancel] at hmult + have he : q^(n+1)*M*(100*q^2) = 100*q^(n+3)*M := by + rw [show n+3 = (n+1)+2 by omega, pow_add] + ring + rw [he] at hmult + change (∑ y ∈ B, v y) ≤ _ + calc + _ ≤ ∑ _y ∈ B, N := by apply sum_le_sum; intro y _; exact hN y + _ = (B.card:ℝ)*N := by simp + _ ≤ (100*q^(n+3)*M)*N := mul_le_mul_of_nonneg_right hmult hN0 + +end Projective +end SharpLogRamsey.Incidence +namespace SharpLogRamsey.ProjectiveDuality +open SharpLogRamsey.Incidence +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] +variable [Finite K] +variable [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] +local instance flat_JoinedHighRankAssembly_5 : Fintype (Projectivization K (Module.Dual K (Module.Dual K V))) := + Fintype.ofEquiv _ (bidual (K := K) (V := V)) + +theorem low_incidence_dual_mass {n : ℕ} (hdim : Module.finrank K V=n+3) + (w : Projectivization K (Module.Dual K V) → ℝ) + (hw : ∀ b, 0 ≤ w b) (ht : ∑ b, w b=1) (M : ℝ) (hM : ∀ b, w b ≤ M) + (v : Projectivization K V → ℝ) (N : ℝ) (hN0 : 0 ≤ N) (hN : ∀ y, v y ≤ N) : + (∑ y ∈ univ.filter (fun y => (∑ b, if SharpLogRamsey.Incidence.Incident y b then w b else 0)< + 2/(5*(Nat.card K:ℝ))), v y) ≤ 100*(Nat.card K:ℝ)^(n+3)*M*N := by + have H := low_incidence_target_mass + (show Module.finrank K (Module.Dual K V)=n+3 from Subspace.dual_finrank_eq.trans hdim) + w hw ht M hM (fun y => v (bidual.symm y)) N hN0 (fun y => hN _) + rw [sum_filter] at H ⊢ + have he : (∑ y : Projectivization K (Module.Dual K (Module.Dual K V)), + if weightedIncidences SharpLogRamsey.Incidence.Incident w y < 2/(5*(Nat.card K:ℝ)) then v (bidual.symm y) else 0) = + ∑ y : Projectivization K V, + if (∑ b, if SharpLogRamsey.Incidence.Incident y b then w b else 0) < 2/(5*(Nat.card K:ℝ)) then v y else 0 := by + rw [← (bidual (K := K) (V := V)).sum_comp] + simp only [Equiv.symm_apply_apply, weightedIncidences, incident_bidual] + rwa [he] at H +end +end SharpLogRamsey.ProjectiveDuality + +namespace SharpLogRamsey.HighRankLowHit +open scoped BigOperators +open Finset Classical SharpLogRamsey.Incidence SharpLogRamsey.FiniteMarginals +noncomputable section +variable {K V Ω : Type*} [Field K] [AddCommGroup V] [Module K V] + [Finite K] [FiniteDimensional K V] [Fintype Ω] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + +omit [Finite K] [FiniteDimensional K V] [Fintype (Projectivization K V)] in +lemma hit_mass (w : Ω → ℝ) (a : Ω → Projectivization K (Module.Dual K V)) + (y : Projectivization K V) : + (∑ z ∈ univ.filter (fun z => (a z).rep y.rep=0), w z) = + ∑ b, if SharpLogRamsey.Incidence.Incident y b then marginal w a b else 0 := by + have H := sum_marginal w a (fun b => if SharpLogRamsey.Incidence.Incident y b then 1 else 0) + rw [sum_filter] + calc + _ = ∑ z, w z*(if SharpLogRamsey.Incidence.Incident y (a z) then 1 else 0) := by + apply sum_congr rfl + intro z _ + by_cases hz : (a z).rep y.rep=0 <;> simp [SharpLogRamsey.Incidence.Incident, hz] + _ = ∑ b, marginal w a b*(if SharpLogRamsey.Incidence.Incident y b then 1 else 0) := H.symm + _ = _ := by + apply sum_congr rfl + intro b _ + split_ifs <;> simp + +theorem low_hit_mass {n : ℕ} (hdim : Module.finrank K V=n+3) + (w : Ω → ℝ) (hw : ∀ z, 0 ≤ w z) (ht : ∑ z, w z=1) + (a : Ω → Projectivization K (Module.Dual K V)) (M : ℝ) + (hM : ∀ b, marginal w a b ≤ M) + (p : Projectivization K V × Projectivization K (Module.Dual K V) → ℝ) + (N : ℝ) (hN0 : 0 ≤ N) (hN : ∀ y, (∑ c, p (y,c)) ≤ N) : + (∑ t, p t*(if (∑ z ∈ univ.filter (fun z => (a z).rep t.1.rep=0), w z)< + 2/(5*(Nat.card K:ℝ)) then 1 else 0)) ≤ 100*(Nat.card K:ℝ)^(n+3)*M*N := by + have H := ProjectiveDuality.low_incidence_dual_mass hdim (marginal w a) + (marginal_nonneg w hw a) (by rw [marginal_total, ht]) M hM + (fun y => ∑ c, p (y,c)) N hN0 hN + rw [sum_filter] at H + simp_rw [Fintype.sum_prod_type, hit_mass] + convert H using 1 + apply sum_congr rfl + intro y _ + rw [← sum_mul] + split_ifs <;> simp +end +end SharpLogRamsey.HighRankLowHit + +namespace SharpLogRamsey.HighRankBudgets +open Filter Real +open scoped Topology BigOperators +noncomputable section + +def beta (η : ℝ) : ℝ := η/10000000 +def scaleK (σ η D : ℝ) : ℝ := D*σ^(3*beta η) + +lemma eventually_monomial_le_linear (C a ε : ℝ) (ha : a < 1) (hε : 0 < ε) : + ∀ᶠ x : ℝ in atTop, C*x^a ≤ ε*x := by + have ht : Tendsto (fun x : ℝ => C*x^(a-1)) atTop (𝓝 0) := by + convert (tendsto_rpow_neg_atTop (sub_pos.mpr ha)).const_mul C using 1 <;> simp + filter_upwards [ht.eventually (gt_mem_nhds hε), eventually_gt_atTop (0 : ℝ)] with x hx hx0 + calc + _ = (C*x^(a-1))*x := by + have hp : x^(a-1)*x = x^a := by + calc + _ = x^(a-1)*x^(1 : ℝ) := by rw [Real.rpow_one] + _ = _ := by rw [← Real.rpow_add hx0]; congr 1; ring + rw [mul_assoc, hp] + _ ≤ ε*x := mul_le_mul_of_nonneg_right hx.le hx0.le + +lemma K_upper {σ η D : ℝ} (hσ : 0<σ) (hD : D ≤ σ^(1-η/2)) : + scaleK σ η D ≤ σ^(1-η/2+3*beta η) := by + unfold scaleK + calc + _ ≤ σ^(1-η/2)*σ^(3*beta η) := mul_le_mul_of_nonneg_right hD (by positivity) + _ = _ := (Real.rpow_add hσ _ _).symm + +lemma eventually_K_linear {η : ℝ} (hη : 0<η) (c ε : ℝ) (hc : 0≤c) (hε : 0<ε) : + ∀ᶠ σ : ℝ in atTop, ∀ D : ℝ, D ≤ σ^(1-η/2) → c*scaleK σ η D ≤ ε*σ := by + have he : 1-η/2+3*beta η < 1 := by unfold beta; linarith + filter_upwards [eventually_monomial_le_linear c (1-η/2+3*beta η) ε he hε, + eventually_gt_atTop (0:ℝ)] with σ hh hσ D hD + exact (mul_le_mul_of_nonneg_left (K_upper hσ hD) hc).trans hh + +theorem eventually_exp_K_over_q {η : ℝ} (hη : 0<η) (C a ε : ℝ) + (hC : 0≤C) (ha : 0≤a) (hε : 0<ε) : + ∀ᶠ σ : ℝ in atTop, ∀ D : ℝ, D ≤ σ^(1-η/2) → + C*Real.exp (a*scaleK σ η D)/Real.exp σ < ε := by + have ht : Tendsto (fun σ : ℝ => C*Real.exp (-(σ/2))) atTop (𝓝 0) := by + have hneg : Tendsto (fun σ : ℝ => -(σ/2)) atTop atBot := + tendsto_neg_atTop_atBot.comp (tendsto_id.atTop_div_const (by norm_num : (0:ℝ)<2)) + simpa using (Real.tendsto_exp_atBot.comp hneg).const_mul C + filter_upwards [eventually_K_linear hη a (1/2) ha (by norm_num), + ht.eventually (gt_mem_nhds hε)] with σ hK hx D hD + calc + _ = C*Real.exp (a*scaleK σ η D-σ) := by rw [Real.exp_sub]; ring + _ ≤ C*Real.exp (-(σ/2)) := by + apply mul_le_mul_of_nonneg_left _ hC + apply Real.exp_le_exp.mpr + linarith [hK D hD] + _ < ε := hx + +lemma row_size {q x : ℝ} (hq : 1≤q) (hx : 1≤x) : + q*x ≤ (⌈q*x⌉₊:ℝ) ∧ (⌈q*x⌉₊:ℝ) ≤ 2*q*x := by + have hqx : 1≤q*x := by nlinarith + exact ⟨Nat.le_ceil _, (Nat.ceil_lt_add_one (by positivity)).le.trans (by linarith)⟩ + +lemma block_size {h d : ℕ} (hd : 0 A (z i) ≤ W)) + simp_rw [hh, weight, ← prod_mul_distrib] + rw [← Fintype.prod_sum (fun (_ : Fin m) (a : Ω) => w a * (if A a ≤ W then 1 else 0))] + simp + +theorem span_growth (w : Ω → ℝ) (hw : ∀ a, 0 ≤ w a) (ht : ∑ a, w a = 1) + (A : Ω → Submodule K V) (r m : ℕ) (p : ℝ) (hp : p ≤ 1) + (hescape : ∀ W : Submodule K V, Module.finrank K W < r → + p ≤ ∑ a, w a * (if ¬ A a ≤ W then 1 else 0)) + (W : Submodule K V) : + expected (weight w : (Fin m → Ω) → ℝ) (rowSpan A) r W + (fun U => if Module.finrank K U < r then 1 else 0) ≤ r*(1-p)^m := by + apply rank_reached (weight w) (weight_nonneg w hw) (weight_total w ht m) + (rowSpan A) (fun U => Module.finrank K U) r ((1-p)^m) (pow_nonneg (by linarith) _) + · intro U z + exact Submodule.finrank_mono (le_rowSpan A U z) + · intro U hU + rw [stagnation_mass] + have hs : (∑ a, w a * (if A a ≤ U then 1 else 0)) + + (∑ a, w a * (if ¬ A a ≤ U then 1 else 0)) = 1 := by + rw [← sum_add_distrib] + convert ht using 1 + apply sum_congr rfl + intro a _ + by_cases ha : A a ≤ U <;> simp [ha] + have h0 : 0 ≤ ∑ a, w a * (if A a ≤ U then 1 else 0) := by + apply sum_nonneg + intro a _ + split_ifs + · simpa only [mul_one] using hw a + · simp + apply pow_le_pow_left₀ h0 + linarith [hescape U hU] + · omega + +noncomputable def projectiveSubmoduleEquiv (W : Submodule K V) : + Projectivization K W ≃ {a : Projectivization K V // a.submodule ≤ W} := by + let f : Projectivization K W → {a : Projectivization K V // a.submodule ≤ W} := + fun a => ⟨Projectivization.map W.subtype W.injective_subtype a, by + induction a using Projectivization.ind with + | h v hv => + rw [Projectivization.map_mk, Projectivization.submodule_mk, + Submodule.span_singleton_le_iff_mem] + exact v.property⟩ + apply Equiv.ofBijective f + constructor + · intro a b h + exact Projectivization.map_injective W.subtype W.injective_subtype + (congrArg Subtype.val h) + · rintro ⟨a, ha⟩ + have hmem : a.rep ∈ W := ha (by + rw [Projectivization.submodule_eq] + exact Submodule.mem_span_singleton_self _) + let v : W := ⟨a.rep, hmem⟩ + have hv : v ≠ 0 := fun h => a.rep_nonzero (congrArg Subtype.val h) + refine ⟨Projectivization.mk K v hv, ?_⟩ + apply Subtype.ext + exact a.mk_rep + +variable [Finite K] [Fintype (Projectivization K V)] + +omit [Fintype Ω] [FiniteDimensional K V] in +lemma projective_card (W : Submodule K V) : + (univ.filter (fun b : Projectivization K V => b.submodule ≤ W)).card = + ∑ i ∈ range (Module.finrank K W), Nat.card K^i := by + rw [← Fintype.card_subtype, ← Nat.card_eq_fintype_card, + ← Nat.card_congr (projectiveSubmoduleEquiv W)] + exact Projectivization.card_of_finrank K W rfl + +omit [Fintype Ω] [Fintype (Projectivization K V)] [Field K] [AddCommGroup V] + [Module K V] [FiniteDimensional K V] [Finite K] in +lemma geom_sum_le_twice {q : ℝ} (hq : 2 ≤ q) (r : ℕ) : + (∑ i ∈ range (r+1), q^i) ≤ 2*q^r := by + induction r with + | zero => simp + | succ r ih => + rw [sum_range_succ, pow_succ] + have hp : 0 ≤ q^r := pow_nonneg (by linarith) _ + nlinarith [mul_le_mul_of_nonneg_right hq hp] + +omit [Fintype Ω] [FiniteDimensional K V] in +lemma small_span_card (r : ℕ) (hr : 2 ≤ r) (W : Submodule K V) + (hW : Module.finrank K W < r) : + ((univ.filter (fun b : Projectivization K V => b.submodule ≤ W)).card : ℝ) ≤ + 2*(Nat.card K:ℝ)^(r-2) := by + rw [projective_card, Nat.cast_sum] + push_cast + calc + _ ≤ ∑ i ∈ range ((r-2)+1), (Nat.card K:ℝ)^i := by + apply sum_le_sum_of_subset_of_nonneg + · apply range_mono + omega + · intro _ _ _; positivity + _ ≤ _ := geom_sum_le_twice (by exact_mod_cast (Finite.one_lt_card : 1 < Nat.card K)) _ + +omit [Finite K] [FiniteDimensional K V] in +lemma marginal_mass (w : Ω → ℝ) (b : Ω → Projectivization K V) (W : Submodule K V) : + (∑ a, w a * (if (b a).submodule ≤ W then 1 else 0)) = + ∑ y ∈ univ.filter (fun y : Projectivization K V => y.submodule ≤ W), + ∑ a ∈ univ.filter (fun a => b a = y), w a := by + rw [sum_fiberwise_eq_sum_filter univ + (univ.filter (fun y : Projectivization K V => y.submodule ≤ W)) b w] + simp [sum_filter, mul_ite] + +omit [Finite K] [FiniteDimensional K V] in +lemma marginal_cap (w : Ω → ℝ) (b : Ω → Projectivization K V) (M : ℝ) + (hM : ∀ y, (∑ a ∈ univ.filter (fun a => b a = y), w a) ≤ M) (W : Submodule K V) : + (∑ a, w a * (if (b a).submodule ≤ W then 1 else 0)) ≤ + M * (univ.filter (fun y : Projectivization K V => y.submodule ≤ W)).card := by + rw [marginal_mass] + calc + _ ≤ ∑ _y ∈ univ.filter (fun y : Projectivization K V => y.submodule ≤ W), M := by + apply sum_le_sum + intro y _ + exact hM y + _ = _ := by simp [mul_comm] + +omit [Fintype Ω] [Finite K] [FiniteDimensional K V] [Fintype (Projectivization K V)] in +def hitSpace (a : Ω → Module.Dual K V) (b : Ω → Projectivization K V) + (y : Projectivization K V) (z : Ω) : Submodule K V := + if a z y.rep = 0 then (b z).submodule else ⊥ + +omit [Finite K] [FiniteDimensional K V] [Fintype (Projectivization K V)] in +lemma escape_mass (w : Ω → ℝ) (hw : ∀ z, 0 ≤ w z) + (a : Ω → Module.Dual K V) (b : Ω → Projectivization K V) + (y : Projectivization K V) (W : Submodule K V) : + (∑ z, w z * (if a z y.rep = 0 then 1 else 0)) - + (∑ z, w z * (if (b z).submodule ≤ W then 1 else 0)) ≤ + ∑ z, w z * (if ¬ hitSpace a b y z ≤ W then 1 else 0) := by + rw [sub_le_iff_le_add, ← sum_add_distrib] + apply sum_le_sum + intro z _ + by_cases hz : a z y.rep = 0 <;> + by_cases hb : (b z).submodule ≤ W <;> + simp [hitSpace, hz, hb, hw z] + +theorem projective_span_growth (w : Ω → ℝ) (hw : ∀ z, 0 ≤ w z) (ht : ∑ z, w z = 1) + (a : Ω → Module.Dual K V) (b : Ω → Projectivization K V) + (y : Projectivization K V) (r m : ℕ) (hr : 2 ≤ r) (H M : ℝ) (hM0 : 0 ≤ M) + (hM : ∀ u, (∑ z ∈ univ.filter (fun z => b z = u), w z) ≤ M) + (hH : H ≤ ∑ z, w z * (if a z y.rep = 0 then 1 else 0)) + (hH1 : H ≤ 1) : + expected (weight w : (Fin m → Ω) → ℝ) (rowSpan (hitSpace a b y)) r y.submodule + (fun U => if Module.finrank K U < r then 1 else 0) ≤ + r*(1-(H-2*M*(Nat.card K:ℝ)^(r-2)))^m := by + apply span_growth w hw ht (hitSpace a b y) r m _ + · have hnonneg : 0 ≤ 2*M*(Nat.card K:ℝ)^(r-2) := by positivity + linarith + · intro W hW + have hcap := (marginal_cap w b M hM W).trans + (mul_le_mul_of_nonneg_left (small_span_card r hr W hW) hM0) + have hesc := escape_mass w hw a b y W + linarith + +end +end SharpLogRamsey.HighRankCoverage + +namespace SharpLogRamsey.HighRankGrowth +open scoped BigOperators +open Finset Classical FiniteRowProcess HighRankCoverage HighRankDecoder +noncomputable section +variable {Ω K V : Type*} [Fintype Ω] [Field K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + +omit [Fintype Ω] [FiniteDimensional K V] in +lemma run_span_le (A : Ω → Submodule K V) (m n : ℕ) + (z : Fin n → Fin m → Ω) (W U : Submodule K V) + (hW : W ≤ U) (hA : ∀ i j, A (z i j) ≤ U) : + run (rowSpan A) n z W ≤ U := by + induction n generalizing W with + | zero => exact hW + | succ n ih => + apply ih (fun i => z i.succ) (rowSpan A W (z 0)) + · apply sup_le hW + exact iSup_le (hA 0) + · intro i j + exact hA i.succ j + +omit [Fintype Ω] [FiniteDimensional K V] in +lemma run_le_full {h r m : ℕ} (e : Fin r × Fin m ↪ Fin h) + (a : Ω → Module.Dual K V) (b : Ω → Projectivization K V) + (y : Projectivization K V) (z : Fin h → Ω) : + run (rowSpan (HighRankCoverage.hitSpace a b y)) r + (fun i j => z (e (i,j))) y.submodule ≤ hitSpan a b y z := by + apply run_span_le + · exact center_le a b y z + · intro i j + unfold HighRankCoverage.hitSpace + split_ifs with hi + · exact hit_le a b y z (e (i,j)) hi + · exact bot_le + +omit [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] in +lemma block_mean (w : Ω → ℝ) (ht : ∑ x, w x = 1) {h r m : ℕ} + (e : Fin r × Fin m ↪ Fin h) (f : (Fin r → Fin m → Ω) → ℝ) : + (∑ z : Fin h → Ω, ProductLaw.weight w z*f (fun i j => z (e (i,j)))) = + ∑ z : Fin r → Fin m → Ω, weight (weight w : (Fin m → Ω) → ℝ) z*f z := by + have H := ProductLaw.marginal w ht e (fun z => f (fun i j => z (i,j))) + trans ∑ z : Fin r × Fin m → Ω, ProductLaw.weight w z*f (fun i j => z (i,j)) + · convert H using 1 <;> congr! + rw [← (Equiv.curry (Fin r) (Fin m) Ω).symm.sum_comp] + apply sum_congr rfl + intro z _ + congr 1 + simp only [ProductLaw.weight, weight, Fintype.prod_prod_type, Equiv.curry_symm_apply, Function.uncurry] + +variable [Finite K] [Fintype (Projectivization K V)] + +theorem raw_row_span_growth (w : Ω → ℝ) (hw : ∀ z, 0 ≤ w z) + (ht : ∑ z, w z = 1) (a : Ω → Module.Dual K V) + (b : Ω → Projectivization K V) (y : Projectivization K V) + (h r m : ℕ) (e : Fin r × Fin m ↪ Fin h) (hr : 2 ≤ r) + (H M : ℝ) (hM0 : 0 ≤ M) + (hM : ∀ u, (∑ z ∈ univ.filter (fun z => b z = u), w z) ≤ M) + (hH : H ≤ ∑ z, w z * (if a z y.rep = 0 then 1 else 0)) (hH1 : H ≤ 1) : + (∑ z : Fin h → Ω, ProductLaw.weight w z* + (if Module.finrank K (hitSpan a b y z) < r then 1 else 0)) ≤ + r*(1-(H-2*M*(Nat.card K:ℝ)^(r-2)))^m := by + let f (z : Fin r → Fin m → Ω) : ℝ := + if Module.finrank K (run (rowSpan (HighRankCoverage.hitSpace a b y)) r z y.submodule : Submodule K V) < r + then 1 else 0 + calc + _ ≤ ∑ z : Fin h → Ω, ProductLaw.weight w z*f (fun i j => z (e (i,j))) := by + apply sum_le_sum + intro z _ + apply mul_le_mul_of_nonneg_left _ (ProductLaw.nonneg w hw z) + dsimp [f] + split_ifs with hfull hpart hpart + · rfl + · exact False.elim (hpart ((Submodule.finrank_mono (run_le_full e a b y z)).trans_lt hfull)) + · norm_num + · rfl + _ = _ := block_mean w ht e f + _ ≤ _ := projective_span_growth w hw ht a b y r m hr H M hM0 hM hH hH1 + +end +end SharpLogRamsey.HighRankGrowth + +namespace SharpLogRamsey.FiniteEventBounds +open scoped BigOperators +open Finset Classical +noncomputable section + +noncomputable def indicator (P : Prop) : ℝ := if P then 1 else 0 +lemma indicator_nonneg (P : Prop) : 0 ≤ indicator P := by unfold indicator; split_ifs <;> norm_num +lemma indicator_le_one (P : Prop) : indicator P ≤ 1 := by unfold indicator; split_ifs <;> norm_num +lemma indicator_mono {P Q : Prop} (H : P → Q) : indicator P ≤ indicator Q := by + unfold indicator + by_cases hp : P + · simp only [hp, ite_eq_left] + rw [ite_eq_left (H hp)] + · simp only [hp, ite_false] + split_ifs <;> norm_num +lemma indicator_or_le (P Q : Prop) : indicator (P ∨ Q) ≤ indicator P+indicator Q := by + unfold indicator + by_cases hp : P <;> by_cases hq : Q <;> simp [hp,hq] +lemma indicator_or_five (A B C D E : Prop) : + indicator (A ∨ B ∨ C ∨ D ∨ E) ≤ + indicator A+indicator B+indicator C+indicator D+indicator E := by + have h₁ := indicator_or_le A (B ∨ C ∨ D ∨ E) + have h₂ := indicator_or_le B (C ∨ D ∨ E) + have h₃ := indicator_or_le C (D ∨ E) + have h₄ := indicator_or_le D E + linarith + +variable {X Y : Type*} [Fintype X] [Fintype Y] + +def mean2 (w : X → ℝ) (v : Y → ℝ) (f : X → Y → ℝ) : ℝ := + ∑ x, w x*∑ y, v y*f x y + +lemma mean2_nonneg (w : X → ℝ) (v : Y → ℝ) + (hw : ∀ x, 0 ≤ w x) (hv : ∀ y, 0 ≤ v y) (f : X → Y → ℝ) + (hf : ∀ x y, 0 ≤ f x y) : 0 ≤ mean2 w v f := by + apply sum_nonneg + intro x _ + apply mul_nonneg (hw x) + apply sum_nonneg + intro y _ + exact mul_nonneg (hv y) (hf x y) + +lemma mean2_mono (w : X → ℝ) (v : Y → ℝ) + (hw : ∀ x, 0 ≤ w x) (hv : ∀ y, 0 ≤ v y) {f g : X → Y → ℝ} + (H : ∀ x y, f x y ≤ g x y) : mean2 w v f ≤ mean2 w v g := by + apply sum_le_sum + intro x _ + apply mul_le_mul_of_nonneg_left _ (hw x) + apply sum_le_sum + intro y _ + exact mul_le_mul_of_nonneg_left (H x y) (hv y) + +lemma mean2_add (w : X → ℝ) (v : Y → ℝ) (f g : X → Y → ℝ) : + mean2 w v (fun x y => f x y+g x y) = mean2 w v f+mean2 w v g := by + simp [mean2, mul_add, sum_add_distrib] + +lemma mean2_const (w : X → ℝ) (v : Y → ℝ) + (hw : ∑ x, w x=1) (hv : ∑ y, v y=1) (c : ℝ) : + mean2 w v (fun _ _ => c) = c := by + simp [mean2, ← sum_mul, hw, hv] + +lemma mean2_left (w : X → ℝ) (v : Y → ℝ) (hv : ∑ y, v y=1) (f : X → ℝ) : + mean2 w v (fun x _ => f x) = ∑ x, w x*f x := by + simp [mean2, ← sum_mul, hv] + +lemma mean2_right (w : X → ℝ) (v : Y → ℝ) (hw : ∑ x, w x=1) (f : Y → ℝ) : + mean2 w v (fun _ y => f y) = ∑ y, v y*f y := by + simp [mean2, ← sum_mul, hw] + +lemma mean2_symm (w : X → ℝ) (v : Y → ℝ) (f : X → Y → ℝ) : + mean2 w v f = mean2 v w (fun y x => f x y) := by + unfold mean2 + simp_rw [mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro y _ + apply sum_congr rfl + intro x _ + ring + +lemma mean2_cover_five (w : X → ℝ) (v : Y → ℝ) + (hw : ∀ x, 0 ≤ w x) (hv : ∀ y, 0 ≤ v y) + (A : X → Prop) (B : Y → Prop) (C : X → Prop) (D : Y → Prop) + (E J : X → Y → Prop) + (H : ∀ x y, J x y → A x ∨ B y ∨ C x ∨ D y ∨ E x y) : + mean2 w v (fun x y => indicator (J x y)) ≤ + mean2 w v (fun x _ => indicator (A x))+ + mean2 w v (fun _ y => indicator (B y))+ + mean2 w v (fun x _ => indicator (C x))+ + mean2 w v (fun _ y => indicator (D y))+ + mean2 w v (fun x y => indicator (E x y)) := by + have hh := mean2_mono w v hw hv (fun x y => + (indicator_mono (H x y)).trans (indicator_or_five (A x) (B y) (C x) (D y) (E x y))) + simpa only [mean2_add] using hh + +variable {Z : Type*} [Fintype Z] + +lemma mean2_sum (w : X → ℝ) (v : Y → ℝ) (p : Z → ℝ) (f : Z → X → Y → ℝ) : + (∑ z, p z*mean2 w v (f z)) = + mean2 w v (fun x y => ∑ z, p z*f z x y) := by + unfold mean2 + simp_rw [mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro x _ + rw [sum_comm] + apply sum_congr rfl + intro y _ + apply sum_congr rfl + intro z _ + ring + +omit [Fintype X] [Fintype Y] in +lemma average_with_exception (p : Z → ℝ) (hp : ∀ z, 0 ≤ p z) + (ht : ∑ z, p z=1) (G : Z → Prop) (f c : Z → ℝ) (b : ℝ) + (hb : 0 ≤ b) (hc : ∀ z, 0 ≤ c z) (hf : ∀ z, f z ≤ 1) + (hgood : ∀ z, p z≠0 → G z → f z ≤ b+c z) : + (∑ z, p z*f z) ≤ (∑ z, p z*indicator (¬G z))+b+∑ z, p z*c z := by + calc + _ ≤ ∑ z, p z*(indicator (¬G z)+b+c z) := by + apply sum_le_sum + intro z _ + by_cases hz : p z=0 + · simp [hz] + apply mul_le_mul_of_nonneg_left _ (hp z) + by_cases hG : G z + · simpa [indicator, hG] using hgood z hz hG + · simp only [indicator, hG, not_false_eq_true, ite_true] + have H := hf z + linarith [hc z] + _ = _ := by simp [mul_add, sum_add_distrib, ← sum_mul, ht] + +end +end SharpLogRamsey.FiniteEventBounds + +namespace SharpLogRamsey.HighRankCoverageProbability +open scoped BigOperators +open Finset Classical FiniteEventBounds HighRankDecoder +noncomputable section +variable {K V Ω : Type*} [Field K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] [Finite K] [Fintype (Projectivization K V)] [Fintype Ω] + +noncomputable def conflictMass (w : Ω → ℝ) (a : Ω → Module.Dual K V) + (b : Ω → Projectivization K V) (y : Projectivization K V) + (c : Projectivization K (Module.Dual K V)) : ℝ := + ∑ z, w z*indicator (a z y.rep=0 ∧ c.rep (b z).rep≠0) + +omit [Finite K] [Fintype (Projectivization K V)] in +theorem raw_coverage_union (w : Ω → ℝ) (hw : ∀ z, 0 ≤ w z) + (ht : ∑ z, w z=1) (a : Ω → Module.Dual K V) (b : Ω → Projectivization K V) + (y : Projectivization K V) (c : Projectivization K (Module.Dual K V)) + (hcy : c.rep y.rep=0) (h r T : ℕ) : + mean2 (ProductLaw.weight w : (Fin h → Ω) → ℝ) + (ProductLaw.weight w : (Fin h → Ω) → ℝ) + (fun z₁ z₂ => indicator (¬Admitted a b z₁ z₂ r T y c)) ≤ + (∑ z : Fin h → Ω, ProductLaw.weight w z* + indicator (Module.finrank K (hitSpan a b y z) a (z i) y.rep=0)).card indicator + (r < Module.finrank K (hitSpan a b y z₁ ⊔ hitSpan a b y z₂ : Submodule K V) ∧ + hitSpan a b y z₁ ⊔ hitSpan a b y z₂ ≤ LinearMap.ker c.rep)) := by + have hnt : ∑ z : Fin h → Ω, ProductLaw.weight w z=1 := by + convert ProductLaw.total (ι := Fin h) w ht using 1 + congr! + have hnn := fun z : Fin h → Ω => ProductLaw.nonneg w hw z + have H := mean2_cover_five (ProductLaw.weight w : (Fin h → Ω) → ℝ) + (ProductLaw.weight w : (Fin h → Ω) → ℝ) hnn hnn + (fun z => Module.finrank K (hitSpan a b y z) < r) + (fun z => (univ.filter (fun i => a (z i) y.rep=0)).card < T) + (fun z => ∃ i, a (z i) y.rep=0 ∧ c.rep (b (z i)).rep≠0) + (fun z => ∃ i, a (z i) y.rep=0 ∧ c.rep (b (z i)).rep≠0) + (fun z₁ z₂ => r < Module.finrank K + (hitSpan a b y z₁ ⊔ hitSpan a b y z₂ : Submodule K V) ∧ + hitSpan a b y z₁ ⊔ hitSpan a b y z₂ ≤ LinearMap.ker c.rep) + (fun z₁ z₂ => ¬Admitted a b z₁ z₂ r T y c) (by + intro z₁ z₂ hJ + by_contra hbad + push Not at hbad + apply hJ + apply coverage a b z₁ z₂ r T y c hcy + · exact hbad.2.2.1 + · exact hbad.2.2.2.1 + · exact hbad.1 + · rintro ⟨hrank,hann⟩ + exact hbad.2.2.2.2 hrank hann + · exact hbad.2.1) + rw [mean2_left _ _ hnt, mean2_right _ _ hnt, + mean2_left _ _ hnt, mean2_right _ _ hnt] at H + convert H using 1 + ring + +omit [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] + [Finite K] [Fintype (Projectivization K V)] in + +end +end SharpLogRamsey.HighRankCoverageProbability +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/SelectedStep.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/SelectedStep.lean new file mode 100644 index 0000000000000000000000000000000000000000..a66b9226e6ce001e633a14df11003b1d223ae262 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/SelectedStep.lean @@ -0,0 +1,112 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.ClassStep +import OAI.Combinatorics.SharpRamsey.Marking.ExcessCost + +namespace OAI + +section +namespace SharpLogRamsey.Marking +open Finset Real Filter Selection Selection.Windows ActualHighRank SourceScales +open scoped Classical BigOperators Topology +noncomputable section +local instance selectFiniteDual {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Fin (d+1)→K)) := + Finite.of_injective ((↑) : Module.Dual K (Fin (d+1)→K)→((Fin (d+1)→K)→K)) DFunLike.coe_injective +local instance selectFiniteDouble {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Module.Dual K (Fin (d+1)→K))) := + Finite.of_injective ((↑) : Module.Dual K (Module.Dual K (Fin (d+1)→K))→(Module.Dual K (Fin (d+1)→K)→K)) DFunLike.coe_injective +local instance selectProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Fin (d+1)→K)) := Fintype.ofFinite _ +local instance selectDualProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Fin (d+1)→K))) := Fintype.ofFinite _ +local instance selectDoubleProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Module.Dual K (Fin (d+1)→K)))) := Fintype.ofFinite _ + +def classCount (i : ℕ) : ℕ:=2*(i+4)+(i+4)^2 +lemma classCount_pos (i : ℕ) : 0 < classCount i:=by unfold classCount;positivity + + theorem eventually_selected_step (i : ℕ) (η c C C0 : ℝ) + (hη : 0 < η) (hηu : η ≤ 1) (hc : 0 < c) (hC : 0 < C) (hC0 : 0 < C0) : + ∀ᶠ σ : ℝ in atTop, ∀ (q : ℕ) [Fact q.Prime], 3 ≤ q → exp σ=(q:ℝ) → + ∀ (Ω Γ : Type) [Fintype Ω] [Fintype Γ] (N m : ℕ) (p : Law Ω) (Cmsg : Ω→Γ) + (F : Ω→Fin N→ProjectivePair (K:=ZMod q) (V:=Fin (i+4)→ZMod q)) + (S : Γ→Fin N→Finset (ProjectivePair (K:=ZMod q) (V:=Fin (i+4)→ZMod q))) + (D J : ℝ) (R : ℕ), Admissible σ η D R → + c*(q:ℝ)*σ^(1+η) ≤ m → (m:ℝ) ≤ C*q*σ^(1+η) → + (∀ z j,log (S z j).card ≤ J) → + (∀ x,p.mass x≠0→∀ j,F x j∈S (Cmsg x) j) → + (∀ x,p.mass x≠0→∀ j,Incidence.Incident (F x j).1 (F x j).2) → + (∀ x,p.mass x≠0→ScanConsistent ((List.ofFn (F x)).map toScan)) → + ((classCount i*m:ℕ):ℝ)+expensiveBudget (ZMod q) (Fin (i+4)→ZMod q)+ + expensiveBudget (ZMod q) (Module.Dual (ZMod q) (Fin (i+4)→ZMod q)) ≤ N → + excessCost p Cmsg F J (jointJ (ZMod q) (i+3)) ≤ + (C0*(m:ℝ)*D*σ^(-beta η))/(classCount i:ℝ) → + (∀ x,p.mass x≠0→∀ W : Submodule (ZMod q) (Fin (i+4)→ZMod q), + ((univ.filter (fun j : Fin N=>covectorTuple (F x) j∈ + orthogonalRectangle Projectivization.rep Projectivization.rep W)).card:ℝ) ≤ C0*σ) → + ∃ m' : ℕ, (m:ℝ)/64 ≤ m' ∧ + Nonempty (ContextOutput p F m' (stepPrefactor (i+3)*(q:ℝ)^(i+3)*exp (16*scaleKstar σ η D)) + (D*σ^(-η/3)*(N:ℝ)) (4*classCount i)) := by + filter_upwards [eventually_class_step i η c C C0 hη hηu hc hC hC0, + eventually_ge_atTop (1:ℝ)] with σ hstep hσ + intro q _ hq he Ω Γ _ _ N m p Cmsg F S D J R had hmlo hmhi hSJ hS hf hcon hpack hexc hocc + have hσ0 : 0 < σ:=lt_of_lt_of_le zero_lt_one hσ + have hD : 0 ≤ D:=(rpow_nonneg hσ0.le _).trans had.D_lower + have hdim : Module.finrank (ZMod q) (Fin (i+4)→ZMod q)=(i+1)+3:=by simp + have hgap : 0 ≤ scaleKstar σ η D:=by unfold scaleKstar;positivity + obtain ⟨cl,E,hE,T,hmn,hprob,hcard,hgcon,hgf,hG,hdef⟩:= + actual_ordered_class hdim hgap p Cmsg F S J hcon hf hS hSJ m hpack + let θ:=sourceMessage Cmsg F + let p':=p.onContextEvent θ E hE + let e:=chosenOrder T hmn + let G:=orderedTuple T hmn θ F + let S':=fun z j=>cheapBoth z (e z j) + let J':=jointJ (ZMod q) (i+3) + let budget:=excessCost p Cmsg F J J'/(p.map θ).event E + have hK : (0:ℝ) < classCount i:=by exact_mod_cast classCount_pos i + have hp : 1/(classCount i:ℝ) ≤ (p.map θ).event E:=hprob + have hcost0 : 0 ≤ C0*(m:ℝ)*D*σ^(-beta η):=by positivity + have hbudget : budget ≤ C0*(m:ℝ)*D*σ^(-beta η) := by + apply (div_le_iff₀ hE).mpr + calc + _ ≤ (C0*(m:ℝ)*D*σ^(-beta η))/(classCount i:ℝ):=hexc + _ = (C0*(m:ℝ)*D*σ^(-beta η))*(1/(classCount i:ℝ)):=by ring + _ ≤ _:=mul_le_mul_of_nonneg_left hp hcost0 + have hocc' : ∀ x,p'.mass x≠0→∀ W : Submodule (ZMod q) (Fin (i+4)→ZMod q), + ((univ.filter (fun j : Fin m=>covectorTuple (G x) j∈ + orthogonalRectangle Projectivization.rep Projectivization.rep W)).card:ℝ) ≤ C0*σ := by + intro x hx W + have hh:=count_injective_restriction (e (θ x)).toEmbedding + (fun j=>covectorTuple (F x) j∈orthogonalRectangle Projectivization.rep Projectivization.rep W) + apply le_trans _ (hocc x (p.onContextEvent_support θ E hE x hx).1 W) + have heq : ∀ j,covectorTuple (G x) j=covectorTuple (F x) (e (θ x) j) := fun _=>rfl + simp_rw [heq] + convert (Nat.cast_le (α:=ℝ)).mpr hh using 1 + congr! + congr 2 + ext index + simp only [orthogonalRectangle,mem_filter,mem_univ,true_and] + have hJ : ((i+3:ℕ):ℝ)*σ ≤ J':=by + have hq0 : (0:ℝ) < q:=he ▸ exp_pos _ + dsimp only [J',jointJ] + rw [Nat.card_zmod,log_mul (by norm_num) (pow_ne_zero _ hq0.ne'),log_pow,←he,log_exp] + linarith [log_nonneg (by norm_num : (1:ℝ) ≤ 64)] + obtain ⟨m',hmret,⟨out⟩⟩:=hstep q hq he Ω _ m p' θ G S' D J' (C0*σ) budget R cl + had hmlo hmhi hJ (by positivity) le_rfl + (fun z j=>cheapBoth_log_card hdim z (e z j)) (fun x hx j=>(hG x hx j).1) + hgf hgcon (fun x hx j=>(hG x hx j).2) + (fun z j=>by simpa only [Nat.card_zmod] using cheapBoth_card hdim z (e z j)) + hdef hbudget hocc' + have hdom : ∀ x,p'.mass x ≤ (classCount i:ℝ)*p.mass x:=by + intro x + have hh:=p.onContextEvent_domination p θ E hE 1 (by intro x;simp) x + apply hh.trans + apply mul_le_mul_of_nonneg_right _ (p.nonneg x) + apply (div_le_iff₀ hE).mpr + have hh:=(div_le_iff₀ hK).mp hp + linarith + have out':=out.rebase p (by norm_num) hdom + have full:=out'.transport (Equiv.refl _) F (fun x=>e (θ x)) (fun _ _=>rfl) + refine ⟨m',hmret,⟨full.mono (le_refl _) ?_ (le_refl _)⟩⟩ + exact mul_le_mul_of_nonneg_left (by exact_mod_cast hmn) (by positivity) +end +end SharpLogRamsey.Marking + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/SelectionLogBound.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/SelectionLogBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..9a0ce5963bf84223ff00f33081689ff3d3c72b50 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/SelectionLogBound.lean @@ -0,0 +1,83 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.FinalMarking + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Real +open scoped Classical +noncomputable section + +theorem log_choose_bound {N ℓ : ℕ} (hℓ : 0<ℓ) (hN : ℓ≤N) : + log (N.choose ℓ:ℝ)≤(ℓ:ℝ)*(1+log (N:ℝ)-log (ℓ:ℝ)) := by + have hl : (0:ℝ)<ℓ := by exact_mod_cast hℓ + have hn : (0:ℝ) v ≤ a x)).card : ℝ) ≤ M*(u/v)^n) : + ∑ x, w x ≤ M*(1+2^(n+1)) := by + classical + let H : Finset Y := univ.filter (fun x => u ≤ a x) + let L : Finset Y := univ.filter (fun x => 0 < a x ∧ a x < u) + have hH : ∑ x ∈ H, w x ≤ M := by + calc + _ ≤ ∑ _x ∈ H, (1 : ℝ) := Finset.sum_le_sum (fun x _ => hw1 x) + _ = (H.card : ℝ) := by simp + _ ≤ M := by simpa [H, ne_of_gt hu] using htail u hu le_rfl + have htailL : ∀ v, 0 < v → v ≤ u → + ((univ.filter (fun x : L => v ≤ a x)).card : ℝ) ≤ M*(u/v)^n := by + intro v hv hvu + have hc : (univ.filter (fun x : L => v ≤ a x)).card ≤ + (univ.filter (fun x : Y => v ≤ a x)).card := by + apply Finset.card_le_card_of_injOn (fun x : L => x.val) + · intro x hx + exact mem_filter.mpr ⟨mem_univ _, (mem_filter.mp hx).2⟩ + · intro x _ y _ hh + exact Subtype.ext hh + exact (by exact_mod_cast hc : + ((univ.filter (fun x : L => v ≤ a x)).card : ℝ) ≤ + ((univ.filter (fun x : Y => v ≤ a x)).card : ℝ)).trans (htail v hv hvu) + have hL : ∑ x ∈ L, w x ≤ M*2^(n+1) := by + have hh := small_tail_sum (fun x : L => a x) (fun x : L => w x) u C M n T + hu hC hM hCu (fun x => ⟨(mem_filter.mp x.2).2.1, (mem_filter.mp x.2).2.2.le⟩) + (fun x => hw x (mem_filter.mp x.2).2.1 (mem_filter.mp x.2).2.2.le) hT htailL + simpa only [Finset.sum_coe_sort] using hh + have he : ∑ x, w x = (∑ x ∈ H, w x)+(∑ x ∈ L, w x) := by + dsimp [H,L] + rw [Finset.sum_filter, Finset.sum_filter, ← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro x _ + by_cases hh : u ≤ a x + · simp [hh, not_lt_of_ge hh] + · have hxu : a x < u := lt_of_not_ge hh + by_cases hz : a x = 0 + · simp [hz, hzero x hz] + · have hx0 : 0 < a x := lt_of_le_of_ne (ha x) (Ne.symm hz) + simp [hh, hx0, hxu] + rw [he] + nlinarith + +end +end SharpLogRamsey.DyadicTail +end + +section + +namespace SharpLogRamsey.HighRankSampling +open scoped BigOperators +open Finset Classical +open SharpLogRamsey.RichUnion SharpLogRamsey.HighRankGeometry +open SharpLogRamsey.FiniteSamplingBounds +noncomputable section +variable {K : Type*} [Field K] [Fintype K] {n : ℕ} +local instance flat_JoinedHighRankAssembly_1 : Fintype (Projectivization K (Fin n → K)) := Fintype.ofFinite _ + +theorem high_rank_expected (hn : 0 < n) + (mass : Projectivization K (Fin n → K) → ℝ) + (hmass : ∀ x, 0 ≤ mass x) (htotal : ∑ x, mass x = 1) + (X Y : Finset (Projectivization K (Fin n → K))) + (hsupport : ∀ x, x ∉ X → mass x = 0) + (A u : ℝ) (hA : 0 < A) (hu : 0 < u) (huA : u ≤ 2*A) + (hu20 : u ≤ 1/20) (hCu : 20*Real.exp (1/2)*u ≤ 1) + (r : ℕ) (hr : 0 < r) + (hcap : ∀ x ∈ X, mass x ≤ A/(Fintype.card K : ℝ)^r) + (W : Projectivization K (Fin n → K) → Submodule K (Fin n → K)) + (hrank : ∀ y ∈ Y, Module.finrank K (W y) = r) + (hy : ∀ y ∈ Y, y.submodule ≤ W y) + (h T : ℕ) (hT : (h : ℝ)/(10*(Fintype.card K : ℝ)) ≤ T) (hTn : n+1 ≤ T) : + (∑ y ∈ Y, rowTail mass (projectivePoints (W y)) h T) ≤ + (10*(n : ℝ)*A/u)^n*X.card*(1+2^(n+1)) := by + classical + let q : ℝ := Fintype.card K + let a (y : Y) : ℝ := q * ∑ x ∈ projectivePoints (W y), mass x + let w (y : Y) : ℝ := rowTail mass (projectivePoints (W y)) h T + let M : ℝ := (10*(n : ℝ)*A/u)^n*X.card + have hq : 0 < q := by dsimp [q]; exact_mod_cast Fintype.card_pos (α := K) + have hM : 0 ≤ M := by dsimp [M]; positivity + have ha : ∀ y, 0 ≤ a y := fun y => + mul_nonneg hq.le (Finset.sum_nonneg (fun x _ => hmass x)) + have hzero : ∀ y, a y = 0 → w y = 0 := by + intro y hay + apply rowTail_zero mass hmass _ h T (by omega) + exact (mul_eq_zero.mp hay).resolve_left (ne_of_gt hq) + have hw : ∀ y, 0 < a y → a y ≤ u → w y ≤ (20*Real.exp (1/2)*a y)^T := by + intro y hay hayu + apply rowTail_small mass hmass htotal _ h T q (a y) hq hay (hayu.trans hu20) _ hT + dsimp [a] + rw [mul_div_cancel_left₀ _ (ne_of_gt hq)] + have htail : ∀ v, 0 < v → v ≤ u → + ((univ.filter (fun y : Y => v ≤ a y)).card : ℝ) ≤ M*(u/v)^n := by + intro v hv hvu + let Z := Y.filter (fun y => v ≤ q * ∑ x ∈ projectivePoints (W y), mass x) + have hc : (univ.filter (fun y : Y => v ≤ a y)).card = Z.card := by + apply Finset.card_bij (fun y _ => y.val) + · intro y hyy + exact mem_filter.mpr ⟨y.2, (mem_filter.mp hyy).2⟩ + · intro y _ z _ hzz + exact Subtype.ext hzz + · intro y hyy + exact ⟨⟨y,(mem_filter.mp hyy).1⟩,mem_filter.mpr ⟨mem_univ _,(mem_filter.mp hyy).2⟩,rfl⟩ + rw [hc] + have hb := high_rank_tail hn mass X Z hsupport A v hA hv (hvu.trans huA) r hr hcap W + (fun y hyy => hrank y (mem_filter.mp hyy).1) + (fun y hyy => hy y (mem_filter.mp hyy).1) + (fun y hyy => (mem_filter.mp hyy).2) + convert hb using 1 + dsimp [M] + rw [mul_right_comm _ (X.card : ℝ), ← mul_pow] + congr 2 + field_simp + have H := DyadicTail.tail_sum a w u (20*Real.exp (1/2)) M n T hu (by positivity) + hM hCu ha (fun y => rowTail_le_one mass hmass htotal _ h T) hzero hw hTn htail + change (∑ y : Y, rowTail mass (projectivePoints (W y)) h T) ≤ _ at H + rw [Finset.sum_coe_sort Y (fun y => rowTail mass (projectivePoints (W y)) h T)] at H + exact H + +lemma mean_admitted_eq + (mass : Projectivization K (Fin n → K) → ℝ) + (Y : Finset (Projectivization K (Fin n → K))) + (W : Projectivization K (Fin n → K) → Submodule K (Fin n → K)) (h T : ℕ) : + (∑ z : Fin h → Projectivization K (Fin n → K), + rowWeight mass z * ((Y.filter (fun y => T ≤ hitCount (projectivePoints (W y)) z)).card : ℝ)) = + ∑ y ∈ Y, rowTail mass (projectivePoints (W y)) h T := by + classical + simp_rw [← Finset.sum_boole, Finset.mul_sum, rowTail] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro y _ + apply Finset.sum_congr rfl + intro z _ + split_ifs <;> simp + +end +end SharpLogRamsey.HighRankSampling +end + +namespace SharpLogRamsey.HighRankDecoder +open scoped BigOperators +open Finset Classical +noncomputable section +variable {K V Ω : Type*} [Field K] [AddCommGroup V] [Module K V] + +noncomputable def hitSpan {h : ℕ} (a : Ω → Module.Dual K V) + (b : Ω → Projectivization K V) (y : Projectivization K V) (z : Fin h → Ω) : + Submodule K V := + y.submodule ⊔ ⨆ i, if a (z i) y.rep = 0 then (b (z i)).submodule else ⊥ + +lemma center_le {h : ℕ} (a : Ω → Module.Dual K V) (b : Ω → Projectivization K V) + (y : Projectivization K V) (z : Fin h → Ω) : y.submodule ≤ hitSpan a b y z := le_sup_left + +lemma hit_le {h : ℕ} (a : Ω → Module.Dual K V) (b : Ω → Projectivization K V) + (y : Projectivization K V) (z : Fin h → Ω) (i : Fin h) (hi : a (z i) y.rep = 0) : + (b (z i)).submodule ≤ hitSpan a b y z := by + apply le_trans _ le_sup_right + have H := le_iSup (fun j => if a (z j) y.rep = 0 then (b (z j)).submodule else ⊥) i + rwa [ite_eq_left hi] at H + +lemma line_le_ker (b : Projectivization K V) (c : Module.Dual K V) : + b.submodule ≤ LinearMap.ker c ↔ c b.rep = 0 := by + rw [Projectivization.submodule_eq, Submodule.span_singleton_le_iff_mem] + rfl + +lemma annihilates_hitSpan {h : ℕ} (a : Ω → Module.Dual K V) (b : Ω → Projectivization K V) + (y : Projectivization K V) (z : Fin h → Ω) (c : Module.Dual K V) + (hcy : c y.rep = 0) + (hconflict : ∀ i, a (z i) y.rep = 0 → c (b (z i)).rep = 0) : + hitSpan a b y z ≤ LinearMap.ker c := by + apply sup_le ((line_le_ker y c).mpr hcy) + apply iSup_le + intro i + split_ifs with hi + · exact (line_le_ker _ c).mpr (hconflict i hi) + · exact bot_le + +noncomputable def Admitted [FiniteDimensional K V] {h : ℕ} + (a : Ω → Module.Dual K V) (b : Ω → Projectivization K V) + (z₁ z₂ : Fin h → Ω) (r T : ℕ) + (y : Projectivization K V) (c : Projectivization K (Module.Dual K V)) : Prop := + Module.finrank K (hitSpan a b y z₁) = r ∧ + hitSpan a b y z₁ ≤ LinearMap.ker c.rep ∧ + T ≤ (univ.filter (fun i => (b (z₂ i)).submodule ≤ hitSpan a b y z₁)).card + +lemma admitted_incident [FiniteDimensional K V] {h : ℕ} + (a : Ω → Module.Dual K V) (b : Ω → Projectivization K V) + (z₁ z₂ : Fin h → Ω) (r T : ℕ) + (y : Projectivization K V) (c : Projectivization K (Module.Dual K V)) + (H : Admitted a b z₁ z₂ r T y c) : c.rep y.rep = 0 := + (line_le_ker y c.rep).mp ((center_le a b y z₁).trans H.2.1) + +theorem coverage [FiniteDimensional K V] {h : ℕ} + (a : Ω → Module.Dual K V) (b : Ω → Projectivization K V) + (z₁ z₂ : Fin h → Ω) (r T : ℕ) + (y : Projectivization K V) (c : Projectivization K (Module.Dual K V)) + (hcy : c.rep y.rep = 0) + (hconflict₁ : ∀ i, a (z₁ i) y.rep = 0 → c.rep (b (z₁ i)).rep = 0) + (hconflict₂ : ∀ i, a (z₂ i) y.rep = 0 → c.rep (b (z₂ i)).rep = 0) + (hreach : r ≤ Module.finrank K (hitSpan a b y z₁)) + (hexcess : ¬ (r < Module.finrank K (hitSpan a b y z₁ ⊔ hitSpan a b y z₂ : Submodule K V) ∧ + hitSpan a b y z₁ ⊔ hitSpan a b y z₂ ≤ LinearMap.ker c.rep)) + (hhits : T ≤ (univ.filter (fun i => a (z₂ i) y.rep = 0)).card) : + Admitted a b z₁ z₂ r T y c := by + have ha₁ := annihilates_hitSpan a b y z₁ c.rep hcy hconflict₁ + have ha₂ := annihilates_hitSpan a b y z₂ c.rep hcy hconflict₂ + have hcombined : Module.finrank K (hitSpan a b y z₁ ⊔ hitSpan a b y z₂ : Submodule K V) ≤ r := by + by_contra hn + exact hexcess ⟨Nat.lt_of_not_ge hn, sup_le ha₁ ha₂⟩ + have hle := Submodule.finrank_mono + (show hitSpan a b y z₁ ≤ hitSpan a b y z₁ ⊔ hitSpan a b y z₂ from le_sup_left) + have hrank : Module.finrank K (hitSpan a b y z₁) = r := by omega + have heq : hitSpan a b y z₁ = hitSpan a b y z₁ ⊔ hitSpan a b y z₂ := by + apply Submodule.eq_of_le_of_finrank_eq le_sup_left + omega + refine ⟨hrank, ha₁, hhits.trans (card_le_card ?_)⟩ + intro i hi + apply mem_filter.mpr + refine ⟨mem_univ _, ?_⟩ + rw [heq] + exact (hit_le a b y z₂ i (mem_filter.mp hi).2).trans le_sup_right + +end +end SharpLogRamsey.HighRankDecoder + +namespace SharpLogRamsey.HighRankExcess +open scoped BigOperators +open Finset Classical +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + +noncomputable def projectiveSubmoduleEquiv (W : Submodule K V) : + Projectivization K W ≃ {a : Projectivization K V // a.submodule ≤ W} := by + let f : Projectivization K W → {a : Projectivization K V // a.submodule ≤ W} := + fun a => ⟨Projectivization.map W.subtype W.injective_subtype a, by + induction a using Projectivization.ind with + | h v hv => + rw [Projectivization.map_mk, Projectivization.submodule_mk, + Submodule.span_singleton_le_iff_mem] + exact v.property⟩ + apply Equiv.ofBijective f + constructor + · intro a b h + exact Projectivization.map_injective W.subtype W.injective_subtype + (congrArg Subtype.val h) + · rintro ⟨a, ha⟩ + have hmem : a.rep ∈ W := ha (by + rw [Projectivization.submodule_eq] + exact Submodule.mem_span_singleton_self _) + let v : W := ⟨a.rep, hmem⟩ + have hv : v ≠ 0 := fun h => a.rep_nonzero (congrArg Subtype.val h) + refine ⟨Projectivization.mk K v hv, ?_⟩ + apply Subtype.ext + exact a.mk_rep + +variable [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + +omit [FiniteDimensional K V] [Fintype (Projectivization K (Module.Dual K V))] in +lemma projective_card (W : Submodule K V) : + (univ.filter (fun b : Projectivization K V => b.submodule ≤ W)).card = + ∑ i ∈ range (Module.finrank K W), Nat.card K^i := by + rw [← Fintype.card_subtype, ← Nat.card_eq_fintype_card, + ← Nat.card_congr (projectiveSubmoduleEquiv W)] + exact Projectivization.card_of_finrank K W rfl + +omit [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] [Finite K] in +lemma geom_sum_le_twice {q : ℝ} (hq : 2 ≤ q) (r : ℕ) : + (∑ i ∈ range (r+1), q^i) ≤ 2*q^r := by + induction r with + | zero => simp + | succ r ih => + rw [sum_range_succ, pow_succ] + have hp : 0 ≤ q^r := pow_nonneg (by linarith) _ + nlinarith [mul_le_mul_of_nonneg_right hq hp] + +omit [Fintype (Projectivization K (Module.Dual K V))] [FiniteDimensional K V] in +lemma small_span_card (r : ℕ) (hr : 1 ≤ r) (W : Submodule K V) + (hW : Module.finrank K W ≤ r) : + ((univ.filter (fun b : Projectivization K V => b.submodule ≤ W)).card : ℝ) ≤ + 2*(Nat.card K:ℝ)^(r-1) := by + rw [projective_card, Nat.cast_sum] + push_cast + calc + _ ≤ ∑ i ∈ range ((r-1)+1), (Nat.card K:ℝ)^i := by + apply sum_le_sum_of_subset_of_nonneg + · apply range_mono + omega + · intro _ _ _; positivity + _ ≤ _ := geom_sum_le_twice (by exact_mod_cast (Finite.one_lt_card : 1 < Nat.card K)) _ + +def partners (W : Submodule K V) : Finset (Projectivization K (Module.Dual K V)) := + univ.filter (fun a => W ≤ LinearMap.ker a.rep) + +omit [Finite K] [FiniteDimensional K V] [Fintype (Projectivization K V)] in +lemma partners_eq (W : Submodule K V) : + partners W = univ.filter (fun a => a.submodule ≤ W.dualAnnihilator) := by + ext a + simp only [partners, mem_filter, mem_univ, true_and, + Projectivization.submodule_eq, Submodule.span_singleton_le_iff_mem, + Submodule.mem_dualAnnihilator] + rfl + +omit [Fintype (Projectivization K V)] in +lemma excess_partners_card {d r : ℕ} (hdim : Module.finrank K V = d+1) + (hr : r < d) (W : Submodule K V) (hW : r < Module.finrank K W) : + ((partners W).card:ℝ) ≤ 2*(Nat.card K:ℝ)^(d-r-1) := by + rw [partners_eq] + apply small_span_card (d-r) (by omega) + have h := Subspace.finrank_add_finrank_dualAnnihilator_eq W + omega + +omit [Finite K] [Fintype (Projectivization K V)] in +lemma full_rank_no_partners {d : ℕ} (hdim : Module.finrank K V = d+1) + (W : Submodule K V) (hW : d < Module.finrank K W) : partners W = ∅ := by + have htop : W = ⊤ := by + apply Submodule.eq_top_of_finrank_eq + have hm := Submodule.finrank_le W + omega + subst W + apply filter_eq_empty_iff.mpr + intro a _ ha + exact a.rep_nonzero (LinearMap.ker_eq_top.mp (top_unique ha)) + +def excessCarrier (U : Finset (Projectivization K V)) + (W : Projectivization K V → Submodule K V) (r : ℕ) : + Finset (Projectivization K V × Projectivization K (Module.Dual K V)) := + (U ×ˢ univ).filter (fun z => r < Module.finrank K (W z.1) ∧ W z.1 ≤ LinearMap.ker z.2.rep) + +omit [Fintype (Projectivization K V)] in +lemma excessCarrier_card {d r : ℕ} (hdim : Module.finrank K V = d+1) (hr : r < d) + (U : Finset (Projectivization K V)) (W : Projectivization K V → Submodule K V) : + ((excessCarrier U W r).card:ℝ) ≤ U.card*(2*(Nat.card K:ℝ)^(d-r-1)) := by + have he : excessCarrier U W r = + U.biUnion (fun y => if r < Module.finrank K (W y) then + (partners (W y)).image (Prod.mk y) else ∅) := by + ext z + simp only [excessCarrier, mem_filter, mem_product, mem_univ, and_true, mem_biUnion] + constructor + · rintro ⟨hy, hr, hc⟩ + refine ⟨z.1, hy, ?_⟩ + rw [ite_eq_left hr] + apply mem_image.mpr + exact ⟨z.2, mem_filter.mpr ⟨mem_univ _, hc⟩, Prod.eta z⟩ + · rintro ⟨y, hy, hz⟩ + split_ifs at hz with hr + · obtain ⟨c, hc, rfl⟩ := mem_image.mp hz + exact ⟨hy, hr, (mem_filter.mp hc).2⟩ + · simp at hz + rw [he] + calc + _ ≤ ∑ y ∈ U, ((if r < Module.finrank K (W y) then + (partners (W y)).image (Prod.mk y) else ∅).card:ℝ) := by + exact_mod_cast card_biUnion_le + _ ≤ ∑ _y ∈ U, 2*(Nat.card K:ℝ)^(d-r-1) := by + apply sum_le_sum + intro y _ + split_ifs with hW + · rw [card_image_of_injective _ (by intro a b h; exact Prod.mk.inj h |>.2)] + exact excess_partners_card hdim hr (W y) hW + · simp + _ = _ := by simp + +omit [Fintype (Projectivization K V)] in +theorem target_excess_mass {d r : ℕ} (hdim : Module.finrank K V = d+1) (hr : r < d) + (U : Finset (Projectivization K V)) (W : Projectivization K V → Submodule K V) + (p : Projectivization K V × Projectivization K (Module.Dual K V) → ℝ) + (hp : ∀ z, 0 ≤ p z) (M : ℝ) (hM : 0 ≤ M) : + (∑ z ∈ excessCarrier U W r, p z) ≤ + (∑ z ∈ U ×ˢ univ, if M < p z then p z else 0) + + U.card*(2*(Nat.card K:ℝ)^(d-r-1))*M := by + have hsplit : (∑ z ∈ excessCarrier U W r, p z) ≤ + (∑ z ∈ excessCarrier U W r, if M < p z then p z else 0) + + (excessCarrier U W r).card * M := by + rw [← nsmul_eq_mul, ← sum_const, ← sum_add_distrib] + apply sum_le_sum + intro z _ + split_ifs with hz + · linarith + · simpa only [zero_add] using le_of_not_gt hz + have hlarge : (∑ z ∈ excessCarrier U W r, if M < p z then p z else 0) ≤ + ∑ z ∈ U ×ˢ univ, if M < p z then p z else 0 := by + apply sum_le_sum_of_subset_of_nonneg (filter_subset _ _) + intro z _ _ + split_ifs <;> first | exact hp z | rfl + have hc := mul_le_mul_of_nonneg_right (excessCarrier_card hdim hr U W) hM + linarith + +omit [Finite K] [Fintype (Projectivization K V)] in +lemma excessCarrier_full_rank {d : ℕ} (hdim : Module.finrank K V = d+1) + (U : Finset (Projectivization K V)) (W : Projectivization K V → Submodule K V) : + excessCarrier U W d = ∅ := by + apply filter_eq_empty_iff.mpr + intro z _ hz + have hm : z.2 ∈ partners (W z.1) := mem_filter.mpr ⟨mem_univ _, hz.2⟩ + rw [full_rank_no_partners hdim (W z.1) hz.1] at hm + simp at hm + +omit [Fintype (Projectivization K V)] in +lemma target_excess_mass_le {d r : ℕ} (hdim : Module.finrank K V = d+1) (hr : r ≤ d) + (U : Finset (Projectivization K V)) (W : Projectivization K V → Submodule K V) + (p : Projectivization K V × Projectivization K (Module.Dual K V) → ℝ) + (hp : ∀ z, 0 ≤ p z) (M : ℝ) (hM : 0 ≤ M) : + (∑ z ∈ excessCarrier U W r, p z) ≤ + (∑ z ∈ U ×ˢ univ, if M < p z then p z else 0) + + U.card*(2*(Nat.card K:ℝ)^(d-r-1))*M := by + obtain hrd | rfl := hr.lt_or_eq + · exact target_excess_mass hdim hrd U W p hp M hM + · rw [excessCarrier_full_rank hdim, sum_empty] + apply add_nonneg + · apply sum_nonneg + intro z _ + split_ifs <;> first | exact hp _ | rfl + · positivity + +end +end SharpLogRamsey.HighRankExcess +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/TargetEvent.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/TargetEvent.lean new file mode 100644 index 0000000000000000000000000000000000000000..ada90cc88f8d9488fd96d6b1c895d667744c3b70 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/TargetEvent.lean @@ -0,0 +1,477 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.TailSum + +namespace OAI + +/-! High-rank geometric supports and entropy estimates. -/ + +section +open scoped BigOperators Classical +open Finset +namespace SharpLogRamsey.HighRankExcess +open scoped BigOperators +open Finset Classical +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] +variable [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] +omit [Finite K] [FiniteDimensional K V] in +lemma target_event_eq (U : Finset (Projectivization K V)) + (W : Projectivization K V → Submodule K V) (r : ℕ) + (p : Projectivization K V × Projectivization K (Module.Dual K V) → ℝ) + (hsupp : ∀ z, p z≠0 → z.1 ∈ U) : + (∑ z, p z*(if r < Module.finrank K (W z.1) ∧ W z.1 ≤ LinearMap.ker z.2.rep + then 1 else 0)) = ∑ z ∈ excessCarrier U W r, p z := by + let E (z : Projectivization K V × Projectivization K (Module.Dual K V)) := + r < Module.finrank K (W z.1) ∧ W z.1 ≤ LinearMap.ker z.2.rep + have he (z : Projectivization K V × Projectivization K (Module.Dual K V)) : + p z*(if E z then 1 else 0) = + if z ∈ U ×ˢ univ then (if E z then p z else 0) else 0 := by + by_cases hpz : p z=0 + · simp [hpz] + · simp [hsupp z hpz, mul_ite] + change (∑ z, p z*(if E z then 1 else 0)) = _ + simp_rw [he] + rw [excessCarrier, sum_filter] + rw [← sum_filter] + simp only [filter_mem_eq_inter, univ_inter] + rfl + +omit [Fintype (Projectivization K V)] in +lemma target_excess_mass_sharp {d r : ℕ} (hdim : Module.finrank K V = d+1) (hr : r ≤ d) + (U : Finset (Projectivization K V)) (W : Projectivization K V → Submodule K V) + (p : Projectivization K V × Projectivization K (Module.Dual K V) → ℝ) + (hp : ∀ z, 0 ≤ p z) (M : ℝ) (hM : 0 ≤ M) : + (∑ z ∈ excessCarrier U W r, p z) ≤ + (∑ z ∈ U ×ˢ univ, if M < p z then p z else 0) + + (if r first | exact hp _ | rfl + +end +end SharpLogRamsey.HighRankExcess + +namespace SharpLogRamsey.ProductLaw +open scoped BigOperators +open Finset Classical +noncomputable section +variable {ι κ Ω : Type*} [Fintype ι] [Fintype κ] [Fintype Ω] + +noncomputable def weight (w : Ω → ℝ) (z : ι → Ω) : ℝ := ∏ i, w (z i) + +omit [Fintype κ] in +lemma total (w : Ω → ℝ) (ht : ∑ x, w x = 1) : ∑ z : ι → Ω, weight w z = 1 := by + unfold weight + rw [← Fintype.prod_sum] + simp [ht] + +omit [Fintype κ] [Fintype Ω] in +lemma nonneg (w : Ω → ℝ) (hw : ∀ a, 0 ≤ w a) (z : ι → Ω) : 0 ≤ weight w z := + prod_nonneg (fun i _ => hw (z i)) + +lemma reindex (w : Ω → ℝ) (e : ι ≃ κ) (f : (κ → Ω) → ℝ) : + (∑ z : ι → Ω, weight w z*f (z ∘ e.symm)) = ∑ z : κ → Ω, weight w z*f z := by + let E : (κ → Ω) ≃ (ι → Ω) := Equiv.arrowCongr e.symm (Equiv.refl Ω) + rw [← E.sum_comp] + apply sum_congr rfl + intro z _ + have hfun : E z ∘ e.symm = z := by funext i; simp [E] + rw [hfun] + congr 1 + unfold weight + simpa [E] using e.prod_comp (fun i => w (z i)) + +omit [Fintype κ] in +lemma restriction (w : Ω → ℝ) (ht : ∑ x, w x = 1) + (P : ι → Prop) (f : ({i // P i} → Ω) → ℝ) : + (∑ z : ι → Ω, weight w z*f (fun i => z i)) = + ∑ z : {i // P i} → Ω, weight w z*f z := by + let E := Equiv.piEquivPiSubtypeProd P (fun _ : ι => Ω) + rw [← E.symm.sum_comp] + simp only [Fintype.sum_prod_type] + have hsplit (z : {i // P i} → Ω) (z' : {i // ¬P i} → Ω) : + weight w (E.symm (z,z')) = weight w z*weight w z' := by + unfold weight + rw [← Fintype.prod_subtype_mul_prod_subtype P] + congr 1 + · apply prod_congr rfl + intro i _ + simp [E, i.property] + · apply prod_congr rfl + intro i _ + simp [E, i.property] + have hres (z : {i // P i} → Ω) (z' : {i // ¬P i} → Ω) : + (fun i : {i // P i} => E.symm (z,z') i) = z := by + funext i + simp [E, i.property] + simp_rw [hsplit, hres] + apply sum_congr rfl + intro z _ + calc + _ = weight w z*f z*(∑ z' : {i // ¬P i} → Ω, weight w z') := by + rw [mul_sum] + apply sum_congr rfl + intro z' _ + ring + _ = _ := by + have hz : (∑ z' : {i // ¬P i} → Ω, weight w z') = 1 := by + unfold weight + rw [← Fintype.prod_sum] + simp [ht] + rw [hz, mul_one] + +lemma marginal (w : Ω → ℝ) (ht : ∑ x, w x = 1) (e : κ ↪ ι) + (f : (κ → Ω) → ℝ) : + (∑ z : ι → Ω, weight w z*f (z ∘ e)) = ∑ z : κ → Ω, weight w z*f z := by + let E : κ ≃ {i // i ∈ Set.range e} := Equiv.ofInjective e e.injective + have h := restriction w ht (fun i => i ∈ Set.range e) + (fun z => f (z ∘ E)) + change (∑ z : ι → Ω, weight w z*f (z ∘ e)) = _ at h + rw [h] + convert reindex w E.symm f using 1 + simp only [Equiv.symm_symm] + congr! + +omit [Fintype κ] in +lemma coordinate_mean (w : Ω → ℝ) (ht : ∑ x, w x = 1) + (i : ι) (f : Ω → ℝ) : + (∑ z : ι → Ω, weight w z*f (z i)) = ∑ x, w x*f x := by + have hi (z : ι → Ω) : weight w z*f (z i) = + ∏ j, w (z j)*(if j=i then f (z j) else 1) := by + rw [prod_mul_distrib] + simp [weight] + simp_rw [hi] + rw [← Fintype.prod_sum (fun j x => w x*(if j=i then f x else 1))] + have he (j : ι) : (∑ x, w x*(if j=i then f x else 1)) = + if j=i then ∑ x, w x*f x else 1 := by + split_ifs <;> simp_all + simp_rw [he] + simp + +omit [Fintype κ] in + +lemma row_exists_le (w : Ω → ℝ) (hw : ∀ x, 0 ≤ w x) + (ht : ∑ x, w x = 1) (E : Ω → Prop) : + (∑ z : ι → Ω, weight w z*(if ∃ i, E (z i) then 1 else 0)) ≤ + (Fintype.card ι:ℝ)*(∑ x, w x*(if E x then 1 else 0)) := by + calc + _ ≤ ∑ z : ι → Ω, weight w z*(∑ i : ι, if E (z i) then 1 else 0) := by + apply sum_le_sum + intro z _ + apply mul_le_mul_of_nonneg_left _ (nonneg w hw z) + split_ifs with h + · obtain ⟨i,hi⟩ := h + have H := single_le_sum (fun j (_ : j ∈ (univ : Finset ι)) => + show (0:ℝ) ≤ if E (z j) then 1 else 0 by split_ifs <;> norm_num) (mem_univ i) + simpa only [ite_eq_left hi] using H + · apply sum_nonneg + intro i _ + split_ifs <;> norm_num + _ = ∑ i : ι, ∑ z : ι → Ω, weight w z*(if E (z i) then 1 else 0) := by + simp_rw [mul_sum] + exact sum_comm + _ = ∑ _i : ι, (∑ x, w x*(if E x then 1 else 0)) := by + apply sum_congr rfl + intro i _ + exact coordinate_mean w ht i (fun x => if E x then 1 else 0) + _ = _ := by simp + +end +end SharpLogRamsey.ProductLaw + +namespace SharpLogRamsey.FiniteMarginals +open scoped BigOperators +open Finset Classical +noncomputable section +variable {Ω Y ι : Type*} [Fintype Ω] [Fintype Y] [Fintype ι] + +omit [Fintype Y] [Fintype ι] in +def marginal (w : Ω → ℝ) (f : Ω → Y) (y : Y) : ℝ := ∑ z, if f z=y then w z else 0 + +omit [Fintype ι] in +lemma sum_marginal (w : Ω → ℝ) (f : Ω → Y) (g : Y → ℝ) : + (∑ y, marginal w f y*g y) = ∑ z, w z*g (f z) := by + unfold marginal + simp_rw [sum_mul] + rw [sum_comm] + apply sum_congr rfl + intro z _ + simp + +omit [Fintype ι] in +lemma marginal_total (w : Ω → ℝ) (f : Ω → Y) : ∑ y, marginal w f y=∑ z, w z := by + simpa using sum_marginal w f (fun _ => 1) + +omit [Fintype Y] [Fintype ι] in +lemma marginal_nonneg (w : Ω → ℝ) (hw : ∀ z, 0 ≤ w z) (f : Ω → Y) (y : Y) : + 0 ≤ marginal w f y := by + apply sum_nonneg + intro z _ + split_ifs + · exact hw z + · exact le_rfl + +omit [Fintype Y] in +lemma row_mass (w : Ω → ℝ) (f : Ω → Y) (u : ι → Y) : + ProductLaw.weight (marginal w f) u = + ∑ z : ι → Ω, ProductLaw.weight w z*(if (fun i => f (z i))=u then 1 else 0) := by + unfold ProductLaw.weight marginal + rw [Fintype.prod_sum] + apply sum_congr rfl + intro z _ + by_cases he : (fun i => f (z i))=u + · have hp : ∀ i, f (z i)=u i := congrFun he + simp [hp] + · rw [ite_eq_right he, mul_zero] + obtain ⟨i, hi⟩ : ∃ i, f (z i)≠u i := by + by_contra hh + push Not at hh + exact he (funext hh) + exact prod_eq_zero (mem_univ i) (ite_eq_right hi) + +lemma row_pushforward (w : Ω → ℝ) (f : Ω → Y) (F : (ι → Y) → ℝ) : + (∑ z : ι → Ω, ProductLaw.weight w z*F (fun i => f (z i))) = + ∑ u : ι → Y, ProductLaw.weight (marginal w f) u*F u := by + simp_rw [row_mass, sum_mul] + rw [sum_comm] + apply sum_congr rfl + intro z _ + simp + +end +end SharpLogRamsey.FiniteMarginals + +namespace SharpLogRamsey.HighRankSize +open scoped BigOperators +open Finset Classical HighRankDecoder RichUnion FiniteMarginals +noncomputable section +variable {K Ω : Type*} [Field K] [Fintype K] [Fintype Ω] {n : ℕ} +local instance flat_JoinedHighRankAssembly_2 : Fintype (Projectivization K (Fin n → K)) := Fintype.ofFinite _ +local instance flat_JoinedHighRankAssembly_3 : Finite (Module.Dual K (Fin n → K)) := + Finite.of_injective ((↑) : Module.Dual K (Fin n → K) → ((Fin n → K) → K)) DFunLike.coe_injective +local instance flat_JoinedHighRankAssembly_4 : Fintype (Projectivization K (Module.Dual K (Fin n → K))) := Fintype.ofFinite _ + +def rankPoints {h : ℕ} (a : Ω → Module.Dual K (Fin n → K)) + (b : Ω → Projectivization K (Fin n → K)) (z₁ : Fin h → Ω) (r : ℕ) := + univ.filter (fun y => Module.finrank K (hitSpan a b y z₁)=r) + +def points {h : ℕ} (a : Ω → Module.Dual K (Fin n → K)) + (b : Ω → Projectivization K (Fin n → K)) (z₁ z₂ : Fin h → Ω) (r T : ℕ) := + (rankPoints a b z₁ r).filter (fun y => + T ≤ (univ.filter (fun i => (b (z₂ i)).submodule ≤ hitSpan a b y z₁)).card) + +def domain {h : ℕ} (a : Ω → Module.Dual K (Fin n → K)) + (b : Ω → Projectivization K (Fin n → K)) (z₁ z₂ : Fin h → Ω) (r T : ℕ) : + Finset (Projectivization K (Fin n → K) × Projectivization K (Module.Dual K (Fin n → K))) := + univ.filter (fun t => Admitted a b z₁ z₂ r T t.1 t.2) + +omit [Fintype Ω] in +lemma partner_bound {r : ℕ} (hr : r + (HighRankExcess.partners (hitSpan a b y z₁)).image (Prod.mk y)) := by + ext t + simp only [domain, points, rankPoints, HighRankExcess.partners] + simp only [mem_filter, mem_univ, true_and, mem_biUnion, mem_image] + change (Admitted a b z₁ z₂ r T t.1 t.2) ↔ _ + unfold Admitted + constructor + · rintro ⟨hR,hC,hT⟩ + exact ⟨t.1,⟨hR,hT⟩,t.2,hC,rfl⟩ + · rintro ⟨y,⟨hR,hT⟩,c,hC,he⟩ + cases he + exact ⟨hR,hC,hT⟩ + rw [he] + calc + _ ≤ ∑ y ∈ points a b z₁ z₂ r T, + (((HighRankExcess.partners (hitSpan a b y z₁)).image (Prod.mk y)).card:ℝ) := by + exact_mod_cast card_biUnion_le + _ ≤ ∑ _y ∈ points a b z₁ z₂ r T, 2*(Fintype.card K:ℝ)^(n-r-1) := by + apply sum_le_sum + intro y hy + rw [card_image_of_injective _ (by intro c c' hh; exact (Prod.mk.inj hh).2)] + exact partner_bound hr _ (mem_filter.mp (mem_filter.mp hy).1).2 + _ = _ := by simp + +lemma mean_points {h : ℕ} (w : Ω → ℝ) (a : Ω → Module.Dual K (Fin n → K)) + (b : Ω → Projectivization K (Fin n → K)) (z₁ : Fin h → Ω) (r T : ℕ) : + (∑ z₂ : Fin h → Ω, ProductLaw.weight w z₂*((points a b z₁ z₂ r T).card:ℝ)) = + ∑ y ∈ rankPoints a b z₁ r, FiniteSamplingBounds.rowTail (marginal w b) + (projectivePoints (hitSpan a b y z₁)) h T := by + let F (z : Fin h → Projectivization K (Fin n → K)) : ℝ := + (((rankPoints a b z₁ r).filter (fun y => T ≤ + FiniteSamplingBounds.hitCount (projectivePoints (hitSpan a b y z₁)) z)).card:ℝ) + have he : ∀ z₂, ((points a b z₁ z₂ r T).card:ℝ) = F (fun i => b (z₂ i)) := by + intro z₂ + simp only [F, points, FiniteSamplingBounds.hitCount, mem_projectivePoints] + simp_rw [he] + have H := row_pushforward (ι := Fin h) w b F + calc + _ = ∑ z : Fin h → Projectivization K (Fin n → K), + ProductLaw.weight (marginal w b) z*F z := by + convert H using 1 + congr! + · congr 1 + ext z + simp + _ = _ := by + convert HighRankSampling.mean_admitted_eq (marginal w b) + (rankPoints a b z₁ r) (fun y => hitSpan a b y z₁) h T using 1 + congr! + +theorem expected_domain {h r T : ℕ} (hn : 0 hitSpan a b y z₁) + (fun y hy => (mem_filter.mp hy).2) (fun y _ => center_le a b y z₁) h T hT hTn + calc + _ ≤ ∑ z₂ : Fin h → Ω, ProductLaw.weight w z₂* + (((points a b z₁ z₂ r T).card:ℝ)*(2*(Fintype.card K:ℝ)^(n-r-1))) := by + apply sum_le_sum + intro z₂ _ + exact mul_le_mul_of_nonneg_left (domain_card hrn a b z₁ z₂ T) (ProductLaw.nonneg w hw z₂) + _ = (∑ z₂ : Fin h → Ω, ProductLaw.weight w z₂*((points a b z₁ z₂ r T).card:ℝ))* + (2*(Fintype.card K:ℝ)^(n-r-1)) := by simp only [← mul_assoc, sum_mul] + _ ≤ _ := by + rw [mean_points] + exact mul_le_mul_of_nonneg_right H (by positivity) + +end +end SharpLogRamsey.HighRankSize + +namespace SharpLogRamsey.FiniteRowProcess +open scoped BigOperators +open Finset Classical +noncomputable section +variable {Ω X : Type*} [Fintype Ω] + +def weight (w : Ω → ℝ) {n : ℕ} (z : Fin n → Ω) : ℝ := ∏ i, w (z i) + +omit [Fintype Ω] in +lemma weight_nonneg (w : Ω → ℝ) (hw : ∀ a, 0 ≤ w a) {n : ℕ} (z : Fin n → Ω) : + 0 ≤ weight w z := prod_nonneg (fun _ _ => hw _) + +lemma weight_total (w : Ω → ℝ) (hw : ∑ a, w a = 1) (n : ℕ) : + ∑ z : Fin n → Ω, weight w z = 1 := by + unfold weight + rw [← Fintype.prod_sum] + simp [hw] + +def run (step : X → Ω → X) : (n : ℕ) → (Fin n → Ω) → X → X + | 0, _, x => x + | n+1, z, x => run step n (Fin.tail z) (step x (z 0)) + +def expected (w : Ω → ℝ) (step : X → Ω → X) (n : ℕ) (x : X) (f : X → ℝ) : ℝ := + ∑ z : Fin n → Ω, weight w z * f (run step n z x) + +lemma expected_zero (w : Ω → ℝ) (step : X → Ω → X) (x : X) (f : X → ℝ) : + expected w step 0 x f = f x := by simp [expected, weight, run] + +lemma expected_succ (w : Ω → ℝ) (step : X → Ω → X) (n : ℕ) (x : X) (f : X → ℝ) : + expected w step (n+1) x f = ∑ a, w a * expected w step n (step x a) f := by + unfold expected + rw [← Equiv.sum_comp (Fin.consEquiv (fun _ : Fin (n+1) => Ω)) + (fun z => weight w z * f (run step (n+1) z x))] + simp only [Fintype.sum_prod_type] + change (∑ a, ∑ z, weight w (Fin.cons a z) * f (run step (n+1) (Fin.cons a z) x)) = _ + simp only [run, Fin.cons_zero, Fin.tail_cons, weight, Fin.prod_univ_succ, Fin.cons_succ] + simp only [mul_assoc, mul_sum] + +lemma expected_le_one (w : Ω → ℝ) (hw : ∀ a, 0 ≤ w a) (ht : ∑ a, w a = 1) + (step : X → Ω → X) (n : ℕ) (x : X) (f : X → ℝ) (hf : ∀ x, f x ≤ 1) : + expected w step n x f ≤ 1 := by + rw [← weight_total w ht n] + apply sum_le_sum + intro z _ + exact mul_le_of_le_one_right (weight_nonneg w hw z) (hf _) + +omit [Fintype Ω] in +lemma rank_run (step : X → Ω → X) (rank : X → ℕ) + (hmono : ∀ x a, rank x ≤ rank (step x a)) (n : ℕ) (z : Fin n → Ω) (x : X) : + rank x ≤ rank (run step n z x) := by + induction n generalizing x with + | zero => rfl + | succ n ih => exact (hmono x (z 0)).trans (ih (Fin.tail z) _) + +theorem rank_reached (w : Ω → ℝ) (hw : ∀ a, 0 ≤ w a) (ht : ∑ a, w a = 1) + (step : X → Ω → X) (rank : X → ℕ) (r : ℕ) (δ : ℝ) (hδ : 0 ≤ δ) + (hmono : ∀ x a, rank x ≤ rank (step x a)) + (hbad : ∀ x, rank x < r → + (∑ a, w a * (if rank (step x a) ≤ rank x then 1 else 0)) ≤ δ) + (n : ℕ) (x : X) (hx : r ≤ rank x+n) : + expected w step n x (fun y => if rank y < r then 1 else 0) ≤ n*δ := by + induction n generalizing x with + | zero => + rw [expected_zero] + simp only [Nat.add_zero] at hx + simp [Nat.not_lt.mpr hx] + | succ n ih => + by_cases hxr : r ≤ rank x + · have hz : expected w step (n+1) x (fun y => if rank y < r then 1 else 0) = 0 := by + apply sum_eq_zero + intro z _ + simp [Nat.not_lt.mpr (hxr.trans (rank_run step rank hmono _ z x))] + rw [hz] + positivity + · have hb := hbad x (Nat.lt_of_not_ge hxr) + rw [expected_succ] + calc + _ ≤ ∑ a, w a * ((n:ℝ)*δ + if rank (step x a) ≤ rank x then 1 else 0) := by + apply sum_le_sum + intro a _ + apply mul_le_mul_of_nonneg_left _ (hw a) + by_cases ha : rank (step x a) ≤ rank x + · rw [ite_eq_left ha] + exact (expected_le_one w hw ht step n (step x a) _ (by intro y; split_ifs <;> norm_num)).trans + (by nlinarith [show (0:ℝ) ≤ n from Nat.cast_nonneg n]) + · rw [ite_eq_right ha, add_zero] + apply ih + omega + _ = (n:ℝ)*δ + ∑ a, w a * (if rank (step x a) ≤ rank x then 1 else 0) := by + simp only [mul_add, sum_add_distrib, ← sum_mul, ht, one_mul] + _ ≤ (n:ℝ)*δ+δ := add_le_add_right hb _ + _ = (n+1:ℕ)*δ := by push_cast; ring + +end +end SharpLogRamsey.FiniteRowProcess + +namespace SharpLogRamsey.HighRankCoverage +open scoped BigOperators +open Finset Classical FiniteRowProcess +noncomputable section +variable {Ω K V : Type*} [Fintype Ω] [Field K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + +end +end SharpLogRamsey.HighRankCoverage +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/TrackedGeometry.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/TrackedGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..82e89d02a711b834b4b6be4bddf9f4e265d9dc9b --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/TrackedGeometry.lean @@ -0,0 +1,56 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.UniformStep +import OAI.Combinatorics.SharpRamsey.Marking.TrackedSelection + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset Real Marking +open scoped Classical BigOperators +noncomputable section +variable {Ω α : Type} [Fintype Ω] [Fintype α] {n m : ℕ} + {p : Law Ω} {G : Ω→Fin n→α} {B C L : ℝ} + +lemma ContextOutput.log_size (e : ContextOutput p G m B C L) {J : ℝ} + (hJ : 0 ≤ J) (hB : B ≤ exp J) : ∀ z i,log (e.domains z i).card ≤ J := by + intro z i + by_cases hz : (e.domains z i).card=0 + · simpa only [hz,Nat.cast_zero,log_zero] using hJ + · have hp : (0:ℝ) < (e.domains z i).card:=by exact_mod_cast Nat.pos_of_ne_zero hz + exact (log_le_log hp ((e.size z i).trans hB)).trans_eq (log_exp _) + +lemma ContextOutput.count_bound (e : ContextOutput p G m B C L) (P : α→Prop) + {M : ℝ} (h : ∀ x,p.mass x≠0→((univ.filter (fun i=>P (G x i))).card:ℝ) ≤ M) : + ∀ x,((univ.filter (fun i=>P (G (e.source x) (e.chosen x i)))).card:ℝ) ≤ M := by + intro x + have hh:=count_injective_restriction (e.chosen x).toEmbedding (fun i=>P (G (e.source x) i)) + apply le_trans _ (h _ (e.supported x)) + exact (Nat.cast_le (α:=ℝ)).mpr hh + +lemma ContextOutput.tracked_linear [Nonempty α] {β : Type} [Fintype β] {N n m : ℕ} + {H : Ω→Fin n→β} (e : ContextOutput p H m B C L) + (stream : Ω→Fin N→α) (F : Ω→Fin n→α) + (φ : α→β) (hφ : Function.Injective φ) (hH : ∀ x i,H x i=φ (F x i)) + {d : ℕ} (hd : 1 ≤ d) (hm : 0 < m) (hn : n ≤ N) + {D q σ η c : ℝ} (hD : 0 < D) (hL : 0 < L) (hq : 0 < q) (hσ : 1 ≤ σ) + (hη : 0 ≤ η) (hc : 0 < c) + (hdom : ∀ g,(p.map stream).mass g ≤ D/(Fintype.card α:ℝ)^N) + (hselect : ∀ x,p.mass x≠0→Occurs (F x) (stream x) ∨ Occurs (reverseTuple (F x)) (stream x)) + (hsize : (N:ℝ) ≤ q^d*σ) (hlength : c*q*σ^(1+η) ≤ m) + (halphabet : q^(2*d-1) ≤ (Fintype.card α:ℝ)) : + (m:ℝ)*((d:ℝ)*log q)-(1+|log c|+|log (2*(L*D))|)*m ≤ + entropy (e.μ.map (fun x i=>H (e.source x) (e.chosen x i))) := by + have hh:=e.tracked_entropy stream F φ hφ hH hd hm hn hD hL hq (by linarith) hc + hdom hselect hsize hlength halphabet + have hpos : (1:ℝ) ≤ m:=by exact_mod_cast hm + have hgain : 0 ≤ (m:ℝ)*(η*log σ):=mul_nonneg (Nat.cast_nonneg _) (mul_nonneg hη (log_nonneg hσ)) + have hm' : |log (2*(L*D))| ≤ (m:ℝ)*|log (2*(L*D))|:=le_mul_of_one_le_left (abs_nonneg _) hpos + have hc':=mul_le_mul_of_nonneg_left (neg_abs_le (log c)) (Nat.cast_nonneg m) + nlinarith only [hh,hgain,hm',hc',le_abs_self (log (2*(L*D)))] +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/TrackedSelection.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/TrackedSelection.lean new file mode 100644 index 0000000000000000000000000000000000000000..96da8567ff6d1cd0aae05c08fe6db5f91967459a --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/TrackedSelection.lean @@ -0,0 +1,115 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.OutputRebase +import OAI.Combinatorics.SharpRamsey.Entropy.SelectedEntropy + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset Real +open scoped Classical BigOperators +noncomputable section +variable {α β Ω : Type} [Fintype α] [Fintype β] [Fintype Ω] + +def reverseTuple {n : ℕ} (f : Fin n→α) : Fin n→α:=fun i=>f i.rev + +omit [Fintype α] in +lemma occurs_iff_orderEmbedding {N n : ℕ} (f : Fin n→α) (g : Fin N→α) : + Occurs f g ↔ ∃ e : Fin n↪o Fin N,∀ i,g (e i)=f i := by + constructor + · rintro ⟨S,hS⟩ + exact ⟨S.val.orderEmbOfFin S.property,hS⟩ + · rintro ⟨e,he⟩ + let S : Finset (Fin N):=univ.image e + have hS : S.card=n:=by rw [card_image_of_injective _ e.injective,card_univ,Fintype.card_fin] + refine ⟨⟨S,hS⟩,?_⟩ + have hh : e=S.orderEmbOfFin hS:=orderEmbOfFin_unique' hS (fun i=>mem_image.mpr ⟨i,mem_univ _,rfl⟩) + intro i + change g (S.orderEmbOfFin hS i)=f i + simpa only [←hh] using he i + +omit [Fintype α] in +lemma occurs_restrict {N n m : ℕ} {f : Fin n→α} {g : Fin N→α} + (e : Fin m↪o Fin n) (h : Occurs f g) : Occurs (fun i=>f (e i)) g := by + obtain ⟨j,hj⟩:=(occurs_iff_orderEmbedding _ _).mp h + exact (occurs_iff_orderEmbedding _ _).mpr ⟨e.trans j,fun i=>hj (e i)⟩ + +omit [Fintype α] in +lemma occurs_reverse_restrict {N n m : ℕ} {f : Fin n→α} {g : Fin N→α} + (e : Fin m↪o Fin n) (h : Occurs (reverseTuple f) g) : + Occurs (reverseTuple (fun i=>f (e i))) g := by + let er : Fin m↪o Fin n:=OrderEmbedding.ofStrictMono (fun i=>(e i.rev).rev) (by + intro i j hij + exact Fin.rev_lt_rev.mpr (e.strictMono (Fin.rev_lt_rev.mpr hij))) + have hh:=occurs_restrict er h + change Occurs (fun i=>f (Fin.rev ((e i.rev).rev))) g at hh + change Occurs (fun i=>f (e i.rev)) g + simpa only [Fin.rev_rev] using hh + +variable {N n m : ℕ} {p : Law Ω} {G : Ω→Fin n→β} {B C L : ℝ} + +lemma ContextOutput.map_domination (e : ContextOutput p G m B C L) + (stream : Ω→Fin N→α) {D : ℝ} (hL : 0 ≤ L) + (hdom : ∀ g,(p.map stream).mass g ≤ D/(Fintype.card α:ℝ)^N) : + ∀ g,(e.μ.map (stream∘e.source)).mass g ≤ L*D/(Fintype.card α:ℝ)^N := by + intro g + rw [←Law.map_map] + calc + _ ≤ ∑ x ∈ univ.filter (fun x=>stream x=g),L*p.mass x:=by + dsimp only [Law.map] + convert sum_le_sum (fun x (_ : x∈univ.filter (fun x=>stream x=g))=>e.dominated x) using 1 + congr! + _ = L*(p.map stream).mass g:=by + simp only [Law.map,mul_sum] + congr! + _ ≤ L*(D/(Fintype.card α:ℝ)^N):=mul_le_mul_of_nonneg_left (hdom g) hL + _ = _:=by ring + +lemma ContextOutput.length_le (e : ContextOutput p G m B C L) : m ≤ n := by + have hx : Nonempty e.X:=by + by_contra hh + have hz : Fintype.card e.X=0:=Fintype.card_eq_zero_iff.mpr (not_nonempty_iff.mp hh) + have : IsEmpty e.X:=Fintype.card_eq_zero_iff.mp hz + have he : (0:ℝ)=1:=by simpa using e.μ.total + norm_num at he + obtain ⟨x⟩:=hx + simpa only [Fintype.card_fin] using Fintype.card_le_of_injective (e.chosen x) (e.chosen x).injective + +theorem ContextOutput.tracked_entropy [Nonempty α] + (e : ContextOutput p G m B C L) (stream : Ω→Fin N→α) (F : Ω→Fin n→α) + (φ : α→β) (hφ : Function.Injective φ) (hG : ∀ x i,G x i=φ (F x i)) + {d : ℕ} (hd : 1 ≤ d) (hm : 0 < m) (hn : n ≤ N) + {D q σ η c : ℝ} (hD : 0 < D) (hL : 0 < L) (hq : 0 < q) (hσ : 0 < σ) (hc : 0 < c) + (hdom : ∀ g,(p.map stream).mass g ≤ D/(Fintype.card α:ℝ)^N) + (hselect : ∀ x,p.mass x≠0→Occurs (F x) (stream x) ∨ Occurs (reverseTuple (F x)) (stream x)) + (hsize : (N:ℝ) ≤ q^d*σ) (hlength : c*q*σ^(1+η) ≤ m) + (halphabet : q^(2*d-1) ≤ (Fintype.card α:ℝ)) : + (m:ℝ)*((d:ℝ)*log q+η*log σ+log c-1)-log (2*(L*D)) ≤ + entropy (e.μ.map (fun x i=>G (e.source x) (e.chosen x i))) := by + let f:=fun x i=>F (e.source x) (e.chosen x i) + have hselection : ∀ x,e.μ.mass x≠0→Occurs (f x) (stream (e.source x)) ∨ + Occurs (reverseTuple (f x)) (stream (e.source x)):=by + intro x _ + rcases hselect (e.source x) (e.supported x) with h|h + · exact Or.inl (occurs_restrict (e.chosen x) h) + · exact Or.inr (occurs_reverse_restrict (e.chosen x) h) + have hh:=selected_map_entropy hd hm (e.length_le.trans hn) e.μ (stream∘e.source) f reverseTuple + (mul_pos hL hD) hq hσ hc (e.map_domination stream hL.le hdom) hselection hsize hlength halphabet + have he : entropy (e.μ.map (fun x i=>G (e.source x) (e.chosen x i)))=entropy (e.μ.map f) := by + have hp : Function.Injective (fun a : Fin m→α=>φ∘a):=by + intro a b hab + funext i + exact hφ (congrFun hab i) + have h:=entropy_map_eq_of_injective (e.μ.map f) (fun a : Fin m→α=>φ∘a) hp + rw [Law.map_map] at h + convert h using 1 + congr 2 + funext x i + exact hG _ _ + rwa [he] +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/TrackedStep.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/TrackedStep.lean new file mode 100644 index 0000000000000000000000000000000000000000..4931d51dc6d8da45403fac26c5778b4f4855b75a --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/TrackedStep.lean @@ -0,0 +1,156 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.TrackedGeometry + +namespace OAI + +section +namespace SharpLogRamsey.Marking +open Finset Real Filter Selection Selection.Windows ActualHighRank SourceScales +open scoped Classical BigOperators Topology +noncomputable section +local instance trackFiniteDual {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Fin (d+1)→K)) := + Finite.of_injective ((↑) : Module.Dual K (Fin (d+1)→K)→((Fin (d+1)→K)→K)) DFunLike.coe_injective +local instance trackFiniteDouble {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Module.Dual K (Fin (d+1)→K))) := + Finite.of_injective ((↑) : Module.Dual K (Module.Dual K (Fin (d+1)→K))→(Module.Dual K (Fin (d+1)→K)→K)) DFunLike.coe_injective +local instance trackProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Fin (d+1)→K)) := Fintype.ofFinite _ +local instance trackDualProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Fin (d+1)→K))) := Fintype.ofFinite _ +local instance trackDoubleProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Module.Dual K (Fin (d+1)→K)))) := Fintype.ofFinite _ + +lemma flag_alphabet_lower (i q : ℕ) [Fact q.Prime] : + (q:ℝ)^(2*(i+3)-1) ≤ (Fintype.card (Flag (ZMod q) (Fin (i+4)→ZMod q)):ℝ) := by + have hdim : Module.finrank (ZMod q) (Fin (i+4)→ZMod q)=(i+3)+1:=by simp + have halphabet : (q:ℝ)^(2*(i+3)-1) ≤ (Fintype.card (Flag (ZMod q) (Fin (i+4)→ZMod q)):ℝ):=by + have hh : q^(2*(i+3)-1) ≤ Fintype.card (Flag (ZMod q) (Fin (i+4)→ZMod q)):=by + rw [actualFlag_card hdim,Nat.card_zmod] + have h1 : q^(i+3) ≤ ∑ j∈range ((i+3)+1),q^j:=single_le_sum (by intros;positivity) (mem_range.mpr (by omega)) + have h2 : q^(i+2) ≤ ∑ j∈range (i+3),q^j:=single_le_sum (by intros;positivity) (mem_range.mpr (by omega)) + calc + _ = q^(i+3)*q^(i+2):=by rw [←pow_add];congr 1;omega + _ ≤ _:=Nat.mul_le_mul h1 h2 + exact_mod_cast hh + exact halphabet + +lemma tracked_log_budget (i q : ℕ) (σ Δ P : ℝ) (hσ : 0 ≤ σ) (hΔ : 0 ≤ Δ) + (hP : 1 ≤ P) (he : exp σ=(q:ℝ)) : + 0 ≤ log P+((i+3:ℕ):ℝ)*σ+Δ ∧ + P*(q:ℝ)^(i+3)*exp Δ ≤ exp (log P+((i+3:ℕ):ℝ)*σ+Δ) ∧ + log P+((i+3:ℕ):ℝ)*σ+Δ-jointJ (ZMod q) (i+3) ≤ Δ+(|log P|+|log 64|) := by + have hq0 : (0:ℝ) < q:=he ▸ exp_pos _ + have hP0 : 0 < P:=lt_of_lt_of_le zero_lt_one hP + have hlogq : log (q:ℝ)=σ:=by rw [←he,log_exp] + refine ⟨by have:=log_nonneg hP;positivity,?_,?_⟩ + · rw [exp_add,exp_add,exp_log hP0,exp_nat_mul,he] + · dsimp only [jointJ] + rw [Nat.card_zmod,log_mul (by norm_num) (pow_ne_zero _ hq0.ne'),log_pow,hlogq] + linarith [le_abs_self (log P),neg_abs_le (log 64)] + +lemma flag_context_linear (i q : ℕ) [Fact q.Prime] (σ η c Lstar : ℝ) + (hσ : 1 ≤ σ) (hη : 0 ≤ η) (hc : 0 < c) (hLs : 0 < Lstar) + (he : exp σ=(q:ℝ)) + (Ω : Type) [Fintype Ω] (N k m : ℕ) (p : Law Ω) + (stream : Ω→Fin N→Flag (ZMod q) (Fin (i+4)→ZMod q)) + (F : Ω→Fin k→Flag (ZMod q) (Fin (i+4)→ZMod q)) + (B Λ L : ℝ) (hLL : L ≤ Lstar) (hkn : k ≤ N) + (hdom : ∀ g,(p.map stream).mass g ≤ 2/(Fintype.card (Flag (ZMod q) (Fin (i+4)→ZMod q)):ℝ)^N) + (hselect : ∀ x,p.mass x≠0→Occurs (F x) (stream x) ∨ Occurs (reverseTuple (F x)) (stream x)) + (hN : (N:ℝ) ≤ (q:ℝ)^(i+3)*σ) + (e : ContextOutput p (fun x j=>flagPair (F x j)) m B Λ L) + (hmlo : c*(q:ℝ)*σ^(1+η) ≤ m) : + (m:ℝ)*((i+3:ℕ):ℝ)*σ-(1+|log c|+|log (2*(Lstar*2))|)*m ≤ + entropy (e.μ.map (fun x j=>flagPair (F (e.source x) (e.chosen x j)))) := by + have hq0 : (0:ℝ) < q:=he ▸ exp_pos _ + have hσ0 : 0 < σ:=lt_of_lt_of_le zero_lt_one hσ + have hm : 0 < m:=by + have : (0:ℝ) < m:=(by positivity : (0:ℝ) < c*(q:ℝ)*σ^(1+η)).trans_le hmlo + exact_mod_cast this + have halphabet:=flag_alphabet_lower i q + have : Nonempty (Flag (ZMod q) (Fin (i+4)→ZMod q)):=Fintype.card_pos_iff.mp (by + have : (0:ℝ) < (Fintype.card (Flag (ZMod q) (Fin (i+4)→ZMod q)):ℝ):=(pow_pos hq0 _).trans_le halphabet + exact_mod_cast this) + let ee:=e.mono (le_refl _) (le_refl _) hLL + have hh:=ee.tracked_linear stream F flagPair flagPair_injective (by intros;rfl) + (by omega : 1 ≤ i+3) hm hkn (by norm_num : (0:ℝ) < 2) hLs hq0 hσ hη hc + hdom hselect hN hmlo halphabet + have hlogq : log (q:ℝ)=σ:=by rw [←he,log_exp] + rw [hlogq] at hh + dsimp only [ee,ContextOutput.mono] at hh + convert hh using 1 <;> first | ring | congr! + +lemma flag_context_occ (i q : ℕ) [Fact q.Prime] + (Ω : Type) [Fintype Ω] (k m : ℕ) (p : Law Ω) + (F : Ω→Fin k→Flag (ZMod q) (Fin (i+4)→ZMod q)) (B Λ L M : ℝ) + (hocc : ∀ x,p.mass x≠0→∀ W : Submodule (ZMod q) (Fin (i+4)→ZMod q), + ((univ.filter (fun j : Fin k=>(flagPair (F x j)).swap∈ + orthogonalRectangle Projectivization.rep Projectivization.rep W)).card:ℝ) ≤ M) + (e : ContextOutput p (fun x j=>flagPair (F x j)) m B Λ L) : + ∀ x,e.μ.mass x≠0→∀ W : Submodule (ZMod q) (Fin (i+4)→ZMod q), + ((univ.filter (fun j=>covectorTuple (fun j=>flagPair (F (e.source x) (e.chosen x j))) j∈ + orthogonalRectangle Projectivization.rep Projectivization.rep W)).card:ℝ) ≤ M := by + intro x _ W + have hh:=count_injective_restriction (e.chosen x).toEmbedding + (fun j=>(flagPair (F (e.source x) j)).swap∈orthogonalRectangle Projectivization.rep Projectivization.rep W) + apply le_trans _ (hocc _ (e.supported x) W) + convert (Nat.cast_le (α:=ℝ)).mpr hh using 1 + congr! + congr 2 + ext index + simp only [orthogonalRectangle,mem_filter,mem_univ,true_and] + +theorem eventually_tracked_step (i : ℕ) (η c Lstar P M0 : ℝ) + (hη : 0 < η) (hηu : η ≤ 1) (hc : 0 < c) (hLs : 0 < Lstar) + (hP : 1 ≤ P) (hPs : stepPrefactor (i+3) ≤ P) (hM0 : 0 ≤ M0) : + ∀ᶠ σ : ℝ in atTop, ∀ (q : ℕ) [Fact q.Prime], 3 ≤ q → exp σ=(q:ℝ) → + ∀ (Ω : Type) [Fintype Ω] (N k m : ℕ) (p : Law Ω) + (stream : Ω→Fin N→Flag (ZMod q) (Fin (i+4)→ZMod q)) + (F : Ω→Fin k→Flag (ZMod q) (Fin (i+4)→ZMod q)) + (Λ Δ L : ℝ) (R : ℕ), + 0 < k → k ≤ N → (k:ℝ) ≤ (q:ℝ)*σ^(1+η) → + 0 ≤ Λ → 0 ≤ Δ → 0 < L → L ≤ Lstar → + Admissible σ η (stageD σ η k Λ Δ) R → + (∀ g,(p.map stream).mass g ≤ 2/(Fintype.card (Flag (ZMod q) (Fin (i+4)→ZMod q)):ℝ)^N) → + (∀ x,p.mass x≠0→Occurs (F x) (stream x) ∨ Occurs (reverseTuple (F x)) (stream x)) → + (N:ℝ) ≤ (q:ℝ)^(i+3)*σ → + (∀ x,p.mass x≠0→ScanConsistent ((List.ofFn (fun j=>flagPair (F x j))).map toScan)) → + (∀ x,p.mass x≠0→∀ W : Submodule (ZMod q) (Fin (i+4)→ZMod q), + ((univ.filter (fun j : Fin k=>(flagPair (F x j)).swap∈ + orthogonalRectangle Projectivization.rep Projectivization.rep W)).card:ℝ) ≤ M0*σ) → + (e : ContextOutput p (fun x j=>flagPair (F x j)) m + (P*(q:ℝ)^(i+3)*exp Δ) Λ L) → c*(q:ℝ)*σ^(1+η) ≤ m → + ∃ m' : ℕ, (m:ℝ)/(256*classCount i) ≤ m' ∧ + Nonempty (ContextOutput p (fun x j=>flagPair (F x j)) m' + (P*(q:ℝ)^(i+3)*exp (16*scaleKstar σ η (stageD σ η k Λ Δ))) + (stageD σ η k Λ Δ*σ^(-η/3)*(k:ℝ)) ((4*classCount i)*L)) := by + let A:=1+|log c|+|log (2*(Lstar*2))| + let B:=|log P|+|log 64| + have hA : 0 ≤ A:=by dsimp [A];positivity + have hB : 0 ≤ B:=by dsimp [B];positivity + filter_upwards [eventually_uniform_step i η c 1 A B M0 hη hηu hc (by norm_num) hA hB hM0, + eventually_ge_atTop (1:ℝ)] with σ hstep hσ + intro q _ hq he Ω _ N k m p stream F Λ Δ L R hk hkn hku hΛ hΔ hL hLL had hdom hselect hN hcon hocc e hmlo + have hσ0 : 0 < σ:=lt_of_lt_of_le zero_lt_one hσ + have hF:=flag_context_linear i q σ η c Lstar hσ hη.le hc hLs he Ω N k m p stream F + _ Λ L hLL hkn hdom hselect hN e hmlo + let G:=fun x j=>flagPair (F (e.source x) (e.chosen x j)) + let J:=log P+((i+3:ℕ):ℝ)*σ+Δ + obtain ⟨hJ0,hBJ,hJgap⟩:=tracked_log_budget i q σ Δ P hσ0.le hΔ hP he + have hcons : ∀ x,e.μ.mass x≠0→ScanConsistent ((List.ofFn (G x)).map toScan):=by + intro x _ + exact scanConsistent_ordered _ (hcon _ (e.supported x)) (e.chosen x) + have hocc':=flag_context_occ i q Ω k m p F _ Λ L (M0*σ) hocc e + obtain ⟨m',hmret,⟨out⟩⟩:=hstep q hq he e.X e.Γ m k e.μ e.msg G e.domains Λ Δ J R + hk hΛ hΔ hku hmlo (by simpa only [one_mul] using (show (m:ℝ) ≤ k by exact_mod_cast e.length_le).trans hku) + had e.cost hF hJgap (e.log_size hJ0 hBJ) + (fun x _ j=>e.hit x j) (fun x _ j=>(F (e.source x) (e.chosen x j)).incident) hcons hocc' + have hs : stepPrefactor (i+3)*(q:ℝ)^(i+3)*exp (16*scaleKstar σ η (stageD σ η k Λ Δ)) ≤ + P*(q:ℝ)^(i+3)*exp (16*scaleKstar σ η (stageD σ η k Λ Δ)):=by gcongr + have hcost : stageD σ η k Λ Δ*σ^(-η/3)*(m:ℝ) ≤ stageD σ η k Λ Δ*σ^(-η/3)*(k:ℝ):=by + apply mul_le_mul_of_nonneg_left (by exact_mod_cast e.length_le) + unfold stageD + positivity + exact ⟨m',hmret,⟨e.compose (out.mono hs hcost (le_refl _)) (by positivity)⟩⟩ +end +end SharpLogRamsey.Marking + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/UniformStep.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/UniformStep.lean new file mode 100644 index 0000000000000000000000000000000000000000..df7c35bf51c593edca0192c29ebc94d5cdebb8a7 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/UniformStep.lean @@ -0,0 +1,108 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.SelectedStep +import OAI.Combinatorics.SharpRamsey.Marking.StageBudget + +namespace OAI + +section +namespace SharpLogRamsey.Marking +open Finset Real Filter Selection Selection.Windows ActualHighRank SourceScales +open scoped Classical BigOperators Topology +noncomputable section +local instance uniformFiniteDual {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Fin (d+1)→K)) := + Finite.of_injective ((↑) : Module.Dual K (Fin (d+1)→K)→((Fin (d+1)→K)→K)) DFunLike.coe_injective +local instance uniformFiniteDouble {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Module.Dual K (Fin (d+1)→K))) := + Finite.of_injective ((↑) : Module.Dual K (Module.Dual K (Fin (d+1)→K))→(Module.Dual K (Fin (d+1)→K)→K)) DFunLike.coe_injective +local instance uniformProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Fin (d+1)→K)) := Fintype.ofFinite _ +local instance uniformDualProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Fin (d+1)→K))) := Fintype.ofFinite _ +local instance uniformDoubleProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Module.Dual K (Fin (d+1)→K)))) := Fintype.ofFinite _ + +theorem eventually_uniform_step (i : ℕ) (η c C A B M0 : ℝ) + (hη : 0 < η) (hηu : η ≤ 1) (hc : 0 < c) (hC : 0 < C) + (hA : 0 ≤ A) (hB : 0 ≤ B) (hM0 : 0 ≤ M0) : + ∀ᶠ σ : ℝ in atTop, ∀ (q : ℕ) [Fact q.Prime], 3 ≤ q → exp σ=(q:ℝ) → + ∀ (Ω Γ : Type) [Fintype Ω] [Fintype Γ] (N k : ℕ) (p : Law Ω) (msg : Ω→Γ) + (F : Ω→Fin N→ProjectivePair (K:=ZMod q) (V:=Fin (i+4)→ZMod q)) + (S : Γ→Fin N→Finset (ProjectivePair (K:=ZMod q) (V:=Fin (i+4)→ZMod q))) + (Λ Δ J : ℝ) (R : ℕ), + 0 < k → 0 ≤ Λ → 0 ≤ Δ → (k:ℝ) ≤ (q:ℝ)*σ^(1+η) → + c*(q:ℝ)*σ^(1+η) ≤ N → (N:ℝ) ≤ C*q*σ^(1+η) → + Admissible σ η (stageD σ η k Λ Δ) R → + entropy (p.map msg) ≤ Λ → + (N:ℝ)*((i+3:ℕ):ℝ)*σ-A*N ≤ entropy (p.map F) → + J-jointJ (ZMod q) (i+3) ≤ Δ+B → + (∀ z j,log (S z j).card ≤ J) → + (∀ x,p.mass x≠0→∀ j,F x j∈S (msg x) j) → + (∀ x,p.mass x≠0→∀ j,Incidence.Incident (F x j).1 (F x j).2) → + (∀ x,p.mass x≠0→ScanConsistent ((List.ofFn (F x)).map toScan)) → + (∀ x,p.mass x≠0→∀ W : Submodule (ZMod q) (Fin (i+4)→ZMod q), + ((univ.filter (fun j : Fin N=>covectorTuple (F x) j∈ + orthogonalRectangle Projectivization.rep Projectivization.rep W)).card:ℝ) ≤ M0*σ) → + ∃ m' : ℕ, (N:ℝ)/(256*classCount i) ≤ m' ∧ + Nonempty (ContextOutput p F m' (stepPrefactor (i+3)*(q:ℝ)^(i+3)*exp (16*scaleKstar σ η (stageD σ η k Λ Δ))) + (stageD σ η k Λ Δ*σ^(-η/3)*(N:ℝ)) (4*classCount i)) := by + let K:=classCount i + let Ecoef:=64*(((i+1:ℕ):ℝ)+4)^3 + let A1:=log 64+2*log (3*(((i+1:ℕ):ℝ)+4))+A+B + let B1:=(1+Ecoef)/c+A1 + let C0:=max M0 (4*(K:ℝ)^2*B1)+1 + have hK : 0 < K:=classCount_pos i + have hKr : (0:ℝ) < K:=by exact_mod_cast hK + have hE : 0 ≤ Ecoef:=by dsimp only [Ecoef];positivity + have hA1 : 0 ≤ A1:=by + have hl : (1:ℝ) ≤ 3*(((i+1:ℕ):ℝ)+4):=by + have : (0:ℝ) ≤ (i+1:ℕ):=by positivity + nlinarith + dsimp only [A1] + linarith [log_nonneg hl,log_nonneg (by norm_num : (1:ℝ) ≤ 64)] + have hB1 : 0 ≤ B1:=by dsimp only [B1];positivity + have hC0 : 0 < C0:=by dsimp only [C0];linarith [le_max_left M0 (4*(K:ℝ)^2*B1)] + have hMup : M0 ≤ C0:=by dsimp only [C0];linarith [le_max_left M0 (4*(K:ℝ)^2*B1)] + have hCostup : 4*(K:ℝ)^2*B1 ≤ C0:=by dsimp only [C0];linarith [le_max_right M0 (4*(K:ℝ)^2*B1)] + filter_upwards [eventually_selected_step i η (c/(4*K)) C C0 hη hηu (by positivity) hC hC0, + eventually_class_packing η c Ecoef K hη hc hE hK, + eventually_ge_atTop (1:ℝ)] with σ hstep hpack hσ + intro q _ hq he Ω Γ _ _ N k p msg F S Λ Δ J R hk hΛ hΔ hkup hNlo hNhi had hmsg hF hJ hSJ hS hf hcon hocc + have hσ0 : 0 < σ:=by linarith + have hq0 : (0:ℝ) < q:=he ▸ exp_pos _ + have hlog : log (Nat.card (ZMod q):ℝ)=σ:=by rw [Nat.card_zmod,←he,log_exp] + have hdim : Module.finrank (ZMod q) (Fin (i+4)→ZMod q)=(i+1)+3:=by simp + let D:=stageD σ η k Λ Δ + let Dn:=D*σ^(-beta η) + have hDn : 0 ≤ Dn:=by dsimp only [Dn,D,stageD];positivity + let m:=N/(2*K) + obtain ⟨hm,hNm,hKm,hpacking,hmlo⟩:=hpack (q:ℝ) N he hNlo + have hmhi : (m:ℝ) ≤ C*q*σ^(1+η):= + (show (m:ℝ) ≤ N by exact_mod_cast Nat.div_le_self N (2*K)).trans hNhi + have hx:=excessCost_linear hdim p msg F σ Λ Δ A B J hlog hσ hΔ hB hmsg hF hJ + rw [Nat.card_zmod] at hx + have hxb := stage_budget_bound hσ0 hk hΛ hΔ hq0 hc hA1 hE hkup hNlo + have hcb := class_budget_scale hK hB1 hDn hNm (hx.trans hxb) + have hcb' : excessCost p msg F J (jointJ (ZMod q) (i+3)) ≤ + C0*(m:ℝ)*D*σ^(-beta η)/(K:ℝ) := by + apply hcb.trans + calc + _ = (4*(K:ℝ)^2*B1)*((m:ℝ)*Dn/(K:ℝ)):=by ring + _ ≤ C0*((m:ℝ)*Dn/(K:ℝ)):=mul_le_mul_of_nonneg_right hCostup (by positivity) + _ = _:=by dsimp only [Dn];ring + have hpacking' : ((classCount i*m:ℕ):ℝ)+ + expensiveBudget (ZMod q) (Fin (i+4)→ZMod q)+ + expensiveBudget (ZMod q) (Module.Dual (ZMod q) (Fin (i+4)→ZMod q)) ≤ N := by + have hh:=twoExpensive_linear hdim hlog hσ + rw [Nat.card_zmod] at hh + dsimp only [Ecoef] at hpacking + linarith only [hh,hpacking] + obtain ⟨m',hmret,⟨out⟩⟩:=hstep q hq he Ω Γ N m p msg F S D J R had hmlo hmhi + hSJ hS hf hcon hpacking' hcb' (by + intro x hx W + exact (hocc x hx W).trans (mul_le_mul_of_nonneg_right hMup hσ0.le)) + refine ⟨m',?_,⟨out⟩⟩ + have hn : (N:ℝ) ≤ 4*K*m:=by exact_mod_cast hNm + apply (div_le_iff₀ (show (0:ℝ) < 256*K by positivity)).mpr + nlinarith only [hn,hmret] +end +end SharpLogRamsey.Marking + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Marking/UniformSupports.lean b/lean/OAI/Combinatorics/SharpRamsey/Marking/UniformSupports.lean new file mode 100644 index 0000000000000000000000000000000000000000..78efa2695f170ea9385213c497c77d1b931b3224 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Marking/UniformSupports.lean @@ -0,0 +1,98 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Selection.SupportThreshold + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset Real Filter +open scoped Classical BigOperators Topology +noncomputable section + +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K V)] + +lemma projective_entropy_le {n : ℕ} (hdim : Module.finrank K V=n+3) + (p : Law (Projectivization K V)) : + entropy p ≤ (n+3:ℕ)*log (Nat.card K) := by + have hq : (2:ℝ)≤Nat.card K := by + exact_mod_cast (show 2≤Nat.card K from Finite.one_lt_card) + have hc : (Fintype.card (Projectivization K V):ℝ) ≤ (Nat.card K:ℝ)^(n+3) := by + rw [←Nat.card_eq_fintype_card,Projectivization.card_of_finrank K V hdim, + Nat.cast_sum] + simp only [Nat.cast_pow] + apply (sum_powers_le_twice hq (by omega : 0 + (((s - 1 : ℕ) : ℝ) * Real.log (t : ℝ) - Real.log (ramsey s t : ℝ)) / + Real.log (Real.log (t : ℝ))) + Filter.atTop (nhds ((s - 2 : ℕ) : ℝ)) + +end SharpLogRamsey + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Parameters/BookScales.lean b/lean/OAI/Combinatorics/SharpRamsey/Parameters/BookScales.lean new file mode 100644 index 0000000000000000000000000000000000000000..5023502216edbabbf989df835f351aebe71ad747 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Parameters/BookScales.lean @@ -0,0 +1,54 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Windows.UniformBook + +namespace OAI + +section +namespace SharpLogRamsey.SourceScales +open Real Filter +open scoped Topology +noncomputable section + +lemma Kstar_ge_one {σ η D : ℝ} {R : ℕ} (hσ : 1≤σ) (hη : 0<η) + (had : Admissible σ η D R) : 1≤ scaleKstar σ η D := by + apply one_le_mul_of_one_le_of_one_le + · exact (one_le_rpow hσ (beta_pos hη).le).trans had.D_lower + · exact one_le_rpow hσ (by have := beta_pos hη; positivity) + +lemma P_ge_Kstar {σ η D : ℝ} {R : ℕ} (hσ : 0<σ) + (had : Admissible σ η D R) : + scaleKstar σ η D*σ^(3*beta η)≤ scaleP σ η D R := by + have hD : 0σ^(-100*beta η)) atTop (𝓝 0) := by + simpa only [neg_mul] using tendsto_rpow_neg_atTop (show 0<100*beta η by positivity) + filter_upwards [(tendsto_rpow_atTop (show 0<3*beta η by positivity)).eventually_ge_atTop + (16+log 1000000),ht.eventually (eventually_le_nhds (by norm_num : (0:ℝ)<1/40000)), + eventually_ge_atTop (1:ℝ)] with σ hpow hτ hσ D R had + have hσ0 : 0<σ:=by linarith + have hK:=Kstar_ge_one hσ hη had + have hlo:=P_ge_Kstar hσ0 had + have hlog : 0≤log (1000000:ℝ):=log_nonneg (by norm_num) + have hKP : 16*scaleKstar σ η D+log 1000000≤ scaleP σ η D R := by + nlinarith [mul_le_mul_of_nonneg_left hpow (by linarith : 0≤ scaleKstar σ η D), + mul_le_mul_of_nonneg_left hK hlog] + exact ⟨by positivity,by linarith,hKP,rpow_pos_of_pos hσ0 _,hτ⟩ +end +end SharpLogRamsey.SourceScales + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Parameters/EndpointScales.lean b/lean/OAI/Combinatorics/SharpRamsey/Parameters/EndpointScales.lean new file mode 100644 index 0000000000000000000000000000000000000000..a466f842d8623ea11c7cf72b486eebd5908d8332 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Parameters/EndpointScales.lean @@ -0,0 +1,62 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.UniformSupports + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset Real +open scoped Classical BigOperators +noncomputable section + +lemma endpoint_error_scale {x b κ δ H L S C₀ : ℝ} + (hx : 1≤x) (hb : 0≤b) (hC₀ : 0≤C₀) + (hκ : x^(4*b)≤κ) (hδ : δ≤κ*x^(-2*b)) + (hH : L-H≤δ) (hS : S*exp (-L)≤C₀) : + exp (-κ)+(L-H+S*exp (-L))/(κ*(1/50))≤ + (51+50*C₀)*x^(-2*b) := by + have hx0 : 0¬goodFirst p MA L κ (1/50) a))≤(51+50*C₀)*x^(-2*β) ∧ + p.snd.event (univ.filter (fun b=>¬goodSecond p MB L κ (1/50) b))≤(51+50*C₀)*x^(-2*β) := by + have hκ0 : 0<κ := (rpow_pos_of_pos (by linarith : 0C*σ^(-2*beta η)) atTop (𝓝 0) := by + simpa only [mul_zero,neg_mul] using + (tendsto_rpow_neg_atTop (by positivity : 0<2*beta η)).const_mul C + have h2 : Tendsto (fun σ : ℝ=>(2*C/c)*σ^(-1001*beta η)) atTop (𝓝 0) := by + simpa only [mul_zero,neg_mul] using + (tendsto_rpow_neg_atTop (by positivity : 0<1001*beta η)).const_mul (2*C/c) + have h3 : Tendsto (fun σ : ℝ=>(4*C/c)*σ^(2000*beta η-η/2)) atTop (𝓝 0) := by + simpa only [mul_zero,neg_neg] using (tendsto_rpow_neg_atTop (neg_pos.mpr hexp)).const_mul (4*C/c) + have ht := (h1.add h2).add h3 + simp only [add_zero] at ht + filter_upwards [ht.eventually (gt_mem_nhds hε),eventually_gt_atTop (0:ℝ)] with σ hsmall hσ + intro q D N budget M n k hq hD hN hbudget hM hk hn + dsimp only + let a:=σ^(-2000*beta η)/q + have ha : 0flagPair (F x j))).map toScan)) → + (∀ x,p.mass x≠0→∀ W : Submodule (ZMod q) (Fin (i+4)→ZMod q), + ((univ.filter (fun j : Fin k=>(flagPair (F x j)).swap∈ + orthogonalRectangle Projectivization.rep Projectivization.rep W)).card:ℝ) ≤ M0*σ) → + ContextOutput p (fun x j=>flagPair (F x j)) k + (P*(q:ℝ)^(i+3)*exp (((i+2:ℕ):ℝ)*σ)) 0 1 → + ∃ m : ℕ,c*(q:ℝ)*σ^(1+η) ≤ m ∧ + Nonempty (ContextOutput p (fun x j=>flagPair (F x j)) m + (P*(q:ℝ)^(i+3)*exp (48*σ^(8*beta η))) k Lstar) := by + intro T r Lstar c + have hK : 0 < classCount i:=classCount_pos i + have hr : 1 ≤ r:=by + dsimp [r] + have : (1:ℝ) ≤ classCount i:=by exact_mod_cast hK + linarith + have hr0 : 0 < r:=by linarith + have hLone : (1:ℝ) ≤ 4*classCount i:=by + have : (1:ℝ) ≤ classCount i:=by exact_mod_cast hK + linarith + have hLs : 0 < Lstar:=by dsimp [Lstar];positivity + have hc : 0 < c:=by dsimp [c];positivity + filter_upwards [eventually_tracked_step i η c Lstar P M0 hη hηu hc hLs hP hPs hM0, + eventually_iteration_budgets (i+3) η hη hηu,eventually_ge_atTop (1:ℝ)] with σ hstep hbud hσ + intro q _ hq he Ω _ N k p stream F hk hkn hku hklo hdom hselect hN hcon hocc e0 + obtain ⟨hdata,hΛlast,hΔlast⟩:=hbud k hk + have hσ0 : 0 < σ:=by linarith + have hq0 : (0:ℝ) < q:=he ▸ exp_pos _ + have hh : ∀ n ≤ T, ∃ m : ℕ,(k:ℝ)/r^n ≤ m ∧ + Nonempty (ContextOutput p (fun x j=>flagPair (F x j)) m + (P*(q:ℝ)^(i+3)*exp (iterationBudgets (i+3) σ η k n).2) + (iterationBudgets (i+3) σ η k n).1 ((4*classCount i)^n)) := by + intro n + induction n with + | zero => intro _; exact ⟨k,by simp,by simpa only [iterationBudgets,pow_zero,show i+3-1=i+2 by omega] using Nonempty.intro e0⟩ + | succ n ih => + intro hn + obtain ⟨m,hm,⟨e⟩⟩:=ih (by omega) + have hml : c*(q:ℝ)*σ^(1+η) ≤ m:=by + have hh:=retained_length hr (by positivity : 0 ≤ (q:ℝ)*σ^(1+η)) (by omega : n ≤ T) hklo hm + simpa only [c,mul_assoc] using hh + have hL : (0:ℝ) < (4*classCount i)^n:=by positivity + have hLL : ((4*classCount i)^n:ℝ) ≤ Lstar:=pow_le_pow_right₀ hLone (by omega) + obtain ⟨m',hm',⟨out⟩⟩:=hstep q hq he Ω N k m p stream F + (iterationBudgets (i+3) σ η k n).1 (iterationBudgets (i+3) σ η k n).2 + ((4*classCount i)^n) (evenScale σ η) hk hkn hku (hdata n).1 (hdata n).2.1 + hL hLL (hdata n).2.2 hdom hselect hN hcon hocc e hml + refine ⟨m',?_,?_⟩ + · calc + (k:ℝ)/r^(n+1) = ((k:ℝ)/r^n)/r:=by rw [pow_succ,div_mul_eq_div_div] + _ ≤ (m:ℝ)/r:=div_le_div_of_nonneg_right hm hr0.le + _ ≤ _:=hm' + · simpa only [iterationBudgets,pow_succ'] using Nonempty.intro out + obtain ⟨m,hm,⟨e⟩⟩:=hh T le_rfl + refine ⟨m,?_,⟨e.mono ?_ hΛlast (le_refl _)⟩⟩ + · have hh:=retained_length hr (by positivity : 0 ≤ (q:ℝ)*σ^(1+η)) (le_refl T) hklo hm + simpa only [c,mul_assoc] using hh + · exact mul_le_mul_of_nonneg_left (exp_le_exp.mpr hΔlast) (by positivity) +end +end SharpLogRamsey.Marking + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Parameters/HeavyPlaneScales.lean b/lean/OAI/Combinatorics/SharpRamsey/Parameters/HeavyPlaneScales.lean new file mode 100644 index 0000000000000000000000000000000000000000..8dc0598f3fc1b399d9aa517542feab5dac427b56 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Parameters/HeavyPlaneScales.lean @@ -0,0 +1,71 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Parameters.SourceTrainingScales + +namespace OAI + +section +namespace SharpLogRamsey.SourceScales +open Real Filter +open scoped Topology + +lemma dyadic_class_count {q : ℕ} {σ : ℝ} (_hq : 0(a,b)∈S)).card:ℝ)≤2*exp ((d-r')*σ)) + (hfB : ∀ b,((univ.filter (fun a=>(a,b)∈S)).card:ℝ)≤2*exp ((d-r)*σ)) + (hdef : d*σ-entropy p≤D*σ^β) : + let κ:=D*σ^(3*β) + p.fst.event (univ.filter (fun a=>¬highGoodFirst p (1024*exp (r'*σ)) (d*σ) κ (exp (κ-r'*σ)) a))≤4300*σ^(-2*β) ∧ + p.snd.event (univ.filter (fun b=>¬highGoodSecond p (1024*exp (r*σ)) (d*σ) κ (exp (κ-r*σ)) b))≤4300*σ^(-2*β) ∧ + p.event (univ.filter (fun z=>exp (κ-d*σ)σ^(-η/2+6*beta η)) atTop (𝓝 0) := by + rw [show -η/2+6*beta η = -(η/2-6*beta η) by ring] + exact tendsto_rpow_neg_atTop hneg + have ht : Tendsto (fun σ : ℝ=>log 1024*σ^(-1:ℝ)+4*σ^(-η/2+6*beta η)) atTop (𝓝 0) := by + simpa only [mul_zero,add_zero] using + ((tendsto_rpow_neg_atTop (by norm_num : (0:ℝ)<1)).const_mul (log 1024)).add (ha.const_mul 4) + have hg : Tendsto (fun σ : ℝ=>σ^(4*beta η)) atTop atTop := + tendsto_rpow_atTop (by positivity) + have hτ : Tendsto (fun σ : ℝ=>σ^(-100*beta η)) atTop (𝓝 0) := by + simpa only [neg_mul] using + tendsto_rpow_neg_atTop (show 0<100*beta η by positivity) + filter_upwards [eventually_ge_atTop (1:ℝ),ht.eventually (gt_mem_nhds (show (0:ℝ)<1 by norm_num)), + hg.eventually (eventually_ge_atTop (log (200/97))), + hτ.eventually (gt_mem_nhds (show (0:ℝ)<1/40000 by norm_num))] with σ hσ hs hg hτ D hDl hDu + have hσ0 : 0<σ := by linarith + have hD : 1≤D := (one_le_rpow hσ hb.le).trans hDl + have hKK:=K_le_Kstar hσ hη (by linarith : 0≤D) + have hK : σ^(4*beta η)≤ scaleK σ η D := by + calc + _ = σ^beta η*σ^(3*beta η) := by rw [←rpow_add hσ0]; congr 1; ring + _ ≤ _ := mul_le_mul_of_nonneg_right hDl (by positivity) + have hKu : scaleKstar σ η D≤σ^(1-η/2+6*beta η) := by + unfold scaleKstar + rw [rpow_add hσ0] + exact mul_le_mul_of_nonneg_right hDu (by positivity) + have hK1 : 1≤ scaleKstar σ η D := + one_le_mul_of_one_le_of_one_le hD (one_le_rpow hσ (by positivity)) + refine ⟨?_,hg.trans hK,?_,rpow_pos_of_pos hσ0 _,hτ.le⟩ + · have hh : log 1024+4*σ^(1-η/2+6*beta η)<σ := by + have he : log 1024*σ^(-1:ℝ)+4*σ^(-η/2+6*beta η)= + (log 1024+4*σ^(1-η/2+6*beta η))/σ := by + have hep : σ^(1-η/2+6*beta η)/σ=σ^(-η/2+6*beta η) := by + calc + _ = σ^(1-η/2+6*beta η)/σ^(1:ℝ) := by rw [rpow_one] + _ = _ := by rw [←rpow_sub hσ0]; congr 1; ring + rw [rpow_neg_one,add_div,mul_div_assoc,hep] + ring + rw [he] at hs + simpa only [one_mul] using (div_lt_iff₀ hσ0).mp hs + linarith + · have hlog : log (4:ℝ)≤3 := by + have hh:=log_le_sub_one_of_pos (by norm_num : (0:ℝ)<4) + linarith + linarith +end +end SharpLogRamsey.SourceScales + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Parameters/IterationScales.lean b/lean/OAI/Combinatorics/SharpRamsey/Parameters/IterationScales.lean new file mode 100644 index 0000000000000000000000000000000000000000..874b3bd4563fda8a1e7bc84e566f2769d6888705 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Parameters/IterationScales.lean @@ -0,0 +1,112 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.CostContraction +import OAI.Combinatorics.SharpRamsey.Marking.StageBudget +import OAI.Combinatorics.SharpRamsey.Parameters.ParameterIteration + +namespace OAI + +section +namespace SharpLogRamsey.SourceScales +open Real Filter +open scoped Topology +noncomputable section + +def evenScale (σ η : ℝ) : ℕ:=2*⌈σ^beta η/2⌉₊ + +lemma evenScale_bounds {σ η : ℝ} (hσ : 0 ≤ σ) : + σ^beta η ≤ (evenScale σ η:ℝ) ∧ + (evenScale σ η:ℝ) ≤ 2*σ^beta η+2 ∧ Even (evenScale σ η) := by + have hp : 0 ≤ σ^beta η:=rpow_nonneg hσ _ + have hlo:=Nat.le_ceil (σ^beta η/2) + have hup:=Nat.ceil_lt_add_one (show 0 ≤ σ^beta η/2 by positivity) + refine ⟨?_,?_,?_⟩ + · dsimp only [evenScale];push_cast;linarith + · dsimp only [evenScale];push_cast;linarith + · exact even_two_mul _ + +def nextD (σ η D : ℝ) : ℝ:=σ^beta η*(1+D*σ^(-η/3)+16*D*σ^(6*beta η)*σ^(-η)) + +lemma stage_next {σ η D : ℝ} {k : ℕ} (hk : 0 < k) : + stageD σ η k (D*σ^(-η/3)*k) (16*scaleKstar σ η D)=nextD σ η D := by + have hk0 : (k:ℝ)≠0:=by exact_mod_cast hk.ne' + dsimp only [stageD,nextD,scaleKstar] + rw [mul_div_cancel_right₀ _ hk0] + ring + +lemma nextD_lower {σ η D : ℝ} (hσ : 0 ≤ σ) (hD : 0 ≤ D) : + σ^beta η ≤ nextD σ η D := by + unfold nextD + have hp : 0 ≤ σ^beta η:=rpow_nonneg hσ _ + have h1 : 0 ≤ D*σ^(-η/3):=by positivity + have h2 : 0 ≤ 16*D*σ^(6*beta η)*σ^(-η):=by positivity + nlinarith + +theorem eventually_iteration_scales (η : ℝ) (hη : 0 < η) (hηu : η ≤ 1) : + ∀ᶠ σ : ℝ in atTop, ∀ D : ℝ, 0 ≤ D → + nextD σ η D ≤ σ^(2*beta η)+D*σ^(-η/4) ∧ + (D ≤ σ^(1-η/2) → nextD σ η D ≤ σ^(1-η/2)) := by + have hg1 : beta η-η/3 < -η/4:=by unfold beta;linarith + have hg2 : 7*beta η-η < -η/4:=by unfold beta;linarith + have hg3 : 2*beta η < 1-η/2:=by unfold beta;linarith + filter_upwards [eventually_monomial_le_power 1 (beta η-η/3) (-η/4) (1/2) hg1 (by norm_num), + eventually_monomial_le_power 16 (7*beta η-η) (-η/4) (1/2) hg2 (by norm_num), + eventually_monomial_le_power 1 (2*beta η) (1-η/2) (1/2) hg3 (by norm_num), + eventually_monomial_le_power 1 (1-3*η/4) (1-η/2) (1/2) (by linarith) (by norm_num), + eventually_ge_atTop (1:ℝ)] with σ h1 h2 h3 h4 hσ D hD + have hσ0 : 0 < σ:=lt_of_lt_of_le zero_lt_one hσ + have hp : σ^beta η ≤ σ^(2*beta η):=rpow_le_rpow_of_exponent_le hσ (by have:=beta_pos hη;linarith) + have heq : nextD σ η D=σ^beta η+D*σ^(beta η-η/3)+16*D*σ^(7*beta η-η) := by + unfold nextD + rw [mul_add,mul_add] + simp only [mul_one] + have hP1 : σ^beta η*σ^(-η/3)=σ^(beta η-η/3):=by rw [←rpow_add hσ0];congr 1;ring + have hP2 : σ^beta η*σ^(6*beta η)*σ^(-η)=σ^(7*beta η-η):=by + rw [←rpow_add hσ0,←rpow_add hσ0];congr 1;ring + calc + _ = σ^beta η+D*(σ^beta η*σ^(-η/3))+16*D*(σ^beta η*σ^(6*beta η)*σ^(-η)):=by ring + _ = _:=by rw [hP1,hP2] + have hrec : nextD σ η D ≤ σ^(2*beta η)+D*σ^(-η/4):=by + rw [heq] + have hh1:=mul_le_mul_of_nonneg_left h1 hD + have hh2:=mul_le_mul_of_nonneg_left h2 hD + nlinarith only [hp,hh1,hh2] + refine ⟨hrec,?_⟩ + intro hDu + have hu : D*σ^(-η/4) ≤ σ^(1-3*η/4):=by + calc + _ ≤ σ^(1-η/2)*σ^(-η/4):=mul_le_mul_of_nonneg_right hDu (rpow_nonneg hσ0.le _) + _ = _:=by rw [←rpow_add hσ0];congr 1;ring + linarith + +theorem eventually_initial_stage (d : ℕ) (η : ℝ) (hη : 0 < η) (hηu : η ≤ 1) : + ∀ᶠ σ : ℝ in atTop, ∀ k : ℕ, + Admissible σ η (stageD σ η k 0 (((d-1:ℕ):ℝ)*σ)) (evenScale σ η) ∧ + stageD σ η k 0 (((d-1:ℕ):ℝ)*σ) ≤ σ := by + have hg1 : beta η < 1-η/2:=by unfold beta;linarith + have hg2 : 1-η+beta η < 1-η/2:=by unfold beta;linarith + filter_upwards [eventually_monomial_le_power 1 (beta η) (1-η/2) (1/2) hg1 (by norm_num), + eventually_monomial_le_power ((d-1:ℕ):ℝ) (1-η+beta η) (1-η/2) (1/2) hg2 (by norm_num), + eventually_ge_atTop (1:ℝ)] with σ h1 h2 hσ k + have hσ0 : 0 < σ:=lt_of_lt_of_le zero_lt_one hσ + have hh : stageD σ η k 0 (((d-1:ℕ):ℝ)*σ)=σ^beta η+((d-1:ℕ):ℝ)*σ^(1-η+beta η):=by + unfold stageD + simp only [zero_div,add_zero] + rw [mul_add,mul_one] + congr 1 + calc + _ = ((d-1:ℕ):ℝ)*(σ^beta η*σ^(1:ℝ)*σ^(-η)):=by rw [rpow_one];ring + _ = _:=by rw [←rpow_add hσ0,←rpow_add hσ0];congr 2;ring + have hu : stageD σ η k 0 (((d-1:ℕ):ℝ)*σ) ≤ σ^(1-η/2):=by rw [hh];linarith + obtain ⟨hRl,hRu,hRe⟩:=evenScale_bounds (η:=η) hσ0.le + refine ⟨⟨?_,hu,hRl,hRu,hRe⟩,hu.trans ?_⟩ + · rw [hh];have : 0 ≤ ((d-1:ℕ):ℝ)*σ^(1-η+beta η):=by positivity + linarith + · calc + _ ≤ σ^(1:ℝ):=rpow_le_rpow_of_exponent_le hσ (by linarith) + _ = _:=rpow_one _ +end +end SharpLogRamsey.SourceScales + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Parameters/NoContext.lean b/lean/OAI/Combinatorics/SharpRamsey/Parameters/NoContext.lean new file mode 100644 index 0000000000000000000000000000000000000000..6602737d2e2a211c009c592084eaa95a3f2d53af --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Parameters/NoContext.lean @@ -0,0 +1,74 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Entropy.TerminalEntropy +import OAI.Combinatorics.SharpRamsey.Parameters.TerminalGain + +namespace OAI + +section +namespace SharpLogRamsey.Marking +open Finset Real Filter Selection Selection.Windows ActualHighRank SourceScales ActualPivot +open scoped Classical BigOperators Topology +noncomputable section +local instance noCtxFiniteDual {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Fin (d+1)→K)) := + Finite.of_injective ((↑) : Module.Dual K (Fin (d+1)→K)→((Fin (d+1)→K)→K)) DFunLike.coe_injective +local instance noCtxFiniteDouble {K : Type} [Field K] [Fintype K] {d : ℕ} : Finite (Module.Dual K (Module.Dual K (Fin (d+1)→K))) := + Finite.of_injective ((↑) : Module.Dual K (Module.Dual K (Fin (d+1)→K))→(Module.Dual K (Fin (d+1)→K)→K)) DFunLike.coe_injective +local instance noCtxProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Fin (d+1)→K)) := Fintype.ofFinite _ +local instance noCtxDualProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Fin (d+1)→K))) := Fintype.ofFinite _ +local instance noCtxDoubleProjective {K : Type} [Field K] [Fintype K] {d : ℕ} : Fintype (Projectivization K (Module.Dual K (Module.Dual K (Fin (d+1)→K)))) := Fintype.ofFinite _ + +theorem eventually_no_small_context (i : ℕ) (η c Lstar P : ℝ) + (hη : 0 < η) (hc : 0 < c) (hLs : 0 < Lstar) (hP : 1 ≤ P) : + ∀ᶠ σ : ℝ in atTop, ∀ (q : ℕ) [Fact q.Prime], exp σ=(q:ℝ) → + ∀ (Ω : Type) [Fintype Ω] (N k m : ℕ) (p : Law Ω) + (stream : Ω→Fin N→Flag (ZMod q) (Fin (i+4)→ZMod q)) + (F : Ω→Fin k→Flag (ZMod q) (Fin (i+4)→ZMod q)), + k ≤ N → (k:ℝ) ≤ (q:ℝ)*σ^(1+η) → + (∀ g,(p.map stream).mass g ≤ 2/(Fintype.card (Flag (ZMod q) (Fin (i+4)→ZMod q)):ℝ)^N) → + (∀ x,p.mass x≠0→Occurs (F x) (stream x) ∨ Occurs (reverseTuple (F x)) (stream x)) → + (N:ℝ) ≤ (q:ℝ)^(i+3)*σ → + (∀ x,p.mass x≠0→ScanConsistent ((List.ofFn (fun j=>flagPair (F x j))).map toScan)) → + c*(q:ℝ)*σ^(1+η) ≤ m → + ¬Nonempty (ContextOutput p (fun x j=>flagPair (F x j)) m + (P*(q:ℝ)^(i+3)*exp (48*σ^(8*beta η))) k Lstar) := by + let A:=1+|log c|+|log (2*(Lstar*2))| + let B:=|log P|+|log 64| + let E:=32*((i:ℝ)+5)^3 + let C:=log (3*((i:ℝ)+5))+log 64+1/c+1 + have hB : 0 ≤ B:=by dsimp [B];positivity + have hE : 0 ≤ E:=by dsimp [E];positivity + have hg : 1+8*beta η < 1+η:=by unfold beta;linarith + filter_upwards [eventually_monomial_le_power (E*(48+B)) (1+8*beta η) (1+η) c hg hc, + tendsto_log_atTop.eventually_gt_atTop ((A+C)/η),eventually_ge_atTop (1:ℝ)] with σ hsmall hlog hσ + intro q _ he Ω _ N k m p stream F hkn hku hdom hsel hN hcons hmlo ⟨e⟩ + have hσ0 : 0 < σ:=by linarith + have hq0 : (0:ℝ) < q:=he ▸ exp_pos _ + have hm0 : (0:ℝ) < m:=(by positivity : (0:ℝ) < c*(q:ℝ)*σ^(1+η)).trans_le hmlo + have hgain:=flag_context_gain i q σ η c Lstar hσ hη.le hc hLs he Ω N k m p stream F + _ k Lstar (le_refl _) hkn hdom hsel hN e hmlo + have hu:=terminal_entropy_upper i q σ P (48*σ^(8*beta η)) k Lstar hσ hP (by positivity) he + Ω k m p F hcons e + have hp : 1 ≤ σ^(8*beta η):=one_le_rpow hσ (by have:=beta_pos hη;positivity) + have hdelta : 48*σ^(8*beta η)+B ≤ (48+B)*σ^(8*beta η):=by nlinarith [mul_le_mul_of_nonneg_left hp hB] + have herr : E*(q:ℝ)*σ*(48*σ^(8*beta η)+B) ≤ m:=by + calc + _ ≤ E*(q:ℝ)*σ*((48+B)*σ^(8*beta η)):=mul_le_mul_of_nonneg_left hdelta (by positivity) + _ = (q:ℝ)*(E*(48+B)*σ^(1+8*beta η)):=by rw [rpow_add hσ0,rpow_one];ring + _ ≤ (q:ℝ)*(c*σ^(1+η)):=mul_le_mul_of_nonneg_left hsmall hq0.le + _ ≤ _:=by nlinarith only [hmlo] + have hk : (k:ℝ) ≤ (m:ℝ)/c:=by apply (le_div_iff₀ hc).mpr;nlinarith only [mul_le_mul_of_nonneg_left hku hc.le,hmlo] + have hgaineq : A+C < η*log σ:=(div_lt_iff₀ hη).mp hlog |>.trans_eq (mul_comm _ _) + have hstrict:=mul_lt_mul_of_pos_left hgaineq hm0 + change (m:ℝ)*(((i+3:ℕ):ℝ)*σ+η*log σ)-A*m ≤ _ at hgain + change entropy (e.μ.map (fun x j=>flagPair (F (e.source x) (e.chosen x j)))) ≤ + (k:ℝ)+(m:ℝ)*(((i+3:ℕ):ℝ)*σ+log (3*((i:ℝ)+5))+log 64)+ + E*(q:ℝ)*σ*(48*σ^(8*beta η)+B) at hu + dsimp only [C] at hstrict + have hk' : (k:ℝ) ≤ (m:ℝ)*(1/c):=by simpa [div_eq_mul_inv] using hk + nlinarith only [hgain,hu,herr,hk',hstrict] +end +end SharpLogRamsey.Marking + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Parameters/NumericalIteration.lean b/lean/OAI/Combinatorics/SharpRamsey/Parameters/NumericalIteration.lean new file mode 100644 index 0000000000000000000000000000000000000000..24a6cdce8090257c087f3bb3fc343dccf7ef5d55 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Parameters/NumericalIteration.lean @@ -0,0 +1,87 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Parameters.IterationScales + +namespace OAI + +section +namespace SharpLogRamsey.SourceScales +open Real Filter +open scoped Topology +noncomputable section + +def iterationBudgets (d : ℕ) (σ η : ℝ) (k : ℕ) : ℕ→ℝ×ℝ + | 0 => (0,((d-1:ℕ):ℝ)*σ) + | n+1 => let b:=iterationBudgets d σ η k n + let D:=stageD σ η k b.1 b.2 + (D*σ^(-η/3)*k,16*scaleKstar σ η D) + +def iterationD (d : ℕ) (σ η : ℝ) (k n : ℕ) : ℝ:= + stageD σ η k (iterationBudgets d σ η k n).1 (iterationBudgets d σ η k n).2 + +lemma iterationD_succ (d : ℕ) (σ η : ℝ) {k : ℕ} (hk : 0 < k) (n : ℕ) : + iterationD d σ η k (n+1)=nextD σ η (iterationD d σ η k n) := by + exact stage_next hk + +lemma iteration_data {d k : ℕ} {σ η : ℝ} (hk : 0 < k) (hσ : 1 ≤ σ) + (hinit : Admissible σ η (iterationD d σ η k 0) (evenScale σ η)) + (hiter : ∀ D : ℝ,0 ≤ D→nextD σ η D ≤ σ^(2*beta η)+D*σ^(-η/4) ∧ + (D ≤ σ^(1-η/2)→nextD σ η D ≤ σ^(1-η/2))) : + ∀ n, 0 ≤ (iterationBudgets d σ η k n).1 ∧ 0 ≤ (iterationBudgets d σ η k n).2 ∧ + Admissible σ η (iterationD d σ η k n) (evenScale σ η) := by + have hσ0 : 0 ≤ σ:=by linarith + intro n + induction n with + | zero => exact ⟨le_refl 0,mul_nonneg (Nat.cast_nonneg _) hσ0,hinit⟩ + | succ n ih => + have hD : 0 ≤ iterationD d σ η k n:=(rpow_nonneg hσ0 _).trans ih.2.2.1 + obtain ⟨hlo,hup,hev⟩:=evenScale_bounds (η:=η) hσ0 + refine ⟨?_,?_,?_⟩ + · change 0 ≤ iterationD d σ η k n*σ^(-η/3)*(k:ℝ) + positivity + · change 0 ≤ 16*scaleKstar σ η (iterationD d σ η k n) + unfold scaleKstar;positivity + · rw [iterationD_succ d σ η hk] + exact ⟨nextD_lower hσ0 hD,(hiter _ hD).2 ih.2.2.D_upper,hlo,hup,hev⟩ + +theorem eventually_iteration_budgets (d : ℕ) (η : ℝ) (hη : 0 < η) (hηu : η ≤ 1) : + ∀ᶠ σ : ℝ in atTop, ∀ k : ℕ,0 < k→ + (∀ n,0 ≤ (iterationBudgets d σ η k n).1 ∧ 0 ≤ (iterationBudgets d σ η k n).2 ∧ + Admissible σ η (iterationD d σ η k n) (evenScale σ η)) ∧ + (iterationBudgets d σ η k (⌈8/η⌉₊+1)).1 ≤ k ∧ + (iterationBudgets d σ η k (⌈8/η⌉₊+1)).2 ≤ 48*σ^(8*beta η) := by + have hg : 2*beta η-η/3 < 0:=by unfold beta;linarith + filter_upwards [eventually_initial_stage d η hη hηu,eventually_iteration_scales η hη hηu, + ParameterIteration.eventual_half hη, + eventually_monomial_le_power 3 (2*beta η-η/3) 0 1 hg (by norm_num), + eventually_ge_atTop (1:ℝ)] with σ hinit hiter hhalf hsmall hσ k hk + have hσ0 : 0 < σ:=by linarith + have hdata:=iteration_data hk hσ (hinit k).1 hiter + let T:=⌈8/η⌉₊ + have hD : iterationD d σ η k T ≤ 3*σ^(2*beta η):=by + apply ParameterIteration.source_contraction hσ (beta_pos hη).le hhalf _ T + (ParameterIteration.prescribed_count hη) (hinit k).2 + intro n _ + rw [iterationD_succ d σ η hk] + exact (hiter _ ((rpow_nonneg hσ0.le _).trans (hdata n).2.2.1)).1 + refine ⟨hdata,?_,?_⟩ + · change iterationD d σ η k T*σ^(-η/3)*(k:ℝ) ≤ k + have hh : iterationD d σ η k T*σ^(-η/3) ≤ 1:=by + calc + _ ≤ 3*σ^(2*beta η)*σ^(-η/3):=mul_le_mul_of_nonneg_right hD (rpow_nonneg hσ0.le _) + _ = 3*σ^(2*beta η-η/3):=by rw [mul_assoc,←rpow_add hσ0];congr 2;ring + _ ≤ 1:=by simpa using hsmall + simpa only [one_mul] using mul_le_mul_of_nonneg_right hh (Nat.cast_nonneg k) + · change 16*scaleKstar σ η (iterationD d σ η k T) ≤ _ + unfold scaleKstar + calc + _ ≤ 16*(3*σ^(2*beta η))*σ^(6*beta η):=by + have hh:=mul_le_mul_of_nonneg_right hD (rpow_nonneg hσ0.le (6*beta η)) + have hh':=mul_le_mul_of_nonneg_left hh (by norm_num : (0:ℝ) ≤ 16) + simpa only [mul_assoc] using hh' + _ = _:=by rw [show 16*(3*σ^(2*beta η))*σ^(6*beta η)=48*(σ^(2*beta η)*σ^(6*beta η)) by ring,←rpow_add hσ0];congr 2;ring +end +end SharpLogRamsey.SourceScales + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Parameters/OpenScales.lean b/lean/OAI/Combinatorics/SharpRamsey/Parameters/OpenScales.lean new file mode 100644 index 0000000000000000000000000000000000000000..c01227eb842a73093928268115570c54502142f9 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Parameters/OpenScales.lean @@ -0,0 +1,104 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Parameters.IntegerScales + +namespace OAI + +section +namespace SharpLogRamsey.SourceScales +open Real Filter +open scoped Topology +noncomputable section + +lemma Kstar_lower {σ η D : ℝ} (hσ : 0<σ) (hDl : σ^beta η≤D) : + σ^(7*beta η)≤ scaleKstar σ η D := by + calc + _ = σ^beta η*σ^(6*beta η) := by rw [←rpow_add hσ]; congr 1; ring + _ ≤ _ := mul_le_mul_of_nonneg_right hDl (by positivity) + +lemma K_ratio {σ η D : ℝ} (hσ : 0<σ) : + scaleK σ η D=σ^(-3*beta η)*scaleKstar σ η D := by + unfold scaleK scaleKstar + rw [mul_left_comm,←rpow_add hσ] + congr 2 + ring + +lemma Kstar_inv_bound {σ η D : ℝ} (hσ : 0<σ) (hDl : σ^beta η≤D) : + 1≤σ^(-7*beta η)*scaleKstar σ η D := by + have hh:=mul_le_mul_of_nonneg_left (Kstar_lower hσ hDl) + (rpow_pos_of_pos hσ (-7*beta η)).le + rw [←rpow_add hσ] at hh + simpa only [show -7*beta η+7*beta η=0 by ring,rpow_zero] using hh + +theorem eventually_open_regime (η : ℝ) (d : ℕ) (hη : 0<η) : + ∀ᶠ σ : ℝ in atTop, ∀ D q : ℝ, σ^beta η≤D → 0log 1024*σ^(-7*beta η)+3*σ^(-3*beta η)) atTop (𝓝 0) := by + have h1 : Tendsto (fun σ : ℝ=>σ^(-7*beta η)) atTop (𝓝 0) := by + simpa only [neg_mul] using tendsto_rpow_neg_atTop (show 0<7*beta η by positivity) + have h2 : Tendsto (fun σ : ℝ=>σ^(-3*beta η)) atTop (𝓝 0) := by + simpa only [neg_mul] using tendsto_rpow_neg_atTop (show 0<3*beta η by positivity) + simpa only [mul_zero,add_zero] using (h1.const_mul (log 1024)).add (h2.const_mul 3) + have hs : Tendsto (fun σ : ℝ=>(4*exp 1)^2*(20000*((d:ℝ)+3)^2)*σ^(-2000*beta η)) atTop (𝓝 0) := by + have he : Tendsto (fun σ : ℝ=>σ^(-2000*beta η)) atTop (𝓝 0) := by + simpa only [neg_mul] using tendsto_rpow_neg_atTop (show 0<2000*beta η by positivity) + simpa only [mul_zero] using he.const_mul ((4*exp 1)^2*(20000*((d:ℝ)+3)^2)) + filter_upwards [eventually_gt_atTop (0:ℝ),ht.eventually (gt_mem_nhds (show (0:ℝ)<1 by norm_num)), + hs.eventually (gt_mem_nhds (show (0:ℝ)<1/4 by norm_num))] with σ hσ ht hs D q hDl hq + have hD : 0 first | rfl | ring + +theorem eventually_open_deletion_small (η c ε : ℝ) (hη : 0<η) (hc : 0σ^(-η/2-6*beta η)) atTop (𝓝 0) := by + simpa only [neg_add, neg_div, sub_eq_add_neg] using + tendsto_rpow_neg_atTop (show 0<η/2+6*beta η by positivity) + have he2 : Tendsto (fun σ : ℝ=>σ^(-3*beta η)) atTop (𝓝 0) := by + simpa only [neg_mul] using tendsto_rpow_neg_atTop (show 0<3*beta η by positivity) + have he3 : Tendsto (fun σ : ℝ=>σ^(-7*beta η)) atTop (𝓝 0) := by + simpa only [neg_mul] using tendsto_rpow_neg_atTop (show 0<7*beta η by positivity) + have ht : Tendsto (fun σ : ℝ=>c⁻¹*σ^(-η/2-6*beta η)+2*σ^(-3*beta η)+log 64*σ^(-7*beta η)) atTop (𝓝 0) := by + simpa only [mul_zero,add_zero] using ((he1.const_mul c⁻¹).add (he2.const_mul 2)).add (he3.const_mul (log 64)) + filter_upwards [eventually_gt_atTop (0:ℝ),ht.eventually (gt_mem_nhds hε)] with σ hσ ht D w hDl hw hwD + have hD : 0 intro _; simpa only [pow_zero,one_mul] using h₀.trans (by linarith) + | succ i ih => + intro hi + have hd := ih (by omega) + have hh := (hstep i (by omega)).trans (add_le_add_right (mul_le_mul_of_nonneg_left hd hb) a) + have hac : a+2*a*b≤2*a := by nlinarith + rw [pow_succ] + nlinarith + exact hbound T le_rfl + +theorem source_contraction {σ β η : ℝ} (hσ : 1≤σ) (hβ : 0≤β) + (hhalf : σ^(-η/4)≤1/2) (D : ℕ→ℝ) (T : ℕ) + (hT : 1≤(T:ℝ)*η/4) (h₀ : D 0≤σ) + (hstep : ∀ i rhs; rw [←rpow_one σ] + rw [←rpow_add hσ0] + congr 1 + ring + rw [hpow] at Hb + have hsmall : σ^(1-(T:ℝ)*η/4)≤1 := rpow_le_one_of_one_le_of_nonpos hσ (by linarith) + linarith + +theorem eventual_half {η : ℝ} (hη : 0<η) : + ∀ᶠ σ : ℝ in Filter.atTop, σ^(-η/4)≤1/2 := by + have ht : Filter.Tendsto (fun σ : ℝ=>σ^(-η/4)) Filter.atTop (nhds 0) := by + simpa only [neg_div] using (tendsto_rpow_neg_atTop (show 0<η/4 by linarith)) + exact ht.eventually (eventually_le_nhds (by norm_num : (0:ℝ)<1/2)) + +theorem prescribed_count {η : ℝ} (hη : 0<η) : + 1≤(⌈8/η⌉₊:ℝ)*η/4 := by + have h := Nat.le_ceil (8/η) + have hh := mul_le_mul_of_nonneg_right h hη.le + have he : (8/η)*η=(8:ℝ) := div_mul_cancel₀ 8 (ne_of_gt hη) + rw [he] at hh + linarith + +end SharpLogRamsey.ParameterIteration + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Parameters/PlanarScales.lean b/lean/OAI/Combinatorics/SharpRamsey/Parameters/PlanarScales.lean new file mode 100644 index 0000000000000000000000000000000000000000..c03c8336618be7f641abc7938faa74998da87e52 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Parameters/PlanarScales.lean @@ -0,0 +1,109 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Planar.PlanarBudget + +namespace OAI + +section +namespace SharpLogRamsey.PlanarLearning +open Finset Real Filter SourceScales +open scoped Topology +noncomputable section + +lemma even_order {σ P : ℝ} (hσ : 0<σ) (hP : 0x^(-a*β)) atTop (𝓝 0) := by + simpa only [neg_mul] using tendsto_rpow_neg_atTop (mul_pos ha hβ) + have he : Tendsto (fun x : ℝ=>x^β*exp (-x)) atTop (𝓝 0) := by + simpa only [neg_one_mul] using tendsto_rpow_mul_exp_neg_mul_atTop_nhds_zero β 1 (by norm_num) + unfold treeErrorEnvelope + simpa only [mul_zero,add_zero] using + ((((hp 1998 (by norm_num)).const_mul (240*(4*exp 1)^2*C)).add + ((hp 1899 (by norm_num)).const_mul ((4*exp 1)^2*C))).add + (he.const_mul 2)).add ((hp 2 (by norm_num)).const_mul (2*C)) |>.add + ((hp 1999 (by norm_num)).const_mul (48*(4*exp 1)*C)) + +lemma treeError_le_envelope {β C x q h ε εA εB δA δB : ℝ} + (hβ : 0<β) (hC : 0≤C) (hx : 1≤x) (hq : x≤q) + (hh0 : 0≤h) (hh : h≤x^β) (hε : 0≤ε) + (hεA : 0≤εA) (hεB : 0≤εB) + (he : q*ε≤C*x^(-2000*β)) (heA : q*εA≤C*x^(-2000*β)) + (heB : q*εB≤C*x^(-2000*β)) + (hdA : δA≤C*x^(-2*β)) (hdB : δB≤C*x^(-2*β)) : + treeError q (x^(-100*β)) h ε εA εB δA δB≤treeErrorEnvelope β C x := by + have hx0 : 0 Real.exp (L/1000)) atTop atTop := + tendsto_exp_atTop.comp (tendsto_id.atTop_div_const (by norm_num : (0:ℝ)<1000)) + exact (ht.eventually (eventually_ge_atTop C)).and (ht.eventually (eventually_ge_atTop (C^2))) + have hpoly : ∀ᶠ L : ℝ in atTop,2*L^2≤Real.exp (L/25) := by + have hh := ScaleSelection.eventually_polynomial_le_exp_rpow 2 2 1 (1/25) + (by norm_num) (by norm_num) + simpa only [Real.rpow_one,Real.rpow_ofNat,div_eq_mul_inv,mul_comm,one_mul] using hh + have hgrid := ScaleSelection.eventually_polynomial_le_exp_rpow 1 2 (9*beta η) (1/1000) + (by have := beta_pos hη; positivity) (by norm_num) + have hlarge : ∀ᶠ L : ℝ in atTop,1000000000≤L := eventually_ge_atTop _ + filter_upwards [eventually_uniform_L hη hconst,eventually_uniform_L hη hpoly, + eventually_uniform_L hη hlarge,eventually_uniform_R hη 400,hgrid, + eventually_ge_atTop (1:ℝ)] with σ hc hp hl hr hg hσ D R N had hN + let L := scaleL σ η D + let P := scaleP σ η D R + have hL : 1000000000≤L := hl D R had + have hR : (400:ℝ)≤R := hr D R had + have hL0 : 0≤L := by linarith + have hR1 : (1:ℝ)≤R := by linarith + have hP : P=L*R := rfl + have hPL : 400*L≤P := by rw [hP]; nlinarith + have hPR : 1000000000*(R:ℝ)≤P := by rw [hP]; nlinarith + have hP0 : 0≤P := by linarith + have hcc := hc D R had + change C≤Real.exp (L/1000) ∧ C^2≤Real.exp (L/1000) at hcc + have hNN : (N:ℝ)≤Real.exp (L/1000) := by + apply hN.trans + calc + σ^2≤Real.exp ((1/1000)*σ^(9*beta η)) := by simpa only [one_mul,Real.rpow_ofNat] using hg + _ ≤ Real.exp (L/1000) := Real.exp_le_exp.mpr (by linarith [(scale_bounds hσ hη had).1]) + have ht := two_pow_le_exp R + have h2 : (2:ℝ)≤Real.exp (P/40) := by + have hh := Real.add_one_le_exp (P/40) + linarith + dsimp only + change C*2^R≤Real.exp (P/20) ∧ (2*L^2)^R≤Real.exp (P/25) ∧ + C^2*Real.exp (L/50)+(N:ℝ)*2^R*Real.exp (P/50)≤Real.exp (P/20) ∧ + 2≤Real.exp (P/20) ∧ 400000*Real.exp (L/1000)≤Real.exp (P/100) + refine ⟨?_,?_,?_,?_,?_⟩ + · calc + C*2^R≤Real.exp (L/1000)*Real.exp (R:ℝ) := mul_le_mul hcc.1 ht (by positivity) (Real.exp_pos _).le + _ = Real.exp (L/1000+R) := (Real.exp_add _ _).symm + _ ≤ Real.exp (P/20) := Real.exp_le_exp.mpr (by linarith) + · have hh := pow_le_pow_left₀ (show 0≤2*L^2 by positivity) (hp D R had) R + apply hh.trans_eq + rw [←Real.exp_nat_mul] + congr 1 + rw [hP] + ring + · have hfirst : C^2*Real.exp (L/50)≤Real.exp (P/40) := by + calc + _ ≤ Real.exp (L/1000)*Real.exp (L/50) := mul_le_mul_of_nonneg_right hcc.2 (Real.exp_pos _).le + _ = Real.exp (L/1000+L/50) := (Real.exp_add _ _).symm + _ ≤ _ := Real.exp_le_exp.mpr (by linarith) + have hsecond : (N:ℝ)*2^R*Real.exp (P/50)≤Real.exp (P/40) := by + calc + _ ≤ (Real.exp (L/1000)*Real.exp (R:ℝ))*Real.exp (P/50) := by gcongr + _ = Real.exp (L/1000+R+P/50) := by rw [←Real.exp_add,←Real.exp_add] + _ ≤ _ := Real.exp_le_exp.mpr (by linarith) + calc + _ ≤ 2*Real.exp (P/40) := by linarith + _ ≤ Real.exp (P/40)*Real.exp (P/40) := mul_le_mul_of_nonneg_right h2 (Real.exp_pos _).le + _ = Real.exp (P/20) := by rw [←Real.exp_add]; congr 1; ring + · exact h2.trans (Real.exp_le_exp.mpr (by linarith)) + · have hnum : (400000:ℝ)≤Real.exp (L/1000) := by + have hh := Real.add_one_le_exp (L/1000) + linarith + calc + _ ≤ Real.exp (L/1000)*Real.exp (L/1000) := mul_le_mul_of_nonneg_right hnum (Real.exp_pos _).le + _ = Real.exp (L/500) := by rw [←Real.exp_add]; congr 1; ring + _ ≤ _ := Real.exp_le_exp.mpr (by linarith) + +end +end SharpLogRamsey.SourceScales + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Parameters/SourceScaleComparisons.lean b/lean/OAI/Combinatorics/SharpRamsey/Parameters/SourceScaleComparisons.lean new file mode 100644 index 0000000000000000000000000000000000000000..f7593c9c0fa7b94fa484bf6d93535b27bd26532b --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Parameters/SourceScaleComparisons.lean @@ -0,0 +1,92 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Parameters.SourceScales + +namespace OAI + +section +namespace SharpLogRamsey.SourceScales +open Filter Real +open scoped Topology +noncomputable section + +def scaleK (σ η D : ℝ) : ℝ := D*σ^(3*beta η) +def scaleKstar (σ η D : ℝ) : ℝ := D*σ^(6*beta η) + +lemma Kstar_eq (σ η D : ℝ) (hσ : 0<σ) : + scaleKstar σ η D=scaleL σ η D*σ^(-2*beta η) := by + unfold scaleKstar scaleL + rw [mul_assoc,←Real.rpow_add hσ] + congr 2 + ring + +lemma R_bound {σ η D : ℝ} {R : ℕ} (hσ : 1 ≤ σ) (hη : 0<η) + (h : Admissible σ η D R) : (R:ℝ) ≤ 4*σ^beta η := by + have hh := Real.one_le_rpow hσ (beta_pos hη).le + linarith [h.R_upper] + +lemma L_pos {σ η D : ℝ} {R : ℕ} (hσ : 0<σ) (h : Admissible σ η D R) : + 0 C*σ^(-2*beta η)) atTop (𝓝 0) := by + convert (tendsto_rpow_neg_atTop (show 0<2*beta η by positivity)).const_mul C using 1 <;> simp [neg_mul] + have h2 : Tendsto (fun σ : ℝ => 4*C*σ^(-99*beta η)) atTop (𝓝 0) := by + convert (tendsto_rpow_neg_atTop (show 0<99*beta η by positivity)).const_mul (4*C) using 1 <;> simp [neg_mul] + have ht : Tendsto (fun σ : ℝ => C*σ^(-2*beta η)+4*C*σ^(-99*beta η)) atTop (𝓝 0) := by + simpa using h1.add h2 + filter_upwards [ht.eventually (gt_mem_nhds hδ),eventually_ge_atTop (1:ℝ)] with σ he hσ D R had b τ hb' hτ + have hσ0 : 0<σ := by linarith + have hL := (L_pos hσ0 had).le + have hP := (P_pos hσ0 had).le + have hR := R_bound hσ hη had + have hh : (R:ℝ)*(C*σ^(-100*beta η)) ≤ 4*C*σ^(-99*beta η) := by + calc + _ ≤ (4*σ^beta η)*(C*σ^(-100*beta η)) := + mul_le_mul_of_nonneg_right hR (by positivity) + _ = _ := by + rw [show (4*σ^beta η)*(C*σ^(-100*beta η))=4*C*(σ^beta η*σ^(-100*beta η)) by ring, + ←Real.rpow_add hσ0] + congr 2 + ring + have hb'' : b ≤ scaleL σ η D*(C*σ^(-2*beta η)) := by + rw [Kstar_eq σ η D hσ0] at hb' + nlinarith only [hb'] + have hτ' : scaleP σ η D R*τ ≤ scaleL σ η D*(4*C*σ^(-99*beta η)) := by + calc + _ ≤ scaleP σ η D R*(C*σ^(-100*beta η)) := mul_le_mul_of_nonneg_left hτ hP + _ = scaleL σ η D*((R:ℝ)*(C*σ^(-100*beta η))) := mul_assoc _ _ _ + _ ≤ _ := mul_le_mul_of_nonneg_left hh hL + calc + _ ≤ scaleL σ η D*(C*σ^(-2*beta η)+4*C*σ^(-99*beta η)) := by linarith + _ ≤ scaleL σ η D*δ := mul_le_mul_of_nonneg_left he.le hL + _ = _ := mul_comm _ _ + +theorem eventually_log_le_L {η : ℝ} (hη : 0<η) (C δ : ℝ) (hδ : 0<δ) : + ∀ᶠ σ : ℝ in atTop, ∀ (D : ℝ) (R : ℕ), Admissible σ η D R → + C*Real.log σ ≤ δ*scaleL σ η D := by + have hb : 0<9*beta η := by have := beta_pos hη; positivity + have ht : Tendsto (fun σ : ℝ => C*(Real.log σ/σ^(9*beta η))) atTop (𝓝 0) := by + simpa using ((isLittleO_log_rpow_atTop hb).tendsto_div_nhds_zero).const_mul C + filter_upwards [ht.eventually (gt_mem_nhds hδ),eventually_ge_atTop (1:ℝ)] with σ hh hσ D R had + have hp : 0<σ^(9*beta η) := Real.rpow_pos_of_pos (by linarith) _ + have hmul := (div_lt_iff₀ hp).mp (show C*Real.log σ/σ^(9*beta η)<δ by simpa [mul_div_assoc] using hh) + exact hmul.le.trans (mul_le_mul_of_nonneg_left (scale_bounds hσ hη had).1 hδ.le) + +end +end SharpLogRamsey.SourceScales + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Parameters/SourceScales.lean b/lean/OAI/Combinatorics/SharpRamsey/Parameters/SourceScales.lean new file mode 100644 index 0000000000000000000000000000000000000000..1ae9cf7ffe8c67d96c3107cb9d5b20433b80b5ae --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Parameters/SourceScales.lean @@ -0,0 +1,315 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Entropy.StrongDegreeBudget + +namespace OAI + +section +section + +namespace SharpLogRamsey.ScaleSelection +open Filter Real +open scoped Topology +open SharpLogRamsey.MomentBudgetBridge + +theorem eventually_polynomial_le_exp_rpow (C a b c : ℝ) (hb : 0 < b) (hc : 0 < c) : + ∀ᶠ x : ℝ in atTop, C*x^a ≤ Real.exp (c*x^b) := by + have ht := (isLittleO_rpow_exp_pos_mul_atTop (a/b) hc).bound (show 0 < (1/(|C|+1) : ℝ) by positivity) + have hcomp := (tendsto_rpow_atTop hb).eventually ht + filter_upwards [hcomp, eventually_gt_atTop (0 : ℝ)] with x hx hx0 + have hp : (x^b)^(a/b) = x^a := by + rw [← Real.rpow_mul hx0.le] + congr 1 + field_simp + simp only [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _), hp, + abs_of_pos (Real.rpow_pos_of_pos hx0 a)] at hx + have hC : C ≤ |C|+1 := by linarith [le_abs_self C] + calc + C*x^a ≤ (|C|+1)*x^a := mul_le_mul_of_nonneg_right hC (Real.rpow_nonneg hx0.le _) + _ ≤ (|C|+1)*((1/(|C|+1))*Real.exp (c*x^b)) := + mul_le_mul_of_nonneg_left hx (by positivity) + _ = _ := by field_simp + +theorem eventually_polynomial_exp_neg_rpow_lt (C a b c ε : ℝ) + (hb : 0 < b) (hc : 0 < c) (hε : 0 < ε) : + ∀ᶠ x : ℝ in atTop, C*x^a*Real.exp (-c*x^b) < ε := by + have ht := (isLittleO_rpow_exp_pos_mul_atTop (a/b) hc).bound + (show 0 < ε/(2*(|C|+1)) by positivity) + have hcomp := (tendsto_rpow_atTop hb).eventually ht + filter_upwards [hcomp, eventually_gt_atTop (0 : ℝ)] with x hx hx0 + have hp : (x^b)^(a/b) = x^a := by + rw [← Real.rpow_mul hx0.le] + congr 1 + field_simp + simp only [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _), hp, + abs_of_pos (Real.rpow_pos_of_pos hx0 a)] at hx + have hC : C ≤ |C|+1 := by linarith [le_abs_self C] + calc + _ ≤ (|C|+1)*x^a*Real.exp (-c*x^b) := by + gcongr + _ ≤ (|C|+1)*(ε/(2*(|C|+1))*Real.exp (c*x^b))*Real.exp (-c*x^b) := by + gcongr + _ = ε/2 := by + rw [mul_assoc (|C|+1), mul_assoc, ← Real.exp_add, + show c*x^b+-c*x^b=0 by ring, Real.exp_zero] + field_simp + _ < ε := by linarith + +def majorant (x : ℝ) : ℝ := + 1+4*(x^2)^2+4*(x^2)^3*(202*x^2)+(x^2)^4*(202*x^2)^2+ + (x^2)^4*(x^2+4)*(2*x^2)^200 + +theorem certificate_le_majorant (x P : ℝ) (p D : ℕ) (hx : 1 ≤ x) + (hP : 0 ≤ P) (hP' : P ≤ x^2) (hp : (p : ℝ) ≤ x^2) (hD : (D : ℝ) ≤ x^2) : + certificateOverhead p D P ≤ majorant x := by + have hA : anchorBudget p P ≤ 202*x^2 := by unfold anchorBudget; linarith + have hA0 : 0 ≤ anchorBudget p P := anchorBudget_nonneg p hP + unfold certificateOverhead majorant + gcongr + +theorem majorant_le (x : ℝ) (hx : 1 ≤ x) : + majorant x ≤ (1+4+808+40804+5*2^200 : ℝ)*x^410 := by + have hx0 : 0 ≤ x := by linarith + have h0 : (1 : ℝ) ≤ x^410 := one_le_pow₀ hx + have h4 : x^4 ≤ x^410 := pow_le_pow_right₀ hx (by decide) + have h8 : x^8 ≤ x^410 := pow_le_pow_right₀ hx (by decide) + have h12 : x^12 ≤ x^410 := pow_le_pow_right₀ hx (by decide) + have hD : x^2+4 ≤ 5*x^2 := by nlinarith [sq_nonneg (x-1)] + have hm : (x^2)^4*(x^2+4)*(2*x^2)^200 ≤ 5*2^200*x^410 := by + calc + _ ≤ (x^2)^4*(5*x^2)*(2*x^2)^200 := by gcongr + _ = _ := by ring + have he : majorant x = 1+4*x^4+808*x^8+40804*x^12+ + (x^2)^4*(x^2+4)*(2*x^2)^200 := by unfold majorant; ring + rw [he] + nlinarith only [h0, h4, h8, h12, hm] + +theorem eventually_certificate_budget (b : ℝ) (hb : 0 < b) : + ∀ᶠ x : ℝ in atTop, ∀ (p D : ℕ) (P : ℝ), + (p : ℝ) ≤ x^2 → (D : ℝ) ≤ x^2 → x^b ≤ P → P ≤ x^2 → + certificateOverhead p D P ≤ Real.exp (2*P/25) := by + have hh := eventually_polynomial_le_exp_rpow + (1+4+808+40804+5*2^200) 410 b (2/25) hb (by norm_num) + filter_upwards [hh, eventually_ge_atTop (1 : ℝ)] with x hx hx1 p D P hp hD hP hP' + have hx0 : 0 ≤ x := by linarith + calc + _ ≤ majorant x := certificate_le_majorant x P p D hx1 + ((Real.rpow_nonneg hx0 _).trans hP) hP' hp hD + _ ≤ (1+4+808+40804+5*2^200 : ℝ)*x^410 := majorant_le x hx1 + _ ≤ Real.exp ((2/25)*x^b) := by simpa only [Real.rpow_ofNat] using hx + _ ≤ _ := Real.exp_le_exp.mpr (by linarith) + +theorem eventually_shift_budget (b : ℝ) (hb : 0 < b) : + ∀ᶠ x : ℝ in atTop, ∀ (p D : ℕ) (P : ℝ), + (p : ℝ) ≤ x^2 → (D : ℝ) ≤ x^2 → x^b ≤ P → + shiftOverhead p D ≤ Real.exp (2*P/25) := by + have hh := eventually_polynomial_le_exp_rpow (4+200^200) 402 b (2/25) hb (by norm_num) + filter_upwards [hh, eventually_ge_atTop (1 : ℝ)] with x hx hx1 p D P hp hD hP + have hx0 : 0 ≤ x := by linarith + have hm : shiftOverhead p D ≤ (4+200^200 : ℝ)*x^402 := by + have h0 : (1 : ℝ) ≤ x^402 := one_le_pow₀ hx1 + have hh : (D : ℝ)*(200*(p : ℝ))^200 ≤ 200^200*x^402 := by + calc + _ ≤ x^2*(200*x^2)^200 := mul_le_mul hD + (pow_le_pow_left₀ (by positivity) + (mul_le_mul_of_nonneg_left hp (by norm_num)) 200) + (pow_nonneg (mul_nonneg (by norm_num) (Nat.cast_nonneg p)) 200) (sq_nonneg x) + _ = _ := by ring + unfold shiftOverhead + nlinarith only [h0, hh] + calc + _ ≤ (4+200^200 : ℝ)*x^402 := hm + _ ≤ Real.exp ((2/25)*x^b) := by simpa only [Real.rpow_ofNat] using hx + _ ≤ _ := Real.exp_le_exp.mpr (by linarith) + +theorem eventually_position_budgets (b : ℝ) (hb : 0 < b) : + ∀ᶠ x : ℝ in atTop, ∀ (p : ℕ) (P : ℝ), + (p : ℝ) ≤ x^2 → x^b ≤ P → + (p : ℝ)^2 ≤ Real.exp (P/10) ∧ 2*(p : ℝ)+3 ≤ Real.exp (P/10) := by + have hh := eventually_polynomial_le_exp_rpow 1 4 b (1/10) hb (by norm_num) + have hh' := eventually_polynomial_le_exp_rpow 5 2 b (1/10) hb (by norm_num) + filter_upwards [hh, hh', eventually_ge_atTop (1 : ℝ)] with x hx hx' hx1 p P hp hP + have hx0 : 0 ≤ x := by linarith + have he : Real.exp ((1/10)*x^b) ≤ Real.exp (P/10) := Real.exp_le_exp.mpr (by linarith) + constructor + · calc + _ ≤ (x^2)^2 := pow_le_pow_left₀ (Nat.cast_nonneg _) hp _ + _ = x^4 := by ring + _ ≤ Real.exp ((1/10)*x^b) := by simpa only [one_mul, Real.rpow_ofNat] using hx + _ ≤ _ := he + · have h1 : 1 ≤ x^2 := one_le_pow₀ hx1 + calc + _ ≤ 5*x^2 := by linarith + _ ≤ Real.exp ((1/10)*x^b) := by simpa only [Real.rpow_ofNat] using hx' + _ ≤ _ := he + +lemma nineteen_twentieth_pow_le (n : ℕ) : + (19/20 : ℝ)^n ≤ Real.exp (-(n : ℝ)/20) := by + have hb : (19/20 : ℝ) ≤ Real.exp (-(1/20 : ℝ)) := by + linarith only [Real.add_one_le_exp (-(1/20 : ℝ))] + calc + _ ≤ (Real.exp (-(1/20 : ℝ)))^n := pow_le_pow_left₀ (by norm_num) hb _ + _ = _ := by rw [← Real.exp_nat_mul]; congr 1; ring + +theorem eventually_root_budget (b : ℝ) (hb : 0 < b) : + ∀ᶠ x : ℝ in atTop, ∀ (p R : ℕ), (p : ℝ) ≤ x^2 → x^b ≤ R → + ∃ h : ℕ, 0 < h ∧ 400 ≤ R ∧ h ≤ (R/2)/400 ∧ + (p : ℝ)*h*(19/20 : ℝ)^(h-1) < 1/2 := by + have hh := eventually_polynomial_exp_neg_rpow_lt (Real.exp (1/10)) (2+b) b + (1/16000) (1/2) hb (by norm_num) (by norm_num) + filter_upwards [hh, (tendsto_rpow_atTop hb).eventually_ge_atTop 1600, + eventually_ge_atTop (1 : ℝ)] with x hx hxb hx1 p R hp hR + have hx0 : 0 < x := by linarith + let h : ℕ := ⌊x^b/800⌋₊ + have hh1 : 1 ≤ h := by + apply Nat.le_floor + norm_num + linarith + have hhle : (h : ℝ) ≤ x^b/800 := Nat.floor_le (by positivity) + have hhgt : x^b/800 < (h : ℝ)+1 := Nat.lt_floor_add_one _ + have hhr : 800*h ≤ R := by + have hcast : (800 : ℝ)*(h : ℝ) ≤ R := by linarith + exact_mod_cast hcast + have hnat : ((h-1 : ℕ) : ℝ) = (h : ℝ)-1 := by rw [Nat.cast_sub hh1]; norm_num + have hp' : (p : ℝ)*h ≤ x^(2+b) := by + calc + _ ≤ x^2*x^b := by gcongr; linarith only [hhle, Real.rpow_nonneg hx0.le b] + _ = _ := by rw [Real.rpow_add hx0]; simp only [Real.rpow_ofNat] + have he : (19/20 : ℝ)^(h-1) ≤ Real.exp ((1/10)-(1/16000)*x^b) := by + apply (nineteen_twentieth_pow_le (h-1)).trans + apply Real.exp_le_exp.mpr + rw [hnat] + linarith + refine ⟨h, by omega, by omega, by omega, ?_⟩ + calc + _ ≤ x^(2+b)*Real.exp ((1/10)-(1/16000)*x^b) := + mul_le_mul hp' he (by positivity) (by positivity) + _ = Real.exp (1/10)*x^(2+b)*Real.exp (-(1/16000)*x^b) := by + rw [sub_eq_add_neg, Real.exp_add, neg_mul] + ring + _ < _ := hx + +end SharpLogRamsey.ScaleSelection +end + +section + +namespace SharpLogRamsey.SourceScales +open Filter Real +open scoped Topology +open SharpLogRamsey.ScaleSelection SharpLogRamsey.MomentBudgetBridge + +noncomputable def beta (η : ℝ) : ℝ := η/10000000 +noncomputable def scaleL (σ η D : ℝ) : ℝ := D*σ^(8*beta η) +noncomputable def scaleP (σ η D : ℝ) (R : ℕ) : ℝ := scaleL σ η D*R + +structure Admissible (σ η D : ℝ) (R : ℕ) : Prop where + D_lower : σ^beta η ≤ D + D_upper : D ≤ σ^(1-η/2) + R_lower : σ^beta η ≤ (R : ℝ) + R_upper : (R : ℝ) ≤ 2*σ^beta η+2 + R_even : Even R + +lemma beta_pos {η : ℝ} (hη : 0 < η) : 0 < beta η := by + unfold beta + positivity + +lemma exponent_gap {η : ℝ} (hη : 0 < η) : 1-η/2+9*beta η < 1 := by + unfold beta + linarith + +lemma scale_bounds {σ η D : ℝ} {R : ℕ} (hσ : 1 ≤ σ) (hη : 0 < η) + (h : Admissible σ η D R) : + σ^(9*beta η) ≤ scaleL σ η D ∧ + σ^(10*beta η) ≤ scaleP σ η D R ∧ + scaleP σ η D R ≤ 4*σ^(1-η/2+9*beta η) := by + have hσ0 : 0 < σ := by linarith + have hb : 0 < beta η := beta_pos hη + have hpow : 1 ≤ σ^beta η := Real.one_le_rpow hσ hb.le + have hD0 : 0 ≤ D := (Real.rpow_nonneg hσ0.le _).trans h.D_lower + have hL : σ^(9*beta η) ≤ scaleL σ η D := by + calc + _ = σ^beta η*σ^(8*beta η) := by rw [← Real.rpow_add hσ0]; congr 1; ring + _ ≤ _ := mul_le_mul_of_nonneg_right h.D_lower (Real.rpow_nonneg hσ0.le _) + refine ⟨hL, ?_, ?_⟩ + · calc + _ = σ^(9*beta η)*σ^beta η := by rw [← Real.rpow_add hσ0]; congr 1; ring + _ ≤ scaleL σ η D*(R : ℝ) := mul_le_mul hL h.R_lower + (Real.rpow_nonneg hσ0.le _) (by unfold scaleL; positivity) + _ = _ := rfl + · have hR : (R : ℝ) ≤ 4*σ^beta η := by linarith [h.R_upper] + calc + _ ≤ (σ^(1-η/2)*σ^(8*beta η))*(4*σ^beta η) := by + unfold scaleP scaleL + exact mul_le_mul (mul_le_mul_of_nonneg_right h.D_upper + (Real.rpow_nonneg hσ0.le _)) hR (Nat.cast_nonneg _) (by positivity) + _ = 4*σ^(1-η/2+9*beta η) := by + rw [mul_assoc, mul_left_comm (σ^(8*beta η)) 4, ← mul_assoc, + mul_comm (σ^(1-η/2)) 4, mul_assoc, ← Real.rpow_add hσ0, + ← Real.rpow_add hσ0] + congr 2 + ring + +lemma eventually_monomial_le_linear (C a ε : ℝ) (ha : a < 1) (hε : 0 < ε) : + ∀ᶠ x : ℝ in atTop, C*x^a ≤ ε*x := by + have ht : Tendsto (fun x : ℝ => C*x^(a-1)) atTop (𝓝 0) := by + convert (tendsto_rpow_neg_atTop (sub_pos.mpr ha)).const_mul C using 1 <;> simp + filter_upwards [ht.eventually (gt_mem_nhds hε), eventually_gt_atTop (0 : ℝ)] with x hx hx0 + calc + _ = (C*x^(a-1))*x := by + have hp : x^(a-1)*x = x^a := by + calc + _ = x^(a-1)*x^(1 : ℝ) := by rw [Real.rpow_one] + _ = _ := by rw [← Real.rpow_add hx0]; congr 1; ring + rw [mul_assoc, hp] + _ ≤ ε*x := mul_le_mul_of_nonneg_right hx.le hx0.le + +theorem eventually_P_le_linear {η : ℝ} (hη : 0 < η) (ε : ℝ) (hε : 0 < ε) : + ∀ᶠ σ : ℝ in atTop, ∀ (D : ℝ) (R : ℕ), Admissible σ η D R → + scaleP σ η D R ≤ ε*σ := by + filter_upwards [eventually_monomial_le_linear 4 (1-η/2+9*beta η) ε + (exponent_gap hη) hε, eventually_ge_atTop (1 : ℝ)] with σ hσ hσ1 D R h + exact (scale_bounds hσ1 hη h).2.2.trans hσ + +theorem moment_order_le {σ P : ℝ} {p : ℕ} (hσ : 10002 ≤ σ) (hP : 1 ≤ P) + (hp : (p : ℝ) ≤ 10000*σ/P+2) : (p : ℝ) ≤ σ^2 := by + have hσ0 : 0 ≤ σ := by linarith + have hdiv : 10000*σ/P ≤ 10000*σ := div_le_self (by positivity) hP + nlinarith [sq_nonneg (σ-10002)] + +theorem eventually_enumeration_budgets {η : ℝ} (hη : 0 < η) : + ∀ᶠ σ : ℝ in atTop, ∀ (D : ℝ) (R p m : ℕ), Admissible σ η D R → + (p : ℝ) ≤ 10000*σ/scaleP σ η D R+2 → (m : ℝ) ≤ σ^2 → + 10000 ≤ scaleL σ η D ∧ + certificateOverhead p m (scaleP σ η D R) ≤ Real.exp (2*scaleP σ η D R/25) ∧ + shiftOverhead p m ≤ Real.exp (2*scaleP σ η D R/25) ∧ + (p : ℝ)^2 ≤ Real.exp (scaleP σ η D R/10) ∧ + 2*(p : ℝ)+3 ≤ Real.exp (scaleP σ η D R/10) ∧ + ∃ h : ℕ, 0 < h ∧ 400 ≤ R ∧ h ≤ (R/2)/400 ∧ + (p : ℝ)*h*(19/20 : ℝ)^(h-1) < 1/2 := by + have hb := beta_pos hη + have h10 : 0 < 10*beta η := by positivity + have h9 : 0 < 9*beta η := by positivity + filter_upwards [eventually_certificate_budget (10*beta η) h10, + eventually_shift_budget (10*beta η) h10, + eventually_position_budgets (10*beta η) h10, + eventually_root_budget (beta η) hb, + (tendsto_rpow_atTop h9).eventually_ge_atTop 10000, + eventually_P_le_linear hη 1 (by norm_num), + eventually_ge_atTop (10002 : ℝ)] with σ hc hs hp hr hL hPu hσ D R p m had hp' hm + have hσ1 : 1 ≤ σ := by linarith + obtain ⟨hLb, hPb, _⟩ := scale_bounds hσ1 hη had + have hP1 : 1 ≤ scaleP σ η D R := (Real.one_le_rpow hσ1 h10.le).trans hPb + have hpm : (p : ℝ) ≤ σ^2 := moment_order_le hσ hP1 hp' + have hP2 : scaleP σ η D R ≤ σ^2 := by + have := hPu D R had + nlinarith [sq_nonneg (σ-1)] + obtain ⟨hp2, hps⟩ := hp p (scaleP σ η D R) hpm hPb + exact ⟨hL.trans hLb, hc p m _ hpm hm hPb hP2, + hs p m _ hpm hm hPb, hp2, hps, hr p R hpm had.R_lower⟩ + +end SharpLogRamsey.SourceScales +end + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Parameters/SourceTrainingScales.lean b/lean/OAI/Combinatorics/SharpRamsey/Parameters/SourceTrainingScales.lean new file mode 100644 index 0000000000000000000000000000000000000000..98c1e0636a37ca4cada3fc2fcc5dbb67793c8624 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Parameters/SourceTrainingScales.lean @@ -0,0 +1,72 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Parameters.SourcePencilScales + +namespace OAI + +section +namespace SharpLogRamsey.SourceScales +open Filter Real +open scoped Topology +noncomputable section + +theorem eventually_training_loss {η : ℝ} (hη : 0<η) (C δ : ℝ) + (hC : 0≤C) (hδ : 0<δ) : + ∀ᶠ σ : ℝ in atTop,∀ (D : ℝ) (R : ℕ),Admissible σ η D R → + ∀ b τ : ℝ,b≤C*scaleKstar σ η D → τ≤C*σ^(-100*beta η) → + b+2*scaleP σ η D R*τ≤δ*scaleL σ η D := by + filter_upwards [eventually_sparse_loss hη (2*C) δ (by positivity) hδ, + eventually_ge_atTop (1:ℝ)] with σ hh hσ D R had b τ hb hτ + have hK : 0 ≤ scaleKstar σ η D := by + rw [Kstar_eq _ _ _ (by linarith)] + exact mul_nonneg (L_pos (by linarith) had).le (Real.rpow_nonneg (by linarith) _) + have h1 : b≤(2*C)*scaleKstar σ η D := by nlinarith + have h2 : 2*τ≤(2*C)*σ^(-100*beta η) := by linarith + have hh' := hh D R had b (2*τ) h1 h2 + nlinarith only [hh'] + +theorem eventually_exceptional_training {η : ℝ} (hη : 0<η) (C : ℝ) (hC : 0≤C) : + ∀ᶠ σ : ℝ in atTop,∀ (D : ℝ) (R : ℕ),Admissible σ η D R → + ∀ b τ : ℝ,b≤C*scaleKstar σ η D → τ≤C*σ^(-100*beta η) → + 50000*Real.exp (-(95/100:ℝ)*scaleL σ η D)≤ + Real.exp (-b-2*scaleP σ η D R*τ)/800 := by + have he : ∀ᶠ L : ℝ in atTop,(40000000:ℝ)≤Real.exp (L/2) := by + filter_upwards [eventually_ge_atTop (80000000:ℝ)] with L hL + have hh := Real.add_one_le_exp (L/2) + linarith + filter_upwards [eventually_training_loss hη C (1/100) hC (by norm_num), + eventually_uniform_L hη he,eventually_ge_atTop (1:ℝ)] with σ hl he hσ D R had b τ hb hτ + have hL := (L_pos (by linarith) had).le + have hl' := hl D R had b τ hb hτ + have he' := he D R had + have hh : 40000000*Real.exp (-(95/100:ℝ)*scaleL σ η D)≤ + Real.exp (-b-2*scaleP σ η D R*τ) := by + calc + _ ≤ Real.exp (scaleL σ η D/2)*Real.exp (-(95/100:ℝ)*scaleL σ η D) := + mul_le_mul_of_nonneg_right he' (Real.exp_pos _).le + _ = Real.exp (scaleL σ η D/2-(95/100:ℝ)*scaleL σ η D) := by + rw [←Real.exp_add]; congr 1; ring + _ ≤ _ := Real.exp_le_exp.mpr (by linarith) + linarith + +lemma exceptional_below_threshold {B q T z L P b τ : ℝ} + (hB : 0≤B) (hq : 0flagPair (F x j)) m B Λ L) + (hmlo : c*(q:ℝ)*σ^(1+η) ≤ m) : + (m:ℝ)*(((i+3:ℕ):ℝ)*σ+η*log σ)-(1+|log c|+|log (2*(Lstar*2))|)*m ≤ + entropy (e.μ.map (fun x j=>flagPair (F (e.source x) (e.chosen x j)))) := by + have hq0 : (0:ℝ) < q:=he ▸ exp_pos _ + have hσ0 : 0 < σ:=by linarith + have hm : 0 < m:=by + have hscale : 0 < σ^(1+η):= + lt_of_lt_of_le zero_lt_one (one_le_rpow hσ (by linarith only [hη])) + have : (0:ℝ) < m:=(mul_pos (mul_pos hc hq0) hscale).trans_le hmlo + exact_mod_cast this + have halphabet:=flag_alphabet_lower i q + have : Nonempty (Flag (ZMod q) (Fin (i+4)→ZMod q)):=Fintype.card_pos_iff.mp (by + have : (0:ℝ) < (Fintype.card (Flag (ZMod q) (Fin (i+4)→ZMod q)):ℝ):=(pow_pos hq0 _).trans_le halphabet + exact_mod_cast this) + let ee:=e.mono (le_refl _) (le_refl _) hLL + have hh:=ee.tracked_entropy stream F flagPair flagPair_injective (by intros;rfl) + (by omega : 1 ≤ i+3) hm hkn (by norm_num : (0:ℝ) < 2) hLs hq0 hσ0 hc + hdom hselect hN hmlo halphabet + have hlogq : log (q:ℝ)=σ:=by rw [←he,log_exp] + rw [hlogq] at hh + dsimp only [ee,ContextOutput.mono] at hh + have hh' : (m:ℝ)*(((i+3:ℕ):ℝ)*σ+η*log σ+log c-1)-log (2*(Lstar*2)) ≤ + entropy (e.μ.map (fun x j=>flagPair (F (e.source x) (e.chosen x j)))) := by + convert hh using 1 + first | ring | congr! + have hpos : (1:ℝ) ≤ m:=by exact_mod_cast hm + have hm' : |log (2*(Lstar*2))| ≤ (m:ℝ)*|log (2*(Lstar*2))|:=le_mul_of_one_le_left (abs_nonneg _) hpos + have hc':=mul_le_mul_of_nonneg_left (neg_abs_le (log c)) (Nat.cast_nonneg m) + nlinarith only [hh',hm',hc',le_abs_self (log (2*(Lstar*2)))] + +end +end SharpLogRamsey.Marking + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Planar/HeavyPlaneCover.lean b/lean/OAI/Combinatorics/SharpRamsey/Planar/HeavyPlaneCover.lean new file mode 100644 index 0000000000000000000000000000000000000000..3fc398a30e8558697e20ac9956b68038dcc12882 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Planar/HeavyPlaneCover.lean @@ -0,0 +1,128 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Planar.HeavyPlaneInput +import OAI.Combinatorics.SharpRamsey.Planar.PlanarComplete + +namespace OAI + +section +namespace SharpLogRamsey.HeavyPlaneRestriction +open Finset Real Filter SourceScales Incidence PreparedProjectiveGeometry +open scoped Classical BigOperators Topology +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedHeavyPlaneCover_1 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedHeavyPlaneCover_2 : Fintype (Projectivization K V) := by + let : Finite V := Module.finite_of_finite K + exact Fintype.ofFinite _ +local instance flat_JoinedHeavyPlaneCover_3 (W : Submodule K V) : Fintype (Projectivization K W) := by + let : Finite W := Module.finite_of_finite K + exact Fintype.ofFinite _ + +lemma planeSupport_mono (W : Submodule K V) {S U : Finset (Projectivization K V)} + (h : S⊆U) : planeSupport W S⊆planeSupport W U := by + intro a ha + exact mem_filter.mpr ⟨mem_univ _,h (mem_filter.mp ha).2⟩ + +lemma plane_cap_lift (W : Submodule K V) (U S : Finset (Projectivization K V)) + (E : Finset (Projectivization K W)) (hE : E⊆planeSupport W U) : + E.image (Projectivization.map W.subtype W.injective_subtype)⊆U ∧ + (E.image (Projectivization.map W.subtype W.injective_subtype)).card=E.card ∧ + (S∩E.image (Projectivization.map W.subtype W.injective_subtype)).card= + (planeSupport W S∩E).card := by + have hi := Projectivization.map_injective W.subtype W.injective_subtype + refine ⟨?_,card_image_of_injective _ hi,?_⟩ + · intro a ha + obtain ⟨x,hx,rfl⟩ := mem_image.mp ha + exact (mem_filter.mp (hE hx)).2 + · have he : (planeSupport W S∩E).image (Projectivization.map W.subtype W.injective_subtype)= + S∩E.image (Projectivization.map W.subtype W.injective_subtype) := by + ext a + constructor + · intro ha + obtain ⟨x,hx,rfl⟩ := mem_image.mp ha + exact mem_inter.mpr ⟨(mem_filter.mp (mem_inter.mp hx).1).2, + mem_image.mpr ⟨x,(mem_inter.mp hx).2,rfl⟩⟩ + · intro ha + obtain ⟨ha,hE⟩ := mem_inter.mp ha + obtain ⟨x,hx,rfl⟩ := mem_image.mp hE + exact mem_image.mpr ⟨x,mem_inter.mpr ⟨mem_filter.mpr ⟨mem_univ _,ha⟩,hx⟩,rfl⟩ + rw [←he,card_image_of_injective _ hi] + +lemma heavy_domain_gaps (N M N₁ M₁ n t a u h L : ℝ) + (hN : 0 + E.image (Projectivization.map W.subtype W.injective_subtype) + refine ⟨caps.image f,?_,?_,?_⟩ + · intro E hE + obtain ⟨E₀,hE₀,rfl⟩ := mem_image.mp hE + obtain ⟨hEU,hsize⟩ := hs E₀ hE₀ + obtain ⟨hsub,hcard,_⟩ := plane_cap_lift W U ∅ E₀ hEU + refine ⟨hsub,?_⟩ + dsimp only [f] + rw [hcard] + exact hsize.trans (mul_le_mul_of_nonneg_right (by exact_mod_cast han) (exp_pos _).le) + · intro S T hSU _ hSa hTU hTt hsp + obtain ⟨E,hE,hcap⟩ := hc (planeSupport W S) T (planeSupport_mono W hSU) hSa hTU hTt hsp + refine ⟨f E,mem_image.mpr ⟨E,hE,rfl⟩,?_⟩ + obtain ⟨_,_,he⟩ := plane_cap_lift W U S E (hs E hE).1 + dsimp only [f] + rw [he] + have hna' : (n:ℝ)≤50*a := by exact_mod_cast hna + linarith + · apply le_trans _ hl + apply log_le_log (by positivity) + have hh := card_image_le (s:=caps) (f:=f) + exact_mod_cast Nat.add_le_add_right hh 1 + +end +end SharpLogRamsey.HeavyPlaneRestriction + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Planar/HeavyPlaneCurrent.lean b/lean/OAI/Combinatorics/SharpRamsey/Planar/HeavyPlaneCurrent.lean new file mode 100644 index 0000000000000000000000000000000000000000..e78b1f7d93a1a6aed845e1446ba8321a212f0282 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Planar/HeavyPlaneCurrent.lean @@ -0,0 +1,195 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.Projection +import OAI.Combinatorics.SharpRamsey.Marking.MultiplicityClass + +namespace OAI + +section +namespace SharpLogRamsey.HeavyPlaneRestriction +open Finset SharpLogRamsey.Incidence SharpLogRamsey.Projection +open scoped Classical +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + +def center (W : Submodule K V) (hW : Module.finrank K W + 1 = Module.finrank K V) : + Projectivization K (Module.Dual K V) := + Projectivization.mk'' W.dualAnnihilator (by + have h := Subspace.finrank_add_finrank_dualAnnihilator_eq W + omega) + +lemma center_submodule (W : Submodule K V) + (hW : Module.finrank K W + 1 = Module.finrank K V) : + (center W hW).submodule = W.dualAnnihilator := by + simp [center] + +lemma restrict_ne_zero (W : Submodule K V) + (hW : Module.finrank K W + 1 = Module.finrank K V) + (t : Projectivization K (Module.Dual K V)) (ht : t ≠ center W hW) : + W.dualRestrict t.rep ≠ 0 := by + intro h + apply ht + apply (rep_mem_line_iff t (center W hW)).mp + rw [center_submodule, ← W.dualRestrict_ker_eq_dualAnnihilator] + exact h + +def restrict (W : Submodule K V) + (hW : Module.finrank K W + 1 = Module.finrank K V) + (t : {t : Projectivization K (Module.Dual K V) // t ≠ center W hW}) : + Projectivization K (Module.Dual K W) := + Projectivization.mk K (W.dualRestrict t.val.rep) (restrict_ne_zero W hW t.val t.property) + +lemma restrict_eq_project (W : Submodule K V) + (hW : Module.finrank K W + 1 = Module.finrank K V) + (t u : {t : Projectivization K (Module.Dual K V) // t ≠ center W hW}) + (he : restrict W hW t = restrict W hW u) : + project (center W hW) t = project (center W hW) u := by + obtain ⟨a,ha⟩ := (Projectivization.mk_eq_mk_iff' K _ _ _ _).mp he + have hz : t.val.rep - a • u.val.rep ∈ (center W hW).submodule := by + rw [center_submodule, ← W.dualRestrict_ker_eq_dualAnnihilator] + change W.dualRestrict (t.val.rep-a • u.val.rep)=0 + rw [map_sub,map_smul,← ha,sub_self] + unfold project + apply (Projectivization.mk_eq_mk_iff' K _ _ _ _).mpr + refine ⟨a,?_⟩ + change a • (center W hW).submodule.mkQ u.val.rep = _ + have hh : (center W hW).submodule.mkQ (t.val.rep-a • u.val.rep)=0 := by + change _ ∈ LinearMap.ker (center W hW).submodule.mkQ + rwa [Submodule.ker_mkQ] + rw [map_sub,map_smul,sub_eq_zero] at hh + exact hh.symm + +omit [FiniteDimensional K V] in +lemma incident_mk_left (v : V) (hv : v ≠ 0) + (f : Projectivization K (Module.Dual K V)) : + SharpLogRamsey.Incidence.Incident (Projectivization.mk K v hv) f ↔ f.rep v=0 := by + obtain ⟨a,ha⟩ := Projectivization.exists_smul_eq_mk_rep K v hv + unfold SharpLogRamsey.Incidence.Incident + rw [←ha] + simp [Units.smul_def] + +omit [FiniteDimensional K V] in +lemma incident_mk_right (p : Projectivization K V) (f : Module.Dual K V) (hf : f ≠ 0) : + SharpLogRamsey.Incidence.Incident p (Projectivization.mk K f hf) ↔ f p.rep=0 := by + obtain ⟨a,ha⟩ := Projectivization.exists_smul_eq_mk_rep K f hf + unfold SharpLogRamsey.Incidence.Incident + rw [←ha] + simp [Units.smul_def] + +lemma restrict_incident_iff (W : Submodule K V) + (hW : Module.finrank K W + 1 = Module.finrank K V) + (a : Projectivization K W) + (t : {t : Projectivization K (Module.Dual K V) // t ≠ center W hW}) : + SharpLogRamsey.Incidence.Incident a (restrict W hW t) ↔ + SharpLogRamsey.Incidence.Incident (Projectivization.map W.subtype W.injective_subtype a) t.val := by + rw [restrict,incident_mk_right] + conv_rhs => rw [←a.mk_rep,Projectivization.map_mk,incident_mk_left] + rfl + +variable [Finite K] [Fintype (Projectivization K (Module.Dual K V))] + +theorem restrict_fiber_card (W : Submodule K V) + (hW : Module.finrank K W + 1 = Module.finrank K V) + (A : Finset (Projectivization K (Module.Dual K V))) + (b : Projectivization K (Module.Dual K W)) : + ((A.subtype (· ≠ center W hW)).filter (fun t => restrict W hW t=b)).card ≤ Nat.card K := by + let F := (A.subtype (· ≠ center W hW)).filter (fun t => restrict W hW t=b) + by_cases hF : F.Nonempty + · obtain ⟨t,ht⟩ := hF + apply le_trans _ (project_fiber_card A (center W hW) (project (center W hW) t)) + apply card_le_card + intro u hu + obtain ⟨hu,hue⟩ := mem_filter.mp hu + apply mem_filter.mpr ⟨hu,?_⟩ + exact restrict_eq_project W hW u t (hue.trans (mem_filter.mp ht).2.symm) + · change F.card ≤ _ + rw [not_nonempty_iff_eq_empty.mp hF] + simp + +end +end SharpLogRamsey.HeavyPlaneRestriction + +namespace SharpLogRamsey.HeavyPlaneRestriction +open Finset SharpLogRamsey.Incidence SharpLogRamsey.Projection +open scoped Classical BigOperators +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + +lemma center_restrict_zero (W : Submodule K V) + (hW : Module.finrank K W+1=Module.finrank K V) : + W.dualRestrict (center W hW).rep=0 := by + have hm : (center W hW).rep ∈ (center W hW).submodule := + (rep_mem_line_iff _ _).mpr rfl + rw [center_submodule,←W.dualRestrict_ker_eq_dualAnnihilator] at hm + exact hm + +lemma center_incident (W : Submodule K V) + (hW : Module.finrank K W+1=Module.finrank K V) (a : Projectivization K W) : + SharpLogRamsey.Incidence.Incident (Projectivization.map W.subtype W.injective_subtype a) (center W hW) := by + rw [←a.mk_rep,Projectivization.map_mk,incident_mk_left] + have he := congrArg (fun f : Module.Dual K W => f a.rep) (center_restrict_zero W hW) + exact he + +lemma sparse_noncentral (W : Submodule K V) + (hW : Module.finrank K W+1=Module.finrank K V) + (S : Finset (Projectivization K W)) (hS : S.Nonempty) + (t : Projectivization K (Module.Dual K V)) (δ : ℝ) (hδ : δ<1) + (hs : ((S.filter (fun a => SharpLogRamsey.Incidence.Incident (Projectivization.map W.subtype W.injective_subtype a) t)).card:ℝ) + ≤δ*S.card) : t≠center W hW := by + intro ht + subst t + have hf : S.filter (fun a => SharpLogRamsey.Incidence.Incident (Projectivization.map W.subtype W.injective_subtype a) + (center W hW))=S := filter_eq_self.mpr (fun a _ => center_incident W hW a) + rw [hf] at hs + have hp : (0:ℝ) SharpLogRamsey.Incidence.Incident + (Projectivization.map W.subtype W.injective_subtype a) t)).card:ℝ)≤δ*S.card) : + ∃ (h : ℕ) (T₁ U₁ : Finset (Projectivization K (Module.Dual K W))), + 1≤h ∧ h≤Nat.card K ∧ T₁.Nonempty ∧ T₁⊆U₁ ∧ + h*U₁.card≤U.card ∧ + (T.card:ℝ)≤2*h*(Nat.log 2 (Nat.card K)+1:ℕ)*(T₁.card:ℝ) ∧ + (∀ t∈T₁,((S.filter (fun a => SharpLogRamsey.Incidence.Incident a t)).card:ℝ)≤δ*S.card) ∧ + U₁=MultiplicityClass.domain (U.subtype (· ≠ center W hW)) (restrict W hW) h := by + have hn : ∀ t∈T,t≠center W hW := fun t ht => sparse_noncentral W hW S hS t δ hδ (hs t ht) + let A := T.subtype (· ≠ center W hW) + let B := U.subtype (· ≠ center W hW) + have hA : A.Nonempty := by + obtain ⟨t,ht⟩ := hT + exact ⟨⟨t,hn t ht⟩,mem_subtype.mpr ht⟩ + have hAB : A⊆B := fun t ht => mem_subtype.mpr (hTU (mem_subtype.mp ht)) + have hAc : A.card=T.card := by + rw [card_subtype,filter_eq_self.mpr hn] + have hBc : B.card≤U.card := by rw [card_subtype]; exact card_filter_le _ _ + have hq : 1≤Nat.card K := (Finite.one_lt_card : 1 restrict_fiber_card W hW T t) + refine ⟨h,T₁,MultiplicityClass.domain B (restrict W hW) h,hh,hq',hT₁,hsub, + (MultiplicityClass.domain_card B (restrict W hW) h).trans hBc,?_,?_,rfl⟩ + · rwa [hAc] at hsize + · intro t ht + obtain ⟨u,hu,rfl⟩ := mem_image.mp (himage ht) + have hs' := hs u.val (mem_subtype.mp hu) + have he : S.filter (fun a => SharpLogRamsey.Incidence.Incident a (restrict W hW u))= + S.filter (fun a => SharpLogRamsey.Incidence.Incident (Projectivization.map W.subtype W.injective_subtype a) u.val) := by + apply filter_congr + intro a ha + exact restrict_incident_iff W hW a u + rwa [he] + +end +end SharpLogRamsey.HeavyPlaneRestriction + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Planar/HeavyPlaneInput.lean b/lean/OAI/Combinatorics/SharpRamsey/Planar/HeavyPlaneInput.lean new file mode 100644 index 0000000000000000000000000000000000000000..72d175a4cfeb4c0cccec81eedbfa72ced1468273 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Planar/HeavyPlaneInput.lean @@ -0,0 +1,157 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Spatial.SpatialPrepared +import OAI.Combinatorics.SharpRamsey.Planar.HeavyPlaneCurrent + +namespace OAI + +section +namespace SharpLogRamsey.HeavyPlaneRestriction +open Finset Real Incidence PreparedProjectiveGeometry +open scoped Classical BigOperators +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedHeavyPlaneInput_1 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedHeavyPlaneInput_2 : Fintype (Projectivization K V) := by + let : Finite V := Module.finite_of_finite K + exact Fintype.ofFinite _ +local instance flat_JoinedHeavyPlaneInput_3 : Fintype (Projectivization K (Module.Dual K V)) := Fintype.ofFinite _ +local instance flat_JoinedHeavyPlaneInput_4 (W : Submodule K V) : Fintype (Projectivization K W) := by + let : Finite W := Module.finite_of_finite K + exact Fintype.ofFinite _ + +def planeSupport (W : Submodule K V) (S : Finset (Projectivization K V)) : + Finset (Projectivization K W) := + univ.filter (fun a => Projectivization.map W.subtype W.injective_subtype a∈S) + +lemma planeSupport_image (W : Submodule K V) (S : Finset (Projectivization K V)) : + (planeSupport W S).image (Projectivization.map W.subtype W.injective_subtype)=S∩planePoints W := by + ext x + constructor + · intro hx + obtain ⟨a,ha,rfl⟩ := mem_image.mp hx + refine mem_inter.mpr ⟨(mem_filter.mp ha).2,mem_planePoints.mpr ?_⟩ + exact (projectiveSubmoduleEquiv W a).property + · intro hx + obtain ⟨hS,hW⟩ := mem_inter.mp hx + let a := (projectiveSubmoduleEquiv W).symm ⟨x,mem_planePoints.mp hW⟩ + have he : Projectivization.map W.subtype W.injective_subtype a=x := + congrArg Subtype.val ((projectiveSubmoduleEquiv W).apply_symm_apply _) + exact mem_image.mpr ⟨a,mem_filter.mpr ⟨mem_univ _,by simpa only [he]⟩,he⟩ + +lemma planeSupport_card (W : Submodule K V) (S : Finset (Projectivization K V)) : + (planeSupport W S).card=(S∩planePoints W).card := by + rw [←planeSupport_image,card_image_of_injective _ + (Projectivization.map_injective W.subtype W.injective_subtype)] + +lemma planeSupport_incidence_le (W : Submodule K V) (S : Finset (Projectivization K V)) + (t : Projectivization K (Module.Dual K V)) : + ((planeSupport W S).filter (fun a => SharpLogRamsey.Incidence.Incident + (Projectivization.map W.subtype W.injective_subtype a) t)).card≤ + (S.filter (fun a => SharpLogRamsey.Incidence.Incident a t)).card := by + rw [←card_image_of_injective _ (Projectivization.map_injective W.subtype W.injective_subtype)] + apply card_le_card + intro x hx + obtain ⟨a,ha,rfl⟩ := mem_image.mp hx + obtain ⟨ha,ht⟩ := mem_filter.mp ha + exact mem_filter.mpr ⟨(mem_filter.mp ha).2,ht⟩ + +theorem heavy_half (W : Submodule K V) (S : Finset (Projectivization K V)) + (T : Finset (Projectivization K (Module.Dual K V))) (τ : ℝ) + (hτ : 0<τ) (hA : (planeSupport W S).Nonempty) + (hheavy : (S.card:ℝ)≤50*(planeSupport W S).card) + (hs : (incidenceCount S T:ℝ)≤τ*(S.card:ℝ)*T.card/Nat.card K) : + ∃ T₀ : Finset (Projectivization K (Module.Dual K V)),T₀⊆T ∧ T.card≤2*T₀.card ∧ + ∀ t∈T₀,(((planeSupport W S).filter (fun a => SharpLogRamsey.Incidence.Incident + (Projectivization.map W.subtype W.injective_subtype a) t)).card:ℝ)≤ + (100*τ/Nat.card K)*(planeSupport W S).card := by + let D := fun t : Projectivization K (Module.Dual K V) => + (((planeSupport W S).filter (fun a => SharpLogRamsey.Incidence.Incident + (Projectivization.map W.subtype W.injective_subtype a) t)).card:ℝ) + let δ := 100*τ/(Nat.card K:ℝ) + let A := (planeSupport W S).card + let T₀ := T.filter (fun t => D t≤δ*A) + let B := T\T₀ + have hq : (0:ℝ) by + dsimp only [D] + exact_mod_cast planeSupport_incidence_le W S t) + have htot : ∑ t∈T,D t≤δ*A*T.card/2 := by + apply hsum.trans (hs.trans _) + calc + _ ≤ τ*(50*A)*T.card/Nat.card K := by gcongr + _ = _ := by dsimp [δ]; ring + have hB : δ*A*B.card≤∑ t∈T,D t := by + calc + _ = ∑ _t∈B,δ*A := by simp; ring + _ ≤ ∑ t∈B,D t := by + apply sum_le_sum + intro t ht + have htt := (mem_sdiff.mp ht).1 + have hn := (mem_sdiff.mp ht).2 + exact (lt_of_not_ge (fun hh => hn (mem_filter.mpr ⟨htt,hh⟩))).le + _ ≤ _ := sum_le_sum_of_subset_of_nonneg sdiff_subset (by intros; dsimp [D]; positivity) + have hc : B.card+T₀.card=T.card := by exact card_sdiff_add_card_eq_card hsub + have hbr : (B.card:ℝ)≤(T.card:ℝ)/2 := by + have hp := mul_pos hδ hAp + nlinarith [hB.trans htot] + refine ⟨T₀,hsub,?_,fun t ht => (mem_filter.mp ht).2⟩ + have hc' : (B.card:ℝ)+T₀.card=T.card := by exact_mod_cast hc + have := (show (T.card:ℝ)≤2*T₀.card by linarith) + exact_mod_cast this + +theorem heavy_reduction (W : Submodule K V) + (hW : Module.finrank K W+1=Module.finrank K V) + (S : Finset (Projectivization K V)) (hS : S.Nonempty) + (T U : Finset (Projectivization K (Module.Dual K V))) + (hT : T.Nonempty) (hTU : T⊆U) (τ b : ℝ) + (hτ : 0<τ) (hτsmall : 100*τ/(Nat.card K:ℝ)<1) + (hheavy : (S.card:ℝ)/50≤(S∩planePoints W).card) + (hprod : (Nat.card K:ℝ)^4*exp (-b)≤(S.card:ℝ)*T.card) + (hs : (incidenceCount S T:ℝ)≤τ*(S.card:ℝ)*T.card/Nat.card K) : + ∃ (h : ℕ) (T₁ U₁ : Finset (Projectivization K (Module.Dual K W))), + 1≤h ∧ h≤Nat.card K ∧ T₁.Nonempty ∧ T₁⊆U₁ ∧ h*U₁.card≤U.card ∧ + (T.card:ℝ)≤4*h*(Nat.log 2 (Nat.card K)+1:ℕ)*(T₁.card:ℝ) ∧ + (∀ t∈T₁,(((planeSupport W S).filter (fun a => SharpLogRamsey.Incidence.Incident a t)).card:ℝ)≤ + (100*τ/Nat.card K)*(planeSupport W S).card) ∧ + (Nat.card K:ℝ)^3*exp (-b)≤ + 200*(Nat.log 2 (Nat.card K)+1:ℕ)*(planeSupport W S).card*(T₁.card:ℝ) ∧ + U₁=MultiplicityClass.domain (U.subtype (· ≠ center W hW)) (restrict W hW) h := by + have hAp : (0:ℝ)<(planeSupport W S).card := by + rw [planeSupport_card] + exact (div_pos (by exact_mod_cast card_pos.mpr hS) (by norm_num)).trans_le hheavy + have hA : (planeSupport W S).Nonempty := card_pos.mp (by exact_mod_cast hAp) + have hh : (S.card:ℝ)≤50*(planeSupport W S).card := by rw [planeSupport_card]; linarith + obtain ⟨T₀,hsub,hhalf,hsp⟩ := heavy_half W S T τ hτ hA hh hs + have ht₀ : T₀.Nonempty := card_pos.mp (by have := card_pos.mpr hT; omega) + obtain ⟨h,T₁,U₁,hh1,hhq,ht₁,htu,hcap,hsize,hsp₁,he⟩ := + sparse_restriction_class W hW (planeSupport W S) hA T₀ U ht₀ (hsub.trans hTU) + (100*τ/Nat.card K) hτsmall hsp + have hhalf' : (T.card:ℝ)≤2*T₀.card := by exact_mod_cast hhalf + have hsize' : (T.card:ℝ)≤4*h*(Nat.log 2 (Nat.card K)+1:ℕ)*(T₁.card:ℝ) := by linarith + refine ⟨h,T₁,U₁,hh1,hhq,ht₁,htu,hcap,hsize',hsp₁,?_,he⟩ + have hq : (0:ℝ) (W:Set V)) SetLike.coe_injective + exact Fintype.ofFinite _ + +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +abbrev HeavyHeaders (K V : Type) [Field K] [AddCommGroup V] [Module K V] (n m : ℕ) := + {W : Submodule K V // Module.finrank K W=3} × Fin (Nat.card K+1) × Fin (n+1) × Fin (m+1) +local instance flat_JoinedHeavyPlanePublic_4 (n m : ℕ) : Fintype (HeavyHeaders K V n m) := by + unfold HeavyHeaders + infer_instance +abbrev headerPlane {n m : ℕ} (j : HeavyHeaders K V n m) : Submodule K V := j.1.val +omit [Finite K] [FiniteDimensional K V] in +lemma header_rank {n m : ℕ} (j : HeavyHeaders K V n m) : Module.finrank K (headerPlane j)=3 := j.1.property +omit [Finite K] [FiniteDimensional K V] in +lemma header_codim (hV : Module.finrank K V=4) {n m : ℕ} (j : HeavyHeaders K V n m) : + Module.finrank K (headerPlane j)+1=Module.finrank K V := by rw [header_rank,hV] +def headerDomain (hV : Module.finrank K V=4) + (UT : Finset (Projectivization K (Module.Dual K V))) {n : ℕ} + (j : HeavyHeaders K V n UT.card) := MultiplicityClass.domain + (UT.subtype (· ≠ center (headerPlane j) (header_codim hV j))) + (restrict (headerPlane j) (header_codim hV j)) j.2.1.val +def HeaderValid (hV : Module.finrank K V=4) + (U : Finset (Projectivization K V)) (UT : Finset (Projectivization K (Module.Dual K V))) + (n t : ℕ) (L b₁ : ℝ) (j : HeavyHeaders K V n UT.card) : Prop := + 0 x.val) + Subtype.val_injective + +theorem heavy_families {η : ℝ} (hη : 0<η) (C : ℝ) (hC : 1≤C) : + ∀ᶠ σ : ℝ in atTop,∀ (K V : Type) [Field K] [Finite K] + [AddCommGroup V] [Module K V] [FiniteDimensional K V], + ∀ D R,Admissible σ η D R → exp σ=(Nat.card K:ℝ) → ∀ hV : Module.finrank K V=4, + ∀ (U : Finset (Projectivization K V)) + (UT : Finset (Projectivization K (Module.Dual K V))) (n t : ℕ) (b τ : ℝ), + 0 100*C*σ^(-100*beta η)) atTop (𝓝 0) := by + simpa using (tendsto_rpow_neg_atTop (by have := beta_pos hη; positivity : 0<100*beta η)).const_mul (100*C) + filter_upwards [fixed_heavy_cover hη (101*C+2) hC',eventually_heavy_loss hη, + htiny.eventually (gt_mem_nhds (by norm_num : (0:ℝ)<1/20)), + eventually_ge_atTop (1:ℝ)] with σ hcover hloss htiny hσ + intro K V _ _ _ _ _ D R had hex hV U UT n t b τ hn ht hnu htu hb hbu hτ hτu + let P := scaleP σ η D R + let E := 4000*(Nat.card K:ℝ)*P*(log ((U.card:ℝ)/n)+log ((UT.card:ℝ)/t)+P) + let L : ℝ := (Nat.log 2 (Nat.card K)+1:ℕ) + let b₁ := b+log (200*L) + have hq : (0:ℝ) hc S T,?_⟩ + have he := exp_le_exp.mpr hlen + rw [exp_log (by positivity)] at he + linarith + · refine ⟨∅,by simp,?_,?_⟩ + · intro S T hj; exact (hv hj).elim + · simp only [card_empty,Nat.cast_zero]; exact (exp_pos _).le + choose fam hf using each + exact ⟨fam,hf⟩ + +theorem public_heavy_cover {η : ℝ} (hη : 0<η) (C : ℝ) (hC : 1≤C) : + ∀ᶠ σ : ℝ in atTop,∀ (K V : Type) [Field K] [Finite K] + [AddCommGroup V] [Module K V] [FiniteDimensional K V], + ∀ D R,Admissible σ η D R → exp σ=(Nat.card K:ℝ) → Module.finrank K V=4 → + ∀ (U : Finset (Projectivization K V)) + (UT : Finset (Projectivization K (Module.Dual K V))) (n t : ℕ) (b τ : ℝ), + 0 100*C*σ^(-100*beta η)) atTop (𝓝 0) := by + simpa using (tendsto_rpow_neg_atTop (by have := beta_pos hη; positivity : 0<100*beta η)).const_mul (100*C) + filter_upwards [heavy_families hη C hC, + htiny.eventually (gt_mem_nhds (by norm_num : (0:ℝ)<1/20))] with σ hf htiny + intro K V _ _ _ _ _ D R had hex hV U UT n t b τ hn ht hnu htu hb hbu hτ hτu + let P := scaleP σ η D R + let E := 4000*(Nat.card K:ℝ)*P*(log ((U.card:ℝ)/n)+log ((UT.card:ℝ)/t)+P) + let L : ℝ := (Nat.log 2 (Nat.card K)+1:ℕ) + let b₁ := b+log (200*L) + have hq : (0:ℝ) ring + have hupper := sparse_product_bound_two (n:=0) (by simpa using hW) (planeSupport W S) T₁ hsp20 + have hlo : (Nat.card K:ℝ)^3*exp (-b₁)≤((planeSupport W S).card:ℝ)*T₁.card := by + have hexp : exp (-b₁)=exp (-b)/(200*L) := by + dsimp only [b₁] + rw [neg_add,exp_add,exp_neg (log (200*L)),exp_log (by positivity)] + ring + rw [hexp,←mul_div_assoc] + apply (div_le_iff₀ (by positivity : 0<200*L)).mpr + dsimp only [L] + nlinarith [hprod₁] + have hv : valid j := by + dsimp only [valid,HeaderValid] + rw [hdj] + dsimp only [j,headerPlane] + refine ⟨by omega,?_,card_pos.mpr hT₁,?_,card_le_card (planeSupport_mono W hSU), + card_le_card hT₁U,hU₁,?_,hlo,?_⟩ + · have hc := hheavy + rw [←planeSupport_card] at hc + have := div_pos hn' (by norm_num : (0:ℝ)<50) + exact_mod_cast this.trans_le hc + · rw [←planeSupport_card] at hheavy + have hh : (n:ℝ)≤50*(planeSupport W S).card := by linarith + exact_mod_cast hh + · simpa only [hTt] using hsize₁ + · simpa using hupper + obtain ⟨E,hE,hcap⟩ := hcapture j S T₁ hv hSU hSn rfl (by rwa [hdj]) rfl (by simpa only [j,headerPlane] using hsp) + exact ⟨E,mem_biUnion.mpr ⟨j,mem_univ _,hE⟩,hcap⟩ + · have hsum : (caps.card:ℝ)≤∑ j : J,((fam j).card:ℝ) := by exact_mod_cast (card_biUnion_le (s:=(univ:Finset J)) (t:=fam)) + apply hsum.trans + calc + _ ≤ ∑ _j : J,exp E := sum_le_sum (fun j _ => hcount j) + _ = (Fintype.card J:ℝ)*exp E := by simp + _ ≤ _ := by + apply mul_le_mul_of_nonneg_right _ (exp_pos _).le + have hh := header_card K V n UT.card + rw [Nat.card_eq_fintype_card] at hh + exact_mod_cast hh + +end +end SharpLogRamsey.HeavyPlaneRestriction + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Planar/PlanarBoth.lean b/lean/OAI/Combinatorics/SharpRamsey/Planar/PlanarBoth.lean new file mode 100644 index 0000000000000000000000000000000000000000..3b589b6a1a1b25436d4305c18f06646f09182b69 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Planar/PlanarBoth.lean @@ -0,0 +1,138 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Planar.PlanarUniform +import OAI.Combinatorics.SharpRamsey.Validation.ValidationExtend +import OAI.Combinatorics.SharpRamsey.Geometry.ProjectiveTransport + +namespace OAI + +section +namespace SharpLogRamsey.PlanarLearning +open Finset Real Filter SourceScales Incidence +open scoped Classical BigOperators Topology NNReal +noncomputable section +local instance flat_JoinedPlanarBoth_1 {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedPlanarBoth_2 {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] : Fintype (Projectivization K V) := by + letI : Finite V := Module.finite_of_finite K + exact Fintype.ofFinite _ + +lemma validation_description_cost {q P d H : ℝ} (hq : 1≤q) (hP : 1≤P) + (hd : 0≤d) (hH : log (H+1)≤4*q) (h : ℕ) (hh : (h:ℝ)≤20*q*(d+2)+1) : + 2*((h:ℝ)*(6*P+log 2)+log 2+log (H+1))+log 3≤1000*q*P*(d+P) := by + have hl2 : 0≤log (2:ℝ) := log_nonneg (by norm_num) + have hl2' : log (2:ℝ)≤1 := by have := log_le_sub_one_of_pos (by norm_num : (0:ℝ)<2); linarith + have hl3 : log (3:ℝ)≤2 := by have := log_le_sub_one_of_pos (by norm_num : (0:ℝ)<3); linarith + have hh' : (h:ℝ)≤21*q*(d+2) := by nlinarith + have h1 := mul_le_mul_of_nonneg_right hh' (show 0≤6*P+log 2 by positivity) + have h2 := mul_le_mul_of_nonneg_left (show 6*P+log 2≤7*P by linarith) + (show 0≤21*q*(d+2) by positivity) + have hqP : q≤q*P := le_mul_of_one_le_right (by linarith) hP + have hPP : q*P≤q*P*P := le_mul_of_one_le_right (by positivity) hP + have hqp : 1≤q*P := one_le_mul_of_one_le_of_one_le hq hP + have hpos : 0≤q*P*d := by positivity + nlinarith + +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + +lemma plane_pair_log_card (hdim : Module.finrank K V=3) : + log (((Fintype.card (Projectivization K V):ℝ)+ + Fintype.card (Projectivization K (Module.Dual K V)))*log 2+1)≤4*Nat.card K := by + let A : ℝ := Fintype.card (Projectivization K V) + let B : ℝ := Fintype.card (Projectivization K (Module.Dual K V)) + have ha : 0≤A := by positivity + have hb : 0≤B := by positivity + have hl2 : 0≤log (2:ℝ) := log_nonneg (by norm_num) + have hl2' : log (2:ℝ)≤1 := by have := log_le_sub_one_of_pos (by norm_num : (0:ℝ)<2); linarith + have hbound : (A+B)*log 2+1≤(A+1)*(B+1) := by nlinarith [mul_nonneg ha hb] + have hh := log_le_log (by positivity : 0<(A+B)*log 2+1) hbound + rw [log_mul (by positivity) (by positivity)] at hh + have hA := (plane_log_card hdim).1 + have hB := (plane_log_card (K:=K) (V:=Module.Dual K V) (Subspace.dual_finrank_eq.trans hdim)).1 + change log ((A+B)*log 2+1)≤_ + dsimp only [A,B] at hh + linarith + +theorem dual_description + (hdim : Module.finrank K V=3) (U : Finset (Projectivization K V)) + (UT : Finset (Projectivization K (Module.Dual K V))) (n t : ℕ) + (hn : 0 (hsize W hW).2) + (by simpa only [Nat.zero_add,mul_comm] using hprod) + let out := caps.image (fun W => W.image e.symm) + have hq : (1:ℝ)≤Nat.card K := by exact_mod_cast (show 1≤Nat.card K from Nat.card_pos (α:=K)) + have hn' : (0:ℝ) ring + obtain ⟨F,hF,hcapF⟩ := hc T (S.image e) hTt (image_subset_image hSU) hcS hsp' ⟨W,hW,hcap⟩ + obtain ⟨hFU,_⟩ := hs F hF + have hp := ProjectiveDuality.pullback_cover e U S F hFU + refine ⟨F.image e.symm,mem_image.mpr ⟨F,hF,rfl⟩,?_⟩ + rw [hp.2.2] + nlinarith + · have hbound := hl + rw [hcard] at hbound + have hh : (Validation.scheduleLength (Nat.card K) U.card n:ℝ)≤ + 20*(Nat.card K:ℝ)*(log ((U.card:ℝ)/n)+2)+1 := by + exact (Nat.ceil_lt_add_one (by positivity)).le + have hcost := validation_description_cost hq hP hd + (plane_pair_log_card (K:=K) (V:=Module.Dual K V) hdim') + (Validation.scheduleLength (Nat.card K) U.card n) hh + have hc' : (out.card:ℝ)≤caps.card := by exact_mod_cast card_image_le (s:=caps) (f:=fun W => W.image e.symm) + have hout : log ((out.card:ℝ)+1)≤log ((caps.card:ℝ)+1) := log_le_log (by positivity) (by linarith) + apply hout.trans (hbound.trans _) + have hpos1 : 0≤(Nat.card K:ℝ)*P*log ((U.card:ℝ)/n) := by positivity + have hpos2 : 0≤(Nat.card K:ℝ)*P*log ((UT.card:ℝ)/t) := by positivity + have hpositive : 0≤(Nat.card K:ℝ)*P^2 := by positivity + nlinarith only [hlen,hcost,hpos1,hpos2,hpositive] + +end +end SharpLogRamsey.PlanarLearning + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Planar/PlanarBudget.lean b/lean/OAI/Combinatorics/SharpRamsey/Planar/PlanarBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..e964d23856f95dfdfeec4c3e150f66a2adcb89f7 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Planar/PlanarBudget.lean @@ -0,0 +1,118 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Selection.UniversalTables +import OAI.Combinatorics.SharpRamsey.Learning.RegularPreparationBounds +import OAI.Combinatorics.SharpRamsey.Planar.PlanePencils + +namespace OAI + +section +namespace SharpLogRamsey.PlanarLearning +open Finset Real PreparedRow PreparedGeometry PreparedTypical GreedyPreparation +open scoped Classical BigOperators NNReal +noncomputable section + +structure Budget (σ P : ℝ) (L : ℝ≥0) (R p h : ℕ) : Prop where + sigma : 2≤σ + large : 100000000000000≤P + upper : P≤σ + B : 2*exp (6*P)≤exp σ + identity : P=(L:ℝ)*R + Llarge : 10000≤(L:ℝ) + Rlarge : 400≤R + p_pos : 0

0) ∧ + HighPencil 2 R p h S O x c L A ((O.card:ℝ)/(S.card:ℝ)) B (∅ : Finset Unit) (fun _ => 0) := by + have hsqs : 400000*B*exp ((L:ℝ)/1000)≤400000*B*exp ((L:ℝ)/100) := by + apply mul_le_mul_of_nonneg_left _ (by positivity) + exact exp_le_exp.mpr (by nlinarith [L.coe_nonneg]) + have hsqa : 400000*B*exp ((L:ℝ)/1000)≤B*exp (P/100) := by + have hh := mul_le_mul_of_nonneg_left hbud.variance hB.le + nlinarith only [hh] + have hcs : ((∑ i∈range 2,Nat.card K^i):ℝ)≤400000*B^2 := by + nlinarith [sq_nonneg B] + exact plane_pencils hdim R p h hbud.p_pos S O x c L A hA _ B 400000 _ + hB.le htyp hsq hsqs (by simpa only [←hbud.identity] using hsqa) hcs hcards hdir + (by simpa only [←hbud.identity] using hbud.diag) + (by simpa only [←hbud.identity] using hbud.pow) + (by simpa only [←hbud.identity] using hbud.sum) + (by simpa only [←hbud.identity] using hbud.two) + (by simpa only [←hbud.identity] using hbud.cert) + (by simpa only [←hbud.identity] using hbud.shift) + (by simpa only [←hbud.identity] using hbud.pb) + (by simpa only [←hbud.identity] using hbud.ps) + hbud.h_pos hbud.h_small hbud.h_root + +omit [Field K] [Finite K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] in +lemma plane_error {q B L b e X : ℝ} (hq : 0 C*σ^(-100*beta η)) atTop (𝓝 0) := by + simpa using (tendsto_rpow_neg_atTop (by have := beta_pos hη; positivity : 0<100*beta η)).const_mul C + filter_upwards [full_source_cover_uniform hη C hC, + eventually_uniform_L hη (eventually_ge_atTop (2000:ℝ)),eventually_uniform_R hη 1, + eventually_training_loss hη C 1 (by linarith) (by norm_num), + ht.eventually (gt_mem_nhds (by norm_num : (0:ℝ)<1/20000)), + eventually_ge_atTop (1:ℝ)] with σ hcover hL hR hbsmall ht hσ + intro K V _ _ _ _ _ D R had hex hdim U UT n t b τ hn ht0 hnu htu hb hbu hτ hτu hprodlo hprodhi + let P := scaleP σ η D R + have hL' := hL D R had + have hR' := hR D R had + have hLP : scaleL σ η D≤P := le_mul_of_one_le_right (by linarith) hR' + have hP : 2000≤P := hL'.trans hLP + have hτsmall : τ≤1/20000 := hτu.trans ht.le + have hbP : b≤P := by + have hh := hbsmall D R had b 0 hbu (by positivity) + simp only [mul_zero,add_zero,one_mul] at hh + exact hh.trans hLP + have hn' : (0:ℝ) PreparedProposals.accepts (coordinateSupport i.1 R) M + (PreparedDescription.good i.1 (fun _ : Unit => ∅) [] L ((N:ℝ)/2) (N*exp (6*P))) + have hprob : ∀ i,exp (-a)≤PublicTables.acceptProb law (A i) := by + intro i + have hh := input_probability hdim U N hN0 σ P b τ L c R p h M hqexp hc hbud hb hτ hτsmall hN hloss herror hM i.1 i.2 + have he := PublicTables.sampling_exponent hNr hUr M (2*P*τ) + simp only [neg_mul] at hh + rw [he] at hh + apply le_trans _ hh + apply exp_le_exp.mpr + dsimp only [a,a₀] + have hh' : 0≤log (H+1) := log_nonneg (by linarith) + linarith + obtain ⟨messages,_,hsize,hcap,hlen⟩ := PublicTables.decoder_cover law A a H + ((N:ℝ)/2) (N*exp (6*P)) + (Fintype.card (Projectivization K (Module.Dual K V))) (decode U N L) (fun i : ι => i.1) + ha (input_card U N b τ) hea hprob + (fun i ω hω => input_decode U N L P b τ i.1 i.2 ω hω) + exact ⟨messages,hsize,fun S hS => hcap ⟨S,hS⟩,hlen⟩ + +end +end SharpLogRamsey.PlanarLearning + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Planar/PlanarDescription.lean b/lean/OAI/Combinatorics/SharpRamsey/Planar/PlanarDescription.lean new file mode 100644 index 0000000000000000000000000000000000000000..0b80f4480fe1e6d77d20aea1449187f7db1af4ad --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Planar/PlanarDescription.lean @@ -0,0 +1,126 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Planar.PlanarSourceCover +import OAI.Combinatorics.SharpRamsey.Learning.EnumeratedCover + +namespace OAI + +section +namespace SharpLogRamsey.PlanarLearning +open Finset Real Filter SourceScales +open scoped Classical BigOperators Topology NNReal +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedPlanarDescription_1 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedPlanarDescription_2 : Fintype (Projectivization K (Module.Dual K V)) := Fintype.ofFinite _ +local instance flat_JoinedPlanarDescription_3 : Fintype (Projectivization K V) := by + letI : Finite V := Module.finite_of_finite K + exact Fintype.ofFinite _ + +lemma plane_card (hdim : Module.finrank K V=3) : + (Fintype.card (Projectivization K V):ℝ)=1+Nat.card K+(Nat.card K:ℝ)^2 := by + rw [←Nat.card_eq_fintype_card,Projectivization.card_of_finrank K V hdim] + norm_num [sum_range_succ] + +lemma plane_log_card (hdim : Module.finrank K V=3) : + log ((Fintype.card (Projectivization K V):ℝ)+1)≤2*Nat.card K ∧ + log ((Fintype.card (Projectivization K V):ℝ)*log 2+1)≤2*Nat.card K := by + let q : ℝ := Nat.card K + have hq : 1≤q := by + dsimp only [q] + exact_mod_cast (show 1≤Nat.card K from Nat.card_pos (α:=K)) + have hQ : (Fintype.card (Projectivization K V):ℝ)+1≤(q+1)^2 := by + rw [plane_card hdim]; dsimp [q] at *; nlinarith + have hlog : log ((q+1)^2)≤2*q := by + rw [log_pow] + have hh := log_le_sub_one_of_pos (show 0 C*σ^(-100*beta η)) atTop (𝓝 0) := by + simpa using (tendsto_rpow_neg_atTop (by have := beta_pos hη; positivity : 0<100*beta η)).const_mul C + filter_upwards [source_cover (K:=K) (V:=V) hη C hC, + eventually_uniform_L hη (eventually_ge_atTop (1:ℝ)), + eventually_uniform_R hη 1,ht.eventually (gt_mem_nhds (by norm_num : (0:ℝ)<1))] + with σ hcover hL hR ht + intro D R had hex hdim U n b τ hn hnu hb hbu hτ hτu + let P := scaleP σ η D R + let q : ℝ := Nat.card K + let d := log ((U.card:ℝ)/n) + have hP : 1≤P := one_le_mul_of_one_le_of_one_le (hL D R had) (hR D R had) + have hq : 1≤q := by + dsimp only [q] + exact_mod_cast (show 1≤Nat.card K from Nat.card_pos (α:=K)) + have hn' : (0:ℝ) ∅) [] c + ∃ Ds : Finset (Projectivization K V), + (Ds.card:ℝ)≤(S.card:ℝ)/10000 ∧ + (∑ H∈E,mass S c H)≤20804*(Nat.card K:ℝ)*B ∧ + (∀ x,((own S (fun _ : Unit => ∅) [] x).card:ℝ)/(S.card:ℝ)≤1/25) ∧ + ∀ x,x∉Ds → + ((pencil x∩E).card:ℝ)≤50000*B*exp ((L:ℝ)/1000) ∧ + SecondPencil 2 R S (own S (fun _ : Unit => ∅) [] x) x c L (pencil x\E) + (((own S (fun _ : Unit => ∅) [] x).card:ℝ)/(S.card:ℝ)) B 400000 (∅ : Finset Unit) (fun _ => 0) ∧ + HighPencil 2 R p h S (own S (fun _ : Unit => ∅) [] x) x c L (pencil x\E) + (((own S (fun _ : Unit => ∅) [] x).card:ℝ)/(S.card:ℝ)) B (∅ : Finset Unit) (fun _ => 0) := by + let q : ℝ := Nat.card K + let N : ℝ := S.card + let B : ℝ := q^2/N + have hq : 0 ∅) [] c hc hcs (by intro i; exact Fin.elim0 i) L L.coe_nonneg + have hDsN : (Ds.card:ℝ)≤N/10000 := by + apply hDs.trans + have hh : exp (-(L:ℝ)/500)≤1 := exp_le_one_iff.mpr (by nlinarith [L.coe_nonneg]) + simpa only [mul_one] using mul_le_mul_of_nonneg_left hh (show 0≤N/10000 by positivity) + have hcards : ((∑ i∈range 2,Nat.card K^i):ℝ)≤4*B^2 := + Incidence.sparse_retained_pencil (n:=0) hdim S S hS Subset.rfl T hST hsp + have hdir : (1:ℝ)≤4*B := Incidence.scalar_direction_two q N hq2 hNs hsmall + refine ⟨Ds,hDsN,hW,hown,?_⟩ + intro x hx + obtain ⟨he,htyp,hsq⟩ := hregular x hx + refine ⟨he.le,?_⟩ + exact plane_pencil_budgets hdim S _ x c L _ sdiff_subset σ P B R p h + hbud hB htyp hsq hcards hdir + +end +end SharpLogRamsey.PlanarLearning + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Planar/PlanarPublic.lean b/lean/OAI/Combinatorics/SharpRamsey/Planar/PlanarPublic.lean new file mode 100644 index 0000000000000000000000000000000000000000..9601888548557afb668a3ec191b11d8c6b395c94 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Planar/PlanarPublic.lean @@ -0,0 +1,90 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Learning.PublicDecoderCover +import OAI.Combinatorics.SharpRamsey.Planar.PlanarRow + +namespace OAI + +section +namespace SharpLogRamsey.PlanarLearning +open Finset Real PreparedRow +open scoped Classical BigOperators NNReal +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedPlanarPublic_1 (R : ℕ) : DecidableEq (Fin R × Projectivization K V) := Classical.decEq _ +local instance flat_JoinedPlanarPublic_2 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedPlanarPublic_3 : Fintype (Projectivization K (Module.Dual K V)) := Fintype.ofFinite _ +local instance flat_JoinedPlanarPublic_4 : Fintype (Projectivization K V) := by + letI : Finite V := Module.finite_of_finite K + exact Fintype.ofFinite _ + +def Input (U : Finset (Projectivization K V)) (N : ℕ) (b τ : ℝ) + (S : Finset (Projectivization K V)) : Prop := + S⊆U ∧ S.card=N ∧ ∃ T : Finset (Projectivization K (Module.Dual K V)), + T.Nonempty ∧ S.card≤T.card ∧ + (Nat.card K:ℝ)^3*exp (-b)≤(S.card:ℝ)*T.card ∧ + (Incidence.incidenceCount S T:ℝ)≤τ*(S.card:ℝ)*T.card/Nat.card K + +lemma input_card (U : Finset (Projectivization K V)) (N : ℕ) (b τ : ℝ) : + (Fintype.card {S // Input U N b τ S}:ℝ)≤ + exp ((Fintype.card (Projectivization K V):ℝ)*log 2) := by + have hh := Fintype.card_subtype_le (Input U N b τ) + rw [Fintype.card_finset] at hh + rw [exp_nat_mul,exp_log (by norm_num : (0:ℝ)<2)] + exact_mod_cast hh + +lemma input_probability (hdim : Module.finrank K V=3) + (U : Finset (Projectivization K V)) (N : ℕ) (hN0 : 0 ∅) [] L ((N:ℝ)/2) (N*exp (6*P)))) := by + obtain ⟨hSU,hSN,T,hT,hST,hpr,hsp⟩ := hS + have hSn : S.Nonempty := card_pos.mp (by omega) + have hh := short_proposal hdim S U T hSn hT hSU hST σ P b τ L c R p h M hqexp + (by simpa only [hSN] using hc) hbud hb hτ hτsmall hpr hsp + (by simpa only [hSN] using hN) hloss herror hM + simpa only [hSN] using hh + +def decode (U : Finset (Projectivization K V)) (N : ℕ) (L : ℝ) + {R M : ℕ} (ω : (Fin R×Projectivization K V)→Fin (M+2)) + (z : Fin (Fintype.card (Projectivization K (Module.Dual K V))+1)) : + Finset (Projectivization K V) := + U∩PreparedDecoder.decode (fun _ : Unit => ∅) [] N z pencil inc L (Nat.card K) + (fun x => (ω x:ℕ)) + +lemma input_decode (U : Finset (Projectivization K V)) (N : ℕ) (L P b τ : ℝ) + {R M : ℕ} (S : Finset (Projectivization K V)) (hS : Input U N b τ S) + (ω : (Fin R×Projectivization K V)→Fin (M+2)) + (hω : PreparedProposals.accepts (coordinateSupport S R) M + (PreparedDescription.good S (fun _ : Unit => ∅) [] L ((N:ℝ)/2) (N*exp (6*P))) ω) : + ∃ z,(N:ℝ)/2≤(S∩decode U N L ω z).card ∧ + ((decode U N L ω z).card:ℝ)≤N*exp (6*P) := by + obtain ⟨z,hz,hcap,hsize⟩ := hω.2.2 + rw [hS.2.1] at hcap hsize + refine ⟨⟨z,by omega⟩,?_,?_⟩ + · have he : S∩decode U N L ω ⟨z,by omega⟩= + S∩PreparedDecoder.decode (fun _ : Unit => ∅) [] N z pencil inc L (Nat.card K) (fun x => (ω x:ℕ)) := by + ext x + simp only [decode,mem_inter] + exact ⟨fun hh => ⟨hh.1,hh.2.2⟩,fun hh => ⟨hh.1,hS.1 hh.1,hh.2⟩⟩ + rw [he] + exact hcap + · exact (show ((decode U N L ω ⟨z,by omega⟩).card:ℝ)≤ + (PreparedDecoder.decode (fun _ : Unit => ∅) [] N z pencil inc L (Nat.card K) (fun x => (ω x:ℕ))).card + by exact_mod_cast card_le_card inter_subset_right).trans hsize + +end +end SharpLogRamsey.PlanarLearning + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Planar/PlanarRow.lean b/lean/OAI/Combinatorics/SharpRamsey/Planar/PlanarRow.lean new file mode 100644 index 0000000000000000000000000000000000000000..c74b5efa28ddfc30409f2c6e732d296d4fca5276 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Planar/PlanarRow.lean @@ -0,0 +1,94 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Planar.PlanarTraining + +namespace OAI + +section +namespace SharpLogRamsey.PlanarLearning +open Finset Real PreparedRow PreparedGeometry PreparedTypical GreedyPreparation +open scoped Classical BigOperators NNReal +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedPlanarRow_1 (R : ℕ) : DecidableEq (Fin R × Projectivization K V) := Classical.decEq _ +local instance flat_JoinedPlanarRow_2 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedPlanarRow_3 : Fintype (Projectivization K (Module.Dual K V)) := Fintype.ofFinite _ +local instance flat_JoinedPlanarRow_4 : Fintype (Projectivization K V) := by + letI : Finite V := Module.finite_of_finite K + exact Fintype.ofFinite _ + +theorem short_proposal (hdim : Module.finrank K V=3) + (S U : Finset (Projectivization K V)) (T : Finset (Projectivization K (Module.Dual K V))) + (hS : S.Nonempty) (hT : T.Nonempty) (hSU : S⊆U) (hST : S.card≤T.card) + (σ P b τ : ℝ) (L c : ℝ≥0) (R p h M : ℕ) + (hqexp : exp σ=(Nat.card K:ℝ)) (hc : (c:ℝ)=(Nat.card K:ℝ)/S.card) + (hbud : Budget σ P L R p h) (hb : 0≤b) (hτ : 0<τ) (hτsmall : τ≤1/20) + (hproduct : (Nat.card K:ℝ)^3*exp (-b)≤(S.card:ℝ)*T.card) + (hsparse : (Incidence.incidenceCount S T:ℝ)≤τ*(S.card:ℝ)*T.card/Nat.card K) + (hN : 100*(Nat.card K:ℝ)*P≤S.card) + (hloss : b+2*P*τ≤P/1000000) + (herror : 50000*exp (-(95/100:ℝ)*(L:ℝ))≤exp (-b-2*P*τ)/800) + (hM : 2*(Nat.card K:ℝ)*P≤M) : + ((S.card:ℝ)/(U.card:ℝ))^M*(exp (-2*P*τ)/4)≤ + PublicTables.acceptProb + (PreparedProposals.proposal (coordinateSupport U R) ((R:ℝ≥0)*S.card*(L*c)) M) + (PreparedProposals.accepts (coordinateSupport S R) M + (PreparedDescription.good S (fun _ : Unit => ∅) [] L ((S.card:ℝ)/2) (S.card*exp (6*P)))) := by + let q : ℝ := Nat.card K + let N : ℝ := S.card + let B : ℝ := q^2/N + let E := badHyperplanes S (fun _ : Unit => ∅) [] c + let E₀ := T.filter (fun H => mass S c H≤2*τ) + have hq : 0 ∅) [] x).card:ℝ)/(S.card:ℝ)))* + ((pencil x∩E).card:ℝ)≤(q*B*exp (-b-2*P*τ)/8)/(100*q) := by + intro x hx + have hc := (hpencils x hx).1 + simp only [own,card_empty,Nat.cast_zero,zero_div,sub_zero,mul_one] + exact plane_error hq hB.le L.coe_nonneg hc herror + have hmean : (R:ℝ)*S.card*(L*c:ℝ≥0)=q*P := by + push_cast + rw [hc,hbud.identity] + dsimp [q] + field_simp + have hQ : (10:ℝ)≤∑ i∈range 3,(Nat.card K:ℝ)^i := by + have hq3 : 3≤q := by + have hh := add_one_le_exp σ + rw [hqexp] at hh + linarith [hbud.sigma] + simp only [sum_range_succ,sum_range_zero,zero_add,pow_zero,pow_one] + nlinarith + have hout := PreparedDescription.short_proposal 0 R p h M (by omega) hdim S S U Ds Ds hS + Subset.rfl hSU Subset.rfl (fun _ : Unit => ∅) [] E E₀ hE₀ hE₀E c L hc hown + σ P B 400000 b (2*P*τ) (20804*q*B) (by linarith [hbud.sigma]) hqexp + hbud.large hbud.upper hbud.identity rfl hb (by positivity) hloss hbud.order + (by change (Ds.card:ℝ)≤N*exp (-P/200)+N/10000; linarith [mul_nonneg hNs.le (exp_pos (-P/200)).le]) + (by change (Ds.card:ℝ)≤2*N+N*exp (5*P); nlinarith [mul_nonneg hNs.le (exp_pos (5*P)).le]) + (by nlinarith [hbud.large]) (by norm_num) hbud.Llarge hbud.Rlarge hbud.p_pos hbud.p_even + (by simpa only [←hbud.identity] using hBbig) hQ hbud.sparseSchedules + (fun H hH => by simpa only [←hbud.identity,mul_comm,mul_left_comm,mul_assoc] using + sparse_training_exponent S c L R H τ (hsmallE H hH)) + (by positivity) le_rfl (by simpa only [mass,hc,inc] using hW) (by simpa only [neg_mul] using hZ) hErr + (∅ : Finset Unit) (fun _ => 0) (fun x hx => (hpencils x hx).2.1) (fun x hx => (hpencils x hx).2.2) + (by rw [hmean]; nlinarith only [hM]) + simp only [sized,neg_mul] at hout ⊢ + with_unfolding_all exact hout + +end +end SharpLogRamsey.PlanarLearning + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Planar/PlanarSourceCover.lean b/lean/OAI/Combinatorics/SharpRamsey/Planar/PlanarSourceCover.lean new file mode 100644 index 0000000000000000000000000000000000000000..c63a03cf86e51eaecbd818e6d70ba0993467a39e --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Planar/PlanarSourceCover.lean @@ -0,0 +1,81 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Parameters.PlanarScales +import OAI.Combinatorics.SharpRamsey.Planar.PlanarCover + +namespace OAI + +section +namespace SharpLogRamsey.PlanarLearning +open Finset Real Filter SourceScales +open scoped Classical BigOperators Topology NNReal +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedPlanarSourceCover_1 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedPlanarSourceCover_2 : Fintype (Projectivization K (Module.Dual K V)) := Fintype.ofFinite _ +local instance flat_JoinedPlanarSourceCover_3 : Fintype (Projectivization K V) := by + letI : Finite V := Module.finite_of_finite K + exact Fintype.ofFinite _ + +theorem source_cover {η : ℝ} (hη : 0<η) (C : ℝ) (hC : 1≤C) : + ∀ᶠ σ : ℝ in atTop, ∀ D R, Admissible σ η D R → + exp σ=(Nat.card K:ℝ) → Module.finrank K V=3 → + ∀ (U : Finset (Projectivization K V)) (n : ℕ) (b τ : ℝ), + 0 C*σ^(-100*beta η)) atTop (𝓝 0) := by + simpa using (tendsto_rpow_neg_atTop (by have := beta_pos hη; positivity : 0<100*beta η)).const_mul C + filter_upwards [eventually_budget hη, + eventually_training_loss hη C (1/1000000) (by linarith) (by norm_num), + eventually_exceptional_training hη C (by linarith), + ht.eventually (gt_mem_nhds (by norm_num : (0:ℝ)<1/20)), + eventually_ge_atTop (1:ℝ)] with σ hb hl he ht hσ + intro D R had hex hdim U n b τ hn hnu hnlarge hb0 hbu hτ hτu + obtain ⟨p,h,hbud⟩ := hb D R had + let P := scaleP σ η D R + let L := Real.toNNReal (scaleL σ η D) + let c := Real.toNNReal ((Nat.card K:ℝ)/n) + let M := ⌈2*(Nat.card K:ℝ)*P⌉₊ + have hL0 : 0≤ scaleL σ η D := (L_pos (by linarith) had).le + have hLL : (L:ℝ)=scaleL σ η D := coe_toNNReal _ hL0 + have hc : (c:ℝ)=(Nat.card K:ℝ)/n := coe_toNNReal _ (by positivity) + have hLP : scaleL σ η D≤P := by + have hR : (1:ℝ)≤R := by exact_mod_cast (show 1≤R by have := hbud.Rlarge; omega) + exact le_mul_of_one_le_right hL0 hR + have hloss : b+2*P*τ≤P/1000000 := by + have hh := hl D R had b τ hbu hτu + dsimp [P] + nlinarith + have herr : 50000*exp (-(95/100:ℝ)*(L:ℝ))≤exp (-b-2*P*τ)/800 := by + rw [hLL] + exact he D R had b τ hbu hτu + obtain ⟨messages,hsize,hcapture,hlen⟩ := public_cover hdim U n hn hnu σ P b τ L c R p h M + hex hc hbud hb0 hτ (hτu.trans ht.le) hnlarge hloss herr (Nat.le_ceil _) + refine ⟨messages.image (fun z => decode U n L z.1 z.2),?_,?_,?_⟩ + · intro W hW + obtain ⟨z,hz,rfl⟩ := mem_image.mp hW + exact ⟨inter_subset_left,hsize z hz⟩ + · intro S hS + obtain ⟨z,hz,hcap⟩ := hcapture S hS + exact ⟨_,mem_image.mpr ⟨z,hz,rfl⟩,hcap⟩ + · apply le_trans _ hlen + apply log_le_log (by positivity) + have hc := card_image_le (s:=messages) (f:=fun z => decode U n L z.1 z.2) + have hc' : (((messages.image (fun z => decode U n L z.1 z.2)).card):ℝ) ≤ messages.card := by + exact_mod_cast hc + linarith only [hc'] + +end +end SharpLogRamsey.PlanarLearning + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Planar/PlanarTraining.lean b/lean/OAI/Combinatorics/SharpRamsey/Planar/PlanarTraining.lean new file mode 100644 index 0000000000000000000000000000000000000000..4505d253ed78aca7353203b7db87c59c0f38030e --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Planar/PlanarTraining.lean @@ -0,0 +1,83 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Planar.PlanarGeometry + +namespace OAI + +section +namespace SharpLogRamsey.PlanarLearning +open Finset Real PreparedRow PreparedGeometry PreparedTypical GreedyPreparation +open scoped Classical BigOperators NNReal +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedPlanarTraining_1 (R : ℕ) : DecidableEq (Fin R × Projectivization K V) := Classical.decEq _ +local instance flat_JoinedPlanarTraining_2 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedPlanarTraining_3 : Fintype (Projectivization K (Module.Dual K V)) := Fintype.ofFinite _ +local instance flat_JoinedPlanarTraining_4 : Fintype (Projectivization K V) := by + letI : Finite V := Module.finite_of_finite K + exact Fintype.ofFinite _ + +theorem training (hdim : Module.finrank K V=3) + (S : Finset (Projectivization K V)) (T : Finset (Projectivization K (Module.Dual K V))) + (hS : S.Nonempty) (hT : T.Nonempty) (hST : S.card≤T.card) + (σ P τ : ℝ) (R p h : ℕ) (L c : ℝ≥0) + (hqexp : exp σ=(Nat.card K:ℝ)) (hc : (c:ℝ)=(Nat.card K:ℝ)/S.card) + (hbud : Budget σ P L R p h) (hτ : 0<τ) (hτsmall : τ≤1/20) + (hsparse : (Incidence.incidenceCount S T:ℝ)≤τ*(S.card:ℝ)*T.card/Nat.card K) + (hN : 100*(Nat.card K:ℝ)*P≤S.card) : + let E₀ := T.filter (fun H => mass S c H≤2*τ) + (Incidence.incidenceCount S T:ℝ)≤(S.card:ℝ)*T.card/(20*Nat.card K) ∧ + exp (3*P)≤(Nat.card K:ℝ)^2/S.card ∧ (c:ℝ)≤1/100 ∧ + E₀.Nonempty ∧ (T.card:ℝ)≤2*E₀.card ∧ + E₀⊆badHyperplanes S (fun _ : Unit => ∅) [] c ∧ + ∀ H∈E₀,mass S c H≤2*τ := by + let q : ℝ := Nat.card K + let N : ℝ := S.card + have hq : 0 ∅) [] c T hT τ hτ + (by linarith) htrain + exact ⟨hsp,hBbig,hcsmall,hE₀,by linarith only [hhalf],hE₀E,hsmallE⟩ + +lemma training_size {q N t z : ℝ} (hN : 0 C*σ^(-100*beta η)) atTop (𝓝 0) := by + simpa using (tendsto_rpow_neg_atTop (by have := beta_pos hη; positivity : 0<100*beta η)).const_mul C + filter_upwards [eventually_budget hη, + eventually_training_loss hη C (1/1000000) (by linarith) (by norm_num), + eventually_exceptional_training hη C (by linarith), + ht.eventually (gt_mem_nhds (by norm_num : (0:ℝ)<1/20)), + eventually_ge_atTop (1:ℝ)] with σ hb hl he ht hσ + intro K V _ _ _ _ _ D R had hex hdim U n b τ hn hnu hnlarge hb0 hbu hτ hτu + obtain ⟨p,h,hbud⟩ := hb D R had + let P := scaleP σ η D R + let L := Real.toNNReal (scaleL σ η D) + let c := Real.toNNReal ((Nat.card K:ℝ)/n) + let M := ⌈2*(Nat.card K:ℝ)*P⌉₊ + have hL0 : 0≤ scaleL σ η D := (L_pos (by linarith) had).le + have hLL : (L:ℝ)=scaleL σ η D := coe_toNNReal _ hL0 + have hc : (c:ℝ)=(Nat.card K:ℝ)/n := coe_toNNReal _ (by positivity) + have hLP : scaleL σ η D≤P := by + have hR : (1:ℝ)≤R := by exact_mod_cast (show 1≤R by have := hbud.Rlarge; omega) + exact le_mul_of_one_le_right hL0 hR + have hloss : b+2*P*τ≤P/1000000 := by + have hh := hl D R had b τ hbu hτu + dsimp [P] + nlinarith + have herr : 50000*exp (-(95/100:ℝ)*(L:ℝ))≤exp (-b-2*P*τ)/800 := by + rw [hLL] + exact he D R had b τ hbu hτu + obtain ⟨messages,hsize,hcapture,hlen⟩ := public_cover hdim U n hn hnu σ P b τ L c R p h M + hex hc hbud hb0 hτ (hτu.trans ht.le) hnlarge hloss herr (Nat.le_ceil _) + refine ⟨messages.image (fun z => decode U n L z.1 z.2),?_,?_,?_⟩ + · intro W hW + obtain ⟨z,hz,rfl⟩ := mem_image.mp hW + exact ⟨inter_subset_left,hsize z hz⟩ + · intro S hS + obtain ⟨z,hz,hcap⟩ := hcapture S hS + exact ⟨_,mem_image.mpr ⟨z,hz,rfl⟩,hcap⟩ + · apply le_trans _ hlen + apply log_le_log (by positivity) + have hc := card_image_le (s:=messages) (f:=fun z => decode U n L z.1 z.2) + have hc' : (((messages.image (fun z => decode U n L z.1 z.2)).card):ℝ) ≤ messages.card := by + exact_mod_cast hc + linarith only [hc'] + +theorem full_source_cover_uniform {η : ℝ} (hη : 0<η) (C : ℝ) (hC : 1≤C) : + ∀ᶠ σ : ℝ in atTop,∀ (K V : Type) [Field K] [Finite K] + [AddCommGroup V] [Module K V] [FiniteDimensional K V],∀ D R,Admissible σ η D R → + exp σ=(Nat.card K:ℝ) → Module.finrank K V=3 → + ∀ (U : Finset (Projectivization K V)) (n : ℕ) (b τ : ℝ), + 0 C*σ^(-100*beta η)) atTop (𝓝 0) := by + simpa using (tendsto_rpow_neg_atTop (by have := beta_pos hη; positivity : 0<100*beta η)).const_mul C + filter_upwards [source_cover_uniform hη C hC, + eventually_uniform_L hη (eventually_ge_atTop (1:ℝ)), + eventually_uniform_R hη 1,ht.eventually (gt_mem_nhds (by norm_num : (0:ℝ)<1))] + with σ hcover hL hR ht + intro K V _ _ _ _ _ D R had hex hdim U n b τ hn hnu hb hbu hτ hτu + let P := scaleP σ η D R + let q : ℝ := Nat.card K + let d := log ((U.card:ℝ)/n) + have hP : 1≤P := one_le_mul_of_one_le_of_one_le (hL D R had) (hR D R had) + have hq : 1≤q := by + dsimp only [q] + exact_mod_cast (show 1≤Nat.card K from Nat.card_pos (α:=K)) + have hn' : (0:ℝ) 0) ∧ + HighPencil 2 R p h S O x c L A f B (∅ : Finset Unit) (fun _ => 0) := by + have hcover : ∀ H∈A,∀ J∈A,H≠J → 0 (htyp H hH).1),(fun H hH => (htyp H hH).2.1), + ?_,hsq.trans hsqs,hcards,?_,?_,?_,hdiag,hpow,?_,htwo⟩ + · intro H hH + exact (htyp H hH).2.2.trans (by norm_num) + · simp + · intro H hH J hJ hne hh + exact (hcover H hH J hJ hne hh).elim + · simp + · simpa using hsum + · refine ⟨(fun H hH => (htyp H hH).1),(fun H hH => (htyp H hH).2.1), + (fun H hH => (htyp H hH).2.2),hsq.trans hsqa,hcarda,?_,?_,?_,?_,?_,?_, + ?_,?_,hpb,hps,hh,hhs,hhe⟩ + · simpa using hdir + · simp + · intro H hH J hJ hne hh + exact (hcover H hH J hJ hne hh).elim + · simp + · simp + · intro H hH + have ha : (0:ℝ)<1/(100*(p:ℝ)) := by positivity + rw [plane_neighbors_empty hdim (S\(O∪{x})) x c _ ha A hA H hH] + simp only [card_empty,Nat.cast_zero] + positivity + · simpa using hcert + · simpa using hshift + +end +end SharpLogRamsey.PreparedGeometry + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/AuxiliaryCharges.lean b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/AuxiliaryCharges.lean new file mode 100644 index 0000000000000000000000000000000000000000..454593a2b64f1a31e11a54628fc0f3d8f82be6e4 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/AuxiliaryCharges.lean @@ -0,0 +1,133 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Selection.EndpointSupports + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset Real +open scoped Classical BigOperators NNReal +noncomputable section +variable {K V ι : Type*} [Field K] [AddCommGroup V] [Module K V] + [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype ι] [DecidableEq ι] + +omit [Finite K] [FiniteDimensional K V] in +lemma directedCollision_le_reciprocal + (p : Law (ι→Projectivization K (Module.Dual K V)×Projectivization K V)) + (ρ : ℝ) (r s : ℕ) (i j : ι) : + (directedCollision p Projectivization.rep Projectivization.rep ρ r s i j : ℝ) ≤ + (reciprocalCharges p Projectivization.rep Projectivization.rep ρ r s i j : ℝ) := by + unfold reciprocalCharges + exact_mod_cast (le_add_right (le_refl _) : + directedCollision p Projectivization.rep Projectivization.rep ρ r s i j ≤ _) + +theorem integer_good_event_le + (p : Law (ι→Projectivization K (Module.Dual K V)×Projectivization K V)) + (i j : ι) (MA MB κ ρ ε c a : ℝ) (d r : ℕ) + (hMA : 0 + goodFirst (p.marginal i) MA ((d:ℝ)*log (Nat.card K)) κ ε ay.1 ∧ + goodSecond (p.marginal j) MB ((d:ℝ)*log (Nat.card K)) κ ε ay.2 ∧ + ay.1.rep ay.2.rep=0)) ≤ 2*a/ρ^2 + 2*a/c^2 := by + apply (projective_integer_incidence p i j MA MB κ ρ ε c d r + hMA hMB hρ hc hcap hr hγ hκ hu hv hconsistent).trans + have hdir := directedCollision_le_reciprocal p ρ r (d+1-r) i j + have hn : (0:ℝ)≤(reciprocalCharges p Projectivization.rep Projectivization.rep + ρ r (d+1-r) i j:ℝ) := NNReal.coe_nonneg _ + apply add_le_add <;> apply div_le_div_of_nonneg_right _ (sq_nonneg _) + · linarith only [hcharge, hn] + · linarith only [hcharge, hdir] + +theorem open_good_event_le + (p : Law (ι→Projectivization K (Module.Dual K V)×Projectivization K V)) + (i j : ι) (MA MB κ ρ ε a : ℝ) (d r : ℕ) + (hMA : 0 + goodFirst (p.marginal i) MA ((d:ℝ)*log (Nat.card K)) κ ε ay.1 ∧ + goodSecond (p.marginal j) MB ((d:ℝ)*log (Nat.card K)) κ ε ay.2 ∧ + ay.1.rep ay.2.rep=0)) ≤ 2*a/ρ^2 := by + let p₂ := p.map (fun x => (x i,x j)) + have hi : p₂.fst=p.marginal i := by + exact (Law.map_fst p₂).symm.trans (p.map_map (fun x => (x i,x j)) Prod.fst) + have hj : p₂.snd=p.marginal j := by + exact (Law.map_snd p₂).symm.trans (p.map_map (fun x => (x i,x j)) Prod.snd) + have hcon : ∀ z,p₂.mass z≠0 → + z.1.1.rep z.2.2.rep=0 → z.2.1.rep z.1.2.rep=0 := by + intro z hz + obtain ⟨x,hx,rfl⟩ := p.map_support (fun x => (x i,x j)) z hz + exact hconsistent x hx + have h := projective_open_incidence p₂ MA MB κ ρ ε d r hMA hMB hρ + hd hr hγ hκ hu hv hcon + rw [hi,hj] at h + apply h.trans + exact div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left hinfo (by norm_num)) + (sq_nonneg ρ) + +omit [Finite K] [FiniteDimensional K V] in +theorem auxiliary_three_estimates + (p : Law (ι→Projectivization K (Module.Dual K V)×Projectivization K V)) + (i j : ι) (MA MB L κ ε z : ℝ) + (A : AuxiliarySupport (p.marginal i).fst + (univ.filter (goodFirst (p.marginal i) MA L κ ε)) MA κ) + (B : AuxiliarySupport (p.marginal j).snd + (univ.filter (goodSecond (p.marginal j) MB L κ ε)) MB κ) + (hz : ((p.marginal i).fst.prod (p.marginal j).snd).event + (univ.filter (fun ay => goodFirst (p.marginal i) MA L κ ε ay.1 ∧ + goodSecond (p.marginal j) MB L κ ε ay.2 ∧ ay.1.rep ay.2.rep=0)) ≤ z) : + let SA := fun b => levelSet (p.marginal i).fst b ∩ + univ.filter (goodFirst (p.marginal i) MA L κ ε) + let SB := fun b => levelSet (p.marginal j).snd b ∩ + univ.filter (goodSecond (p.marginal j) MB L κ ε) + (∑ a, ∑ b, A.law.mass a * B.law.mass b * + ((((SA a ×ˢ SB b).filter (fun ay => ay.1.rep ay.2.rep=0)).card:ℝ) / + ((SA a).card * (SB b).card))) ≤ (4*exp 1)^2*z ∧ + (∑ a, A.law.mass a * SupportMixtures.pairing (SupportMixtures.kernel (SA a)) + (fun y => if goodSecond (p.marginal j) MB L κ ε y then (p.marginal j).snd.mass y else 0) + (fun x y => if x.rep y.rep=0 then 1 else 0)) ≤ (4*exp 1)*z ∧ + (∑ b, B.law.mass b * SupportMixtures.pairing + (fun x => if goodFirst (p.marginal i) MA L κ ε x then (p.marginal i).fst.mass x else 0) + (SupportMixtures.kernel (SB b)) + (fun x y => if x.rep y.rep=0 then 1 else 0)) ≤ (4*exp 1)*z := by + dsimp only + have h₂ := actual_auxiliary_incidence (p.marginal i).fst (p.marginal j).snd + (univ.filter (goodFirst (p.marginal i) MA L κ ε)) + (univ.filter (goodSecond (p.marginal j) MB L κ ε)) MA MB κ + A.law B.law A.density B.density (fun x y => x.rep y.rep=0) + have h₁A := actual_auxiliary_target_left (p.marginal i).fst (p.marginal j).snd + (univ.filter (goodFirst (p.marginal i) MA L κ ε)) + (univ.filter (goodSecond (p.marginal j) MB L κ ε)) MA κ + A.law A.density (fun x y => x.rep y.rep=0) + have h₁B := actual_auxiliary_target_right (p.marginal i).fst (p.marginal j).snd + (univ.filter (goodFirst (p.marginal i) MA L κ ε)) + (univ.filter (goodSecond (p.marginal j) MB L κ ε)) MB κ + B.law B.density (fun x y => x.rep y.rep=0) + simp only [mem_filter, mem_univ, true_and] at h₂ h₁A h₁B + exact ⟨h₂.trans (mul_le_mul_of_nonneg_left hz (sq_nonneg _)), + h₁A.trans (mul_le_mul_of_nonneg_left hz (by positivity)), + h₁B.trans (mul_le_mul_of_nonneg_left hz (by positivity))⟩ + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/AuxiliaryFamilies.lean b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/AuxiliaryFamilies.lean new file mode 100644 index 0000000000000000000000000000000000000000..dd074afb39e65865b8bcafce78757a1b4f946398 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/AuxiliaryFamilies.lean @@ -0,0 +1,126 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Reciprocal.CanonicalAuxiliaryLaw + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset Real SupportMixtures +open scoped Classical BigOperators +noncomputable section +variable {A B I J Ω Θ : Type*} [Fintype A] [Fintype B] [Fintype I] [Fintype J] + [Fintype Ω] [Fintype Θ] + +lemma Law.pi_coordinate_sum (p : I → Law A) (i : I) (f : A → ℝ) : + (∑ z, (Law.pi p).mass z * f (z i)) = ∑ a, (p i).mass a * f a := by + let ρ := Law.pi (fun j : {j : I // j ≠ i} => p j) + have hm (z : I → A) : (Law.pi p).mass z = (p i).mass (z i) * + ρ.mass (fun j => z j) := by + change (∏ j, (p j).mass (z j)) = (p i).mass (z i) * + (∏ j : {j : I // j ≠ i}, (p j).mass (z j)) + have he : (∏ j ∈ (univ : Finset I).erase i, (p j).mass (z j)) = + ∏ j : {j : I // j ≠ i}, (p j).mass (z j) := + prod_subtype _ (by simp) _ + rw [← he] + exact (mul_prod_erase univ (fun j => (p j).mass (z j)) (mem_univ i)).symm + calc + _ = ∑ z, (p i).mass (z i) * ρ.mass (fun j => z j) * f (z i) := by + simp_rw [hm] + _ = ∑ z : A × ({j : I // j ≠ i} → A), (p i).mass z.1 * ρ.mass z.2 * f z.1 := + Fintype.sum_equiv (Equiv.piSplitAt i (fun _ : I => A)) _ _ (fun _ => rfl) + _ = _ := by + rw [Fintype.sum_prod_type] + apply sum_congr rfl + intro a _ + simp only [← sum_mul, ← mul_sum, ρ.total, mul_one] + +lemma Law.independent_coordinates_sum (p : I → Law A) (q : J → Law B) + (i : I) (j : J) (f : A → B → ℝ) : + (∑ z, ((Law.pi p).prod (Law.pi q)).mass z * f (z.1 i) (z.2 j)) = + ∑ a, ∑ b, (p i).mass a * (q j).mass b * f a b := by + change (∑ z : (I → A) × (J → B), (Law.pi p).mass z.1 * (Law.pi q).mass z.2 * f (z.1 i) (z.2 j)) = _ + rw [Fintype.sum_prod_type] + simp only [mul_assoc, ← mul_sum] + simp_rw [Law.pi_coordinate_sum q j] + exact Law.pi_coordinate_sum p i (fun a => ∑ b, (q j).mass b * f a b) + +namespace AuxiliarySupport +variable {p : I → Law A} {q : J → Law B} {goodA : I → Finset A} + {goodB : J → Finset B} {MA κA : I → ℝ} {MB κB : J → ℝ} + +def familyLaw (X : ∀ i, AuxiliarySupport (p i) (goodA i) (MA i) (κA i)) + (Y : ∀ j, AuxiliarySupport (q j) (goodB j) (MB j) (κB j)) : + Law ((I → Finset A) × (J → Finset B)) := + (Law.pi (fun i => (X i).setLaw)).prod (Law.pi (fun j => (Y j).setLaw)) + +lemma familyLaw_support (X : ∀ i, AuxiliarySupport (p i) (goodA i) (MA i) (κA i)) + (Y : ∀ j, AuxiliarySupport (q j) (goodB j) (MB j) (κB j)) + (z : (I → Finset A) × (J → Finset B)) (hz : (familyLaw X Y).mass z ≠ 0) : + (∀ i, z.1 i ⊆ goodA i ∧ MA i * exp (-κA i) / 2 ≤ ((z.1 i).card : ℝ) ∧ + ((z.1 i).card : ℝ) ≤ MA i) ∧ + (∀ j, z.2 j ⊆ goodB j ∧ MB j * exp (-κB j) / 2 ≤ ((z.2 j).card : ℝ) ∧ + ((z.2 j).card : ℝ) ≤ MB j) := by + have hz' : (∏ i, (X i).setLaw.mass (z.1 i)) * + (∏ j, (Y j).setLaw.mass (z.2 j)) ≠ 0 := hz + constructor + · intro i + apply (X i).setLaw_support + exact (prod_ne_zero_iff.mp (mul_ne_zero_iff.mp hz').1) i (mem_univ _) + · intro j + apply (Y j).setLaw_support + exact (prod_ne_zero_iff.mp (mul_ne_zero_iff.mp hz').2) j (mem_univ _) + +theorem familyLaw_incidence + (X : ∀ i, AuxiliarySupport (p i) (goodA i) (MA i) (κA i)) + (Y : ∀ j, AuxiliarySupport (q j) (goodB j) (MB j) (κB j)) + (i : I) (j : J) (R : A → B → Prop) : + (∑ z, (familyLaw X Y).mass z * pairing (kernel (z.1 i)) (kernel (z.2 j)) + (fun a b => if R a b then 1 else 0)) ≤ + (4 * exp 1) * (4 * exp 1) * ((p i).prod (q j)).event + (univ.filter (fun z => z.1 ∈ goodA i ∧ z.2 ∈ goodB j ∧ R z.1 z.2)) := by + rw [familyLaw, Law.independent_coordinates_sum + (fun i => (X i).setLaw) (fun j => (Y j).setLaw) i j + (fun S T => pairing (kernel S) (kernel T) (fun a b => if R a b then 1 else 0))] + have h := independent_pairing_le (X i).setLaw.mass (Y j).setLaw.mass id id + (fun a b => if R a b then (1 : ℝ) else 0) + (fun a => if a ∈ goodA i then (p i).mass a else 0) + (fun b => if b ∈ goodB j then (q j).mass b else 0) + (4 * exp 1) (4 * exp 1) (X i).setLaw.nonneg (Y j).setLaw.nonneg + (by intros; split_ifs <;> norm_num) (X i).setLaw_density (Y j).setLaw_density + simpa only [id_eq, good_pairing_eq_event] using h + +end AuxiliarySupport + +lemma Law.history_observable_sum (μ : Law Ω) (θ : Ω → Θ) (F : Ω → B) + (f : Θ → B → ℝ) : + (∑ ω, μ.mass ω * f (θ ω) (F ω)) = + ∑ z, (μ.map θ).mass z * ∑ b, ((μ.cond θ z).map F).mass b * f z b := by + simp only [mul_sum, ← mul_assoc, Law.cond_map_weight] + have h := μ.sum_map (fun ω => (F ω, θ ω)) (fun z => f z.2 z.1) + rw [Fintype.sum_prod_type, sum_comm] at h + exact h.symm + +lemma Law.withKernel_observable_sum (μ : Law Ω) (θ : Ω → Θ) (ρ : Θ → Law A) + (F : Ω → B) (f : Θ → B → A → ℝ) : + (∑ x, (μ.withKernel θ ρ).mass x * f (θ x.1) (F x.1) x.2) = + ∑ z, (μ.map θ).mass z * ∑ a, (ρ z).mass a * + ∑ b, ((μ.cond θ z).map F).mass b * f z b a := by + rw [μ.withKernel_sum θ ρ (fun ω a => f (θ ω) (F ω) a)] + rw [μ.history_observable_sum θ F (fun z b => ∑ a, (ρ z).mass a * f z b a)] + apply sum_congr rfl + intro z _ + congr 1 + simp only [mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro a _ + apply sum_congr rfl + intro b _ + ring + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/AuxiliaryLevels.lean b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/AuxiliaryLevels.lean new file mode 100644 index 0000000000000000000000000000000000000000..25b1b8b9d7ad87ecb014eca49885f894a3990423 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/AuxiliaryLevels.lean @@ -0,0 +1,445 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Reciprocal.ReciprocalCharges + +namespace OAI + +section +open Finset +open scoped Classical BigOperators + +namespace SharpLogRamsey.Selection +variable {α β : Type*} [Fintype α] [Fintype β] + +theorem entropy_le_cross (p : Law α) (q : α → ℝ) (hq : ∀ a, 0 h a) + simp only [sum_sub_distrib, p.total] at HH + unfold entropy + linarith + +lemma geometric_subprob (l : α → ℕ) (hl : Function.Injective l) {r : ℝ} + (hr : 0 pow_nonneg hr.le _) + rw [sum_image (fun _ _ _ _ he => hl he), tsum_geometric_of_lt_one hr.le hr1] at hs + rw [← mul_sum] + have H := mul_le_mul_of_nonneg_left hs (sub_nonneg.mpr hr1.le) + simpa only [mul_inv_cancel₀ (sub_pos.mpr hr1).ne'] using H + +theorem integer_entropy (p : Law α) (l : α → ℕ) (hl : Function.Injective l) + (M : ℝ) (hM : 0 (1-r)*r^(l a)) + (fun a => mul_pos (sub_pos.mpr hr1) (pow_pos hr _)) + (geometric_subprob l hl hr hr1) + have he : -∑ a, p.mass a*Real.log ((1-r)*r^(l a)) = + Real.log (M+1) + (∑ a, p.mass a*(l a:ℝ))*Real.log (1+1/M) := by + have her : Real.log r = -Real.log (1+1/M) := by + have heq : r=(1+1/M)⁻¹ := by dsimp [r]; field_simp + rw [heq,Real.log_inv] + have hlogc : Real.log (1-r) = -Real.log (M+1) := by + rw [hc, Real.log_div one_ne_zero (by positivity : M+1≠0), Real.log_one, zero_sub] + simp_rw [Real.log_mul (sub_pos.mpr hr1).ne' (pow_pos hr _).ne', + Real.log_pow, hlogc,her] + simp only [mul_add, mul_neg, sum_add_distrib, sum_neg_distrib, + ← mul_assoc, ← sum_mul,p.total,one_mul] + ring + rw [he] at H + have hlog0 : 0≤Real.log (1+1/M) := Real.log_nonneg (by + have h : (0:ℝ)≤1/M := by positivity + linarith) + have hlog := Real.log_le_sub_one_of_pos (show 0<1+1/M by positivity) + have hh := mul_le_mul_of_nonneg_left hlog hM.le + have hx : M*(1+1/M-1)=1 := by field_simp; ring + rw [hx] at hh + have hm' := mul_le_mul_of_nonneg_right hm hlog0 + linarith + +noncomputable def massLevel (p : Law α) (a : α) : ℕ := ⌊-Real.log (p.mass a)⌋₊ + +lemma massLevel_mean (p : Law α) : + (∑ a, p.mass a*(massLevel p a:ℝ)) ≤ entropy p := by + unfold entropy + rw [←sum_neg_distrib] + apply sum_le_sum + intro a _ + by_cases hp : p.mass a=0 + · simp [hp] + have hlog : 0 ≤ -Real.log (p.mass a) := + neg_nonneg.mpr (Real.log_nonpos (p.nonneg a) (p.mass_le_one a)) + have H := mul_le_mul_of_nonneg_left (Nat.floor_le hlog) (p.nonneg a) + simpa only [massLevel, mul_neg] using H + +abbrev Levels (p : Law α) := {n // n ∈ (univ.image (massLevel p) : Finset ℕ)} + +noncomputable def levelIndex (p : Law α) (a : α) : Levels p := + ⟨massLevel p a, mem_image.mpr ⟨a, mem_univ _, rfl⟩⟩ + +lemma level_entropy (p : Law α) : + entropy (p.map (levelIndex p)) ≤ Real.log (entropy p+2)+1 := by + have hh := integer_entropy (p.map (levelIndex p)) Subtype.val Subtype.val_injective + (entropy p+1) (by linarith [entropy_nonneg p]) + have hm : ∑ n : Levels p, (p.map (levelIndex p)).mass n*(n.val:ℝ) ≤ entropy p+1 := by + rw [p.sum_map] + exact (massLevel_mean p).trans (by linarith) + simpa only [show entropy p+1+1=entropy p+2 by ring] using hh hm + +lemma same_level_weight (p : Law α) {a b : α} (ha : 0 p.mass a*f a) + +theorem support_average (p : Law α) (l : α→β) (G : β→Finset α) + (R : Finset β) (hR : (1:ℝ)/2 ≤ (p.map l).event R) + (hG : ∀ b∈R, 0<(G b).card) + (hfiber : ∀ b∈R, ∀ a∈G b, l a=b) + (hcharge : ∀ b∈R, ∀ a∈G b, + (p.map l).mass b ≤ Real.exp 1*2*(G b).card*p.mass a) (a : α) : + ∑ b : R, ((p.map l).onEvent R (by linarith)).mass b * + (if a∈G b then 1/((G b).card:ℝ) else 0) ≤ 4*Real.exp 1*p.mass a := by + have hp := p.nonneg a + have hR0 : 0<(p.map l).event R := by linarith + have he := (p.map l).onEvent_mean R hR0 + (fun b => if a∈G b then 1/((G b).card:ℝ) else 0) + rw [he] + have hsum : (∑ b∈R, (p.map l).mass b*(if a∈G b then 1/((G b).card:ℝ) else 0)) ≤ + 2*Real.exp 1*p.mass a := by + by_cases ha : l a∈R + · rw [sum_eq_single_of_mem (l a) ha] + · by_cases hg : a∈G (l a) + · simp only [ite_eq_left hg,one_div] + have H := hcharge (l a) ha a hg + have hc : (0:ℝ)<(G (l a)).card := by exact_mod_cast hG (l a) ha + have H' : (p.map l).mass (l a)/((G (l a)).card:ℝ) ≤ + 2*Real.exp 1*p.mass a := (div_le_iff₀ hc).mpr (by nlinarith [H]) + simpa only [div_eq_mul_inv] using H' + · simp only [ite_eq_right hg,mul_zero] + positivity + · intro b hb hba + have hab : a∉G b := by intro hh; exact hba (hfiber b hb a hh).symm + simp [hab] + · have hz : ∀ b∈R, a∉G b := by + intro b hb hh + exact ha ((hfiber b hb a hh) ▸ hb) + have : (∑ b∈R, (p.map l).mass b*(if a∈G b then 1/((G b).card:ℝ) else 0))=0 := by + apply sum_eq_zero + intro b hb + simp [hz b hb] + rw [this] + positivity + apply (div_le_iff₀ hR0).mpr + calc + _ ≤ 2*Real.exp 1*p.mass a := hsum + _ = (4*Real.exp 1*p.mass a)*(1/2) := by ring + _ ≤ _ := mul_le_mul_of_nonneg_left hR (by positivity) + +theorem partition_entropy (p : Law α) (l : α→β) (S : Finset α) + (hs : ∀ a, a∉S → p.mass a=0) : + entropy p ≤ entropy (p.map l)+ + ∑ b, (p.map l).mass b*Real.log (S.filter (fun a => l a=b)).card := by + let T (b : β) := S.filter (fun a => l a=b) + have hm (b : β) : ∑ a∈T b, p.mass a=(p.map l).mass b := by + apply sum_subset (by + intro a ha + exact mem_filter.mpr ⟨mem_univ _,(mem_filter.mp ha).2⟩) + intro a ha hna + apply hs + intro haS + apply hna + exact mem_filter.mpr ⟨haS,(mem_filter.mp ha).2⟩ + have hlog (b : β) : + (p.map l).mass b*Real.log ((p.map l).mass b)- + (p.map l).mass b*Real.log (T b).card ≤ ∑ a∈T b, p.mass a*Real.log (p.mass a) := by + have H := log_sum (T b) p.mass (fun _ => 1) (fun a _ => p.nonneg a) + (by intros; norm_num) (by intro i hi hf; norm_num at hf) + simp only [div_one,sum_const,nsmul_eq_mul,mul_one,hm] at H + by_cases hb : (p.map l).mass b=0 + · simpa [hb] using H + have hc : (T b).card≠0 := by + intro he + have hz : T b=∅ := card_eq_zero.mp he + exact hb (by simpa [hz] using (hm b).symm) + rw [Real.log_div hb (by exact_mod_cast hc),mul_sub] at H + exact H + have H := sum_le_sum (fun b (_ : b∈univ) => hlog b) + have he : (∑ b, ∑ a∈T b, p.mass a*Real.log (p.mass a))= + ∑ a, p.mass a*Real.log (p.mass a) := by + rw [show (∑ b, ∑ a∈T b, p.mass a*Real.log (p.mass a))= + ∑ a∈S, p.mass a*Real.log (p.mass a) from sum_fiberwise S l _] + exact sum_subset (subset_univ S) (fun a _ hna => by rw [hs a hna,zero_mul]) + rw [sum_sub_distrib,he] at H + unfold entropy + dsimp only [T] at H + linarith + +theorem partition_loss (p : Law α) (l : α→β) (S : Finset α) + (hs : ∀ a, a∉S → p.mass a=0) (loss : β→ℝ) (J : ℝ) + (hc : ∀ b, 0<(p.map l).mass b → + Real.log (S.filter (fun a => l a=b)).card ≤ J-loss b/2) : + ∑ b, (p.map l).mass b*loss b ≤ 2*(J-entropy p+entropy (p.map l)) := by + have hh (b : β) : (p.map l).mass b*Real.log (S.filter (fun a => l a=b)).card ≤ + (p.map l).mass b*(J-loss b/2) := by + by_cases hz : (p.map l).mass b=0 + · simp [hz] + · exact mul_le_mul_of_nonneg_left (hc b (lt_of_le_of_ne ((p.map l).nonneg b) (Ne.symm hz))) + ((p.map l).nonneg b) + have H := (partition_entropy p l S hs).trans (add_le_add_right (sum_le_sum (fun b _ => hh b)) _) + simp only [mul_sub,←mul_div_assoc,sum_sub_distrib,←sum_mul,←sum_div,(p.map l).total,one_mul] at H + linarith + +noncomputable def levelSet (p : Law α) (b : Levels p) : Finset α := + univ.filter (fun a => 0 hrow a ha) + simp only [sum_const,nsmul_eq_mul,←mul_sum] at H + have hm := (p.map (levelIndex p)).nonneg b + have Hc : (S.card:ℝ) ≤ 2*(B.card:ℝ) := by exact_mod_cast hc + have Hm := mul_le_mul_of_nonneg_right Hc hm + have H₂ : (S.card:ℝ)*(p.map (levelIndex p)).mass b ≤ + (S.card:ℝ)*(2*Real.exp 1*(∑ a∈B,p.mass a)) := by nlinarith + exact (mul_le_mul_iff_right₀ (show (0:ℝ) (f z.1,g z.2))).fst=p.fst.map f ∧ + (p.map (fun z => (f z.1,g z.2))).snd=p.snd.map g := by + constructor + · rw [←Law.map_fst,Law.map_comp,←Law.map_fst,Law.map_comp] + rfl + · rw [←Law.map_snd,Law.map_comp,←Law.map_snd,Law.map_comp] + rfl + +lemma endpoint_levels_entropy (p : Law (α×β)) : + entropy (p.map (fun z => (levelIndex p.fst z.1,levelIndex p.snd z.2))) ≤ + Real.log (entropy p.fst+2)+Real.log (entropy p.snd+2)+2 := by + have H := entropy_subadditive (p.map (fun z => (levelIndex p.fst z.1,levelIndex p.snd z.2))) + have hm := p.map_prod_marginals (levelIndex p.fst) (levelIndex p.snd) + rw [hm.1,hm.2] at H + linarith [level_entropy p.fst,level_entropy p.snd] + +noncomputable def levelLoss (p : Law α) (A : ℝ) (b : Levels p) : ℝ := + Real.log (A/(levelSet p b).card) + +lemma levelLoss_nonneg (p : Law α) {A : ℝ} (b : Levels p) + (hcap : ((levelSet p b).card:ℝ) ≤ A) : 0≤levelLoss p A b := by + unfold levelLoss + by_cases hz : (levelSet p b).card=0 + · simp [hz] + · have hc : (0:ℝ)<(levelSet p b).card := by exact_mod_cast (Nat.pos_of_ne_zero hz) + exact Real.log_nonneg ((le_div_iff₀ hc).mpr (by simpa using hcap)) + +lemma levelLoss_size (p : Law α) {A K : ℝ} (hA : 0 0 a∉good) := by ext; simp + change (∑ b : Levels p, ∑ a∈levelSet p b\good,p.mass a)=∑ a∈univ\good,p.mass a + simp_rw [he,he',sum_filter] + rw [sum_comm] + apply sum_congr rfl + intro a _ + by_cases ha : 0 simp [ha,hg] + · have hz := le_antisymm (le_of_not_gt ha) (p.nonneg a) + simp [hz] + +noncomputable def retainedLevels (p : Law α) (good : Finset α) (A K : ℝ) : Finset (Levels p) := + univ.filter (fun b => 0<(levelSet p b).card ∧ levelLoss p A b≤K ∧ + (levelSet p b).card ≤ 2*((levelSet p b)∩good).card) + +lemma retained_mass (p : Law α) (good : Finset α) {A K : ℝ} (hK : 0 p.nonneg a) + by_cases hb : b∈R + · rw [ite_eq_left hb] + have hh : 0≤q.mass b*levelLoss p A b/K := by positivity + have hh' : 0≤2*Real.exp 1*(∑ a∈levelSet p b\good,p.mass a) := by positivity + linarith + rw [ite_eq_right hb,zero_add] + by_cases hc : (levelSet p b).card=0 + · have h0 : q.mass b=0 := by + rw [show q.mass b=(∑ a∈levelSet p b,p.mass a) from (levelSet_mass p b).symm] + simp [card_eq_zero.mp hc] + simp only [h0,zero_mul,zero_div,zero_add] + positivity + by_cases hlow : levelLoss p A b≤K + · have hf : 2*((levelSet p b)∩good).card < (levelSet p b).card := by + by_contra! hn + apply hb + exact mem_filter.mpr ⟨mem_univ _,Nat.pos_of_ne_zero hc,hlow,hn⟩ + have H := bad_level_charge p b good hf + have hh : 0≤q.mass b*levelLoss p A b/K := by positivity + exact H.trans (by linarith) + · have H : q.mass b ≤ q.mass b*levelLoss p A b/K := by + apply (le_div_iff₀ hK).mpr + exact mul_le_mul_of_nonneg_left (le_of_not_ge hlow) hm + have hh : 0≤2*Real.exp 1*(∑ a∈levelSet p b\good,p.mass a) := by positivity + linarith + have H := sum_le_sum (fun b (_ : b∈univ) => hpoint b) + simp only [sum_add_distrib,←sum_div,←mul_sum,q.total,←sum_filter] at H + rw [level_bad_total p good] at H + have heR : univ.filter (fun b => b∈R)=R := by ext; simp + rw [heR] at H + change 1≤q.event R+(∑ b,q.mass b*levelLoss p A b)/K+2*Real.exp 1*p.event (univ\good) at H + change 1-_/_-_≤q.event R + linarith + +theorem auxiliary_supports (p : Law α) (good : Finset α) {A K : ℝ} + (hA : 0 levelSet p b∩good) R hR + · intro b hb + have hh := (mem_filter.mp hb).2 + have hp := hh.1 + have hs := hh.2.2 + omega + · intro b hb a ha + exact (mem_filter.mp (mem_inter.mp ha).1).2.2 + · intro b hb a ha + exact good_level_charge p b good ((mem_filter.mp hb).2.2.2) ha + +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/CanonicalAuxiliaryLaw.lean b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/CanonicalAuxiliaryLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..f423612194a295790de4f4cc285707b338d58932 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/CanonicalAuxiliaryLaw.lean @@ -0,0 +1,97 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Selection.EndpointSupports + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset Real SupportMixtures +open scoped Classical BigOperators +noncomputable section +variable {A B Ω Θ : Type*} [Fintype A] [Fintype B] [Fintype Ω] [Fintype Θ] + +namespace AuxiliarySupport +variable {p : Law A} {good : Finset A} {M κ : ℝ} + +def setLaw (X : AuxiliarySupport p good M κ) : Law (Finset A) := + X.law.map (fun b => levelSet p b ∩ good) + +lemma setLaw_support (X : AuxiliarySupport p good M κ) (S : Finset A) + (hS : X.setLaw.mass S ≠ 0) : + S ⊆ good ∧ M * exp (-κ) / 2 ≤ (S.card : ℝ) ∧ (S.card : ℝ) ≤ M := by + obtain ⟨b,hb,rfl⟩ := X.law.map_support (fun b => levelSet p b ∩ good) S hS + exact ⟨inter_subset_right, X.size b⟩ + +lemma setLaw_sum (X : AuxiliarySupport p good M κ) (f : Finset A → ℝ) : + (∑ S, X.setLaw.mass S * f S) = + ∑ b, X.law.mass b * f (levelSet p b ∩ good) := + X.law.sum_map _ f + +lemma setLaw_density (X : AuxiliarySupport p good M κ) (a : A) : + (∑ S, X.setLaw.mass S * kernel S a) ≤ + 4 * exp 1 * (if a ∈ good then p.mass a else 0) := by + rw [X.setLaw_sum] + by_cases ha : a ∈ good + · simpa only [ite_eq_left ha, kernel] using X.density a + · simp only [kernel, mem_inter, ha, and_false, ite_false, mul_zero, sum_const_zero, + le_refl] + +lemma setLaw_nonempty (X : AuxiliarySupport p good M κ) (hM : 0 < M) + (S : Finset A) (hS : X.setLaw.mass S ≠ 0) : S.Nonempty := by + have hh := (X.setLaw_support S hS).2.1 + apply card_pos.mp + have : (0 : ℝ) < S.card := lt_of_lt_of_le (by positivity) hh + exact_mod_cast this + +end AuxiliarySupport + +def Law.withKernel (μ : Law Ω) (θ : Ω → Θ) (ρ : Θ → Law A) : Law (Ω × A) where + mass x := μ.mass x.1 * (ρ (θ x.1)).mass x.2 + nonneg x := mul_nonneg (μ.nonneg x.1) ((ρ (θ x.1)).nonneg x.2) + total := by + rw [Fintype.sum_prod_type] + simp only [← mul_sum, Law.total, mul_one] + +omit [Fintype Θ] in +@[simp] lemma Law.withKernel_mass (μ : Law Ω) (θ : Ω → Θ) (ρ : Θ → Law A) + (ω : Ω) (a : A) : (μ.withKernel θ ρ).mass (ω,a) = + μ.mass ω * (ρ (θ ω)).mass a := rfl + +omit [Fintype Θ] in +lemma Law.withKernel_fst (μ : Law Ω) (θ : Ω → Θ) (ρ : Θ → Law A) : + (μ.withKernel θ ρ).fst = μ := by + ext ω + simp only [Law.fst, Law.withKernel_mass, ← mul_sum, Law.total, mul_one] + +omit [Fintype Θ] in +lemma Law.withKernel_sum (μ : Law Ω) (θ : Ω → Θ) (ρ : Θ → Law A) + (f : Ω → A → ℝ) : + (∑ x, (μ.withKernel θ ρ).mass x * f x.1 x.2) = + ∑ ω, μ.mass ω * ∑ a, (ρ (θ ω)).mass a * f ω a := by + simp only [Fintype.sum_prod_type, Law.withKernel_mass, mul_sum, mul_assoc] + +lemma Law.withKernel_history_sum (μ : Law Ω) (θ : Ω → Θ) (ρ : Θ → Law A) + (f : Θ → A → ℝ) : + (∑ x, (μ.withKernel θ ρ).mass x * f (θ x.1) x.2) = + ∑ z, (μ.map θ).mass z * ∑ a, (ρ z).mass a * f z a := by + exact (μ.withKernel_sum θ ρ (fun ω a => f (θ ω) a)).trans + (μ.sum_map θ (fun z => ∑ a, (ρ z).mass a * f z a)).symm + +lemma Law.withKernel_bound (μ : Law Ω) (θ : Ω → Θ) (ρ : Θ → Law A) + (f : Ω → A → ℝ) (g : Θ → ℝ) + (h : ∀ ω, μ.mass ω ≠ 0 → (∑ a, (ρ (θ ω)).mass a * f ω a) ≤ g (θ ω)) : + (∑ x, (μ.withKernel θ ρ).mass x * f x.1 x.2) ≤ + ∑ z, (μ.map θ).mass z * g z := by + rw [μ.withKernel_sum, μ.sum_map] + apply sum_le_sum + intro ω _ + by_cases hω : μ.mass ω = 0 + · simp only [hω, zero_mul, le_refl] + · exact mul_le_mul_of_nonneg_left (h ω hω) (μ.nonneg ω) + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/CoreDimensions.lean b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/CoreDimensions.lean new file mode 100644 index 0000000000000000000000000000000000000000..577022475052678945f66bc763d4085a7009c9eb --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/CoreDimensions.lean @@ -0,0 +1,129 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Selection.EndpointCurrent + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open scoped BigOperators Classical +open Finset +noncomputable section +variable {α : Type*} [Fintype α] + +lemma Law.event_sdiff_lower (p : Law α) (S T : Finset α) : + p.event S-p.event T ≤ p.event (S\T) := by + have hsubset : S ⊆ (S \ T) ∪ T := by + intro atom hmem + by_cases hremoved : atom ∈ T + · exact mem_union_right _ hremoved + · exact mem_union_left _ (mem_sdiff.mpr ⟨hmem, hremoved⟩) + exact sub_le_iff_le_add.mpr ((p.event_mono hsubset).trans (p.event_union_le _ _)) + +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] +variable [Finite K] [FiniteDimensional K V] [Fintype (Projectivization K V)] + +omit [Finite K] in + +lemma Law.core_nonheavy_mass (p : Law (Projectivization K V)) + {ρ ε : ℝ} (hρ : 0 ≤ ρ) (bad : Finset (Projectivization K V)) + (hbad : p.event bad ≤ ε) : + 1-(Module.finrank K V:ℝ)*ρ-ε ≤ + p.event ((univ.filter (fun b => b.rep ∈ p.core (K := K) Projectivization.rep ρ))\bad) := by + have h := p.core_capture (K := K) Projectivization.rep hρ + have hh := p.event_sdiff_lower (univ.filter (fun b => b.rep ∈ p.core (K := K) Projectivization.rep ρ)) bad + linarith + +omit [FiniteDimensional K V] in + +theorem Law.subspace_log_dimension (p : Law (Projectivization K V)) + (W : Submodule K V) (E : Finset (Projectivization K V)) {A κ γ : ℝ} + (hA : 0 < A) (hγ : 0 < γ) (hκ : Real.log (2/γ) ≤ κ) (d : ℕ) + (hmass : γ ≤ p.event E) (hE : ∀ a ∈ E, a.submodule ≤ W) + (hcap : ∀ a ∈ E, p.mass a ≤ A*Real.exp (2*κ)/(Nat.card K:ℝ)^d) : + (d:ℝ)+1-(Real.log A+3*κ)/Real.log (Nat.card K) ≤ Module.finrank K W := by + have hq : (1:ℝ) < Nat.card K := by exact_mod_cast Finite.one_lt_card (α := K) + have hq0 := lt_trans zero_lt_one hq + have hc : 0 < A*Real.exp (2*κ)/(Nat.card K:ℝ)^d := by positivity + have h := p.subspace_mass_le_pow W E hc.le hγ hmass hE hcap + have hr := p.subspace_rank_pos W E hc.le hγ hmass hE hcap + have hl := Real.log_le_log hγ h + rw [Real.log_mul (mul_pos (by norm_num) hc).ne' (pow_ne_zero _ hq0.ne'), + Real.log_mul (by norm_num) hc.ne', Real.log_div (by positivity) (pow_ne_zero _ hq0.ne'), + Real.log_mul hA.ne' (Real.exp_ne_zero _), Real.log_exp, Real.log_pow, Real.log_pow] at hl + have hcast : ((Module.finrank K W-1:ℕ):ℝ) = (Module.finrank K W:ℝ)-1 := by + rw [Nat.cast_sub (by omega), Nat.cast_one] + rw [hcast] at hl + rw [Real.log_div (by norm_num) hγ.ne'] at hκ + have hlog : 0 < Real.log (Nat.card K) := Real.log_pos hq + have hh : (d:ℝ)+1-(Module.finrank K W:ℝ) ≤ (Real.log A+3*κ)/Real.log (Nat.card K) := by + apply (le_div_iff₀ hlog).mpr + nlinarith + linarith + +end +end SharpLogRamsey.Selection + +namespace SharpLogRamsey.Selection +open Finset Real +open scoped Classical BigOperators +noncomputable section +variable {K V A : Type*} [Field K] [AddCommGroup V] [Module K V] + [Finite K] [FiniteDimensional K V] [Fintype (Projectivization K V)] [Fintype A] + +lemma conditional_atom_cap {m z M κ L : ℝ} (hM : 0 < M) + (hm : exp (-κ)/M ≤ m) (hz : z≤exp (κ-L)) : + z/m≤M*exp (2*κ-L) := by + have hm0 : 0 < m := lt_of_lt_of_le (by positivity) hm + have hl : exp (-κ)≤ m*M := (div_le_iff₀ hM).mp hm + apply (div_le_iff₀ hm0).mpr + calc + z ≤ exp (κ-L) := hz + _ = exp (2*κ-L)*exp (-κ) := by rw [← exp_add]; congr 1; ring + _ ≤ exp (2*κ-L)*(m*M) := mul_le_mul_of_nonneg_left hl (exp_pos _).le + _ = _ := by ring + +theorem conditional_core_dimension (p : Law (Projectivization K V)) + (z : Projectivization K V→ℝ) (m M κ ρ ε : ℝ) (d : ℕ) + (hM : 0 < M) (hm : exp (-κ)/M ≤ m) + (hp : ∀ b,p.mass b=z b/m) (hρ : 0≤ρ) + (hheavy : p.event (univ.filter (fun b => exp (κ-(d:ℝ)*log (Nat.card K)) exp (κ-(d:ℝ)*log (Nat.card K)) b.rep∈p.core (K:=K) Projectivization.rep ρ))\bad + have hmass := p.core_nonheavy_mass hρ bad hheavy + apply p.subspace_log_dimension (p.core (K:=K) Projectivization.rep ρ) E hM hγ hκ d hmass + · intro b hb + rw [Projectivization.submodule_eq,Submodule.span_singleton_le_iff_mem] + exact (mem_filter.mp (mem_sdiff.mp hb).1).2 + · intro b hb + have hz : z b≤exp (κ-(d:ℝ)*log (Nat.card K)) := by + have hn := (mem_sdiff.mp hb).2 + simpa only [bad,mem_filter,mem_univ,true_and,not_lt] using hn + rw [hp b] + have hh := conditional_atom_cap hM hm hz + have he : exp (2*κ-(d:ℝ)*log (Nat.card K))=exp (2*κ)/(Nat.card K:ℝ)^d := by + rw [exp_sub,exp_nat_mul,exp_log] + exact_mod_cast (Nat.zero_lt_of_lt (Finite.one_lt_card (α:=K))) + rw [he] at hh + simpa only [mul_div_assoc] using hh + +theorem goodSecond_core_dimension (p : Law (Projectivization K V×A)) + (M κ ρ ε : ℝ) (d : ℕ) (a : A) (hM : 0 < M) (hρ : 0≤ρ) + (hgood : goodSecond p M ((d:ℝ)*log (Nat.card K)) κ ε a) + (hγ : 0<1-(Module.finrank K V:ℝ)*ρ-ε) + (hκ : log (2/(1-(Module.finrank K V:ℝ)*ρ-ε))≤κ) : + (d:ℝ)+1-(log M+3*κ)/log (Nat.card K)≤ + Module.finrank K ((p.condFst a).core (K:=K) Projectivization.rep ρ) := by + have hm : p.snd.mass a≠0 := (lt_of_lt_of_le (by positivity) hgood.1).ne' + exact conditional_core_dimension (p.condFst a) (fun b => p.mass (b,a)) + (p.snd.mass a) M κ ρ ε d hM hgood.1 (p.condFst_mass a hm) hρ hgood.2 hγ hκ + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ExposureReciprocal.lean b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ExposureReciprocal.lean new file mode 100644 index 0000000000000000000000000000000000000000..f110198b243039c01125c2f3fb6dd0d14a47875a --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ExposureReciprocal.lean @@ -0,0 +1,184 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Reciprocal.ReciprocalChargeHistories + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical BigOperators NNReal +noncomputable section +universe u v w +variable {C : Type v} {A B : Type w} [Fintype C] [Fintype A] [Fintype B] +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] + +def chargedBad (v : B→V) (w : A→Module.Dual K V) (ρ : ℝ) (r s : ℕ) (n : ℕ) (J D a : ℝ) : (k : ℕ) → {ι : Type u} → [Fintype ι] → + [DecidableEq ι] → Law (ι → A×B) → (C × Fin (n+k) ↪ ι) → + (ι → Option C) → Fin k → ℝ + | 0, _, _, _, _, _, _, j => Fin.elim0 j + | k+1, _, _, _, p, e, own, j => Fin.cases + (roundBad p e own (reciprocalCharges p v w ρ r s) J D a) + (fun t => (∑ f : C → Fin (n+k+1), + ∑ z, (p.restrict (freshRepresentatives e f)).mass z * + chargedBad v w ρ r s n J D a k + ((p.cond (fun x (i : freshRepresentatives e f) => x i) z).restrict + (freshRepresentatives e f)ᶜ) + (remainingEmbedding e f) (fun i => own i) t) / + Fintype.card (C → Fin (n+k+1))) j + +def chargedSelectedBad (v : B→V) (w : A→Module.Dual K V) (ρ : ℝ) (r s : ℕ) (n : ℕ) (J D a : ℝ) : (k : ℕ) → {ι : Type u} → [Fintype ι] → + [DecidableEq ι] → Law (ι → A×B) → (C × Fin (n+k) ↪ ι) → + (ι → Option C) → Fin k → ℝ + | 0, _, _, _, _, _, _, j => Fin.elim0 j + | k+1, _, _, _, p, e, own, j => Fin.cases + (roundSelectedBad p e own (reciprocalCharges p v w ρ r s) J D a) + (fun t => (∑ f : C → Fin (n+k+1), + ∑ z, (p.restrict (freshRepresentatives e f)).mass z * + chargedSelectedBad v w ρ r s n J D a k + ((p.cond (fun x (i : freshRepresentatives e f) => x i) z).restrict + (freshRepresentatives e f)ᶜ) + (remainingEmbedding e f) (fun i => own i) t) / + Fintype.card (C → Fin (n+k+1))) j + +omit [FiniteDimensional K V] in + +theorem chargedSelectedBad_le (v : B→V) (w : A→Module.Dual K V) (ρ : ℝ) (r s : ℕ) (n k : ℕ) (J D a : ℝ) + {ι : Type u} [Fintype ι] [DecidableEq ι] (p : Law (ι→A×B)) + (e : C×Fin (n+k) ↪ ι) (own : ι→Option C) + (hown : ∀ b x,own (e (b,x))=some b) (t : Fin k) : + (n:ℝ)*chargedSelectedBad v w ρ r s n J D a k p e own t≤chargedBad v w ρ r s n J D a k p e own t := by + induction k generalizing ι with + | zero => exact Fin.elim0 t + | succ k ih => + refine Fin.cases ?_ (fun j => ?_) t + · change (n:ℝ)*roundSelectedBad p e own (reciprocalCharges p v w ρ r s) J D a≤ + roundBad p e own (reciprocalCharges p v w ρ r s) J D a + exact (mul_le_mul_of_nonneg_right (by exact_mod_cast (show n≤n+(k+1) by omega)) + (roundSelectedBad_nonneg p e own _ J D a)).trans (roundSelectedBad_le p e own hown _ J D a) + · change (n:ℝ)*((∑ f : C→Fin (n+k+1),∑ z, + (p.restrict (freshRepresentatives e f)).mass z * + chargedSelectedBad v w ρ r s n J D a k + ((p.cond (fun x (i : freshRepresentatives e f) => x i) z).restrict + (freshRepresentatives e f)ᶜ) + (remainingEmbedding e f) (fun i => own i) j)/_)≤_ + rw [←mul_div_assoc] + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) + rw [mul_sum] + apply sum_le_sum + intro f _ + rw [mul_sum] + apply sum_le_sum + intro z _ + rw [mul_left_comm] + apply mul_le_mul_of_nonneg_left _ ((p.restrict _).nonneg z) + exact ih _ (remainingEmbedding e f) (fun i => own i) + (fun b x => remaining_own e f own hown b x) j + +omit [FiniteDimensional K V] in +lemma history_average_const {ι β : Type*} [Fintype ι] [DecidableEq ι] [Fintype β] + {m : ℕ} (hm : 0 < m) (p : Law (ι→β)) (e : C×Fin m ↪ ι) (a : ℝ) : + (∑ f : C→Fin m,∑ z,(p.restrict (freshRepresentatives e f)).mass z*a)/ + Fintype.card (C→Fin m)=a := by + let : Nonempty (Fin m) := ⟨⟨0,hm⟩⟩ + have hc : (Fintype.card (C→Fin m):ℝ)≠0 := by exact_mod_cast Fintype.card_ne_zero + have hi (f : C→Fin m) : ∑ z, (p.restrict (freshRepresentatives e f)).mass z*a=a := by + rw [←sum_mul,Law.total,one_mul] + simp_rw [hi] + simp only [sum_const,card_univ,nsmul_eq_mul] + exact mul_div_cancel_left₀ a hc + +theorem chargedBad_budget (v : B→V) (w : A→Module.Dual K V) + {ρ : ℝ} (hρ : 0≤ρ) {r s : ℕ} (hsum : Module.finrank K V=r+s) + (n k : ℕ) (hn : 0 exact Fin.elim0 t + | succ k ih => + refine Fin.cases ?_ (fun j => ?_) t + · change roundBad p e own (reciprocalCharges p v w ρ r s) J D a≤ + tupleDeficit J p/D+roundInformation p e own/a+2*N*M/((n:ℝ)*a) + refine (roundBad_le (by omega : 0 x i) z).restrict + (freshRepresentatives e f)ᶜ) + (remainingEmbedding e f) (fun i => own i) j)/_≤_ + calc + _ ≤ (∑ f : C→Fin (n+k+1),∑ z, + (p.restrict (freshRepresentatives e f)).mass z * + (exposureDeficits n J k + ((p.cond (fun x (i : freshRepresentatives e f) => x i) z).restrict + (freshRepresentatives e f)ᶜ) (remainingEmbedding e f) j/D+ + exposureScores n k + ((p.cond (fun x (i : freshRepresentatives e f) => x i) z).restrict + (freshRepresentatives e f)ᶜ) (remainingEmbedding e f) (fun i => own i) j/a+ + 2*N*M/((n:ℝ)*a))) /Fintype.card (C→Fin (n+k+1)) := by + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) + apply sum_le_sum + intro f _ + apply sum_le_sum + intro z _ + by_cases hz : (p.restrict (freshRepresentatives e f)).mass z=0 + · rw [hz,zero_mul,zero_mul] + · apply mul_le_mul_of_nonneg_left _ ((p.restrict _).nonneg z) + exact ih _ (remainingEmbedding e f) (fun i => own i) (fun i => S i) + (tupleSupported_cond_restrict p S hS _ z hz) (fun i => hJ i) + ((Nat.cast_le.mpr (Fintype.card_subtype_le _)).trans hN) + (tupleFlags_cond_restrict p v w hf _ z hz) + (rectangleBound_cond_restrict p v w ho _ z hz) j + _ = _ := by + rw [exposureDeficits_succ,exposureScores_succ] + simp only [mul_add,sum_add_distrib,add_div] + rw [history_average_const (by omega : 0 incident_iff_submodule a b) + rw [Nat.card_congr e, ← Nat.card_congr (projectiveSubmoduleEquiv (LinearMap.ker b.rep))] + apply Projectivization.card_of_finrank + have h := Module.Dual.finrank_ker_add_one_of_ne_zero b.rep_nonzero + omega + +theorem incident_iff_dualAnnihilator (a : Projectivization K V) + (b : Projectivization K (Module.Dual K V)) : + Incident a b ↔ b.submodule ≤ a.submodule.dualAnnihilator := by + rw [Projectivization.submodule_eq, Submodule.span_singleton_le_iff_mem, + Submodule.mem_dualAnnihilator] + change b.rep a.rep = 0 ↔ a.submodule ≤ LinearMap.ker b.rep + exact incident_iff_submodule a b + +theorem card_incident_dual [Finite K] [FiniteDimensional K V] {d : ℕ} + (hdim : Module.finrank K V = d+1) (a : Projectivization K V) : + Nat.card {b : Projectivization K (Module.Dual K V) // Incident a b} = + ∑ i ∈ Finset.range d, Nat.card K^i := by + let e := Equiv.subtypeEquivRight (fun b => incident_iff_dualAnnihilator a b) + rw [Nat.card_congr e, ← Nat.card_congr (projectiveSubmoduleEquiv a.submodule.dualAnnihilator)] + apply Projectivization.card_of_finrank + have h := Subspace.finrank_add_finrank_dualAnnihilator_eq a.submodule + rw [Projectivization.finrank_submodule] at h + omega + +theorem card_common_incident_dual [Finite K] [FiniteDimensional K V] {d : ℕ} + (hdim : Module.finrank K V = d+2) + (a a' : Projectivization K V) (haa : a ≠ a') : + Nat.card {b : Projectivization K (Module.Dual K V) // Incident a b ∧ Incident a' b} = + ∑ i ∈ Finset.range d, Nat.card K^i := by + let W := Submodule.span K (Set.range ![a.rep, a'.rep]) + have hW : Module.finrank K W = 2 := by + simpa [W] using finrank_span_eq_card (Projectivization.linearIndependent_pair_iff_ne.mpr haa) + have hpred (b : Projectivization K (Module.Dual K V)) : + (Incident a b ∧ Incident a' b) ↔ b.submodule ≤ W.dualAnnihilator := by + rw [Projectivization.submodule_eq, Submodule.span_singleton_le_iff_mem, + Submodule.mem_dualAnnihilator] + change _ ↔ W ≤ LinearMap.ker b.rep + rw [Submodule.span_le] + simp [Incident, Set.insert_subset_iff, and_comm] + let e := Equiv.subtypeEquivRight hpred + rw [Nat.card_congr e, ← Nat.card_congr (projectiveSubmoduleEquiv W.dualAnnihilator)] + apply Projectivization.card_of_finrank + have h := Subspace.finrank_add_finrank_dualAnnihilator_eq W + omega + +section Design +variable {X Y : Type*} [Fintype X] [Fintype Y] + +noncomputable def weightedIncidences (R : X → Y → Prop) (w : X → ℝ) (y : Y) : ℝ := + ∑ x, if R x y then w x else 0 + +theorem design_quadratic (R : X → Y → Prop) (k l : ℝ) + (hdeg : ∀ x, (Fintype.card {y // R x y} : ℝ) = k) + (hpair : ∀ x z, x ≠ z → (Fintype.card {y // R x y ∧ R z y} : ℝ) = l) + (w : X → ℝ) : + ∑ y, (weightedIncidences R w y)^2 = + (k-l) * (∑ x, (w x)^2) + l * (∑ x, w x)^2 := by + have hcount (x z : X) : (Fintype.card {y // R x y ∧ R z y} : ℝ) = + if x = z then k else l := by + by_cases h : x = z + · subst z; simpa using hdeg x + · simpa [h] using hpair x z h + have hexpand (y : Y) : (weightedIncidences R w y)^2 = + ∑ x, ∑ z, if R x y ∧ R z y then w x * w z else 0 := by + rw [weightedIncidences, sq, Finset.sum_mul_sum] + apply Finset.sum_congr rfl + intro x _ + apply Finset.sum_congr rfl + intro z _ + by_cases hx : R x y <;> by_cases hz : R z y <;> simp [hx,hz] + have hcoeff (x z : X) : (if x = z then k else l) = + (if x = z then k-l else 0) + l := by split_ifs <;> ring + calc + _ = ∑ x, ∑ z, ∑ y, if R x y ∧ R z y then w x * w z else 0 := by + simp_rw [hexpand] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro x _ + rw [Finset.sum_comm] + _ = ∑ x, ∑ z, (w x * w z) * (if x = z then k else l) := by + apply Finset.sum_congr rfl + intro x _ + apply Finset.sum_congr rfl + intro z _ + rw [← hcount] + simp only [Fintype.card_subtype, ← Finset.sum_filter, Finset.sum_const, + nsmul_eq_mul] + ring + _ = ∑ x, ∑ z, (w x * w z) * ((if x = z then k-l else 0) + l) := by + simp_rw [hcoeff] + _ = (k-l) * (∑ x, (w x)^2) + l * (∑ x, w x)^2 := by + simp only [mul_add, Finset.sum_add_distrib, mul_ite, mul_zero] + simp only [Finset.sum_ite_eq, Finset.mem_univ, ite_true] + simp only [sq, Finset.sum_mul, Finset.mul_sum] + congr 1 <;> apply Finset.sum_congr rfl + · intro x _; ring + · intro x _; apply Finset.sum_congr rfl; intro z _; ring + +theorem design_variance (R : X → Y → Prop) (k l : ℝ) + (hdeg : ∀ x, (Fintype.card {y // R x y} : ℝ) = k) + (hpair : ∀ x z, x ≠ z → (Fintype.card {y // R x y ∧ R z y} : ℝ) = l) + [Nonempty Y] (w : X → ℝ) : + ∑ y, (weightedIncidences R w y - k / Fintype.card Y * ∑ x, w x)^2 = + (k-l) * (∑ x, (w x)^2) + + (l - k^2 / Fintype.card Y) * (∑ x, w x)^2 := by + have hv : (Fintype.card Y : ℝ) ≠ 0 := by exact_mod_cast Fintype.card_ne_zero + have hsum : ∑ y, weightedIncidences R w y = k * ∑ x, w x := by + unfold weightedIncidences + rw [Finset.sum_comm, Finset.mul_sum] + apply Finset.sum_congr rfl + intro x _ + rw [← hdeg x] + simp [← Finset.sum_filter, Fintype.card_subtype] + simp_rw [sub_sq] + rw [Finset.sum_add_distrib, Finset.sum_sub_distrib, design_quadratic R k l hdeg hpair w] + simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] + rw [← Finset.sum_mul, ← Finset.mul_sum, hsum] + field_simp + ring + +end Design + +theorem geom_design_identity (q : ℝ) (n : ℕ) : + (∑ i ∈ range (n+2), q^i)^2 = + (∑ i ∈ range (n+1), q^i) * (∑ i ∈ range (n+3), q^i) + q^(n+1) := by + have hk : (∑ i ∈ range (n+2), q^i) = q*(∑ i ∈ range (n+1), q^i)+1 := + geom_sum_succ + have hv : (∑ i ∈ range (n+3), q^i) = q*(∑ i ∈ range (n+2), q^i)+1 := + geom_sum_succ + have hd : (∑ i ∈ range (n+2), q^i) = q^(n+1)+(∑ i ∈ range (n+1), q^i) := + geom_sum_succ' + have hc : q^(n+1) = (∑ i ∈ range (n+2), q^i) - + (∑ i ∈ range (n+1), q^i) := by linarith + rw [hv, hc, hk] + ring + +section Projective +variable [Finite K] [FiniteDimensional K V] +variable [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K V))] + +theorem projective_variance {n : ℕ} (hdim : Module.finrank K V = n+3) + (w : Projectivization K V → ℝ) : + ∑ y : Projectivization K (Module.Dual K V), + (weightedIncidences Incident w y - + (∑ i ∈ range (n+2), (Nat.card K : ℝ)^i) / + (∑ i ∈ range (n+3), (Nat.card K : ℝ)^i) * ∑ x, w x)^2 = + (Nat.card K : ℝ)^(n+1) * ((∑ x, w x^2) - + (∑ x, w x)^2 / (∑ i ∈ range (n+3), (Nat.card K : ℝ)^i)) := by + have hv : (Fintype.card (Projectivization K (Module.Dual K V)) : ℝ) = + ∑ i ∈ range (n+3), (Nat.card K : ℝ)^i := by + rw [← Nat.card_eq_fintype_card, Projectivization.card_of_finrank K _ + (Subspace.dual_finrank_eq.trans hdim)] + push_cast + rfl + have hvpos : 0 < ∑ i ∈ range (n+3), (Nat.card K : ℝ)^i := by + apply Finset.sum_pos' + · intro i hi; positivity + · exact ⟨0, by simp, by simp⟩ + have : Nonempty (Projectivization K (Module.Dual K V)) := by + apply Fintype.card_pos_iff.mp + exact_mod_cast hv ▸ hvpos + have hg (x : Projectivization K V) : + (Fintype.card {y : Projectivization K (Module.Dual K V) // Incident x y} : ℝ) = + ∑ i ∈ range (n+2), (Nat.card K : ℝ)^i := by + rw [← Nat.card_eq_fintype_card, card_incident_dual (d := n+2) hdim x] + push_cast + rfl + have hp (x z : Projectivization K V) (hxz : x ≠ z) : + (Fintype.card {y : Projectivization K (Module.Dual K V) // + Incident x y ∧ Incident z y} : ℝ) = + ∑ i ∈ range (n+1), (Nat.card K : ℝ)^i := by + rw [← Nat.card_eq_fintype_card, card_common_incident_dual (d := n+1) hdim x z hxz] + push_cast + rfl + have he := design_variance Incident _ _ hg hp w + rw [hv] at he + rw [he] + have hd : (∑ i ∈ range (n+2), (Nat.card K : ℝ)^i) - + (∑ i ∈ range (n+1), (Nat.card K : ℝ)^i) = (Nat.card K : ℝ)^(n+1) := by + rw [geom_sum_succ']; ring + rw [hd] + have hg := geom_design_identity (Nat.card K : ℝ) n + rw [hg] + field_simp + ring + +theorem projective_variance_le {n : ℕ} (hdim : Module.finrank K V = n+3) + (w : Projectivization K V → ℝ) : + ∑ y : Projectivization K (Module.Dual K V), + (weightedIncidences Incident w y - + (∑ i ∈ range (n+2), (Nat.card K : ℝ)^i) / + (∑ i ∈ range (n+3), (Nat.card K : ℝ)^i) * ∑ x, w x)^2 ≤ + (Nat.card K : ℝ)^(n+1) * ∑ x, w x^2 := by + rw [projective_variance hdim] + apply mul_le_mul_of_nonneg_left _ (by positivity) + exact sub_le_self _ (by positivity) + +noncomputable def incidenceCount (S : Finset (Projectivization K V)) + (T : Finset (Projectivization K (Module.Dual K V))) : ℕ := + ∑ y ∈ T, (S.filter (fun x => Incident x y)).card + +theorem projective_mixing_sq {n : ℕ} (hdim : Module.finrank K V = n+3) + (S : Finset (Projectivization K V)) + (T : Finset (Projectivization K (Module.Dual K V))) : + ((incidenceCount S T : ℝ) - + (∑ i ∈ range (n+2), (Nat.card K : ℝ)^i) / + (∑ i ∈ range (n+3), (Nat.card K : ℝ)^i) * S.card * T.card)^2 ≤ + (Nat.card K : ℝ)^(n+1) * S.card * T.card := by + let w : Projectivization K V → ℝ := fun x => if x ∈ S then 1 else 0 + have hsum : ∑ x, w x = (S.card : ℝ) := by simp [w] + have hsumsq : ∑ x, w x^2 = (S.card : ℝ) := by simp [w] + have hc (y : Projectivization K (Module.Dual K V)) : + weightedIncidences Incident w y = ((S.filter (fun x => Incident x y)).card : ℝ) := by + simp [weightedIncidences, w, ← Finset.sum_filter] + congr 1 + ext x + simp [and_comm] + let p : ℝ := (∑ i ∈ range (n+2), (Nat.card K : ℝ)^i) / + (∑ i ∈ range (n+3), (Nat.card K : ℝ)^i) + let f (y : Projectivization K (Module.Dual K V)) := weightedIncidences Incident w y - p*S.card + have hf : ∑ y ∈ T, f y = (incidenceCount S T : ℝ) - p*S.card*T.card := by + simp only [f, hc, Finset.sum_sub_distrib, Finset.sum_const, nsmul_eq_mul, + incidenceCount, Nat.cast_sum] + ring + have hCS := Finset.sum_mul_sq_le_sq_mul_sq T (fun _ => (1:ℝ)) f + simp only [one_mul, one_pow, Finset.sum_const, nsmul_eq_mul, mul_one] at hCS + have hv := projective_variance_le hdim w + rw [hsum, hsumsq] at hv + have hsub : ∑ y ∈ T, f y^2 ≤ ∑ y, f y^2 := + Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ T) (fun _ _ _ => sq_nonneg _) + calc + _ = (∑ y ∈ T, f y)^2 := by rw [hf] + _ ≤ (T.card : ℝ) * ∑ y ∈ T, f y^2 := hCS + _ ≤ (T.card : ℝ) * ((Nat.card K : ℝ)^(n+1)*S.card) := + mul_le_mul_of_nonneg_left (hsub.trans hv) (by positivity) + _ = _ := by ring + +theorem projective_mixing {n : ℕ} (hdim : Module.finrank K V = n+3) + (S : Finset (Projectivization K V)) + (T : Finset (Projectivization K (Module.Dual K V))) : + |(incidenceCount S T : ℝ) - + (∑ i ∈ range (n+2), (Nat.card K : ℝ)^i) / + (∑ i ∈ range (n+3), (Nat.card K : ℝ)^i) * S.card * T.card| ≤ + Real.sqrt ((Nat.card K : ℝ)^(n+1)) * Real.sqrt ((S.card : ℝ)*T.card) := by + calc + _ ≤ Real.sqrt ((Nat.card K : ℝ)^(n+1) * S.card * T.card) := by + simpa only [Real.sqrt_sq_eq_abs] using + Real.sqrt_le_sqrt (projective_mixing_sq hdim S T) + _ = _ := by rw [mul_assoc, Real.sqrt_mul (by positivity)] + +theorem sparse_product_bound {n : ℕ} (hdim : Module.finrank K V = n+3) + (S : Finset (Projectivization K V)) + (T : Finset (Projectivization K (Module.Dual K V))) + (hsparse : (incidenceCount S T : ℝ) ≤ (S.card : ℝ)*T.card/(4*Nat.card K)) : + (S.card : ℝ)*T.card ≤ 16*(Nat.card K : ℝ)^(n+3) := by + let q : ℝ := Nat.card K + let v : ℝ := ∑ i ∈ range (n+3), q^i + let k : ℝ := ∑ i ∈ range (n+2), q^i + let a : ℝ := (S.card : ℝ)*T.card + have hq : 1 < q := by + change (1:ℝ) < (Nat.card K : ℝ) + exact_mod_cast (Finite.one_lt_card : 1 < Nat.card K) + have hk : 1 ≤ k := by + have h0 : (1:ℝ) ≤ ∑ i ∈ range (n+2), q^i := by + calc + _ = q^0 := by simp + _ ≤ ∑ i ∈ range (n+2), q^i := + single_le_sum (fun i hi => by positivity) (by simp) + exact h0 + have hgeom : v = q*k+1 := geom_sum_succ + have hv : 0 < v := by nlinarith + have hp : 1/(2*q) ≤ k/v := by + apply (div_le_div_iff₀ (by positivity) hv).mpr + nlinarith + have ha : 0 ≤ a := by positivity + have hdev : a/(4*q) ≤ k/v*a-(incidenceCount S T : ℝ) := by + have hmul := mul_le_mul_of_nonneg_right hp ha + change (incidenceCount S T : ℝ) ≤ a/(4*q) at hsparse + have heq : (1/(2*q))*a = 2*(a/(4*q)) := by ring + rw [heq] at hmul + linarith + have hsq := projective_mixing_sq hdim S T + change ((incidenceCount S T : ℝ) - k/v*S.card*T.card)^2 ≤ q^(n+1)*S.card*T.card at hsq + have hsq' : (a/(4*q))^2 ≤ q^(n+1)*a := by + have hdnon : 0 ≤ k/v*a-(incidenceCount S T : ℝ) := + (by positivity : 0 ≤ a/(4*q)).trans hdev + have h := (sq_le_sq₀ (by positivity : 0 ≤ a/(4*q)) hdnon).mpr hdev + nlinarith [hsq] + have hpow : q^(n+3) = q^(n+1)*q^2 := by rw [← pow_add] + rw [hpow] + by_cases haz : a = 0 + · change a ≤ _; rw [haz]; positivity + have hap : 0 < a := lt_of_le_of_ne ha (Ne.symm haz) + have hq0 : q ≠ 0 := by linarith + have hcancel : (a/(4*q))^2 * (16*q^2) = a^2 := by field_simp; ring + have hmult := mul_le_mul_of_nonneg_right hsq' (by positivity : 0 ≤ 16*q^2) + rw [hcancel] at hmult + change a ≤ _ + nlinarith [hmult] + +end Projective +end SharpLogRamsey.Incidence + +namespace SharpLogRamsey.Incidence +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] +variable [Finite K] [FiniteDimensional K V] +variable [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + +theorem mixing_cell_scale {n : ℕ} (hdim : Module.finrank K V=n+3) + (S : Finset (Projectivization K V)) + (T : Finset (Projectivization K (Module.Dual K V))) {B z : ℝ} + (hB : 1≤B) (hz : 0≤z) (hz1 : z≤1) + (hcap : (S.card:ℝ)*T.card ≤ B*(Nat.card K:ℝ)^(n+3)*z^2) : + (incidenceCount S T:ℝ) ≤ 2*B*(Nat.card K:ℝ)^(n+2)*z := by + let q : ℝ := Nat.card K + let p : ℝ := (∑ i∈range (n+2),q^i)/(∑ i∈range (n+3),q^i) + let a : ℝ := (S.card:ℝ)*T.card + have hq : 0 pow_nonneg hq.le _) ⟨0,by simp,by simp⟩ + have hp : p≤1/q := by + apply (div_le_div_iff₀ hv hq).mpr + have he : (∑ i∈range (n+3),q^i)=q*(∑ i∈range (n+2),q^i)+1 := geom_sum_succ + linarith + have ha : 0≤a := by dsimp [a]; positivity + have hzz : z^2≤z := by nlinarith + have hmean : p*a≤B*q^(n+2)*z := by + have H := mul_le_mul_of_nonneg_right hp ha + have H' : a/q≤B*q^(n+2)*z^2 := by + apply (div_le_iff₀ hq).mpr + change a≤B*q^(n+3)*z^2 at hcap + calc + a ≤ B*q^(n+3)*z^2 := hcap + _ = _ := by rw [show n+3=(n+2)+1 by omega,pow_succ]; ring + have H'' := mul_le_mul_of_nonneg_left hzz (show 0≤B*q^(n+2) by positivity) + calc + p*a ≤ a/q := by simpa only [one_div,div_eq_mul_inv,mul_comm,mul_one] using H + _ ≤ B*q^(n+2)*z^2 := H' + _ ≤ _ := H'' + have hs := projective_mixing_sq hdim S T + change ((incidenceCount S T:ℝ)-p*S.card*T.card)^2 ≤ q^(n+1)*S.card*T.card at hs + simp only [mul_assoc] at hs + change ((incidenceCount S T:ℝ)-p*a)^2 ≤ q^(n+1)*a at hs + have hscale : q^(n+1)*a ≤ (B*q^(n+2)*z)^2 := by + have H := mul_le_mul_of_nonneg_left hcap (pow_nonneg hq.le (n+1)) + have he : q^(n+1)*(B*q^(n+3)*z^2)=B*(q^(n+2)*z)^2 := by + rw [mul_pow,←pow_mul] + have he : q^(n+1)*q^(n+3)=q^((n+2)*2) := by rw [←pow_add]; congr 1; omega + calc + _ = B*(q^(n+1)*q^(n+3))*z^2 := by ring + _ = _ := by rw [he]; ring + change q^(n+1)*a ≤ q^(n+1)*(B*q^(n+3)*z^2) at H + rw [he] at H + have hBB : B≤B^2 := by nlinarith + have H' := mul_le_mul_of_nonneg_right hBB (sq_nonneg (q^(n+2)*z)) + exact H.trans (by nlinarith [H']) + have hpos : 0≤B*q^(n+2)*z := by positivity + have hdev := (sq_le_sq₀ (abs_nonneg ((incidenceCount S T:ℝ)-p*a)) hpos).mp + (by simpa using hs.trans hscale) + have hh := le_abs_self ((incidenceCount S T:ℝ)-p*a) + linarith + +theorem mixing_loss_log {n : ℕ} (hdim : Module.finrank K V=n+3) + (S : Finset (Projectivization K V)) + (T : Finset (Projectivization K (Module.Dual K V))) + {A B C : ℝ} (hA : 0 Incident z.1 z.2)).card := by + classical + simp only [Finset.product_eq_sprod,incidenceCount,Finset.card_filter] + rw [Finset.sum_product S T,Finset.sum_comm] + +end SharpLogRamsey.Incidence + +namespace SharpLogRamsey.Selection +variable {α β : Type*} [Fintype α] [Fintype β] + +noncomputable def positiveSupport (p : Law α) : Finset α := univ.filter (fun a => 0 f a=b),p.mass a=(p.map f).mass b := by + apply sum_subset (by + intro a ha + exact mem_filter.mpr ⟨mem_univ _,(mem_filter.mp ha).2⟩) + intro a ha hna + apply positiveSupport_zero + intro hs + exact hna (mem_filter.mpr ⟨hs,(mem_filter.mp ha).2⟩) + +lemma positive_cell_nonempty (p : Law α) (f : α→β) (b : β) (hb : 0<(p.map f).mass b) : + ((positiveSupport p).filter (fun a => f a=b)).Nonempty := by + by_contra hn + have he := not_nonempty_iff_eq_empty.mp hn + have H := positiveSupport_cell_mass p f b + rw [he,sum_empty] at H + linarith + +end SharpLogRamsey.Selection + +namespace SharpLogRamsey.Incidence +open SharpLogRamsey.Selection +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] +variable [Finite K] [FiniteDimensional K V] +variable [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + +noncomputable def endpointLabels + (p : Law (Projectivization K V × Projectivization K (Module.Dual K V))) := + fun z : Projectivization K V × Projectivization K (Module.Dual K V) => + (levelIndex p.fst z.1,levelIndex p.snd z.2) + +omit [Finite K] [FiniteDimensional K V] in +lemma endpoint_cell_subset + (p : Law (Projectivization K V × Projectivization K (Module.Dual K V))) + (hs : ∀ z, 0 endpointLabels p z=b) ⊆ + (((levelSet p.fst b.1).product (levelSet p.snd b.2)).filter (fun z => Incident z.1 z.2)) := by + intro z hz + have hp := (mem_filter.mp (mem_filter.mp hz).1).2 + have hl := (mem_filter.mp hz).2 + have ha : (levelIndex p.fst z.1)=b.1 := congrArg Prod.fst hl + have hb : (levelIndex p.snd z.2)=b.2 := congrArg Prod.snd hl + exact mem_filter.mpr ⟨mem_product.mpr + ⟨mem_filter.mpr ⟨mem_univ _,hp.trans_le (p.le_fst z.1 z.2),ha⟩, + mem_filter.mpr ⟨mem_univ _,hp.trans_le (p.le_snd z.1 z.2),hb⟩⟩,hs z hp⟩ + +theorem reciprocal_level_losses {n : ℕ} (hdim : Module.finrank K V=n+3) + (p : Law (Projectivization K V × Projectivization K (Module.Dual K V))) + (hs : ∀ z, 0 levelLoss p.fst A b.1+levelLoss p.snd B b.2 + have hcell (b : Levels p.fst × Levels p.snd) (hb : 0<(p.map l).mass b) : + Real.log ((positiveSupport p).filter (fun z => l z=b)).card ≤ + Real.log (2*C*(Nat.card K:ℝ)^(n+2))-loss b/2 := by + let S := (positiveSupport p).filter (fun z => l z=b) + have hn := positive_cell_nonempty p l b hb + obtain ⟨z,hz⟩ := hn + have hsub := endpoint_cell_subset p hs b + have hz' := mem_product.mp (mem_filter.mp (hsub (by simpa only [l] using hz))).1 + have hAS : 0<(levelSet p.fst b.1).card := card_pos.mpr ⟨z.1,hz'.1⟩ + have hBT : 0<(levelSet p.snd b.2).card := card_pos.mpr ⟨z.2,hz'.2⟩ + have hcount : S.card≤ incidenceCount (levelSet p.fst b.1) (levelSet p.snd b.2) := by + rw [incidenceCount_eq_card] + exact card_le_card hsub + have hSn : 0¬goodFirst q MA L κ (1/50) x))≤3251*σ^(-2*β) ∧ + q.snd.event (univ.filter (fun x=>¬goodSecond q MB L κ (1/50) x))≤3251*σ^(-2*β) := by + filter_upwards [eventually_actual_reciprocal d β hβ] with σ he + intro K V _ _ _ _ _ _ _ hdim hlog Ω Θ ι C _ _ _ _ _ p θ G S u n k e own t hp D J a + hS hf hcap hD hJ z c hz i hi + let M:=contextual n k p θ G e own t + have hd:=((not_badIndices (M.tupleLaw z.1) (M.embedding z.1) (M.owner z.1) + c J (D*σ^β) a z.2 i).mp hi).1 + have hcaps:=prepared_context_property n k p θ G e own t hp z hz + (fun θ=>∀ i,(((S θ i).image Prod.fst).card:ℝ)≤1024*exp (((d+3:ℕ):ℝ)*σ-u θ i) ∧ + (((S θ i).image Prod.snd).card:ℝ)≤1024*exp (u θ i) ∧ + ((S θ i).card:ℝ)≤64*(Nat.card K:ℝ)^(d+2)) hcap + apply he K V hdim hlog (M.tupleLaw z.1|>.marginal i) (S z.1.1 (M.origin z.1 i)) D + (u z.1.1 (M.origin z.1 i)) + · exact prepared_marginal_domain n k p θ G e own t hp z hz S hS i + · intro x hx + exact prepared_marginal_property n k p θ G e own t hp z hz + (fun _ _ x=>x.1.rep x.2.rep=0) hf i x (ne_of_gt hx) + · exact (hcaps _).1 + · exact (hcaps _).2.1 + · exact (hcaps _).2.2 + · exact hD + · exact (sub_le_sub_right hJ _).trans hd +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ProdRectangleEvent.lean b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ProdRectangleEvent.lean new file mode 100644 index 0000000000000000000000000000000000000000..bc64e58aa06622c05e6f017cd45e7d433b273c5c --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ProdRectangleEvent.lean @@ -0,0 +1,354 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Reciprocal.ReciprocalCurrent + +namespace OAI + +section +open scoped BigOperators Classical +open Finset +namespace SharpLogRamsey.Selection +open scoped BigOperators Classical +open Finset +noncomputable section +variable {A B : Type*} [Fintype A] [Fintype B] +lemma Law.prod_rectangle_event (p : Law A) (q : Law B) (S : Finset A) (T : Finset B) : + (p.prod q).event (S ×ˢ T) = p.event S*q.event T := by + simp only [Law.event, Law.prod, sum_product, sum_mul, mul_sum] + exact sum_comm + +lemma Law.event_filter_le_add (p : Law A) (P Q : A → Prop) : + p.event (univ.filter P) ≤ p.event (univ.filter (fun a => P a ∧ ¬Q a)) + + p.event (univ.filter (fun a => P a ∧ Q a)) := by + simp only [Law.event, sum_filter, ← sum_add_distrib] + apply sum_le_sum + intro a _ + by_cases hp : P a <;> by_cases hq : Q a <;> simp [hp,hq] + +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] + +def firstCore (p : Law (A × B)) (v : B → V) (ρ : ℝ) (a : A) : Submodule K V := + (p.condSnd a).core v ρ + +def secondCore (p : Law (A × B)) (w : A → Module.Dual K V) (ρ : ℝ) (y : B) : + Submodule K (Module.Dual K V) := (p.condFst y).core w ρ + +def coreContained (p q : Law (A × B)) (v : B → V) (w : A → Module.Dual K V) + (ρ : ℝ) (a : A) (y : B) : Prop := + secondCore q w ρ y ≤ (firstCore (K := K) p v ρ a).dualAnnihilator + +def coreCollision (p q : Law (A × B)) (v : B → V) (w : A → Module.Dual K V) + (ρ : ℝ) (goodA : A → Prop) (goodB : B → Prop) (z : (A × B) × (A × B)) : Prop := + goodA z.1.1 ∧ goodB z.2.2 ∧ w z.1.1 (v z.2.2) = 0 ∧ + coreContained p q v w ρ z.1.1 z.2.2 ∧ + v z.1.2 ∈ firstCore (K := K) p v ρ z.1.1 ∧ w z.2.1 ∈ secondCore q w ρ z.2.2 + +lemma core_capture_product (p q : Law (A × B)) (v : B → V) + (w : A → Module.Dual K V) {ρ c : ℝ} (hρ : 0 ≤ ρ) (hc : 0 ≤ c) + (hd : c ≤ 1-(Module.finrank K V:ℝ)*ρ) (a : A) (y : B) : + c^2 ≤ ((p.condSnd a).prod (q.condFst y)).event + (univ.filter (fun bc : B × A => v bc.1 ∈ firstCore (K := K) p v ρ a ∧ + w bc.2 ∈ secondCore q w ρ y)) := by + have h₁ := (p.condSnd a).core_capture (K := K) v hρ + have h₂ := (q.condFst y).core_capture (K := K) w hρ + rw [Subspace.dual_finrank_eq] at h₂ + have he : (univ.filter (fun bc : B × A => v bc.1 ∈ firstCore (K := K) p v ρ a ∧ + w bc.2 ∈ secondCore q w ρ y)) = + (univ.filter (fun b => v b ∈ firstCore (K := K) p v ρ a)) ×ˢ + (univ.filter (fun a => w a ∈ secondCore q w ρ y)) := by ext bc; simp + rw [he, Law.prod_rectangle_event, pow_two] + exact mul_le_mul (hd.trans h₁) (hd.trans h₂) hc + ((p.condSnd a).event_nonneg _) + +lemma core_collision_capture (p q : Law (A × B)) (v : B → V) + (w : A → Module.Dual K V) {ρ c : ℝ} (hρ : 0 ≤ ρ) (hc : 0 ≤ c) + (hd : c ≤ 1-(Module.finrank K V:ℝ)*ρ) (goodA : A → Prop) (goodB : B → Prop) : + c^2*(p.fst.prod q.snd).event (univ.filter (fun ay : A × B => + goodA ay.1 ∧ goodB ay.2 ∧ w ay.1 (v ay.2) = 0 ∧ coreContained p q v w ρ ay.1 ay.2)) ≤ + (p.prod q).event (univ.filter (coreCollision p q v w ρ goodA goodB)) := by + rw [show (p.prod q).event (univ.filter (coreCollision p q v w ρ goodA goodB)) = + (p.prod q).event (univ.filter (fun z => coreCollision p q v w ρ goodA goodB (z.1,z.2))) by rfl, + p.product_event_disintegration q (fun ab cy => coreCollision p q v w ρ goodA goodB (ab,cy))] + simp only [Law.event, sum_filter, mul_sum] + apply sum_le_sum + intro ay _ + rw [←mul_sum] + by_cases h : goodA ay.1 ∧ goodB ay.2 ∧ w ay.1 (v ay.2) = 0 ∧ coreContained p q v w ρ ay.1 ay.2 + · rw [ite_eq_left h] + have he : (∑ bc : B × A, if coreCollision p q v w ρ goodA goodB ((ay.1,bc.1), (bc.2,ay.2)) + then ((p.condSnd ay.1).prod (q.condFst ay.2)).mass bc else 0) = + ((p.condSnd ay.1).prod (q.condFst ay.2)).event (univ.filter (fun bc : B × A => + v bc.1 ∈ firstCore (K := K) p v ρ ay.1 ∧ w bc.2 ∈ secondCore q w ρ ay.2)) := by + simp [Law.event, sum_filter, coreCollision, h.1,h.2.1,h.2.2.1,h.2.2.2] + rw [he, mul_comm (c^2)] + exact mul_le_mul_of_nonneg_left (core_capture_product p q v w hρ hc hd ay.1 ay.2) + ((p.fst.prod q.snd).nonneg ay) + · rw [ite_eq_right h, mul_zero] + exact mul_nonneg ((p.fst.prod q.snd).nonneg ay) (sum_nonneg (fun bc _ => by + split_ifs; exact ((p.condSnd ay.1).prod (q.condFst ay.2)).nonneg bc; rfl)) +omit [FiniteDimensional K V] in + +lemma exceptional_core_mass (p q : Law (A × B)) (v : B → V) + (w : A → Module.Dual K V) {ρ : ℝ} (hρ : 0 < ρ) + (goodA : A → Prop) (goodB : B → Prop) : + ρ^2*(p.fst.prod q.snd).event (univ.filter (fun ay : A × B => + (goodA ay.1 ∧ goodB ay.2 ∧ w ay.1 (v ay.2) = 0) ∧ + ¬coreContained p q v w ρ ay.1 ay.2)) ≤ + (p.prod q).event (univ.filter (fun z : (A × B) × (A × B) => + w z.1.1 (v z.2.2) = 0 ∧ w z.2.1 (v z.1.2) ≠ 0)) := by + calc + _ ≤ ∑ ay : A × B, (p.fst.prod q.snd).mass ay * + ((p.condSnd ay.1).prod (q.condFst ay.2)).event + (univ.filter (fun bc : B × A => + w ay.1 (v ay.2) = 0 ∧ w bc.2 (v bc.1) ≠ 0)) := by + change ρ^2*(∑ ay with (goodA ay.1 ∧ goodB ay.2 ∧ w ay.1 (v ay.2) = 0) ∧ + ¬coreContained p q v w ρ ay.1 ay.2, (p.fst.prod q.snd).mass ay) ≤ _ + rw [sum_filter,mul_sum] + apply sum_le_sum + intro ay _ + by_cases h : (goodA ay.1 ∧ goodB ay.2 ∧ w ay.1 (v ay.2) = 0) ∧ + ¬coreContained p q v w ρ ay.1 ay.2 + · rw [ite_eq_left h, mul_comm (ρ^2)] + apply mul_le_mul_of_nonneg_left _ ((p.fst.prod q.snd).nonneg ay) + simp only [h.1.2.2, true_and] + apply le_of_not_gt + intro he + exact h.2 ((p.condSnd ay.1).cores_orthogonal (q.condFst ay.2) v w hρ he.le) + · rw [ite_eq_right h,mul_zero] + exact mul_nonneg ((p.fst.prod q.snd).nonneg ay) + (((p.condSnd ay.1).prod (q.condFst ay.2)).event_nonneg _) + _ = _ := by + convert (p.product_event_disintegration q + (fun ab cy => w ab.1 (v cy.2) = 0 ∧ w cy.1 (v ab.2) ≠ 0)).symm using 1 <;> congr! + +theorem reciprocal_incidence_collision (p : Law ((A × B) × (A × B))) + (v : B → V) (w : A → Module.Dual K V) + {ρ c : ℝ} (hρ : 0 < ρ) (hc : 0 < c) + (hd : c ≤ 1-(Module.finrank K V:ℝ)*ρ) + (goodA : A → Prop) (goodB : B → Prop) + (hconsistent : ∀ z, p.mass z ≠ 0 → + w z.1.1 (v z.2.2) = 0 → w z.2.1 (v z.1.2) = 0) : + (p.fst.fst.prod p.snd.snd).event (univ.filter (fun ay : A × B => + goodA ay.1 ∧ goodB ay.2 ∧ w ay.1 (v ay.2) = 0)) ≤ + 2*mutualInfo p/ρ^2 + + 2*(mutualInfo p+p.event (univ.filter (coreCollision p.fst p.snd v w ρ goodA goodB)))/c^2 := by + have hconf : p.event (univ.filter (fun z : (A × B) × (A × B) => + w z.1.1 (v z.2.2) = 0 ∧ w z.2.1 (v z.1.2) ≠ 0)) = 0 := by + apply sum_eq_zero + intro z hz + by_contra hn + have hz' := (mem_filter.mp hz).2 + exact hz'.2 (hconsistent z hn hz'.1) + have herr := mutualInfo_event_transfer p (univ.filter (fun z : (A × B) × (A × B) => + w z.1.1 (v z.2.2) = 0 ∧ w z.2.1 (v z.1.2) ≠ 0)) + rw [hconf,add_zero] at herr + have he := (exceptional_core_mass p.fst p.snd v w hρ goodA goodB).trans herr + have hex : (p.fst.fst.prod p.snd.snd).event (univ.filter (fun ay : A × B => + (goodA ay.1 ∧ goodB ay.2 ∧ w ay.1 (v ay.2) = 0) ∧ + ¬coreContained p.fst p.snd v w ρ ay.1 ay.2)) ≤ 2*mutualInfo p/ρ^2 := by + apply (le_div_iff₀ (sq_pos_of_pos hρ)).mpr + simpa only [mul_comm] using he + have hcap := (core_collision_capture p.fst p.snd v w hρ.le hc.le hd goodA goodB).trans + (mutualInfo_event_transfer p (univ.filter (coreCollision p.fst p.snd v w ρ goodA goodB))) + have hcm : (p.fst.fst.prod p.snd.snd).event (univ.filter (fun ay : A × B => + goodA ay.1 ∧ goodB ay.2 ∧ w ay.1 (v ay.2) = 0 ∧ + coreContained p.fst p.snd v w ρ ay.1 ay.2)) ≤ + 2*(mutualInfo p+p.event (univ.filter (coreCollision p.fst p.snd v w ρ goodA goodB)))/c^2 := by + apply (le_div_iff₀ (sq_pos_of_pos hc)).mpr + simpa only [mul_comm] using hcap + have hs := (p.fst.fst.prod p.snd.snd).event_filter_le_add + (fun ay : A × B => goodA ay.1 ∧ goodB ay.2 ∧ w ay.1 (v ay.2) = 0) + (fun ay => coreContained p.fst p.snd v w ρ ay.1 ay.2) + have hcm' : (p.fst.fst.prod p.snd.snd).event (univ.filter (fun ay : A × B => + (goodA ay.1 ∧ goodB ay.2 ∧ w ay.1 (v ay.2) = 0) ∧ + coreContained p.fst p.snd v w ρ ay.1 ay.2)) ≤ + 2*(mutualInfo p+p.event (univ.filter (coreCollision p.fst p.snd v w ρ goodA goodB)))/c^2 := by + simpa only [and_assoc] using hcm + have HF := hs.trans (by + convert add_le_add hex hcm' using 1 + congr!) + convert HF using 1 + congr! + +end +end SharpLogRamsey.Selection + +namespace SharpLogRamsey.Selection +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] + +lemma not_contained_of_rank_sum (W : Submodule K V) (U : Submodule K (Module.Dual K V)) + {r s : ℕ} (hW : r ≤ Module.finrank K W) (hU : s ≤ Module.finrank K U) + (hsum : Module.finrank K V < r+s) : ¬U ≤ W.dualAnnihilator := by + intro h + have hle := Submodule.finrank_mono h + have hd := Subspace.finrank_add_finrank_dualAnnihilator_eq W + omega + +lemma complementary_of_rank_sum (W : Submodule K V) (U : Submodule K (Module.Dual K V)) + {r s : ℕ} (hW : r ≤ Module.finrank K W) (hU : s ≤ Module.finrank K U) + (hsum : Module.finrank K V = r+s) (h : U ≤ W.dualAnnihilator) : + Module.finrank K W = r ∧ U = W.dualAnnihilator := by + have hle := Submodule.finrank_mono h + have hd := Subspace.finrank_add_finrank_dualAnnihilator_eq W + refine ⟨by omega, Submodule.eq_of_le_of_finrank_eq h ?_⟩ + omega + +end SharpLogRamsey.Selection + +namespace SharpLogRamsey.Selection +open scoped BigOperators Classical +open Finset +noncomputable section +variable {A B Ω : Type*} [Fintype A] [Fintype B] [Fintype Ω] +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] + +omit [Fintype Ω] [FiniteDimensional K V] in +lemma firstCore_own (p : Law (A × B)) (v : B → V) (w : A → Module.Dual K V) + {ρ : ℝ} (hρ : 0 ≤ ρ) + (hflag : ∀ ab, p.mass ab ≠ 0 → w ab.1 (v ab.2) = 0) + (a : A) (ha : p.fst.mass a ≠ 0) : + w a ∈ (firstCore (K := K) p v ρ a).dualAnnihilator := by + rw [Submodule.mem_dualAnnihilator] + apply (p.condSnd a).core_le_test v ρ (w a) + have he : (p.condSnd a).event (univ.filter (fun b => w a (v b) ≠ 0)) = 0 := by + apply sum_eq_zero + intro b hb + rw [p.condSnd_mass a ha] + rw [show p.mass (a,b) = 0 from not_not.mp (fun hn => (mem_filter.mp hb).2 (hflag (a,b) hn))] + exact zero_div _ + simpa only [he] using hρ + +omit [Fintype Ω] [FiniteDimensional K V] in +lemma secondCore_own (p : Law (A × B)) (v : B → V) (w : A → Module.Dual K V) + {ρ : ℝ} (hρ : 0 ≤ ρ) + (hflag : ∀ ab, p.mass ab ≠ 0 → w ab.1 (v ab.2) = 0) + (y : B) (hy : p.snd.mass y ≠ 0) : + v y ∈ (secondCore p w ρ y).dualCoannihilator := by + rw [Submodule.mem_dualCoannihilator] + apply (p.condFst y).core_le_test w ρ (Module.Dual.eval K V (v y)) + have he : (p.condFst y).event (univ.filter (fun a => (Module.Dual.eval K V (v y)) (w a) ≠ 0)) = 0 := by + apply sum_eq_zero + intro a ha + rw [p.condFst_mass y hy] + rw [show p.mass (a,y) = 0 from not_not.mp (fun hn => (mem_filter.mp ha).2 (hflag (a,y) hn))] + exact zero_div _ + simpa only [he] using hρ + +def orthogonalRectangle (v : B → V) (w : A → Module.Dual K V) (W : Submodule K V) : Finset (A × B) := + univ.filter (fun ab => v ab.2 ∈ W ∧ w ab.1 ∈ W.dualAnnihilator) + +omit [Fintype Ω] in +lemma coreCollision_rectangle (p q : Law (A × B)) (v : B → V) (w : A → Module.Dual K V) + {ρ : ℝ} (hρ : 0 ≤ ρ) (goodA : A → Prop) (goodB : B → Prop) + (hpflag : ∀ ab, p.mass ab ≠ 0 → w ab.1 (v ab.2) = 0) + (hqflag : ∀ ab, q.mass ab ≠ 0 → w ab.1 (v ab.2) = 0) + {r s : ℕ} (hsum : Module.finrank K V = r+s) + (hW : ∀ a, goodA a → r ≤ Module.finrank K (firstCore (K := K) p v ρ a)) + (hU : ∀ y, goodB y → s ≤ Module.finrank K (secondCore q w ρ y)) + (ab cy : A × B) (hp : p.mass ab ≠ 0) (hq : q.mass cy ≠ 0) + (hcol : coreCollision p q v w ρ goodA goodB (ab,cy)) : + ab ∈ orthogonalRectangle v w (firstCore (K := K) p v ρ ab.1) ∧ + cy ∈ orthogonalRectangle v w (firstCore (K := K) p v ρ ab.1) := by + obtain ⟨hga,hgy,_,hcont,hb,hc⟩ := hcol + have hcomp := (complementary_of_rank_sum _ _ (hW _ hga) (hU _ hgy) hsum hcont).2 + have hpa : p.fst.mass ab.1 ≠ 0 := (lt_of_lt_of_le (lt_of_le_of_ne (p.nonneg _) (Ne.symm hp)) (p.le_fst _ _)).ne' + have hqy : q.snd.mass cy.2 ≠ 0 := (lt_of_lt_of_le (lt_of_le_of_ne (q.nonneg _) (Ne.symm hq)) (q.le_snd _ _)).ne' + have hy := secondCore_own q v w hρ hqflag cy.2 hqy + rw [hcomp, Subspace.dualAnnihilator_dualCoannihilator_eq] at hy + exact ⟨mem_filter.mpr ⟨mem_univ _, hb, firstCore_own p v w hρ hpflag ab.1 hpa⟩, + mem_filter.mpr ⟨mem_univ _,hy,hcomp ▸ hc⟩⟩ + +end +end SharpLogRamsey.Selection +namespace SharpLogRamsey.Selection +open scoped BigOperators Classical +open Finset +noncomputable section +variable {A B Ω : Type*} [Fintype A] [Fintype B] [Fintype Ω] + +lemma Law.event_map (p : Law Ω) (f : Ω → A) (E : Finset A) : + (p.map f).event E = p.event (univ.filter (fun x => f x ∈ E)) := by + have h := p.sum_map f (fun a => if a ∈ E then 1 else 0) + simpa only [mul_ite, mul_one, mul_zero, ← sum_filter, filter_mem_eq_inter, univ_inter, + Law.event] using h + +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] + +omit [FiniteDimensional K V] in + +lemma slot_flag {n : ℕ} (p : Law Ω) (f : Ω → Fin n → A × B) + (v : B → V) (w : A → Module.Dual K V) + (hflag : ∀ x, p.mass x ≠ 0 → ∀ i, w (f x i).1 (v (f x i).2) = 0) + (i : Fin n) (ab : A × B) (hab : (p.map (fun x => f x i)).mass ab ≠ 0) : + w ab.1 (v ab.2) = 0 := by + obtain ⟨x,hx,rfl⟩ := p.map_support (fun x => f x i) ab hab + exact hflag x hx i + +theorem reciprocal_charge_sum {n : ℕ} (p : Law Ω) (f : Ω → Fin n → A × B) + (v : B → V) (w : A → Module.Dual K V) {ρ M : ℝ} (hρ : 0 ≤ ρ) + (goodA : Fin n → A → Prop) (goodB : Fin n → B → Prop) + (hflag : ∀ x, p.mass x ≠ 0 → ∀ i, w (f x i).1 (v (f x i).2) = 0) + {r s : ℕ} (hsum : Module.finrank K V = r+s) + (hW : ∀ i a, goodA i a → r ≤ Module.finrank K + (firstCore (K := K) (p.map (fun x => f x i)) v ρ a)) + (hU : ∀ j y, goodB j y → s ≤ Module.finrank K + (secondCore (p.map (fun x => f x j)) w ρ y)) + (hocc : ∀ x, p.mass x ≠ 0 → ∀ W : Submodule K V, + ((univ.filter (fun j : Fin n => f x j ∈ orthogonalRectangle v w W)).card:ℝ) ≤ M) : + ∑ i, ∑ j with i < j, + p.event (univ.filter (fun x => coreCollision (p.map (fun z => f z i)) + (p.map (fun z => f z j)) v w ρ (goodA i) (goodB j) (f x i,f x j))) ≤ n*M := by + let C (i j : Fin n) (x : Ω) := coreCollision (p.map (fun z => f z i)) + (p.map (fun z => f z j)) v w ρ (goodA i) (goodB j) (f x i,f x j) + have hpoint (x : Ω) (hx : p.mass x ≠ 0) (i : Fin n) : + ∑ j with i < j, (if C i j x then (1:ℝ) else 0) ≤ M := by + have hc : (univ.filter (fun j : Fin n => i < j ∧ C i j x)) ⊆ + univ.filter (fun j => f x j ∈ orthogonalRectangle v w + (firstCore (K := K) (p.map (fun z => f z i)) v ρ (f x i).1)) := by + intro j hj + have hpi : (p.map (fun z => f z i)).mass (f x i) ≠ 0 := + (lt_of_lt_of_le (lt_of_le_of_ne (p.nonneg x) (Ne.symm hx)) (p.le_map _ x)).ne' + have hpj : (p.map (fun z => f z j)).mass (f x j) ≠ 0 := + (lt_of_lt_of_le (lt_of_le_of_ne (p.nonneg x) (Ne.symm hx)) (p.le_map _ x)).ne' + exact mem_filter.mpr ⟨mem_univ _, (coreCollision_rectangle _ _ v w hρ _ _ + (slot_flag p f v w hflag i) (slot_flag p f v w hflag j) hsum (hW i) (hU j) + (f x i) (f x j) hpi hpj (mem_filter.mp hj).2.2).2⟩ + have hh := (Nat.cast_le.mpr (card_le_card hc) : + ((univ.filter (fun j : Fin n => i < j ∧ C i j x)).card:ℝ) ≤ _) + have hs : (∑ j with i < j, (if C i j x then (1:ℝ) else 0)) = + ((univ.filter (fun j : Fin n => i < j ∧ C i j x)).card:ℝ) := by + simp only [← sum_filter, filter_filter, sum_const, nsmul_eq_mul, mul_one] + rw [hs] + exact hh.trans (hocc x hx _) + have hs : (∑ i, ∑ j with i < j, p.event (univ.filter (C i j))) = + ∑ x, p.mass x * (∑ i, ∑ j with i < j, (if C i j x then (1:ℝ) else 0)) := by + have he (i j : Fin n) : p.event (univ.filter (C i j)) = + ∑ x, p.mass x*(if C i j x then (1:ℝ) else 0) := by + simp only [Law.event, sum_filter, mul_ite, mul_one, mul_zero] + simp_rw [he] + calc + _ = ∑ i, ∑ x, ∑ j with i < j, p.mass x*(if C i j x then (1:ℝ) else 0) := by + apply sum_congr rfl + intro i hi + exact sum_comm + _ = ∑ x, ∑ i, ∑ j with i < j, p.mass x*(if C i j x then (1:ℝ) else 0) := sum_comm + _ = _ := by simp_rw [← mul_sum] + change (∑ i, ∑ j with i < j, p.event (univ.filter (C i j))) ≤ _ + rw [hs] + calc + _ ≤ ∑ x, p.mass x * (n*M) := by + apply sum_le_sum + intro x hx + by_cases hp : p.mass x = 0 + · simp [hp] + apply mul_le_mul_of_nonneg_left _ (p.nonneg x) + calc + _ ≤ ∑ _i : Fin n, M := sum_le_sum (fun i _ => hpoint x hp i) + _ = _ := by simp + _ = _ := by rw [← sum_mul, p.total, one_mul] + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/Reciprocal.lean b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/Reciprocal.lean new file mode 100644 index 0000000000000000000000000000000000000000..8d72b0c0e46d2abeafa8a3aad56bb251704ecc10 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/Reciprocal.lean @@ -0,0 +1,175 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Reciprocal.CoreDimensions + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset Real +open scoped Classical BigOperators +noncomputable section +variable {A B : Type*} [Fintype A] [Fintype B] + +def goodFirst (p : Law (A×B)) (M L κ ε : ℝ) (a : A) : Prop := + exp (-κ)/M ≤ p.fst.mass a ∧ + (p.condSnd a).event (univ.filter (fun b => exp (κ-L) p.mass (a,b)) + (p.fst.mass a) M κ ρ ε d hM hgood.1 (p.condSnd_mass a hm) hρ hgood.2 hγ hκ + +end +end SharpLogRamsey.Selection + +namespace SharpLogRamsey.Selection +open scoped BigOperators Classical +open Finset +noncomputable section +variable {A B : Type*} [Fintype A] [Fintype B] +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] + +theorem reciprocal_open_incidence (p : Law ((A × B) × (A × B))) + (v : B → V) (w : A → Module.Dual K V) {ρ : ℝ} (hρ : 0 < ρ) + (goodA : A → Prop) (goodB : B → Prop) + {r s : ℕ} (hsum : Module.finrank K V < r+s) + (hW : ∀ a, goodA a → r ≤ Module.finrank K (firstCore (K := K) p.fst v ρ a)) + (hU : ∀ y, goodB y → s ≤ Module.finrank K (secondCore p.snd w ρ y)) + (hconsistent : ∀ z, p.mass z ≠ 0 → + w z.1.1 (v z.2.2) = 0 → w z.2.1 (v z.1.2) = 0) : + (p.fst.fst.prod p.snd.snd).event (univ.filter (fun ay : A × B => + goodA ay.1 ∧ goodB ay.2 ∧ w ay.1 (v ay.2) = 0)) ≤ 2*mutualInfo p/ρ^2 := by + have he := exceptional_core_mass p.fst p.snd v w hρ goodA goodB + have heq : (univ.filter (fun ay : A × B => + (goodA ay.1 ∧ goodB ay.2 ∧ w ay.1 (v ay.2) = 0) ∧ + ¬coreContained p.fst p.snd v w ρ ay.1 ay.2)) = + univ.filter (fun ay : A × B => goodA ay.1 ∧ goodB ay.2 ∧ w ay.1 (v ay.2) = 0) := by + ext ay + simp only [mem_filter, mem_univ, true_and] + refine ⟨And.left, fun h => ⟨h,?_⟩⟩ + exact not_contained_of_rank_sum _ _ (hW _ h.1) (hU _ h.2.1) hsum + rw [heq] at he + have hz : p.event (univ.filter (fun z : (A × B) × (A × B) => + w z.1.1 (v z.2.2) = 0 ∧ w z.2.1 (v z.1.2) ≠ 0)) = 0 := by + apply sum_eq_zero + intro z hz + by_contra hn + exact (mem_filter.mp hz).2.2 (hconsistent z hn (mem_filter.mp hz).2.1) + have ht := mutualInfo_event_transfer p (univ.filter (fun z : (A × B) × (A × B) => + w z.1.1 (v z.2.2) = 0 ∧ w z.2.1 (v z.1.2) ≠ 0)) + rw [hz,add_zero] at ht + apply (le_div_iff₀ (sq_pos_of_pos hρ)).mpr + simpa only [mul_comm] using he.trans ht + +lemma open_band_rank {σ e u v : ℝ} {d r a b : ℕ} + (hu : (r:ℝ)-1 < (u-e)/σ) + (hv : (r:ℝ) > (v+e)/σ) + (ha : (u-e)/σ ≤ a) (hb : (d:ℝ)+1-(v+e)/σ ≤ b) : + d+1 < a+b := by + have har : r ≤ a := by + by_contra hn + have hn' : (a:ℝ)+1 ≤ r := by exact_mod_cast (show a+1 ≤ r by omega) + linarith + have hreal : (d:ℝ)+1-r < b := by linarith + have hab : d+1 < b+r := by exact_mod_cast (show (d:ℝ)+1 < (b:ℝ)+r by linarith) + omega + +lemma integer_band_rank {e u v σ : ℝ} {d r a b : ℕ} + (hu : (r:ℝ)-1 < (u-e)/σ) + (hv : (v+e)/σ < (r:ℝ)+1) + (ha : (u-e)/σ ≤ a) (hb : (d:ℝ)+1-(v+e)/σ ≤ b) : + r ≤ a ∧ d+1-r ≤ b := by + constructor + · by_contra hn + have hn' : (a:ℝ)+1 ≤ r := by exact_mod_cast (show a+1 ≤ r by omega) + linarith + · have hreal : (d:ℝ)-r < b := by linarith + have hab : d < b+r := by exact_mod_cast (show (d:ℝ) < (b:ℝ)+r by linarith) + omega + +end +end SharpLogRamsey.Selection + +namespace SharpLogRamsey.Selection +open Finset Real +open scoped Classical BigOperators +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + +private lemma round_core_rank {r a : ℕ} {x : ℝ} + (hx : (r:ℝ)-1 + goodFirst p.fst MA ((d:ℝ)*log (Nat.card K)) κ ε ay.1 ∧ + goodSecond p.snd MB ((d:ℝ)*log (Nat.card K)) κ ε ay.2 ∧ + ay.1.rep ay.2.rep=0))≤2*mutualInfo p/ρ^2 := by + apply reciprocal_open_incidence p Projectivization.rep Projectivization.rep hρ _ _ + (r:=r) (s:=d+2-r) (by omega) _ _ hconsistent + · intro a ha + exact round_core_rank hu (goodFirst_core_dimension p.fst MA κ ρ ε d a hMA hρ.le ha hγ hκ) + · intro y hy + have hh := goodSecond_core_dimension p.snd MB κ ρ ε d y hMB hρ.le hy + (by simpa only [Subspace.dual_finrank_eq] using hγ) + (by simpa only [Subspace.dual_finrank_eq] using hκ) + apply round_core_rank (x:=(d:ℝ)+1-(log MB+3*κ)/log (Nat.card K)) _ hh + have hc : ((d+2-r:ℕ):ℝ)=(d:ℝ)+2-r := by + rw [Nat.cast_sub (by omega),Nat.cast_add,Nat.cast_ofNat] + rw [hc] + linarith + +theorem projective_integer_ranks + (p q : Law (Projectivization K (Module.Dual K V)×Projectivization K V)) + (MA MB κ ρ ε : ℝ) (d r : ℕ) (hMA : 0 x i∈orthogonalRectangle v w W)).card:ℝ)≤M + +def tupleFlags (p : Law (ι→A×B)) (v : B→V) (w : A→Module.Dual K V) : Prop := + ∀ x,p.mass x≠0 → ∀ i,w (x i).1 (v (x i).2)=0 + +def rankCollision (p : Law (ι→A×B)) (v : B→V) (w : A→Module.Dual K V) + (ρ : ℝ) (r s : ℕ) (i j : ι) (x : ι→A×B) : Prop := + coreCollision (p.marginal i) (p.marginal j) v w ρ + (fun a => r≤Module.finrank K (firstCore (K:=K) (p.marginal i) v ρ a)) + (fun y => s≤Module.finrank K (secondCore (p.marginal j) w ρ y)) (x i,x j) + +def directedCollision (p : Law (ι→A×B)) (v : B→V) (w : A→Module.Dual K V) + (ρ : ℝ) (r s : ℕ) (i j : ι) : ℝ≥0 := + ⟨p.event (univ.filter (rankCollision p v w ρ r s i j)),p.event_nonneg _⟩ + +def reciprocalCharges (p : Law (ι→A×B)) (v : B→V) (w : A→Module.Dual K V) + (ρ : ℝ) (r s : ℕ) (i j : ι) : ℝ≥0 := + directedCollision p v w ρ r s i j+directedCollision p v w ρ r s j i + +omit [FiniteDimensional K V] in +lemma marginal_flag (p : Law (ι→A×B)) (v : B→V) (w : A→Module.Dual K V) + (hf : tupleFlags p v w) (i : ι) (ab : A×B) (ha : (p.marginal i).mass ab≠0) : + w ab.1 (v ab.2)=0 := by + obtain ⟨x,hx,rfl⟩ := p.map_support (fun x => x i) ab ha + exact hf x hx i + +lemma rankCollision_rectangle (p : Law (ι→A×B)) (v : B→V) (w : A→Module.Dual K V) + {ρ : ℝ} (hρ : 0≤ρ) {r s : ℕ} (hsum : Module.finrank K V=r+s) + (hflag : tupleFlags p v w) (x : ι→A×B) (hx : p.mass x≠0) (i j : ι) + (hc : rankCollision p v w ρ r s i j x) : + x j∈orthogonalRectangle v w (firstCore (K:=K) (p.marginal i) v ρ (x i).1) := by + have hpi : (p.marginal i).mass (x i)≠0 := + (lt_of_lt_of_le (lt_of_le_of_ne (p.nonneg x) (Ne.symm hx)) (p.le_map _ x)).ne' + have hpj : (p.marginal j).mass (x j)≠0 := + (lt_of_lt_of_le (lt_of_le_of_ne (p.nonneg x) (Ne.symm hx)) (p.le_map _ x)).ne' + exact (coreCollision_rectangle _ _ v w hρ _ _ + (marginal_flag p v w hflag i) (marginal_flag p v w hflag j) hsum + (fun _ h => h) (fun _ h => h) (x i) (x j) hpi hpj hc).2 + +theorem directedCollision_sum (p : Law (ι→A×B)) (v : B→V) (w : A→Module.Dual K V) + {ρ M : ℝ} (hρ : 0≤ρ) {r s : ℕ} (hsum : Module.finrank K V=r+s) + (hflag : tupleFlags p v w) (hocc : rectangleBound p v w M) : + ∑ i,∑ j,(directedCollision p v w ρ r s i j:ℝ)≤Fintype.card ι*M := by + let C := rankCollision p v w ρ r s + have hpoint (x : ι→A×B) (hx : p.mass x≠0) (i : ι) : + ∑ j,(if C i j x then (1:ℝ) else 0)≤M := by + have hs : univ.filter (fun j => C i j x)⊆ + univ.filter (fun j => x j∈orthogonalRectangle v w + (firstCore (K:=K) (p.marginal i) v ρ (x i).1)) := by + intro j hj + exact mem_filter.mpr ⟨mem_univ _,rankCollision_rectangle p v w hρ hsum hflag x hx i j (mem_filter.mp hj).2⟩ + have hc := (Nat.cast_le.mpr (card_le_card hs) : + ((univ.filter (fun j => C i j x)).card:ℝ)≤_) + simpa only [sum_boole] using hc.trans (hocc x hx _) + have he (i j : ι) : (directedCollision p v w ρ r s i j:ℝ)= + ∑ x,p.mass x*(if C i j x then (1:ℝ) else 0) := by + simp only [directedCollision,Law.event,sum_filter,mul_ite,mul_one,mul_zero] + rfl + simp_rw [he] + have hswap : (∑ i,∑ j,∑ x,p.mass x*(if C i j x then (1:ℝ) else 0))= + ∑ x,p.mass x*(∑ i,∑ j,(if C i j x then (1:ℝ) else 0)) := by + conv_lhs => arg 2; ext i; rw [sum_comm] + rw [sum_comm] + simp_rw [mul_sum] + rw [hswap] + calc + _ ≤ ∑ x,p.mass x*(Fintype.card ι*M) := by + apply sum_le_sum + intro x _ + by_cases hx : p.mass x=0 + · simp [hx] + apply mul_le_mul_of_nonneg_left _ (p.nonneg x) + exact (sum_le_sum (fun i _ => hpoint x hx i)).trans_eq (by simp) + _ = _ := by rw [←sum_mul,p.total,one_mul] + +theorem reciprocalCharges_sum (p : Law (ι→A×B)) (v : B→V) (w : A→Module.Dual K V) + {ρ M : ℝ} (hρ : 0≤ρ) {r s : ℕ} (hsum : Module.finrank K V=r+s) + (hflag : tupleFlags p v w) (hocc : rectangleBound p v w M) : + ∑ i,∑ j,(reciprocalCharges p v w ρ r s i j:ℝ)≤2*Fintype.card ι*M := by + simp only [reciprocalCharges,NNReal.coe_add,sum_add_distrib] + rw [sum_comm (f:=fun i j => (directedCollision p v w ρ r s j i:ℝ))] + linarith only [directedCollision_sum p v w hρ hsum hflag hocc] + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalBands.lean b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalBands.lean new file mode 100644 index 0000000000000000000000000000000000000000..296faeb75e908a45b37a168e7ebe83519a9e094f --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalBands.lean @@ -0,0 +1,93 @@ +import Mathlib + +namespace OAI + +section +namespace SharpLogRamsey.ReciprocalBands +open Real +noncomputable section + +def clamp (d : ℕ) (σ x : ℝ) : ℝ := max σ (min ((d:ℝ)*σ) x) + +lemma clamp_range {d : ℕ} (hd : 1≤d) {σ x : ℝ} (hσ : 0≤σ) : + σ≤clamp d σ x ∧ clamp d σ x≤(d:ℝ)*σ := by + have hd' : (1:ℝ)≤d := by exact_mod_cast hd + exact ⟨le_max_left _ _,max_le (by nlinarith) (min_le_left _ _)⟩ + +theorem clamped_caps {d : ℕ} (hd : 1≤d) {σ a b C : ℝ} + (hσ : 0≤σ) (hb : 0 simp only [Nat.cast_zero,zero_mul] at hhi; linarith + | succ d ih => + by_cases hprev : u≤(d:ℝ)*σ + · obtain ⟨r,h₁,h₂,h₃⟩ := ih hprev + exact ⟨r,h₁,h₂.trans (Nat.le_succ d),h₃⟩ + have hhi' : u≤((d:ℝ)+1)*σ := by simpa only [Nat.cast_add,Nat.cast_one] using hhi + by_cases hnext : ((d:ℝ)+1)*σ-K≤u + · refine ⟨d+1,by omega,le_rfl,Or.inl ?_⟩ + rw [IntegerBand,abs_le] + simp only [Nat.cast_add,Nat.cast_one] + constructor <;> linarith + have hd : 1≤d := by + by_contra hn + have hz : d=0 := by omega + simp only [hz,Nat.cast_zero,zero_add,one_mul] at hnext + linarith + by_cases hleft : u≤(d:ℝ)*σ+K + · refine ⟨d,hd,by omega,Or.inl ?_⟩ + rw [IntegerBand,abs_le] + constructor <;> linarith + · refine ⟨d+1,by omega,le_rfl,Or.inr ⟨by omega,?_⟩⟩ + unfold OpenBand + simp only [Nat.cast_add,Nat.cast_one,add_sub_cancel_right] + exact ⟨lt_of_not_ge hleft,lt_of_not_ge hnext⟩ + +end +end SharpLogRamsey.ReciprocalBands + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalChargeHistories.lean b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalChargeHistories.lean new file mode 100644 index 0000000000000000000000000000000000000000..823f429a1f997fb88dd975aa647b3841414380a9 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalChargeHistories.lean @@ -0,0 +1,65 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Reciprocal.ReciprocalActualCharges + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical BigOperators NNReal +noncomputable section +variable {α ι : Type*} [Fintype α] [Fintype ι] [DecidableEq ι] + +def Law.revealRest (p : Law (ι→α)) (E : Finset ι) (z : E→α) : Law (↥(Eᶜ)→α) := + (p.cond (fun x (i:E) => x i) z).restrict Eᶜ + +variable {A B : Type*} [Fintype A] [Fintype B] +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] + +omit [FiniteDimensional K V] in +lemma tupleFlags_cond_restrict (p : Law (ι→A×B)) (v : B→V) (w : A→Module.Dual K V) + (hf : tupleFlags p v w) (E : Finset ι) (z : E→A×B) + (hz : (p.restrict E).mass z≠0) : + tupleFlags (A:=A) (B:=B) (ι := ↥(Eᶜ)) (p.revealRest E z) v w := by + intro x hx i + obtain ⟨y,hy,rfl⟩ := (p.cond (fun x (i:E) => x i) z).map_support _ x hx + exact hf y (p.cond_support _ z hz y hy).1 i + +omit [FiniteDimensional K V] in + +lemma rectangleBound_cond_restrict (p : Law (ι→A×B)) (v : B→V) (w : A→Module.Dual K V) + {M : ℝ} (ho : rectangleBound p v w M) (E : Finset ι) (z : E→A×B) + (hz : (p.restrict E).mass z≠0) : + rectangleBound (A:=A) (B:=B) (ι := ↥(Eᶜ)) (p.revealRest E z) v w M := by + intro x hx W + obtain ⟨y,hy,rfl⟩ := (p.cond (fun x (i:E) => x i) z).map_support _ x hx + have ht := ho y (p.cond_support _ z hz y hy).1 W + refine le_trans ?_ ht + apply Nat.cast_le.mpr + apply card_le_card_of_injOn (fun (i : (Eᶜ : Finset ι)) => (i:ι)) + · intro i hi + exact mem_filter.mpr ⟨mem_univ _, (mem_filter.mp hi).2⟩ + · exact Subtype.val_injective.injOn + +lemma reciprocalCharges_history_sum (p : Law (ι→A×B)) (v : B→V) (w : A→Module.Dual K V) + {ρ M : ℝ} (hρ : 0≤ρ) (hM : 0≤M) {r s : ℕ} (hsum : Module.finrank K V=r+s) + (hf : tupleFlags p v w) (ho : rectangleBound p v w M) + (E : Finset ι) (z : E→A×B) (hz : (p.restrict E).mass z≠0) : + ∑ i,∑ j,(reciprocalCharges (A:=A) (B:=B) (ι := ↥(Eᶜ)) + (p.revealRest E z) v w ρ r s i j:ℝ) + ≤2*Fintype.card ι*M := by + have hh := reciprocalCharges_sum (A:=A) (B:=B) (ι := ↥(Eᶜ)) + (p.revealRest E z) v w hρ hsum + (tupleFlags_cond_restrict p v w hf E z hz) + (rectangleBound_cond_restrict p v w ho E z hz) + refine hh.trans ?_ + apply mul_le_mul_of_nonneg_right _ hM + apply mul_le_mul_of_nonneg_left _ (by norm_num) + exact Nat.cast_le.mpr (Fintype.card_subtype_le _) + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalCharges.lean b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalCharges.lean new file mode 100644 index 0000000000000000000000000000000000000000..03108a801c2d7a539b15884b1ec75e734c969aa8 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalCharges.lean @@ -0,0 +1,79 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Reciprocal.Reciprocal + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset Real +open scoped Classical BigOperators NNReal +noncomputable section +variable {K V ι : Type*} [Field K] [AddCommGroup V] [Module K V] + [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype ι] [DecidableEq ι] + +theorem projective_integer_incidence + (p : Law (ι→Projectivization K (Module.Dual K V)×Projectivization K V)) + (i j : ι) (MA MB κ ρ ε c : ℝ) (d r : ℕ) + (hMA : 0 + goodFirst (p.marginal i) MA ((d:ℝ)*log (Nat.card K)) κ ε ay.1 ∧ + goodSecond (p.marginal j) MB ((d:ℝ)*log (Nat.card K)) κ ε ay.2 ∧ + ay.1.rep ay.2.rep=0))≤ + 2*(pairInformation p i j:ℝ)/ρ^2+ + 2*((pairInformation p i j:ℝ)+ + (directedCollision p Projectivization.rep Projectivization.rep ρ r (d+1-r) i j:ℝ))/c^2 := by + classical + let : DecidableEq (Projectivization K (Module.Dual K V)×Projectivization K V) := Classical.decEq _ + let : DecidableEq ((Projectivization K (Module.Dual K V)×Projectivization K V)× + (Projectivization K (Module.Dual K V)×Projectivization K V)) := Classical.decEq _ + let p₂ := p.map (fun x => (x i,x j)) + have hi : p₂.fst=p.marginal i := by + rw [←Law.map_fst,Law.map_map]; rfl + have hj : p₂.snd=p.marginal j := by + rw [←Law.map_snd,Law.map_map]; rfl + let ga := goodFirst (p.marginal i) MA ((d:ℝ)*log (Nat.card K)) κ ε + let gb := goodSecond (p.marginal j) MB ((d:ℝ)*log (Nat.card K)) κ ε + have hcon : ∀ z,p₂.mass z≠0 → + z.1.1.rep z.2.2.rep=0 → z.2.1.rep z.1.2.rep=0 := by + intro z hz + obtain ⟨x,hx,rfl⟩ := p.map_support (fun x => (x i,x j)) z hz + exact hconsistent x hx + have hb := reciprocal_incidence_collision p₂ Projectivization.rep Projectivization.rep + hρ hc hcap ga gb hcon + have he : p₂.event (univ.filter (coreCollision p₂.fst p₂.snd + Projectivization.rep Projectivization.rep ρ ga gb))≤ + (directedCollision p Projectivization.rep Projectivization.rep ρ r (d+1-r) i j:ℝ) := by + rw [hi,hj] + have hm := p.event_map (fun x => (x i,x j)) + (univ.filter (coreCollision (p.marginal i) (p.marginal j) + Projectivization.rep Projectivization.rep ρ ga gb)) + refine hm.le.trans ?_ + apply p.event_mono + intro x hx + have hh := (mem_filter.mp hx).2 + simp only [mem_filter,mem_univ,true_and] at hh + have hranks := projective_integer_ranks (p.marginal i) (p.marginal j) + MA MB κ ρ ε d r hMA hMB hρ.le hr hγ hκ hu hv (x i).1 (x j).2 hh.1 hh.2.1 + exact mem_filter.mpr ⟨mem_univ _,hranks.1,hranks.2,hh.2.2⟩ + rw [hi,hj] at hb he + change _≤2*mutualInfo p₂/ρ^2+2*(mutualInfo p₂+_)/c^2 + exact hb.trans (add_le_add le_rfl + (div_le_div_of_nonneg_right + (mul_le_mul_of_nonneg_left (add_le_add le_rfl he) + (by norm_num : (0 : ℝ) ≤ 2)) (sq_nonneg c))) + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalCurrent.lean b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalCurrent.lean new file mode 100644 index 0000000000000000000000000000000000000000..dfae08333630d2768d4ad32f5cebba33f571b2cc --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalCurrent.lean @@ -0,0 +1,436 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Exposure.ExposureGood + +namespace OAI + +section +open scoped BigOperators Classical +open Finset +namespace SharpLogRamsey.Selection +variable {α : Type*} [Fintype α] +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] + +noncomputable def Law.tests (p : Law α) (v : α → V) (ρ : ℝ) : Set (Module.Dual K V) := + {f | p.event (univ.filter (fun a => f (v a) ≠ 0)) ≤ ρ} + +noncomputable def Law.core (p : Law α) (v : α → V) (ρ : ℝ) : Submodule K V := + (Submodule.span K (p.tests (K:=K) v ρ)).dualCoannihilator + +omit [FiniteDimensional K V] in +theorem Law.mem_core (p : Law α) (v : α → V) (ρ : ℝ) (x : V) : + x ∈ p.core (K:=K) v ρ ↔ ∀ f ∈ p.tests (K:=K) v ρ, f x = 0 := by + unfold Law.core + rw [Submodule.mem_dualCoannihilator] + constructor + · intro h f hf + exact h f (Submodule.subset_span hf) + · intro h + have hs : Submodule.span K (p.tests (K:=K) v ρ) ≤ LinearMap.ker (Module.Dual.eval K V x) := by + rw [Submodule.span_le] + exact h + exact fun f hf => hs hf + +omit [FiniteDimensional K V] in +theorem Law.core_le_test (p : Law α) (v : α → V) (ρ : ℝ) + (f : Module.Dual K V) (hf : p.event (univ.filter (fun a => f (v a) ≠ 0)) ≤ ρ) : + p.core (K:=K) v ρ ≤ LinearMap.ker f := by + intro x hx + exact (p.mem_core (K:=K) v ρ x).mp hx f hf + +theorem Law.core_failure_le (p : Law α) (v : α → V) {ρ : ℝ} (hρ : 0 ≤ ρ) : + p.event (univ.filter (fun a => v a ∉ p.core (K:=K) v ρ)) ≤ + (Module.finrank K V : ℝ)*ρ := by + obtain ⟨b,hb,hspan,hli⟩ := exists_linearIndependent K (p.tests (K:=K) v ρ) + let : Finite b := hli.finite + let : Fintype b := Fintype.ofFinite b + have hcard : Fintype.card b ≤ Module.finrank K V := by + have h := hli.fintype_card_le_finrank + simpa only [Subspace.dual_finrank_eq] using h + have hsome (a : α) (ha : v a ∉ p.core (K:=K) v ρ) : ∃ f : b, f.val (v a) ≠ 0 := by + by_contra hn + push Not at hn + apply ha + rw [p.mem_core (K:=K)] + have hs : Submodule.span K b ≤ LinearMap.ker (Module.Dual.eval K V (v a)) := by + rw [Submodule.span_le] + intro f hf + exact hn ⟨f,hf⟩ + rw [hspan] at hs + intro f hf + exact hs (Submodule.subset_span hf) + have hpoint (a : α) : + (if v a ∉ p.core (K:=K) v ρ then p.mass a else 0) ≤ + ∑ f : b, if f.val (v a) ≠ 0 then p.mass a else 0 := by + by_cases ha : v a ∉ p.core (K:=K) v ρ + · obtain ⟨f,hf⟩ := hsome a ha + rw [ite_eq_left ha] + calc + _ = (if f.val (v a) ≠ 0 then p.mass a else 0) := (ite_eq_left hf).symm + _ ≤ ∑ g : b, if g.val (v a) ≠ 0 then p.mass a else 0 := + single_le_sum (f := fun g : b => if g.val (v a) ≠ 0 then p.mass a else 0) + (fun g hg => by split_ifs <;> first | exact p.nonneg _ | positivity) (mem_univ f) + · rw [ite_eq_right ha] + exact sum_nonneg fun f hf => by split_ifs <;> first | exact p.nonneg _ | positivity + calc + p.event (univ.filter (fun a => v a ∉ p.core (K:=K) v ρ)) + = ∑ a, if v a ∉ p.core (K:=K) v ρ then p.mass a else 0 := by simp only [Law.event,sum_filter] + _ ≤ ∑ a, ∑ f : b, if f.val (v a) ≠ 0 then p.mass a else 0 := sum_le_sum fun a ha => hpoint a + _ = ∑ f : b, p.event (univ.filter (fun a => f.val (v a) ≠ 0)) := by + rw [sum_comm]; simp only [Law.event,sum_filter] + _ ≤ ∑ _ : b, ρ := sum_le_sum fun f hf => hb f.property + _ = (Fintype.card b : ℝ)*ρ := by simp + _ ≤ (Module.finrank K V : ℝ)*ρ := mul_le_mul_of_nonneg_right (by exact_mod_cast hcard) hρ + +theorem Law.event_complement (p : Law α) (E : Finset α) : + p.event E + p.event Eᶜ = 1 := by + exact (sum_add_sum_compl E p.mass).trans p.total + +theorem Law.core_capture (p : Law α) (v : α → V) {ρ : ℝ} (hρ : 0 ≤ ρ) : + 1-(Module.finrank K V : ℝ)*ρ ≤ + p.event (univ.filter (fun a => v a ∈ p.core (K:=K) v ρ)) := by + have h := p.core_failure_le (K:=K) v hρ + have hc := p.event_complement (univ.filter (fun a => v a ∈ p.core (K:=K) v ρ)) + have he : (univ.filter (fun a => v a ∈ p.core (K:=K) v ρ))ᶜ = + univ.filter (fun a => v a ∉ p.core (K:=K) v ρ) := by ext a; simp + rw [he] at hc + linarith + +variable {β : Type*} [Fintype β] + +theorem Law.event_gt_le (p : Law α) (f : α → ℝ) (hf : ∀ a, 0 ≤ f a) + {ρ : ℝ} (_hρ : 0 < ρ) : + p.event (univ.filter (fun a => ρ < f a))*ρ ≤ ∑ a, p.mass a*f a := by + rw [Law.event,sum_filter,sum_mul] + apply sum_le_sum + intro a ha + by_cases he : ρ < f a + · rw [ite_eq_left he] + exact mul_le_mul_of_nonneg_left he.le (p.nonneg a) + · rw [ite_eq_right he,zero_mul] + exact mul_nonneg (p.nonneg a) (hf a) + +omit [FiniteDimensional K V] in + +theorem Law.cores_orthogonal (p : Law α) (q : Law β) (v : α → V) + (w : β → Module.Dual K V) {ρ : ℝ} (hρ : 0 < ρ) + (herror : (p.prod q).event (univ.filter (fun z : α × β => w z.2 (v z.1) ≠ 0)) ≤ ρ^2) : + (q.core (K:=K) w ρ) ≤ (p.core (K:=K) v ρ).dualAnnihilator := by + let err : α → ℝ := fun a => q.event (univ.filter (fun b => w b (v a) ≠ 0)) + have hmean : (∑ a, p.mass a*err a) = + (p.prod q).event (univ.filter (fun z : α × β => w z.2 (v z.1) ≠ 0)) := by + simp only [err,Law.event,Law.prod,sum_filter,Fintype.sum_prod_type,mul_sum,mul_ite,mul_zero] + have hbad : p.event (univ.filter (fun a => ρ < err a)) ≤ ρ := by + have h := p.event_gt_le err (fun a => q.event_nonneg _) hρ + rw [hmean] at h + apply (mul_le_mul_iff_left₀ hρ).mp + nlinarith + intro f hf + rw [Submodule.mem_dualAnnihilator] + have ht : f ∈ p.tests (K:=K) v ρ := by + change p.event (univ.filter (fun a => f (v a) ≠ 0)) ≤ ρ + apply le_trans _ hbad + apply sum_le_sum_of_subset_of_nonneg + · intro a ha + simp only [mem_filter,mem_univ,true_and] at ha ⊢ + by_contra hn + have he : Module.Dual.eval K V (v a) ∈ q.tests (K:=K) w ρ := by + exact le_of_not_gt hn + exact ha ((q.mem_core (K:=K) w ρ f).mp hf _ he) + · intro a ha hb + exact p.nonneg a + intro x hx + exact (p.mem_core (K:=K) v ρ x).mp hx f ht + +end SharpLogRamsey.Selection + +namespace SharpLogRamsey.Incidence +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + +def Incident (a : Projectivization K V) + (b : Projectivization K (Module.Dual K V)) : Prop := b.rep a.rep = 0 + +theorem incident_iff_submodule (a : Projectivization K V) + (b : Projectivization K (Module.Dual K V)) : + Incident a b ↔ a.submodule ≤ LinearMap.ker b.rep := by + rw [Projectivization.submodule_eq, Submodule.span_singleton_le_iff_mem] + rfl + +noncomputable def projectiveSubmoduleEquiv (W : Submodule K V) : + Projectivization K W ≃ {a : Projectivization K V // a.submodule ≤ W} := by + let f : Projectivization K W → {a : Projectivization K V // a.submodule ≤ W} := + fun a => ⟨Projectivization.map W.subtype W.injective_subtype a, by + induction a using Projectivization.ind with + | h v hv => + rw [Projectivization.map_mk, Projectivization.submodule_mk, + Submodule.span_singleton_le_iff_mem] + exact v.property⟩ + apply Equiv.ofBijective f + constructor + · intro a b h + exact Projectivization.map_injective W.subtype W.injective_subtype + (congrArg Subtype.val h) + · rintro ⟨a, ha⟩ + have hmem : a.rep ∈ W := ha (by + rw [Projectivization.submodule_eq] + exact Submodule.mem_span_singleton_self _) + let v : W := ⟨a.rep, hmem⟩ + have hv : v ≠ 0 := fun h => a.rep_nonzero (congrArg Subtype.val h) + refine ⟨Projectivization.mk K v hv, ?_⟩ + apply Subtype.ext + exact a.mk_rep + +end SharpLogRamsey.Incidence + +namespace SharpLogRamsey.Selection +open SharpLogRamsey.Incidence +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] +variable [Finite K] [FiniteDimensional K V] [Fintype (Projectivization K V)] + +omit [FiniteDimensional K V] in + +theorem card_projective_subspace (W : Submodule K V) : + Fintype.card {a : Projectivization K V // a.submodule ≤ W} = + ∑ i ∈ Finset.range (Module.finrank K W), Nat.card K ^ i := by + rw [← Nat.card_eq_fintype_card, + ← Nat.card_congr (projectiveSubmoduleEquiv W)] + exact Projectivization.card_of_finrank K W rfl + +omit [FiniteDimensional K V] in + +theorem Law.subspace_mass_bound (p : Law (Projectivization K V)) + (W : Submodule K V) (E : Finset (Projectivization K V)) {c : ℝ} + (hc : 0 ≤ c) (hE : ∀ a ∈ E, a.submodule ≤ W) + (hcap : ∀ a ∈ E, p.mass a ≤ c) : + p.event E ≤ c * ∑ i ∈ Finset.range (Module.finrank K W), (Nat.card K : ℝ)^i := by + have hcard : E.card ≤ Fintype.card {a : Projectivization K V // a.submodule ≤ W} := by + rw [Fintype.card_subtype] + apply card_le_card + intro a ha + exact mem_filter.mpr ⟨mem_univ _,hE a ha⟩ + calc + p.event E ≤ ∑ _a ∈ E, c := sum_le_sum hcap + _ = c*E.card := by simp [mul_comm] + _ ≤ c * (Fintype.card {a : Projectivization K V // a.submodule ≤ W} : ℝ) := + mul_le_mul_of_nonneg_left (by exact_mod_cast hcard) hc + _ = _ := by rw [card_projective_subspace]; simp + +theorem sum_powers_le_twice {q : ℝ} (hq : 2 ≤ q) {n : ℕ} (hn : 0 < n) : + ∑ i ∈ Finset.range n, q^i ≤ 2*q^(n-1) := by + obtain ⟨m,rfl⟩ := Nat.exists_eq_succ_of_ne_zero (Nat.ne_of_gt hn) + simp only [Nat.succ_sub_one] + clear hn + induction m with + | zero => simp + | succ m ih => + rw [sum_range_succ] + have hp : 0 ≤ q^m := pow_nonneg (by linarith) _ + have hmul : 2*q^m ≤ q^(m+1) := by + rw [pow_succ] + nlinarith + calc + _ ≤ 2*q^m+q^(m+1) := by + simp only [Nat.succ_eq_add_one] at ih + linarith + _ ≤ 2*q^(m+1) := by linarith + +omit [FiniteDimensional K V] in + +theorem Law.subspace_rank_pos (p : Law (Projectivization K V)) + (W : Submodule K V) (E : Finset (Projectivization K V)) {c γ : ℝ} + (hc : 0 ≤ c) (hγ : 0 < γ) (hmass : γ ≤ p.event E) + (hE : ∀ a ∈ E, a.submodule ≤ W) + (hcap : ∀ a ∈ E, p.mass a ≤ c) : 0 < Module.finrank K W := by + have h := p.subspace_mass_bound W E hc hE hcap + by_contra hn + have hz : Module.finrank K W = 0 := by omega + simp only [hz,range_zero,sum_empty,mul_zero] at h + linarith + +omit [FiniteDimensional K V] in + +theorem Law.subspace_mass_le_pow (p : Law (Projectivization K V)) + (W : Submodule K V) (E : Finset (Projectivization K V)) {c γ : ℝ} + (hc : 0 ≤ c) (hγ : 0 < γ) (hmass : γ ≤ p.event E) + (hE : ∀ a ∈ E, a.submodule ≤ W) + (hcap : ∀ a ∈ E, p.mass a ≤ c) : + γ ≤ 2*c*(Nat.card K : ℝ)^(Module.finrank K W-1) := by + have hr := p.subspace_rank_pos W E hc hγ hmass hE hcap + have hq : (2 : ℝ) ≤ Nat.card K := by + exact_mod_cast (Finite.one_lt_card (α:=K)) + calc + γ ≤ p.event E := hmass + _ ≤ c * ∑ i ∈ range (Module.finrank K W), (Nat.card K : ℝ)^i := + p.subspace_mass_bound W E hc hE hcap + _ ≤ c*(2*(Nat.card K : ℝ)^(Module.finrank K W-1)) := + mul_le_mul_of_nonneg_left (sum_powers_le_twice hq hr) hc + _ = _ := by ring + +end SharpLogRamsey.Selection +namespace SharpLogRamsey.Selection +variable {α β : Type*} [Fintype α] [Fintype β] + +theorem Law.small_atoms (p : Law α) (S : Finset α) + (hs : ∀ a, a ∉ S → p.mass a = 0) {c : ℝ} (hc : 0 ≤ c) : + p.event (univ.filter (fun a => p.mass a < c)) ≤ S.card*c := by + have h (a : α) : (if p.mass a < c then p.mass a else 0) ≤ + if a ∈ S then c else 0 := by + by_cases ha : a ∈ S + · rw [ite_eq_left ha]; split_ifs <;> linarith + · rw [ite_eq_right ha,hs a ha]; split_ifs <;> rfl + have hh := sum_le_sum fun a (_ : a ∈ univ) => h a + simpa [Law.event, sum_filter] using hh + +theorem negative_log_part (p : Law α) (S : Finset α) + (hs : ∀ a, a ∉ S → p.mass a = 0) (L : ℝ) : + (∑ a, p.mass a*max (-(Real.log (p.mass a)+L)) 0) ≤ S.card*Real.exp (-L) := by + have pointwise (a : α) : p.mass a*max (-(Real.log (p.mass a)+L)) 0 ≤ + if a ∈ S then Real.exp (-L) else 0 := by + by_cases ha : a ∈ S + · rw [ite_eq_left ha] + by_cases hp : p.mass a = 0 + · simp [hp,Real.exp_nonneg] + have hp0 : 0 < p.mass a := lt_of_le_of_ne (p.nonneg a) (Ne.symm hp) + by_cases hz : 0 ≤ -(Real.log (p.mass a)+L) + · rw [max_eq_left hz] + have hh := mul_log_div_ge (p.nonneg a) (Real.exp_nonneg (-L)) + (fun h => False.elim ((Real.exp_ne_zero _) h)) + rw [Real.log_div hp (Real.exp_ne_zero _),Real.log_exp] at hh + nlinarith + · rw [max_eq_right (le_of_not_ge hz),mul_zero] + exact Real.exp_nonneg _ + · rw [ite_eq_right ha,hs a ha,zero_mul] + have h := sum_le_sum fun a (_ : a ∈ univ) => pointwise a + simpa using h + +theorem positive_log_part (p : Law α) (S : Finset α) + (hs : ∀ a, a ∉ S → p.mass a = 0) (L : ℝ) : + (∑ a, p.mass a*max (Real.log (p.mass a)+L) 0) ≤ + L-entropy p+S.card*Real.exp (-L) := by + have pointwise (a : α) : p.mass a*max (Real.log (p.mass a)+L) 0 = + p.mass a*(Real.log (p.mass a)+L)+ + p.mass a*max (-(Real.log (p.mass a)+L)) 0 := by + by_cases h : 0 ≤ Real.log (p.mass a)+L + · rw [max_eq_left h,max_eq_right (by linarith)]; ring + · rw [max_eq_right (le_of_not_ge h),max_eq_left (by linarith)]; ring + simp_rw [pointwise,sum_add_distrib,mul_add,sum_add_distrib,← sum_mul,p.total,one_mul] + have h := negative_log_part p S hs L + unfold entropy + linarith + +theorem Law.heavy_atoms (p : Law α) (S : Finset α) + (hs : ∀ a, a ∉ S → p.mass a = 0) (L : ℝ) {K : ℝ} (hK : 0 < K) : + p.event (univ.filter (fun a => Real.exp (K-L) < p.mass a)) ≤ + (L-entropy p+S.card*Real.exp (-L))/K := by + apply (le_div_iff₀ hK).mpr + have h (a : α) : (if Real.exp (K-L) < p.mass a then p.mass a else 0)*K ≤ + p.mass a*max (Real.log (p.mass a)+L) 0 := by + by_cases ha : Real.exp (K-L) < p.mass a + · rw [ite_eq_left ha] + have hp : 0 < p.mass a := (Real.exp_pos _).trans ha + have hh := Real.log_lt_log (Real.exp_pos (K-L)) ha + rw [Real.log_exp] at hh + have hle : K ≤ max (Real.log (p.mass a)+L) 0 := + (by linarith : K ≤ Real.log (p.mass a)+L).trans (le_max_left _ _) + exact mul_le_mul_of_nonneg_left hle (p.nonneg a) + · rw [ite_eq_right ha,zero_mul] + exact mul_nonneg (p.nonneg _) (le_max_right _ _) + have hh := (sum_le_sum fun a (_ : a ∈ univ) => h a).trans (positive_log_part p S hs L) + simpa only [Law.event,sum_filter,sum_mul] using hh + +theorem Law.bad_conditional_mass (p : Law (α × β)) (E : Finset (α × β)) + {ρ : ℝ} (hρ : 0 < ρ) : + p.snd.event (univ.filter (fun b => + ρ < (p.condFst b).event (univ.filter (fun a => (a,b) ∈ E)))) ≤ p.event E/ρ := by + apply (le_div_iff₀ hρ).mpr + have hh (b : β) : + (if ρ < (p.condFst b).event (univ.filter (fun a => (a,b) ∈ E)) + then p.snd.mass b else 0)*ρ ≤ ∑ a, if (a,b) ∈ E then p.mass (a,b) else 0 := by + have he : p.snd.mass b*((p.condFst b).event (univ.filter (fun a => (a,b) ∈ E))) = + ∑ a, if (a,b) ∈ E then p.mass (a,b) else 0 := by + simp only [Law.event,sum_filter,mul_sum,mul_ite,mul_zero,p.snd_mul_condFst] + rw [← he] + split_ifs with h + · exact mul_le_mul_of_nonneg_left h.le (p.snd.nonneg b) + · rw [zero_mul] + exact mul_nonneg (p.snd.nonneg b) ((p.condFst b).event_nonneg _) + have h := sum_le_sum fun b (_ : b ∈ univ) => hh b + have he : (∑ z, if z ∈ E then p.mass z else 0) = p.event E := by + rw [← sum_filter] + simp [Law.event] + change (∑ b with ρ < (p.condFst b).event (univ.filter (fun a => (a,b) ∈ E)), p.snd.mass b)*ρ ≤ _ + rw [sum_filter,sum_mul,← he,Fintype.sum_prod_type,sum_comm] + exact h + +end SharpLogRamsey.Selection +namespace SharpLogRamsey.Selection +open scoped BigOperators Classical +open Finset +noncomputable section +variable {A B C D : Type*} [Fintype A] [Fintype B] [Fintype C] [Fintype D] + +def Law.condSnd (p : Law (A × B)) (a : A) : Law B := + (p.cond Prod.fst a).map Prod.snd + +lemma Law.fst_mul_condSnd (p : Law (A × B)) (a : A) (b : B) : + p.fst.mass a*(p.condSnd a).mass b = p.mass (a,b) := by + have h := p.cond_map_weight Prod.fst Prod.snd a b + rw [Law.map_fst] at h + change p.fst.mass a*((p.cond Prod.fst a).map Prod.snd).mass b = _ + rw [h] + simp [Law.map, Fintype.sum_prod_type, sum_filter, Prod.mk.injEq, and_comm, ite_and] + +lemma Law.condSnd_mass (p : Law (A × B)) (a : A) (ha : p.fst.mass a ≠ 0) (b : B) : + (p.condSnd a).mass b = p.mass (a,b)/p.fst.mass a := by + apply (eq_div_iff ha).mpr + rw [mul_comm, p.fst_mul_condSnd] + +lemma Law.paired_cond_mass (p : Law (A × B)) (q : Law (C × D)) + (a : A) (b : B) (c : C) (y : D) (v : ℝ) : + (p.fst.mass a*q.snd.mass y)* + (((p.condSnd a).mass b*(q.condFst y).mass c)*v) = + (p.mass (a,b)*q.mass (c,y))*v := by + calc + _ = (p.fst.mass a*(p.condSnd a).mass b)* + (q.snd.mass y*(q.condFst y).mass c)*v := by ring + _ = _ := by rw [p.fst_mul_condSnd,q.snd_mul_condFst] + +lemma Law.product_disintegration (p : Law (A × B)) (q : Law (C × D)) + (F : (A × B) → (C × D) → ℝ) : + (∑ z : (A × B) × (C × D), (p.prod q).mass z * F z.1 z.2) = + ∑ ay : A × D, (p.fst.prod q.snd).mass ay * + ∑ bc : B × C, ((p.condSnd ay.1).prod (q.condFst ay.2)).mass bc * + F (ay.1,bc.1) (bc.2,ay.2) := by + simp only [Law.prod, Fintype.sum_prod_type, mul_sum] + simp_rw [p.paired_cond_mass q] + apply sum_congr rfl + intro a _ + calc + _ = ∑ b : B, ∑ y : D, ∑ c : C, p.mass (a,b)*q.mass (c,y)*F (a,b) (c,y) := by + apply sum_congr rfl + intro b _ + exact sum_comm + _ = _ := sum_comm + +lemma Law.product_event_disintegration (p : Law (A × B)) (q : Law (C × D)) + (E : (A × B) → (C × D) → Prop) : + (p.prod q).event (univ.filter (fun z => E z.1 z.2)) = + ∑ ay : A × D, (p.fst.prod q.snd).mass ay * + ((p.condSnd ay.1).prod (q.condFst ay.2)).event + (univ.filter (fun bc : B × C => E (ay.1,bc.1) (bc.2,ay.2))) := by + simpa only [Law.event, sum_filter, mul_ite, mul_one, mul_zero] using + p.product_disintegration q (fun ab cy => if E ab cy then 1 else 0) + +end +end SharpLogRamsey.Selection + +namespace SharpLogRamsey.Selection +open scoped BigOperators Classical +open Finset +noncomputable section +variable {A B : Type*} [Fintype A] [Fintype B] + +end +end SharpLogRamsey.Selection +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalDomains.lean b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalDomains.lean new file mode 100644 index 0000000000000000000000000000000000000000..24c00ad3d4bd09dc6cb09f099a9a1d7594c0fa8e --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalDomains.lean @@ -0,0 +1,81 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Entropy.ReciprocalEntropy +import OAI.Combinatorics.SharpRamsey.Execution.ExecutedDecodedSize + +namespace OAI + +section +namespace SharpLogRamsey.ActualPivot +open Finset Real Incidence Validation ScheduledBanks PublicTables ReadyTests + PivotGeometry ProjectiveDuality TreeDecoder FreshExecution ExecutedPotential +open scoped Classical BigOperators +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] + {I : Type*} {n : ℕ} {b τ P H : ℝ} + +omit [Finite K] [FiniteDimensional K V] [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma chronoFlagDomain_card (U : ChronoDomains (K:=K) (V:=V)) : + (flagDomain (fun y x=>SharpLogRamsey.Incidence.Incident x y) U).card= + incidenceCount U.2 U.1 := by + simp only [flagDomain,incidenceCount,card_eq_sum_ones,sum_filter,sum_product] + +omit [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +theorem reciprocal_flagDomain_size (hdim : Module.finrank K V=n+3) (hb : 0≤b) + (U : ChronoDomains (K:=K) (V:=V)) + (S : Finset (Projectivization K (Module.Dual K V))) (T : Finset (Projectivization K V)) + (hS : S.Nonempty) (hT : T.Nonempty) + (hprod : (Nat.card K:ℝ)^(n+3)*exp (-b)≤(S.card:ℝ)*T.card) + (hA : (U.1.card:ℝ)≤2000*(Nat.card K:ℝ)^(n+3)/T.card) + (hB : (U.2.card:ℝ)≤2000*(Nat.card K:ℝ)^(n+3)/S.card) : + ((flagDomain (fun y x=>SharpLogRamsey.Incidence.Incident x y) U).card:ℝ)≤ + 8000000*(Nat.card K:ℝ)^(n+2)*exp b := by + have hq : (0:ℝ)True) U S T hS hT + ((Nat.card K:ℝ)^(n+3)) 2000 b (by positivity) (by norm_num) hprod hA hB + have hcap : (U.2.card:ℝ)*U.1.card≤(2000^2*exp b)*(Nat.card K:ℝ)^(n+3)*(1:ℝ)^2 := by + have hp' : (U.1.card:ℝ)*U.2.card≤2000^2*(Nat.card K:ℝ)^(n+3)*exp b := by + simpa only [flagDomain,filter_true,card_product,Nat.cast_mul] using hp + calc + _ = (U.1.card:ℝ)*U.2.card := by ring + _ ≤ _ := hp' + _ = _ := by ring + have hB' : 1≤(2000:ℝ)^2*exp b := by nlinarith [one_le_exp hb] + have hm := mixing_cell_scale hdim U.2 U.1 hB' (by norm_num : (0:ℝ)≤1) le_rfl hcap + rw [chronoFlagDomain_card] + convert hm using 1 + ring + +variable (hdim : Module.finrank K V=n+3) + (book : Book (K:=K) (V:=V) (Nat.card K) b τ P H (n+3)) + (hb : 0≤b) (hτ : 0≤τ) (hτsmall : τ≤1/40000) +include hb + +theorem Book.actual_decoded_size (s : I→Original (K:=K) (V:=V) n b) + (z : I→Banks (K:=K) (V:=V) b) + (targets : I→List (Projectivization K (Module.Dual K V)×Projectivization K V)) + (counts : I→ℕ) (t : BinaryTree I) (U : ChronoDomains (K:=K) (V:=V)) : + let rd := fixedRead (fun _i : I=>chronoRead (K:=K) (V:=V) b) z + let ch := fixedChoose (fun i=>book.chronoChoose hdim hτ hτsmall (s i)) z + ∀ D∈decode (fun y x=>SharpLogRamsey.Incidence.Incident x y) rd + (message (fun y x=>SharpLogRamsey.Incidence.Incident x y) rd targets counts (execute rd ch t U) U) U, + (D.card:ℝ)≤8000000*(Nat.card K:ℝ)^(n+2)*exp b := by + apply decoded_domains_size + intro i U c hc + obtain ⟨x,hx,rfl⟩:=Option.map_eq_some_iff.mp hc + have hh:=book.choose_caps hdim hτ hτsmall (s i) U.swap (z i) x hx + apply reciprocal_flagDomain_size hdim hb _ (s i).B (s i).A (s i).nonemptyB (s i).nonemptyA + · simpa only [mul_comm] using (s i).product + · exact hh.2.2.2.2.2 + · exact hh.2.2.2.2.1 + +end +end SharpLogRamsey.ActualPivot + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalMarginals.lean b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalMarginals.lean new file mode 100644 index 0000000000000000000000000000000000000000..88f09b07e4001105ee459daf29abf9c838b6cf44 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalMarginals.lean @@ -0,0 +1,86 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Parameters.EndpointScales + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset Real Filter +open scoped Classical BigOperators Topology +noncomputable section + +lemma Law.map_image_support {A B : Type*} [Fintype A] [Fintype B] + (p : Law A) (S : Finset A) (f : A→B) + (hS : ∀ a,a∉S→p.mass a=0) : + ∀ b,b∉S.image f→(p.map f).mass b=0 := by + intro b hb + by_contra he + obtain ⟨a,ha,rfl⟩:=p.map_support f b he + exact hb (mem_image.mpr ⟨a,by by_contra h; exact ha (hS a h),rfl⟩) + +lemma reciprocal_source_scales {σ β D : ℝ} (hσ : 0<σ) (hD : σ^β≤D) : + σ^(4*β)≤D*σ^(3*β) ∧ D*σ^β≤(D*σ^(3*β))*σ^(-2*β) := by + constructor + · calc + _ = σ^β*σ^(3*β) := by rw [←rpow_add hσ]; congr 1; ring + _ ≤ _ := mul_le_mul_of_nonneg_right hD (rpow_nonneg hσ.le _) + · rw [mul_assoc,←rpow_add hσ,show 3*β+-2*β=β by ring] + +theorem eventually_actual_reciprocal (n : ℕ) (β : ℝ) (hβ : 0<β) : + ∀ᶠ σ : ℝ in atTop, ∀ (K V : Type) [Field K] [AddCommGroup V] [Module K V] + [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K V))], + Module.finrank K V=n+3 → log (Nat.card K)=σ → + ∀ (p : Law (Projectivization K (Module.Dual K V)×Projectivization K V)) + (S : Finset (Projectivization K (Module.Dual K V)×Projectivization K V)) (D u : ℝ), + (∀ a,a∉S→p.mass a=0) → + (∀ a,0¬goodFirst p MA L κ (1/50) a))≤3251*σ^(-2*β) ∧ + p.snd.event (univ.filter (fun b=>¬goodSecond p MB L κ (1/50) b))≤3251*σ^(-2*β) := by + filter_upwards [eventually_reciprocal_auxiliary_choices n β (1024^2) 64 hβ + (by norm_num) (by norm_num),eventually_ge_atTop (1:ℝ)] with σ he hσ + intro K V _ _ _ _ _ _ _ hdim hlog p S D u hs hf hA hB hS hD hdef + have hσ0 : 0<σ := by linarith + have hq : (0:ℝ) + (covectorTuple (F x) (finProdFinEquiv i))∈ + orthogonalRectangle Projectivization.rep Projectivization.rep W)).card:ℝ)≤M + else c*σ^(1+η/2)≤(w:ℝ)*D) → + Nonempty (Fin w) → + Nonempty (ContextOutput p F (w*(n+k)) (8000000*(Nat.card K:ℝ)^(d+2)*exp b) + (reciprocalOutputCost (K:=K) (V:=V) (I:=Fin w) (d:=d) (b:=b) (P:=P) (H:=H) + w (Nat.log 2 w+1) (2*(n+k))) 2) := by + filter_upwards [eventually_integer_output d η C A C0 c hη hC hC0 hc, + eventually_open_output d η C A C0 c hη hC hC0 hc] with σ hi ho + intro K V _ _ _ _ _ _ _ _ hdim hlog D P H hDl hDu + dsimp only + intro book hb hH hP haP hτ hτsmall Ω Θ _ _ w n k p θ F S integer r J M budget hn hk hkn hw hJ hM hSJ hS hf hcon hclass hsize hbudget hb0 hk0 hcase hne + obtain ⟨fallback⟩:=hne + have hN : 0windowTuple (covectorTuple (F x)) + let T:=fun z (i : Slot w (n+k))=>covectorDomain (S z (finProdFinEquiv i)) + let u':=fun z (i : Slot w (n+k))=>u z (finProdFinEquiv i) + have hG : ∀ x,p.mass x≠0→∀ i,G x i∈T (θ x) i := by + intro x hx i + exact (covectorDomain_mem _ _).mpr (hS x hx _) + have hT : ∀ z i,log (T z i).card≤J := by + intro z i + simpa only [T,covectorDomain_card] using hSJ z (finProdFinEquiv i) + have hflag : ∀ x,p.mass x≠0→∀ i,(G x i).1.rep (G x i).2.rep=0 := by + intro x hx i + exact covectorTuple_flag (F x) (hf x hx) _ + have hchron : ∀ x,p.mass x≠0→∀ i j,position i congr! + have hout : Nonempty (ContextOutput p (fun x=>flattenTuple (G x)) (w*(n+k)) + (8000000*(Nat.card K:ℝ)^(d+2)*exp (16*scaleKstar σ η D)) + (reciprocalOutputCost (K:=K) (V:=V) (I:=Fin w) (d:=d) (b:=16*scaleKstar σ η D) (P:=P) (H:=H) + w (Nat.log 2 w+1) (2*(n+k))) 2) := by + cases integer + · simp only [Bool.false_eq_true,ite_false] at hr hu hcase + exact ho K V hdim hlog D P H hDl hDu book hb hH hP haP hτ hτsmall Ω Θ w n k p θ G T u' + (d+4-r.val) J budget hn hk hkn hw hcase (by omega) hJ hT hG hflag hchron hcap + (by intro x hx i;simpa only [u',hlog] using (hu x hx (finProdFinEquiv i)).2.2) + hbud hb0 hk0 fallback + · simp only [ite_true] at hr hu hcase + exact hi K V hdim hlog D P H hDl hDu book hb hH hP haP hτ hτsmall Ω Θ w n k p θ G T u' + (d+3-r.val) J M budget hn hk hkn hw (by omega) hJ hM hT hG hflag hchron hcap + (by intro x hx i;simpa only [u',hlog] using (hu x hx (finProdFinEquiv i)).2.2) + hcase.2.2 hbud hb0 hcase.1 hk0 hcase.2.1 fallback + obtain ⟨e⟩:=hout + exact ⟨e.transport (Equiv.prodComm _ _) F (fun _=>(OrderIso.refl _).toOrderEmbedding) (by + intro x i + simp only [G,flatten_window,covectorTuple,Equiv.prodComm_apply,Prod.swap_swap, + OrderIso.coe_toOrderEmbedding,OrderIso.refl_apply])⟩ +end +end SharpLogRamsey.Marking + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalOutput.lean b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalOutput.lean new file mode 100644 index 0000000000000000000000000000000000000000..c4b959b3d4d443f4fc8f4b7cce30aee6060d6b34 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalOutput.lean @@ -0,0 +1,79 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.ContextOutput + +namespace OAI + +section +namespace SharpLogRamsey.ActualPivot +open Finset Real Selection TreeDecoder FreshExecution BinaryTree ExecutedPotential +open scoped Classical BigOperators +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V))) ] + {I X Ω : Type} [Fintype I] [Fintype X] [Fintype Ω] + {d ℓ : ℕ} {b τ P H : ℝ} +local instance outEqI : DecidableEq I := Classical.decEq _ +local instance outBanks : Fintype (Banks (K:=K) (V:=V) b) := inferInstance + +def reciprocalOutputCost (W ht m : ℕ) : ℝ := + ((2*W+1:ℕ):ℝ)*log 2+ + (W:ℝ)*(log ((Fintype.card I:ℝ)+1)+headerCost (K:=K) (V:=V)+log (m+1:ℕ))+ + (2*(H+22)*(Nat.card K:ℝ)*P)* + ((ht:ℝ)*(potential ((Nat.card K:ℝ)^(d+3)) ((univ,univ) : ChronoDomains (K:=K) (V:=V))+(W:ℝ)*(b+log 4+2*log 2000))+(W:ℝ)*P) + +theorem Book.context_output (hdim : Module.finrank K V=d+3) + (book : Book (K:=K) (V:=V) (Nat.card K) b τ P H (d+3)) + (hb : 0≤b) (hH : 0≤H) (hP : 4≤P) (haP : b+log 1000000≤P) + (hτ : 0≤τ) (hτsmall : τ≤1/40000) + (p : Law Ω) (G : Ω→Fin ℓ→Flag (K:=K) (V:=V)) (μ : Law X) (source : X→Ω) + (hmarginal : μ.map source=p) + (s : X→I→Original (K:=K) (V:=V) d b) + (targets : X→I→List (Flag (K:=K) (V:=V))) (t : X→BinaryTree I) + (N W ht m : ℕ) (hN : 0banksLaw (K:=K) (V:=V) b)).mass z* + ∑ x,μ.mass x*((N:ℝ)- + (fullOutput (fun y x=>SharpLogRamsey.Incidence.Incident x y) + (fun i=>book.chronoChoose hdim hτ hτsmall (s x i)) + (fun _=>chronoRead b) (targets x) z (t x) (univ,univ)).length))≤(N:ℝ)/4) : + Nonempty (ContextOutput p G (N/2) (8000000*(Nat.card K:ℝ)^(d+2)*exp b) + (reciprocalOutputCost (K:=K) (V:=V) (I:=I) (d:=d) (b:=b) (P:=P) (H:=H) W ht m) 2) := by + obtain ⟨z,hE,hprob,hdom,hextract,hdomains,hcost⟩:=book.actual_replacement hdim hb hH hP haP hτ hτsmall + μ s targets t (univ,univ) N W ht m hN hsize hnodes hheight hcounts + (fun _ _=>True) (by intro x hx;exact List.pairwise_of_forall (fun _ _=>trivial)) + source p.mass 1 p.nonneg (by norm_num) + (by intro a;change (μ.map source).mass a≤1*p.mass a;rw [hmarginal,one_mul]) hmean + let R:=fun (y : Projectivization K (Module.Dual K V)) (x : Projectivization K V)=>SharpLogRamsey.Incidence.Incident x y + let choose:=fun x i=>book.chronoChoose hdim hτ hτsmall (s x i) + let read:=fun _ : I=>chronoRead (K:=K) (V:=V) b + let E:=fun x=>(N:ℝ)/2≤(fullOutput R (choose x) read (targets x) z (t x) (univ,univ)).length + let ν:=Selection.Law.ofPublic (PublicTables.conditionSuccess μ.asPublic E hE) + let M:=fun x=>fullMessage R (choose x) read (targets x) z (t x) (univ,univ) + let S:=univ.image M + let msg : X→S:=fun x=>⟨M x,mem_image.mpr ⟨x,mem_univ _,rfl⟩⟩ + let DD:=fun c : S=>(decode R (fixedRead read z) c.val (univ,univ)).take (N/2) + let out:=fun x=>(fullOutput R (choose x) read (targets x) z (t x) (univ,univ)).take (N/2) + apply contextOutput_of_lists p G ν source msg out DD (by positivity) + · intro x hx + exact (hextract x hx).1 + · intro x hx + have hμ : μ.mass x≠0:=(PublicTables.conditionSuccess_support μ.asPublic E hE x hx).1 + exact (hextract x hx).2.1.trans (hsub x hμ) + · intro x hx + exact (hextract x hx).2.2.2 + · exact hdomains + · intro a + have hh:=hdom a + simpa only [mul_one,Law.map] using hh + · exact hcost +end +end SharpLogRamsey.ActualPivot + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalPopulation.lean b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalPopulation.lean new file mode 100644 index 0000000000000000000000000000000000000000..290ea22f2238cb0b47d94eb3a28c11490a87f3a8 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalPopulation.lean @@ -0,0 +1,84 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Reciprocal.ReciprocalTree +import OAI.Combinatorics.SharpRamsey.Parameters.ReciprocalScales +import OAI.Combinatorics.SharpRamsey.Execution.VariableOutput + +namespace OAI + +section +namespace SharpLogRamsey.ActualPivot +open Finset Real Incidence SupportMixtures Selection Selection.AuxiliarySupport +open FreshExecution TreeDecoder BinaryTree +open scoped Classical BigOperators +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] + {I Ω : Type*} [Fintype I] [Fintype Ω] + {p : I→Law (Projectivization K (Module.Dual K V))} + {r : I→Law (Projectivization K V)} + {goodA : I→Finset (Projectivization K (Module.Dual K V))} + {goodB : I→Finset (Projectivization K V)} {MA MB κA κB : I→ℝ} +local instance flat_ActualReciprocalPopulation_1 : DecidableEq I := Classical.decEq _ +local instance populationBanksFintype (b : ℝ) : Fintype (Banks (K:=K) (V:=V) b) := inferInstance + +variable (X : ∀ i,AuxiliarySupport (p i) (goodA i) (MA i) (κA i)) + (Y : ∀ i,AuxiliarySupport (r i) (goodB i) (MB i) (κB i)) + {d : ℕ} {b τ P H : ℝ} (hdim : Module.finrank K V=d+3) + (book : Book (K:=K) (V:=V) (Nat.card K) b τ P H (d+3)) + (hτ : 0<τ) (hτsmall : τ≤1/40000) + (hMA : ∀ i,0(target ω i j).1)) (r k) (GA i j) (goodB k)≤εA) + (hmeanB : ∀ i∈labels t,∀ j,∀ k∈insert i (rightPath i t), + goodIncidence (p k) (μ.map (fun ω=>(target ω i j).2)) (goodA k) (GB i j)≤εB) + (hbadA : ∀ i∈labels t,∀ j,(∑ ω,μ.mass ω*(if (target ω i j).1∈GA i j then (0:ℝ) else 1))≤δA) + (hbadB : ∀ i∈labels t,∀ j,(∑ ω,μ.mass ω*(if (target ω i j).2∈GB i j then (0:ℝ) else 1))≤δB) : + (∑ z,(PublicTables.piLaw (fun _ : I=>banksLaw (K:=K) (V:=V) b)).mass z * + ∑ ω,(μ.prod (familyLaw X Y).nullFree).mass ω*((∑ i∈labels t,(n i:ℝ))- + (fullOutput (fun y x=>SharpLogRamsey.Incidence.Incident x y) + (fun i=>book.chronoChoose hdim hτ.le hτsmall (originalFamily X Y hMA hMB hprod ω.2 i)) + (fun _=>chronoRead b) (fun i=>List.ofFn (target ω.1 i)) z t (univ,univ)).length))≤ + (∑ i∈labels t,(n i:ℝ))*treeError (Nat.card K) τ t.height ε εA εB δA δB := by + apply original_variable_loss (μ.prod (familyLaw X Y).nullFree).asPublic + (fun _ : I=>banksLaw (K:=K) (V:=V) b) (fun y x=>SharpLogRamsey.Incidence.Incident x y) + (fun ω i=>book.chronoChoose hdim hτ.le hτsmall (originalFamily X Y hMA hMB hprod ω.2 i)) + (fun _=>chronoRead b) n (fun ω=>target ω.1) t (univ,univ) ht (fun ω=>hR ω.1) + intro i hi j + apply book.original_tree_target_loss X Y hdim hτ hτsmall hMA hMB hprod + μ i t ht hi (fun ω=>(target ω i j).1) (fun ω=>(target ω i j).2) + (GA i j) (GB i j) ε εA εB δA δB hε hεA hεB + · intro k hk l hl + exact hfirst k (plannedPath_subset i t hk) l hl + · intro k hk l hl + exact hsecond k (plannedPath_subset i t hk) l hl + · intro k hk + exact hself k (plannedPath_subset i t hk) + · exact hmeanA i hi j + · exact hmeanB i hi j + · exact hbadA i hi j + · exact hbadB i hi j + +end +end SharpLogRamsey.ActualPivot + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalPotential.lean b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalPotential.lean new file mode 100644 index 0000000000000000000000000000000000000000..4eab7c3e1bc8ab760098659ed63ea6b1b36ddeb2 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalPotential.lean @@ -0,0 +1,66 @@ +import Mathlib + +namespace OAI + +section +namespace SharpLogRamsey.ReciprocalPotential +open Real + +lemma gap_nonneg {a s : ℝ} (hs : 0 + goodFirst (p.marginal i) (P*exp (((n+3:ℕ):ℝ)*log (Nat.card K)-u)) L κ ε ay.1 ∧ + goodSecond (p.marginal j) (P*exp v) L κ ε ay.2 ∧ ay.1.rep ay.2.rep=0))≤z) + (hz : (4*exp 1)^2*z≤1/(4*(Nat.card K:ℝ))) : + v≤u+2*κ+log 64 := by + apply auxiliary_chronological_order hdim (p.marginal i).fst (p.marginal j).snd _ _ + _ _ κ u v (mul_pos (by linarith) (exp_pos _)) + (mul_pos (by linarith) (exp_pos _)) + (by simpa using mul_le_mul_of_nonneg_right hP (exp_pos (((n+3:ℕ):ℝ)*log (Nat.card K)-u)).le) + (by simpa using mul_le_mul_of_nonneg_right hP (exp_pos v).le) A B + exact (auxiliary_three_estimates p i j _ _ L κ ε z A B hevent).1.trans hz + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalStep.lean b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalStep.lean new file mode 100644 index 0000000000000000000000000000000000000000..6e2669603cf59a263337dd987dcb0cf48c81084e --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalStep.lean @@ -0,0 +1,155 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Reciprocal.ReciprocalOrdered +import OAI.Combinatorics.SharpRamsey.Windows.SuppliedBook +import OAI.Combinatorics.SharpRamsey.Exposure.RestrictionGeometry +import OAI.Combinatorics.SharpRamsey.Execution.OutputRebase +import OAI.Combinatorics.SharpRamsey.Marking.StepCost + +namespace OAI + +section +namespace SharpLogRamsey.Marking +open Finset Real Filter Selection Selection.Windows ActualPivot ReciprocalBands SourceScales +open scoped Classical BigOperators Topology +noncomputable section + + theorem eventually_reciprocal_step (i : ℕ) (η c C C0 : ℝ) + (hη : 0 < η) (hηu : η ≤ 1) (hc : 0 < c) (hC : 0 < C) (hC0 : 0 < C0) : + ∀ᶠ σ : ℝ in atTop, ∀ (q : ℕ) [Fact q.Prime], 3 ≤ q → exp σ=(q:ℝ) → + ∀ (V : Type) [AddCommGroup V] [Module (ZMod q) V] [FiniteDimensional (ZMod q) V] + [Fintype (Projectivization (ZMod q) V)] + [Fintype (Projectivization (ZMod q) (Module.Dual (ZMod q) V))] + [Fintype (Projectivization (ZMod q) (Module.Dual (ZMod q) (Module.Dual (ZMod q) V)))], + Module.finrank (ZMod q) V=i+4 → + ∀ (Ω Θ : Type) [Fintype Ω] [Fintype Θ] (m : ℕ) (p : Law Ω) (θ : Ω→Θ) + (F : Ω→Fin m→ProjectivePair (K:=ZMod q) (V:=V)) + (S : Θ→Fin m→Finset (ProjectivePair (K:=ZMod q) (V:=V))) + (D J M budget : ℝ) (R : ℕ) (integer : Bool) (r : Fin (i+4)), + Admissible σ η D R → c*(q:ℝ)*σ^(1+η) ≤ m → (m:ℝ) ≤ C*q*σ^(1+η) → + ((i+3:ℕ):ℝ)*σ ≤ J → 0 ≤ M → M ≤ C0*σ → + (∀ z j,log (S z j).card ≤ J) → + (∀ x,p.mass x≠0→∀ j,F x j∈S (θ x) j) → + (∀ x,p.mass x≠0→∀ j,Incidence.Incident (F x j).1 (F x j).2) → + (∀ x,p.mass x≠0→ScanConsistent ((List.ofFn (F x)).map toScan)) → + (∀ x,p.mass x≠0→∀ j,ValidSlotClass (i+3) (scaleKstar σ η D) (S (θ x) j) (.inl (integer,r))) → + (∀ z j,((S z j).card:ℝ) ≤ 64*(q:ℝ)^(i+3)) → + (∑ z,(p.map θ).mass z*((m:ℝ)*J-entropy ((p.cond θ z).map F))) ≤ budget → + budget ≤ C0*(m:ℝ)*D*σ^(-beta η) → + (∀ x,p.mass x≠0→∀ W : Submodule (ZMod q) V, + ((univ.filter (fun j : Fin m=>covectorTuple (F x) j∈ + orthogonalRectangle Projectivization.rep Projectivization.rep W)).card:ℝ) ≤ M) → + ∃ w m' : ℕ, 1 ≤ w ∧ (w:ℝ)*D ≤ max C 12*σ^(1+η/2) ∧ (m:ℝ)/8 ≤ m' ∧ + Nonempty (ContextOutput p F m' (8000000*(q:ℝ)^(i+3)*exp (16*scaleKstar σ η D)) + (D*σ^(-η/3)*(m:ℝ)) 2) := by + obtain ⟨H,hH,hbook⟩:=supplied_book i + let Cw:=max C 12 + let cs:=min (1/2) (c/(2*Cw)) + let a:=1+η/2 + have hCw : 0 < Cw:=hC.trans_le (le_max_left _ _) + have hcs : 0 < cs:=lt_min (by norm_num) (by dsimp only [Cw]; positivity) + filter_upwards [hbook η hη, + eventually_reciprocal_ordered (i+1) η Cw a (4*C0) cs hη hCw (by positivity) hcs, + eventually_reciprocal_windows η c C hη hηu hc hC, + eventually_reciprocal_message_cost i η c Cw H hη hc hCw hH, + eventually_ge_atTop (1:ℝ)] with σ hbk hout hwin hcost hσ + intro q _ hq he V _ _ _ _ _ _ hdim Ω Θ _ _ m p θ F S D J M budget R integer r + had hmlo hmhi hJ hM hMup hSJ hS hf hcon hclass hsize hbudget hbud hocc + have hσ0 : 0 < σ:=by linarith + have hq0 : 0 < (q:ℝ):=he ▸ exp_pos _ + have hqlog : log (Nat.card (ZMod q):ℝ)=σ:=by rw [Nat.card_zmod,←he,log_exp] + have hD : 1 ≤ D:=(one_le_rpow hσ (beta_pos hη).le).trans had.D_lower + have hD0 : 0 < D:=by linarith + obtain ⟨hb,hP,hbP,hτ,hτsmall,⟨book⟩⟩:=hbk q hq he V hdim D R had + let x:=if integer then (q:ℝ)*σ^(1+η/2) else (q:ℝ)*D*σ^(η/2) + let n:=⌈x⌉₊ + let k:=⌊(q:ℝ)*D*σ^(3000*beta η)⌋₊ + let L:=4*(n+k) + let w:=m/L + have hwindows:=hwin (q:ℝ) D m integer he had.D_lower had.D_upper hmlo hmhi + change 2 ≤ n ∧ 0 < k ∧ k ≤ n ∧ 1 ≤ w ∧ w*L ≤ m ∧ (m:ℝ)/2 ≤ (w*L:ℕ) ∧ + (1/2)*(q:ℝ)*D*σ^(3000*beta η) ≤ k ∧ + (w:ℝ)*D ≤ Cw*σ^a ∧ (w:ℝ) ≤ Cw*σ^a ∧ + (if integer then (q:ℝ)*σ^(1+η/2) ≤ (n:ℝ) else (c/(2*Cw))*σ^(1+η/2) ≤ (w:ℝ)*D) ∧ + (L:ℝ) ≤ 12*(q:ℝ)*σ^a at hwindows + obtain ⟨hn,hk,hkn,hw,hwm,hhalf,hklow,hwD,hwup,hcase,hLup⟩:=hwindows + let T : Θ→Finset (Fin m):=fun _=>prefixSet hwm + let e:=chosenOrder T hwm + let G:=orderedTuple T hwm θ F + let S':=fun z j=>S z (e z j) + have hGS : ∀ z j,log (S' z j).card ≤ J:=fun z j=>hSJ z (e z j) + have hG : ∀ x,p.mass x≠0→∀ j,G x j∈S' (θ x) j:=fun x hx j=>hS x hx (e (θ x) j) + have hgf : ∀ x,p.mass x≠0→∀ j,Incidence.Incident (G x j).1 (G x j).2:= + fun x hx j=>hf x hx (e (θ x) j) + have hgcon : ∀ x,p.mass x≠0→ScanConsistent ((List.ofFn (G x)).map toScan):= + fun x hx=>scanConsistent_ordered (F x) (hcon x hx) (e (θ x)) + have hgclass : ∀ x,p.mass x≠0→∀ j,ValidSlotClass (i+3) (scaleKstar σ η D) (S' (θ x) j) + (.inl (integer,r)):=fun x hx j=>hclass x hx (e (θ x) j) + have hgsize : ∀ z j,((S' z j).card:ℝ) ≤ 64*(Nat.card (ZMod q):ℝ)^((i+1)+2):=by + intro z j + simpa only [Nat.card_zmod] using hsize z (e z j) + have hgbud : (∑ z,(p.map θ).mass z*((w*(4*(n+k)):ℕ)*J- + entropy ((p.cond θ z).map G))) ≤ budget := + (prefix_budget hwm p θ F S J hS hSJ).trans hbudget + have hbb : budget ≤ (4*C0)*(w*(2*(n+k)):ℝ)*D*σ^(-beta η) := by + have hm : (m:ℝ) ≤ 4*(w*(2*(n+k)):ℕ):=by + push_cast at hhalf ⊢ + dsimp only [L] at hhalf + push_cast at hhalf + linarith + have hh:=mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hm hC0.le) + (mul_nonneg hD0.le (rpow_nonneg hσ0.le (-beta η))) + push_cast at hh ⊢ + nlinarith only [hbud,hh] + have hkc : cs*(Nat.card (ZMod q):ℝ)*D*σ^(3000*beta η) ≤ k := by + rw [Nat.card_zmod] + apply le_trans _ hklow + dsimp only [cs] + gcongr + exact min_le_left _ _ + have hnewcase : if integer then + M ≤ (4*C0)*σ ∧ cs*(Nat.card (ZMod q):ℝ)*σ^(1+η/2) ≤ n ∧ + ∀ x,p.mass x≠0→∀ W : Submodule (ZMod q) V, + ((univ.filter (fun j : Slot w (n+k)=>covectorTuple (G x) (finProdFinEquiv j)∈ + orthogonalRectangle Projectivization.rep Projectivization.rep W)).card:ℝ) ≤ M + else cs*σ^(1+η/2) ≤ (w:ℝ)*D := by + cases integer + · simp only [Bool.false_eq_true,ite_false] at hcase ⊢ + exact (mul_le_mul_of_nonneg_right (min_le_right _ _) (rpow_nonneg hσ0.le _)).trans hcase + · simp only [ite_true] at hcase ⊢ + refine ⟨by nlinarith,?_,?_⟩ + · rw [Nat.card_zmod] + have hc1 : cs ≤ 1:=(min_le_left _ _).trans (by norm_num) + calc + _ ≤ (q:ℝ)*σ^(1+η/2) := by + calc + _ = cs*((q:ℝ)*σ^(1+η/2)) := by ring + _ ≤ 1*((q:ℝ)*σ^(1+η/2)) := mul_le_mul_of_nonneg_right hc1 (by positivity) + _ = _ := one_mul _ + _ ≤ _:=hcase + · intro z hz W + let ee : Slot w (n+k)↪Fin m:=finProdFinEquiv.toEmbedding.trans (e (θ z)).toEmbedding + have hh:=count_injective_restriction ee (fun j=>covectorTuple (F z) j∈ + orthogonalRectangle Projectivization.rep Projectivization.rep W) + apply le_trans _ (hocc z hz W) + have heq : ∀ j,covectorTuple (G z) (finProdFinEquiv j)=covectorTuple (F z) (ee j) := fun _=>rfl + simp_rw [heq] + convert (Nat.cast_le (α:=ℝ)).mpr hh using 1 <;> congr! + have hne : Nonempty (Fin w):=⟨⟨0,by omega⟩⟩ + obtain ⟨out⟩:=hout (ZMod q) V hdim hqlog D (scaleP σ η D R) H had.D_lower had.D_upper + book hb hH hP hbP hτ hτsmall Ω Θ w n k p θ G S' integer r J M budget hn hk hkn hwup + hJ hM hGS hG hgf hgcon hgclass hgsize hgbud hbb hkc hnewcase hne + have hfinalcost:=hcost q he V hdim D R w n k m had hw hmlo hwD hwup + (hLup.trans (by dsimp only [Cw];gcongr;exact le_max_right _ _)) hP hbP + have out' := out.mono (le_refl _) hfinalcost (le_refl 2) + have final:=out'.transport (Equiv.refl _) F (fun z=>e (θ z)) (fun _ _=>rfl) + refine ⟨w,w*(n+k),hw,hwD,?_,?_⟩ + · dsimp only [L] at hhalf + push_cast at hhalf ⊢ + linarith + · simpa only [Nat.card_zmod] using Nonempty.intro final +end +end SharpLogRamsey.Marking + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalTree.lean b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalTree.lean new file mode 100644 index 0000000000000000000000000000000000000000..ceff085faf0074d554f1affd219bf7c8931696cd --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/ReciprocalTree.lean @@ -0,0 +1,111 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Selection.OriginalFamilies + +namespace OAI + +section +namespace SharpLogRamsey.ActualPivot +open Finset Real Incidence SupportMixtures Selection Selection.AuxiliarySupport +open FreshExecution TreeDecoder BinaryTree +open scoped Classical BigOperators +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] + {I Ω : Type*} [Fintype I] [Fintype Ω] + {p : I→Law (Projectivization K (Module.Dual K V))} + {r : I→Law (Projectivization K V)} + {goodA : I→Finset (Projectivization K (Module.Dual K V))} + {goodB : I→Finset (Projectivization K V)} {MA MB κA κB : I→ℝ} + +local instance reciprocalBanksFintype (b : ℝ) : Fintype (Banks (K:=K) (V:=V) b) := inferInstance + +def goodIncidence (p : Law (Projectivization K (Module.Dual K V))) + (r : Law (Projectivization K V)) + (A : Finset (Projectivization K (Module.Dual K V))) (B : Finset (Projectivization K V)) : ℝ := + (p.prod r).event (univ.filter (fun ay=>ay.1∈A ∧ ay.2∈B ∧ ay.1.rep ay.2.rep=0)) + +variable (X : ∀ i,AuxiliarySupport (p i) (goodA i) (MA i) (κA i)) + (Y : ∀ i,AuxiliarySupport (r i) (goodB i) (MB i) (κB i)) + {n : ℕ} {b τ P H : ℝ} (hdim : Module.finrank K V=n+3) + (book : Book (K:=K) (V:=V) (Nat.card K) b τ P H (n+3)) + (hτ : 0<τ) (hτsmall : τ≤1/40000) + (hMA : ∀ i,0banksLaw (K:=K) (V:=V) b)).mass z * + targetFailure + (fun i=>book.chronoChoose hdim hτ.le hτsmall (originalFamily X Y hMA hMB hprod ω.2 i)) + (fun _=>chronoRead b) (a ω.1) (c ω.1) target t (univ,univ) z))≤ + 20*(12*(Nat.card K:ℝ)*((4*exp 1)*(4*exp 1)*ε))*t.height^2+ + ((Nat.card K:ℝ)*((4*exp 1)*(4*exp 1)*ε)/τ+2*exp (-(Nat.card K:ℝ)))*t.height+ + δA+δB+((t.height:ℝ)+1)* + (12*(Nat.card K:ℝ)*((4*exp 1)*εA)+12*(Nat.card K:ℝ)*((4*exp 1)*εB)) := by + let ν := μ.prod (familyLaw X Y).nullFree + have hdc (i j : I) : + (∑ ω,ν.mass ω * density (originalFamily X Y hMA hMB hprod ω.2 i).B + (originalFamily X Y hMA hMB hprod ω.2 j).A)≤ + (4*exp 1)*(4*exp 1)*goodIncidence (p i) (r j) (goodA i) (goodB j) := by + rw [show (∑ ω,ν.mass ω * density (originalFamily X Y hMA hMB hprod ω.2 i).B + (originalFamily X Y hMA hMB hprod ω.2 j).A)= + ∑ z,(familyLaw X Y).nullFree.mass z * density (originalFamily X Y hMA hMB hprod z i).B + (originalFamily X Y hMA hMB hprod z j).A from + μ.prod_right_sum (familyLaw X Y).nullFree + (fun z=>density (originalFamily X Y hMA hMB hprod z i).B + (originalFamily X Y hMA hMB hprod z j).A)] + exact originalFamily_density X Y hMA hMB hprod i j + exact book.target_loss hdim hτ.le hτsmall ν.asPublic + (fun ω i=>originalFamily X Y hMA hMB hprod ω.2 i) target t (univ,univ) ht hmem + (by intros; exact ⟨subset_univ _,subset_univ _⟩) + (fun ω=>a ω.1∈GA) (fun ω=>c ω.1∈GB) (fun ω=>a ω.1) (fun ω=>c ω.1) + (by simp) (by simp) hτ ((4*exp 1)*(4*exp 1)*ε) ((4*exp 1)*εA) ((4*exp 1)*εB) + δA δB (by positivity) (by positivity) (by positivity) + (fun i hi j hj=>(hdc i j).trans (mul_le_mul_of_nonneg_left (hfirst i hi j hj) (by positivity))) + (fun i hi j hj=>(hdc j i).trans (mul_le_mul_of_nonneg_left (hsecond i hi j hj) (by positivity))) + (fun i hi=>(hdc i i).trans (mul_le_mul_of_nonneg_left (hself i hi) (by positivity))) + (fun i hi=>(originalFamily_first_target X Y hMA hMB hprod μ a GA i).trans + (mul_le_mul_of_nonneg_left (hmeanA i hi) (by positivity))) + (fun i hi=>(originalFamily_second_target X Y hMA hMB hprod μ c GB i).trans + (mul_le_mul_of_nonneg_left (hmeanB i hi) (by positivity))) + (by + have hh := (μ.prod_left_sum (familyLaw X Y).nullFree + (fun ω=>if a ω∈GA then (0:ℝ) else 1)).le.trans hbadA + convert hh using 1 + congr 1 + funext outcome + congr 1 + by_cases hgood : a outcome.1∈GA <;> simp only [hgood,ite_true,ite_false]) + (by + have hh := (μ.prod_left_sum (familyLaw X Y).nullFree + (fun ω=>if c ω∈GB then (0:ℝ) else 1)).le.trans hbadB + convert hh using 1 + congr 1 + funext outcome + congr 1 + by_cases hgood : c outcome.1∈GB <;> simp only [hgood,ite_true,ite_false]) + +end +end SharpLogRamsey.ActualPivot + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/SourceReciprocalExposure.lean b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/SourceReciprocalExposure.lean new file mode 100644 index 0000000000000000000000000000000000000000..457a58156d6f5046dd0799fe0df262306872879d --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Reciprocal/SourceReciprocalExposure.lean @@ -0,0 +1,96 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Exposure.ExposureContexts + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical BigOperators +noncomputable section +universe u +variable {Θ Ω C ι : Type*} {A B : Type u} [Fintype Θ] [Fintype Ω] [Fintype C] + [Fintype ι] [DecidableEq ι] [Fintype A] [Fintype B] +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] + +lemma reciprocal_conditional_supported (p : Law Ω) (θ : Ω→Θ) (G : Ω→ι→A×B) + (S : Θ→ι→Finset (A×B)) + (hS : ∀ x,p.mass x≠0→∀ i,G x i∈S (θ x) i) + (z : Θ) (hz : (p.map θ).mass z≠0) : + tupleSupported ((p.cond θ z).map G) (S z) := by + intro f hf i + obtain ⟨x,hx,rfl⟩ := (p.cond θ z).map_support G f hf + obtain ⟨hx,he⟩:=p.cond_support θ z hz x hx + simpa only [he] using hS x hx i + +omit [FiniteDimensional K V] in +lemma conditional_tupleFlags (p : Law Ω) (θ : Ω→Θ) (G : Ω→ι→A×B) + (v : B→V) (w : A→Module.Dual K V) + (hf : ∀ x,p.mass x≠0→∀ i,w (G x i).1 (v (G x i).2)=0) + (z : Θ) (hz : (p.map θ).mass z≠0) : + tupleFlags ((p.cond θ z).map G) v w := by + intro f hf' i + obtain ⟨x,hx,rfl⟩ := (p.cond θ z).map_support G f hf' + exact hf x (p.cond_support θ z hz x hx).1 i + +omit [FiniteDimensional K V] in +lemma conditional_rectangleBound (p : Law Ω) (θ : Ω→Θ) (G : Ω→ι→A×B) + (v : B→V) (w : A→Module.Dual K V) (M : ℝ) + (ho : ∀ x,p.mass x≠0→∀ W : Submodule K V, + ((univ.filter (fun i=>G x i∈orthogonalRectangle v w W)).card:ℝ)≤M) + (z : Θ) (hz : (p.map θ).mass z≠0) : + rectangleBound ((p.cond θ z).map G) v w M := by + intro f hf W + obtain ⟨x,hx,rfl⟩ := (p.cond θ z).map_support G f hf + exact ho x (p.cond_support θ z hz x hx).1 W + +theorem actual_source_reciprocal (v : B→V) (w : A→Module.Dual K V) + {ρ : ℝ} (hρ : 0≤ρ) {r s : ℕ} (hsum : Module.finrank K V=r+s) + (n k : ℕ) (hn : 2≤n) (hk : 0G x i∈orthogonalRectangle v w W)).card:ℝ)≤M) + (hbudget : (∑ z,(p.map θ).mass z*((Fintype.card ι:ℝ)*J- + entropy ((p.cond θ z).map G)))≤budget) : + ∃ t : Fin k, + (∑ z,(p.map θ).mass z*chargedBad v w ρ r s n J D a k + ((p.cond θ z).map G) (e z) (own z) t)≤ + budget/D+2*budget/((k:ℝ)*a)+2*Fintype.card ι*M/((n:ℝ)*a) ∧ + (n:ℝ)*(∑ z,(p.map θ).mass z*chargedSelectedBad v w ρ r s n J D a k + ((p.cond θ z).map G) (e z) (own z) t)≤ + budget/D+2*budget/((k:ℝ)*a)+2*Fintype.card ι*M/((n:ℝ)*a) := by + have hb : contextAverage (p.map θ) (fun z=>tupleDeficit J ((p.cond θ z).map G))≤budget := hbudget + have hTC : contextAverage (p.map θ) (fun z=>totalCorrelation ((p.cond θ z).map G))≤budget := by + apply le_trans _ hb + apply contextAverage_mono + intro z hz + exact totalCorrelation_le_tupleDeficit _ J (tupleSupported_marginal_cap _ (S z) + (reciprocal_conditional_supported p θ G S hS z hz) J (hJ z)) + obtain ⟨t,ht,ht'⟩ := exists_context_good_reciprocal v w hρ hsum n k hn hk J D a M hD ha hM + (p.map θ) (fun z=>(p.cond θ z).map G) e own hown S + (reciprocal_conditional_supported p θ G S hS) hJ + (conditional_tupleFlags p θ G v w hf) (conditional_rectangleBound p θ G v w M ho) + have hscale : contextAverage (p.map θ) (fun z=>tupleDeficit J ((p.cond θ z).map G))/D+ + 2*contextAverage (p.map θ) (fun z=>totalCorrelation ((p.cond θ z).map G))/((k:ℝ)*a)+ + 2*Fintype.card ι*M/((n:ℝ)*a)≤ + budget/D+2*budget/((k:ℝ)*a)+2*Fintype.card ι*M/((n:ℝ)*a) := by + have hdenom : 0 ≤ (k : ℝ) * a := mul_nonneg (Nat.cast_nonneg k) ha.le + exact add_le_add + (add_le_add (div_le_div_of_nonneg_right hb hD.le) + (div_le_div_of_nonneg_right + (mul_le_mul_of_nonneg_left hTC (show (0 : ℝ) ≤ 2 by norm_num)) hdenom)) le_rfl + exact ⟨t,ht.trans hscale,ht'.trans hscale⟩ + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Selection/BandCharges.lean b/lean/OAI/Combinatorics/SharpRamsey/Selection/BandCharges.lean new file mode 100644 index 0000000000000000000000000000000000000000..5f0f10974b195546ca88cc24ac3a024049adaa59 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Selection/BandCharges.lean @@ -0,0 +1,130 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Reciprocal.ReciprocalBands +import OAI.Combinatorics.SharpRamsey.Reciprocal.AuxiliaryCharges + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset Real ReciprocalBands +open scoped Classical BigOperators +noncomputable section + +lemma integer_band_rank_bounds {d r : ℕ} {σ C κ gap u v : ℝ} + (hσ : 0<σ) (hC : 0 + goodFirst (p.marginal i) (C*exp (((d:ℝ)+1)*log (Nat.card K)-u)) + ((d:ℝ)*log (Nat.card K)) κ (1/50) ay.1 ∧ + goodSecond (p.marginal j) (C*exp v) + ((d:ℝ)*log (Nat.card K)) κ (1/50) ay.2 ∧ + ay.1.rep ay.2.rep=0)) ≤ (20000*((d:ℝ)+1)^2+8)*a := by + have hσ : 0 + goodFirst (p.marginal i) (C*exp (((d:ℝ)+1)*log (Nat.card K)-u)) + ((d:ℝ)*log (Nat.card K)) κ (1/50) ay.1 ∧ + goodSecond (p.marginal j) (C*exp v) + ((d:ℝ)*log (Nat.card K)) κ (1/50) ay.2 ∧ + ay.1.rep ay.2.rep=0)) ≤ (20000*((d:ℝ)+1)^2)*a := by + have hσ : 0 exact ⟨0,le_rfl,hl,by simpa [value] using hu⟩ + | succ m ih => + by_cases h : 1≤y + · exact ⟨0,Nat.zero_le _,by simpa [value] using h,by simpa [value] using hu⟩ + · have hl' : value m≤2*y := by rw [value_succ] at hl; linarith + obtain ⟨i,him,hiy,hyi⟩ := ih (2*y) hl' (by linarith) + refine ⟨i+1,Nat.succ_le_succ him,?_,?_⟩ <;> rw [value_succ] <;> linarith + +lemma sum_le_two (m : ℕ) : (∑ i∈range m,value i)≤2 := by + have he : (∑ i∈range m,value i)=2*(1-value m) := by + induction m with + | zero => simp [value] + | succ m ih => rw [sum_range_succ,ih,value_succ]; ring + rw [he] + have hp := (value_pos m).le + linarith + +lemma sum_pow_le_two (m r : ℕ) (hr : 1≤r) : + (∑ i∈range m,(value i)^r)≤2 := by + apply le_trans _ (sum_le_two m) + exact sum_le_sum (fun i _ => pow_le_of_le_one (value_pos i).le (value_le_one i) (by omega)) + +lemma value_log_le {n : ℕ} (hn : 0pow_nonneg (Nat.cast_nonneg _) _) (mem_range.mpr (by omega)) + +def emptyOriginal {n : ℕ} {b : ℝ} (hdim : Module.finrank K V=n+3) (hb : 0≤b) : + Original (K:=K) (V:=V) n b where + A := univ + B := univ + nonemptyA := by + have h:=projective_card_lower (show Module.finrank K V=(n+2)+1 by omega) + have hq : (0:ℝ) by_cases hf : x ∈ F <;> simp [he,hf,p.nonneg] + simpa only [sum_add_distrib, sum_ite_mem_eq] using + (sum_le_sum (fun x (_ : x ∈ (univ : Finset α)) => h x)) + +lemma Law.event_mono (p : Law α) {E F : Finset α} (h : E ⊆ F) : p.event E ≤ p.event F := + sum_le_sum_of_subset_of_nonneg h (fun x _ _ => p.nonneg x) + +def conditionalHeavy (p : Law (α × β)) (L K : ℝ) (b : β) : ℝ := + (p.condFst b).event (univ.filter (fun a => Real.exp (K-L) < p.mass (a,b))) + +def goodSecond (p : Law (α × β)) (M L K ρ : ℝ) (b : β) : Prop := + Real.exp (-K)/M ≤ p.snd.mass b ∧ conditionalHeavy p L K b ≤ ρ + +theorem badSecond_mass (p : Law (α × β)) (S : Finset (α × β)) + (hs : ∀ x, x ∉ S → p.mass x = 0) (D : Finset β) + (hD : ∀ b, b ∉ D → p.snd.mass b = 0) + (M L K ρ : ℝ) (hM : 0 < M) (hcard : (D.card:ℝ) ≤ M) + (hK : 0 < K) (hρ : 0 < ρ) : + p.snd.event (univ.filter (fun b => ¬goodSecond p M L K ρ b)) ≤ + Real.exp (-K)+(L-entropy p+S.card*Real.exp (-L))/(K*ρ) := by + have hsub : univ.filter (fun b => ¬goodSecond p M L K ρ b) ⊆ + univ.filter (fun b => p.snd.mass b < Real.exp (-K)/M) ∪ + univ.filter (fun b => ρ < conditionalHeavy p L K b) := by + intro b hb + simp only [mem_filter, mem_univ, true_and,goodSecond,not_and_or,not_le,mem_union] at hb ⊢ + exact hb + have hsmall := p.snd.small_atoms D hD (c := Real.exp (-K)/M) (by positivity) + have hs2 : D.card*(Real.exp (-K)/M) ≤ Real.exp (-K) := by + calc + _ ≤ M*(Real.exp (-K)/M) := mul_le_mul_of_nonneg_right hcard (by positivity) + _ = _ := by field_simp + have hheavy := p.bad_conditional_mass (univ.filter (fun x => Real.exp (K-L) < p.mass x)) hρ + have hheavy' : p.snd.event (univ.filter (fun b => ρ < conditionalHeavy p L K b)) ≤ + (L-entropy p+S.card*Real.exp (-L))/(K*ρ) := by + have he := p.heavy_atoms S hs L hK + have hh := hheavy.trans (div_le_div_of_nonneg_right he hρ.le) + convert hh using 1 <;> try rfl + · simp only [conditionalHeavy,mem_filter,mem_univ,true_and] + with_unfolding_all rfl + · rw [div_div] + exact (p.snd.event_mono hsub).trans ((p.snd.event_union_le _ _).trans + (add_le_add (hsmall.trans hs2) hheavy')) + +def goodSecondHigh (p : Law (α × β)) (M L K ρ R : ℝ) (b : β) : Prop := + goodSecond p M L K ρ b ∧ p.snd.mass b ≤ Real.exp (K-R) + +theorem badSecondHigh_mass (p : Law (α × β)) (S : Finset (α × β)) + (hs : ∀ x, x ∉ S → p.mass x = 0) (D : Finset β) + (hD : ∀ b, b ∉ D → p.snd.mass b = 0) + (M L K ρ R : ℝ) (hM : 0 < M) (hcard : (D.card:ℝ) ≤ M) + (hK : 0 < K) (hρ : 0 < ρ) : + p.snd.event (univ.filter (fun b => ¬goodSecondHigh p M L K ρ R b)) ≤ + Real.exp (-K)+(L-entropy p+S.card*Real.exp (-L))/(K*ρ)+ + (R-entropy p.snd+D.card*Real.exp (-R))/K := by + have hsub : univ.filter (fun b => ¬goodSecondHigh p M L K ρ R b) ⊆ + univ.filter (fun b => ¬goodSecond p M L K ρ b) ∪ + univ.filter (fun b => Real.exp (K-R) < p.snd.mass b) := by + intro b hb + simpa only [mem_filter,mem_univ,true_and,goodSecondHigh,not_and_or,not_le,mem_union] using hb + exact (p.snd.event_mono hsub).trans ((p.snd.event_union_le _ _).trans + (add_le_add (badSecond_mass p S hs D hD M L K ρ hM hcard hK hρ) + (p.snd.heavy_atoms D hD R hK))) +end +end SharpLogRamsey.Selection +namespace SharpLogRamsey.Selection +open Finset +open scoped BigOperators Classical +variable {α β : Type*} [Fintype α] [Fintype β] + +theorem endpoint_entropy_from_fibers (p : Law (α × β)) (D : β → Finset α) + (hD : ∀ a b, a ∉ D b → p.mass (a,b) = 0) (J : ℝ) + (hJ : ∀ b, Real.log (D b).card ≤ J) : entropy p-J ≤ entropy p.snd := by + have hh : (∑ b, p.snd.mass b*entropy (p.condFst b)) ≤ J := by + calc + _ ≤ ∑ b, p.snd.mass b*J := by + apply sum_le_sum + intro b _ + by_cases hb : p.snd.mass b = 0 + · rw [hb,zero_mul,zero_mul] + · apply mul_le_mul_of_nonneg_left _ (p.snd.nonneg b) + apply (entropy_le_log_card (p.condFst b) (D b) ?_).trans (hJ b) + intro a ha + rw [p.condFst_mass b hb,hD a b ha,zero_div] + _ = _ := by rw [← sum_mul,p.snd.total,one_mul] + rw [entropy_chain] + linarith +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Selection/EndpointSupports.lean b/lean/OAI/Combinatorics/SharpRamsey/Selection/EndpointSupports.lean new file mode 100644 index 0000000000000000000000000000000000000000..106276c84e146822be46aaeba4c777c9cb71abe9 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Selection/EndpointSupports.lean @@ -0,0 +1,172 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Reciprocal.LevelLosses +import OAI.Combinatorics.SharpRamsey.Selection.SupportIncidence + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset Real +open scoped Classical BigOperators +noncomputable section +variable {A B : Type*} [Fintype A] [Fintype B] + +def Law.swap (p : Law (A × B)) : Law (B × A) where + mass z := p.mass (z.2,z.1) + nonneg z := p.nonneg _ + total := by + rw [Fintype.sum_prod_type, sum_comm, ← Fintype.sum_prod_type] + exact p.total + +@[simp] lemma Law.swap_mass (p : Law (A × B)) (b : B) (a : A) : + p.swap.mass (b,a) = p.mass (a,b) := rfl + +@[simp] lemma Law.swap_fst (p : Law (A × B)) : p.swap.fst = p.snd := rfl + +@[simp] lemma Law.swap_snd (p : Law (A × B)) : p.swap.snd = p.fst := rfl + +lemma Law.swap_eq_map (p : Law (A × B)) : p.swap = p.map Prod.swap := by + ext ⟨b,a⟩ + exact (p.map_mass_injective Prod.swap Prod.swap_injective (a,b)).symm + +@[simp] lemma entropy_swap (p : Law (A × B)) : entropy p.swap = entropy p := by + rw [Law.swap_eq_map] + exact entropy_map_eq_of_injective p Prod.swap Prod.swap_injective + +lemma Law.swap_condFst (p : Law (A × B)) (a : A) (ha : p.fst.mass a ≠ 0) : + p.swap.condFst a = p.condSnd a := by + ext endpoint + exact (p.swap.condFst_mass a ha endpoint).trans (p.condSnd_mass a ha endpoint).symm + +lemma goodSecond_swap (p : Law (A × B)) {M : ℝ} (hM : 0 < M) + (L κ ε : ℝ) (a : A) : goodSecond p.swap M L κ ε a ↔ goodFirst p M L κ ε a := by + unfold goodSecond goodFirst conditionalHeavy + simp only [Law.swap_snd] + constructor <;> intro h + · have ha : p.fst.mass a ≠ 0 := (lt_of_lt_of_le (by positivity) h.1).ne' + rw [Law.swap_condFst p a ha] at h + exact h + · have ha : p.fst.mass a ≠ 0 := (lt_of_lt_of_le (by positivity) h.1).ne' + rw [Law.swap_condFst p a ha] + exact h + +theorem badFirst_mass (p : Law (A × B)) (S : Finset (A × B)) + (hs : ∀ x, x ∉ S → p.mass x = 0) (D : Finset A) + (hD : ∀ a, a ∉ D → p.fst.mass a = 0) + (M L κ ε : ℝ) (hM : 0 < M) (hcard : (D.card:ℝ) ≤ M) + (hκ : 0 < κ) (hε : 0 < ε) : + p.fst.event (univ.filter (fun a => ¬goodFirst p M L κ ε a)) ≤ + exp (-κ) + (L - entropy p + S.card * exp (-L)) / (κ * ε) := by + have hs' : ∀ x, x ∉ S.image Prod.swap → p.swap.mass x = 0 := by + rintro ⟨b,a⟩ hx + rw [Law.swap_mass] + apply hs + intro h + exact hx (mem_image.mpr ⟨(a,b),h,rfl⟩) + have H := badSecond_mass p.swap (S.image Prod.swap) hs' D + hD M L κ ε hM hcard hκ hε + have he : (S.image Prod.swap).card = S.card := card_image_of_injective S Prod.swap_injective + simpa only [Law.swap_snd, goodSecond_swap p hM L κ ε, entropy_swap, he] using H + +lemma levelSet_card_le_domain (p : Law A) (S : Finset A) + (hS : ∀ a, a ∉ S → p.mass a = 0) (b : Levels p) : + (levelSet p b).card ≤ S.card := by + apply card_le_card + intro a ha + by_contra hnot + have hp := (mem_filter.mp ha).2.1 + rw [hS a hnot] at hp + exact lt_irrefl _ hp + +structure AuxiliarySupport (p : Law A) (good : Finset A) (M κ : ℝ) where + law : Law (retainedLevels p good M κ) + size : ∀ b : retainedLevels p good M κ, + M * exp (-κ) / 2 ≤ ((levelSet p b ∩ good).card : ℝ) ∧ + ((levelSet p b ∩ good).card : ℝ) ≤ M + density : ∀ a, (∑ b : retainedLevels p good M κ, law.mass b * + (if a ∈ levelSet p b ∩ good then 1 / ((levelSet p b ∩ good).card : ℝ) else 0)) + ≤ 4 * exp 1 * p.mass a + +lemma auxiliarySupport_exists (p : Law A) (good : Finset A) {M κ : ℝ} + (hM : 0 < M) (hκ : 0 < κ) + (hcap : ∀ b, ((levelSet p b).card : ℝ) ≤ M) + (hbudget : (∑ b, (p.map (levelIndex p)).mass b * levelLoss p M b) / κ + + 2 * exp 1 * p.event (univ \ good) ≤ 1/2) : + Nonempty (AuxiliarySupport p good M κ) := by + obtain ⟨ρ,hsize,hρ⟩ := auxiliary_supports p good hM hκ hcap hbudget + exact ⟨⟨ρ,hsize,hρ⟩⟩ + +lemma mean_levelLoss_nonneg (p : Law A) (M : ℝ) + (hcap : ∀ b, ((levelSet p b).card : ℝ) ≤ M) : + 0 ≤ ∑ b, (p.map (levelIndex p)).mass b * levelLoss p M b := + sum_nonneg (fun b _ => mul_nonneg ((p.map (levelIndex p)).nonneg b) + (levelLoss_nonneg p b (hcap b))) + +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + +theorem reciprocal_auxiliary_choices {n : ℕ} (hdim : Module.finrank K V = n+3) + (p : Law (Projectivization K (Module.Dual K V) × Projectivization K V)) + (S : Finset (Projectivization K (Module.Dual K V) × Projectivization K V)) + (DA : Finset (Projectivization K (Module.Dual K V))) + (DB : Finset (Projectivization K V)) + (hs : ∀ z, z ∉ S → p.mass z = 0) + (hf : ∀ z, 0 < p.mass z → z.1.rep z.2.rep = 0) + (hDA : ∀ a, a ∉ DA → p.fst.mass a = 0) + (hDB : ∀ b, b ∉ DB → p.snd.mass b = 0) + (MA MB C L κ ε : ℝ) (hMA : 0 < MA) (hMB : 0 < MB) (hC : 1 ≤ C) + (hA : (DA.card : ℝ) ≤ MA) (hB : (DB.card : ℝ) ≤ MB) + (hcap : MA * MB ≤ C * (Nat.card K : ℝ)^(n+3)) + (hκ : 0 < κ) (hε : 0 < ε) + (hsmall : + (2 * (log (2*C*(Nat.card K:ℝ)^(n+2)) - entropy p + + log (entropy p.fst+2) + log (entropy p.snd+2) + 2)) / κ + + 2 * exp 1 * (exp (-κ) + (L - entropy p + S.card * exp (-L)) / (κ*ε)) ≤ 1/2) : + Nonempty (AuxiliarySupport p.fst (univ.filter (goodFirst p MA L κ ε)) MA κ) ∧ + Nonempty (AuxiliarySupport p.snd (univ.filter (goodSecond p MB L κ ε)) MB κ) := by + have hLA (b : Levels p.fst) : ((levelSet p.fst b).card : ℝ) ≤ MA := + (show ((levelSet p.fst b).card : ℝ) ≤ DA.card by + exact_mod_cast levelSet_card_le_domain p.fst DA hDA b).trans hA + have hLB (b : Levels p.snd) : ((levelSet p.snd b).card : ℝ) ≤ MB := + (show ((levelSet p.snd b).card : ℝ) ≤ DB.card by + exact_mod_cast levelSet_card_le_domain p.snd DB hDB b).trans hB + have hloss := Incidence.reciprocal_level_losses hdim p.swap + (by rintro ⟨a,b⟩ h; exact hf (b,a) (by exact h)) + hMB hMA hC (by simpa only [mul_comm MA] using hcap) + hLB hLA + rw [entropy_swap] at hloss + change (∑ b, (p.snd.map (levelIndex p.snd)).mass b * levelLoss p.snd MB b) + + (∑ b, (p.fst.map (levelIndex p.fst)).mass b * levelLoss p.fst MA b) ≤ + 2 * (log (2*C*(Nat.card K:ℝ)^(n+2)) - entropy p + + log (entropy p.snd+2) + log (entropy p.fst+2) + 2) at hloss + have hna := mean_levelLoss_nonneg p.fst MA hLA + have hnb := mean_levelLoss_nonneg p.snd MB hLB + have hbadA := badFirst_mass p S hs DA hDA MA L κ ε hMA hA hκ hε + have hbadB := badSecond_mass p S hs DB hDB MB L κ ε hMB hB hκ hε + have heA : univ \ univ.filter (goodFirst p MA L κ ε) = + univ.filter (fun a => ¬goodFirst p MA L κ ε a) := by ext; simp + have heB : univ \ univ.filter (goodSecond p MB L κ ε) = + univ.filter (fun a => ¬goodSecond p MB L κ ε a) := by ext; simp + constructor + · apply auxiliarySupport_exists p.fst _ hMA hκ hLA + rw [heA] + apply le_trans _ hsmall + apply add_le_add + · apply div_le_div_of_nonneg_right _ hκ.le + linarith + · exact mul_le_mul_of_nonneg_left hbadA (by positivity) + · apply auxiliarySupport_exists p.snd _ hMB hκ hLB + rw [heB] + apply le_trans _ hsmall + apply add_le_add + · apply div_le_div_of_nonneg_right _ hκ.le + linarith + · exact mul_le_mul_of_nonneg_left hbadB (by positivity) + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Selection/FamilyAverages.lean b/lean/OAI/Combinatorics/SharpRamsey/Selection/FamilyAverages.lean new file mode 100644 index 0000000000000000000000000000000000000000..1eb377ce957b94ca0727dbfdaa2098007f2e90d4 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Selection/FamilyAverages.lean @@ -0,0 +1,103 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Reciprocal.AuxiliaryFamilies + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset Real SupportMixtures +open scoped Classical BigOperators +noncomputable section +variable {A B I J : Type*} [Fintype A] [Fintype B] [Fintype I] [Fintype J] + +lemma Law.prod_left_sum (p : Law A) (q : Law B) (f : A → ℝ) : + (∑ z, (p.prod q).mass z * f z.1) = ∑ a, p.mass a * f a := by + simp only [Law.prod, Fintype.sum_prod_type] + apply sum_congr rfl + intro a _ + simp only [←sum_mul, ←mul_sum, q.total, mul_one] + +lemma Law.prod_right_sum (p : Law A) (q : Law B) (f : B → ℝ) : + (∑ z, (p.prod q).mass z * f z.2) = ∑ b, q.mass b * f b := by + simp only [Law.prod, Fintype.sum_prod_type, mul_assoc, ←mul_sum, + ←sum_mul, p.total, one_mul] + +namespace AuxiliarySupport +variable {p : I → Law A} {q : J → Law B} {goodA : I → Finset A} + {goodB : J → Finset B} {MA κA : I → ℝ} {MB κB : J → ℝ} + +lemma familyLaw_first_sum + (X : ∀ i, AuxiliarySupport (p i) (goodA i) (MA i) (κA i)) + (Y : ∀ j, AuxiliarySupport (q j) (goodB j) (MB j) (κB j)) + (i : I) (f : Finset A → ℝ) : + (∑ z, (familyLaw X Y).mass z * f (z.1 i)) = ∑ S, (X i).setLaw.mass S * f S := by + rw [familyLaw, Law.prod_left_sum (Law.pi (fun i => (X i).setLaw)) + (Law.pi (fun j => (Y j).setLaw)) (fun z : I → Finset A => f (z i))] + exact Law.pi_coordinate_sum _ i f + +lemma familyLaw_second_sum + (X : ∀ i, AuxiliarySupport (p i) (goodA i) (MA i) (κA i)) + (Y : ∀ j, AuxiliarySupport (q j) (goodB j) (MB j) (κB j)) + (j : J) (f : Finset B → ℝ) : + (∑ z, (familyLaw X Y).mass z * f (z.2 j)) = ∑ S, (Y j).setLaw.mass S * f S := by + rw [familyLaw, Law.prod_right_sum (Law.pi (fun i => (X i).setLaw)) + (Law.pi (fun j => (Y j).setLaw)) (fun z : J → Finset B => f (z j))] + exact Law.pi_coordinate_sum _ j f + +lemma familyLaw_first_density + (X : ∀ i, AuxiliarySupport (p i) (goodA i) (MA i) (κA i)) + (Y : ∀ j, AuxiliarySupport (q j) (goodB j) (MB j) (κB j)) (i : I) (a : A) : + (∑ z, (familyLaw X Y).mass z * kernel (z.1 i) a) ≤ + (4*exp 1) * (if a ∈ goodA i then (p i).mass a else 0) := by + rw [familyLaw_first_sum X Y i (fun S => kernel S a)] + exact (X i).setLaw_density a + +lemma familyLaw_second_density + (X : ∀ i, AuxiliarySupport (p i) (goodA i) (MA i) (κA i)) + (Y : ∀ j, AuxiliarySupport (q j) (goodB j) (MB j) (κB j)) (j : J) (b : B) : + (∑ z, (familyLaw X Y).mass z * kernel (z.2 j) b) ≤ + (4*exp 1) * (if b ∈ goodB j then (q j).mass b else 0) := by + rw [familyLaw_second_sum X Y j (fun S => kernel S b)] + exact (Y j).setLaw_density b + +lemma familyLaw_first_target + {T : Type*} [Fintype T] (r : Law T) (goodT : Finset T) + (X : ∀ i, AuxiliarySupport (p i) (goodA i) (MA i) (κA i)) + (Y : ∀ j, AuxiliarySupport (q j) (goodB j) (MB j) (κB j)) + (i : I) (R : A → T → Prop) : + (∑ z, (familyLaw X Y).mass z * pairing (kernel (z.1 i)) + (fun b => if b ∈ goodT then r.mass b else 0) (fun a b => if R a b then 1 else 0)) ≤ + (4*exp 1) * ((p i).prod r).event + (univ.filter (fun z => z.1 ∈ goodA i ∧ z.2 ∈ goodT ∧ R z.1 z.2)) := by + have h := one_sided_pairing_le (familyLaw X Y).mass (fun z => z.1 i) + (fun a => if a ∈ goodA i then (p i).mass a else 0) + (fun b => if b ∈ goodT then r.mass b else 0) + (fun a b => if R a b then (1:ℝ) else 0) (4*exp 1) + (familyLaw X Y).nonneg (by intro b; split_ifs <;> simp [r.nonneg]) + (by intros; split_ifs <;> norm_num) (familyLaw_first_density X Y i) + simpa only [good_pairing_eq_event] using h + +lemma familyLaw_second_target + {T : Type*} [Fintype T] (r : Law T) (goodT : Finset T) + (X : ∀ i, AuxiliarySupport (p i) (goodA i) (MA i) (κA i)) + (Y : ∀ j, AuxiliarySupport (q j) (goodB j) (MB j) (κB j)) + (j : J) (R : B → T → Prop) : + (∑ z, (familyLaw X Y).mass z * pairing (kernel (z.2 j)) + (fun b => if b ∈ goodT then r.mass b else 0) (fun a b => if R a b then 1 else 0)) ≤ + (4*exp 1) * ((q j).prod r).event + (univ.filter (fun z => z.1 ∈ goodB j ∧ z.2 ∈ goodT ∧ R z.1 z.2)) := by + have h := one_sided_pairing_le (familyLaw X Y).mass (fun z => z.2 j) + (fun a => if a ∈ goodB j then (q j).mass a else 0) + (fun b => if b ∈ goodT then r.mass b else 0) + (fun a b => if R a b then (1:ℝ) else 0) (4*exp 1) + (familyLaw X Y).nonneg (by intro b; split_ifs <;> simp [r.nonneg]) + (by intros; split_ifs <;> norm_num) (familyLaw_second_density X Y j) + simpa only [good_pairing_eq_event] using h + +end AuxiliarySupport +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Selection/FilteredPredeletion.lean b/lean/OAI/Combinatorics/SharpRamsey/Selection/FilteredPredeletion.lean new file mode 100644 index 0000000000000000000000000000000000000000..db2e7ea647714a915ee18e90619235ef8ec20fdc --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Selection/FilteredPredeletion.lean @@ -0,0 +1,78 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Selection.PredeletionMean + +namespace OAI + +section +namespace SharpLogRamsey.Selection.Windows +open Finset ExposureModel +open scoped Classical BigOperators +noncomputable section +variable {Ω Θ β : Type} [Fintype Ω] [Fintype Θ] [Fintype β] +variable (w n k : ℕ) (p : Law Ω) (θ : Ω→Θ) (G : Ω→Slot w (n+k)→β) (t : Fin k) +local instance filtFinDec (j : ℕ) : DecidableEq (Fin j) := Classical.decEq _ +local instance filtBlockDec : DecidableEq (Block w) := Classical.decEq _ + +lemma filteredPopulation_loss + (z : (model w n k p θ G t).FreshHistory) + (bad : Finset ((model w n k p θ G t).Index z.1)) + (live : Finset (Fin w)) (keep : Fin w→Prop) [DecidablePred keep] : + (∑ i∈live,(goodMiddle w n k p θ G t z bad i).card) ≤ + (∑ i∈live.filter keep,(goodMiddle w n k p θ G t z bad i).card)+ + (2*(n+k))*(live.filter (fun i=>¬keep i)).card := by + rw [←sum_filter_add_sum_filter_not live keep] + apply Nat.add_le_add_left + calc + _ ≤ ∑ i∈live.filter (fun i=>¬keep i),2*(n+k) := by + apply sum_le_sum + intro i _ + simpa only [Fintype.card_fin] using card_le_univ (goodMiddle w n k p θ G t z bad i) + _ = _ := by simp [Nat.mul_comm] + +lemma filtered_predeletion_mean (hkn : k≤n) + (hp : ∀ z,0<(model w n k p θ G t).remaining z) + (bad : ∀ z : (model w n k p θ G t).FreshHistory,Finset ((model w n k p θ G t).Index z.1)) + (keep : (model w n k p θ G t).FreshHistory→Fin w→Prop) + (B ε : ℝ) + (hbad : (∑ z,((model w n k p θ G t).freshLaw hp).mass z*((bad z).card:ℝ))≤B) + (hrep : (n:ℝ)*(∑ z,((model w n k p θ G t).freshLaw hp).mass z* + (((model w n k p θ G t).freshSelected z∩bad z).card:ℝ))≤B) + (hdrop : ∀ z,((model w n k p θ G t).freshLaw hp).mass z≠0→ + (((univ\badWindows ((model w n k p θ G t).representative z) (bad z)).filter + (fun i=>¬keep z i)).card:ℝ)≤ε*w) : + (∑ z,((model w n k p θ G t).freshLaw hp).mass z* + ((w*(2*(n+k)):ℝ)-(∑ i∈(univ\badWindows ((model w n k p θ G t).representative z) (bad z)).filter (keep z), + (goodMiddle w n k p θ G t z (bad z) i).card:ℕ)))≤5*B+(w*(2*(n+k)):ℝ)*ε := by + classical + let M:=model w n k p θ G t + let live:=fun z=>univ\badWindows (M.representative z) (bad z) + have hpnt (z : M.FreshHistory) (hz : (M.freshLaw hp).mass z≠0) : + ((w*(2*(n+k)):ℝ)-(∑ i∈(live z).filter (keep z), + (goodMiddle w n k p θ G t z (bad z) i).card:ℕ))≤ + (w*(2*(n+k)):ℝ)-(∑ i∈live z,(goodMiddle w n k p θ G t z (bad z) i).card:ℕ)+ + (w*(2*(n+k)):ℝ)*ε := by + have hh := (Nat.cast_le (α:=ℝ)).mpr (filteredPopulation_loss w n k p θ G t z (bad z) (live z) (keep z)) + push_cast at hh + have hd:=mul_le_mul_of_nonneg_left (hdrop z hz) (show (0:ℝ)≤2*((n:ℝ)+k) by positivity) + dsimp only [live] at hh ⊢ + push_cast + nlinarith + calc + _ ≤ ∑ z,(M.freshLaw hp).mass z*((w*(2*(n+k)):ℝ)- + (∑ i∈live z,(goodMiddle w n k p θ G t z (bad z) i).card:ℕ)+(w*(2*(n+k)):ℝ)*ε) := by + apply sum_le_sum + intro z _ + by_cases hs : (M.freshLaw hp).mass z=0 + · dsimp only [M] at hs ⊢ + simp only [hs,zero_mul,le_refl] + · exact mul_le_mul_of_nonneg_left (hpnt z hs) ((M.freshLaw hp).nonneg z) + _ = (∑ z,(M.freshLaw hp).mass z*((w*(2*(n+k)):ℝ)- + (∑ i∈live z,(goodMiddle w n k p θ G t z (bad z) i).card:ℕ)))+(w*(2*(n+k)):ℝ)*ε := by + simp only [mul_add,sum_add_distrib,←sum_mul,(M.freshLaw hp).total,one_mul] + _ ≤ _ := add_le_add (bad_predeletion_five w n k p θ G t hkn hp bad B hbad hrep) le_rfl +end +end SharpLogRamsey.Selection.Windows + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Selection/FreshAccrual.lean b/lean/OAI/Combinatorics/SharpRamsey/Selection/FreshAccrual.lean new file mode 100644 index 0000000000000000000000000000000000000000..4cd2a8c5ac044fb2b80852950d430f9ff22500c4 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Selection/FreshAccrual.lean @@ -0,0 +1,165 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.FreshExecution + +namespace OAI + +section +namespace SharpLogRamsey.FreshExecution +open Finset BinaryTree TreeDecoder PublicTables ChronologicalTree +open scoped Classical BigOperators +noncomputable section +variable {I A B C : Type*} [DecidableEq I] {α : I→Type*} + +def labels (t : BinaryTree I) : Finset I := (inorder t).toFinset + +@[simp] lemma labels_nil : labels (.nil : BinaryTree I)=∅ := rfl + +@[simp] lemma labels_node (i : I) (l r : BinaryTree I) : + labels (.node i l r)=insert i (labels l∪labels r) := by + ext j + simp only [labels,inorder,List.mem_toFinset,List.mem_append,List.mem_cons, + mem_insert,mem_union] + tauto + +def Separated : BinaryTree I→Prop + | .nil=>True + | .node i l r=>Separated l ∧ Separated r ∧ i∉labels l ∧ i∉labels r ∧ + Disjoint (labels l) (labels r) + +lemma separated_of_nodup (t : BinaryTree I) (h : (inorder t).Nodup) : Separated t := by + induction t with + | nil=>trivial + | node i l r hl hr=> + simp only [inorder,List.nodup_append,List.nodup_cons] at h + refine ⟨hl h.1,hr h.2.1.2,?_,?_,?_⟩ + · intro hi + exact h.2.2 i (by simpa only [labels,List.mem_toFinset] using hi) i (List.mem_cons_self ..) rfl + · simpa only [labels,List.mem_toFinset] using h.2.1.1 + · apply disjoint_left.mpr + intro j hj hj' + exact h.2.2 j (by simpa only [labels,List.mem_toFinset] using hj) j + (List.mem_cons_of_mem _ (by simpa only [labels,List.mem_toFinset] using hj')) rfl + +lemma arrive_absent (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (z : ∀ i,α i) (target : I) + (t : BinaryTree I) (U : Domains A B) (h : target∉labels t) : + arrive choose read z target t U=none := by + induction t generalizing U with + | nil=>rfl + | node i l r hl hr=> + have hi : i≠target := by + intro he + apply h + rw [labels_node,he] + exact mem_insert_self target _ + have hL : target∉labels l := by intro hj; apply h; simp only [labels_node,mem_insert,mem_union]; tauto + have hR : target∉labels r := by intro hj; apply h; simp only [labels_node,mem_insert,mem_union]; tauto + rw [arrive,ite_eq_right hi] + cases hc : choose i (z i) U with + | none=>rfl + | some c=>simp only [hl _ hL,hr _ hR,Option.orElse_none] + +def accrued (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (f : ∀ i,Domains A B→α i→ℝ) + (z : ∀ i,α i) : BinaryTree I→Domains A B→ℝ + | .nil,_=>0 + | .node i l r,U=>f i U (z i)+match choose i (z i) U with + | none=>0 + | some c=> + let V:=read i (z i) U c + accrued choose read f z l (V.1,U.2)+accrued choose read f z r (U.1,V.2) + +lemma produced_root (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (z : ∀ i,α i) (i : I) + (f : Domains A B→α i→ℝ) (l r : BinaryTree I) (U : Domains A B) : + produced choose read i f (.node i l r) U z=f U (z i) := by + simp only [produced,arrive,ite_true] + +lemma produced_left (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (z : ∀ i,α i) (i j : I) + (f : Domains A B→α j→ℝ) (l r : BinaryTree I) (U : Domains A B) + (hj : j∈labels l) (hi : i∉labels l) (hd : Disjoint (labels l) (labels r)) + (c : C) (hc : choose i (z i) U=some c) : + produced choose read j f (.node i l r) U z= + produced choose read j f l ((read i (z i) U c).1,U.2) z := by + have hij : i≠j := fun he=>hi (he ▸ hj) + have hnj : j∉labels r := disjoint_left.mp hd hj + unfold produced + rw [arrive,ite_eq_right hij,hc] + dsimp only + rw [arrive_absent choose read z j r _ hnj] + cases arrive choose read z j l ((read i (z i) U c).1,U.2) <;> rfl + +lemma produced_right (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (z : ∀ i,α i) (i j : I) + (f : Domains A B→α j→ℝ) (l r : BinaryTree I) (U : Domains A B) + (hj : j∈labels r) (hi : i∉labels r) (hd : Disjoint (labels l) (labels r)) + (c : C) (hc : choose i (z i) U=some c) : + produced choose read j f (.node i l r) U z= + produced choose read j f r (U.1,(read i (z i) U c).2) z := by + have hij : i≠j := fun he=>hi (he ▸ hj) + have hnj : j∉labels l := disjoint_right.mp hd hj + unfold produced + rw [arrive,ite_eq_right hij,hc] + dsimp only + rw [arrive_absent choose read z j l _ hnj] + rfl + +lemma produced_deleted (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (z : ∀ i,α i) (i j : I) + (f : Domains A B→α j→ℝ) (l r : BinaryTree I) (U : Domains A B) + (hi : i≠j) (hc : choose i (z i) U=none) : + produced choose read j f (.node i l r) U z=0 := by + simp only [produced,arrive,ite_eq_right hi,hc] + +theorem accrued_eq_sum (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (f : ∀ i,Domains A B→α i→ℝ) + (z : ∀ i,α i) (t : BinaryTree I) (U : Domains A B) (ht : Separated t) : + accrued choose read f z t U=∑ i∈labels t,produced choose read i (f i) t U z := by + induction t generalizing U with + | nil=>simp only [accrued,labels_nil,sum_empty] + | node i l r hl hr=> + rcases ht with ⟨htl,htr,hli,hri,hd⟩ + rw [labels_node,sum_insert (by simp only [mem_union,not_or]; exact ⟨hli,hri⟩), + sum_union hd,produced_root,accrued] + cases hc : choose i (z i) U with + | none=> + simp only [add_zero] + have hzl : (∑ j∈labels l,produced choose read j (f j) (.node i l r) U z)=0 := by + apply sum_eq_zero + intro j hj + exact produced_deleted choose read z i j (f j) l r U (fun he=>hli (he ▸ hj)) hc + have hzr : (∑ j∈labels r,produced choose read j (f j) (.node i l r) U z)=0 := by + apply sum_eq_zero + intro j hj + exact produced_deleted choose read z i j (f j) l r U (fun he=>hri (he ▸ hj)) hc + rw [hzl,hzr,add_zero,add_zero] + | some c=> + dsimp only + rw [hl _ htl,hr _ htr] + congr 1 + exact congrArg₂ (·+·) + (sum_congr rfl (fun j hj=>(produced_left choose read z i j (f j) l r U hj hli hd c hc).symm)) + (sum_congr rfl (fun j hj=>(produced_right choose read z i j (f j) l r U hj hri hd c hc).symm)) + +variable [Fintype I] [∀ i,Fintype (α i)] + +theorem accrued_expectation (p : ∀ i,Law (α i)) (dummy : ∀ i,α i) + (choose : ∀ i,α i→Domains A B→Option C) + (read : ∀ i,α i→CapReader A B C) (f : ∀ i,Domains A B→α i→ℝ) + (t : BinaryTree I) (U : Domains A B) (ht : Separated t) + (budget : I→ℝ) (hb : ∀ i∈labels t,0≤budget i) + (hlocal : ∀ i∈labels t,∀ V,(∑ x,(p i).mass x*f i V x)≤budget i) : + (∑ z,(piLaw p).mass z*accrued choose read f z t U)≤∑ i∈labels t,budget i := by + simp_rw [accrued_eq_sum choose read f _ t U ht,mul_sum] + rw [sum_comm] + apply sum_le_sum + intro i hi + exact produced_bound p choose read i (dummy i) (f i) t U (budget i) (hb i hi) (hlocal i hi) + +end +end SharpLogRamsey.FreshExecution + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Selection/FreshFamilies.lean b/lean/OAI/Combinatorics/SharpRamsey/Selection/FreshFamilies.lean new file mode 100644 index 0000000000000000000000000000000000000000..81c67e526373379e3ca7990c44451817251d29ad --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Selection/FreshFamilies.lean @@ -0,0 +1,126 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Selection.TableCompositions + +namespace OAI + +section +namespace SharpLogRamsey.PublicTables +open Finset +open scoped Classical BigOperators +noncomputable section +variable {ι : Type*} [Fintype ι] [DecidableEq ι] {α : ι→Type*} [∀ i,Fintype (α i)] + + def piLaw (p : ∀ i,Law (α i)) : Law (∀ i,α i) where + mass z := ∏ i,(p i).mass (z i) + nonneg z := prod_nonneg (fun i _=>(p i).nonneg (z i)) + total := by rw [←Fintype.prod_sum]; simp only [Law.total,prod_const_one] + +abbrev Outside (i : ι) := ∀ j : {j // j≠i},α j + +def outside (i : ι) (z : ∀ j,α j) : Outside (α:=α) i := fun j=>z j + +def outsideLaw (p : ∀ i,Law (α i)) (i : ι) : Law (Outside (α:=α) i) := + piLaw (ι := {j : ι // j≠i}) (α := fun j=>α j.1) (fun j=>p j.1) + +lemma family_mass_split (p : ∀ i,Law (α i)) (i : ι) (z : ∀ j,α j) : + (piLaw p).mass z=(p i).mass (z i)*(outsideLaw p i).mass (outside i z) := by + change (∏ j,(p j).mass (z j))=(p i).mass (z i)* + (∏ j : {j : ι // j≠i},(p j).mass (z j)) + have he : (∏ j ∈ (univ : Finset ι).erase i,(p j).mass (z j))= + ∏ j : {j : ι // j≠i},(p j).mass (z j) := + Finset.prod_subtype _ (by simp) _ + rw [←he] + exact (mul_prod_erase univ (fun j=>(p j).mass (z j)) (mem_univ i)).symm + +theorem family_integral (p : ∀ i,Law (α i)) (i : ι) + (f : Outside (α:=α) i→α i→ℝ) : + (∑ z,(piLaw p).mass z*f (outside i z) (z i)) = + ∑ s,(outsideLaw p i).mass s*(∑ x,(p i).mass x*f s x) := by + calc + _ = ∑ z,(p i).mass (z i)*(outsideLaw p i).mass (outside i z)*f (outside i z) (z i) := by + apply sum_congr rfl + intro z _ + rw [family_mass_split] + _ = ∑ y : α i×Outside (α:=α) i,(p i).mass y.1*(outsideLaw p i).mass y.2*f y.2 y.1 := + Fintype.sum_equiv (Equiv.piSplitAt i α) _ _ (fun _=>rfl) + _ = _ := by + rw [Fintype.sum_prod_type,sum_comm] + apply sum_congr rfl + intro s _ + rw [mul_sum] + apply sum_congr rfl + intro x _ + ring + +theorem ready_family_bound (p : ∀ i,Law (α i)) (i : ι) + (Ready : Outside (α:=α) i→Prop) (f : Outside (α:=α) i→α i→ℝ) + (B : Outside (α:=α) i→ℝ) + (h : ∀ s,Ready s→(∑ x,(p i).mass x*f s x)≤B s) : + (∑ z,(piLaw p).mass z*(if Ready (outside i z) then f (outside i z) (z i) else 0))≤ + ∑ s,(outsideLaw p i).mass s*(if Ready s then B s else 0) := by + rw [family_integral p i (fun s x=>if Ready s then f s x else 0)] + apply sum_le_sum + intro s _ + apply mul_le_mul_of_nonneg_left _ ((outsideLaw p i).nonneg s) + by_cases hs : Ready s + · simpa only [ite_eq_left hs] using h s hs + · simp only [ite_eq_right hs,mul_zero,sum_const_zero,le_refl] + +theorem predictable_budget (p : ∀ i,Law (α i)) + (Ready : ∀ i,Outside (α:=α) i→Prop) (f : ∀ i,Outside (α:=α) i→α i→ℝ) + (B : ℝ) (hB : 0≤B) + (hlocal : ∀ i s,Ready i s→(∑ x,(p i).mass x*f i s x)≤B) + (hunique : ∀ z,((univ.filter (fun i=>Ready i (outside i z))).card:ℝ)≤1) : + (∑ z,(piLaw p).mass z * + (∑ i,if Ready i (outside i z) then f i (outside i z) (z i) else 0))≤B := by + have hi (i : ι) := ready_family_bound p i (Ready i) (f i) (fun _=>B) (hlocal i) + have he (i : ι) : + (∑ s,(outsideLaw p i).mass s*(if Ready i s then B else 0)) = + ∑ z,(piLaw p).mass z*(if Ready i (outside i z) then B else 0) := by + rw [family_integral p i (fun s _=>if Ready i s then B else 0)] + apply sum_congr rfl + intro s _ + rw [←sum_mul,(p i).total,one_mul] + simp_rw [he] at hi + calc + _ ≤ ∑ z,(piLaw p).mass z*(∑ i,if Ready i (outside i z) then B else 0) := by + calc + _ = ∑ i,∑ z,(piLaw p).mass z * + (if Ready i (outside i z) then f i (outside i z) (z i) else 0) := by + simp_rw [mul_sum] + rw [sum_comm] + _ ≤ ∑ i,∑ z,(piLaw p).mass z * + (if Ready i (outside i z) then B else 0) := sum_le_sum (fun i _=>hi i) + _ = _ := by rw [sum_comm]; simp_rw [mul_sum] + _ ≤ ∑ z,(piLaw p).mass z*B := by + apply sum_le_sum + intro z _ + apply mul_le_mul_of_nonneg_left _ ((piLaw p).nonneg z) + rw [←sum_filter,sum_const,nsmul_eq_mul] + exact (mul_le_mul_of_nonneg_right (hunique z) hB).trans_eq (one_mul B) + _ = B := by rw [←sum_mul,(piLaw p).total,one_mul] + +theorem exists_fixed_family {Ω : Type*} [Fintype Ω] (μ : Law Ω) + (p : ∀ i,Law (α i)) (success : Ω→(∀i,α i)→Prop) (c : ℝ) + (h : c≤∑ z,(piLaw p).mass z*(∑ ω,μ.mass ω*(if success ω z then 1 else 0))) : + ∃ z,c≤∑ ω,μ.mass ω*(if success ω z then 1 else 0) := by + by_contra! hn + have hlt : (∑ z,(piLaw p).mass z*(∑ ω,μ.mass ω*(if success ω z then 1 else 0))) + mul_le_mul_of_nonneg_left (hn y).le ((piLaw p).nonneg y)) + ⟨z,mem_univ _,mul_lt_mul_of_pos_left (hn z) (lt_of_le_of_ne ((piLaw p).nonneg z) (Ne.symm hz))⟩ + simpa only [←sum_mul,(piLaw p).total,one_mul] using hh + linarith + +end +end SharpLogRamsey.PublicTables + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Selection/FreshRepresentatives.lean b/lean/OAI/Combinatorics/SharpRamsey/Selection/FreshRepresentatives.lean new file mode 100644 index 0000000000000000000000000000000000000000..3257d6d6de701833a7af5c3fef98f82df97b8bb6 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Selection/FreshRepresentatives.lean @@ -0,0 +1,98 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Exposure.ExposureMixture + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical BigOperators NNReal +noncomputable section +variable {β C ι : Type} [Fintype β] [Fintype C] [Fintype ι] [DecidableEq ι] +namespace ExposureModel + +abbrev FreshHistory (M : ExposureModel ι β C) := Σ z : M.History,C→Fin (M.remaining z) + +def freshLaw (M : ExposureModel ι β C) (h : ∀ z,0Law.equiprobable (C→Fin (M.remaining z))) + +omit [Fintype ι] [DecidableEq ι] in +lemma freshLaw_sum (M : ExposureModel ι β C) (h : ∀ z,0∑ x,(M.tupleLaw z).mass x*φ (M.restore z x)) + +def freshBad (M : ExposureModel ι β C) + (charge : ∀ z,M.Index z→M.Index z→NNReal) (J D a : ℝ) (x : M.FreshHistory) : + Finset (M.Index x.1) := + badIndices (M.tupleLaw x.1) (M.embedding x.1) (M.owner x.1) (charge x.1) J D a x.2 + +def freshSelected (M : ExposureModel ι β C) (x : M.FreshHistory) : Finset (M.Index x.1) := + freshRepresentatives (M.embedding x.1) x.2 + +variable {A B K V : Type} [Fintype A] [Fintype B] [Field K] + [AddCommGroup V] [Module K V] [FiniteDimensional K V] + +omit [Fintype ι] [DecidableEq ι] [FiniteDimensional K V] in +lemma fresh_bad_mean (M : ExposureModel ι (A×B) C) (h : ∀ z,0reciprocalCharges (M.tupleLaw z) v w ρ r s) J D a x).card:ℝ))= + M.mean (reciprocalBadStatistic v w ρ r s J D a) := by + rw [freshLaw_sum] + rfl + +omit [Fintype ι] [DecidableEq ι] [FiniteDimensional K V] in +lemma fresh_selected_mean (M : ExposureModel ι (A×B) C) (h : ∀ z,0reciprocalCharges (M.tupleLaw z) v w ρ r s) J D a x).card:ℝ))= + M.mean (reciprocalSelectedStatistic v w ρ r s J D a) := by + rw [freshLaw_sum] + rfl + +end ExposureModel +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Selection/HistoryLaw.lean b/lean/OAI/Combinatorics/SharpRamsey/Selection/HistoryLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..f9bc3f56e0f85b15ba039edbcbffc35f4083c47b --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Selection/HistoryLaw.lean @@ -0,0 +1,96 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Selection.NullFreeLaw + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical BigOperators +noncomputable section +variable {Θ Ω : Type*} [Fintype Θ] [Fintype Ω] + +def Law.sigma (μ : Law Θ) {A : Θ→Type*} [∀ z,Fintype (A z)] + (ρ : ∀ z,Law (A z)) : Law (Sigma A) where + mass x := μ.mass x.1*(ρ x.1).mass x.2 + nonneg x := mul_nonneg (μ.nonneg x.1) ((ρ x.1).nonneg x.2) + total := by + rw [Fintype.sum_sigma] + calc + _ = ∑ z,μ.mass z := by + apply sum_congr rfl + intro z _ + change (∑ y,μ.mass z*(ρ z).mass y)=μ.mass z + rw [←mul_sum,(ρ z).total,mul_one] + _ = 1 := μ.total + +lemma Law.sigma_sum (μ : Law Θ) {A : Θ→Type*} [∀ z,Fintype (A z)] + (ρ : ∀ z,Law (A z)) (f : Sigma A→ℝ) : + (∑ x,(μ.sigma ρ).mass x*f x)=∑ z,μ.mass z*∑ a,(ρ z).mass a*f ⟨z,a⟩ := by + simp only [Law.sigma,Fintype.sum_sigma,mul_sum,mul_assoc] + +lemma Law.history_sum (μ : Law Ω) (θ : Ω→Θ) (f : Ω→ℝ) : + (∑ z,(μ.map θ).mass z*∑ ω,(μ.cond θ z).mass ω*f ω)=∑ ω,μ.mass ω*f ω := by + have h:=μ.history_observable_sum θ id (fun _ ω=>f ω) + simpa only [Law.sum_map,id_eq] using h.symm + +lemma Law.nullFree_map {B : Type*} [Fintype B] (μ : Law Ω) (f : Ω→B) : + μ.nullFree.map (fun ω=>f ω.val)=μ.map f := by + ext b + change (∑ ω : {ω // μ.mass ω≠0} with f ω.val=b,μ.mass ω.val)=∑ ω with f ω=b,μ.mass ω + simpa only [sum_filter,mul_ite,mul_one,mul_zero,Law.nullFree] using + μ.nullFree_integral (fun ω=>if f ω=b then 1 else 0) + +abbrev Law.History (μ : Law Ω) (θ : Ω→Θ) := {z // (μ.map θ).mass z≠0} + +abbrev Law.HistorySource (μ : Law Ω) (θ : Ω→Θ) (z : μ.History θ) := + {ω // (μ.cond θ z.val).mass ω≠0} + +abbrev Law.HistoryExtension (μ : Law Ω) (θ : Ω→Θ) + (A : μ.History θ→Type*) := Σ z : μ.History θ, μ.HistorySource θ z × A z + +def Law.historyExtension (μ : Law Ω) (θ : Ω→Θ) + {A : μ.History θ→Type*} [∀ z,Fintype (A z)] + (ρ : ∀ z,Law (A z)) : Law (μ.HistoryExtension θ A) := + (μ.map θ).nullFree.sigma (fun z=>(μ.cond θ z.val).nullFree.prod (ρ z)) + +lemma Law.historyExtension_support (μ : Law Ω) (θ : Ω→Θ) + {A : μ.History θ→Type*} (x : μ.HistoryExtension θ A) : + μ.mass x.2.1.val≠0 ∧ θ x.2.1.val=x.1.val := + μ.cond_support θ x.1.val x.1.property x.2.1.val x.2.1.property + +theorem Law.historyExtension_source (μ : Law Ω) (θ : Ω→Θ) + {A : μ.History θ→Type*} [∀ z,Fintype (A z)] + (ρ : ∀ z,Law (A z)) (f : Ω→ℝ) : + (∑ x,(μ.historyExtension θ ρ).mass x*f x.2.1.val)=∑ ω,μ.mass ω*f ω := by + unfold Law.historyExtension + rw [Law.sigma_sum] + change (∑ z,(μ.map θ).nullFree.mass z * + ∑ x,((μ.cond θ z.val).nullFree.prod (ρ z)).mass x*f x.1.val)=_ + have he (z : μ.History θ) : + (∑ x,((μ.cond θ z.val).nullFree.prod (ρ z)).mass x*f x.1.val)= + ∑ ω,(μ.cond θ z.val).mass ω*f ω := by + rw [Law.prod_left_sum (μ.cond θ z.val).nullFree (ρ z) (fun ω=>f ω.val)] + exact (μ.cond θ z.val).nullFree_integral f + simp_rw [he] + exact ((μ.map θ).nullFree_integral (fun z=>∑ ω,(μ.cond θ z).mass ω*f ω)).trans + (μ.history_sum θ f) + +theorem Law.historyExtension_bound (μ : Law Ω) (θ : Ω→Θ) + {A : μ.History θ→Type*} [∀ z,Fintype (A z)] + (ρ : ∀ z,Law (A z)) (f : μ.HistoryExtension θ A→ℝ) (c : ℝ) + (h : ∀ z,(∑ x,((μ.cond θ z.val).nullFree.prod (ρ z)).mass x*f ⟨z,x⟩)≤c) : + (∑ x,(μ.historyExtension θ ρ).mass x*f x)≤c := by + unfold Law.historyExtension + rw [Law.sigma_sum] + calc + _ ≤ ∑ z,(μ.map θ).nullFree.mass z*c := + sum_le_sum (fun z _=>mul_le_mul_of_nonneg_left (h z) ((μ.map θ).nullFree.nonneg z)) + _ = c := by rw [←sum_mul,Law.total,one_mul] + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Selection/LiveFamilies.lean b/lean/OAI/Combinatorics/SharpRamsey/Selection/LiveFamilies.lean new file mode 100644 index 0000000000000000000000000000000000000000..c27a3988321d3c637a771cd7de4a34ae425f0906 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Selection/LiveFamilies.lean @@ -0,0 +1,120 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Reciprocal.ReciprocalPopulation +import OAI.Combinatorics.SharpRamsey.Windows.BalancedWindows +import OAI.Combinatorics.SharpRamsey.Selection.EmptySupports + +namespace OAI + +section +namespace SharpLogRamsey.ActualPivot +open Finset Real Selection Selection.AuxiliarySupport +open FreshExecution TreeDecoder BinaryTree ChronologicalTree +open scoped Classical BigOperators +noncomputable section +variable {I : Type*} [Fintype I] [LinearOrder I] +local instance liveDecEq : DecidableEq I := Classical.decEq _ + +def liveRetraction (S : Finset I) (h : S.Nonempty) (i : I) : S := + if hi : i∈S then ⟨i,hi⟩ else ⟨h.choose,h.choose_spec⟩ + +omit [Fintype I] [LinearOrder I] in +lemma liveRetraction_mem (S : Finset I) (h : S.Nonempty) (i : I) (hi : i∈S) : + (liveRetraction S h i).val=i := by simp [liveRetraction,hi] + +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] + {Ω : Type*} [Fintype Ω] + {p : I→Law (Projectivization K (Module.Dual K V))} + {r : I→Law (Projectivization K V)} + {goodA : I→Finset (Projectivization K (Module.Dual K V))} + {goodB : I→Finset (Projectivization K V)} {MA MB κA κB : I→ℝ} +local instance liveBanksFintype (b : ℝ) : Fintype (Banks (K:=K) (V:=V) b) := inferInstance + +variable (S : Finset I) (hS : S.Nonempty) + (X : ∀ i : S,AuxiliarySupport (p i) (goodA i) (MA i) (κA i)) + (Y : ∀ i : S,AuxiliarySupport (r i) (goodB i) (MB i) (κB i)) + +abbrev liveX (i : I) := X (liveRetraction S hS i) +abbrev liveY (i : I) := Y (liveRetraction S hS i) + +variable {d : ℕ} {b τ P H : ℝ} (hdim : Module.finrank K V=d+3) + (book : Book (K:=K) (V:=V) (Nat.card K) b τ P H (d+3)) + (hτ : 0<τ) (hτsmall : τ≤1/40000) + (hMA : ∀ i∈S,0hMA _ (liveRetraction S hS i).property) + (fun i=>hMB _ (liveRetraction S hS i).property) + (fun i=>hprod _ (liveRetraction S hS i).property) z i + +theorem Book.live_population_loss + (μ : Law Ω) (counts : I→ℕ) + (target : Ω→∀ i,Fin (counts i)→Projectivization K (Module.Dual K V)×Projectivization K V) + (fallback : I) + (hR : ∀ ω,∀ i∈S,∀ j,SharpLogRamsey.Incidence.Incident (target ω i j).2 (target ω i j).1) + (GA : ∀ i,Fin (counts i)→Finset (Projectivization K (Module.Dual K V))) + (GB : ∀ i,Fin (counts i)→Finset (Projectivization K V)) + (ε εA εB δA δB : ℝ) (hε : 0≤ε) (hεA : 0≤εA) (hεB : 0≤εB) + (hfirst : ∀ i∈S,∀ j∈S,i < j → goodIncidence (p i) (r j) (goodA i) (goodB j)≤ε) + (hself : ∀ i∈S,goodIncidence (p i) (r i) (goodA i) (goodB i)≤ε) + (hmeanA : ∀ i∈S,∀ j,∀ k∈S,i ≤ k → + goodIncidence (μ.map (fun ω=>(target ω i j).1)) (r k) (GA i j) (goodB k)≤εA) + (hmeanB : ∀ i∈S,∀ j,∀ k∈S,k ≤ i → + goodIncidence (p k) (μ.map (fun ω=>(target ω i j).2)) (goodA k) (GB i j)≤εB) + (hbadA : ∀ i∈S,∀ j,(∑ ω,μ.mass ω*(if (target ω i j).1∈GA i j then (0:ℝ) else 1))≤δA) + (hbadB : ∀ i∈S,∀ j,(∑ ω,μ.mass ω*(if (target ω i j).2∈GB i j then (0:ℝ) else 1))≤δB) : + (∑ z,(PublicTables.piLaw (fun _ : I=>banksLaw (K:=K) (V:=V) b)).mass z * + ∑ ω,(μ.prod (familyLaw (liveX S hS X) (liveY S hS Y)).nullFree).mass ω* + ((∑ i∈S,(counts i:ℝ))- + (fullOutput (fun y x=>SharpLogRamsey.Incidence.Incident x y) + (fun i=>book.chronoChoose hdim hτ.le hτsmall (liveOriginal S hS X Y hMA hMB hprod ω.2 i)) + (fun _=>chronoRead b) (fun i=>List.ofFn (target ω.1 i)) z (liveTree S fallback) (univ,univ)).length))≤ + (∑ i∈S,(counts i:ℝ))*treeError (Nat.card K) τ (liveTree S fallback).height ε εA εB δA δB := by + have hsubL (i j : I) (hj : j∈leftPath i (liveTree S fallback)) : j∈S := by + rw [←liveTree_labels S fallback] + exact leftPath_subset i _ hj + have hsubR (i j : I) (hj : j∈rightPath i (liveTree S fallback)) : j∈S := by + rw [←liveTree_labels S fallback] + exact rightPath_subset i _ hj + have hh := book.original_population_loss (liveX S hS X) (liveY S hS Y) hdim hτ hτsmall + (fun i=>hMA _ (liveRetraction S hS i).property) + (fun i=>hMB _ (liveRetraction S hS i).property) + (fun i=>hprod _ (liveRetraction S hS i).property) μ counts target (liveTree S fallback) + (liveTree_separated S fallback) + simp only [liveTree_labels] at hh + apply hh (fun ω=>hR ω) GA GB ε εA εB δA δB hε hεA hεB + · intro i hi j hj + simpa only [liveRetraction_mem S hS i hi,liveRetraction_mem S hS j (hsubL i j hj)] using + hfirst i hi j (hsubL i j hj) (liveTree_left S fallback i j hj) + · intro i hi j hj + simpa only [liveRetraction_mem S hS i hi,liveRetraction_mem S hS j (hsubR i j hj)] using + hfirst j (hsubR i j hj) i hi (liveTree_right S fallback i j hj) + · intro i hi + simpa only [liveRetraction_mem S hS i hi] using hself i hi + · intro i hi j k hk + rcases mem_insert.mp hk with hki|hk + · subst k + simpa only [liveRetraction_mem S hS i hi] using hmeanA i hi j i hi le_rfl + · simpa only [liveRetraction_mem S hS k (hsubL i k hk)] using + hmeanA i hi j k (hsubL i k hk) (liveTree_left S fallback i k hk).le + · intro i hi j k hk + rcases mem_insert.mp hk with hki|hk + · subst k + simpa only [liveRetraction_mem S hS i hi] using hmeanB i hi j i hi le_rfl + · simpa only [liveRetraction_mem S hS k (hsubR i k hk)] using + hmeanB i hi j k (hsubR i k hk) (liveTree_right S fallback i k hk).le + · exact hbadA + · exact hbadB + +end +end SharpLogRamsey.ActualPivot + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Selection/LiveRealization.lean b/lean/OAI/Combinatorics/SharpRamsey/Selection/LiveRealization.lean new file mode 100644 index 0000000000000000000000000000000000000000..34facaba05b2e2677f39cdcaf5d3f8e051ffbc93 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Selection/LiveRealization.lean @@ -0,0 +1,128 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.HighRankContext +import OAI.Combinatorics.SharpRamsey.Selection.LiveFamilies + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical BigOperators +noncomputable section +variable {A B C : Type*} [Fintype A] [Fintype B] [Fintype C] + +end +end SharpLogRamsey.Selection + +namespace SharpLogRamsey.ChronologicalTree +open BinaryTree Finset +open scoped Classical +variable {I : Type*} [LinearOrder I] +lemma liveTree_empty (fallback : I) : liveTree ∅ fallback=nil := by + simp [liveTree,balanced,BinaryTree.map] +end SharpLogRamsey.ChronologicalTree + +namespace SharpLogRamsey.ActualPivot +open Finset Real Selection Selection.AuxiliarySupport +open FreshExecution TreeDecoder BinaryTree ChronologicalTree +open scoped Classical BigOperators +noncomputable section +variable {K V I Y₀ : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] + [Fintype I] [LinearOrder I] [Fintype Y₀] {d : ℕ} {b τ P H : ℝ} +local instance realDecEq : DecidableEq I := Classical.decEq _ +local instance realizationBanksFintype : Fintype (Banks (K:=K) (V:=V) b) := inferInstance + +structure Realization (q : Law Y₀) where + Ω : Type + inst : Fintype Ω + μ : Law Ω + source : Ω→Y₀ + supports : Ω→I→Original (K:=K) (V:=V) d b + marginal : μ.map source=q + +attribute [instance] Realization.inst + +variable (hdim : Module.finrank K V=d+3) + (book : Book (K:=K) (V:=V) (Nat.card K) b τ P H (d+3)) + (hb : 0≤b) (hτ : 0<τ) (hτsmall : τ≤1/40000) + +include hb + +theorem Book.live_realization + (q : Law Y₀) (S : Finset I) (fallback : I) + (p : I→Law (Projectivization K (Module.Dual K V))) + (r : I→Law (Projectivization K V)) + (goodA : I→Finset (Projectivization K (Module.Dual K V))) + (goodB : I→Finset (Projectivization K V)) (MA MB κA κB : I→ℝ) + (X : ∀ i : S,AuxiliarySupport (p i) (goodA i) (MA i) (κA i)) + (Y : ∀ i : S,AuxiliarySupport (r i) (goodB i) (MB i) (κB i)) + (hMA : ∀ i∈S,0(target y i j).1)) (r k) (GA i j) (goodB k)≤εA) + (hmeanB : ∀ i∈S,∀ j,∀ k∈S,k ≤ i → + goodIncidence (p k) (q.map (fun y=>(target y i j).2)) (goodA k) (GB i j)≤εB) + (hbadA : ∀ i∈S,∀ j,(∑ y,q.mass y*(if (target y i j).1∈GA i j then (0:ℝ) else 1))≤δA) + (hbadB : ∀ i∈S,∀ j,(∑ y,q.mass y*(if (target y i j).2∈GB i j then (0:ℝ) else 1))≤δB) : + ∃ e : Realization (K:=K) (V:=V) (I:=I) (d:=d) (b:=b) q, + (∑ z,(PublicTables.piLaw (fun _ : I=>banksLaw (K:=K) (V:=V) b)).mass z* + ∑ ω,e.μ.mass ω*((∑ i∈S,(counts i:ℝ))- + (fullOutput (fun y x=>SharpLogRamsey.Incidence.Incident x y) + (fun i=>book.chronoChoose hdim hτ.le hτsmall (e.supports ω i)) + (fun _=>chronoRead b) (fun i=>List.ofFn (target (e.source ω) i)) z + (liveTree S fallback) (univ,univ)).length))≤ + (∑ i∈S,(counts i:ℝ))*treeError (Nat.card K) τ (liveTree S fallback).height ε εA εB δA δB := by + by_cases hS : S.Nonempty + · let e : Realization (K:=K) (V:=V) (I:=I) (d:=d) (b:=b) q := + { Ω := {y // q.mass y≠0} × OriginalChoice (liveX S hS X) (liveY S hS Y) + inst := inferInstance + μ := q.nullFree.prod (familyLaw (liveX S hS X) (liveY S hS Y)).nullFree + source := fun ω=>ω.1.val + supports := fun ω=>liveOriginal S hS X Y hMA hMB hprod ω.2 + marginal := by + rw [Law.prod_map_left] + exact (q.nullFree_map id).trans (Law.map_id q) } + refine ⟨e,?_⟩ + apply book.live_population_loss S hS X Y hdim hτ hτsmall hMA hMB hprod q.nullFree counts + (fun y=>target y.val) fallback (fun y=>hR y.val y.property) GA GB ε εA εB δA δB hε hεA hεB + hfirst hself + · intro i hi j k hk hik + rw [q.nullFree_map (fun y=>(target y i j).1)] + exact hmeanA i hi j k hk hik + · intro i hi j k hk hki + rw [q.nullFree_map (fun y=>(target y i j).2)] + exact hmeanB i hi j k hk hki + · intro i hi j + rw [q.nullFree_integral (fun y=>if (target y i j).1∈GA i j then (0:ℝ) else 1)] + exact hbadA i hi j + · intro i hi j + rw [q.nullFree_integral (fun y=>if (target y i j).2∈GB i j then (0:ℝ) else 1)] + exact hbadB i hi j + · have hS' : S=∅ := not_nonempty_iff_eq_empty.mp hS + let e : Realization (K:=K) (V:=V) (I:=I) (d:=d) (b:=b) q := + { Ω := Y₀ + inst := inferInstance + μ := q + source := id + supports := fun _ _=>emptyOriginal hdim hb + marginal := Law.map_id q } + refine ⟨e,?_⟩ + simp [hS',liveTree_empty,fullOutput_nil] +end +end SharpLogRamsey.ActualPivot + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Selection/MixedLoss.lean b/lean/OAI/Combinatorics/SharpRamsey/Selection/MixedLoss.lean new file mode 100644 index 0000000000000000000000000000000000000000..60103e87515c944b150bff9792fb46ae2f26f5f4 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Selection/MixedLoss.lean @@ -0,0 +1,65 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.ExecutedReplacement +import OAI.Combinatorics.SharpRamsey.Exposure.MixtureRealization + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical BigOperators +noncomputable section +variable {X Ω B A Θ : Type*} [Fintype X] [Fintype Ω] [Fintype B] [Fintype A] [Fintype Θ] + +lemma Law.attach_left (q : Law X) (μ : Law Ω) (f : X→B) (g : Ω→B) (φ : X→ℝ) : + (∑ x,(q.attach μ f g).mass x*φ x.1)=∑ x,q.mass x*φ x := by + rw [Law.attach,Law.sigma_sum] + apply sum_congr rfl + intro x _ + change q.mass x*(∑ a,(μ.cond g (f x)).mass a*φ x)=q.mass x*φ x + rw [←sum_mul,(μ.cond g (f x)).total,one_mul] + +theorem Law.mixed_loss (ν : Law Θ) {Y : {θ // ν.mass θ≠0}→Type*} + [∀ θ,Fintype (Y θ)] (μ : ∀ θ,Law (Y θ)) (p : Law A) + (N : ℕ) (pop : Θ→ℕ) (out : A→(Σ θ,Y θ)→ℕ) (δ : ℝ) (hδ : 0≤δ) + (hsize : ∀ θ,pop θ≤N) + (hlocal : ∀ θ,(∑ a,p.mass a*∑ y,(μ θ).mass y*((pop θ.val:ℝ)-(out a ⟨θ,y⟩:ℝ)))≤ + (pop θ.val:ℝ)*δ) : + (∑ a,p.mass a*∑ ω,(ν.nullFree.sigma μ).mass ω*((N:ℝ)-(out a ω:ℝ)))≤ + (∑ θ,ν.mass θ*((N:ℝ)-(pop θ:ℝ)))+(N:ℝ)*δ := by + have hloc (θ : {θ // ν.mass θ≠0}) : + (∑ a,p.mass a*∑ y,(μ θ).mass y*((N:ℝ)-(out a ⟨θ,y⟩:ℝ)))≤ + (N:ℝ)-(pop θ.val:ℝ)+(N:ℝ)*δ := by + calc + _ = (N:ℝ)-(pop θ.val:ℝ)+ + ∑ a,p.mass a*∑ y,(μ θ).mass y*((pop θ.val:ℝ)-(out a ⟨θ,y⟩:ℝ)) := by + have he (a : A) (y : Y θ) : (N:ℝ)-(out a ⟨θ,y⟩:ℝ)= + ((N:ℝ)-(pop θ.val:ℝ))+((pop θ.val:ℝ)-(out a ⟨θ,y⟩:ℝ)) := by ring + simp_rw [he] + simp only [mul_add,sum_add_distrib,←sum_mul,(μ θ).total,p.total,one_mul] + _ ≤ _ := add_le_add le_rfl ((hlocal θ).trans + (mul_le_mul_of_nonneg_right (show (pop θ.val:ℝ)≤(N:ℝ) by exact_mod_cast hsize θ.val) hδ)) + calc + _ = ∑ θ,ν.nullFree.mass θ*(∑ a,p.mass a* + ∑ y,(μ θ).mass y*((N:ℝ)-(out a ⟨θ,y⟩:ℝ))) := by + simp_rw [Law.sigma_sum,mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro θ _ + apply sum_congr rfl + intro a _ + apply sum_congr rfl + intro y _ + ring + _ ≤ ∑ θ,ν.nullFree.mass θ*((N:ℝ)-(pop θ.val:ℝ)+(N:ℝ)*δ) := + sum_le_sum (fun θ _=>mul_le_mul_of_nonneg_left (hloc θ) (ν.nullFree.nonneg θ)) + _ = _ := by + rw [ν.nullFree_integral (fun θ=>(N:ℝ)-(pop θ:ℝ)+(N:ℝ)*δ)] + simp only [mul_add,sum_add_distrib,←sum_mul,ν.total,one_mul] + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Selection/NullFreeLaw.lean b/lean/OAI/Combinatorics/SharpRamsey/Selection/NullFreeLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..828543f3c959e4402a02ba3beee6b6f138659ad0 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Selection/NullFreeLaw.lean @@ -0,0 +1,57 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Selection.FamilyAverages +import OAI.Combinatorics.SharpRamsey.Selection.ScheduledBanks + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical BigOperators +noncomputable section +variable {Ω : Type*} [Fintype Ω] + +def Law.asPublic (μ : Law Ω) : PublicTables.Law Ω := ⟨μ.mass,μ.nonneg,μ.total⟩ + +lemma Law.nullFree_sum (μ : Law Ω) (f : Ω→ℝ) : + (∑ ω : {ω // μ.mass ω≠0},μ.mass ω*f ω) = ∑ ω,μ.mass ω*f ω := by + calc + _ = ∑ ω∈univ.filter (fun ω=>μ.mass ω≠0),μ.mass ω*f ω := + (sum_subtype _ (by simp) _).symm + _ = _ := by + apply sum_subset (filter_subset _ _) + intro ω hω hn + have hh : μ.mass ω=0 := by simpa using hn + simp [hh] + +def Law.nullFree (μ : Law Ω) : Law {ω // μ.mass ω≠0} where + mass ω := μ.mass ω + nonneg ω := μ.nonneg ω + total := by simpa only [mul_one,μ.total] using μ.nullFree_sum (fun _=>1) + +lemma Law.nullFree_integral (μ : Law Ω) (f : Ω→ℝ) : + (∑ ω,μ.nullFree.mass ω*f ω)=∑ ω,μ.mass ω*f ω := μ.nullFree_sum f + +lemma Law.nullFree_positive (μ : Law Ω) (ω : {ω // μ.mass ω≠0}) : 0<μ.nullFree.mass ω := + lt_of_le_of_ne (μ.nonneg ω) (Ne.symm ω.property) + +lemma Law.nullFree_public_integral (μ : Law Ω) (f : Ω→ℝ) : + (∑ ω,μ.nullFree.asPublic.mass ω*f ω)=∑ ω,μ.mass ω*f ω := μ.nullFree_sum f + +lemma Law.prod_sum_swap {A : Type*} [Fintype A] (μ : Law Ω) (ρ : Law A) + (f : Ω→A→ℝ) : + (∑ z,(μ.prod ρ).mass z*f z.1 z.2)=∑ a,ρ.mass a*(∑ ω,μ.mass ω*f ω a) := by + simp only [Law.prod,Fintype.sum_prod_type,mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro a _ + apply sum_congr rfl + intros + ring + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Selection/OriginalFamilies.lean b/lean/OAI/Combinatorics/SharpRamsey/Selection/OriginalFamilies.lean new file mode 100644 index 0000000000000000000000000000000000000000..373770f8e3545258a380d4e91cc9415f8c284bc8 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Selection/OriginalFamilies.lean @@ -0,0 +1,153 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Selection.NullFreeLaw +import OAI.Combinatorics.SharpRamsey.Execution.OriginalTargetLoss + +namespace OAI + +section +namespace SharpLogRamsey.ActualPivot +open Finset Real Incidence SupportMixtures Selection Selection.AuxiliarySupport +open scoped Classical BigOperators +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] + {I : Type*} [Fintype I] + {p : I→Law (Projectivization K (Module.Dual K V))} + {r : I→Law (Projectivization K V)} + {goodA : I→Finset (Projectivization K (Module.Dual K V))} + {goodB : I→Finset (Projectivization K V)} {MA MB κA κB : I→ℝ} + +variable (X : ∀ i,AuxiliarySupport (p i) (goodA i) (MA i) (κA i)) + (Y : ∀ i,AuxiliarySupport (r i) (goodB i) (MB i) (κB i)) + +abbrev OriginalChoice := {z // (familyLaw X Y).mass z≠0} + +omit [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma originalChoice_size (z : OriginalChoice X Y) (i : I) : + MA i*exp (-κA i)/2≤((z.val.1 i).card:ℝ) ∧ + MB i*exp (-κB i)/2≤((z.val.2 i).card:ℝ) := + ⟨((familyLaw_support X Y z.val z.property).1 i).2.1, + ((familyLaw_support X Y z.val z.property).2 i).2.1⟩ + +def originalFamily {n : ℕ} {b : ℝ} (hMA : ∀ i,0ay.1∈goodA i ∧ ay.2∈goodB j ∧ ay.1.rep ay.2.rep=0)) := by + change (∑ z,(familyLaw X Y).nullFree.mass z * density (z.val.1 i) (z.val.2 j))≤_ + rw [(familyLaw X Y).nullFree_integral (fun z=>density (z.1 i) (z.2 j))] + exact familyLaw_incidence X Y i j (fun a y=>a.rep y.rep=0) + +variable {Ω : Type*} [Fintype Ω] + +omit [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma firstTargetDensity_mean (μ : Law Ω) (a : Ω→Projectivization K (Module.Dual K V)) + (G : Finset (Projectivization K (Module.Dual K V))) (T : Finset (Projectivization K V)) : + (∑ ω,μ.mass ω*firstTargetDensity (a ω∈G) (a ω) T)= + pairing (fun y=>if y∈G then (μ.map a).mass y else 0) (kernel T) + (fun y x=>if y.rep x.rep=0 then 1 else 0) := by + rw [←μ.sum_map a (fun y=>firstTargetDensity (y∈G) y T)] + unfold pairing firstTargetDensity + apply sum_congr rfl + intro y _ + by_cases hy : y∈G <;> simp [hy,mul_sum] + +omit [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma secondTargetDensity_mean (μ : Law Ω) (c : Ω→Projectivization K V) + (G : Finset (Projectivization K V)) (S : Finset (Projectivization K (Module.Dual K V))) : + (∑ ω,μ.mass ω*secondTargetDensity (c ω∈G) (c ω) S)= + pairing (kernel S) (fun x=>if x∈G then (μ.map c).mass x else 0) + (fun y x=>if y.rep x.rep=0 then 1 else 0) := by + rw [←μ.sum_map c (fun x=>secondTargetDensity (x∈G) x S),pairing_reverse] + unfold pairing secondTargetDensity + apply sum_congr rfl + intro x _ + by_cases hx : x∈G <;> simp [hx,mul_sum] + +omit [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +theorem originalFamily_first_target {n : ℕ} {b : ℝ} (hMA : ∀ i,0ay.1∈G ∧ ay.2∈goodB j ∧ ay.1.rep ay.2.rep=0)) := by + change (∑ z,(μ.prod (familyLaw X Y).nullFree).mass z * + firstTargetDensity (a z.1∈G) (a z.1) (z.2.val.2 j))≤_ + rw [μ.prod_sum_swap (familyLaw X Y).nullFree + (fun ω z=>firstTargetDensity (a ω∈G) (a ω) (z.val.2 j))] + simp_rw [firstTargetDensity_mean] + rw [(familyLaw X Y).nullFree_integral (fun z=>pairing + (fun y=>if y∈G then (μ.map a).mass y else 0) (kernel (z.2 j)) + (fun y x=>if y.rep x.rep=0 then 1 else 0))] + simp_rw [pairing_reverse (fun y=>if y∈G then (μ.map a).mass y else 0)] + have hh := familyLaw_second_target (μ.map a) G X Y j (fun y x=>x.rep y.rep=0) + have he : ((r j).prod (μ.map a)).event + (univ.filter (fun yx=>yx.1∈goodB j ∧ yx.2∈G ∧ yx.2.rep yx.1.rep=0))= + ((μ.map a).prod (r j)).event + (univ.filter (fun xy=>xy.1∈G ∧ xy.2∈goodB j ∧ xy.1.rep xy.2.rep=0)) := by + rw [←good_pairing_eq_event (r j) (μ.map a) (goodB j) G (fun y x=>x.rep y.rep=0), + ←good_pairing_eq_event (μ.map a) (r j) G (goodB j) (fun x y=>x.rep y.rep=0)] + exact pairing_reverse _ _ _ + rw [he] at hh + exact hh + +omit [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +theorem originalFamily_second_target {n : ℕ} {b : ℝ} (hMA : ∀ i,0ay.1∈goodA i ∧ ay.2∈G ∧ ay.1.rep ay.2.rep=0)) := by + change (∑ z,(μ.prod (familyLaw X Y).nullFree).mass z * + secondTargetDensity (c z.1∈G) (c z.1) (z.2.val.1 i))≤_ + rw [μ.prod_sum_swap (familyLaw X Y).nullFree + (fun ω z=>secondTargetDensity (c ω∈G) (c ω) (z.val.1 i))] + simp_rw [secondTargetDensity_mean] + rw [(familyLaw X Y).nullFree_integral (fun z=>pairing (kernel (z.1 i)) + (fun x=>if x∈G then (μ.map c).mass x else 0) + (fun y x=>if y.rep x.rep=0 then 1 else 0))] + exact familyLaw_first_target (μ.map c) G X Y i (fun y x=>y.rep x.rep=0) + +end +end SharpLogRamsey.ActualPivot + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Selection/PredeletionMean.lean b/lean/OAI/Combinatorics/SharpRamsey/Selection/PredeletionMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..91950408e755b7f0b72ff73926ddcbb8c21551b9 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Selection/PredeletionMean.lean @@ -0,0 +1,75 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Windows.GoodPopulation + +namespace OAI + +section +namespace SharpLogRamsey.Selection.Windows +open Finset ExposureModel +open scoped Classical BigOperators +noncomputable section +variable {Ω Θ β : Type} [Fintype Ω] [Fintype Θ] [Fintype β] +variable (w n k : ℕ) (p : Law Ω) (θ : Ω→Θ) (G : Ω→Slot w (n+k)→β) (t : Fin k) +local instance preFinDec (j : ℕ) : DecidableEq (Fin j) := Classical.decEq _ +local instance preBlockDec : DecidableEq (Block w) := Classical.decEq _ + +lemma bad_predeletion_mean + (hp : ∀ z,0<(model w n k p θ G t).remaining z) + (bad : ∀ z : (model w n k p θ G t).FreshHistory,Finset ((model w n k p θ G t).Index z.1)) : + (∑ z,((model w n k p θ G t).freshLaw hp).mass z* + ((w*(2*(n+k)):ℝ)-(∑ i∈univ\badWindows ((model w n k p θ G t).representative z) (bad z), + (goodMiddle w n k p θ G t z (bad z) i).card:ℕ)))≤ + (∑ z,((model w n k p θ G t).freshLaw hp).mass z*((bad z).card:ℝ))+ + (2*(n+k):ℕ)*(∑ z,((model w n k p θ G t).freshLaw hp).mass z* + (((model w n k p θ G t).freshSelected z∩bad z).card:ℝ)) := by + let M:=model w n k p θ G t + have hpnt (z : M.FreshHistory) : + ((w*(2*(n+k)):ℝ)-(∑ i∈univ\badWindows (M.representative z) (bad z), + (goodMiddle w n k p θ G t z (bad z) i).card:ℕ))≤ + ((bad z).card:ℝ)+((badWindows (M.representative z) (bad z)).card:ℝ)*(2*(n+k):ℕ) := by + have hh:=goodPopulation_predeletion w n k p θ G t z (bad z) (badWindows (M.representative z) (bad z)) + have hh' := (Nat.cast_le (α:=ℝ)).mpr hh + push_cast at hh' + change (w:ℝ)*(2*((n:ℝ)+(k:ℝ)))≤ + (∑ i∈univ\badWindows (M.representative z) (bad z), + ((goodMiddle w n k p θ G t z (bad z) i).card:ℝ))+ + ((bad z).card:ℝ)+((badWindows (M.representative z) (bad z)).card:ℝ)*(2*((n:ℝ)+(k:ℝ))) at hh' + push_cast + linarith + + calc + _ ≤ ∑ z,(M.freshLaw hp).mass z*(((bad z).card:ℝ)+ + ((badWindows (M.representative z) (bad z)).card:ℝ)*(2*(n+k):ℕ)) := + sum_le_sum (fun z _=>mul_le_mul_of_nonneg_left (hpnt z) ((M.freshLaw hp).nonneg z)) + _ = (∑ z,(M.freshLaw hp).mass z*((bad z).card:ℝ))+ + (2*(n+k):ℕ)*(∑ z,(M.freshLaw hp).mass z* + ((badWindows (M.representative z) (bad z)).card:ℝ)) := by + simp only [mul_add,sum_add_distrib,mul_sum,mul_left_comm,mul_comm] + _ ≤ _ := add_le_add le_rfl (mul_le_mul_of_nonneg_left + (bad_windows_mean w n k p θ G t hp bad) (show (0:ℝ)≤((2*(n+k):ℕ):ℝ) by positivity)) + +theorem bad_predeletion_five (hkn : k≤n) + (hp : ∀ z,0<(model w n k p θ G t).remaining z) + (bad : ∀ z : (model w n k p θ G t).FreshHistory,Finset ((model w n k p θ G t).Index z.1)) + (B : ℝ) + (hbad : (∑ z,((model w n k p θ G t).freshLaw hp).mass z*((bad z).card:ℝ))≤B) + (hrep : (n:ℝ)*(∑ z,((model w n k p θ G t).freshLaw hp).mass z* + (((model w n k p θ G t).freshSelected z∩bad z).card:ℝ))≤B) : + (∑ z,((model w n k p θ G t).freshLaw hp).mass z* + ((w*(2*(n+k)):ℝ)-(∑ i∈univ\badWindows ((model w n k p θ G t).representative z) (bad z), + (goodMiddle w n k p θ G t z (bad z) i).card:ℕ)))≤5*B := by + have h:=bad_predeletion_mean w n k p θ G t hp bad + have hh : (2*(n+k):ℕ)≤4*n := by omega + have hh' : ((2*(n+k):ℕ):ℝ)≤4*(n:ℝ) := by exact_mod_cast hh + have hn : 0≤∑ z,((model w n k p θ G t).freshLaw hp).mass z* + (((model w n k p θ G t).freshSelected z∩bad z).card:ℝ) := + sum_nonneg (fun z _=>mul_nonneg (((model w n k p θ G t).freshLaw hp).nonneg z) (by positivity)) + have hmul:=mul_le_mul_of_nonneg_right hh' hn + nlinarith + +end +end SharpLogRamsey.Selection.Windows + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Selection/ProducedSupportLoss.lean b/lean/OAI/Combinatorics/SharpRamsey/Selection/ProducedSupportLoss.lean new file mode 100644 index 0000000000000000000000000000000000000000..5166bc216de302411477d69b542c2388defb0904 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Selection/ProducedSupportLoss.lean @@ -0,0 +1,91 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Geometry.ReadyProjectiveValidation + +namespace OAI + +section +namespace SharpLogRamsey.PublicTables +open Finset +open scoped Classical BigOperators +noncomputable section +variable {Ω Y : Type*} [Fintype Ω] + +lemma integral_finset_sum (p : Law Ω) (A : Ω→Prop) (f : Y→Ω→ℝ) (s : Finset Y) (m : ℕ) : + integral p A (fun z => ∑ y∈s,f y z) m = ∑ y∈s,integral p A (f y) m := by + have ho (z : Table Ω m) : outcome A (fun z => ∑ y∈s,f y z) m z= + ∑ y∈s,outcome A (f y) m z := by + unfold outcome + cases first A m z <;> simp + simp only [integral,ho,mul_sum] + exact sum_comm + +lemma integral_div (p : Law Ω) (A : Ω→Prop) (f : Ω→ℝ) (b : ℝ) (m : ℕ) : + integral p A (fun z => f z/b) m=integral p A f m/b := by + have ho (z : Table Ω m) : outcome A (fun z => f z/b) m z=outcome A f m z/b := by + unfold outcome + cases first A m z <;> simp + simp only [integral,ho,←mul_div_assoc,←sum_div] + +end +end SharpLogRamsey.PublicTables + +namespace SharpLogRamsey.Validation +open Finset Real Incidence +open scoped Classical BigOperators +noncomputable section +variable {K V : Type*} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +variable [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + +def excludedFraction {Ω Y : Type*} [Fintype Ω] (R : Ω→Y→Prop) (q : ℝ) (Y₀ : Finset Y) + {h : ℕ} (z : Fin h→Ω) : ℝ := + ((Y₀.filter (fun y => ¬pass R q z y)).card:ℝ)/Y₀.card + +omit [Finite K] [FiniteDimensional K V] [Fintype (Projectivization K (Module.Dual K V))] in + +theorem produced_support_loss {h m : ℕ} + (p : PublicTables.Law (Fin h→Projectivization K V)) + (accept : (Fin h→Projectivization K V)→Prop) + (S : Finset (Projectivization K V)) + (Y : Finset (Projectivization K (Module.Dual K V))) (B q : ℝ) + (hy : ∀ y,PublicTables.integral p accept (fun z => if ¬pass SharpLogRamsey.Incidence.Incident q z y then 1 else 0) m≤ + B*(∑ x∈univ.filter (fun x => SharpLogRamsey.Incidence.Incident x y),uniformMass S x)) : + PublicTables.integral p accept (excludedFraction SharpLogRamsey.Incidence.Incident q Y) m≤ + B*(incidenceCount S Y:ℝ)/((S.card:ℝ)*Y.card) := by + have he (z : Fin h→Projectivization K V) : + excludedFraction SharpLogRamsey.Incidence.Incident q Y z=(∑ y∈Y,if ¬pass SharpLogRamsey.Incidence.Incident q z y then (1:ℝ) else 0)/(Y.card:ℝ) := by + simp only [excludedFraction,card_filter,Nat.cast_sum,Nat.cast_ite,Nat.cast_one,Nat.cast_zero] + rw [funext he] + rw [PublicTables.integral_div,PublicTables.integral_finset_sum] + have hh := sum_le_sum (fun y (_ : y∈Y) => hy y) + rw [←mul_sum,uniform_incidence_sum] at hh + simpa only [←mul_div_assoc,div_div] using + div_le_div_of_nonneg_right hh (Nat.cast_nonneg Y.card) + +theorem scheduled_support_loss {n : ℕ} (hdim : Module.finrank K V=n+3) + (S X W : Finset (Projectivization K V)) (hS : S.Nonempty) (hX : X.Nonempty) + (hXS : X⊆S) (hXW : X⊆W) + (T T' U : Finset (Projectivization K (Module.Dual K V))) (hT' : T'.Nonempty) + (hT'T : T'⊆T) (hT'U : T'⊆U) (htrim : (T.card:ℝ)≤2*T'.card) + (C a : ℝ) (hC : 1≤C) (hcap : (S.card:ℝ)≤C*X.card) + (hratio : (W.card:ℝ)≤exp a*X.card) + (hsparse : (incidenceCount S T:ℝ)≤(S.card:ℝ)*T.card/(20000*C*Nat.card K)) + (Y : Finset (Projectivization K (Module.Dual K V))) : + let q : ℝ := Nat.card K + let h := scheduleLength q U.card T'.card + let m := scheduleCutoff q a h + let M := 1000*C*q^(n+3)/S.card + let accept := implementAccept X (GoodCap SharpLogRamsey.Incidence.Incident q U T' M) + PublicTables.integral (rowLaw W (hX.mono hXW) h) accept + (excludedFraction SharpLogRamsey.Incidence.Incident q Y) m≤ + (6*C*q)*(incidenceCount S Y:ℝ)/((S.card:ℝ)*Y.card) := by + apply produced_support_loss + exact (scheduled_from_original hdim S X W hS hX hXS hXW T T' U hT' hT'T hT'U htrim + C a hC hcap hratio hsparse).2.2 + +end +end SharpLogRamsey.Validation + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Selection/ScheduledBanks.lean b/lean/OAI/Combinatorics/SharpRamsey/Selection/ScheduledBanks.lean new file mode 100644 index 0000000000000000000000000000000000000000..e69d90f4c232f1e81f4255a1d0ae188cb0257400 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Selection/ScheduledBanks.lean @@ -0,0 +1,127 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Trees.PivotCalls + +namespace OAI + +section +namespace SharpLogRamsey.ScheduledBanks +open Finset Real Validation PublicTables +open scoped Classical BigOperators +noncomputable section +variable (P Q : Type*) [Fintype P] [Fintype Q] + +abbrev Address := {W : Finset P // W.Nonempty} × Finset Q × Fin (Fintype.card Q+1) + +variable {P Q} +def length (q : ℝ) (a : Address P Q) : ℕ := + scheduleLength q a.2.1.card a.2.2.val + +def cutoff (q b : ℝ) (a : Address P Q) : ℕ := scheduleCutoff q b (length q a) + +abbrev At (q b : ℝ) (a : Address P Q) := Table (Fin (length q a) → P) (cutoff q b a) + +abbrev Bank (q b : ℝ) := ∀ a : Address P Q, At q b a + +def atLaw (q b : ℝ) (a : Address P Q) : Law (At q b a) where + mass := tableWeight (rowLaw a.1.1 a.1.2 (length q a)) (cutoff q b a) + nonneg := tableWeight_nonneg _ _ + total := tableWeight_total _ _ + +def bankLaw (q b : ℝ) : Law (Bank (P:=P) (Q:=Q) q b) := piLaw (atLaw q b) + +theorem integral (q b : ℝ) (a : Address P Q) + (A : (Fin (length q a) → P) → Prop) (f : (Fin (length q a) → P) → ℝ) : + (∑ z, (bankLaw q b).mass z * outcome A f (cutoff q b a) (z a)) = + PublicTables.integral (rowLaw a.1.1 a.1.2 (length q a)) A f (cutoff q b a) := by + rw [show bankLaw (P:=P) (Q:=Q) q b = piLaw (atLaw q b) from rfl] + rw [family_integral (atLaw q b) a (fun _ z => outcome A f (cutoff q b a) z)] + change (∑ s, (outsideLaw (atLaw q b) a).mass s * + PublicTables.integral (rowLaw a.1.1 a.1.2 (length q a)) A f (cutoff q b a)) = _ + rw [←sum_mul, (outsideLaw (atLaw q b) a).total, one_mul] + +end +end SharpLogRamsey.ScheduledBanks + +namespace SharpLogRamsey.ReadyTests +open Finset Real Incidence Validation Selection ScheduledBanks PublicTables +open scoped Classical BigOperators +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + +def Call.address {S : Finset (Projectivization K V)} (c : Call S) : + Address (Projectivization K V) (Projectivization K (Module.Dual K V)) := + ((⟨c.proposal, c.source_nonempty.mono c.source_proposal⟩), c.domain, + ⟨c.target.card, Nat.lt_succ_of_le (card_le_univ _)⟩) + +def Call.accept {S : Finset (Projectivization K V)} (c : Call S) (n : ℕ) : + (Fin (length (Nat.card K) c.address) → Projectivization K V) → Prop := + implementAccept c.source + (GoodCap SharpLogRamsey.Incidence.Incident (Nat.card K) c.domain c.target + (2000*(Nat.card K:ℝ)^(n+3)/S.card)) + +def Call.bankRow {S : Finset (Projectivization K V)} (c : Call S) + (b : ℝ) (n : ℕ) + (z : Bank (P:=Projectivization K V) (Q:=Projectivization K (Module.Dual K V)) (Nat.card K) b) : + Option (Fin (length (Nat.card K) c.address) → Projectivization K V) := + first (c.accept n) (cutoff (Nat.card K) b c.address) (z c.address) + +def Call.bankIndex {S : Finset (Projectivization K V)} (c : Call S) + (b : ℝ) (n : ℕ) + (z : Bank (P:=Projectivization K V) (Q:=Projectivization K (Module.Dual K V)) (Nat.card K) b) : + Option (Fin (cutoff (Nat.card K) b c.address)) := + firstIndex (c.accept n) (cutoff (Nat.card K) b c.address) (z c.address) + +omit [Finite K] [FiniteDimensional K V] in +theorem Call.bank_loss_eq {S : Finset (Projectivization K V)} (c : Call S) + (b : ℝ) (hb : c.overhead = b) (n : ℕ) + (y : Projectivization K (Module.Dual K V)) : + (∑ z, (bankLaw (Nat.card K) b).mass z * + (c.bankRow b n z).elim 0 (fun row => if ¬pass SharpLogRamsey.Incidence.Incident (Nat.card K) row y then 1 else 0)) = + c.loss n y := by + have h := ScheduledBanks.integral (Nat.card K) b c.address (c.accept n) + (fun row => if ¬pass SharpLogRamsey.Incidence.Incident (Nat.card K) row y then 1 else 0) + convert h using 1 + · rfl + · simp only [Call.loss, Call.accept, Call.address, length, cutoff, hb] + rfl + +omit [Finite K] [FiniteDimensional K V] in + theorem Call.bank_production_eq {S : Finset (Projectivization K V)} (c : Call S) + (b : ℝ) (hb : c.overhead = b) (n : ℕ) : + (∑ z, (bankLaw (Nat.card K) b).mass z * (c.bankRow b n z).elim 0 (fun _ => 1)) = + c.production n := by + have h := ScheduledBanks.integral (Nat.card K) b c.address (c.accept n) (fun _ => 1) + convert h using 1 + · rfl + · simp only [Call.production, Call.accept, Call.address, length, cutoff, hb] + rfl + + theorem Call.bank_loss_bound {S : Finset (Projectivization K V)} (c : Call S) + (b : ℝ) (hb : c.overhead=b) {n : ℕ} (hdim : Module.finrank K V=n+3) + (y : Projectivization K (Module.Dual K V)) : + (∑ z, (bankLaw (Nat.card K) b).mass z * + (c.bankRow b n z).elim 0 (fun row => if ¬pass SharpLogRamsey.Incidence.Incident (Nat.card K) row y then 1 else 0)) ≤ + 12*(Nat.card K:ℝ)*(∑ x, SupportMixtures.kernel S x * (if SharpLogRamsey.Incidence.Incident x y then 1 else 0)) := by + rw [c.bank_loss_eq b hb n y] + exact c.loss_bound hdim y + + theorem Call.bank_failure_bound {S : Finset (Projectivization K V)} (c : Call S) + (b : ℝ) (hb : c.overhead=b) {n : ℕ} (hdim : Module.finrank K V=n+3) : + (∑ z, (bankLaw (Nat.card K) b).mass z * (if c.bankRow b n z = none then 1 else 0)) ≤ + exp (-(Nat.card K:ℝ)) := by + have he (z) : (if c.bankRow b n z = none then (1:ℝ) else 0) = + 1-(c.bankRow b n z).elim 0 (fun _=>1) := by cases c.bankRow b n z <;> simp + simp_rw [he, mul_sub, mul_one] + rw [sum_sub_distrib, (bankLaw (P:=Projectivization K V) + (Q:=Projectivization K (Module.Dual K V)) (Nat.card K) b).total, + c.bank_production_eq b hb n] + exact c.failure_bound hdim + +end +end SharpLogRamsey.ReadyTests + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Selection/SourceGridShape.lean b/lean/OAI/Combinatorics/SharpRamsey/Selection/SourceGridShape.lean new file mode 100644 index 0000000000000000000000000000000000000000..ec8fdb495f273a6622bb4b01189194161976122d --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Selection/SourceGridShape.lean @@ -0,0 +1,63 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Parameters.SourcePencilScales +import OAI.Combinatorics.SharpRamsey.Geometry.SparsePencilBounds + +namespace OAI + +section +namespace SharpLogRamsey.SourceScales +open Filter Real Finset +open scoped Topology BigOperators +noncomputable section + +lemma log_grid_bound {n : ℕ} (hn : 0 if a ∈ S then p.mass a else 0) + (fun b => if b ∈ T then q.mass b else 0) (fun a b => if R a b then 1 else 0) = + (p.prod q).event (univ.filter (fun z => z.1 ∈ S ∧ z.2 ∈ T ∧ R z.1 z.2)) := by + simp only [SupportMixtures.pairing, Law.event, sum_filter, Fintype.sum_prod_type, Law.prod] + apply sum_congr rfl + intro a _ + apply sum_congr rfl + intro b _ + by_cases ha : a ∈ S <;> by_cases hb : b ∈ T <;> by_cases hR : R a b <;> + simp [ha, hb, hR] + +lemma auxiliary_good_mixture (p : Law A) (good : Finset A) (M K : ℝ) + (ρ : Law (retainedLevels p good M K)) + (hρ : ∀ a, (∑ b : retainedLevels p good M K, ρ.mass b * + (if a ∈ levelSet p b ∩ good then 1 / ((levelSet p b ∩ good).card : ℝ) else 0)) + ≤ 4 * exp 1 * p.mass a) : + ∀ a, SupportMixtures.mixture ρ.mass (fun b => levelSet p b ∩ good) a ≤ + (4 * exp 1) * (if a ∈ good then p.mass a else 0) := by + intro a + by_cases ha : a ∈ good + · simpa only [ite_eq_left ha, SupportMixtures.mixture, SupportMixtures.kernel] using hρ a + · simp [SupportMixtures.mixture, SupportMixtures.kernel, ha] + +theorem actual_auxiliary_incidence (p : Law A) (q : Law B) + (goodA : Finset A) (goodB : Finset B) (MA MB K : ℝ) + (ρ : Law (retainedLevels p goodA MA K)) + (τ : Law (retainedLevels q goodB MB K)) + (hρ : ∀ a, (∑ b : retainedLevels p goodA MA K, ρ.mass b * + (if a ∈ levelSet p b ∩ goodA then 1 / ((levelSet p b ∩ goodA).card : ℝ) else 0)) + ≤ 4 * exp 1 * p.mass a) + (hτ : ∀ a, (∑ b : retainedLevels q goodB MB K, τ.mass b * + (if a ∈ levelSet q b ∩ goodB then 1 / ((levelSet q b ∩ goodB).card : ℝ) else 0)) + ≤ 4 * exp 1 * q.mass a) + (R : A → B → Prop) : + (∑ a, ∑ b, ρ.mass a * τ.mass b * + (((((levelSet p a ∩ goodA) ×ˢ (levelSet q b ∩ goodB)).filter + (fun z => R z.1 z.2)).card : ℝ) / + (((levelSet p a ∩ goodA).card : ℝ) * (levelSet q b ∩ goodB).card))) ≤ + (4 * exp 1)^2 * (p.prod q).event + (univ.filter (fun z => z.1 ∈ goodA ∧ z.2 ∈ goodB ∧ R z.1 z.2)) := by + have H := SupportMixtures.independent_pairing_le ρ.mass τ.mass + (fun b => levelSet p b ∩ goodA) (fun b => levelSet q b ∩ goodB) + (fun a b => if R a b then (1:ℝ) else 0) + (fun a => if a ∈ goodA then p.mass a else 0) + (fun b => if b ∈ goodB then q.mass b else 0) + (4 * exp 1) (4 * exp 1) ρ.nonneg τ.nonneg (by intros; split_ifs <;> norm_num) + (auxiliary_good_mixture p goodA MA K ρ hρ) + (auxiliary_good_mixture q goodB MB K τ hτ) + simpa only [SupportMixtures.kernel_incidence, good_pairing_eq_event, pow_two] using H + +lemma pairing_reverse (f : A → ℝ) (g : B → ℝ) (R : A → B → ℝ) : + SupportMixtures.pairing f g R = + SupportMixtures.pairing g f (fun b a => R a b) := by + unfold SupportMixtures.pairing + rw [sum_comm] + apply sum_congr rfl + intro b _ + apply sum_congr rfl + intro a _ + rw [mul_comm (f a)] + +theorem actual_auxiliary_target_left (p : Law A) (q : Law B) + (goodA : Finset A) (goodB : Finset B) (MA K : ℝ) + (ρ : Law (retainedLevels p goodA MA K)) + (hρ : ∀ a, (∑ b : retainedLevels p goodA MA K, ρ.mass b * + (if a ∈ levelSet p b ∩ goodA then 1 / ((levelSet p b ∩ goodA).card : ℝ) else 0)) + ≤ 4 * exp 1 * p.mass a) + (R : A → B → Prop) : + (∑ b, ρ.mass b * SupportMixtures.pairing + (SupportMixtures.kernel (levelSet p b ∩ goodA)) + (fun y => if y ∈ goodB then q.mass y else 0) + (fun a y => if R a y then 1 else 0)) ≤ + (4 * exp 1) * (p.prod q).event + (univ.filter (fun z => z.1 ∈ goodA ∧ z.2 ∈ goodB ∧ R z.1 z.2)) := by + have H := SupportMixtures.one_sided_pairing_le ρ.mass + (fun b => levelSet p b ∩ goodA) + (fun a => if a ∈ goodA then p.mass a else 0) + (fun y => if y ∈ goodB then q.mass y else 0) + (fun a y => if R a y then (1:ℝ) else 0) (4 * exp 1) ρ.nonneg + (by intro y; split_ifs <;> simp [q.nonneg]) + (by intros; split_ifs <;> norm_num) + (auxiliary_good_mixture p goodA MA K ρ hρ) + simpa only [good_pairing_eq_event] using H + +theorem actual_auxiliary_target_right (p : Law A) (q : Law B) + (goodA : Finset A) (goodB : Finset B) (MB K : ℝ) + (τ : Law (retainedLevels q goodB MB K)) + (hτ : ∀ a, (∑ b : retainedLevels q goodB MB K, τ.mass b * + (if a ∈ levelSet q b ∩ goodB then 1 / ((levelSet q b ∩ goodB).card : ℝ) else 0)) + ≤ 4 * exp 1 * q.mass a) + (R : A → B → Prop) : + (∑ b, τ.mass b * SupportMixtures.pairing + (fun a => if a ∈ goodA then p.mass a else 0) + (SupportMixtures.kernel (levelSet q b ∩ goodB)) + (fun a y => if R a y then 1 else 0)) ≤ + (4 * exp 1) * (p.prod q).event + (univ.filter (fun z => z.1 ∈ goodA ∧ z.2 ∈ goodB ∧ R z.1 z.2)) := by + have H := actual_auxiliary_target_left q p goodB goodA MB K τ hτ (fun b a => R a b) + rw [← good_pairing_eq_event q p goodB goodA (fun b a => R a b)] at H + rw [pairing_reverse (fun b => if b ∈ goodB then q.mass b else 0)] at H + have he (b : retainedLevels q goodB MB K) : + SupportMixtures.pairing (SupportMixtures.kernel (levelSet q b ∩ goodB)) + (fun a => if a ∈ goodA then p.mass a else 0) + (fun y a => if R a y then (1:ℝ) else 0) = + SupportMixtures.pairing (fun a => if a ∈ goodA then p.mass a else 0) + (SupportMixtures.kernel (levelSet q b ∩ goodB)) + (fun a y => if R a y then (1:ℝ) else 0) := pairing_reverse _ _ _ + simpa only [he, good_pairing_eq_event] using H + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Selection/SupportThreshold.lean b/lean/OAI/Combinatorics/SharpRamsey/Selection/SupportThreshold.lean new file mode 100644 index 0000000000000000000000000000000000000000..f18ab0d79569a6c87b78a2420fd0d4b9444612dc --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Selection/SupportThreshold.lean @@ -0,0 +1,98 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Selection.EndpointSupports + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset Real Filter +open scoped Classical BigOperators Topology +noncomputable section + +lemma log_entropy_envelope {x A h : ℝ} (hx : 1≤x) (hA : 0≤A) + (hh : 0≤h) (hcap : h≤A*x) : + log (h+2) ≤ log (A+2)+log x := by + have hx0 : 0 (2+100*exp 1)*x^(-2*b)) atTop (𝓝 0) := by + simpa only [mul_zero, neg_mul] using + (tendsto_rpow_neg_atTop (show 0<2*b by positivity)).const_mul (2+100*exp 1) + have h₂ : Tendsto (fun x : ℝ => + (2*(log (2*C)+2*log (A+2)+2)+100*exp 1*C₀)/x^(4*b)) atTop (𝓝 0) := by + have h := (tendsto_rpow_neg_atTop (show 0<4*b by positivity)).const_mul + (2*(log (2*C)+2*log (A+2)+2)+100*exp 1*C₀) + simp only [mul_zero] at h + apply (h.congr' ?_) + filter_upwards [eventually_ge_atTop (0:ℝ)] with x hx + simp only [Real.rpow_neg hx, div_eq_mul_inv] + have h₃ : Tendsto (fun x : ℝ => 4*log x/x^(4*b)) atTop (𝓝 0) := by + simpa only [mul_div_assoc, mul_zero] using + ((isLittleO_log_rpow_atTop (show 0<4*b by positivity)).tendsto_div_nhds_zero).const_mul 4 + have h₄ : Tendsto (fun x : ℝ => 2*exp 1*exp (-(x^(4*b)))) atTop (𝓝 0) := by + have h := Real.tendsto_exp_atBot.comp (tendsto_neg_atTop_atBot.comp (tendsto_rpow_atTop (show 0<4*b by positivity))) + simpa only [Function.comp_def, mul_zero] using h.const_mul (2*exp 1) + unfold supportErrorEnvelope + simpa only [add_zero] using ((h₁.add h₂).add h₃).add h₄ + +theorem eventually_support_small (b C C₀ A : ℝ) (hb : 0 rfl + | some x => exact h x (first_valid A m z x he) + +lemma integral_const (p : Law Ω) (A : Ω→Prop) (c : ℝ) (m : ℕ) : + integral p A (fun _ => c) m=c*integral p A (fun _ => 1) m := by + have ho (z : Table Ω m) : outcome A (fun _ => c) m z=c*outcome A (fun _ => 1) m z := by + unfold outcome + cases first A m z <;> simp + simp only [integral,ho,mul_sum] + apply sum_congr rfl + intro z _ + ring + +lemma integral_sub (p : Law Ω) (A : Ω→Prop) (f g : Ω→ℝ) (m : ℕ) : + integral p A (fun z => f z-g z) m=integral p A f m-integral p A g m := by + have ho (z : Table Ω m) : outcome A (fun z => f z-g z) m z= + outcome A f m z-outcome A g m z := by + unfold outcome + cases first A m z <;> simp + simp only [integral,ho,mul_sub,sum_sub_distrib] + +lemma integral_one_nonneg (p : Law Ω) (A : Ω→Prop) (m : ℕ) : + 0≤ integral p A (fun _ => 1) m := by + apply sum_nonneg + intro z _ + apply mul_nonneg (tableWeight_nonneg p m z) + unfold outcome + cases first A m z <;> norm_num + +lemma integral_one_le (p : Law Ω) (A : Ω→Prop) (m : ℕ) : + integral p A (fun _ => 1) m≤1 := by + calc + _ ≤ ∑ z,tableWeight p m z := ?_ + _ = 1 := tableWeight_total p m + apply sum_le_sum + intro z _ + have ho : outcome A (fun _ => 1) m z≤1 := by + unfold outcome + cases first A m z <;> norm_num + simpa only [mul_one] using mul_le_mul_of_nonneg_left ho (tableWeight_nonneg p m z) + +theorem integral_bounded (p : Law Ω) (A : Ω→Prop) (f : Ω→ℝ) (m : ℕ) + (B : ℝ) (hB : 0≤ B) (hf : ∀ z,A z→f z≤ B) : integral p A f m≤ B := by + apply (integral_on_mono p A f (fun _ => B) m hf).trans + rw [integral_const] + exact (mul_le_mul_of_nonneg_left (integral_one_le p A m) hB).trans_eq (mul_one B) + +theorem two_stage_failure (p : Law Ω) (A : Ω→Prop) (next : Ω→ℝ) (m : ℕ) + (δ δ' : ℝ) (hδ' : 0≤δ') + (hfirst : 1-integral p A (fun _ => 1) m≤δ) + (hnext : ∀ z,A z→1-next z≤δ') : + 1-integral p A next m≤δ+δ' := by + have hh := integral_bounded p A (fun z => 1-next z) m δ' hδ' hnext + rw [integral_sub] at hh + linarith + +end +end SharpLogRamsey.PublicTables + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Selection/UnifiedContext.lean b/lean/OAI/Combinatorics/SharpRamsey/Selection/UnifiedContext.lean new file mode 100644 index 0000000000000000000000000000000000000000..e0fc0f5bce1d92cf704b9ad74edcb3dce3a551cd --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Selection/UnifiedContext.lean @@ -0,0 +1,43 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.ContextOutput + +namespace OAI + +section +namespace SharpLogRamsey.ActualHighRank +open Finset Selection +open scoped Classical BigOperators +noncomputable section +variable {Ω F Γ : Type} [Fintype Ω] [Fintype F] [Fintype Γ] + {ℓ m : ℕ} {p : Law Ω} {G : Ω→Fin ℓ→F} {DD : Γ→Finset F} {B C : ℝ} + +def StreamReplacement.toContextOutput (e : StreamReplacement p G Fin.val m DD B C) : + ContextOutput p G m B C 4 := by + let X':={x : e.X // e.μ.mass x≠0} + let S:=univ.image e.msg + let msg : X'→S:=fun x=>⟨e.msg x.val,mem_image.mpr ⟨x.val,mem_univ _,rfl⟩⟩ + refine ⟨X',S,inferInstance,inferInstance,e.μ.nullFree,(fun x=>e.source x.val),msg, + (fun x=>OrderEmbedding.ofStrictMono (e.index x.val) (e.ordered x.val)), + (fun c _=>DD c.val),?_,?_,?_,?_,?_⟩ + · intro x + exact e.supported x.val x.property + · intro x i + exact e.hit x.val x.property i + · intro c i + obtain ⟨x,_,hx⟩:=mem_image.mp c.property + rw [←hx] + exact e.size x + · intro a + rw [Law.nullFree_map] + exact e.dominated a + · have he:=entropy_map_eq_of_injective (e.μ.nullFree.map msg) (Subtype.val : S→Γ) Subtype.val_injective + rw [Law.map_map] at he + change entropy (e.μ.nullFree.map (fun x=>e.msg x.val))=entropy (e.μ.nullFree.map msg) at he + rw [Law.nullFree_map] at he + exact he ▸ e.cost +end +end SharpLogRamsey.ActualHighRank + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Selection/UniversalTables.lean b/lean/OAI/Combinatorics/SharpRamsey/Selection/UniversalTables.lean new file mode 100644 index 0000000000000000000000000000000000000000..09c89372e5d296c0b34b20f9977b49b1fed2e3c6 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Selection/UniversalTables.lean @@ -0,0 +1,117 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Learning.PreparedShortRow + +namespace OAI + +section +namespace SharpLogRamsey.PublicTables +open Finset Real +open scoped Classical BigOperators +noncomputable section +variable {Ω ι : Type*} [Fintype Ω] [Fintype ι] + +def rows : (n : ℕ) → Table Ω n → Finset Ω + | 0, _ => ∅ + | n+1, z => insert z.1 (rows n z.2) + +omit [Fintype Ω] in +lemma rows_card_le (n : ℕ) (z : Table Ω n) : (rows n z).card≤n := by + induction n with + | zero => simp [rows] + | succ n ih => exact (card_insert_le _ _).trans (Nat.add_le_add_right (ih _) 1) + +omit [Fintype Ω] in +lemma first_none_iff (A : Ω→Prop) (n : ℕ) (z : Table Ω n) : + first A n z=none ↔ ∀ x∈rows n z,¬A x := by + induction n with + | zero => simp [first,rows] + | succ n ih => + by_cases h : A z.1 + · simp [first,rows,h] + · simpa [first,rows,h] using ih z.2 + +lemma missed_probability (p : Law Ω) (A : Ω→Prop) (n : ℕ) : + (∑ z,tableWeight p n z*(if first A n z=none then 1 else 0))=(1-acceptProb p A)^n := by + have hh (z : Table Ω n) : + (if first A n z=none then (1:ℝ) else 0)=1-outcome A (fun _ => 1) n z := by + unfold outcome + cases first A n z <;> simp + simp_rw [hh,mul_sub,mul_one] + rw [sum_sub_distrib,tableWeight_total] + change 1-integral p A (fun _ => 1) n=_ + rw [production_probability] + ring + +lemma missing_exp (p : Law Ω) (A : Ω→Prop) (n : ℕ) : + (1-acceptProb p A)^n≤exp (-(n:ℝ)*acceptProb p A) := by + have hh : 1-acceptProb p A≤exp (-acceptProb p A) := by + have := add_one_le_exp (-acceptProb p A) + linarith + have hp := pow_le_pow_left₀ (sub_nonneg.mpr (acceptProb_le_one p A)) hh n + rw [←exp_nat_mul] at hp + simpa only [mul_neg,neg_mul] using hp + +theorem exists_universal (p : Law Ω) (A : ι→Ω→Prop) (n : ℕ) + (h : (∑ i,(1-acceptProb p (A i))^n)<1) : + ∃ z : Table Ω n,∀ i,∃ x∈rows n z,A i x := by + by_contra! hn + have hl (z : Table Ω n) : + (1:ℝ)≤∑ i,if first (A i) n z=none then 1 else 0 := by + obtain ⟨i,hi⟩ := hn z + have hm : first (A i) n z=none := (first_none_iff _ _ _).mpr hi + have hh := single_le_sum (f := fun i => if first (A i) n z=none then (1:ℝ) else 0) + (fun i _ => by split_ifs <;> norm_num) (mem_univ i) + simpa [hm] using hh + have hh : (1:ℝ)≤∑ z,tableWeight p n z*(∑ i,if first (A i) n z=none then 1 else 0) := by + calc + _ = ∑ z,tableWeight p n z := (tableWeight_total p n).symm + _ ≤ _ := by + apply sum_le_sum + intro z _ + simpa only [mul_one] using mul_le_mul_of_nonneg_left (hl z) (tableWeight_nonneg p n z) + simp_rw [mul_sum] at hh + rw [sum_comm] at hh + simp_rw [missed_probability] at hh + linarith + +theorem exists_cover (p : Law Ω) (A : ι→Ω→Prop) (a H : ℝ) + (ha : 0≤a) (hcard : (Fintype.card ι:ℝ)≤exp H) (hH : H+1≤exp a) + (hp : ∀ i,exp (-a)≤acceptProb p (A i)) : + ∃ r : Finset Ω,r.card≤⌈exp (2*a)⌉₊ ∧ (∀ i,∃ x∈r,A i x) ∧ + log ((⌈exp (2*a)⌉₊:ℝ)+1)≤2*a+log 3 := by + let n := ⌈exp (2*a)⌉₊ + have hN : exp (2*a)≤(n:ℝ) := Nat.le_ceil _ + have hl : (∑ i,(1-acceptProb p (A i))^n)<1 := by + calc + _ ≤ (∑ _i : ι,exp (-(n:ℝ)*exp (-a))) := by + apply sum_le_sum + intro i _ + apply (missing_exp p (A i) n).trans + apply exp_le_exp.mpr + have hh := mul_le_mul_of_nonneg_left (hp i) (Nat.cast_nonneg n : (0:ℝ)≤n) + nlinarith only [hh] + _ = (Fintype.card ι:ℝ)*exp (-(n:ℝ)*exp (-a)) := by simp + _ ≤ exp H*exp (-(n:ℝ)*exp (-a)) := by gcongr + _ = exp (H-(n:ℝ)*exp (-a)) := by rw [←exp_add]; congr 1; ring + _ ≤ exp (-1) := by + apply exp_le_exp.mpr + have hh := mul_le_mul_of_nonneg_right hN (exp_pos (-a)).le + have he : exp (2*a)*exp (-a)=exp a := by rw [←exp_add]; congr 1; ring + rw [he] at hh + linarith + _ < 1 := exp_lt_one_iff.mpr (by norm_num) + obtain ⟨z,hz⟩ := exists_universal p A n hl + refine ⟨rows n z,rows_card_le n z,hz,?_⟩ + have hn : (n:ℝ) (W : Set V)) SetLike.coe_injective +local instance flat_JoinedPreparedSpatialRadial_4 : Fintype (Submodule K V) := Fintype.ofFinite _ + +theorem list_radial_exceptions (F : Finset (Submodule K V)) (m : ℕ) + (S : Finset (Projectivization K V)) (bs : List (Submodule K V)) + (h : GreedyPreparation.Complete F planePoints m S bs) + (c K₀ : ℝ) (hc : 0 GreedyPreparation.removed S planePoints bs \ + (GreedyPreparation.own S planePoints bs x∪{x}) + let r := fun x i => (richRadials (X x) x c (a i)).card + apply RadialExceptions.radial_exceptions T a ha r + (c*(GreedyPreparation.removed S planePoints bs).card) K₀ + (8*(c*(GreedyPreparation.removed S planePoints bs).card)^2) hK (by positivity) + · intro x i _ + apply (richRadials_mul_le (X x) x c (a i) hc.le).trans + exact mul_le_mul_of_nonneg_left (Nat.cast_le.mpr (card_le_card sdiff_subset)) hc.le + · intro i hi hk + exact list_radial_pairs F m S bs h c (a i) hc (ha i hi).le + (hJ i hi hk) (hM i hi hk) + +theorem list_strong_exceptions (F : Finset (Submodule K V)) (m : ℕ) + (S : Finset (Projectivization K V)) (bs : List (Submodule K V)) + (h : GreedyPreparation.Complete F planePoints m S bs) + (c a : ℝ) (hc : 0 f P.rep=0)).card≤Kp) + (T : Finset I) (a : I→ℝ) (ha : ∀ i∈T,0 (richRadials (X x) x c (a i)).card) + (c*S.card) K₀ (17436*((q:ℝ)+1)*(c*S.card)) hK (by positivity) + · intro x i _ + exact (richRadials_mul_le (X x) x c (a i) hc.le).trans + (mul_le_mul_of_nonneg_left (Nat.cast_le.mpr (card_le_card (hX x))) hc.le) + · intro i hi hk + obtain ⟨hM,hMN,hs,hch,hp,hKM⟩ := htests i hi hk + have hh := residual_radial_pairs hq S hS X hX c (a i) hc + (ha i hi).le Kp (by omega) hMN hcap hs hch hp hKM + have hz := mul_nonneg + (show 0≤((q:ℝ)+1)*(c*S.card) by positivity) (sub_nonneg.mpr (ha2 i hi)) + exact hh.trans (by nlinarith only [hz]) + +theorem residual_strong_exceptions (hq : 3≤q) + (S : Finset (Projectivization (ZMod q) (Fin 4→ZMod q))) (hS : S.Nonempty) + (X : Projectivization (ZMod q) (Fin 4→ZMod q)→Finset (Projectivization (ZMod q) (Fin 4→ZMod q))) + (hX : ∀ x,X x⊆S) (c a : ℝ) (hc : 0 f P.rep=0)).card≤Kp) + (hsmall : 198*Real.sqrt ((S.card:ℝ)/⌈a/c⌉₊)<⌈a/c⌉₊) + (hchar : 33*Real.sqrt ((S.card:ℝ)/⌈a/c⌉₊) (W : Set (Fin 4→ZMod q))) + SetLike.coe_injective +local instance flat_JoinedSpatialActualCover_2 (q : ℕ) [Fact q.Prime] : + Fintype (Submodule (ZMod q) (Fin 4→ZMod q)) := Fintype.ofFinite _ + +local instance flat_JoinedSpatialActualCover_3 (q : ℕ) [Fact q.Prime] : + Fintype (Projectivization (ZMod q) (Fin 4 → ZMod q)) := Fintype.ofFinite _ +local instance flat_JoinedSpatialActualCover_4 (q : ℕ) [Fact q.Prime] : + Fintype (Projectivization (ZMod q) (Module.Dual (ZMod q) (Fin 4 → ZMod q))) := by + letI : Finite (Module.Dual (ZMod q) (Fin 4 → ZMod q)) := Module.finite_of_finite (ZMod q) + exact Fintype.ofFinite _ + +theorem actual_cover (δ C : ℝ) (hδ : 0 < δ) : + ∀ᶠ σ : ℝ in atTop,∀ (q : ℕ) [Fact q.Prime],3 ≤ q → exp σ=(q:ℝ) → + ∀ (U : Finset (Projectivization (ZMod q) (Fin 4→ZMod q))) + (n Jmax : ℕ) (P g b τ : ℝ) (L : ℝ≥0) (R p h M : ℕ), + 0 < n → n ≤ U.card → σ^δ ≤ P → P ≤ σ/40 → g ≤ σ/2+C → 0 < p → (p:ℝ) ≤ σ^2 → + (n:ℝ)=exp (3*σ/2+g) → exp (σ/2-2*g/15) ≤ Jmax → + (∀ m,0 < m → m ≤ n → n ≤ 2*m → Budget σ P L R (Nat.log 2 m+2) p h) → + 0 ≤ b → 0 < τ → τ ≤ 1/40 → 200*(q:ℝ)*P ≤ n → + b+log 2+4*P*τ ≤ P/1000000 → + 50000*exp (-(95/100:ℝ)*(L:ℝ)) ≤ exp (-(b+log 2)-4*P*τ)/800 → + 2*(q:ℝ)*P ≤ M → + let H := (Fintype.card (Projectivization (ZMod q) (Fin 4→ZMod q)):ℝ)*log 2 + let E := 2*((M:ℝ)*log (2*U.card/n)+4*P*τ+log 4+log (H+1))+log 3+ + log ((Fintype.card (Projectivization (ZMod q) (Module.Dual (ZMod q) (Fin 4→ZMod q))):ℝ)+1) + ∃ caps : Finset (Finset (Projectivization (ZMod q) (Fin 4→ZMod q))), + (∀ W ∈ caps,W⊆U ∧ (W.card:ℝ) ≤ n*exp (6*P)) ∧ + (∀ (S : Finset (Projectivization (ZMod q) (Fin 4→ZMod q))) + (T : Finset (Projectivization (ZMod q) (Module.Dual (ZMod q) (Fin 4→ZMod q)))), + S⊆U → S.card=n → T.Nonempty → S.card ≤ T.card → + (q:ℝ)^4*exp (-b) ≤ (S.card:ℝ)*T.card → + (Incidence.incidenceCount S T:ℝ) ≤ τ*(S.card:ℝ)*T.card/q → + (∃ W : Submodule (ZMod q) (Fin 4→ZMod q),Module.finrank (ZMod q) W=3 ∧ + (n:ℝ)/50 ≤ (S∩planePoints W).card) ∨ + (∃ W ∈ caps,(n:ℝ)/4 ≤ (S∩W).card)) ∧ + (caps.card:ℝ) ≤ (n+1:ℕ)*(Jmax+1:ℕ)* + (((Nat.card (Submodule (ZMod q) (Fin 4→ZMod q))*(n+1)+1:ℕ):ℝ)^Jmax)*exp E := by + filter_upwards [actual_prepared_input δ C hδ] with σ hprep + intro q _ hq hqexp U n Jmax P g b τ L R p h M hn hnu hP hPu hgu hp hpu hN hJ hbud hb hτ hτu hnlarge hloss herror hM + dsimp only + let H := (Fintype.card (Projectivization (ZMod q) (Fin 4→ZMod q)):ℝ)*log 2 + let E := 2*((M:ℝ)*log (2*U.card/n)+4*P*τ+log 4+log (H+1))+log 3+ + log ((Fintype.card (Projectivization (ZMod q) (Module.Dual (ZMod q) (Fin 4→ZMod q))):ℝ)+1) + let B := ((Jmax+1:ℕ):ℝ)* + (((Nat.card (Submodule (ZMod q) (Fin 4→ZMod q))*(n+1)+1:ℕ):ℝ)^Jmax)*exp E + let ms := (range (n+1)).filter (fun m => 0 < m ∧ n ≤ 2*m ∧ m ≤ U.card) + have hmr (m : ℕ) (hm : m ∈ ms) : 0 < m ∧ m ≤ n ∧ n ≤ 2*m ∧ m ≤ U.card := by + obtain ⟨hm,hpos,hhalf,hU⟩ := mem_filter.mp hm + exact ⟨hpos,by have := mem_range.mp hm; omega,hhalf,hU⟩ + have hB : 0 ≤ B := by dsimp [B]; positivity + have hex (m : ℕ) : ∃ caps : Finset (Finset (Projectivization (ZMod q) (Fin 4→ZMod q))), + (m ∈ ms → (∀ W ∈ caps,W⊆U ∧ (W.card:ℝ) ≤ n*exp (6*P)) ∧ + (∀ S,(∃ bs ∈ headers Jmax m,Input U m planePoints bs σ P g (b+log 2) (2*τ) + (Real.toNNReal ((q:ℝ)/m)) p S) → ∃ W ∈ caps,(m:ℝ)/2 ≤ (S∩W).card) ∧ + (caps.card:ℝ) ≤ B) := by + by_cases hm : m ∈ ms + · obtain ⟨hmp,hmn,hnm,hmu⟩ := hmr m hm + have hmp' : (0:ℝ) < m := by exact_mod_cast hmp + have hm': (m:ℝ) ≤ n := by exact_mod_cast hmn + have hnm': (n:ℝ) ≤ 2*m := by exact_mod_cast hnm + have hc : (Real.toNNReal ((q:ℝ)/m):ℝ)=(Nat.card (ZMod q):ℝ)/m := by + rw [Nat.card_eq_fintype_card,ZMod.card,Real.coe_toNNReal _ (by positivity)] + have hdim : Module.finrank (ZMod q) (Fin 4→ZMod q)=4 := by simp + have hx : exp σ=(Nat.card (ZMod q):ℝ) := by simpa only [Nat.card_eq_fintype_card,ZMod.card] using hqexp + obtain ⟨caps,hsize,hcap,hcount⟩ := public_header_cover hdim U m hmp hmu planePoints Jmax + σ P g (b+log 2) (2*τ) L (Real.toNNReal ((q:ℝ)/m)) R p h M hx hc + (hbud m hmp hmn hnm) (by have := log_pos (by norm_num : (1:ℝ) < 2); linarith) + (by linarith) (by linarith) + (by simpa only [Nat.card_eq_fintype_card,ZMod.card] using (show 100*(q:ℝ)*P ≤ m by linarith)) + (by nlinarith) (by simpa only [show (2:ℝ)*P*(2*τ)=4*P*τ by ring] using herror) + (by simpa only [Nat.card_eq_fintype_card,ZMod.card] using hM) + refine ⟨caps,fun _ => ⟨?_,hcap,?_⟩⟩ + · intro W hW + obtain ⟨hWU,hWc⟩ := hsize W hW + exact ⟨hWU,hWc.trans (mul_le_mul_of_nonneg_right hm' (exp_pos _).le)⟩ + · apply hcount.trans + dsimp only [B,E,H] + apply mul_le_mul + · apply mul_le_mul_of_nonneg_left _ (by positivity) + apply pow_le_pow_left₀ (by positivity) + rw [Nat.card_eq_fintype_card] + norm_cast + gcongr + · apply exp_le_exp.mpr + have hn' : (0:ℝ) < n := by exact_mod_cast hn + have hU' : (0:ℝ) < U.card := hn'.trans_le (by exact_mod_cast hnu) + have hlog : log ((U.card:ℝ)/m) ≤ log (2*U.card/n) := by + apply log_le_log (by positivity) + apply (div_le_div_iff₀ hmp' hn').mpr + nlinarith + have hmul := mul_le_mul_of_nonneg_left hlog (Nat.cast_nonneg M) + nlinarith + · positivity + · positivity + · exact ⟨∅,fun h => (hm h).elim⟩ + choose family hf using hex + let caps := ms.biUnion family + refine ⟨caps,?_,?_,?_⟩ + · intro W hW + obtain ⟨m,hm,hW⟩ := mem_biUnion.mp hW + exact (hf m hm).1 W hW + · intro S T hSU hSn hT hST hprod hsp + have hS : S.Nonempty := card_pos.mp (by omega) + have hNS : (S.card:ℝ)=exp (3*σ/2+g) := by simpa only [hSn] using hN + rcases hprep q hq hqexp U S T hSU hS hT hST P g b τ p hτ.le hP hPu hgu hp hpu hNS hprod hsp with hh|hh + · exact Or.inl (by simpa only [hSn] using hh) + · obtain ⟨S',planes,hsub,hS',hhalf,hplanes,_,hinput⟩ := hh + have hm : S'.card ∈ ms := by + apply mem_filter.mpr + refine ⟨mem_range.mpr ?_,card_pos.mpr hS',?_,card_le_card (hsub.trans hSU)⟩ + · have := card_le_card hsub; omega + · simpa only [hSn] using hhalf + have hpl : planes.length ≤ Jmax := by + exact_mod_cast hplanes.trans hJ + have hheader := sized_header S' planePoints planes Jmax S'.card hpl le_rfl + obtain ⟨W,hW,hcap⟩ := (hf S'.card hm).2.1 S' ⟨_,hheader,hinput⟩ + right + refine ⟨W,mem_biUnion.mpr ⟨_,hm,hW⟩,?_⟩ + have hhalf' : (n:ℝ) ≤ 2*S'.card := by exact_mod_cast (show n ≤ 2*S'.card by omega) + have hmon : ((S'∩W).card:ℝ) ≤ (S∩W).card := by + exact_mod_cast (card_le_card (inter_subset_inter hsub (Subset.refl W))) + linarith + · have hcount : (caps.card:ℝ) ≤ ∑ m ∈ ms,((family m).card:ℝ) := by exact_mod_cast card_biUnion_le + calc + _ ≤ ∑ m ∈ ms,((family m).card:ℝ) := hcount + _ ≤ ∑ _m ∈ ms,B := sum_le_sum (fun m hm => (hf m hm).2.2) + _ = (ms.card:ℝ)*B := by simp + _ ≤ (n+1:ℕ)*B := mul_le_mul_of_nonneg_right (by + exact_mod_cast (card_filter_le _ _).trans_eq (card_range _)) hB + _ = _ := by dsimp [B,E,H]; ring + +end +end SharpLogRamsey.SpatialPublic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialBudget.lean b/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..3b1f6372518f1c3e6067ec727b3dbb1fa888bd4b --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialBudget.lean @@ -0,0 +1,95 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Parameters.PlanarScales +import OAI.Combinatorics.SharpRamsey.Spatial.SpatialPencils + +namespace OAI + +section +namespace SharpLogRamsey.SpatialLearning +open Finset Real Filter SourceScales +open scoped Topology NNReal +noncomputable section + +structure Budget (σ P : ℝ) (L : ℝ≥0) (R N p h : ℕ) : Prop where + sigma : 2≤σ + large : 100000000000000≤P + upper : P≤σ + B : 2*exp (6*P)≤exp σ + identity : P=(L:ℝ)*R + Llarge : 10000≤(L:ℝ) + Rlarge : 400≤R + p_pos : 0

(W:Set (Fin 4 → ZMod q))) + SetLike.coe_injective + +theorem complete_cover {η : ℝ} (hη : 0<η) (C : ℝ) (hC : 1≤C) : + ∀ᶠ σ : ℝ in atTop,∀ (q : ℕ) [Fact q.Prime],3≤q → exp σ=(q:ℝ) → + ∀ D R,Admissible σ η D R → + ∀ (U : Finset (Projectivization (ZMod q) (Fin 4 → ZMod q))) + (UT : Finset (Projectivization (ZMod q) (Module.Dual (ZMod q) (Fin 4 → ZMod q)))) + (n t : ℕ) (b τ : ℝ), + 0 C*σ^(-100*beta η)) atTop (𝓝 0) := by + simpa using (tendsto_rpow_neg_atTop (by have := beta_pos hη; positivity : 0<100*beta η)).const_mul C + filter_upwards [source_cover hη C hC,HeavyPlaneRestriction.public_heavy_cover hη C hC, + eventually_uniform_L hη (eventually_ge_atTop (1:ℝ)),eventually_uniform_R hη 1, + eventually_header_budget,ht.eventually (gt_mem_nhds (by norm_num : (0:ℝ)<1))] + with σ hs hh hL hR hbud htau + intro q _ hq hex D R had U UT n t b τ hn ht0 hnu htu hnt hnup hb hbu hτ hτu + let P := scaleP σ η D R + let d := log ((U.card:ℝ)/n) + let dT := log ((UT.card:ℝ)/t) + let Z := (q:ℝ)*P*(d+dT+P) + have hq' : (3:ℝ)≤q := by exact_mod_cast hq + have hP : 1≤P := one_le_mul_of_one_le_of_one_le (hL D R had) (hR D R had) + have hn' : (0:ℝ) (W:Set (Fin 4 → ZMod q))) SetLike.coe_injective + +lemma prepared_cost (q : ℕ) [Fact q.Prime] (σ P τ dT : ℝ) + (U : Finset (Projectivization (ZMod q) (Fin 4 → ZMod q))) (n : ℕ) + (hq : 3≤q) (hex : exp σ=(q:ℝ)) (hn : 0 PreparedProposals.accepts (coordinateSupport i.1 R) M + (PreparedDescription.good i.1 plane bs L ((N:ℝ)/2) (N*exp (6*P))) + have hprob : ∀ i,exp (-a)≤PublicTables.acceptProb law (A i) := by + intro i + have hh := input_probability hdim U N hN0 plane bs σ P g b τ L c R p h M hqexp hc hbud hb hτ hτsmall hN hloss herror hM i.1 i.2 + have he := PublicTables.sampling_exponent hNr hUr M (2*P*τ) + simp only [neg_mul] at hh + rw [he] at hh + apply le_trans _ hh + apply exp_le_exp.mpr + dsimp only [a,a₀] + have hh' : 0≤log (H+1) := log_nonneg (by linarith) + linarith + obtain ⟨messages,_,hsize,hcap,hlen⟩ := PublicTables.decoder_cover law A a H + ((N:ℝ)/2) (N*exp (6*P)) + (Fintype.card (Projectivization K (Module.Dual K V))) (decode U N L plane bs) (fun i : ι => i.1) + ha (input_card U N plane bs σ P g b τ c p) hea hprob + (fun i ω hω => input_decode U N L plane bs σ P g b τ c p i.1 i.2 ω hω) + exact ⟨messages,hsize,fun S hS => hcap ⟨S,hS⟩,hlen⟩ + +end +end SharpLogRamsey.SpatialPublic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialGeometry.lean b/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..019aa1df509fe834f3e3778c144c114f390353ef --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialGeometry.lean @@ -0,0 +1,136 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Spatial.SpatialBudget +import OAI.Combinatorics.SharpRamsey.Geometry.ListSourceRadial +import OAI.Combinatorics.SharpRamsey.Geometry.ResidualSourceRadial + +namespace OAI + +section +namespace SharpLogRamsey.SpatialLearning +open Finset Real PreparedRow PreparedGeometry PreparedTypical GreedyPreparation +open scoped Classical BigOperators NNReal +noncomputable section + +lemma overlap_scale {σ P g N : ℝ} (hN : 0 (W : Set V)) SetLike.coe_injective +local instance flat_JoinedSpatialGreedy_4 : Fintype (Submodule K V) := Fintype.ofFinite _ + +omit [Field K] [Finite K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] in +lemma complete_members {α β : Type*} {F : Finset β} {U : β→Finset α} {m : ℕ} + {S : Finset α} {bs : List β} (h : Complete F U m S bs) : ∀ b∈bs,b∈F := by + induction h with + | nil => simp + | cons S b bs hb hr hm ht ih => + intro a ha + rcases List.mem_cons.mp ha with rfl|ha + · exact hb + · exact ih a ha + +omit [Finite K] in +lemma kernel_plane (hdim : Module.finrank K V=4) (f : Module.Dual K V) (hf : f≠0) : + Module.finrank K (LinearMap.ker f)=3 := by + have hh := Module.Dual.finrank_ker_add_one_of_ne_zero hf + omega + +lemma filter_kernel (S : Finset (Projectivization K V)) (f : Module.Dual K V) : + S.filter (fun x => f x.rep=0)=S∩planePoints (LinearMap.ker f) := by + ext x + simp only [mem_filter,mem_inter,mem_planePoints,Projectivization.submodule_eq, + Submodule.span_singleton_le_iff_mem,LinearMap.mem_ker] + +theorem greedy (hdim : Module.finrank K V=4) + (S : Finset (Projectivization K V)) (hS : S.Nonempty) (σ g : ℝ) + (hσ : 0≤σ) (hg : 0≤g) (hN : (S.card:ℝ)=exp (3*σ/2+g)) : + let m := ⌈exp (σ+17*g/15)⌉₊ + let F := (univ : Finset (Submodule K V)).filter (fun (W : Submodule K V) => Module.finrank K W=3) + (∃ W : Submodule K V,Module.finrank K W=3 ∧ + (S.card:ℝ)/50≤(S∩planePoints W).card) ∨ + (∃ S' : Finset (Projectivization K V),S'⊆S ∧ S'.Nonempty ∧ S.card≤2*S'.card ∧ + (m:ℝ)≤2*exp (σ+17*g/15) ∧ + (∀ f : Module.Dual K V, f ≠ 0 → (S'.filter (fun x => f x.rep = 0)).card ≤ m)) ∨ + (∃ bs : List (Submodule K V),Complete F (planePoints (K:=K) (V:=V)) m S bs ∧ + (removed S planePoints bs).Nonempty ∧ S.card≤2*(removed S planePoints bs).card ∧ + (bs.length:ℝ)≤exp (σ/2-2*g/15) ∧ + ∀ i : Fin bs.length,((indexedCell (removed S planePoints bs) planePoints bs i).card:ℝ)/ + (removed S planePoints bs).card≤1/25) := by + dsimp only + let m := ⌈exp (σ+17*g/15)⌉₊ + let F := (univ : Finset (Submodule K V)).filter (fun (W : Submodule K V) => Module.finrank K W=3) + have hm0 : 0< m := Nat.ceil_pos.mpr (exp_pos _) + have hm : exp (σ+17*g/15)≤(m:ℝ) := Nat.le_ceil _ + have hmup : (m:ℝ)≤2*exp (σ+17*g/15) := by + have hh := Nat.ceil_lt_add_one (exp_pos (σ+17*g/15)).le + have he : 1≤exp (σ+17*g/15) := one_le_exp_iff.mpr (by linarith) + change (m:ℝ)<_ at hh + linarith + have hSc : 0 + (messages bs).image (fun z => decode U N L plane bs z.1 z.2)) + have hcount (bs : List (J×ℕ)) : ((messages bs).card:ℝ)≤exp E := by + have ht : 0<((messages bs).card:ℝ)+1 := by positivity + have he := exp_le_exp.mpr (hlen bs) + rw [exp_log ht] at he + exact (le_add_of_nonneg_right (by norm_num)).trans he + refine ⟨caps,?_,?_,?_⟩ + · intro W hW + obtain ⟨bs,_,hW'⟩ := mem_biUnion.mp hW + obtain ⟨z,hz,rfl⟩ := mem_image.mp hW' + exact ⟨inter_subset_left,hsize bs z hz⟩ + · intro S hS + obtain ⟨bs,hbs,hS⟩ := hS + obtain ⟨z,hz,hzcap⟩ := hcap bs S hS + exact ⟨_,mem_biUnion.mpr ⟨bs,hbs,mem_image.mpr ⟨z,hz,rfl⟩⟩,hzcap⟩ + · have hcc : caps.card≤∑ bs∈headers (α:=J) Jmax N,(messages bs).card := by + apply card_biUnion_le.trans + exact sum_le_sum (fun bs _ => card_image_le) + have hcc' : (caps.card:ℝ)≤∑ bs∈headers (α:=J) Jmax N,((messages bs).card:ℝ) := by + exact_mod_cast hcc + calc + _ ≤ ∑ bs∈headers (α:=J) Jmax N,((messages bs).card:ℝ) := hcc' + _ ≤ ∑ _bs∈headers (α:=J) Jmax N,exp E := sum_le_sum (fun bs _ => hcount bs) + _ = ((headers (α:=J) Jmax N).card:ℝ)*exp E := by simp + _ ≤ _ := by + apply mul_le_mul_of_nonneg_right _ (exp_pos _).le + exact_mod_cast card_headers_le (α:=J) Jmax N + +end +end SharpLogRamsey.SpatialPublic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialInputBridge.lean b/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialInputBridge.lean new file mode 100644 index 0000000000000000000000000000000000000000..d0948b294b5a64001cbb2ab441da5de205763cb9 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialInputBridge.lean @@ -0,0 +1,75 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Spatial.SpatialCover +import OAI.Combinatorics.SharpRamsey.Spatial.SpatialPrepared + +namespace OAI + +section +namespace SharpLogRamsey.SpatialPublic +open Finset Real Filter SpatialLearning GreedyPreparation PreparedProjectiveGeometry +open scoped Classical BigOperators Topology NNReal +noncomputable section + +theorem actual_prepared_input (δ C : ℝ) (hδ : 0<δ) : + ∀ᶠ σ : ℝ in atTop,∀ (q : ℕ) [Fact q.Prime],3≤q → exp σ=(q:ℝ) → + ∀ (U S : Finset (Projectivization (ZMod q) (Fin 4→ZMod q))) + (T : Finset (Projectivization (ZMod q) (Module.Dual (ZMod q) (Fin 4→ZMod q)))), + S⊆U → S.Nonempty → T.Nonempty → S.card≤T.card → + ∀ (P g b τ : ℝ) (p : ℕ),0≤τ → + σ^δ≤P → P≤σ/40 → g≤σ/2+C → 0

y ≠ x ∧ + y.submodule ≤ LinearMap.ker H.rep ⊓ LinearMap.ker J.rep)).card := by + by_contra! hh + have hz := Nat.eq_zero_of_le_zero hh + rw [hz,Nat.cast_zero,mul_zero] at hp + exact lt_irrefl _ hp + exact DyadicGrid.integer_overlap_cover (card_pos.mpr hS) c hc _ hk hu' + +lemma spatial_neighbor_power (hdim : Module.finrank K V=4) + (S O : Finset (Projectivization K V)) (x : Projectivization K V) (c : ℝ≥0) + (A : Finset (Projectivization K (Module.Dual K V))) (hA : A⊆pencil x) + (hu : ∀ H∈A,outsideMass S O x c H≤2) + (H : Projectivization K (Module.Dual K V)) (hH : H∈A) (i : ℕ) : + ((largeNeighbors (S\(O∪{x})) x c (DyadicGrid.value i) A H).card:ℝ)* + (DyadicGrid.value i)^200≤2*((Nat.card K:ℝ)+1) := by + have ha := DyadicGrid.value_pos i + have hh := largeNeighbors_bound hdim (S\(O∪{x})) x c (DyadicGrid.value i) + c.coe_nonneg ha A (fun J hJ => (mem_filter.mp (hA hJ)).2) + H (mem_filter.mp (hA hH)).2 (hu H hH) + have hh' := (le_div_iff₀ ha).mp hh + have hp : (DyadicGrid.value i)^200≤DyadicGrid.value i := + pow_le_of_le_one ha.le (DyadicGrid.value_le_one i) (by decide) + exact (mul_le_mul_of_nonneg_left hp (Nat.cast_nonneg _)).trans hh' + +lemma spatial_pair_power (hdim : Module.finrank K V=4) + (S O : Finset (Projectivization K V)) (x : Projectivization K V) (c : ℝ≥0) + (A : Finset (Projectivization K (Module.Dual K V))) (hA : A⊆pencil x) + (K₀ : ℝ) (hK : 0≤K₀) (i : ℕ) + (hr : ((richRadials (S\(O∪{x})) x c (DyadicGrid.value i)).card:ℝ)* + (DyadicGrid.value i)^100≤K₀) : + ((largePairs (S\(O∪{x})) x c (DyadicGrid.value i) A).card:ℝ)* + (DyadicGrid.value i)^200≤K₀*((Nat.card K:ℝ)+1)^2 := by + apply (pairs_of_radial_bound hdim (S\(O∪{x})) x c _ K₀ hr A + (fun H hH => (mem_filter.mp (hA hH)).2)).trans + apply mul_le_of_le_one_right (by positivity) + exact pow_le_one₀ (DyadicGrid.value_pos i).le (DyadicGrid.value_le_one i) + +theorem spatial_pencils (hdim : Module.finrank K V=4) + (R p h : ℕ) (hp : 0 (htyp H hH).2.1 + have hcover : ∀ H∈A,∀ J∈A,H≠J → 0 (spatial_pair_power hdim S O x c A hA K₀ hK i (hrad i hi)).trans hpair + constructor + · refine ⟨(fun H hH => (htyp H hH).1),hu,?_,hsq.trans hsqs,hcards, + (fun i _ => DyadicGrid.value_pos i),hcover,hpair',hdiag,hpow,?_,htwo⟩ + · intro H hH + exact (htyp H hH).2.2.trans (by norm_num) + · simpa only [card_range] using hsum + · refine ⟨(fun H hH => (htyp H hH).1),hu,(fun H hH => (htyp H hH).2.2), + hsq.trans hsqa,hcarda,hdir,(fun i _ => (DyadicGrid.value_pos i).le),hcover,hpair',?_,?_, + ?_,?_,hpb,hps,hh,hhs,hhe⟩ + · intro H hH i _ + exact (spatial_neighbor_power hdim S O x c A hA hu H hH i).trans hneighbor + · intro H hH + rcases hstrong with he|hb + · rw [neighbors_empty_of_radials hdim (S\(O∪{x})) x c _ he A + (fun J hJ => (mem_filter.mp (hA hJ)).2) H hH] + simp only [card_empty,Nat.cast_zero] + positivity + · exact (largeNeighbors_bound hdim (S\(O∪{x})) x c _ c.coe_nonneg (by positivity) + A (fun J hJ => (mem_filter.mp (hA hJ)).2) H (mem_filter.mp (hA hH)).2 (hu H hH)).trans hb + · simpa only [card_range] using hcert + · simpa only [card_range] using hshift + +end +end SharpLogRamsey.PreparedGeometry + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialPreparation.lean b/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialPreparation.lean new file mode 100644 index 0000000000000000000000000000000000000000..4da61507ba96f1c2765f1caa457edff06fa67117 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialPreparation.lean @@ -0,0 +1,135 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Spatial.SpatialTraining + +namespace OAI + +section +namespace SharpLogRamsey.SpatialLearning +open Finset Real PreparedRow PreparedGeometry PreparedTypical GreedyPreparation PreparedProjectiveGeometry +open scoped Classical BigOperators NNReal +noncomputable section +variable {K V J : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedSpatialPreparation_1 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedSpatialPreparation_2 : Fintype (Projectivization K (Module.Dual K V)) := Fintype.ofFinite _ +local instance flat_JoinedSpatialPreparation_3 : Fintype (Projectivization K V) := by + letI : Finite V := Module.finite_of_finite K + exact Fintype.ofFinite _ + +theorem preparation (hdim : Module.finrank K V=4) + (S : Finset (Projectivization K V)) (T : Finset (Projectivization K (Module.Dual K V))) + (hS : S.Nonempty) (hST : S.card≤T.card) + (plane : J→Finset (Projectivization K V)) (bs : List J) + (σ P g : ℝ) (L c : ℝ≥0) (R p h : ℕ) + (hc : (c:ℝ)=(Nat.card K:ℝ)/S.card) (hcs : (c:ℝ)≤1/100) + (hbud : Budget σ P L R (Nat.log 2 S.card+2) p h) + (hqexp : exp σ=(Nat.card K:ℝ)) (hNup : (S.card:ℝ)≤exp (3*σ/2+g)) + (hcell : ∀ i : Fin bs.length,((indexedCell S plane bs i).card:ℝ)/(S.card:ℝ)≤1/25) + (hsp : (Incidence.incidenceCount S T:ℝ)≤(S.card:ℝ)*T.card/(20*Nat.card K)) + (D₀ D₁ : Finset (Projectivization K V)) + (hD₀ : (D₀.card:ℝ)≤S.card*exp (-P/200)) (hD₁ : (D₁.card:ℝ)≤S.card*exp (5*P)) + (hrad : ∀ x,x∉D₀ → ∀ i∈range (Nat.log 2 S.card+2), + ((richRadials (S\(own S plane bs x∪{x})) x c (DyadicGrid.value i)).card:ℝ)* + (DyadicGrid.value i)^100≤exp (σ+P/100-2*g)) + (hstrong : ∀ x,x∉D₁ → (richRadials (S\(own S plane bs x∪{x})) x c (1/(100*(p:ℝ)))).card=0 ∨ + 2*(exp σ+1)/(1/(100*(p:ℝ)))≤(exp (3*σ)/S.card)*exp (-3*P)) : + let B := (Nat.card K:ℝ)^3/S.card + let E := badHyperplanes S plane bs c + ∃ Ds Da : Finset (Projectivization K V),Ds⊆Da ∧ + (Ds.card:ℝ)≤S.card*exp (-P/200)+(S.card:ℝ)/10000 ∧ + (Da.card:ℝ)≤2*S.card+S.card*exp (5*P) ∧ + (∑ H∈E,mass S c H)≤20804*(Nat.card K:ℝ)*B ∧ + (∀ x,((own S plane bs x).card:ℝ)/(S.card:ℝ)≤1/25) ∧ + (∀ x,x∉Ds → ((pencil x∩E).card:ℝ)≤50000*B*exp ((L:ℝ)/1000) ∧ + SecondPencil 3 R S (own S plane bs x) x c L (pencil x\E) + (((own S plane bs x).card:ℝ)/(S.card:ℝ)) B 400000 + (range (Nat.log 2 S.card+2)) DyadicGrid.value) ∧ + (∀ x,x∉Da → HighPencil 3 R p h S (own S plane bs x) x c L (pencil x\E) + (((own S plane bs x).card:ℝ)/(S.card:ℝ)) B + (range (Nat.log 2 S.card+2)) DyadicGrid.value) := by + let q : ℝ := Nat.card K + let N : ℝ := S.card + let B : ℝ := q^3/N + have hq : 0 (htyp H hH).1,fun H hH => (htyp H hH).2.1, + (fun H hH => (htyp H hH).2.2.trans (by norm_num)),?_,?_, + (fun i _ => DyadicGrid.value_pos i),?_,hpairs,?_,?_,?_,?_⟩ + · apply hsq.trans + apply mul_le_mul_of_nonneg_left _ (by dsimp [B]; positivity) + exact exp_le_exp.mpr (by nlinarith [L.coe_nonneg]) + · nlinarith [sq_nonneg B] + · intro H hH J hJ hne hp + exact spatial_overlap_cover S _ hS x c hc1 _ (fun H hH => (htyp H hH).2.1) H J hH hp + · simpa only [←hbud.identity] using hbud.diag + · simpa only [←hbud.identity] using hbud.pow + · simpa only [card_range,←hbud.identity] using hbud.sum + · simpa only [←hbud.identity] using hbud.two + · exact (hout (hstrong x hs)).1 + · intro x hx + have hx' := not_or.mp (mt mem_union.mpr hx) + have hx'' := not_or.mp (mt mem_union.mpr hx'.1) + obtain ⟨he,htyp,hsq⟩ := hregular x hx''.2 + exact (spatial_pencil_budgets hdim S (own S plane bs x) hS x c L hc1 + (pencil x\badHyperplanes S plane bs c) sdiff_subset σ P g R p h hbud hqexp hNup hsmall + htyp hsq hcards hdir (hrad x hx''.1) (hstrong x hx'.2)).2 + +end +end SharpLogRamsey.SpatialLearning + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialPrepared.lean b/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialPrepared.lean new file mode 100644 index 0000000000000000000000000000000000000000..e7806b4f68f89665889de118fc86ff09ef2c0534 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialPrepared.lean @@ -0,0 +1,90 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Spatial.SpatialGreedy +import OAI.Combinatorics.SharpRamsey.Geometry.PrimeListRadial + +namespace OAI + +section +namespace SharpLogRamsey.SpatialLearning +open Finset Real Filter PreparedProjectiveGeometry GreedyPreparation +open scoped Classical BigOperators Topology +noncomputable section + +theorem prepared_input (δ C : ℝ) (hδ : 0<δ) : + ∀ᶠ σ : ℝ in atTop,∀ (q : ℕ) [Fact q.Prime],3≤q → exp σ=(q:ℝ) → + ∀ (S : Finset (Projectivization (ZMod q) (Fin 4→ZMod q))),S.Nonempty → + ∀ (P g : ℝ) (p : ℕ),σ^δ≤P → P≤σ/40 → g≤σ/2+C → 0

S\(own S planePoints [] x∪{x})) + (fun _ => sdiff_subset) σ P g p (by linarith) hP0 hPu hg hp + ((mul_le_mul_of_nonneg_left hpu (by norm_num)).trans (hpol.trans (exp_le_exp.mpr hP))) hN.le + exact fun x _ => hh.1 x + · have hh := low_radial S hS (fun x => S\(own S planePoints [] x∪{x})) + (fun _ => sdiff_subset) σ P g p (by linarith) hP0 hPu hg hp + ((mul_le_mul_of_nonneg_left hpu (by norm_num)).trans (hpol.trans (exp_le_exp.mpr hP))) hN.le + exact fun _ _ => Or.inr hh.2 + · have hg0 : 0≤g := by linarith + rcases greedy hdim S hS σ g (by linarith) hg0 hN with hh|⟨S',hsub,hn,hhalf,hm,hcap⟩|⟨bs,hbs,hn,hhalf,hJ,hcell⟩ + · exact Or.inl hh + · right + have hNu' : (S'.card:ℝ)≤exp (3*σ/2+g) := (Nat.cast_le.mpr (card_le_card hsub)).trans hN.le + have hNl' : exp (3*σ/2+g)/2≤(S'.card:ℝ) := by + have hh : (S.card:ℝ)≤2*S'.card := by exact_mod_cast hhalf + rw [hN] at hh + linarith + refine ⟨S',[],hsub,hn,hhalf,by simp; positivity,by simp,by simp,?_⟩ + exact hres q hq heq S' hn (fun x => S'\(own S' planePoints [] x∪{x})) + (fun _ => sdiff_subset) P g _ p hP hPu hgu hp hpu hNl' hNu' hm (by + intro f hf + convert hcap f hf using 1 + congr 1 + ext x + simp only [mem_filter]) + · right + have hNu' : ((removed S planePoints bs).card:ℝ)≤exp (3*σ/2+g) := + (Nat.cast_le.mpr (card_le_card (removed_subset S planePoints bs))).trans hN.le + have hNl' : exp (3*σ/2+g)/2≤((removed S planePoints bs).card:ℝ) := by + have hh : (S.card:ℝ)≤2*(removed S planePoints bs).card := by exact_mod_cast hhalf + rw [hN] at hh + linarith + refine ⟨removed S planePoints bs,bs,removed_subset S planePoints bs,hn,hhalf,hJ,?_,hcell,?_⟩ + · intro W hW + exact (mem_filter.mp (complete_members hbs W hW)).2 + · simpa only [own_removed] using hlist q _ _ S bs hbs hn P g p hP hPu hgu hp hpu hNl' hNu' hJ + +end +end SharpLogRamsey.SpatialLearning + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialPublic.lean b/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialPublic.lean new file mode 100644 index 0000000000000000000000000000000000000000..3a8bdfa0464d673b4ad5429bca598d846d8955da --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialPublic.lean @@ -0,0 +1,109 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Spatial.SpatialRow +import OAI.Combinatorics.SharpRamsey.Learning.PublicDecoderCover + +namespace OAI + +section +namespace SharpLogRamsey.SpatialPublic +open Finset Real PreparedRow GreedyPreparation PreparedProjectiveGeometry SpatialLearning +open scoped Classical BigOperators NNReal +noncomputable section +variable {K V J : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedSpatialPublic_1 (R : ℕ) : DecidableEq (Fin R × Projectivization K V) := Classical.decEq _ +local instance flat_JoinedSpatialPublic_2 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedSpatialPublic_3 : Fintype (Projectivization K (Module.Dual K V)) := Fintype.ofFinite _ +local instance flat_JoinedSpatialPublic_4 : Fintype (Projectivization K V) := by + letI : Finite V := Module.finite_of_finite K + exact Fintype.ofFinite _ + +def Input (U : Finset (Projectivization K V)) (N : ℕ) + (plane : J→Finset (Projectivization K V)) (bs : List (J×ℕ)) + (σ P g b τ : ℝ) (c : ℝ≥0) (p : ℕ) (S : Finset (Projectivization K V)) : Prop := + S⊆U ∧ S.card=N ∧ (S.card:ℝ)≤exp (3*σ/2+g) ∧ + sized S plane (bs.map Prod.fst)=bs ∧ + (∀ i : Fin (bs.map Prod.fst).length, + ((indexedCell S plane (bs.map Prod.fst) i).card:ℝ)/(S.card:ℝ)≤1/25) ∧ + (∃ T : Finset (Projectivization K (Module.Dual K V)), + T.Nonempty ∧ S.card≤T.card ∧ + (Nat.card K:ℝ)^4*exp (-b)≤(S.card:ℝ)*T.card ∧ + (Incidence.incidenceCount S T:ℝ)≤τ*(S.card:ℝ)*T.card/Nat.card K) ∧ + ∃ D₀ D₁ : Finset (Projectivization K V), + (D₀.card:ℝ)≤S.card*exp (-P/200) ∧ (D₁.card:ℝ)≤S.card*exp (5*P) ∧ + (∀ x,x∉D₀ → ∀ i∈range (Nat.log 2 S.card+2), + ((richRadials (S\(own S plane (bs.map Prod.fst) x∪{x})) x c (DyadicGrid.value i)).card:ℝ)* + (DyadicGrid.value i)^100≤exp (σ+P/100-2*g)) ∧ + (∀ x,x∉D₁ → (richRadials (S\(own S plane (bs.map Prod.fst) x∪{x})) x c (1/(100*(p:ℝ)))).card=0 ∨ + 2*(exp σ+1)/(1/(100*(p:ℝ)))≤(exp (3*σ)/S.card)*exp (-3*P)) + +lemma input_card (U : Finset (Projectivization K V)) (N : ℕ) + (plane : J→Finset (Projectivization K V)) (bs : List (J×ℕ)) + (σ P g b τ : ℝ) (c : ℝ≥0) (p : ℕ) : + (Fintype.card {S // Input U N plane bs σ P g b τ c p S}:ℝ)≤ + exp ((Fintype.card (Projectivization K V):ℝ)*log 2) := by + have hh := Fintype.card_subtype_le (Input U N plane bs σ P g b τ c p) + rw [Fintype.card_finset] at hh + rw [exp_nat_mul,exp_log (by norm_num : (0:ℝ)<2)] + exact_mod_cast hh + +lemma input_probability (hdim : Module.finrank K V=4) + (U : Finset (Projectivization K V)) (N : ℕ) (hN0 : 0 (ω x:ℕ)) + +lemma input_decode (U : Finset (Projectivization K V)) (N : ℕ) (L : ℝ) + (plane : J→Finset (Projectivization K V)) (bs : List (J×ℕ)) + (σ P g b τ : ℝ) (c : ℝ≥0) (p : ℕ) + {R M : ℕ} (S : Finset (Projectivization K V)) (hS : Input U N plane bs σ P g b τ c p S) + (ω : (Fin R×Projectivization K V)→Fin (M+2)) + (hω : PreparedProposals.accepts (coordinateSupport S R) M + (PreparedDescription.good S plane bs L ((N:ℝ)/2) (N*exp (6*P))) ω) : + ∃ z,(N:ℝ)/2≤(S∩decode U N L plane bs ω z).card ∧ + ((decode U N L plane bs ω z).card:ℝ)≤N*exp (6*P) := by + obtain ⟨z,hz,hcap,hsize⟩ := hω.2.2 + rw [hS.2.1] at hcap hsize + refine ⟨⟨z,by omega⟩,?_,?_⟩ + · have he : S∩decode U N L plane bs ω ⟨z,by omega⟩= + S∩PreparedDecoder.decode plane bs N z pencil inc L (Nat.card K) (fun x => (ω x:ℕ)) := by + ext x + simp only [decode,mem_inter] + exact ⟨fun hh => ⟨hh.1,hh.2.2⟩,fun hh => ⟨hh.1,hS.1 hh.1,hh.2⟩⟩ + rw [he] + exact hcap + · exact (show ((decode U N L plane bs ω ⟨z,by omega⟩).card:ℝ)≤ + (PreparedDecoder.decode plane bs N z pencil inc L (Nat.card K) (fun x => (ω x:ℕ))).card + by exact_mod_cast card_le_card inter_subset_right).trans hsize + +end +end SharpLogRamsey.SpatialPublic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialRow.lean b/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialRow.lean new file mode 100644 index 0000000000000000000000000000000000000000..85d90e675b03abc0c0b2b11914f87fea3b6d7c3a --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialRow.lean @@ -0,0 +1,102 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Spatial.SpatialPreparation + +namespace OAI + +section +namespace SharpLogRamsey.SpatialLearning +open Finset Real PreparedRow PreparedGeometry PreparedTypical GreedyPreparation +open scoped Classical BigOperators NNReal +noncomputable section +variable {K V J : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +local instance flat_JoinedSpatialRow_1 (R : ℕ) : DecidableEq (Fin R × Projectivization K V) := Classical.decEq _ +local instance flat_JoinedSpatialRow_2 : Finite (Module.Dual K V) := Module.finite_of_finite K +local instance flat_JoinedSpatialRow_3 : Fintype (Projectivization K (Module.Dual K V)) := Fintype.ofFinite _ +local instance flat_JoinedSpatialRow_4 : Fintype (Projectivization K V) := by + letI : Finite V := Module.finite_of_finite K + exact Fintype.ofFinite _ + +theorem short_proposal (hdim : Module.finrank K V=4) + (S U : Finset (Projectivization K V)) (T : Finset (Projectivization K (Module.Dual K V))) + (hS : S.Nonempty) (hT : T.Nonempty) (hSU : S⊆U) (hST : S.card≤T.card) + (plane : J→Finset (Projectivization K V)) (bs : List J) + (σ P g b τ : ℝ) (L c : ℝ≥0) (R p h M : ℕ) + (hqexp : exp σ=(Nat.card K:ℝ)) (hc : (c:ℝ)=(Nat.card K:ℝ)/S.card) + (hbud : Budget σ P L R (Nat.log 2 S.card+2) p h) (hb : 0≤b) (hτ : 0<τ) (hτsmall : τ≤1/20) + (hproduct : (Nat.card K:ℝ)^4*exp (-b)≤(S.card:ℝ)*T.card) + (hsparse : (Incidence.incidenceCount S T:ℝ)≤τ*(S.card:ℝ)*T.card/Nat.card K) + (hN : 100*(Nat.card K:ℝ)*P≤S.card) + (hloss : b+2*P*τ≤P/1000000) + (herror : 50000*exp (-(95/100:ℝ)*(L:ℝ))≤exp (-b-2*P*τ)/800) + (hNup : (S.card:ℝ)≤exp (3*σ/2+g)) + (hcell : ∀ i : Fin bs.length,((indexedCell S plane bs i).card:ℝ)/(S.card:ℝ)≤1/25) + (D₀ D₁ : Finset (Projectivization K V)) + (hD₀ : (D₀.card:ℝ)≤S.card*exp (-P/200)) (hD₁ : (D₁.card:ℝ)≤S.card*exp (5*P)) + (hrad : ∀ x,x∉D₀ → ∀ i∈range (Nat.log 2 S.card+2), + ((PreparedProjectiveGeometry.richRadials (S\(own S plane bs x∪{x})) x c (DyadicGrid.value i)).card:ℝ)* + (DyadicGrid.value i)^100≤exp (σ+P/100-2*g)) + (hstrong : ∀ x,x∉D₁ → (PreparedProjectiveGeometry.richRadials (S\(own S plane bs x∪{x})) x c (1/(100*(p:ℝ)))).card=0 ∨ + 2*(exp σ+1)/(1/(100*(p:ℝ)))≤(exp (3*σ)/S.card)*exp (-3*P)) + (hM : 2*(Nat.card K:ℝ)*P≤M) : + ((S.card:ℝ)/(U.card:ℝ))^M*(exp (-2*P*τ)/4)≤ + PublicTables.acceptProb + (PreparedProposals.proposal (coordinateSupport U R) ((R:ℝ≥0)*S.card*(L*c)) M) + (PreparedProposals.accepts (coordinateSupport S R) M + (PreparedDescription.good S plane (sized S plane bs) L ((S.card:ℝ)/2) (S.card*exp (6*P)))) := by + let q : ℝ := Nat.card K + let N : ℝ := S.card + let B : ℝ := q^3/N + let E := badHyperplanes S plane bs c + let E₀ := T.filter (fun H => mass S c H≤2*τ) + have hq : 0 by simpa only [←hbud.identity,mul_comm,mul_left_comm,mul_assoc] using + sparse_training_exponent S c L R H τ (hsmallE H hH)) + (by positivity) le_rfl (by simpa only [mass,hc,inc] using hW) (by simpa only [neg_mul] using hZ) hErr + (range (Nat.log 2 S.card+2)) DyadicGrid.value (fun x hx => (hsecond x hx).2) hhigh + (by rw [hmean]; nlinarith only [hM]) + simp only [neg_mul] at hout ⊢ + with_unfolding_all exact hout + +end +end SharpLogRamsey.SpatialLearning + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialSourceCover.lean b/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialSourceCover.lean new file mode 100644 index 0000000000000000000000000000000000000000..221fc8810a1acb834a6fb63d6961773c0dd81cd8 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialSourceCover.lean @@ -0,0 +1,131 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Spatial.SpatialActualCover +import OAI.Combinatorics.SharpRamsey.Spatial.SpatialParameters + +namespace OAI + +section +namespace SharpLogRamsey.SpatialPublic +open Finset Real Filter SourceScales SpatialLearning DescriptionHeaders PreparedProjectiveGeometry +open scoped Classical BigOperators Topology NNReal +noncomputable section +local instance flat_JoinedSpatialSourceCover_1 (q : ℕ) [Fact q.Prime] : Fintype (Projectivization (ZMod q) (Fin 4 → ZMod q)) := + Fintype.ofFinite _ +local instance flat_JoinedSpatialSourceCover_2 (q : ℕ) [Fact q.Prime] : + Fintype (Projectivization (ZMod q) (Module.Dual (ZMod q) (Fin 4 → ZMod q))) := by + letI : Finite (Module.Dual (ZMod q) (Fin 4 → ZMod q)) := Module.finite_of_finite (ZMod q) + exact Fintype.ofFinite _ +local instance flat_JoinedSpatialSourceCover_3 (q : ℕ) [Fact q.Prime] : Finite (Submodule (ZMod q) (Fin 4 → ZMod q)) := + Finite.of_injective (fun W : Submodule (ZMod q) (Fin 4 → ZMod q) => (W : Set (Fin 4 → ZMod q))) + SetLike.coe_injective + +theorem source_cover {η : ℝ} (hη : 0 < η) (C : ℝ) (hC : 1 ≤ C) : + ∀ᶠ σ : ℝ in atTop, ∀ (q : ℕ) [Fact q.Prime], 3 ≤ q → exp σ = (q:ℝ) → + ∀ (D : ℝ) (R : ℕ), Admissible σ η D R → + ∀ (U : Finset (Projectivization (ZMod q) (Fin 4 → ZMod q))) (n : ℕ) (b τ : ℝ), + 0 < n → n ≤ U.card → (n:ℝ) ≤ 2*(q:ℝ)^2 → 200*(q:ℝ)*scaleP σ η D R ≤ n → + 0 ≤ b → b ≤ C*scaleKstar σ η D → 0 < τ → τ ≤ C*σ^(-100*beta η) → + let P := scaleP σ η D R + let J := ⌈exp (7*σ/10)⌉₊ + let M := ⌈2*(q:ℝ)*P⌉₊ + let H := (Fintype.card (Projectivization (ZMod q) (Fin 4 → ZMod q)):ℝ)*log 2 + let E := 2*((M:ℝ)*log (2*U.card/n)+4*P*τ+log 4+log (H+1))+log 3+ + log ((Fintype.card (Projectivization (ZMod q) (Module.Dual (ZMod q) (Fin 4 → ZMod q))):ℝ)+1) + ∃ caps : Finset (Finset (Projectivization (ZMod q) (Fin 4 → ZMod q))), + (∀ W ∈ caps, W ⊆ U ∧ (W.card:ℝ) ≤ n*exp (6*P)) ∧ + (∀ (S : Finset (Projectivization (ZMod q) (Fin 4 → ZMod q))) + (T : Finset (Projectivization (ZMod q) (Module.Dual (ZMod q) (Fin 4 → ZMod q)))), + S ⊆ U → S.card = n → T.Nonempty → S.card ≤ T.card → + (q:ℝ)^4*exp (-b) ≤ (S.card:ℝ)*T.card → + (Incidence.incidenceCount S T:ℝ) ≤ τ*(S.card:ℝ)*T.card/q → + (∃ W : Submodule (ZMod q) (Fin 4 → ZMod q), Module.finrank (ZMod q) W = 3 ∧ + (n:ℝ)/50 ≤ (S ∩ planePoints W).card) ∨ + (∃ W ∈ caps, (n:ℝ)/4 ≤ (S ∩ W).card)) ∧ + (caps.card:ℝ) ≤ (n+1:ℕ)*(J+1:ℕ)* + (((Nat.card (Submodule (ZMod q) (Fin 4 → ZMod q))*(n+1)+1:ℕ):ℝ)^J)*exp E := by + have hβ := beta_pos hη + have ht : Tendsto (fun σ : ℝ => C*σ^(-100*beta η)) atTop (𝓝 0) := by + simpa using (tendsto_rpow_neg_atTop (by linarith : 0 < 100*beta η)).const_mul C + have hK : ∀ᶠ σ : ℝ in atTop, (1:ℝ) ≤ σ^(7*beta η) := by + filter_upwards [eventually_ge_atTop (1:ℝ)] with σ hσ + exact one_le_rpow hσ (by positivity) + filter_upwards [actual_cover (beta η) (log 2) hβ, + eventually_bounded_budget hη,eventually_grid_shape 2, + eventually_P_le_linear hη (1/40) (by norm_num), + eventually_training_loss hη (2*C+4) (1/1000000) (by linarith) (by norm_num), + eventually_exceptional_training hη (2*C+4) (by linarith), + ht.eventually (gt_mem_nhds (by norm_num : (0:ℝ) < 1/40)), + hK,eventually_ge_atTop (1:ℝ)] with σ hcover hbud hgrid hPu hloss herr hτsmall hK hσ + intro q _ hq hx D R had U n b τ hn hnu hnupper hnlarge hb hbu hτ hτu + let P := scaleP σ η D R + let L := Real.toNNReal (scaleL σ η D) + let g := log (n:ℝ)-3*σ/2 + let J := ⌈exp (7*σ/10)⌉₊ + let M := ⌈2*(q:ℝ)*P⌉₊ + have hσ0 : 0 < σ := by linarith + have hqp : (0:ℝ) < q := by exact_mod_cast (show 0 < q by omega) + have hnp : (0:ℝ) < n := by exact_mod_cast hn + have hxlog : log (q:ℝ) = σ := by rw [←hx,log_exp] + have hNgrid : ((Nat.log 2 n+2:ℕ):ℝ) ≤ σ^2 := hgrid q 2 n hqp hxlog le_rfl hn hnupper + obtain ⟨p,h,hpupper,hbudget⟩ := hbud D R (Nat.log 2 n+2) had hNgrid + have hP0 : 0 ≤ P := by have := hbudget.large; dsimp [P]; linarith + have hL0 : 0 ≤ scaleL σ η D := (L_pos hσ0 had).le + have hLP : scaleL σ η D ≤ P := by + have hR : (1:ℝ) ≤ R := by exact_mod_cast (show 1 ≤ R by have := hbudget.Rlarge; omega) + dsimp [P,scaleP] + exact le_mul_of_one_le_right hL0 hR + have hKlow : 1 ≤ scaleKstar σ η D := by + apply hK.trans + unfold scaleKstar + have hh := mul_le_mul_of_nonneg_right had.D_lower (rpow_nonneg hσ0.le (6*beta η)) + rw [←rpow_add hσ0] at hh + simpa only [show beta η+6*beta η=7*beta η by ring] using hh + have hb' : b+log 2 ≤ (2*C+4)*scaleKstar σ η D := by + have hl : log 2 ≤ (2:ℝ) := (log_le_sub_one_of_pos (by norm_num)).trans (by norm_num) + nlinarith + have hτ' : 2*τ ≤ (2*C+4)*σ^(-100*beta η) := by + have hp : 0 ≤ σ^(-100*beta η) := rpow_nonneg hσ0.le _ + nlinarith + have hl := hloss D R had (b+log 2) (2*τ) hb' hτ' + have he := herr D R had (b+log 2) (2*τ) hb' hτ' + have hPg : σ^beta η ≤ P := by + apply (rpow_le_rpow_of_exponent_le hσ (by linarith : beta η ≤ 9*beta η)).trans + exact (scale_bounds hσ hη had).1.trans hLP + have hPupper : P ≤ σ/40 := by + simpa only [div_eq_mul_inv,mul_comm,one_mul] using hPu D R had + have hgu : g ≤ σ/2+log 2 := by + have hh := log_le_log hnp hnupper + rw [log_mul (by norm_num) (pow_ne_zero _ hqp.ne'),log_pow,hxlog] at hh + norm_num only [Nat.cast_ofNat] at hh + dsimp [g] + linarith + have hgn : (n:ℝ) = exp (3*σ/2+g) := by + dsimp [g] + rw [show 3*σ/2+(log (n:ℝ)-3*σ/2)=log (n:ℝ) by ring,exp_log hnp] + have hJ : exp (σ/2-2*g/15) ≤ J := by + apply le_trans _ (Nat.le_ceil (exp (7*σ/10))) + apply exp_le_exp.mpr + have hh : 0 ≤ log (n:ℝ) := log_nonneg (by exact_mod_cast hn) + dsimp [g] + linarith + have hms : ∀ m, 0 < m → m ≤ n → n ≤ 2*m → + Budget σ P L R (Nat.log 2 m+2) p h := by + intro m _ hmn _ + exact hbudget.mono_grid (Nat.add_le_add_right (Nat.log_mono_right hmn) 2) + have hl' : b+log 2+4*P*τ ≤ P/1000000 := by + have hm := mul_le_mul_of_nonneg_right hLP (by norm_num : (0:ℝ) ≤ 1/1000000) + dsimp [P] at * + nlinarith + have he' : 50000*exp (-(95/100:ℝ)*(L:ℝ)) ≤ exp (-(b+log 2)-4*P*τ)/800 := by + dsimp only [L] + rw [coe_toNNReal _ hL0] + simpa only [show (2:ℝ)*scaleP σ η D R*(2*τ)=4*P*τ by dsimp [P]; ring] using he + exact hcover q hq hx U n J P g b τ L R p h M hn hnu hPg hPupper hgu + hbudget.p_pos hpupper hgn hJ hms hb hτ (hτu.trans hτsmall.le) hnlarge hl' he' (Nat.le_ceil _) + +end +end SharpLogRamsey.SpatialPublic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialTraining.lean b/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialTraining.lean new file mode 100644 index 0000000000000000000000000000000000000000..8743db4791a7e71ff48caa7c758fe38027cfb309 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialTraining.lean @@ -0,0 +1,112 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Spatial.SpatialGeometry +import OAI.Combinatorics.SharpRamsey.Learning.PreparationInvariance + +namespace OAI + +section +namespace SharpLogRamsey.SpatialLearning +open Finset Real PreparedRow PreparedGeometry PreparedTypical GreedyPreparation +open scoped Classical BigOperators NNReal +noncomputable section + +lemma scale_B {q N P : ℝ} (hq : 0 mass S c H≤2*τ) + (Incidence.incidenceCount S T:ℝ)≤(S.card:ℝ)*T.card/(20*Nat.card K) ∧ + exp (3*P)≤(Nat.card K:ℝ)^3/S.card ∧ (c:ℝ)≤1/100 ∧ + E₀.Nonempty ∧ (T.card:ℝ)≤2*E₀.card ∧ + E₀⊆badHyperplanes S plane bs c ∧ + ∀ H∈E₀,mass S c H≤2*τ := by + let q : ℝ := Nat.card K + let N : ℝ := S.card + have hq : 0 W.image f.symm),?_,?_,?_⟩ + · intro W hW + obtain ⟨W₀,hW₀,rfl⟩ := mem_image.mp hW + obtain ⟨hsub,hcard,_⟩ := pullback_cover f U U W₀ (hAs W₀ hW₀).1 + exact ⟨hsub,by simpa only [hcard] using (hAs W₀ hW₀).2⟩ + · intro S T hSU hSn hTU hTt hprod hsp + have hcS : (S.image f).card=n := by rw [card_image_of_injective _ f.injective,hSn] + have hcT' : (T.image g).card=t := by rw [card_image_of_injective _ g.injective,hTt] + have hsp' : (incidenceCount (S.image f) (T.image g):ℝ)≤τ*(n:ℝ)*t/q := by + simpa only [f,g,incidenceCount_mapEquiv] using hsp + obtain ⟨W,hW,hcap⟩ := hAc (S.image f) (T.image g) + (image_subset_image hSU) hcS (image_subset_image hTU) hcT' hprod hsp' + refine ⟨W.image f.symm,mem_image.mpr ⟨W,hW,rfl⟩,?_⟩ + rw [(pullback_cover f U S W (hAs W hW).1).2.2] + exact hcap + · have hcard : ((A.image (fun W => W.image f.symm)).card:ℝ)≤A.card := by + exact_mod_cast card_image_le (s:=A) (f:=fun W => W.image f.symm) + have hl : log (((A.image (fun W => W.image f.symm)).card:ℝ)+1)≤log ((A.card:ℝ)+1) := + log_le_log (by positivity) (by linarith only [hcard]) + exact hl.trans (by simpa only [hcU,hcT] using hAl) + +end +end SharpLogRamsey.SpatialPublic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialValidated.lean b/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialValidated.lean new file mode 100644 index 0000000000000000000000000000000000000000..5e17382d203342ff6da4f9d716c4d4cf1f4c8496 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Spatial/SpatialValidated.lean @@ -0,0 +1,113 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Spatial.SpatialTransport +import OAI.Combinatorics.SharpRamsey.Validation.ValidationGapCosts + +namespace OAI + +section +namespace SharpLogRamsey.SpatialPublic +open Finset Real Filter SourceScales Incidence ProjectiveDuality Validation +open scoped Classical Topology +noncomputable section + +theorem validated_cover {η : ℝ} (hη : 0<η) (C : ℝ) (hC : 1≤C) : + ∀ᶠ σ : ℝ in atTop,∀ (q : ℕ) [Fact q.Prime],3≤q → exp σ=(q:ℝ) → + ∀ (V : Type) [AddCommGroup V] [Module (ZMod q) V] [FiniteDimensional (ZMod q) V], + Module.finrank (ZMod q) V=4 → ∀ D R,Admissible σ η D R → + ∀ (U : Finset (Projectivization (ZMod q) V)) + (UT : Finset (Projectivization (ZMod q) (Module.Dual (ZMod q) V))) + (n t : ℕ) (b τ : ℝ), + 0 C*σ^(-100*beta η)) atTop (𝓝 0) := by + simpa using (tendsto_rpow_neg_atTop (by have := beta_pos hη; positivity : 0<100*beta η)).const_mul C + filter_upwards [complete_cover_any hη C hC, + eventually_uniform_L hη (eventually_ge_atTop (200000:ℝ)),eventually_uniform_R hη 1, + eventually_training_loss hη C 1 (by linarith) (by norm_num), + hdec.eventually (gt_mem_nhds (by norm_num : (0:ℝ)<1/1000000)), + eventually_ge_atTop (1:ℝ)] + with σ hs hL hR hbsmall hτsmall hσ + intro q _ hq hex V _ _ _ hdim D R had U UT n t b τ hn ht hnu htu hb hbu hτ hτu hplo hphi + let P := scaleP σ η D R + have hL' := hL D R had + have hLP : scaleL σ η D≤P := le_mul_of_one_le_right (by linarith) (hR D R had) + have hP : 200000≤P := hL'.trans hLP + have hbP : b≤P := by + have hh := hbsmall D R had b 0 hbu (mul_nonneg (by linarith) (rpow_nonneg (by linarith) _)) + simp only [mul_zero,add_zero,one_mul] at hh + exact hh.trans hLP + have hsmall : τ≤1/1000000 := hτu.trans hτsmall.le + have hq' : (0:ℝ) ring + by_cases hnt : n≤t + · have hnup : (n:ℝ)≤2*(q:ℝ)^2 := by + have hnt' : (n:ℝ)≤t := by exact_mod_cast hnt + nlinarith [sq_nonneg ((n:ℝ)-2*(q:ℝ)^2),sq_nonneg ((q:ℝ)^2)] + obtain ⟨A,hAs,hAc,hAl⟩ := hs q hq hex V hdim D R had U UT n t b τ + hn ht hnu htu hnt hnup hb hbu hτ hτu + obtain ⟨F,hFs,hFc,hFl⟩ := return_gap_cover hd4 A U UT n t hn ht hnu htu P b hP hb hbP + (fun W hW => (hAs W hW).2) (by simpa only [hcard] using hphi) + (by simpa only [hcard] using hplo) + refine ⟨F,by simpa only [hcard] using hFs,?_,?_⟩ + · intro S T hSU hSn hTU hTt hsp + exact hFc S T hSU hSn hTU hTt (hspval S T hsp) (hAc S T hSU hSn hTU hTt hplo hsp) + · simp only [hcard,Nat.cast_one] at hFl + dsimp only [P] at * + nlinarith only [hFl,hAl,hz] + · have htn : t≤n := le_of_not_ge hnt + have htup : (t:ℝ)≤2*(q:ℝ)^2 := by + have htn' : (t:ℝ)≤n := by exact_mod_cast htn + nlinarith [sq_nonneg ((t:ℝ)-2*(q:ℝ)^2),sq_nonneg ((q:ℝ)^2)] + let e := bidual (K:=ZMod q) (V:=V) + have hcU : (U.image e).card=U.card := card_image_of_injective _ e.injective + have hddual : Module.finrank (ZMod q) (Module.Dual (ZMod q) V)=4 := Subspace.dual_finrank_eq.trans hdim + obtain ⟨A,hAs,hAc,hAl⟩ := hs q hq hex (Module.Dual (ZMod q) V) hddual D R had UT (U.image e) t n b τ + ht hn htu (by rwa [hcU]) htn htup hb hbu hτ hτu + obtain ⟨F,hFs,hFc,hFl⟩ := reverse_gap_cover hd4 A U UT n t hn ht hnu htu P hP + (fun W hW => (hAs W hW).2) (by simpa only [hcard] using hphi) + refine ⟨F,by simpa only [hcard] using hFs,?_,?_⟩ + · intro S T hSU hSn hTU hTt hsp + have hcS : (S.image e).card=n := (card_image_of_injective _ e.injective).trans hSn + have hinc : incidenceCount T (S.image e)=incidenceCount S T := incidenceCount_bidual S T + have hspread : (incidenceCount T (S.image e):ℝ)≤τ*(t:ℝ)*n/q := by + rw [hinc] + convert hsp using 1; ring + have hplo' : (q:ℝ)^4*exp (-b)≤(t:ℝ)*n := by simpa only [mul_comm] using hplo + exact hFc S T hSU hSn hTt (hspval S T hsp) + (hAc T (S.image e) hTU hTt (image_subset_image hSU) hcS hplo' hspread) + · simp only [hcard,Nat.cast_one] at hFl + rw [hcU] at hAl + dsimp only [P] at * + nlinarith only [hFl,hAl,hz] + +end +end SharpLogRamsey.SpatialPublic + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Trees/ChronologicalExecution.lean b/lean/OAI/Combinatorics/SharpRamsey/Trees/ChronologicalExecution.lean new file mode 100644 index 0000000000000000000000000000000000000000..60d2ac29299c4b1fa2abd7ad0811913d86667a74 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Trees/ChronologicalExecution.lean @@ -0,0 +1,158 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Trees.PivotExecution +import OAI.Combinatorics.SharpRamsey.Execution.ExecutedSupportTrim + +namespace OAI + +section +namespace SharpLogRamsey.FreshExecution +open Finset PublicTables SupportMixtures +open scoped Classical BigOperators +noncomputable section +variable {A B C Ξ I : Type*} [Fintype A] [Fintype B] [Fintype Ξ] + [DecidableEq I] {α : I→Type*} + +lemma card_mul_kernel_sum (Y : Finset A) (f : A→ℝ) : + (Y.card:ℝ)*(∑ y,kernel Y y*f y)=∑ y∈Y,f y := by + by_cases h : Y.Nonempty + · have hc : (Y.card:ℝ)≠0 := by exact_mod_cast card_ne_zero.mpr h + calc + _ = ∑ y,if y∈Y then f y else 0 := by + rw [mul_sum] + apply sum_congr rfl + intro y _ + by_cases hy : y∈Y <;> simp [kernel,hy,hc] + _ = _ := by simp + · have he : Y=∅ := not_nonempty_iff_eq_empty.mp h + simp [he] + +omit [Fintype A] in +lemma sdiff_card_eq_sum (Y T : Finset A) : + ((Y\T).card:ℝ) = ∑ y∈Y,if y∉T then (1:ℝ) else 0 := by + rw [←sum_filter] + have hf : Y.filter (fun y=>y∉T)=Y\T := by ext y; simp + rw [hf] + simp only [sum_const,nsmul_eq_mul,mul_one] + +omit [Fintype A] [Fintype B] [DecidableEq I] in +lemma firstLoss_points (choose : ∀ i,α i→TreeDecoder.Domains A B→Option C) + (mask : ∀ i,α i→TreeDecoder.CapReader A B C) (Y : Finset A) + (i : I) (U : TreeDecoder.Domains A B) (z : α i) : + firstLoss choose mask Y i U z = ∑ y∈Y,(choose i z U).elim 0 + (fun c=>if y∉(mask i z U c).1 then 1 else 0) := by + cases h : choose i z U with + | none=>simp [firstLoss,h] + | some c=>simp only [firstLoss,h,Option.elim_some]; exact sdiff_card_eq_sum _ _ + +omit [Fintype A] [Fintype B] [DecidableEq I] in +lemma secondLoss_points (choose : ∀ i,α i→TreeDecoder.Domains A B→Option C) + (mask : ∀ i,α i→TreeDecoder.CapReader A B C) (Y : Finset B) + (i : I) (U : TreeDecoder.Domains A B) (z : α i) : + secondLoss choose mask Y i U z = ∑ y∈Y,(choose i z U).elim 0 + (fun c=>if y∉(mask i z U c).2 then 1 else 0) := by + cases h : choose i z U with + | none=>simp [secondLoss,h] + | some c=>simp only [secondLoss,h,Option.elim_some]; exact sdiff_card_eq_sum _ _ + +end +end SharpLogRamsey.FreshExecution + +namespace SharpLogRamsey.ActualPivot +open Finset Real Incidence Validation Selection ScheduledBanks PublicTables ReadyTests + PivotGeometry ProjectiveDuality TreeDecoder FreshExecution SupportMixtures +open scoped Classical BigOperators +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] + +abbrev ChronoDomains := Domains (Projectivization K (Module.Dual K V)) (Projectivization K V) + +def chronoRead (b : ℝ) (z : Banks (K:=K) (V:=V) b) : + CapReader (Projectivization K (Module.Dual K V)) (Projectivization K V) (Code (K:=K) (V:=V) b) := + fun U c=>(read b z.1 z.2 U.swap c).swap + +def chronoMask (b : ℝ) (z : Banks (K:=K) (V:=V) b) : + CapReader (Projectivization K (Module.Dual K V)) (Projectivization K V) (Code (K:=K) (V:=V) b) := + fun U c=>(mask b z.1 z.2 U.swap c).swap + +omit [Finite K] in +lemma chronoRead_first (b : ℝ) (z : Banks (K:=K) (V:=V) b) + (U : ChronoDomains (K:=K) (V:=V)) (c : Code (K:=K) (V:=V) b) : + (chronoRead b z U c).1=U.1∩(chronoMask b z U c).1 := + read_mask_second b z.1 z.2 U.swap c + +omit [Finite K] in +lemma chronoRead_second (b : ℝ) (z : Banks (K:=K) (V:=V) b) + (U : ChronoDomains (K:=K) (V:=V)) (c : Code (K:=K) (V:=V) b) : + (chronoRead b z U c).2=U.2∩(chronoMask b z U c).2 := + read_mask_first b z.1 z.2 U.swap c + +variable {n : ℕ} {b τ P H : ℝ} (hdim : Module.finrank K V=n+3) + (book : Book (K:=K) (V:=V) (Nat.card K) b τ P H (n+3)) (hτ : 0≤τ) (hτsmall : τ≤1/40000) + +def Book.chronoChoose (s : Original (K:=K) (V:=V) n b) + (z : Banks (K:=K) (V:=V) b) (U : ChronoDomains (K:=K) (V:=V)) : + Option (Code (K:=K) (V:=V) b) := book.choose hdim hτ hτsmall s z U.swap + +theorem Book.first_loss_bound {I : Type*} [DecidableEq I] + (s : I→Original (K:=K) (V:=V) n b) (i : I) + (Y : Finset (Projectivization K (Module.Dual K V))) + (U : ChronoDomains (K:=K) (V:=V)) : + (∑ z,(banksLaw b).mass z*firstLoss (fun i=>book.chronoChoose hdim hτ hτsmall (s i)) + (fun _=>chronoMask b) Y i U z) ≤ + 12*(Nat.card K:ℝ)*Y.card*pairing (kernel Y) (kernel (s i).A) + (fun y x=>if y.rep x.rep=0 then 1 else 0) := by + simp_rw [firstLoss_points,mul_sum] + rw [sum_comm] + calc + _ ≤ ∑ y∈Y,12*(Nat.card K:ℝ)*∑ x,kernel (s i).A x * + (if y.rep x.rep=0 then 1 else 0) := by + apply sum_le_sum + intro y hy + exact book.dual_exclusion hdim hτ hτsmall (s i) U.swap y + _ = 12*(Nat.card K:ℝ)*(∑ y∈Y,∑ x,kernel (s i).A x * + (if y.rep x.rep=0 then 1 else 0)) := by rw [mul_sum] + _ = 12*(Nat.card K:ℝ)*(Y.card*pairing (kernel Y) (kernel (s i).A) + (fun y x=>if y.rep x.rep=0 then 1 else 0)) := by + congr 1 + have he : pairing (kernel Y) (kernel (s i).A) (fun y x=>if y.rep x.rep=0 then 1 else 0) = + ∑ y,kernel Y y*(∑ x,kernel (s i).A x*(if y.rep x.rep=0 then 1 else 0)) := by + simp only [pairing,mul_sum,mul_assoc] + rw [he,card_mul_kernel_sum] + _ = _ := by ring + +theorem Book.second_loss_bound {I : Type*} [DecidableEq I] + (s : I→Original (K:=K) (V:=V) n b) (i : I) + (Y : Finset (Projectivization K V)) + (U : ChronoDomains (K:=K) (V:=V)) : + (∑ z,(banksLaw b).mass z*secondLoss (fun i=>book.chronoChoose hdim hτ hτsmall (s i)) + (fun _=>chronoMask b) Y i U z) ≤ + 12*(Nat.card K:ℝ)*Y.card*pairing (kernel (s i).B) (kernel Y) + (fun y x=>if y.rep x.rep=0 then 1 else 0) := by + simp_rw [secondLoss_points,mul_sum] + rw [sum_comm] + calc + _ ≤ ∑ x∈Y,12*(Nat.card K:ℝ)*∑ y,kernel (s i).B y * + (if y.rep x.rep=0 then 1 else 0) := by + apply sum_le_sum + intro x hx + exact book.primal_exclusion hdim hτ hτsmall (s i) U.swap x + _ = 12*(Nat.card K:ℝ)*(∑ x∈Y,∑ y,kernel (s i).B y * + (if y.rep x.rep=0 then 1 else 0)) := by rw [mul_sum] + _ = 12*(Nat.card K:ℝ)*(Y.card*pairing (kernel (s i).B) (kernel Y) + (fun y x=>if y.rep x.rep=0 then 1 else 0)) := by + congr 1 + rw [pairing_reverse] + have he : pairing (kernel Y) (kernel (s i).B) (fun x y=>if y.rep x.rep=0 then 1 else 0) = + ∑ x,kernel Y x*(∑ y,kernel (s i).B y*(if y.rep x.rep=0 then 1 else 0)) := by + simp only [pairing,mul_sum,mul_assoc] + rw [he,card_mul_kernel_sum] + _ = _ := by ring +end +end SharpLogRamsey.ActualPivot + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Trees/ChronologicalOrder.lean b/lean/OAI/Combinatorics/SharpRamsey/Trees/ChronologicalOrder.lean new file mode 100644 index 0000000000000000000000000000000000000000..5f8134f174f15b5181b78cfb2e5e4512d1289c72 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Trees/ChronologicalOrder.lean @@ -0,0 +1,133 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Reciprocal.AuxiliaryCharges + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset Real +open scoped Classical BigOperators +noncomputable section +variable {A : Type*} [Fintype A] + +lemma Law.exists_mass_pos_le_of_mean_le (p : Law A) (f : A → ℝ) (c : ℝ) + (h : (∑ a, p.mass a * f a) ≤ c) : + ∃ a, 0 < p.mass a ∧ f a ≤ c := by + have hp : ∃ a, 0 < p.mass a := by + by_contra! he + have hz : ∑ a, p.mass a = 0 := sum_eq_zero (fun a _ => (he a).antisymm (p.nonneg a)) + linarith [p.total] + by_contra! hh + obtain ⟨a,ha⟩ := hp + have hle (b : A) : p.mass b * c ≤ p.mass b * f b := by + by_cases hb : p.mass b = 0 + · simp [hb] + · exact mul_le_mul_of_nonneg_left (hh b (lt_of_le_of_ne (p.nonneg b) (Ne.symm hb))).le (p.nonneg b) + have hlt : (∑ b, p.mass b*c) < ∑ b, p.mass b*f b := + sum_lt_sum (fun b _ => hle b) ⟨a,mem_univ _,mul_lt_mul_of_pos_left (hh a ha) ha⟩ + rw [←sum_mul,p.total,one_mul] at hlt + exact (not_lt_of_ge h) hlt + +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + +omit [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] in +lemma reverse_incidence_count (S : Finset (Projectivization K (Module.Dual K V))) + (T : Finset (Projectivization K V)) : + Incidence.incidenceCount T S = ((S ×ˢ T).filter (fun z => z.1.rep z.2.rep=0)).card := by + simp only [Incidence.incidenceCount, Incidence.Incident, card_filter, sum_product] + apply sum_congr rfl + intro dualPoint _ + exact card_filter _ _ + +theorem auxiliary_cap_product {n : ℕ} (hdim : Module.finrank K V=n+3) + (p : Law (Projectivization K (Module.Dual K V))) + (q : Law (Projectivization K V)) + (goodA : Finset (Projectivization K (Module.Dual K V))) + (goodB : Finset (Projectivization K V)) + (MA MB κ : ℝ) (hMA : 0 z.1.rep z.2.rep=0)).card : ℝ) / + (((levelSet p a ∩ goodA).card : ℝ) * (levelSet q b ∩ goodB).card))) + ≤ 1/(4*(Nat.card K:ℝ))) : + MA*MB ≤ 64*(Nat.card K:ℝ)^(n+3)*exp (2*κ) := by + let SA := fun a : retainedLevels p goodA MA κ => levelSet p a ∩ goodA + let SB := fun b : retainedLevels q goodB MB κ => levelSet q b ∩ goodB + have hmean : (∑ ab, (A.law.prod B.law).mass ab * + ((((SA ab.1 ×ˢ SB ab.2).filter (fun z => z.1.rep z.2.rep=0)).card:ℝ)/ + ((SA ab.1).card*(SB ab.2).card))) ≤ 1/(4*(Nat.card K:ℝ)) := by + simpa only [Law.prod,Fintype.sum_prod_type] using hsparse + obtain ⟨⟨a,b⟩,_,hs⟩ := (A.law.prod B.law).exists_mass_pos_le_of_mean_le _ _ hmean + have ha := (A.size a).1 + have hb := (B.size b).1 + have hapos : (0:ℝ)<(SA a).card := (by positivity : 0 z.1.rep z.2.rep=0)).card : ℝ) / + (((levelSet p a ∩ goodA).card : ℝ) * (levelSet q b ∩ goodB).card))) + ≤ 1/(4*(Nat.card K:ℝ))) : + v≤u+2*κ+log 64 := by + have hq : (0:ℝ) [] + | .node a l r => inorder l ++ a :: inorder r + +@[simp] lemma inorder_length {α : Type*} (t : BinaryTree α) : + (inorder t).length=t.numNodes := by + induction t with + | nil => rfl + | node a l r hl hr => simp [inorder,hl,hr]; omega + +lemma balanced_card (lo n : ℕ) : (balanced lo n).numNodes=n := by + induction n using Nat.strong_induction_on generalizing lo with + | h n ih => + rw [balanced] + split_ifs with h + · simp [h] + · simp only [numNodes] + rw [ih (n/2) (Nat.div_lt_self (Nat.pos_of_ne_zero h) (by decide)), + ih (n-n/2-1) (by omega)] + have : n/2 + rw [balanced] + split_ifs with h + · simp + · simp only [height] + by_cases hn : n=1 + · subst n + simp [balanced] + have hn2 : 2≤n := by omega + have hl : n/2 + rw [balanced] at ha + split_ifs at ha with h + · simp [inorder] at ha + · simp only [inorder,List.mem_append,List.mem_cons] at ha + have hl : n/2 True + | .node a l r => Chronological l ∧ Chronological r ∧ + (∀ b∈inorder l,b + rw [balanced] + split_ifs with h + · trivial + · change Chronological (balanced lo (n/2)) ∧ + Chronological (balanced (lo+n/2+1) (n-n/2-1)) ∧ _ + refine ⟨ih (n/2) (Nat.div_lt_self (Nat.pos_of_ne_zero h) (by decide)) lo, + ih (n-n/2-1) (by omega) (lo+n/2+1),?_,?_⟩ + · intro b hb + exact (balanced_interval hb).2 + · intro b hb + have H := (balanced_interval hb).1 + omega + +lemma inorder_pairwise {t : BinaryTree ℕ} (ht : Chronological t) : + (inorder t).Pairwise (·<·) := by + induction t with + | nil => simp [inorder] + | node a l r hl hr => + rcases ht with ⟨hcl,hcr,hla,har⟩ + simp only [inorder,List.pairwise_append,List.pairwise_cons] + refine ⟨hl hcl,⟨har,hr hcr⟩,?_⟩ + intro b hb c hc + simp only [List.mem_cons] at hc + rcases hc with rfl | hc + · exact hla b hb + · exact (hla b hb).trans (har c hc) + +lemma balanced_nodup (lo n : ℕ) : (inorder (balanced lo n)).Nodup := + (inorder_pairwise (balanced_chronological lo n)).imp (fun h => ne_of_lt h) + +end SharpLogRamsey.ChronologicalTree + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Trees/GoodChronology.lean b/lean/OAI/Combinatorics/SharpRamsey/Trees/GoodChronology.lean new file mode 100644 index 0000000000000000000000000000000000000000..e1a1954a400f58285e8f7c826449c12d2f05539d --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Trees/GoodChronology.lean @@ -0,0 +1,58 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Windows.PreparedWindows +import OAI.Combinatorics.SharpRamsey.Selection.BandCharges + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical BigOperators +noncomputable section +variable {ι β : Type} [Fintype ι] [DecidableEq ι] [Fintype β] + +lemma pairInformation_symm (p : Law (ι→β)) (i j : ι) : + pairInformation p i j=pairInformation p j i := by + apply Subtype.ext + change mutualInfo (p.map (fun x=>(x i,x j)))=mutualInfo (p.map (fun x=>(x j,x i))) + have he : p.map (fun x=>(x j,x i))=(p.map (fun x=>(x i,x j))).swap := by + rw [Law.swap_eq_map,Law.map_map] + rfl + rw [he] + simp only [mutualInfo,Law.swap_fst,Law.swap_snd,entropy_swap,add_comm] + +variable {A B K V : Type} [Fintype A] [Fintype B] [Field K] + [AddCommGroup V] [Module K V] [FiniteDimensional K V] + +omit [FiniteDimensional K V] in +lemma reciprocalCharges_symm (p : Law (ι→A×B)) (v : B→V) (w : A→Module.Dual K V) + (ρ : ℝ) (r s : ℕ) (i j : ι) : + reciprocalCharges p v w ρ r s i j=reciprocalCharges p v w ρ r s j i := + add_comm _ _ + +variable {C X : Type} [Fintype C] + +lemma good_charge_reversed (p : Law (ι→β)) (e : C×X↪ι) (own : ι→Option C) + (c : ι→ι→NNReal) (hc : ∀ i j,c i j=c j i) (J D a : ℝ) (f : C→X) + (i j : ι) (hi : i∉badIndices p e own c J D a f) + (hj : j∈otherRepresentatives e own f i) : + (pairInformation p j i:ℝ)+(c j i:ℝ)≤a := by + rw [pairInformation_symm p j i,hc j i] + exact ((not_badIndices p e own c J D a f i).mp hi).2 j hj + +lemma good_charge_either (p : Law (ι→β)) (e : C×X↪ι) (own : ι→Option C) + (c : ι→ι→NNReal) (hc : ∀ i j,c i j=c j i) (J D a : ℝ) (f : C→X) + (i j : ι) + (h : (i∉badIndices p e own c J D a f ∧ j∈otherRepresentatives e own f i) ∨ + (j∉badIndices p e own c J D a f ∧ i∈otherRepresentatives e own f j)) : + (pairInformation p i j:ℝ)+(c i j:ℝ)≤a := by + rcases h with h|h + · exact ((not_badIndices p e own c J D a f i).mp h.1).2 j h.2 + · exact good_charge_reversed p e own c hc J D a f j i h.1 h.2 + +end +end SharpLogRamsey.Selection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Trees/OriginalTreeLoss.lean b/lean/OAI/Combinatorics/SharpRamsey/Trees/OriginalTreeLoss.lean new file mode 100644 index 0000000000000000000000000000000000000000..0c4157f5ce1f2eabec128f4d404f2ed168ed9c0a --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Trees/OriginalTreeLoss.lean @@ -0,0 +1,205 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Trees.ChronologicalExecution +import OAI.Combinatorics.SharpRamsey.Execution.ExecutedFailureBudget + +namespace OAI + +section +namespace SharpLogRamsey.ActualPivot +open Finset Real Incidence PublicTables FreshExecution TreeDecoder SupportMixtures BinaryTree +open scoped Classical BigOperators +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] + {I Ω : Type*} [Fintype I] [DecidableEq I] [Fintype Ω] + +local instance banksFintype (b : ℝ) : Fintype (Banks (K:=K) (V:=V) b) := inferInstance + +omit [Finite K] [FiniteDimensional K V] in +lemma banks_nonempty (b : ℝ) : Nonempty (Banks (K:=K) (V:=V) b) := by + by_contra h + have : IsEmpty (Banks (K:=K) (V:=V) b) := not_nonempty_iff.mp h + have hh := (banksLaw (K:=K) (V:=V) b).total + simp at hh + +def density (S : Finset (Projectivization K (Module.Dual K V))) + (T : Finset (Projectivization K V)) : ℝ := + pairing (kernel S) (kernel T) (fun y x=>if y.rep x.rep=0 then 1 else 0) + +omit [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma density_nonneg (S : Finset (Projectivization K (Module.Dual K V))) + (T : Finset (Projectivization K V)) : 0≤density S T := by + unfold density pairing + exact sum_nonneg (fun y _=>sum_nonneg (fun x _=> + mul_nonneg (mul_nonneg (kernel_nonneg _ _) (kernel_nonneg _ _)) (by dsimp only; split_ifs <;> norm_num))) + +omit [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma density_eq_count (S : Finset (Projectivization K (Module.Dual K V))) + (T : Finset (Projectivization K V)) : + density S T=(incidenceCount T S:ℝ)/((T.card:ℝ)*S.card) := by + unfold density + rw [Selection.pairing_reverse,kernel_incidence,incidenceCount_eq_card] + rfl + +variable {n : ℕ} {b τ P H : ℝ} (hdim : Module.finrank K V=n+3) + (book : Book (K:=K) (V:=V) (Nat.card K) b τ P H (n+3)) (hτ : 0≤τ) (hτsmall : τ≤1/40000) + +omit [Fintype I] [DecidableEq I] in +lemma Book.ready_failure_chrono (s : I→Original (K:=K) (V:=V) n b) (i : I) + (U : ChronoDomains (K:=K) (V:=V)) : + (∑ z,(banksLaw (K:=K) (V:=V) b).mass z*readyFailure + (fun i=>book.chronoChoose hdim hτ hτsmall (s i)) (s i).B (s i).A + ((incidenceCount (s i).A (s i).B:ℝ)>τ*((s i).A.card:ℝ)*(s i).B.card/Nat.card K) i U z) ≤ + 2*exp (-(Nat.card K:ℝ)) := by + by_cases hr : (s i).Ready τ U.swap + · have hh := book.ready_failure hdim hτ hτsmall (s i) U.swap hr + have hB : ¬((s i).B∩U.1).card<(9/10:ℝ)*(s i).B.card := not_lt.mpr hr.2.1 + have hA : ¬((s i).A∩U.2).card<(9/10:ℝ)*(s i).A.card := not_lt.mpr hr.1 + have hD : ¬τ*((s i).A.card:ℝ)*(s i).B.card/Nat.card K< + (incidenceCount (s i).A (s i).B:ℝ) := not_lt.mpr hr.2.2 + simp only [readyFailure,hB,hA,hD,not_false_eq_true,and_self,ite_true, + trialFailure,Book.chronoChoose] + convert hh using 1 + rfl + · have hn : ¬(¬((s i).B∩U.1).card<(9/10:ℝ)*(s i).B.card ∧ + ¬((s i).A∩U.2).card<(9/10:ℝ)*(s i).A.card ∧ + ¬τ*((s i).A.card:ℝ)*(s i).B.card/Nat.card K<(incidenceCount (s i).A (s i).B:ℝ)) := by + intro hh + apply hr + exact ⟨not_lt.mp hh.2.1,not_lt.mp hh.1,not_lt.mp hh.2.2⟩ + simp only [readyFailure,ite_eq_right hn,mul_zero,sum_const_zero] + positivity + +omit [FiniteDimensional K V] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +theorem original_density_rejection (μ : Law Ω) (s : Ω→Original (K:=K) (V:=V) n b) + (hτpos : 0<τ) (E : ℝ) + (hmean : (∑ ω,μ.mass ω*density (s ω).B (s ω).A)≤E) : + (∑ ω,μ.mass ω*(if τ*((s ω).A.card:ℝ)*(s ω).B.card/Nat.card K< + (incidenceCount (s ω).A (s ω).B:ℝ) then 1 else 0))≤(Nat.card K:ℝ)*E/τ := by + have hq : (0:ℝ) ring + · exact div_nonneg (mul_nonneg hq.le (density_nonneg _ _)) hτpos.le + calc + _ ≤ ∑ ω,μ.mass ω*((Nat.card K:ℝ)*density (s ω).B (s ω).A/τ) := + sum_le_sum (fun ω _=>mul_le_mul_of_nonneg_left (hpoint ω) (μ.nonneg ω)) + _ = (Nat.card K:ℝ)*(∑ ω,μ.mass ω*density (s ω).B (s ω).A)/τ := by + simp only [mul_sum,sum_div] + apply sum_congr rfl + intros + ring + _ ≤ _ := div_le_div_of_nonneg_right (mul_le_mul_of_nonneg_left hmean hq.le) hτpos.le + +theorem Book.first_trim (μ : Law Ω) (s : Ω→I→Original (K:=K) (V:=V) n b) + (target : I) (t : BinaryTree I) (U : ChronoDomains (K:=K) (V:=V)) + (ht : Separated t) (hmem : target∈labels t) (hU : ∀ ω,(s ω target).B⊆U.1) + (E : ℝ) (hE : 0≤E) + (hmean : ∀ i∈leftPath target t,(∑ ω,μ.mass ω*density (s ω target).B (s ω i).A)≤E) : + (∑ ω,μ.mass ω*(∑ z,(piLaw (fun _ : I=>banksLaw (K:=K) (V:=V) b)).mass z* + (if firstTrim (fun i=>book.chronoChoose hdim hτ hτsmall (s ω i)) + (fun _=>chronoRead b) (s ω target).B target t U z then (1:ℝ) else 0)))≤ + 10*t.height*(12*(Nat.card K:ℝ)*E) := by + apply original_first_trim μ (fun _=>banksLaw (K:=K) (V:=V) b) (fun _=>(banks_nonempty (K:=K) (V:=V) b).some) + (fun ω i=>book.chronoChoose hdim hτ hτsmall (s ω i)) (fun _ _=>chronoRead b) + (fun _ _=>chronoMask b) (fun _ _=>chronoRead_first b) + target (fun ω=>(s ω target).B) (fun ω=>(s ω target).nonemptyB) t U ht hmem hU + (fun ω i=>12*(Nat.card K:ℝ)*(s ω target).B.card*density (s ω target).B (s ω i).A) + (fun ω i _=>mul_nonneg (by positivity) (density_nonneg _ _)) + (fun ω i _=>book.first_loss_bound hdim hτ hτsmall (s ω) i (s ω target).B) + (12*(Nat.card K:ℝ)*E) (by positivity) + intro i hi + have hc (ω : Ω) : ((s ω target).B.card:ℝ)≠0 := by + exact_mod_cast card_ne_zero.mpr (s ω target).nonemptyB + have he (ω : Ω) : (12*(Nat.card K:ℝ)*(s ω target).B.card*density (s ω target).B (s ω i).A)/ + (s ω target).B.card = 12*(Nat.card K:ℝ)*density (s ω target).B (s ω i).A := by + field_simp [hc ω] + simp only [he] + calc + _ = 12*(Nat.card K:ℝ)*(∑ ω,μ.mass ω*density (s ω target).B (s ω i).A) := by + rw [mul_sum]; apply sum_congr rfl; intros; ring + _ ≤ _ := mul_le_mul_of_nonneg_left (hmean i hi) (by positivity) + +theorem Book.second_trim (μ : Law Ω) (s : Ω→I→Original (K:=K) (V:=V) n b) + (target : I) (t : BinaryTree I) (U : ChronoDomains (K:=K) (V:=V)) + (ht : Separated t) (hmem : target∈labels t) (hU : ∀ ω,(s ω target).A⊆U.2) + (E : ℝ) (hE : 0≤E) + (hmean : ∀ i∈rightPath target t,(∑ ω,μ.mass ω*density (s ω i).B (s ω target).A)≤E) : + (∑ ω,μ.mass ω*(∑ z,(piLaw (fun _ : I=>banksLaw (K:=K) (V:=V) b)).mass z* + (if secondTrim (fun i=>book.chronoChoose hdim hτ hτsmall (s ω i)) + (fun _=>chronoRead b) (s ω target).A target t U z then (1:ℝ) else 0)))≤ + 10*t.height*(12*(Nat.card K:ℝ)*E) := by + apply original_second_trim μ (fun _=>banksLaw (K:=K) (V:=V) b) (fun _=>(banks_nonempty (K:=K) (V:=V) b).some) + (fun ω i=>book.chronoChoose hdim hτ hτsmall (s ω i)) (fun _ _=>chronoRead b) + (fun _ _=>chronoMask b) (fun _ _=>chronoRead_second b) + target (fun ω=>(s ω target).A) (fun ω=>(s ω target).nonemptyA) t U ht hmem hU + (fun ω i=>12*(Nat.card K:ℝ)*(s ω target).A.card*density (s ω i).B (s ω target).A) + (fun ω i _=>mul_nonneg (by positivity) (density_nonneg _ _)) + (fun ω i _=>book.second_loss_bound hdim hτ hτsmall (s ω) i (s ω target).A) + (12*(Nat.card K:ℝ)*E) (by positivity) + intro i hi + have hc (ω : Ω) : ((s ω target).A.card:ℝ)≠0 := by + exact_mod_cast card_ne_zero.mpr (s ω target).nonemptyA + have he (ω : Ω) : (12*(Nat.card K:ℝ)*(s ω target).A.card*density (s ω i).B (s ω target).A)/ + (s ω target).A.card = 12*(Nat.card K:ℝ)*density (s ω i).B (s ω target).A := by + field_simp [hc ω] + simp only [he] + calc + _ = 12*(Nat.card K:ℝ)*(∑ ω,μ.mass ω*density (s ω i).B (s ω target).A) := by + rw [mul_sum]; apply sum_congr rfl; intros; ring + _ ≤ _ := mul_le_mul_of_nonneg_left (hmean i hi) (by positivity) + +theorem Book.deletion_loss (μ : Law Ω) (s : Ω→I→Original (K:=K) (V:=V) n b) + (target : I) (t : BinaryTree I) (U : ChronoDomains (K:=K) (V:=V)) + (ht : Separated t) (hmem : target∈labels t) + (hU : ∀ ω,∀ i∈labels t,(s ω i).B⊆U.1 ∧ (s ω i).A⊆U.2) + (hτpos : 0<τ) (E : ℝ) (hE : 0≤E) + (hfirst : ∀ i∈plannedPath target t,∀ j∈leftPath i t, + (∑ ω,μ.mass ω*density (s ω i).B (s ω j).A)≤E) + (hsecond : ∀ i∈plannedPath target t,∀ j∈rightPath i t, + (∑ ω,μ.mass ω*density (s ω j).B (s ω i).A)≤E) + (hself : ∀ i∈plannedPath target t,(∑ ω,μ.mass ω*density (s ω i).B (s ω i).A)≤E) : + (∑ ω,μ.mass ω*(∑ z,(piLaw (fun _ : I=>banksLaw (K:=K) (V:=V) b)).mass z* + (1-pivotSuccess (fun i=>book.chronoChoose hdim hτ hτsmall (s ω i)) + (fun _=>chronoRead b) target t U z)))≤ + 20*(12*(Nat.card K:ℝ)*E)*t.height^2+ + ((Nat.card K:ℝ)*E/τ+2*exp (-(Nat.card K:ℝ)))*t.height := by + apply original_deletion_quadratic μ (fun _=>banksLaw (K:=K) (V:=V) b) + (fun _=>(banks_nonempty (K:=K) (V:=V) b).some) + (fun ω i=>book.chronoChoose hdim hτ hτsmall (s ω i)) (fun _ _=>chronoRead b) + (fun ω i=>(s ω i).B) (fun ω i=>(s ω i).A) + (fun ω i=>τ*((s ω i).A.card:ℝ)*(s ω i).B.card/Nat.card K< + (incidenceCount (s ω i).A (s ω i).B:ℝ)) target t U ht hmem + (12*(Nat.card K:ℝ)*E) ((Nat.card K:ℝ)*E/τ) (2*exp (-(Nat.card K:ℝ))) + (by positivity) (by positivity) (by positivity) + · intro i hi + exact book.first_trim hdim hτ hτsmall μ s i t U ht (plannedPath_subset target t hi) + (fun ω=>(hU ω i (plannedPath_subset target t hi)).1) E hE (hfirst i hi) + · intro i hi + exact book.second_trim hdim hτ hτsmall μ s i t U ht (plannedPath_subset target t hi) + (fun ω=>(hU ω i (plannedPath_subset target t hi)).2) E hE (hsecond i hi) + · intro i hi + exact original_density_rejection μ (fun ω=>s ω i) hτpos E (hself i hi) + · intro i hi ω V + exact book.ready_failure_chrono hdim hτ hτsmall (s ω) i V + +end +end SharpLogRamsey.ActualPivot + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Trees/Pivot.lean b/lean/OAI/Combinatorics/SharpRamsey/Trees/Pivot.lean new file mode 100644 index 0000000000000000000000000000000000000000..f034eac6a3b836379bc0005be40dfe7c1eb9795a --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Trees/Pivot.lean @@ -0,0 +1,93 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Trees.PivotLosses + +namespace OAI + +section +namespace SharpLogRamsey.ActualPivot +open Finset Real Incidence GeometricCover PivotGeometry TreeDecoder SourceScales Filter +open scoped Classical BigOperators Topology +noncomputable section +variable {K V : Type} [Field K] [AddCommGroup V] [Module K V] + +def Header (q b : ℝ) (r : ℕ) + (U : Domains (Projectivization K V) (Projectivization K (Module.Dual K V))) + (s t : ℕ) : Prop := + 0(book.decodeRaw z U v).toFinset) + +omit [Finite K] in +lemma Book.mem_allowed (z : FirstBank (K:=K) (V:=V) b) + (U : Domains (Projectivization K V) (Projectivization K (Module.Dual K V))) + (v : book.LocalRaw U) (c : Code (K:=K) (V:=V) b) (hc : book.decodeRaw z U v=some c) : + c∈book.allowed z U := by + refine mem_biUnion.mpr ⟨v,mem_univ _,?_⟩ + rw [hc] + exact mem_singleton_self c + +omit [Finite K] in +lemma Book.allowed_card (z : FirstBank (K:=K) (V:=V) b) + (U : Domains (Projectivization K V) (Projectivization K (Module.Dual K V))) : + (book.allowed z U).card≤ + ∑ s : FirstSize (K:=K) (V:=V),∑ t : SecondSize (K:=K) (V:=V), + (book.library U s t).card*firstBound b U t*secondBound b U s := by + have hh : (book.allowed z U).card≤Fintype.card (book.LocalRaw U) := by + apply (card_biUnion_le).trans + calc + _ ≤ ∑ _v : book.LocalRaw U,1 := by + apply sum_le_sum + intro v _ + cases book.decodeRaw z U v <;> simp + _ = _ := by simp + simpa only [Book.LocalRaw,Fintype.card_sigma,Fintype.card_prod, + Fintype.card_coe,Fintype.card_fin,←Nat.mul_assoc] using hh + +end +end SharpLogRamsey.ActualPivot + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Trees/PivotAlphabetCost.lean b/lean/OAI/Combinatorics/SharpRamsey/Trees/PivotAlphabetCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..abdbeecdf3008085360813ef2de17ebf32b89149 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Trees/PivotAlphabetCost.lean @@ -0,0 +1,102 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Trees.PivotAlphabetMembership +import OAI.Combinatorics.SharpRamsey.Trees.PivotIndexCost + +namespace OAI + +section +namespace SharpLogRamsey.ActualPivot +open Finset Real Incidence Validation ScheduledBanks PublicTables ReadyTests + PivotGeometry ProjectiveDuality TreeDecoder ExecutedPotential +open scoped Classical BigOperators +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] + {n : ℕ} {b τ P H : ℝ} + +lemma three_card_le_exp (l m n : ℕ) (L : ℝ) + (h : log ((l:ℝ)+1)+log ((m:ℝ)+1)+log ((n:ℝ)+1)≤L) : + (l:ℝ)*m*n≤exp L := by + calc + _ ≤ ((l:ℝ)+1)*((m:ℝ)+1)*((n:ℝ)+1) := by gcongr <;> linarith + _ = exp (log ((l:ℝ)+1)+log ((m:ℝ)+1)+log ((n:ℝ)+1)) := by + rw [exp_add,exp_add,exp_log (by positivity),exp_log (by positivity),exp_log (by positivity)] + _ ≤ _ := exp_le_exp.mpr h + +def headerCost : ℝ := + log ((Fintype.card (Projectivization K (Module.Dual K (Module.Dual K V))):ℝ)+1)+ + log ((Fintype.card (Projectivization K (Module.Dual K V)):ℝ)+1) + +omit [Finite K] [FiniteDimensional K V] [Fintype (Projectivization K V)] in +lemma headerCost_nonneg : 0≤headerCost (K:=K) (V:=V) := by + exact add_nonneg (log_nonneg (by have := Nat.cast_nonneg (α:=ℝ) (Fintype.card (Projectivization K (Module.Dual K (Module.Dual K V)))); linarith)) + (log_nonneg (by have := Nat.cast_nonneg (α:=ℝ) (Fintype.card (Projectivization K (Module.Dual K V))); linarith)) + +variable (book : Book (K:=K) (V:=V) (Nat.card K) b τ P H (n+3)) + (hb : 0≤b) (hH : 0≤H) (hP : 4≤P) (haP : b+log 1000000≤P) +include hb hH hP haP + +omit [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +theorem Book.header_index_cost + (U : Domains (Projectivization K V) (Projectivization K (Module.Dual K V))) (s t : ℕ) + (hh : Header (Nat.card K) b (n+3) U s t) : + log (((book.library U s t).card:ℝ)+1)+log ((firstBound b U t:ℝ)+1)+ + log ((secondBound b U s:ℝ)+1)≤ + (2*(H+22)*(Nat.card K:ℝ)*P)*(potential ((Nat.card K:ℝ)^(n+3)) U+P) := by + have hq : (1:ℝ)≤Nat.card K := by exact_mod_cast (Finite.one_lt_card (α:=K)).le + have hlib := (book.valid U s t hh).2.2 + rcases hh with ⟨hs,ht,hsu,htv,hprod,_⟩ + have hb' : 0≤b+log 4 := add_nonneg hb (log_nonneg (by norm_num)) + have hbP : b+log 4≤P := (add_le_add_right (log_le_log (by norm_num) (by norm_num : (4:ℝ)≤1000000)) b).trans haP + have he := local_index_budget hq (add_nonneg hb (log_nonneg (by norm_num))) haP hP hH + (by exact_mod_cast hs) (by exact_mod_cast ht) (by exact_mod_cast hsu) (by exact_mod_cast htv) + (show 0<(Nat.card K:ℝ)^(n+3) by positivity) hb' hbP hprod hlib + simpa only [firstBound,secondBound,card_image_of_injective _ (bidual (K:=K) (V:=V)).injective, + potential] using he + +theorem Book.allowed_card_exp (z : FirstBank (K:=K) (V:=V) b) + (U : Domains (Projectivization K V) (Projectivization K (Module.Dual K V))) : + ((book.allowed z U).card:ℝ)≤exp (headerCost (K:=K) (V:=V)+ + (2*(H+22)*(Nat.card K:ℝ)*P)*(potential ((Nat.card K:ℝ)^(n+3)) U+P)) := by + let L := (2*(H+22)*(Nat.card K:ℝ)*P)*(potential ((Nat.card K:ℝ)^(n+3)) U+P) + have hh (s t : ℕ) : ((book.library U s t).card:ℝ)*firstBound b U t*secondBound b U s≤exp L := by + by_cases hh : Header (Nat.card K) b (n+3) U s t + · exact three_card_le_exp _ _ _ L (book.header_index_cost hb hH hP haP U s t hh) + · simp only [book.invalid U s t hh,card_empty,Nat.cast_zero,zero_mul] + exact (exp_pos L).le + calc + _ ≤ ∑ s : FirstSize (K:=K) (V:=V),∑ t : SecondSize (K:=K) (V:=V), + ((book.library U s t).card:ℝ)*firstBound b U t*secondBound b U s := by + exact_mod_cast book.allowed_card z U + _ ≤ ∑ _s : FirstSize (K:=K) (V:=V),∑ _t : SecondSize (K:=K) (V:=V),exp L := by + exact sum_le_sum (fun s _=>sum_le_sum (fun t _=>hh s t)) + _ = (((Fintype.card (Projectivization K (Module.Dual K (Module.Dual K V))):ℝ)+1)* + ((Fintype.card (Projectivization K (Module.Dual K V)):ℝ)+1))*exp L := by + simp only [sum_const,card_univ,nsmul_eq_mul,FirstSize,SecondSize,Fintype.card_fin,Nat.cast_add,Nat.cast_one] + ring + _ = _ := by + rw [exp_add] + congr 1 + dsimp only [headerCost] + rw [exp_add,exp_log (by positivity),exp_log (by positivity)] + +theorem Book.allowed_log_cost (z : FirstBank (K:=K) (V:=V) b) + (U : Domains (Projectivization K V) (Projectivization K (Module.Dual K V))) : + log ((book.allowed z U).card:ℝ)≤headerCost (K:=K) (V:=V)+ + (2*(H+22)*(Nat.card K:ℝ)*P)*(potential ((Nat.card K:ℝ)^(n+3)) U+P) := by + by_cases hz : (book.allowed z U).card=0 + · rw [hz,Nat.cast_zero,log_zero] + exact add_nonneg headerCost_nonneg (mul_nonneg (by positivity) + (add_nonneg (potential_nonneg _ _) (by linarith))) + · apply (log_le_iff_le_exp (by exact_mod_cast Nat.pos_of_ne_zero hz)).mpr + exact book.allowed_card_exp hb hH hP haP z U + +end +end SharpLogRamsey.ActualPivot + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Trees/PivotAlphabetMembership.lean b/lean/OAI/Combinatorics/SharpRamsey/Trees/PivotAlphabetMembership.lean new file mode 100644 index 0000000000000000000000000000000000000000..306c73c340df41fa708987e33f883e3896108fdf --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Trees/PivotAlphabetMembership.lean @@ -0,0 +1,79 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Trees.PivotAlphabet + +namespace OAI + +section +namespace SharpLogRamsey.ActualPivot +open Finset Real Incidence Validation ScheduledBanks PublicTables ReadyTests + PivotGeometry ProjectiveDuality TreeDecoder +open scoped Classical BigOperators +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] + {n : ℕ} {b τ P H : ℝ} + +theorem Input.choose_allowed + (book : Book (K:=K) (V:=V) (Nat.card K) b τ P H (n+3)) + {A : Finset (Projectivization K V)} {B : Finset (Projectivization K (Module.Dual K V))} + (d : Input n A B b) (hdim : Module.finrank K V=n+3) + (hW : d.W∈book.library (d.U,d.UT) (A∩d.U).card (B∩d.UT).card) + (z : FirstBank (K:=K) (V:=V) b) (w : SecondBank (K:=K) (V:=V) b) + (c : Code (K:=K) (V:=V) b) (hc : d.choose hdim z w=some c) : + c∈book.allowed z (d.U,d.UT) := by + unfold Input.choose at hc + split at hc + · cases hc + · rename_i i hi + let row := rowAt _ (z d.firstCall.address) i + let call := d.secondCall hdim row (index_valid _ _ _ i hi) + change (call.bankIndex (b+log 1000000) n w).map + (fun j=>(⟨d.firstCall.address,i⟩,⟨call.address,j⟩))=some c at hc + obtain ⟨j,hj,he⟩ := Option.map_eq_some_iff.mp hc + cases he + have hW' : d.W∈book.library (d.U,d.UT) call.address.2.2 d.firstCall.address.2.2 := by + change d.W∈book.library (d.U,d.UT) + ((A∩d.U).image (bidual (K:=K) (V:=V))).card (B∩d.UT).card + simpa only [card_image_of_injective _ (bidual (K:=K) (V:=V)).injective] using hW + let v : book.LocalRaw (d.U,d.UT) := + ⟨call.address.2.2,d.firstCall.address.2.2,⟨d.W,hW'⟩,i,j⟩ + apply book.mem_allowed z (d.U,d.UT) v + have hWn : d.W.Nonempty := d.source_nonempty.mono inter_subset_right + have hBn : (cap SharpLogRamsey.Incidence.Incident (Nat.card K) d.UT row).Nonempty := + call.source_nonempty.mono call.source_proposal + dsimp only [Book.decodeRaw,v] + rw [dite_eq_left hWn] + change (if hc : (cap SharpLogRamsey.Incidence.Incident (Nat.card K) d.UT row).Nonempty then _ else _)=_ + rw [dite_eq_left hBn] + rfl + +theorem Book.choose_allowed (hdim : Module.finrank K V=n+3) + (book : Book (K:=K) (V:=V) (Nat.card K) b τ P H (n+3)) + (hτ : 0≤τ) (hτsmall : τ≤1/40000) + (s : Original (K:=K) (V:=V) n b) (z : Banks (K:=K) (V:=V) b) + (U : Domains (Projectivization K V) (Projectivization K (Module.Dual K V))) + (c : Code (K:=K) (V:=V) b) (hc : book.choose hdim hτ hτsmall s z U=some c) : + c∈book.allowed z.1 U := by + unfold Book.choose at hc + split at hc + · rename_i hr + let d := book.prepare hdim hτ hτsmall s U hr + have hs := book.prepare_spec hdim hτ hτsmall s U hr + dsimp only at hs + have hW : d.W∈book.library (d.U,d.UT) (s.A∩d.U).card (s.B∩d.UT).card := by + have hu : d.U=U.1 := congrArg Prod.fst hs.1 + have hv : d.UT=U.2 := congrArg Prod.snd hs.1 + simpa only [hu,hv] using hs.2.1 + have hh := d.choose_allowed book hdim hW z.1 z.2 c hc + rw [hs.1] at hh + exact hh + · cases hc + +end +end SharpLogRamsey.ActualPivot + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Trees/PivotBanks.lean b/lean/OAI/Combinatorics/SharpRamsey/Trees/PivotBanks.lean new file mode 100644 index 0000000000000000000000000000000000000000..f7ea2404edf6fc1d1dfb61dc938641cad06ab216 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Trees/PivotBanks.lean @@ -0,0 +1,164 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Selection.ScheduledBanks +import OAI.Combinatorics.SharpRamsey.Trees.PivotCaps + +namespace OAI + +section +namespace SharpLogRamsey.ActualPivot +open Finset Real Incidence Validation Selection ScheduledBanks PublicTables + ReadyTests PivotGeometry ProjectiveDuality +open scoped Classical BigOperators +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] + +structure Input (n : ℕ) (A : Finset (Projectivization K V)) + (B : Finset (Projectivization K (Module.Dual K V))) (b : ℝ) where + U : Finset (Projectivization K V) + UT : Finset (Projectivization K (Module.Dual K V)) + W : Finset (Projectivization K V) + nonemptyA : A.Nonempty + nonemptyB : B.Nonempty + trimA : (9/10:ℝ)*A.card ≤ (A∩U).card + trimB : (9/10:ℝ)*B.card ≤ (B∩UT).card + source_nonempty : ((A∩U)∩W).Nonempty + source_fraction : (A.card:ℝ) ≤ 2*((A∩U)∩W).card + proposal_ratio : (W.card:ℝ) ≤ exp (b+log 1000000)*((A∩U)∩W).card + product : (Nat.card K:ℝ)^(n+3)*exp (-b) ≤ (A.card:ℝ)*B.card + sparse : (incidenceCount A B:ℝ) ≤ (A.card:ℝ)*B.card/(40000*Nat.card K) + +variable {n : ℕ} {A : Finset (Projectivization K V)} + {B : Finset (Projectivization K (Module.Dual K V))} {b : ℝ} + +def Input.firstCall (d : Input n A B b) : Call A := + ReadyTests.firstCall A d.U d.W B d.UT b d.nonemptyB d.trimB + d.source_nonempty d.source_fraction d.proposal_ratio d.sparse + +abbrev FirstBank (b : ℝ) := Bank (P:=Projectivization K V) + (Q:=Projectivization K (Module.Dual K V)) (Nat.card K) (b+log 1000000) +abbrev SecondBank (b : ℝ) := Bank (P:=Projectivization K (Module.Dual K V)) + (Q:=Projectivization K (Module.Dual K (Module.Dual K V))) (Nat.card K) (b+log 1000000) + +abbrev Input.FirstRow (d : Input n A B b) := + Fin (length (Nat.card K) d.firstCall.address) → Projectivization K V + +omit [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma Input.first_valid (d : Input n A B b) (z : FirstBank (K:=K) (V:=V) b) + (r : d.FirstRow) (hr : d.firstCall.bankRow (b+log 1000000) n z=some r) : + d.firstCall.accept n r := by + exact PublicTables.first_valid _ _ _ _ hr + +def Input.secondCall (d : Input n A B b) (hdim : Module.finrank K V=n+3) + (r : d.FirstRow) (hr : d.firstCall.accept n r) : Call B := by + have hi : firstIndex (d.firstCall.accept n) 1 (r,PUnit.unit)=some 0 := by + simp only [firstIndex, ite_eq_left hr] + exact ReadyTests.secondCall hdim A d.U d.W B d.UT d.nonemptyA d.nonemptyB + d.trimA d.trimB b d.product d.sparse + (h:=length (Nat.card K) d.firstCall.address) (m:=1) (r,PUnit.unit) 0 hi + +lemma Input.second_overhead (d : Input n A B b) (hdim : Module.finrank K V=n+3) + (r : d.FirstRow) (hr : d.firstCall.accept n r) : + (d.secondCall hdim r hr).overhead=b+log 1000000 := rfl + +def Input.next (d : Input n A B b) (hdim : Module.finrank K V=n+3) + (z : FirstBank (K:=K) (V:=V) b) : Option (Call B) := + match hr : d.firstCall.bankRow (b+log 1000000) n z with + | none => none + | some r => some (d.secondCall hdim r (d.first_valid z r hr)) + +lemma Input.next_none (d : Input n A B b) (hdim : Module.finrank K V=n+3) + (z : FirstBank (K:=K) (V:=V) b) : + d.next hdim z=none ↔ d.firstCall.bankRow (b+log 1000000) n z=none := by + unfold Input.next + split <;> simp_all + +lemma Input.next_overhead (d : Input n A B b) (hdim : Module.finrank K V=n+3) + (z : FirstBank (K:=K) (V:=V) b) (c : Call B) (hc : d.next hdim z=some c) : + c.overhead=b+log 1000000 := by + unfold Input.next at hc + split at hc + · cases hc + · cases Option.some.inj hc + rfl + +def Input.failure (d : Input n A B b) (hdim : Module.finrank K V=n+3) + (z : FirstBank (K:=K) (V:=V) b) (w : SecondBank (K:=K) (V:=V) b) : ℝ := + (d.next hdim z).elim 1 (fun c => if c.bankRow (b+log 1000000) n w=none then 1 else 0) + +def Input.secondLoss (d : Input n A B b) (hdim : Module.finrank K V=n+3) + (y : Projectivization K (Module.Dual K (Module.Dual K V))) + (z : FirstBank (K:=K) (V:=V) b) (w : SecondBank (K:=K) (V:=V) b) : ℝ := + (d.next hdim z).elim 0 (fun c => (c.bankRow (b+log 1000000) n w).elim 0 + (fun r => if ¬pass SharpLogRamsey.Incidence.Incident (Nat.card K) r y then 1 else 0)) + +theorem Input.failure_bound (d : Input n A B b) (hdim : Module.finrank K V=n+3) : + (∑ z, (bankLaw (Nat.card K) (b+log 1000000)).mass z * + ∑ w, (bankLaw (Nat.card K) (b+log 1000000)).mass w * d.failure hdim z w) ≤ + 2*exp (-(Nat.card K:ℝ)) := by + let e := exp (-(Nat.card K:ℝ)) + have he : 0≤e := (exp_pos _).le + have hf := d.firstCall.bank_failure_bound (b+log 1000000) rfl hdim + have hlocal (z : FirstBank (K:=K) (V:=V) b) : + (∑ w, (bankLaw (Nat.card K) (b+log 1000000)).mass w * d.failure hdim z w) ≤ + (if d.firstCall.bankRow (b+log 1000000) n z=none then 1 else 0)+e := by + unfold Input.failure + cases hc : d.next hdim z with + | none => + have hr := (d.next_none hdim z).mp hc + simp only [Option.elim_none, mul_one, ite_eq_left hr, PublicTables.Law.total] + linarith + | some c => + have hr : d.firstCall.bankRow (b+log 1000000) n z≠none := by + intro hr + rw [(d.next_none hdim z).mpr hr] at hc + cases hc + simp only [Option.elim_some, ite_eq_right hr, zero_add] + exact c.bank_failure_bound (b+log 1000000) (d.next_overhead hdim z c hc) + (Subspace.dual_finrank_eq.trans hdim) + calc + _ ≤ ∑ z, (bankLaw (Nat.card K) (b+log 1000000)).mass z * + ((if d.firstCall.bankRow (b+log 1000000) n z=none then 1 else 0)+e) := by + apply sum_le_sum + intro z _ + exact mul_le_mul_of_nonneg_left (hlocal z) ((bankLaw _ _).nonneg z) + _ = (∑ z, (bankLaw (Nat.card K) (b+log 1000000)).mass z * + (if d.firstCall.bankRow (b+log 1000000) n z=none then 1 else 0))+e := by + simp only [mul_add, sum_add_distrib, ←sum_mul, PublicTables.Law.total, one_mul] + _ ≤ _ := by dsimp only [e]; linarith + + theorem Input.second_loss_bound (d : Input n A B b) (hdim : Module.finrank K V=n+3) + (y : Projectivization K (Module.Dual K (Module.Dual K V))) : + (∑ z, (bankLaw (Nat.card K) (b+log 1000000)).mass z * + ∑ w, (bankLaw (Nat.card K) (b+log 1000000)).mass w * d.secondLoss hdim y z w) ≤ + 12*(Nat.card K:ℝ)*(∑ x, SupportMixtures.kernel B x * (if SharpLogRamsey.Incidence.Incident x y then 1 else 0)) := by + let E := 12*(Nat.card K:ℝ)*(∑ x, SupportMixtures.kernel B x * (if SharpLogRamsey.Incidence.Incident x y then 1 else 0)) + have hE : 0≤E := by + dsimp only [E] + apply mul_nonneg (by positivity) + exact sum_nonneg (fun x _ => mul_nonneg (SupportMixtures.kernel_nonneg _ _) (by split_ifs <;> norm_num)) + have hlocal (z : FirstBank (K:=K) (V:=V) b) : + (∑ w, (bankLaw (Nat.card K) (b+log 1000000)).mass w * d.secondLoss hdim y z w) ≤ E := by + unfold Input.secondLoss + cases hc : d.next hdim z with + | none => simpa only [Option.elim_none, mul_zero, sum_const_zero] using hE + | some c => + simp only [Option.elim_some] + exact c.bank_loss_bound (b+log 1000000) (d.next_overhead hdim z c hc) + (Subspace.dual_finrank_eq.trans hdim) y + calc + _ ≤ ∑ z, (bankLaw (Nat.card K) (b+log 1000000)).mass z * E := by + apply sum_le_sum + intro z _ + exact mul_le_mul_of_nonneg_left (hlocal z) ((bankLaw _ _).nonneg z) + _ = E := by rw [←sum_mul, PublicTables.Law.total, one_mul] + +end +end SharpLogRamsey.ActualPivot + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Trees/PivotCalls.lean b/lean/OAI/Combinatorics/SharpRamsey/Trees/PivotCalls.lean new file mode 100644 index 0000000000000000000000000000000000000000..b1f512a914a64deb1e458980e8125d9d9b76aba1 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Trees/PivotCalls.lean @@ -0,0 +1,139 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Learning.ReadyTests + +namespace OAI + +section +namespace SharpLogRamsey.ReadyTests +open Finset Real Incidence Validation Selection PivotGeometry GeometricCover ProjectiveDuality +open scoped Classical BigOperators +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + +def firstCall (A U W : Finset (Projectivization K V)) + (B UT : Finset (Projectivization K (Module.Dual K V))) + (b : ℝ) (hB : B.Nonempty) + (htrimB : (9/10:ℝ)*B.card ≤ (B∩UT).card) + (hsource : ((A∩U)∩W).Nonempty) + (hfrac : (A.card:ℝ) ≤ 2*((A∩U)∩W).card) + (hratio : (W.card:ℝ) ≤ exp (b+log 1000000)*((A∩U)∩W).card) + (hsparse : (incidenceCount A B:ℝ) ≤ (A.card:ℝ)*B.card/(40000*Nat.card K)) : Call A where + source := (A∩U)∩W + proposal := W + targetOriginal := B + target := B∩UT + domain := UT + overhead := b+log 1000000 + source_nonempty := hsource + source_original := inter_subset_left.trans inter_subset_left + source_proposal := inter_subset_right + target_nonempty := by + have hBpos : (0:ℝ) 1) m + +lemma Call.failure_bound {S : Finset (Projectivization K V)} (c : Call S) + {n : ℕ} (hdim : Module.finrank K V = n+3) : + 1-c.production n ≤ exp (-(Nat.card K:ℝ)) := by + have h := (scheduled_from_original hdim S c.source c.proposal + (c.source_nonempty.mono c.source_original) c.source_nonempty + c.source_original c.source_proposal c.targetOriginal c.target c.domain + c.target_nonempty c.target_original c.target_domain c.target_fraction + 2 c.overhead (by norm_num) c.source_fraction c.proposal_ratio + (by convert c.sparse using 1; ring)).2.1 + norm_num only [show (1000:ℝ)*2=2000 by norm_num] at h + exact h + +variable [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] + +def secondCall {n : ℕ} (hdim : Module.finrank K V=n+3) + (A U W : Finset (Projectivization K V)) + (B UT : Finset (Projectivization K (Module.Dual K V))) + (hA : A.Nonempty) (hB : B.Nonempty) + (htrimA : (9/10:ℝ)*A.card≤(A∩U).card) + (htrimB : (9/10:ℝ)*B.card≤(B∩UT).card) + (b : ℝ) (hprod : (Nat.card K:ℝ)^(n+3)*exp (-b)≤(A.card:ℝ)*B.card) + (hsparse : (incidenceCount A B:ℝ)≤(A.card:ℝ)*B.card/(40000*Nat.card K)) + {h m : ℕ} (table : PublicTables.Table (Fin h→Projectivization K V) m) (i : Fin m) + (hi : PublicTables.firstIndex (implementAccept ((A∩U)∩W) + (GoodCap SharpLogRamsey.Incidence.Incident (Nat.card K) UT (B∩UT) + (2000*(Nat.card K:ℝ)^(n+3)/A.card))) m table=some i) : Call B := by + let e := bidual (K:=K) (V:=V) + let capB := cap SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) UT (PublicTables.rowAt m table i) + let sourceB := (B∩UT)∩capB + have hd := second_scheduled hdim A U W B UT hA hB htrimA htrimB b hprod hsparse table i hi + dsimp only at hd + have hAa : (A.image e).card=A.card := card_image_of_injective _ e.injective + have hTa : ((A∩U).image e).card=(A∩U).card := card_image_of_injective _ e.injective + refine { + source := sourceB + proposal := capB + targetOriginal := A.image e + target := (A∩U).image e + domain := U.image e + overhead := b+log 1000000 + source_nonempty := hd.1 + source_original := inter_subset_left.trans inter_subset_left + source_proposal := inter_subset_right + target_nonempty := ?_ + target_original := image_subset_image inter_subset_left + target_domain := image_subset_image inter_subset_right + target_fraction := ?_ + source_fraction := hd.2.1 + proposal_ratio := hd.2.2.1 + sparse := ?_ } + · have hAp : (0:ℝ) pass SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) u (bidual x)) + +omit [Finite K] [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma primalCap_image {h : ℕ} (U : Finset (Projectivization K V)) + (u : Fin h→Projectivization K (Module.Dual K V)) : + (primalCap U u).image (bidual (K:=K) (V:=V))= + cap SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) (U.image (bidual (K:=K) (V:=V))) u := by + ext y + simp only [primalCap,cap,mem_image,mem_filter] + constructor + · rintro ⟨x,⟨hx,hp⟩,rfl⟩ + exact ⟨⟨x,hx,rfl⟩,hp⟩ + · rintro ⟨⟨x,hx,rfl⟩,hp⟩ + exact ⟨x,⟨hx,hp⟩,rfl⟩ + +omit [Finite K] [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma primalCap_card {h : ℕ} (U : Finset (Projectivization K V)) + (u : Fin h→Projectivization K (Module.Dual K V)) : + (primalCap U u).card= + (cap SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) (U.image (bidual (K:=K) (V:=V))) u).card := by + rw [←primalCap_image,card_image_of_injective _ (bidual (K:=K) (V:=V)).injective] + +omit [Finite K] [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma primalCap_capture {h : ℕ} (U S : Finset (Projectivization K V)) + (u : Fin h→Projectivization K (Module.Dual K V)) (M : ℝ) + (hS : S⊆U) + (hg : GoodCap SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) (U.image (bidual (K:=K) (V:=V))) + (S.image (bidual (K:=K) (V:=V))) M u) : + (99:ℝ)*S.card≤100*(S∩primalCap U u).card := by + have hh := cap_capture (image_subset_image hS) hg + have he : (S∩primalCap U u).image (bidual (K:=K) (V:=V))= + (S.image (bidual (K:=K) (V:=V)))∩ + cap SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) (U.image (bidual (K:=K) (V:=V))) u := by + rw [image_inter _ _ (bidual (K:=K) (V:=V)).injective,primalCap_image] + rw [←he,card_image_of_injective _ (bidual (K:=K) (V:=V)).injective, + card_image_of_injective _ (bidual (K:=K) (V:=V)).injective] at hh + exact hh + +omit [Finite K] [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in + +theorem accepted_caps {n h h' : ℕ} + (A U W : Finset (Projectivization K V)) + (B UT : Finset (Projectivization K (Module.Dual K V))) + (z : Fin h→Projectivization K V) (u : Fin h'→Projectivization K (Module.Dual K V)) + (hz : implementAccept ((A∩U)∩W) + (GoodCap SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) UT (B∩UT) (2000*(Nat.card K:ℝ)^(n+3)/A.card)) z) + (hu : implementAccept ((B∩UT)∩cap SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) UT z) + (GoodCap SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) (U.image (bidual (K:=K) (V:=V))) + ((A∩U).image (bidual (K:=K) (V:=V))) (2000*(Nat.card K:ℝ)^(n+3)/B.card)) u) : + primalCap U u⊆U ∧ cap SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) UT z⊆UT ∧ + ((primalCap U u).card:ℝ)≤2000*(Nat.card K:ℝ)^(n+3)/B.card ∧ + ((cap SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) UT z).card:ℝ)≤2000*(Nat.card K:ℝ)^(n+3)/A.card ∧ + (99:ℝ)*(A∩U).card≤100*((A∩U)∩primalCap U u).card ∧ + (99:ℝ)*(B∩UT).card≤100*((B∩UT)∩cap SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) UT z).card := by + refine ⟨filter_subset _ _,filter_subset _ _,?_,hz.2.1,?_,cap_capture inter_subset_right hz.2⟩ + · rw [primalCap_card] + exact hu.2.1 + · exact primalCap_capture U (A∩U) u _ inter_subset_right hu.2 + +omit [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in + +theorem accepted_branch {n h h' : ℕ} + (A U W : Finset (Projectivization K V)) + (B UT : Finset (Projectivization K (Module.Dual K V))) + (hA : A.Nonempty) (hB : B.Nonempty) + (htrimA : (9/10:ℝ)*A.card≤(A∩U).card) + (htrimB : (9/10:ℝ)*B.card≤(B∩UT).card) + (b : ℝ) (hprod : (Nat.card K:ℝ)^(n+3)*exp (-b)≤(A.card:ℝ)*B.card) + (z : Fin h→Projectivization K V) (u : Fin h'→Projectivization K (Module.Dual K V)) + (hz : implementAccept ((A∩U)∩W) + (GoodCap SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) UT (B∩UT) (2000*(Nat.card K:ℝ)^(n+3)/A.card)) z) + (hu : implementAccept ((B∩UT)∩cap SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) UT z) + (GoodCap SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) (U.image (bidual (K:=K) (V:=V))) + ((A∩U).image (bidual (K:=K) (V:=V))) (2000*(Nat.card K:ℝ)^(n+3)/B.card)) u) : + let Q := (Nat.card K:ℝ)^(n+3) + ExecutedPotential.potential Q (primalCap U u,UT)+ + ExecutedPotential.potential Q (U,cap SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) UT z)≤ + ExecutedPotential.potential Q (U,UT)+(b+log 4+2*log 2000) := by + have hv := accepted_caps A U W B UT z u hz hu + apply ExecutedPotential.branch _ 2000 b _ (by norm_num) (U,UT) + (primalCap U u,cap SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) UT z) A B hA hB htrimA htrimB hprod hv.2.2.1 hv.2.2.2.1 + exact pow_pos (by exact_mod_cast Nat.card_pos (α:=K)) _ + +end +end SharpLogRamsey.PivotGeometry + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Trees/PivotDecoder.lean b/lean/OAI/Combinatorics/SharpRamsey/Trees/PivotDecoder.lean new file mode 100644 index 0000000000000000000000000000000000000000..bda813b936d4bc3e7e2408751a5f4856c2033c38 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Trees/PivotDecoder.lean @@ -0,0 +1,149 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Trees.PivotBanks + +namespace OAI + +section +namespace SharpLogRamsey.ActualPivot +open Finset Real Incidence Validation Selection ScheduledBanks PublicTables + ReadyTests PivotGeometry ProjectiveDuality TreeDecoder +open scoped Classical BigOperators +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] + +abbrev FirstCode (b : ℝ) := Σ a : Address (Projectivization K V) + (Projectivization K (Module.Dual K V)), Fin (cutoff (Nat.card K) (b+log 1000000) a) +abbrev SecondCode (b : ℝ) := Σ a : Address (Projectivization K (Module.Dual K V)) + (Projectivization K (Module.Dual K (Module.Dual K V))), + Fin (cutoff (Nat.card K) (b+log 1000000) a) +abbrev Code (b : ℝ) := FirstCode (K:=K) (V:=V) b × SecondCode (K:=K) (V:=V) b + +def read (b : ℝ) (z : FirstBank (K:=K) (V:=V) b) (w : SecondBank (K:=K) (V:=V) b) : + CapReader (Projectivization K V) (Projectivization K (Module.Dual K V)) (Code (K:=K) (V:=V) b) := + fun U c => (primalCap U.1 (rowAt _ (w c.2.1) c.2.2), + cap SharpLogRamsey.Incidence.Incident (Nat.card K) U.2 (rowAt _ (z c.1.1) c.1.2)) + +variable {n : ℕ} {A : Finset (Projectivization K V)} + {B : Finset (Projectivization K (Module.Dual K V))} {b : ℝ} + +def Input.choose (d : Input n A B b) (hdim : Module.finrank K V=n+3) + (z : FirstBank (K:=K) (V:=V) b) (w : SecondBank (K:=K) (V:=V) b) : Option (Code (K:=K) (V:=V) b) := + match hi : d.firstCall.bankIndex (b+log 1000000) n z with + | none => none + | some i => + let r := rowAt _ (z d.firstCall.address) i + let c := d.secondCall hdim r (index_valid _ _ _ i hi) + (c.bankIndex (b+log 1000000) n w).map (fun j => (⟨d.firstCall.address,i⟩,⟨c.address,j⟩)) + +omit [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma Input.firstRow_eq (d : Input n A B b) (z : FirstBank (K:=K) (V:=V) b) : + d.firstCall.bankRow (b+log 1000000) n z = + (d.firstCall.bankIndex (b+log 1000000) n z).map (rowAt _ (z d.firstCall.address)) := by + exact (reconstruct_first _ _ _).symm + +lemma Input.next_of_index (d : Input n A B b) (hdim : Module.finrank K V=n+3) + (z : FirstBank (K:=K) (V:=V) b) + (i : Fin (cutoff (Nat.card K) (b+log 1000000) d.firstCall.address)) + (hi : d.firstCall.bankIndex (b+log 1000000) n z=some i) : + d.next hdim z=some (d.secondCall hdim (rowAt _ (z d.firstCall.address) i) + (index_valid _ _ _ i hi)) := by + have hr : d.firstCall.bankRow (b+log 1000000) n z=some (rowAt _ (z d.firstCall.address) i) := by + rw [d.firstRow_eq,hi,Option.map_some] + unfold Input.next + split + · rename_i he + rw [he] at hr + cases hr + · rename_i r he + have hrow := Option.some.inj (he.symm.trans hr) + subst r + rfl + +lemma Input.choose_of_index (d : Input n A B b) (hdim : Module.finrank K V=n+3) + (z : FirstBank (K:=K) (V:=V) b) (w : SecondBank (K:=K) (V:=V) b) + (i : Fin (cutoff (Nat.card K) (b+log 1000000) d.firstCall.address)) + (hi : d.firstCall.bankIndex (b+log 1000000) n z=some i) : + d.choose hdim z w = + let c := d.secondCall hdim (rowAt _ (z d.firstCall.address) i) (index_valid _ _ _ i hi) + (c.bankIndex (b+log 1000000) n w).map (fun j=>(⟨d.firstCall.address,i⟩,⟨c.address,j⟩)) := by + unfold Input.choose + split + · rename_i he + rw [he] at hi + cases hi + · rename_i j he + have hij := Option.some.inj (he.symm.trans hi) + subst j + rfl + +lemma Input.choose_first_fail (d : Input n A B b) (hdim : Module.finrank K V=n+3) + (z : FirstBank (K:=K) (V:=V) b) (w : SecondBank (K:=K) (V:=V) b) + (hi : d.firstCall.bankIndex (b+log 1000000) n z=none) : d.choose hdim z w=none := by + unfold Input.choose + split + · rfl + · rename_i j he + rw [hi] at he + cases he + +lemma Input.choose_failure (d : Input n A B b) (hdim : Module.finrank K V=n+3) + (z : FirstBank (K:=K) (V:=V) b) (w : SecondBank (K:=K) (V:=V) b) : + (if d.choose hdim z w=none then (1:ℝ) else 0)=d.failure hdim z w := by + cases hi : d.firstCall.bankIndex (b+log 1000000) n z with + | none => + have hr : d.firstCall.bankRow (b+log 1000000) n z=none := by + rw [d.firstRow_eq,hi,Option.map_none] + have hn := (d.next_none hdim z).mpr hr + rw [d.choose_first_fail hdim z w hi] + simp only [Input.failure,hn,Option.elim_none,ite_true] + | some i => + let c := d.secondCall hdim (rowAt _ (z d.firstCall.address) i) (index_valid _ _ _ i hi) + have hn : d.next hdim z=some c := d.next_of_index hdim z i hi + have hr : c.bankRow (b+log 1000000) n w = + (c.bankIndex (b+log 1000000) n w).map (rowAt _ (w c.address)) := + (reconstruct_first _ _ _).symm + rw [d.choose_of_index hdim z w i hi] + simp only [Input.failure,hn,Option.elim_some] + change (if (c.bankIndex (b+log 1000000) n w).map _=none then (1:ℝ) else 0)=_ + rw [hr] + cases c.bankIndex (b+log 1000000) n w <;> simp + +theorem Input.choose_failure_bound (d : Input n A B b) (hdim : Module.finrank K V=n+3) : + (∑ z, (bankLaw (Nat.card K) (b+log 1000000)).mass z * + ∑ w, (bankLaw (Nat.card K) (b+log 1000000)).mass w * + (if d.choose hdim z w=none then 1 else 0)) ≤ 2*exp (-(Nat.card K:ℝ)) := by + simp_rw [d.choose_failure hdim] + exact d.failure_bound hdim + +theorem Input.choose_valid (d : Input n A B b) (hdim : Module.finrank K V=n+3) + (z : FirstBank (K:=K) (V:=V) b) (w : SecondBank (K:=K) (V:=V) b) + (c : Code (K:=K) (V:=V) b) (hc : d.choose hdim z w=some c) : + let D := read b z w (d.U,d.UT) c + D.1⊆d.U ∧ D.2⊆d.UT ∧ + (D.1.card:ℝ)≤2000*(Nat.card K:ℝ)^(n+3)/B.card ∧ + (D.2.card:ℝ)≤2000*(Nat.card K:ℝ)^(n+3)/A.card ∧ + (99:ℝ)*(A∩d.U).card≤100*((A∩d.U)∩D.1).card ∧ + (99:ℝ)*(B∩d.UT).card≤100*((B∩d.UT)∩D.2).card := by + unfold Input.choose at hc + split at hc + · cases hc + · rename_i i hi + let r := rowAt _ (z d.firstCall.address) i + have hv : d.firstCall.accept n r := index_valid _ _ _ i hi + let c' := d.secondCall hdim r hv + change (c'.bankIndex (b+log 1000000) n w).map _=some c at hc + obtain ⟨j,hj,he⟩ := Option.map_eq_some_iff.mp hc + subst c + have hu := index_valid (c'.accept n) _ (w c'.address) j hj + exact accepted_caps A d.U d.W B d.UT r (rowAt _ (w c'.address) j) hv hu + +end +end SharpLogRamsey.ActualPivot + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Trees/PivotDomains.lean b/lean/OAI/Combinatorics/SharpRamsey/Trees/PivotDomains.lean new file mode 100644 index 0000000000000000000000000000000000000000..5fcb113843c885fc76ef68654f030bc222beb911 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Trees/PivotDomains.lean @@ -0,0 +1,103 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Trees.PivotGeometry +import OAI.Combinatorics.SharpRamsey.Trees.TreeDecoder +import OAI.Combinatorics.SharpRamsey.Reciprocal.ReciprocalPotential +import OAI.Combinatorics.SharpRamsey.Trees.TreePotential + +namespace OAI + +section +namespace SharpLogRamsey.PivotDomains +open Finset Real Incidence TreeDecoder +open scoped Classical BigOperators +noncomputable section + +lemma cap_product {q s t a b C K : ℝ} (r : ℕ) (hq : 0 ring + +def Book.prepare (s : Original (K:=K) (V:=V) n b) + (U : Domains (Projectivization K V) (Projectivization K (Module.Dual K V))) (hr : s.Ready τ U) : + Input n s.A s.B b := + (book.input hdim s.A s.B U s.nonemptyA s.nonemptyB hτ hr.1 hr.2.1 s.product hr.2.2 + (s.sparse U hr hτsmall)).choose + +omit [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma Book.prepare_spec (s : Original (K:=K) (V:=V) n b) + (U : Domains (Projectivization K V) (Projectivization K (Module.Dual K V))) (hr : s.Ready τ U) : + let d := book.prepare hdim hτ hτsmall s U hr + (d.U,d.UT)=U ∧ d.W∈book.library U (s.A∩U.1).card (s.B∩U.2).card ∧ d.W⊆U.1 := by + exact (book.input hdim s.A s.B U s.nonemptyA s.nonemptyB hτ hr.1 hr.2.1 s.product hr.2.2 + (s.sparse U hr hτsmall)).choose_spec + +def Book.choose (s : Original (K:=K) (V:=V) n b) + (z : Banks (K:=K) (V:=V) b) + (U : Domains (Projectivization K V) (Projectivization K (Module.Dual K V))) : + Option (Code (K:=K) (V:=V) b) := + if hr : s.Ready τ U then (book.prepare hdim hτ hτsmall s U hr).choose hdim z.1 z.2 else none + +theorem Book.ready_failure (s : Original (K:=K) (V:=V) n b) + (U : Domains (Projectivization K V) (Projectivization K (Module.Dual K V))) (hr : s.Ready τ U) : + (∑ z,(banksLaw b).mass z*(if book.choose hdim hτ hτsmall s z U=none then 1 else 0)) ≤ + 2*exp (-(Nat.card K:ℝ)) := by + simp only [Book.choose,dite_eq_left hr] + rw [banks_integral] + exact (book.prepare hdim hτ hτsmall s U hr).choose_failure_bound hdim + +theorem Book.dual_exclusion (s : Original (K:=K) (V:=V) n b) + (U : Domains (Projectivization K V) (Projectivization K (Module.Dual K V))) + (y : Projectivization K (Module.Dual K V)) : + (∑ z,(banksLaw b).mass z*(book.choose hdim hτ hτsmall s z U).elim 0 + (fun c=>if y∉(mask b z.1 z.2 U c).2 then 1 else 0)) ≤ + 12*(Nat.card K:ℝ)*(∑ x,SupportMixtures.kernel s.A x * + (if SharpLogRamsey.Incidence.Incident x y then 1 else 0)) := by + by_cases hr : s.Ready τ U + · simp only [Book.choose,dite_eq_left hr] + rw [banks_integral] + exact (book.prepare hdim hτ hτsmall s U hr).dual_loss_bound hdim y + · simp only [Book.choose,dite_eq_right hr,Option.elim_none,mul_zero,sum_const_zero] + apply mul_nonneg (by positivity) + exact sum_nonneg (fun x _=>mul_nonneg (SupportMixtures.kernel_nonneg _ _) (by split_ifs <;> norm_num)) + +theorem Book.primal_exclusion (s : Original (K:=K) (V:=V) n b) + (U : Domains (Projectivization K V) (Projectivization K (Module.Dual K V))) + (x : Projectivization K V) : + (∑ z,(banksLaw b).mass z*(book.choose hdim hτ hτsmall s z U).elim 0 + (fun c=>if x∉(mask b z.1 z.2 U c).1 then 1 else 0)) ≤ + 12*(Nat.card K:ℝ)*(∑ y,SupportMixtures.kernel s.B y * + (if SharpLogRamsey.Incidence.Incident x y then 1 else 0)) := by + by_cases hr : s.Ready τ U + · simp only [Book.choose,dite_eq_left hr] + rw [banks_integral] + exact (book.prepare hdim hτ hτsmall s U hr).primal_loss_bound hdim x + · simp only [Book.choose,dite_eq_right hr,Option.elim_none,mul_zero,sum_const_zero] + apply mul_nonneg (by positivity) + exact sum_nonneg (fun y _=>mul_nonneg (SupportMixtures.kernel_nonneg _ _) (by split_ifs <;> norm_num)) + +theorem Book.choose_caps (s : Original (K:=K) (V:=V) n b) + (U : Domains (Projectivization K V) (Projectivization K (Module.Dual K V))) + (z : Banks (K:=K) (V:=V) b) (c : Code (K:=K) (V:=V) b) + (hc : book.choose hdim hτ hτsmall s z U=some c) : + (9/10:ℝ)*s.A.card≤(s.A∩U.1).card ∧ (9/10:ℝ)*s.B.card≤(s.B∩U.2).card ∧ + (read b z.1 z.2 U c).1⊆U.1 ∧ (read b z.1 z.2 U c).2⊆U.2 ∧ + ((read b z.1 z.2 U c).1.card:ℝ)≤2000*(Nat.card K:ℝ)^(n+3)/s.B.card ∧ + ((read b z.1 z.2 U c).2.card:ℝ)≤2000*(Nat.card K:ℝ)^(n+3)/s.A.card := by + unfold Book.choose at hc + split at hc + · rename_i hr + let d := book.prepare hdim hτ hτsmall s U hr + have hdom := (book.prepare_spec hdim hτ hτsmall s U hr).1 + have hcap := d.choose_valid hdim z.1 z.2 c hc + have hu : d.U=U.1 := congrArg Prod.fst hdom + have hv : d.UT=U.2 := congrArg Prod.snd hdom + dsimp only at hcap + rw [hdom,hu,hv] at hcap + exact ⟨hr.1,hr.2.1,hcap.1,hcap.2.1,hcap.2.2.1,hcap.2.2.2.1⟩ + · cases hc + +end +end SharpLogRamsey.ActualPivot + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Trees/PivotFreshPair.lean b/lean/OAI/Combinatorics/SharpRamsey/Trees/PivotFreshPair.lean new file mode 100644 index 0000000000000000000000000000000000000000..8a7b0fafc229d30864e56a4bbeeaf0cec7d0bf49 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Trees/PivotFreshPair.lean @@ -0,0 +1,118 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Selection.TableCompositions + +namespace OAI + +section +namespace SharpLogRamsey.PivotGeometry +open Finset Real Incidence Validation ProjectiveDuality PublicTables +open scoped Classical BigOperators +noncomputable section +variable {K V : Type*} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] + +def reverseLength (A U : Finset (Projectivization K V)) : ℕ := + scheduleLength (Nat.card K) (U.image (bidual (K:=K) (V:=V))).card + ((A∩U).image (bidual (K:=K) (V:=V))).card + +def reverseIntegral {h : ℕ} (n : ℕ) + (A U : Finset (Projectivization K V)) + (B UT : Finset (Projectivization K (Module.Dual K V))) + (b : ℝ) (z : Fin h→Projectivization K V) + (f : (Fin (reverseLength A U)→Projectivization K (Module.Dual K V))→ℝ) : ℝ := + let q : ℝ := Nat.card K + let e := bidual (K:=K) (V:=V) + let capB := cap SharpLogRamsey.Incidence.Incident q UT z + if hc : capB.Nonempty then + integral (rowLaw capB hc (reverseLength A U)) + (implementAccept ((B∩UT)∩capB) + (GoodCap SharpLogRamsey.Incidence.Incident q (U.image e) ((A∩U).image e) (2000*q^(n+3)/B.card))) + f (scheduleCutoff q (b+log 1000000) (reverseLength A U)) + else 0 + +theorem reverse_good {n h : ℕ} (hdim : Module.finrank K V=n+3) + (A U W : Finset (Projectivization K V)) + (B UT : Finset (Projectivization K (Module.Dual K V))) + (hA : A.Nonempty) (hB : B.Nonempty) + (htrimA : (9/10:ℝ)*A.card≤(A∩U).card) + (htrimB : (9/10:ℝ)*B.card≤(B∩UT).card) + (b : ℝ) (hprod : (Nat.card K:ℝ)^(n+3)*exp (-b)≤(A.card:ℝ)*B.card) + (hsparse : (incidenceCount A B:ℝ)≤(A.card:ℝ)*B.card/(40000*Nat.card K)) + (z : Fin h→Projectivization K V) + (hz : implementAccept ((A∩U)∩W) + (GoodCap SharpLogRamsey.Incidence.Incident (Nat.card K) UT (B∩UT) (2000*(Nat.card K:ℝ)^(n+3)/A.card)) z) : + 1-reverseIntegral n A U B UT b z (fun _ => 1)≤ exp (-(Nat.card K:ℝ)) ∧ + ∀ y,reverseIntegral n A U B UT b z + (fun u => if ¬pass SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) u y then 1 else 0)≤ + 12*(Nat.card K:ℝ)*(∑ x∈univ.filter (fun x => SharpLogRamsey.Incidence.Incident x y),uniformMass B x) := by + let M := 2000*(Nat.card K:ℝ)^(n+3)/A.card + let accept : (Fin h→Projectivization K V)→Prop := + implementAccept ((A∩U)∩W) (GoodCap SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) UT (B∩UT) M) + have hi : firstIndex accept 1 (z,PUnit.unit)=some 0 := by + simp only [firstIndex] + rw [ite_eq_left hz] + have hh := second_scheduled (h:=h) (m:=1) hdim A U W B UT hA hB htrimA htrimB b hprod hsparse + (z,PUnit.unit) 0 hi + dsimp only [rowAt] at hh + simp only [Fin.cases_zero] at hh + have hc : (cap SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) UT z).Nonempty := + hh.1.mono (inter_subset_right) + have hf := (hh.2.2.2 hc).2 + simp only [reverseIntegral,dite_eq_left hc,reverseLength] + with_unfolding_all exact hf + +theorem fresh_pair {n : ℕ} (hdim : Module.finrank K V=n+3) + (A U W : Finset (Projectivization K V)) + (B UT : Finset (Projectivization K (Module.Dual K V))) + (hA : A.Nonempty) (hB : B.Nonempty) + (hX : ((A∩U)∩W).Nonempty) + (htrimA : (9/10:ℝ)*A.card≤(A∩U).card) + (htrimB : (9/10:ℝ)*B.card≤(B∩UT).card) + (b : ℝ) (hprod : (Nat.card K:ℝ)^(n+3)*exp (-b)≤(A.card:ℝ)*B.card) + (hsparse : (incidenceCount A B:ℝ)≤(A.card:ℝ)*B.card/(40000*Nat.card K)) + (hsource : (A.card:ℝ)≤2*((A∩U)∩W).card) + (hratio : (W.card:ℝ)≤ exp (b+log 1000000)*((A∩U)∩W).card) : + let q : ℝ := Nat.card K + let h := scheduleLength q UT.card (B∩UT).card + let m := scheduleCutoff q (b+log 1000000) h + let accept := implementAccept ((A∩U)∩W) + (GoodCap SharpLogRamsey.Incidence.Incident q UT (B∩UT) (2000*q^(n+3)/A.card)) + let p := rowLaw W (hX.mono inter_subset_right) h + 1-integral p accept (fun z => reverseIntegral n A U B UT b z (fun _ => 1)) m≤2*exp (-q) ∧ + (∀ y,integral p accept (fun z => if ¬pass SharpLogRamsey.Incidence.Incident q z y then 1 else 0) m≤ + 12*q*(∑ x∈univ.filter (fun x => SharpLogRamsey.Incidence.Incident x y),uniformMass A x)) ∧ + ∀ y,integral p accept (fun z => reverseIntegral n A U B UT b z + (fun u => if ¬pass SharpLogRamsey.Incidence.Incident q u y then 1 else 0)) m≤ + 12*q*(∑ x∈univ.filter (fun x => SharpLogRamsey.Incidence.Incident x y),uniformMass B x) := by + dsimp only + have hBpos : (0:ℝ) (hg z hz).1) + linarith + · intro y + apply integral_bounded + · apply mul_nonneg (by positivity) + exact sum_nonneg (fun x _ => uniform_nonneg B x) + · intro z hz + exact (hg z hz).2 y + +end +end SharpLogRamsey.PivotGeometry + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Trees/PivotGeometry.lean b/lean/OAI/Combinatorics/SharpRamsey/Trees/PivotGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..0fc9a1d85141e49595c7ea4067f62e7c19de8e6b --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Trees/PivotGeometry.lean @@ -0,0 +1,100 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Selection.ProducedSupportLoss + +namespace OAI + +section +namespace SharpLogRamsey.PivotGeometry +open Finset Real Incidence Validation GeometricCover +open scoped Classical BigOperators +noncomputable section + +lemma description_ratio {w Q A B X T b : ℝ} (hT : 0 card_le_card (filter_subset_filter _ hS))).trans + exact sum_le_sum_of_subset_of_nonneg hT (by intros; exact Nat.zero_le _) + +theorem trimmed_inputs (A U : Finset (Projectivization K V)) + (B UT : Finset (Projectivization K (Module.Dual K V))) (q Q τ b : ℝ) + (hq : 0 ring + +theorem first_source (A U : Finset (Projectivization K V)) + (B UT : Finset (Projectivization K (Module.Dual K V))) (q τ b : ℝ) (r : ℕ) + (hA : A.Nonempty) (hB : B.Nonempty) (hq : 0read b z w (univ,univ) c + +omit [Finite K] in +lemma read_mask_first (b : ℝ) (z : FirstBank (K:=K) (V:=V) b) (w : SecondBank (K:=K) (V:=V) b) + (U : Domains (Projectivization K V) (Projectivization K (Module.Dual K V))) + (c : Code (K:=K) (V:=V) b) : + (read b z w U c).1=U.1∩(mask b z w U c).1 := by + ext x + simp [read,mask,primalCap] + +omit [Finite K] in +lemma read_mask_second (b : ℝ) (z : FirstBank (K:=K) (V:=V) b) (w : SecondBank (K:=K) (V:=V) b) + (U : Domains (Projectivization K V) (Projectivization K (Module.Dual K V))) + (c : Code (K:=K) (V:=V) b) : + (read b z w U c).2=U.2∩(mask b z w U c).2 := by + ext x + simp [read,mask,cap] + +variable {n : ℕ} {A : Finset (Projectivization K V)} + {B : Finset (Projectivization K (Module.Dual K V))} {b : ℝ} + +def Input.dualLoss (d : Input n A B b) (hdim : Module.finrank K V=n+3) + (y : Projectivization K (Module.Dual K V)) + (z : FirstBank (K:=K) (V:=V) b) (w : SecondBank (K:=K) (V:=V) b) : ℝ := + (d.choose hdim z w).elim 0 (fun c=>if y∉(mask b z w (d.U,d.UT) c).2 then 1 else 0) + +def Input.primalLoss (d : Input n A B b) (hdim : Module.finrank K V=n+3) + (x : Projectivization K V) + (z : FirstBank (K:=K) (V:=V) b) (w : SecondBank (K:=K) (V:=V) b) : ℝ := + (d.choose hdim z w).elim 0 (fun c=>if x∉(mask b z w (d.U,d.UT) c).1 then 1 else 0) + +lemma Input.dual_loss_le (d : Input n A B b) (hdim : Module.finrank K V=n+3) + (y : Projectivization K (Module.Dual K V)) + (z : FirstBank (K:=K) (V:=V) b) (w : SecondBank (K:=K) (V:=V) b) : + d.dualLoss hdim y z w ≤ (d.firstCall.bankRow (b+log 1000000) n z).elim 0 + (fun r=>if ¬pass SharpLogRamsey.Incidence.Incident (Nat.card K) r y then 1 else 0) := by + unfold Input.dualLoss + rw [d.firstRow_eq] + cases hi : d.firstCall.bankIndex (b+log 1000000) n z with + | none => rw [d.choose_first_fail hdim z w hi]; simp + | some i => + rw [d.choose_of_index hdim z w i hi] + let c := d.secondCall hdim (rowAt _ (z d.firstCall.address) i) (index_valid _ _ _ i hi) + change ((c.bankIndex (b+log 1000000) n w).map _).elim _ _ ≤ _ + cases c.bankIndex (b+log 1000000) n w <;> simp [mask,read,cap] + split_ifs <;> norm_num + +lemma Input.primal_loss_eq (d : Input n A B b) (hdim : Module.finrank K V=n+3) + (x : Projectivization K V) + (z : FirstBank (K:=K) (V:=V) b) (w : SecondBank (K:=K) (V:=V) b) : + d.primalLoss hdim x z w=d.secondLoss hdim (bidual x) z w := by + unfold Input.primalLoss Input.secondLoss + cases hi : d.firstCall.bankIndex (b+log 1000000) n z with + | none => + have hr : d.firstCall.bankRow (b+log 1000000) n z=none := by + rw [d.firstRow_eq,hi,Option.map_none] + rw [d.choose_first_fail hdim z w hi,(d.next_none hdim z).mpr hr] + rfl + | some i => + rw [d.choose_of_index hdim z w i hi,d.next_of_index hdim z i hi] + let c := d.secondCall hdim (rowAt _ (z d.firstCall.address) i) (index_valid _ _ _ i hi) + change ((c.bankIndex (b+log 1000000) n w).map _).elim _ _ = + (c.bankRow (b+log 1000000) n w).elim _ _ + have hr : c.bankRow (b+log 1000000) n w = + (c.bankIndex (b+log 1000000) n w).map (rowAt _ (w c.address)) := + (reconstruct_first _ _ _).symm + rw [hr] + cases c.bankIndex (b+log 1000000) n w <;> simp [mask,read,primalCap] + rfl + +theorem Input.dual_loss_bound (d : Input n A B b) (hdim : Module.finrank K V=n+3) + (y : Projectivization K (Module.Dual K V)) : + (∑ z, (bankLaw (Nat.card K) (b+log 1000000)).mass z * + ∑ w, (bankLaw (Nat.card K) (b+log 1000000)).mass w * d.dualLoss hdim y z w) ≤ + 12*(Nat.card K:ℝ)*(∑ x, SupportMixtures.kernel A x * + (if SharpLogRamsey.Incidence.Incident x y then 1 else 0)) := by + apply le_trans _ (d.firstCall.bank_loss_bound (b+log 1000000) rfl hdim y) + apply sum_le_sum + intro z _ + apply mul_le_mul_of_nonneg_left _ ((bankLaw _ _).nonneg z) + calc + _ ≤ ∑ w, (bankLaw (Nat.card K) (b+log 1000000)).mass w * + (d.firstCall.bankRow (b+log 1000000) n z).elim 0 + (fun r=>if ¬pass SharpLogRamsey.Incidence.Incident (Nat.card K) r y then 1 else 0) := by + apply sum_le_sum + intro w _ + exact mul_le_mul_of_nonneg_left (d.dual_loss_le hdim y z w) ((bankLaw _ _).nonneg w) + _ = _ := by rw [←sum_mul,PublicTables.Law.total,one_mul] + +theorem Input.primal_loss_bound (d : Input n A B b) (hdim : Module.finrank K V=n+3) + (x : Projectivization K V) : + (∑ z, (bankLaw (Nat.card K) (b+log 1000000)).mass z * + ∑ w, (bankLaw (Nat.card K) (b+log 1000000)).mass w * d.primalLoss hdim x z w) ≤ + 12*(Nat.card K:ℝ)*(∑ y, SupportMixtures.kernel B y * + (if SharpLogRamsey.Incidence.Incident x y then 1 else 0)) := by + simp_rw [d.primal_loss_eq hdim] + simpa only [ProjectiveDuality.incident_bidual] using d.second_loss_bound hdim (bidual x) + +end +end SharpLogRamsey.ActualPivot + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Trees/PivotValidation.lean b/lean/OAI/Combinatorics/SharpRamsey/Trees/PivotValidation.lean new file mode 100644 index 0000000000000000000000000000000000000000..560dded581a8ebc2064823834317b4e6881070b0 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Trees/PivotValidation.lean @@ -0,0 +1,94 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Trees.PivotDomains + +namespace OAI + +section +namespace SharpLogRamsey.PivotGeometry +open Finset Real Incidence Validation GeometricCover ProjectiveDuality +open scoped Classical BigOperators +noncomputable section + +lemma second_ratio {w Q A B X b : ℝ} (hA : 0 1) m'≤ exp (-q) ∧ + ∀ y,PublicTables.integral (rowLaw capB hcapB h') + (implementAccept sourceB (GoodCap SharpLogRamsey.Incidence.Incident q domainA targetA M')) + (fun z => if ¬pass SharpLogRamsey.Incidence.Incident q z y then 1 else 0) m'≤ + 12*q*(∑ x∈univ.filter (fun x => SharpLogRamsey.Incidence.Incident x y),uniformMass B x) := by + dsimp only + let e := bidual (K:=K) (V:=V) + let capB := cap SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) UT (PublicTables.rowAt m table i) + let sourceB := (B∩UT)∩capB + have hd := decoded_cap ((A∩U)∩W) SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) UT (B∩UT) + inter_subset_right (2000*(Nat.card K:ℝ)^(n+3)/A.card) h m table i hi + have hs := second_source B (B∩UT) capB hB htrimB hd.2.2 + have hApos : (0:ℝ) .nil + | .node i l r, U => match choose i U with + | none => .nil + | some c => + let V := read U c + .node (i,c) (execute read choose l (V.1,U.2)) + (execute read choose r (U.1,V.2)) + +lemma execute_height (read : CapReader A B C) (choose : I → Domains A B → Option C) + (t : BinaryTree I) (U : Domains A B) : + (execute read choose t U).height≤t.height := by + induction t generalizing U with + | nil => rfl + | node i l r hl hr => + simp only [execute] + split + · simp + · simp only [height] + exact Nat.add_le_add_right (max_le_max (hl _) (hr _)) 1 + +lemma execute_numNodes (read : CapReader A B C) (choose : I → Domains A B → Option C) + (t : BinaryTree I) (U : Domains A B) : + (execute read choose t U).numNodes≤t.numNodes := by + induction t generalizing U with + | nil => rfl + | node i l r hl hr => + simp only [execute] + split + · simp + · simp only [numNodes] + exact Nat.add_le_add_right (Nat.add_le_add (hl _) (hr _)) 1 + +def flagDomain (R : A → B → Prop) (U : Domains A B) : Finset (A×B) := + (U.1×ˢU.2).filter (fun z => R z.1 z.2) + +def retained (R : A → B → Prop) (U : Domains A B) (xs : List (A×B)) (n : ℕ) : List (A×B) := + (xs.filter (fun z => z∈flagDomain R U)).take n + +lemma retained_sublist (R : A → B → Prop) (U : Domains A B) (xs : List (A×B)) (n : ℕ) : + retained R U xs n <+ xs := + (List.take_sublist n _).trans List.filter_sublist + +lemma retained_mem (R : A → B → Prop) (U : Domains A B) (xs : List (A×B)) (n : ℕ) + {x : A×B} (hx : x∈retained R U xs n) : x∈flagDomain R U := by + exact of_decide_eq_true (List.mem_filter.mp (List.mem_of_mem_take hx)).2 + +def output (R : A → B → Prop) (read : CapReader A B C) + (targets : I → List (A×B)) (counts : I → ℕ) : BinaryTree (I×C) → Domains A B → List (A×B) + | .nil, _ => [] + | .node (i,c) l r, U => + let V := read U c + output R read targets counts l (V.1,U.2) ++ + retained R V (targets i) (counts i) ++ + output R read targets counts r (U.1,V.2) + +def message (R : A → B → Prop) (read : CapReader A B C) + (targets : I → List (A×B)) (counts : I → ℕ) : BinaryTree (I×C) → Domains A B → BinaryTree (C×ℕ) + | .nil, _ => .nil + | .node (i,c) l r, U => + let V := read U c + .node (c,(retained R V (targets i) (counts i)).length) + (message R read targets counts l (V.1,U.2)) + (message R read targets counts r (U.1,V.2)) + +def decode (R : A → B → Prop) (read : CapReader A B C) : + BinaryTree (C×ℕ) → Domains A B → List (Finset (A×B)) + | .nil, _ => [] + | .node (c,n) l r, U => + let V := read U c + decode R read l (V.1,U.2) ++ List.replicate n (flagDomain R V) ++ + decode R read r (U.1,V.2) + +lemma forall₂_replicate_membership {α : Type*} (xs : List α) (S : Finset α) + (h : ∀ x∈xs,x∈S) : List.Forall₂ (fun x D => x∈D) xs (List.replicate xs.length S) := by + induction xs with + | nil => simp + | cons a xs ih => + simp only [List.length_cons,List.replicate_succ] + exact List.Forall₂.cons (h a (by simp)) + (ih (fun x hx => h x (List.mem_cons_of_mem a hx))) + +theorem decoder_correct (R : A → B → Prop) (read : CapReader A B C) + (targets : I → List (A×B)) (counts : I → ℕ) (t : BinaryTree (I×C)) (U : Domains A B) : + List.Forall₂ (fun x D => x∈D) (output R read targets counts t U) + (decode R read (message R read targets counts t U) U) := by + induction t generalizing U with + | nil => exact List.Forall₂.nil + | node z l r hl hr => + rcases z with ⟨i,c⟩ + simp only [output,message,decode] + apply List.rel_append + · apply List.rel_append + · exact hl _ + · apply forall₂_replicate_membership + intro x hx + exact retained_mem R _ _ _ hx + · exact hr _ + +def population (targets : I → List (A×B)) : BinaryTree I → List (A×B) + | .nil => [] + | .node i l r => population targets l ++ targets i ++ population targets r + +theorem output_sublist (R : A → B → Prop) (read : CapReader A B C) + (choose : I → Domains A B → Option C) (targets : I → List (A×B)) (counts : I → ℕ) + (t : BinaryTree I) (U : Domains A B) : + output R read targets counts (execute read choose t U) U <+ population targets t := by + induction t generalizing U with + | nil => rfl + | node i l r hl hr => + simp only [execute] + split + · exact List.nil_sublist _ + · simp only [output,population] + exact ((hl _).append (retained_sublist R _ _ _)).append (hr _) + +end +end SharpLogRamsey.TreeDecoder + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Trees/TreeHeight.lean b/lean/OAI/Combinatorics/SharpRamsey/Trees/TreeHeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..05a0adcedb7370563cc638d3afee656f4be77ac6 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Trees/TreeHeight.lean @@ -0,0 +1,63 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Windows.BalancedWindows + +namespace OAI + +section +namespace SharpLogRamsey.ChronologicalTree +open Finset Filter Real BinaryTree +open scoped Classical Topology +noncomputable section + +lemma eventually_natLog_small (β C a : ℝ) (hβ : 0<β) (hC : 0x^(-β)) atTop (𝓝 0) := tendsto_rpow_neg_atTop hβ + have hl := (isLittleO_log_rpow_atTop hβ).tendsto_div_nhds_zero + have ht : Tendsto (fun x : ℝ=>(log C/log 2+1)*x^(-β)+(a/log 2)*(log x/x^β)) + atTop (𝓝 0) := by + simpa only [mul_zero,add_zero] using + (hp.const_mul (log C/log 2+1)).add (hl.const_mul (a/log 2)) + filter_upwards [ht.eventually (gt_mem_nhds (show (0:ℝ)<1 by norm_num)), + eventually_ge_atTop (1:ℝ)] with x hx hx1 n hn + have hx0 : 0 0 + | .node a l r => f a + total f l + total f r + +def root (f : α → ℝ) : BinaryTree α → ℝ + | .nil => 0 + | .node a _ _ => f a + +def Admissible (f : α → ℝ) (K : ℝ) : BinaryTree α → Prop + | .nil => True + | .node a l r => 0≤f a ∧ root f l+root f r≤f a+K ∧ + Admissible f K l ∧ Admissible f K r + +lemma root_nonneg (f : α → ℝ) (K : ℝ) {t : BinaryTree α} (h : Admissible f K t) : + 0≤root f t := by + cases t with + | nil => rfl + | node a l r => exact h.1 + +lemma total_nonneg (f : α → ℝ) (K : ℝ) {t : BinaryTree α} (h : Admissible f K t) : + 0≤total f t := by + induction t with + | nil => rfl + | node a l r hl hr => exact add_nonneg (add_nonneg h.1 (hl h.2.2.1)) (hr h.2.2.2) + +theorem total_le_height (f : α → ℝ) (K : ℝ) (hK : 0≤K) + (t : BinaryTree α) (h : Admissible f K t) : + total f t≤(t.height:ℝ)*(root f t+(t.numNodes:ℝ)*K) := by + induction t with + | nil => simp [total,root] + | node a l r hl hr => + rcases h with ⟨ha,hbranch,hleft,hright⟩ + have hln := root_nonneg f K hleft + have hrn := root_nonneg f K hright + have ihl := hl hleft + have ihr := hr hright + have hhl : (l.height:ℝ)≤(max l.height r.height:ℝ) := by exact_mod_cast le_max_left _ _ + have hhr : (r.height:ℝ)≤(max l.height r.height:ℝ) := by exact_mod_cast le_max_right _ _ + have hL := mul_le_mul_of_nonneg_right hhl (add_nonneg hln (by positivity : 0≤(l.numNodes:ℝ)*K)) + have hR := mul_le_mul_of_nonneg_right hhr (add_nonneg hrn (by positivity : 0≤(r.numNodes:ℝ)*K)) + have hB := mul_le_mul_of_nonneg_left hbranch (show 0≤(max l.height r.height:ℝ) by positivity) + simp only [total,root,height,numNodes,Nat.cast_add,Nat.cast_one,Nat.cast_max] + have hN : 0≤((l.numNodes:ℝ)+(r.numNodes:ℝ)+1)*K := by positivity + nlinarith + +lemma total_mono (f g : α → ℝ) (t : BinaryTree α) (h : ∀ a,f a≤g a) : + total f t≤total g t := by + induction t with + | nil => rfl + | node a l r hl hr => exact add_le_add (add_le_add (h a) hl) hr + +lemma total_affine (f : α → ℝ) (c b : ℝ) (t : BinaryTree α) : + total (fun a => c*(f a+b)) t=c*(total f t+(t.numNodes:ℝ)*b) := by + induction t with + | nil => simp [total] + | node a l r hl hr => simp only [total,numNodes,Nat.cast_add,Nat.cast_one,hl,hr]; ring + +theorem cost_bound (f cost : α → ℝ) (K c b : ℝ) (hK : 0≤K) (hc : 0≤c) + (t : BinaryTree α) (h : Admissible f K t) (hcost : ∀ a,cost a≤c*(f a+b)) : + total cost t≤c*((t.height:ℝ)*(root f t+(t.numNodes:ℝ)*K)+(t.numNodes:ℝ)*b) := by + apply (total_mono cost (fun a => c*(f a+b)) t hcost).trans + rw [total_affine] + exact mul_le_mul_of_nonneg_left (add_le_add (total_le_height f K hK t h) le_rfl) hc + +end SharpLogRamsey.TreePotential + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Trees/TreeShapes.lean b/lean/OAI/Combinatorics/SharpRamsey/Trees/TreeShapes.lean new file mode 100644 index 0000000000000000000000000000000000000000..ed48bed12ca4000e61f77f0432c63ce8c62fedc7 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Trees/TreeShapes.lean @@ -0,0 +1,58 @@ +import Mathlib + +namespace OAI + +section +namespace SharpLogRamsey.TreeShapes +open BinaryTree Finset +open scoped Classical + +def bits : BinaryTree Unit→List Bool + | .nil => [false] + | .node _ l r => true::(bits l++bits r) + +lemma bits_length (t : BinaryTree Unit) : (bits t).length=2*t.numNodes+1 := by + induction t with + | nil => simp [bits] + | node _ l r hl hr => simp only [bits,List.length_cons,List.length_append,numNodes,hl,hr]; omega + +lemma prefix_free (t t' : BinaryTree Unit) (u v : List Bool) + (h : bits t++u=bits t'++v) : t=t' ∧ u=v := by + induction t generalizing t' u v with + | nil => + cases t' with + | nil => simpa [bits] using h + | node _ _ _ => simp [bits] at h + | node a l r hl hr => + cases t' with + | nil => simp [bits] at h + | node a' l' r' => + have he : bits l++(bits r++u)=bits l'++(bits r'++v) := by + simpa only [bits,List.cons_append,List.cons.injEq,true_and,List.append_assoc] using h + obtain ⟨hl',hh⟩ := hl l' (bits r++u) (bits r'++v) he + obtain ⟨hr',hu⟩ := hr r' u v hh + exact ⟨by cases a;cases a';simp [hl',hr'],hu⟩ + +noncomputable def boundedEncode (N : ℕ) (S : Finset (BinaryTree Unit)) + (hS : ∀ t∈S,t.numNodes≤N) (t : S) : List.Vector Bool (2*N+1) := + ⟨bits t.val++List.replicate (2*N+1-(bits t.val).length) false,by + have ht := hS t.val t.property + simp only [List.length_append,List.length_replicate,bits_length] + omega⟩ + +lemma boundedEncode_injective (N : ℕ) (S : Finset (BinaryTree Unit)) + (hS : ∀ t∈S,t.numNodes≤N) : Function.Injective (boundedEncode N S hS) := by + intro s t he + have hh := congrArg Subtype.val he + exact Subtype.ext (prefix_free s.val t.val _ _ hh).1 + +theorem card_le (N : ℕ) (S : Finset (BinaryTree Unit)) + (hS : ∀ t∈S,t.numNodes≤N) : S.card≤2^(2*N+1) := by + have h := Fintype.card_le_of_injective _ (boundedEncode_injective N S hS) + simpa only [Fintype.card_coe,card_vector,Fintype.card_bool] using h + +end SharpLogRamsey.TreeShapes + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Validation/ProducedExclusion.lean b/lean/OAI/Combinatorics/SharpRamsey/Validation/ProducedExclusion.lean new file mode 100644 index 0000000000000000000000000000000000000000..28d554b92f822ddb8e8167b4f36a34540ffbea16 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Validation/ProducedExclusion.lean @@ -0,0 +1,553 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Validation.ValidationTools + +namespace OAI + +section +namespace SharpLogRamsey.Validation +open Finset +open scoped BigOperators Classical +open SharpLogRamsey.FiniteSamplingBounds +noncomputable section +variable {Ω Y : Type*} [Fintype Ω] +theorem produced_exclusion (X W : Finset Ω) (hX : X.Nonempty) (hW : W.Nonempty) + (hsub : X⊆W) (h : ℕ) (hh : 0 if ¬pass R q z y then 1 else 0) m ≤ + 6*q*(∑ x∈univ.filter (fun x => R x y),uniformMass X x) := by + have hd := public_iid_domination X W hX hW hsub h Good hGood + (fun z => if ¬pass R q z y then 1 else 0) (by intro z; split_ifs <;> norm_num) m + simp only [mul_ite,mul_one,mul_zero] at hd + apply hd.trans + have he := mul_le_mul_of_nonneg_left + (pointwise_exclusion (uniformMass X) (uniform_nonneg X) (uniform_total hX) R q hq h hh y) + (show (0:ℝ)≤10/9 by norm_num) + apply he.trans + have hp : 0≤∑ x∈univ.filter (fun x => R x y),uniformMass X x := + sum_nonneg (fun x _ => uniform_nonneg X x) + nlinarith [mul_nonneg hq.le hp] + +end +end SharpLogRamsey.Validation + +namespace SharpLogRamsey.PublicTables +open Finset +open scoped BigOperators Classical +variable {Ω : Type*} [Fintype Ω] + +theorem failure_exp (p : Law Ω) (A : Ω → Prop) [DecidablePred A] (m : ℕ) : + 1-integral p A (fun _ => 1) m ≤ Real.exp (-(m:ℝ)*acceptProb p A) := by + rw [production_probability] + have hp : 0≤1-acceptProb p A := sub_nonneg.mpr (acceptProb_le_one p A) + have he := pow_le_pow_left₀ hp (Real.one_sub_le_exp_neg (acceptProb p A)) m + calc + _ = (1-acceptProb p A)^m := by ring + _ ≤ Real.exp (-acceptProb p A)^m := he + _ = _ := by + rw [←Real.exp_nat_mul] + congr 1 + ring + +end SharpLogRamsey.PublicTables + +namespace SharpLogRamsey.Incidence +open Finset +open scoped BigOperators Classical +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] +variable [Finite K] [FiniteDimensional K V] +variable [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + +theorem low_incidence_half_target_mass {n : ℕ} (hdim : Module.finrank K V = n+3) + (w : Projectivization K V → ℝ) (hw : ∀ x, 0 ≤ w x) (ht : ∑ x, w x = 1) + (M : ℝ) (hM : ∀ x, w x ≤ M) + (v : Projectivization K (Module.Dual K V) → ℝ) (N : ℝ) + (hN0 : 0 ≤ N) (hN : ∀ y, v y ≤ N) : + (∑ y ∈ univ.filter (fun y => weightedIncidences SharpLogRamsey.Incidence.Incident w y < + 1/(2*(Nat.card K:ℝ))), v y) ≤ 36*(Nat.card K:ℝ)^(n+3)*M*N := by + let q : ℝ := Nat.card K + let u : ℝ := ∑ i ∈ range (n+2), q^i + let p : ℝ := u/(∑ i ∈ range (n+3), q^i) + let B := univ.filter (fun y => weightedIncidences SharpLogRamsey.Incidence.Incident w y < 1/(2*q)) + have hq : 2 ≤ q := by + change (2:ℝ) ≤ Nat.card K + exact_mod_cast (Finite.one_lt_card : 1 < Nat.card K) + have hq0 : 0 < q := by linarith + have hu : 1 ≤ u := by + have hs := single_le_sum (f := fun i => q^i) + (fun i _ => pow_nonneg hq0.le i) (show 0 ∈ range (n+2) by simp) + simpa [u] using hs + have hvpos : 0 < ∑ i ∈ range (n+3), q^i := by + rw [geom_sum_succ] + change 0 < q*u+1 + positivity + have hp : 2/(3*q) ≤ p := by + change 2/(3*q) ≤ u/(∑ i ∈ range (n+3), q^i) + apply (div_le_div_iff₀ (by positivity) hvpos).mpr + rw [geom_sum_succ] + change 2*(q*u+1) ≤ u*(3*q) + nlinarith + have hnorm : (∑ x, w x^2) ≤ M := by + calc + _ ≤ ∑ x, M*w x := by + apply sum_le_sum + intro x _ + simpa only [pow_two] using mul_le_mul_of_nonneg_right (hM x) (hw x) + _ = M := by rw [← mul_sum, ht, mul_one] + have hvar := (projective_variance_le hdim w).trans + (mul_le_mul_of_nonneg_left hnorm (show 0 ≤ q^(n+1) by positivity)) + change (∑ y, (weightedIncidences SharpLogRamsey.Incidence.Incident w y-p*(∑ x, w x))^2) ≤ q^(n+1)*M at hvar + rw [ht, mul_one] at hvar + have hc : (B.card:ℝ)*(1/(6*q))^2 ≤ q^(n+1)*M := by + calc + _ = ∑ _y ∈ B, (1/(6*q))^2 := by simp + _ ≤ ∑ y ∈ B, (weightedIncidences SharpLogRamsey.Incidence.Incident w y-p)^2 := by + apply sum_le_sum + intro y hy + have hb : weightedIncidences SharpLogRamsey.Incidence.Incident w y < 1/(2*q) := (mem_filter.mp hy).2 + have hg : 1/(6*q) ≤ p-weightedIncidences SharpLogRamsey.Incidence.Incident w y := by + have he : 2/(3*q)-1/(2*q) = 1/(6*q) := by field_simp; ring + linarith + have hi : 0 ≤ 1/(6*q) := by positivity + nlinarith + _ ≤ ∑ y, (weightedIncidences SharpLogRamsey.Incidence.Incident w y-p)^2 := by + apply sum_le_sum_of_subset_of_nonneg (subset_univ B) + intro y _ _ + positivity + _ ≤ _ := hvar + have hmult := mul_le_mul_of_nonneg_right hc (show 0 ≤ 36*q^2 by positivity) + have hcancel : (B.card:ℝ)*(1/(6*q))^2*(36*q^2) = B.card := by + field_simp + ring + rw [hcancel] at hmult + have he : q^(n+1)*M*(36*q^2) = 36*q^(n+3)*M := by + rw [show n+3 = (n+1)+2 by omega, pow_add] + ring + rw [he] at hmult + change (∑ y ∈ B, v y) ≤ _ + calc + _ ≤ ∑ _y ∈ B, N := by apply sum_le_sum; intro y _; exact hN y + _ = (B.card:ℝ)*N := by simp + _ ≤ (36*q^(n+3)*M)*N := mul_le_mul_of_nonneg_right hmult hN0 + +end SharpLogRamsey.Incidence + +namespace SharpLogRamsey.Validation +open Finset +open scoped BigOperators Classical +open SharpLogRamsey.FiniteSamplingBounds SharpLogRamsey.Incidence +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] +variable [Finite K] [FiniteDimensional K V] +variable [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + +theorem projective_low_card {n : ℕ} (hdim : Module.finrank K V=n+3) + (X : Finset (Projectivization K V)) (hX : X.Nonempty) + (U : Finset (Projectivization K (Module.Dual K V))) : + ((U.filter (fun y => (∑ x∈univ.filter (fun x => SharpLogRamsey.Incidence.Incident x y),uniformMass X x) + <1/(2*(Nat.card K:ℝ)))).card:ℝ) ≤ 36*(Nat.card K:ℝ)^(n+3)/(X.card:ℝ) := by + have hu (x : Projectivization K V) : uniformMass X x ≤ (X.card:ℝ)⁻¹ := by + unfold uniformMass + split_ifs + · exact le_rfl + · exact inv_nonneg.mpr (Nat.cast_nonneg X.card) + have hb := low_incidence_half_target_mass hdim (uniformMass X) (uniform_nonneg X) + (uniform_total hX) (X.card:ℝ)⁻¹ hu (fun _ => (1:ℝ)) 1 (by norm_num) (by simp) + simp only [sum_const, nsmul_eq_mul, mul_one,div_eq_mul_inv] at hb ⊢ + apply le_trans _ hb + apply Nat.cast_le.mpr + apply card_le_card + intro y hy + simp only [mem_filter,mem_univ,true_and] at hy ⊢ + simpa only [weightedIncidences,←sum_filter] using hy.2 + +theorem projective_cap_mean {n : ℕ} (hdim : Module.finrank K V=n+3) + (X : Finset (Projectivization K V)) (hX : X.Nonempty) + (U : Finset (Projectivization K (Module.Dual K V))) (h : ℕ) : + (∑ z : Fin h → Projectivization K V, rowWeight (uniformMass X) z* + ((cap SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) U z).card:ℝ)) ≤ + 36*(Nat.card K:ℝ)^(n+3)/(X.card:ℝ)+ + (U.card:ℝ)*Real.exp (1-(h:ℝ)/(20*(Nat.card K:ℝ))) := by + have hq : 0<(Nat.card K:ℝ) := by exact_mod_cast (Nat.card_pos (α:=K)) + exact (cap_mean_le (uniformMass X) (uniform_nonneg X) (uniform_total hX) + SharpLogRamsey.Incidence.Incident _ hq h U).trans (add_le_add (projective_low_card hdim X hX U) le_rfl) + +theorem projective_ideal_acceptance {n : ℕ} (hdim : Module.finrank K V=n+3) + (X : Finset (Projectivization K V)) (hX : X.Nonempty) + (U T : Finset (Projectivization K (Module.Dual K V))) (hT : T.Nonempty) + (h : ℕ) (hh : 0 SharpLogRamsey.Incidence.Incident x y),uniformMass X x) + ≤ (T.card:ℝ)/(10000*(Nat.card K:ℝ))) : + (9/10:ℝ) ≤ prob (uniformMass X) h (fun z => + ((cap SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) U z).card:ℝ)≤M ∧ + ((T.filter (fun y => ¬pass SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) z y)).card:ℝ)≤(T.card:ℝ)/100) := by + have hq : 0<(Nat.card K:ℝ) := by exact_mod_cast (Nat.card_pos (α:=K)) + apply acceptance_mass (uniformMass X) (uniform_nonneg X) (uniform_total hX) + SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) h U T M hM hT + · exact (projective_cap_mean hdim X hX U h).trans hsize + · apply (loss_mean_le (uniformMass X) (uniform_nonneg X) (uniform_total hX) + SharpLogRamsey.Incidence.Incident _ hq h hh T).trans + have hs := mul_le_mul_of_nonneg_left hsparse (show 0≤5*(Nat.card K:ℝ) by positivity) + apply hs.trans_eq + field_simp + ring + +end +end SharpLogRamsey.Validation + +namespace SharpLogRamsey.PublicTables +open Finset +open scoped BigOperators Classical +universe u +variable {Ω : Type u} + +def rowAt : (n : ℕ) → Table Ω n → Fin n → Ω + | 0, _, i => Fin.elim0 i + | n+1, z, i => Fin.cases z.1 (rowAt n z.2) i + +noncomputable def firstIndex (A : Ω → Prop) [DecidablePred A] : + (n : ℕ) → Table Ω n → Option (Fin n) + | 0, _ => none + | n+1, z => if A z.1 then some 0 else (firstIndex A n z.2).map Fin.succ + +theorem reconstruct_first (A : Ω → Prop) [DecidablePred A] (n : ℕ) (z : Table Ω n) : + (firstIndex A n z).map (rowAt n z) = first A n z := by + induction n with + | zero => rfl + | succ n ih => + change (if A z.1 then some 0 else (firstIndex A n z.2).map Fin.succ).map + (rowAt (n+1) z) = if A z.1 then some z.1 else first A n z.2 + by_cases ha : A z.1 + · simp only [ha,ite_true,Option.map_some,rowAt,Fin.cases_zero] + · simp only [ha,ite_false,Option.map_map] + have hf : rowAt (n+1) z ∘ Fin.succ = rowAt n z.2 := by + funext i + simp only [Function.comp_apply,rowAt,Fin.cases_succ] + rw [hf,ih] + +theorem first_valid (A : Ω → Prop) [DecidablePred A] (n : ℕ) (z : Table Ω n) + (x : Ω) (hx : first A n z=some x) : A x := by + induction n with + | zero => cases hx + | succ n ih => + change (if A z.1 then some z.1 else first A n z.2)=some x at hx + split_ifs at hx with ha + · have : z.1=x := Option.some.inj hx + simpa only [this] using ha + · exact ih z.2 hx + +theorem index_valid (A : Ω → Prop) [DecidablePred A] (n : ℕ) (z : Table Ω n) + (i : Fin n) (hi : firstIndex A n z=some i) : A (rowAt n z i) := by + have he := reconstruct_first A n z + rw [hi,Option.map_some] at he + exact first_valid A n z _ he.symm + +end SharpLogRamsey.PublicTables + +namespace SharpLogRamsey.Validation +open Finset +open scoped BigOperators Classical +open SharpLogRamsey.FiniteSamplingBounds +noncomputable section +variable {Ω Y : Type*} [Fintype Ω] + +def GoodCap (R : Ω → Y → Prop) (q : ℝ) (U T : Finset Y) (M : ℝ) + {h : ℕ} (z : Fin h → Ω) : Prop := + ((cap R q U z).card:ℝ)≤M ∧ + ((T.filter (fun y => ¬pass R q z y)).card:ℝ)≤(T.card:ℝ)/100 + +omit [Fintype Ω] in +lemma cap_capture {R : Ω → Y → Prop} [Fintype Ω] {q : ℝ} {U T : Finset Y} + {M : ℝ} {h : ℕ} {z : Fin h → Ω} (hT : T⊆U) (hg : GoodCap R q U T M z) : + (99:ℝ)*(T.card:ℝ) ≤ 100*((T∩cap R q U z).card:ℝ) := by + have he : T∩cap R q U z = T.filter (pass R q z) := by + ext y + simp only [mem_inter,cap,mem_filter] + exact ⟨fun h => ⟨h.1,h.2.2⟩,fun h => ⟨h.1,hT h.1,h.2⟩⟩ + rw [he] + have ht := card_filter_add_card_filter_not (s:=T) (pass R q z) + have ht' : ((T.filter (pass R q z)).card:ℝ)+ + ((T.filter (fun y => ¬pass R q z y)).card:ℝ) = T.card := by exact_mod_cast ht + have hl := hg.2 + linarith + +theorem decoded_cap (X : Finset Ω) (R : Ω → Y → Prop) + (q : ℝ) (U T : Finset Y) (hT : T⊆U) (M : ℝ) (h m : ℕ) + (table : PublicTables.Table (Fin h → Ω) m) (i : Fin m) + (hi : PublicTables.firstIndex (implementAccept X (GoodCap R q U T M)) m table=some i) : + let C := cap R q U (PublicTables.rowAt m table i) + C⊆U ∧ (C.card:ℝ)≤M ∧ (99:ℝ)*(T.card:ℝ)≤100*((T∩C).card:ℝ) := by + have hg := (PublicTables.index_valid (implementAccept X (GoodCap R q U T M)) m table i hi).2 + exact ⟨filter_subset _ _,hg.1,cap_capture hT hg⟩ + +omit [Fintype Ω] in +lemma uniform_sum_mono {X₀ X E : Finset Ω} (hX : X.Nonempty) (h₀ : X₀.Nonempty) + (hsub : X₀⊆X) (c : ℝ) (hc : 0 mem_inter.mpr ⟨(mem_inter.mp hx).1,hsub (mem_inter.mp hx).2⟩) + apply (le_inv_mul_iff₀ hc).mpr + apply (le_div_iff₀ hx).mpr + rw [show c*(((E∩X₀).card:ℝ)/(X₀.card:ℝ))*(X.card:ℝ) = + (c*(X.card:ℝ)*((E∩X₀).card:ℝ))/(X₀.card:ℝ) by ring] + apply (div_le_iff₀ hx₀).mpr + have h1 := mul_le_mul_of_nonneg_left hcap (show 0≤((E∩X).card:ℝ) by positivity) + have h2 := mul_le_mul_of_nonneg_left he (show 0≤c*(X.card:ℝ) by positivity) + nlinarith + +theorem original_exclusion (X₀ X W : Finset Ω) (hX₀ : X₀.Nonempty) + (hX : X.Nonempty) (hW : W.Nonempty) (hsub : X₀⊆X) (hWsub : X₀⊆W) + (c : ℝ) (hc : 0 if ¬pass R q z y then 1 else 0) m ≤ + (6/c)*q*(∑ x∈univ.filter (fun x => R x y),uniformMass X x) := by + apply (produced_exclusion X₀ W hX₀ hW hWsub h hh Good hGood R q hq y m).trans + have hm := mul_le_mul_of_nonneg_left (uniform_sum_mono hX hX₀ hsub c hc hcap + (E:=univ.filter (fun x => R x y))) (show 0≤6*q by positivity) + exact hm.trans_eq (by ring) + +end +end SharpLogRamsey.Validation + +namespace SharpLogRamsey.Validation +open Finset +open scoped BigOperators Classical +open SharpLogRamsey.FiniteSamplingBounds SharpLogRamsey.Incidence +noncomputable section +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] +variable [Finite K] [FiniteDimensional K V] +variable [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + +theorem projective_public_validation {n : ℕ} (hdim : Module.finrank K V=n+3) + (X W : Finset (Projectivization K V)) (hX : X.Nonempty) (hW : W.Nonempty) + (hsub : X⊆W) (U T : Finset (Projectivization K (Module.Dual K V))) + (hT : T.Nonempty) (h : ℕ) (hh : 0 SharpLogRamsey.Incidence.Incident x y),uniformMass X x) + ≤ (T.card:ℝ)/(10000*(Nat.card K:ℝ))) (m : ℕ) + (hsearch : (Nat.card K:ℝ)≤(m:ℝ)*(((X.card:ℝ)/(W.card:ℝ))^h*(9/10))) : + 1-PublicTables.integral (rowLaw W hW h) + (implementAccept X (GoodCap SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) U T M)) (fun _ => 1) m + ≤ Real.exp (-(Nat.card K:ℝ)) ∧ + ∀ y, PublicTables.integral (rowLaw W hW h) + (implementAccept X (GoodCap SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) U T M)) + (fun z => if ¬pass SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) z y then 1 else 0) m + ≤ 6*(Nat.card K:ℝ)*(∑ x∈univ.filter (fun x => SharpLogRamsey.Incidence.Incident x y),uniformMass X x) := by + have hg : (9/10:ℝ)≤prob (uniformMass X) h (GoodCap SharpLogRamsey.Incidence.Incident (Nat.card K:ℝ) U T M) := + projective_ideal_acceptance hdim X hX U T hT h hh M hM hsize hsparse + have hq : 0<(Nat.card K:ℝ) := by exact_mod_cast Nat.card_pos (α:=K) + constructor + · apply (PublicTables.failure_exp (rowLaw W hW h) _ m).trans + apply Real.exp_le_exp.mpr + rw [proposal_acceptance X W hX hW hsub] + have hmul := mul_le_mul_of_nonneg_left hg + (show 0≤(m:ℝ)*((X.card:ℝ)/(W.card:ℝ))^h by positivity) + nlinarith + · intro y + exact produced_exclusion X W hX hW hsub h hh _ hg SharpLogRamsey.Incidence.Incident _ hq y m + +end +end SharpLogRamsey.Validation + +namespace SharpLogRamsey.Validation +open Finset +open scoped BigOperators Classical +open SharpLogRamsey.FiniteSamplingBounds +noncomputable section +variable {Ω Y I : Type*} [Fintype Ω] [Fintype I] + +theorem ready_exclusion (p : PublicTables.Law I) (Ready : I → Prop) + (X : Finset Ω) (hX : X.Nonempty) (X₀ W : I → Finset Ω) + (hX₀ : ∀ i,(X₀ i).Nonempty) (hW : ∀ i,(W i).Nonempty) + (hsub : ∀ i,Ready i → X₀ i⊆X) (hWsub : ∀ i,Ready i → X₀ i⊆W i) + (c : ℝ) (hc : 0 if ¬pass R q z y then 1 else 0) (m i) else 0) ≤ + (6/c)*q*(∑ x∈univ.filter (fun x => R x y),uniformMass X x) := by + let B := (6/c)*q*(∑ x∈univ.filter (fun x => R x y),uniformMass X x) + have hb : 0≤B := by + dsimp [B] + apply mul_nonneg (by positivity) + exact sum_nonneg (fun x _ => uniform_nonneg X x) + calc + _ ≤ ∑ i,p.mass i*B := by + apply sum_le_sum + intro i _ + split_ifs with hr + · exact mul_le_mul_of_nonneg_left + (original_exclusion (X₀ i) X (W i) (hX₀ i) hX (hW i) (hsub i hr) + (hWsub i hr) c hc (hcap i hr) (h i) (hh i hr) (Good i) (hGood i hr) + R q hq y (m i)) (p.nonneg i) + · exact mul_nonneg (p.nonneg i) hb + _ = _ := by rw [←sum_mul,p.total,one_mul] + +end +end SharpLogRamsey.Validation + +open scoped BigOperators +open Finset +open scoped Classical + +namespace SharpLogRamsey.PublicTables +open Finset +open scoped BigOperators Classical +noncomputable section +variable {Ω Y : Type*} [Fintype Ω] [Fintype Y] + +lemma integral_weighted_sum (p : Law Ω) (A : Ω → Prop) (f : Ω → Y → ℝ) + (w : Y → ℝ) (m : ℕ) : + integral p A (fun z => ∑ y,w y*f z y) m = + ∑ y,w y*integral p A (fun z => f z y) m := by + simp only [integral_formula,accepted,mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro z _ + by_cases hz : A z + · simp only [hz,ite_true,mul_sum] + apply sum_congr rfl + intro y _ + ring + · simp [hz] + +end +end SharpLogRamsey.PublicTables + +namespace SharpLogRamsey.Validation +open Finset +open scoped BigOperators Classical +open SharpLogRamsey.FiniteSamplingBounds SharpLogRamsey.SupportMixtures +noncomputable section +variable {Ω Y I : Type*} [Fintype Ω] [Fintype Y] [Fintype I] + +omit [Fintype Ω] in +lemma kernel_uniform (X : Finset Ω) (x : Ω) : kernel X x=uniformMass X x := by + simp [kernel,uniformMass,one_div] + +def missFraction (R : Ω → Y → Prop) (q : ℝ) (T : Finset Y) + {h : ℕ} (z : Fin h → Ω) : ℝ := + ((T.filter (fun y => ¬pass R q z y)).card:ℝ)/(T.card:ℝ) + +lemma missFraction_eq (R : Ω → Y → Prop) (q : ℝ) (T : Finset Y) + {h : ℕ} (z : Fin h → Ω) : + missFraction R q T z=∑ y,kernel T y*(if ¬pass R q z y then 1 else 0) := by + have he (y : Y) : kernel T y*(if ¬pass R q z y then 1 else 0) = + if y∈T.filter (fun y => ¬pass R q z y) then 1/(T.card:ℝ) else 0 := by + by_cases hy : y∈T <;> by_cases hp : pass R q z y <;> simp [kernel,hy,hp] + simp only [he,←sum_filter] + have hf : univ.filter (fun y => y∈T.filter (fun y => ¬pass R q z y)) = + T.filter (fun y => ¬pass R q z y) := by ext; simp + rw [hf,sum_const,nsmul_eq_mul] + unfold missFraction + ring + +lemma incidence_kernel_sum (X : Finset Ω) (T : Finset Y) (R : Ω → Y → Prop) : + (∑ y,kernel T y*(∑ x∈univ.filter (fun x => R x y),uniformMass X x))= + pairing (kernel X) (kernel T) (fun x y => if R x y then 1 else 0) := by + simp only [pairing,sum_filter,mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro x _ + apply sum_congr rfl + intro y _ + by_cases hr : R x y <;> simp [hr,kernel_uniform,mul_comm] + +theorem ready_fraction (p : PublicTables.Law I) (Ready : I → Prop) + (X : Finset Ω) (hX : X.Nonempty) (X₀ W : I → Finset Ω) + (hX₀ : ∀ i,(X₀ i).Nonempty) (hW : ∀ i,(W i).Nonempty) + (hsub : ∀ i,Ready i → X₀ i⊆X) (hWsub : ∀ i,Ready i → X₀ i⊆W i) + (c : ℝ) (hc : 0 if R x y then 1 else 0) := by + have he : (∑ i, if Ready i then p.mass i * + PublicTables.integral (rowLaw (W i) (hW i) (h i)) (implementAccept (X₀ i) (Good i)) + (missFraction R q T) (m i) else 0) = + ∑ y,kernel T y*(∑ i, if Ready i then p.mass i * + PublicTables.integral (rowLaw (W i) (hW i) (h i)) (implementAccept (X₀ i) (Good i)) + (fun z => if ¬pass R q z y then 1 else 0) (m i) else 0) := by + simp only [mul_sum] + rw [sum_comm] + apply sum_congr rfl + intro i _ + by_cases hi : Ready i + · simp only [hi,ite_true] + rw [show missFraction R q T = (fun z : Fin (h i) → Ω => + ∑ y,kernel T y*(if ¬pass R q z y then 1 else 0)) from + funext (missFraction_eq R q T)] + rw [PublicTables.integral_weighted_sum,mul_sum] + apply sum_congr rfl + intro y _ + ring + · simp [hi] + rw [he] + calc + _ ≤ ∑ y,kernel T y*((6/c)*q*(∑ x∈univ.filter (fun x => R x y),uniformMass X x)) := by + apply sum_le_sum + intro y _ + exact mul_le_mul_of_nonneg_left + (ready_exclusion p Ready X hX X₀ W hX₀ hW hsub hWsub c hc hcap h m hh Good hGood + R q hq y) (kernel_nonneg _ _) + _ = _ := by + rw [←incidence_kernel_sum] + simp only [mul_sum] + apply sum_congr rfl + intro y _ + ring_nf + +theorem independent_loss {J : Type*} [Fintype J] + (w : I → ℝ) (v : J → ℝ) (S : I → Finset Ω) (T : J → Finset Y) + (R : Ω → Y → Prop) (μ : Ω → ℝ) (ν : Y → ℝ) (a b C : ℝ) + (hw : ∀ i,0≤ w i) (hv : ∀ j,0≤ v j) (hC : 0≤ C) + (hS : ∀ x,mixture w S x≤ a*μ x) (hT : ∀ y,mixture v T y≤ b*ν y) + (loss : I → J → ℝ) + (hloss : ∀ i j,loss i j≤ C*pairing (kernel (S i)) (kernel (T j)) + (fun x y => if R x y then 1 else 0)) : + (∑ i,∑ j,w i*v j*loss i j)≤ C*a*b*pairing μ ν (fun x y => if R x y then 1 else 0) := by + calc + _ ≤ ∑ i,∑ j,w i*v j*(C*pairing (kernel (S i)) (kernel (T j)) + (fun x y => if R x y then 1 else 0)) := by + apply sum_le_sum + intro i _ + apply sum_le_sum + intro j _ + exact mul_le_mul_of_nonneg_left (hloss i j) (mul_nonneg (hw i) (hv j)) + _ = C*(∑ i,∑ j,w i*v j*pairing (kernel (S i)) (kernel (T j)) + (fun x y => if R x y then 1 else 0)) := by + simp only [mul_sum] + apply sum_congr rfl + intro i _ + apply sum_congr rfl + intro j _ + ring + _ ≤ C*(a*b*pairing μ ν (fun x y => if R x y then 1 else 0)) := by + apply mul_le_mul_of_nonneg_left _ hC + exact independent_pairing_le w v S T _ μ ν a b hw hv (by intros; split_ifs <;> norm_num) hS hT + _ = _ := by ring + +end +end SharpLogRamsey.Validation + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Validation/ValidationCosts.lean b/lean/OAI/Combinatorics/SharpRamsey/Validation/ValidationCosts.lean new file mode 100644 index 0000000000000000000000000000000000000000..0cc0e4d70994f6a840ee81864c895812fab8c958 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Validation/ValidationCosts.lean @@ -0,0 +1,102 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Validation.ValidationSchedule + +namespace OAI + +section +namespace SharpLogRamsey.Validation +open Finset Real +open scoped Classical BigOperators +noncomputable section + +lemma geom_card_le {q : ℕ} (hq : 2 ≤ q) (r : ℕ) : + ∑ i ∈ range r,q^i ≤ q^r := by + induction r with + | zero => simp + | succ r ih => + rw [sum_range_succ,pow_succ] + calc + _ ≤ q^r+q^r := Nat.add_le_add_right ih _ + _ = q^r*2 := (Nat.mul_two _).symm + _ ≤ _ := Nat.mul_le_mul_left _ hq + +lemma projective_log_card {K V : Type} [Field K] [Finite K] [AddCommGroup V] + [Module K V] [FiniteDimensional K V] [Fintype (Projectivization K V)] + (r : ℕ) (hdim : Module.finrank K V=r) : + log ((Fintype.card (Projectivization K V):ℝ)+1) ≤ ((r:ℝ)+1)*Nat.card K := by + have hqN : 2 ≤ Nat.card K := Finite.one_lt_card + have hq : (1:ℝ) ≤ Nat.card K := by exact_mod_cast hqN.trans' (by norm_num : 1 ≤ 2) + have hq0 : (0:ℝ) < Nat.card K := by linarith + have hcard : (Fintype.card (Projectivization K V):ℝ) ≤ (Nat.card K:ℝ)^r := by + have hn : Fintype.card (Projectivization K V) ≤ Nat.card K^r := by + rw [←Nat.card_eq_fintype_card,Projectivization.card_of_finrank K V hdim] + exact geom_card_le hqN r + exact_mod_cast hn + have hpow : 1 ≤ (Nat.card K:ℝ)^r := one_le_pow₀ hq + have hs : (Fintype.card (Projectivization K V):ℝ)+1 ≤ 2*(Nat.card K:ℝ)^r := by linarith + apply (log_le_log (by positivity) hs).trans + rw [log_mul (by norm_num) (pow_ne_zero _ hq0.ne'),log_pow] + have hl2 : log (2:ℝ) ≤ 1 := by have := log_le_sub_one_of_pos (by norm_num : (0:ℝ)<2); linarith + have hlq : log (Nat.card K:ℝ) ≤ Nat.card K := + (log_le_sub_one_of_pos hq0).trans (by linarith) + have hh := mul_le_mul_of_nonneg_left hlq (show 0 ≤ (r:ℝ) by positivity) + linarith + +lemma pair_log_card {K V : Type} [Field K] [Finite K] [AddCommGroup V] + [Module K V] [FiniteDimensional K V] [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K V))] + (r : ℕ) (hdim : Module.finrank K V=r) : + log (((Fintype.card (Projectivization K V):ℝ)+ + Fintype.card (Projectivization K (Module.Dual K V)))*log 2+1) ≤ + (2*(r:ℝ)+2)*Nat.card K := by + have hA := projective_log_card r hdim + have hB := projective_log_card (K:=K) (V:=Module.Dual K V) r + (Subspace.dual_finrank_eq.trans hdim) + let A : ℝ := Fintype.card (Projectivization K V) + let B : ℝ := Fintype.card (Projectivization K (Module.Dual K V)) + have ha : 0 ≤ A := by positivity + have hb : 0 ≤ B := by positivity + have hl2 : 0 ≤ log (2:ℝ) := log_nonneg (by norm_num) + have hu2 : log (2:ℝ) ≤ 1 := by have := log_le_sub_one_of_pos (by norm_num : (0:ℝ)<2); linarith + have hh : (A+B)*log 2+1 ≤ (A+1)*(B+1) := by nlinarith [mul_nonneg ha hb] + have hl := log_le_log (by positivity : 0 < (A+B)*log 2+1) hh + rw [log_mul (by positivity) (by positivity)] at hl + change log ((A+B)*log 2+1) ≤ _ + change log (A+1) ≤ _ at hA + change log (B+1) ≤ _ at hB + linarith + +lemma row_cost {q P d B H C J : ℝ} {h : ℕ} + (hq : 1 ≤ q) (hP : 1 ≤ P) (hd : 0 ≤ d) (hB : 0 ≤ B) + (hC : 0 ≤ C) (hJ : 0 ≤ J) (hBP : B ≤ C*P) + (hh : (h:ℝ) ≤ 20*q*(d+2)+1) (hH : log (H+1) ≤ J*q) : + 2*((h:ℝ)*B+log 2+log (H+1))+log 3 ≤ + (100*C+2*J+10)*q*P*(d+P) := by + have hu2 : log (2:ℝ) ≤ 1 := by have := log_le_sub_one_of_pos (by norm_num : (0:ℝ)<2); linarith + have hu3 : log (3:ℝ) ≤ 2 := by have := log_le_sub_one_of_pos (by norm_num : (0:ℝ)<3); linarith + have hh' : (h:ℝ) ≤ 21*q*(d+2) := by nlinarith + have hmul := mul_le_mul hh' hBP hB (show 0 ≤ 21*q*(d+2) by positivity) + have hdP : d+2 ≤ 2*(d+P) := by linarith + have hmul' := mul_le_mul_of_nonneg_left hdP (show 0 ≤ 21*C*q*P by positivity) + let v := q*P*(d+P) + have hvq : q ≤ v := by + have hp : 1 ≤ P*(d+P) := one_le_mul_of_one_le_of_one_le hP (by linarith) + have hh := mul_le_mul_of_nonneg_left hp (show 0 ≤ q by linarith) + dsimp only [v]; nlinarith only [hh] + have hv : 1 ≤ v := hq.trans hvq + have hj := mul_le_mul_of_nonneg_left hvq hJ + have hp : 0 ≤ C*v := by positivity + dsimp only [v] at * + nlinarith + +lemma scheduleLength_le {q u t : ℝ} (hq : 0 ≤ q) (ht : 0 < t) (htu : t ≤ u) : + (scheduleLength q u t:ℝ) ≤ 20*q*(log (u/t)+2)+1 := by + have hl : 0 ≤ log (u/t) := log_nonneg ((le_div_iff₀ ht).mpr (by simpa using htu)) + exact (Nat.ceil_lt_add_one (by positivity)).le + +end +end SharpLogRamsey.Validation + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Validation/ValidationExtend.lean b/lean/OAI/Combinatorics/SharpRamsey/Validation/ValidationExtend.lean new file mode 100644 index 0000000000000000000000000000000000000000..57fdad2697210fa2bcaf80df2727e92ff910f89a --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Validation/ValidationExtend.lean @@ -0,0 +1,124 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Learning.ValidationCover + +namespace OAI + +section +namespace SharpLogRamsey.Validation +open Finset Real Incidence +open scoped Classical BigOperators +noncomputable section +variable {K V : Type*} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] +variable [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + +omit [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] in +lemma incidenceCount_mono_left {S S' : Finset (Projectivization K V)} + (h : S'⊆S) (T : Finset (Projectivization K (Module.Dual K V))) : + incidenceCount S' T≤ incidenceCount S T := by + unfold incidenceCount + exact sum_le_sum (fun _ _ => card_le_card (filter_subset_filter _ h)) + +theorem extend_cover {n : ℕ} (hdim : Module.finrank K V=n+3) + (descriptions : Finset (Finset (Projectivization K V))) + (U : Finset (Projectivization K (Module.Dual K V))) (N t : ℕ) + (hN : 0 hf W) + _ = _ := by simp + have hbound : (caps.card:ℝ)+1≤((descriptions.card:ℝ)+1)*exp E := by nlinarith + have hl := log_le_log (by positivity : (0:ℝ) hf W) + _ = _ := by simp + have hbound : (caps.card:ℝ)+1≤((descriptions.card:ℝ)+1)*exp E := by nlinarith + have hl := log_le_log (by positivity : (0:ℝ) W.image e.symm),?_,?_,?_⟩ + · intro W hW + obtain ⟨F,hF,rfl⟩ := mem_image.mp hW + obtain ⟨hFU,hcard,_⟩ := pullback_cover e U ∅ F (hAs F hF).1 + refine ⟨hFU,?_⟩ + rw [hcard] + simpa only [show (1000:ℝ)*2=2000 by norm_num] using (hAs F hF).2 + · intro S T hSU hSN hTt hsp hcap + have hinc : incidenceCount T (S.image e)=incidenceCount S T := incidenceCount_bidual S T + have hcS : (S.image e).card=N := (card_image_of_injective _ e.injective).trans hSN + have hsp' : (incidenceCount T (S.image e):ℝ)≤(t:ℝ)*N/(10000*2*Nat.card K) := by + rw [hinc] + convert hsp using 1 ; ring + obtain ⟨F,hF,hcapture⟩ := hAc T (S.image e) hTt (image_subset_image hSU) hcS hsp' hcap + refine ⟨F.image e.symm,mem_image.mpr ⟨F,hF,rfl⟩,?_⟩ + rw [(pullback_cover e U S F (hAs F hF).1).2.2] + exact hcapture + · have hc : ((A.image (fun W => W.image e.symm)).card:ℝ)≤A.card := by + exact_mod_cast card_image_le (s:=A) (f:=fun W => W.image e.symm) + have hl : log (((A.image (fun W => W.image e.symm)).card:ℝ)+1)≤log ((A.card:ℝ)+1) := + log_le_log (by positivity) (by linarith) + exact hl.trans (by simpa only [hcU] using hAl) + +lemma reverse_size (q N t C b : ℝ) (r : ℕ) (_hq : 0 W.image e.symm),?_,?_,?_⟩ + · intro W hW + obtain ⟨F,hF,rfl⟩ := mem_image.mp hW + obtain ⟨hFU,hcard,_⟩ := pullback_cover e U ∅ F (hAs F hF).1 + refine ⟨hFU,?_⟩ + rw [hcard] + exact (hAs F hF).2 + · intro S T hSU hSN hTt hsp hcap + have hinc : incidenceCount T (S.image e)=incidenceCount S T := incidenceCount_bidual S T + have hcS : (S.image e).card=N := (card_image_of_injective _ e.injective).trans hSN + have hsp' : (incidenceCount T (S.image e):ℝ)≤(t:ℝ)*N/(10000*c*Nat.card K) := by + rw [hinc] + convert hsp using 1 ; ring + obtain ⟨F,hF,hcapture⟩ := hAc T (S.image e) hTt (image_subset_image hSU) hcS hsp' hcap + refine ⟨F.image e.symm,mem_image.mpr ⟨F,hF,rfl⟩,?_⟩ + rw [(pullback_cover e U S F (hAs F hF).1).2.2] + exact hcapture + · have hc : ((A.image (fun W => W.image e.symm)).card:ℝ)≤A.card := by + exact_mod_cast card_image_le (s:=A) (f:=fun W => W.image e.symm) + have hl : log (((A.image (fun W => W.image e.symm)).card:ℝ)+1)≤log ((A.card:ℝ)+1) := + log_le_log (by positivity) (by linarith) + exact hl.trans (by simpa only [hcU] using hAl) + +end +end SharpLogRamsey.Validation + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Validation/ValidationSchedule.lean b/lean/OAI/Combinatorics/SharpRamsey/Validation/ValidationSchedule.lean new file mode 100644 index 0000000000000000000000000000000000000000..64f27c3fb019d963743cce0f4c76087d805addcf --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Validation/ValidationSchedule.lean @@ -0,0 +1,160 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Selection.SparseProductSharp +import OAI.Combinatorics.SharpRamsey.Validation.ProducedExclusion + +namespace OAI + +section +namespace SharpLogRamsey.Validation +open Finset Real Incidence +open scoped Classical BigOperators +noncomputable section + +def scheduleLength (q u t : ℝ) : ℕ := ⌈20*q*(log (u/t)+2)⌉₊ + +def scheduleCutoff (q a : ℝ) (h : ℕ) : ℕ := ⌈2*q*exp ((h:ℝ)*a)⌉₊ + +lemma scheduleLength_pos {q u t : ℝ} (hq : 0 ring + +lemma scheduleCutoff_search {q x w a : ℝ} (hq : 0 SharpLogRamsey.Incidence.Incident x y),uniformMass S x)= + (incidenceCount S T:ℝ)/S.card := by + simp_rw [uniform_sum] + rw [←sum_div] + congr 1 + unfold incidenceCount + push_cast + apply sum_congr rfl + intro y _ + congr 1 + apply congrArg Finset.card + ext x + simp only [mem_inter,mem_filter,mem_univ,true_and] + tauto + +theorem scheduled_validation {n : ℕ} (hdim : Module.finrank K V=n+3) + (S X W : Finset (Projectivization K V)) (hS : S.Nonempty) (hX : X.Nonempty) + (hXS : X⊆S) (hXW : X⊆W) + (T U : Finset (Projectivization K (Module.Dual K V))) (hT : T.Nonempty) (hTU : T⊆U) + (C a : ℝ) (hC : 1≤C) (hcap : (S.card:ℝ)≤C*X.card) + (hratio : (W.card:ℝ)≤exp a*X.card) + (hsparse : (incidenceCount S T:ℝ)≤(S.card:ℝ)*T.card/(10000*C*Nat.card K)) : + let q : ℝ := Nat.card K + let h := scheduleLength q U.card T.card + let m := scheduleCutoff q a h + let M := 1000*C*q^(n+3)/S.card + let accept := implementAccept X (GoodCap SharpLogRamsey.Incidence.Incident q U T M) + (9/10:ℝ)≤prob (uniformMass X) h (GoodCap SharpLogRamsey.Incidence.Incident q U T M) ∧ + 1-PublicTables.integral (rowLaw W (hX.mono hXW) h) accept (fun _ => 1) m≤exp (-q) ∧ + (∀ y,PublicTables.integral (rowLaw W (hX.mono hXW) h) accept + (fun z => if ¬pass SharpLogRamsey.Incidence.Incident q z y then 1 else 0) m≤ + 6*C*q*(∑ x∈univ.filter (fun x => SharpLogRamsey.Incidence.Incident x y),uniformMass S x)) := by + dsimp only + let q : ℝ := Nat.card K + let h := scheduleLength q U.card T.card + let m := scheduleCutoff q a h + let M := 1000*C*q^(n+3)/S.card + have hq : 0 SharpLogRamsey.Incidence.Incident x y),uniformMass X x)≤ + (T.card:ℝ)/(10000*q) := by + rw [uniform_incidence_sum] + apply (div_le_iff₀ hx).mpr + apply hinc.trans (hsparse.trans _) + apply (div_le_iff₀ (by positivity : 0<10000*C*(Nat.card K:ℝ))).mpr + have he : (T.card:ℝ)/(10000*q)*X.card*(10000*C*Nat.card K)=C*X.card*T.card := by + dsimp [q]; field_simp [show (Nat.card K:ℝ) ≠ 0 from hq.ne'] + rw [he] + nlinarith only [mul_le_mul_of_nonneg_right hcap ht.le] + have hh : 0 z i ∈ E)).card +omit [Fintype Ω] in +lemma rowWeight_nonneg (w : Ω → ℝ) (hw : ∀ x, 0 ≤ w x) {h : ℕ} (z : Fin h → Ω) : + 0 ≤ rowWeight w z := Finset.prod_nonneg (fun i _ => hw (z i)) + +lemma rowWeight_total (w : Ω → ℝ) (hw : ∑ x, w x = 1) (h : ℕ) : + ∑ z : Fin h → Ω, rowWeight w z = 1 := by + unfold rowWeight + rw [← Fintype.prod_sum] + simp [hw] + +lemma rowMoment (w : Ω → ℝ) (ht : ∑ x, w x = 1) (E : Finset Ω) (h : ℕ) (b : ℝ) : + (∑ z : Fin h → Ω, rowWeight w z*b^(hitCount E z)) = + (1+(b-1)*(∑ x ∈ E, w x))^h := by + classical + have hi (z : Fin h → Ω) : b^(hitCount E z) = ∏ i, if z i ∈ E then b else 1 := by + simp [hitCount, ← Finset.prod_filter] + simp_rw [hi, rowWeight, ← Finset.prod_mul_distrib] + rw [← Fintype.prod_sum (fun (_ : Fin h) (x : Ω) => w x*(if x ∈ E then b else 1))] + have he : (∑ x : Ω, w x*(if x ∈ E then b else 1)) = 1+(b-1)*(∑ x ∈ E, w x) := by + have hi (x : Ω) : w x*(if x ∈ E then b else 1) = w x+(b-1)*(if x ∈ E then w x else 0) := by + split_ifs <;> ring + simp_rw [hi] + rw [Finset.sum_add_distrib, ← Finset.mul_sum, ht] + simp + rw [he] + simp + +noncomputable def rowLower (w : Ω → ℝ) (E : Finset Ω) (h T : ℕ) : ℝ := + ∑ z : Fin h → Ω, if hitCount E z < T then rowWeight w z else 0 + +lemma rowLower_moment (w : Ω → ℝ) (hw : ∀ x, 0 ≤ w x) (ht : ∑ x, w x = 1) + (E : Finset Ω) (h T : ℕ) : + (1/2:ℝ)^T*rowLower w E h T ≤ (1-(∑ x ∈ E, w x)/2)^h := by + have he : 1-(∑ x ∈ E, w x)/2 = 1+((1/2:ℝ)-1)*(∑ x ∈ E, w x) := by ring + rw [he, ← rowMoment w ht E h (1/2), rowLower, mul_sum] + apply sum_le_sum + intro z _ + split_ifs with hz + · rw [mul_comm ((1/2:ℝ)^T)] + exact mul_le_mul_of_nonneg_left + (pow_le_pow_of_le_one (by norm_num : (0:ℝ) ≤ 1/2) (by norm_num) hz.le) + (rowWeight_nonneg w hw z) + · simp only [mul_zero] + exact mul_nonneg (rowWeight_nonneg w hw z) (by positivity) + +theorem rowLower_exp (w : Ω → ℝ) (hw : ∀ x, 0 ≤ w x) (ht : ∑ x, w x = 1) + (E : Finset Ω) (h T : ℕ) : + rowLower w E h T ≤ Real.exp ((T:ℝ)-(h:ℝ)*(∑ x ∈ E, w x)/2) := by + have hs : (∑ x ∈ E, w x) ≤ 1 := by + rw [← ht] + exact sum_le_sum_of_subset_of_nonneg (subset_univ E) (by intros; exact hw _) + have hpow : (1-(∑ x ∈ E, w x)/2)^h ≤ Real.exp (-(h:ℝ)*(∑ x ∈ E, w x)/2) := by + rw [show -(h:ℝ)*(∑ x ∈ E, w x)/2 = (h:ℝ)*(-(∑ x ∈ E, w x)/2) by ring, + Real.exp_nat_mul] + apply pow_le_pow_left₀ (by linarith) + simpa only [neg_div] using Real.one_sub_le_exp_neg ((∑ x ∈ E, w x)/2) + have hmult := mul_le_mul_of_nonneg_left ((rowLower_moment w hw ht E h T).trans hpow) + (show (0:ℝ) ≤ 2^T by positivity) + have hcancel : (2:ℝ)^T*((1/2:ℝ)^T*rowLower w E h T) = rowLower w E h T := by + rw [← mul_assoc, ← mul_pow] + norm_num + rw [hcancel] at hmult + have htwo : (2:ℝ)^T ≤ Real.exp (T:ℝ) := by + have hh := pow_le_pow_left₀ (by norm_num : (0:ℝ) ≤ 2) + (show (2:ℝ) ≤ Real.exp 1 by simpa only [one_add_one_eq_two] using Real.add_one_le_exp 1) T + simpa [← Real.exp_nat_mul] using hh + calc + _ ≤ (2:ℝ)^T*Real.exp (-(h:ℝ)*(∑ x ∈ E, w x)/2) := hmult + _ ≤ Real.exp (T:ℝ)*Real.exp (-(h:ℝ)*(∑ x ∈ E, w x)/2) := + mul_le_mul_of_nonneg_right htwo (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +theorem rowLower_highRank (w : Ω → ℝ) (hw : ∀ x, 0 ≤ w x) (ht : ∑ x, w x = 1) + (E : Finset Ω) (h T : ℕ) (q : ℝ) (hq : 0 < q) + (hE : 2/(5*q) ≤ ∑ x ∈ E, w x) (hT : (T:ℝ) ≤ (h:ℝ)/(10*q)+1) : + rowLower w E h T ≤ Real.exp (1-(h:ℝ)/(10*q)) := by + apply (rowLower_exp w hw ht E h T).trans + apply Real.exp_le_exp.mpr + have hh := mul_le_mul_of_nonneg_left hE (show 0 ≤ (h:ℝ)/2 by positivity) + have he : ((h:ℝ)/2)*(2/(5*q)) = 2*((h:ℝ)/(10*q)) := by field_simp; ring + rw [he] at hh + nlinarith + +end +end SharpLogRamsey.FiniteSamplingBounds + +namespace SharpLogRamsey.Validation +open Finset +open scoped BigOperators Classical +open SharpLogRamsey.FiniteSamplingBounds +noncomputable section +variable {Ω Y : Type*} [Fintype Ω] [Fintype Y] + +def uniformMass (X : Finset Ω) (x : Ω) : ℝ := if x ∈ X then (X.card : ℝ)⁻¹ else 0 + +omit [Fintype Ω] in +lemma uniform_nonneg (X : Finset Ω) (x : Ω) : 0 ≤ uniformMass X x := by + unfold uniformMass + split_ifs <;> positivity + +lemma uniform_total {X : Finset Ω} (hX : X.Nonempty) : ∑ x, uniformMass X x = 1 := by + have hx : (X.card:ℝ) ≠ 0 := by exact_mod_cast (card_pos.mpr hX).ne' + simp [uniformMass,hx] + +omit [Fintype Ω] in +lemma uniform_sum (X E : Finset Ω) : + (∑ x ∈ E, uniformMass X x) = ((E ∩ X).card : ℝ)/(X.card:ℝ) := by + simp [uniformMass, div_eq_mul_inv, ← filter_mem_eq_inter] + +lemma coordinate_mean (w : Ω → ℝ) (ht : ∑ x, w x=1) + {h : ℕ} (i : Fin h) (f : Ω → ℝ) : + (∑ z : Fin h → Ω, rowWeight w z*f (z i)) = ∑ x, w x*f x := by + have hi (z : Fin h → Ω) : rowWeight w z*f (z i) = + ∏ j, w (z j)*(if j=i then f (z j) else 1) := by + rw [prod_mul_distrib] + simp [rowWeight] + simp_rw [hi] + rw [← Fintype.prod_sum (fun j x => w x*(if j=i then f x else 1))] + have he (j : Fin h) : (∑ x, w x*(if j=i then f x else 1)) = + if j=i then ∑ x, w x*f x else 1 := by + split_ifs <;> simp_all + simp_rw [he] + simp + +omit [Fintype Ω] in +lemma hitCount_real {h : ℕ} (E : Finset Ω) (z : Fin h → Ω) : + (hitCount E z:ℝ) = ∑ i, if z i ∈ E then (1:ℝ) else 0 := by + simp [hitCount, ← sum_boole] + +lemma hitCount_mean (w : Ω → ℝ) (ht : ∑ x, w x=1) (E : Finset Ω) (h : ℕ) : + (∑ z : Fin h → Ω, rowWeight w z*(hitCount E z:ℝ)) = (h:ℝ)*(∑ x ∈ E, w x) := by + simp_rw [hitCount_real, mul_sum] + rw [sum_comm] + have hi (i : Fin h) : (∑ z : Fin h → Ω, + if z i∈E then rowWeight w z else 0) = ∑ x∈E,w x := by + simpa only [mul_ite, mul_one, mul_zero, ← sum_filter, filter_mem_eq_inter, + univ_inter] using coordinate_mean w ht i (fun x => if x∈E then (1:ℝ) else 0) + simp only [mul_ite, mul_one, mul_zero] + simp_rw [hi] + simp [mul_sum] + +def pass (R : Ω → Y → Prop) (q : ℝ) {h : ℕ} (z : Fin h → Ω) (y : Y) : Prop := + (hitCount (univ.filter (fun x => R x y)) z:ℝ) < (h:ℝ)/(5*q) + +def cap (R : Ω → Y → Prop) (q : ℝ) (U : Finset Y) {h : ℕ} (z : Fin h → Ω) : Finset Y := + U.filter (pass R q z) + +omit [Fintype Y] in + +theorem pointwise_exclusion (w : Ω → ℝ) (hw : ∀ x, 0≤w x) (ht : ∑ x, w x=1) + (R : Ω → Y → Prop) (q : ℝ) (hq : 0 R x y), w x) := by + let E := univ.filter (fun x => R x y) + have hm : (h:ℝ)/(5*q)*(∑ z : Fin h → Ω, + if ¬pass R q z y then rowWeight w z else 0) ≤ (h:ℝ)*(∑ x ∈ E, w x) := by + rw [←hitCount_mean w ht E h, mul_sum] + apply sum_le_sum + intro z _ + by_cases hz : pass R q z y + · simp only [hz, not_true_eq_false, ite_false, mul_zero] + exact mul_nonneg (rowWeight_nonneg w hw z) (Nat.cast_nonneg _) + · simp only [hz, not_false_eq_true, ite_true] + have hz' : (h:ℝ)/(5*q) ≤ (hitCount E z:ℝ) := le_of_not_gt hz + nlinarith [mul_le_mul_of_nonneg_right hz' (rowWeight_nonneg w hw z)] + have hc : 0<(h:ℝ) := by exact_mod_cast hh + apply (mul_le_mul_iff_right₀ hc).mp + have hm' := mul_le_mul_of_nonneg_right hm (show 0≤5*q by positivity) + dsimp [E] at hm' + convert hm' using 1 <;> field_simp + +omit [Fintype Y] in + +theorem pointwise_pass (w : Ω → ℝ) (hw : ∀ x, 0≤w x) (ht : ∑ x, w x=1) + (R : Ω → Y → Prop) (q : ℝ) (hq : 0 R x y), w x) : + (∑ z : Fin h → Ω, if pass R q z y then rowWeight w z else 0) ≤ + Real.exp (1-(h:ℝ)/(20*q)) := by + let E := univ.filter (fun x => R x y) + let T := ⌈(h:ℝ)/(5*q)⌉₊ + have ht' : (T:ℝ) ≤ (h:ℝ)/(5*q)+1 := (Nat.ceil_lt_add_one (by positivity)).le + have hpt : (∑ z : Fin h → Ω, if pass R q z y then rowWeight w z else 0) ≤ + rowLower w E h T := by + apply sum_le_sum + intro z _ + by_cases hz : pass R q z y + · have hc : hitCount E z < T := by + apply Nat.lt_ceil.mpr + exact hz + simp only [hz, ite_true, hc, le_refl] + · simp only [hz, ite_false] + split_ifs <;> simp [rowWeight_nonneg w hw z] + apply hpt.trans ((rowLower_exp w hw ht E h T).trans ?_) + apply Real.exp_le_exp.mpr + have hm := mul_le_mul_of_nonneg_left hy (show 0≤(h:ℝ)/2 by positivity) + have he : (h:ℝ)/2*(1/(2*q)) = (h:ℝ)/(4*q) := by ring + rw [he] at hm + have hm' : (h:ℝ)/(4*q) ≤ ((h:ℝ)*(∑ x∈E,w x))/2 := by + exact hm.trans_eq (by dsimp [E]; ring) + calc + _ ≤ (h:ℝ)/(5*q)+1-(h:ℝ)/(4*q) := sub_le_sub ht' hm' + _ = _ := by ring + +end +end SharpLogRamsey.Validation + +namespace SharpLogRamsey.Validation +open Finset +open scoped BigOperators Classical +open SharpLogRamsey.FiniteSamplingBounds +noncomputable section +variable {Ω Y : Type*} [Fintype Ω] [Fintype Y] + +def prob (w : Ω → ℝ) (h : ℕ) (P : (Fin h → Ω) → Prop) : ℝ := + ∑ z : Fin h → Ω, if P z then rowWeight w z else 0 + +lemma prob_nonneg (w : Ω → ℝ) (hw : ∀ x, 0≤w x) {h : ℕ} + (P : (Fin h → Ω) → Prop) : 0 ≤ prob w h P := by + apply sum_nonneg + intro z _ + split_ifs <;> simp [rowWeight_nonneg w hw z] + +lemma prob_le_one (w : Ω → ℝ) (hw : ∀ x, 0≤w x) (ht : ∑ x,w x=1) {h : ℕ} + (P : (Fin h → Ω) → Prop) : prob w h P ≤ 1 := by + rw [←rowWeight_total w ht h] + apply sum_le_sum + intro z _ + split_ifs <;> simp [rowWeight_nonneg w hw z] + +omit [Fintype Y] in +lemma cardinal_mean (w : Ω → ℝ) {h : ℕ} (U : Finset Y) + (P : (Fin h → Ω) → Y → Prop) : + (∑ z : Fin h → Ω, rowWeight w z*((U.filter (P z)).card:ℝ)) = + ∑ y∈U, prob w h (fun z => P z y) := by + have he (z : Fin h → Ω) : ((U.filter (P z)).card:ℝ) = + ∑ y∈U, if P z y then (1:ℝ) else 0 := by simp + simp_rw [he,mul_sum,mul_ite,mul_one,mul_zero] + rw [sum_comm] + rfl + +lemma markov (w : Ω → ℝ) (hw : ∀ x,0≤w x) {h : ℕ} + (f : (Fin h → Ω) → ℝ) (hf : ∀ z,0≤f z) (M : ℝ) (hM : 0 M (∑ x∈univ.filter (fun x => R x y),w x)<1/(2*q))).card:ℝ) + +(U.card:ℝ)*Real.exp (1-(h:ℝ)/(20*q)) := by + simp only [cap] + rw [cardinal_mean w U (fun z y => pass R q z y)] + let B := U.filter (fun y => (∑ x∈univ.filter (fun x => R x y),w x)<1/(2*q)) + calc + _ ≤ ∑ y∈U, ((if y∈B then (1:ℝ) else 0)+Real.exp (1-(h:ℝ)/(20*q))) := by + apply sum_le_sum + intro y hy + by_cases hb : y∈B + · simp only [hb,ite_true] + exact (prob_le_one w hw ht _).trans (by linarith [Real.exp_pos (1-(h:ℝ)/(20*q))]) + · simp only [hb,ite_false,zero_add] + apply pointwise_pass w hw ht R q hq h y + exact le_of_not_gt (fun hh => hb (mem_filter.mpr ⟨hy,hh⟩)) + _ = _ := by + rw [sum_add_distrib] + simp only [sum_boole, sum_const, nsmul_eq_mul] + congr 2 + have he : U.filter (fun y => y∈B) = B := filter_mem_eq_inter.trans (inter_eq_right.mpr (filter_subset _ _)) + rw [he] + +omit [Fintype Y] in + +theorem loss_mean_le (w : Ω → ℝ) (hw : ∀ x,0≤w x) (ht : ∑ x,w x=1) + (R : Ω → Y → Prop) (q : ℝ) (hq : 0 ¬pass R q z y)).card:ℝ)) ≤ + 5*q*(∑ y∈T,∑ x∈univ.filter (fun x => R x y),w x) := by + calc + _ = ∑ y∈T,prob w h (fun z => ¬pass R q z y) := by + have he (z : Fin h → Ω) : ((T.filter (fun y => ¬pass R q z y)).card:ℝ) = + ∑ y∈T, if ¬pass R q z y then (1:ℝ) else 0 := by simp only [sum_boole] + simp_rw [he,mul_sum,mul_ite,mul_one,mul_zero] + rw [sum_comm] + apply sum_congr rfl + intro y _ + unfold prob + apply sum_congr rfl + intro z _ + split_ifs <;> simp_all + _ ≤ _ := by + rw [mul_sum] + apply sum_le_sum + intro y _ + have he := pointwise_exclusion w hw ht R q hq h hh y + apply le_trans (le_of_eq ?_) he + unfold prob + apply sum_congr rfl + intro z _ + split_ifs <;> simp_all + +omit [Fintype Y] in + +theorem acceptance_mass (w : Ω → ℝ) (hw : ∀ x,0≤w x) (ht : ∑ x,w x=1) + (R : Ω → Y → Prop) (q : ℝ) (h : ℕ) (U T : Finset Y) + (M : ℝ) (hM : 0 ¬pass R q z y)).card:ℝ)) ≤ (T.card:ℝ)/2000) : + (9/10:ℝ) ≤ prob w h (fun z => ((cap R q U z).card:ℝ)≤M ∧ + ((T.filter (fun y => ¬pass R q z y)).card:ℝ)≤(T.card:ℝ)/100) := by + let sz (z : Fin h → Ω) : ℝ := (cap R q U z).card + let ls (z : Fin h → Ω) : ℝ := (T.filter (fun y => ¬pass R q z y)).card + let A (z : Fin h → Ω) : Prop := sz z≤M ∧ ls z≤(T.card:ℝ)/100 + have htpos : 0<(T.card:ℝ) := by exact_mod_cast card_pos.mpr hT + have hbS : prob w h (fun z => M Nat.cast_nonneg _) M hM).trans + exact (div_le_iff₀ hM).mpr (by simpa [sz,div_eq_mul_inv,mul_comm] using hs) + have hbL : prob w h (fun z => (T.card:ℝ)/100 Nat.cast_nonneg _) _ (by positivity)).trans + apply (div_le_iff₀ (show 0<(T.card:ℝ)/100 by positivity)).mpr + exact hl.trans_eq (by ring) + have hc : 1≤prob w h A+prob w h (fun z => M (T.card:ℝ)/100 by_cases hl' : ls z≤(T.card:ℝ)/100 <;> + simp_all [A] + all_goals positivity + change (9/10:ℝ) ≤ prob w h A + linarith + +end +end SharpLogRamsey.Validation + +namespace SharpLogRamsey.Validation +open Finset +open scoped BigOperators Classical +open SharpLogRamsey.FiniteSamplingBounds +noncomputable section +variable {Ω Y : Type*} [Fintype Ω] + +def rowLaw (X : Finset Ω) (hX : X.Nonempty) (h : ℕ) : PublicTables.Law (Fin h → Ω) where + mass := rowWeight (uniformMass X) + nonneg := rowWeight_nonneg (uniformMass X) (uniform_nonneg X) + total := rowWeight_total (uniformMass X) (uniform_total hX) h + +def allIn (X : Finset Ω) {h : ℕ} (z : Fin h → Ω) : Prop := ∀ i,z i∈X + +omit [Fintype Ω] in + +theorem contained_row_scaling (X W : Finset Ω) (hX : X.Nonempty) (hsub : X⊆W) + {h : ℕ} (z : Fin h → Ω) : + (if allIn X z then rowWeight (uniformMass W) z else 0) = + ((X.card:ℝ)/(W.card:ℝ))^h * rowWeight (uniformMass X) z := by + have hx : (X.card:ℝ)≠0 := by exact_mod_cast (card_pos.mpr hX).ne' + by_cases hz : allIn X z + · simp only [hz,ite_true] + have hi (i : Fin h) : uniformMass W (z i)=(W.card:ℝ)⁻¹ := by + simp [uniformMass,hsub (hz i)] + have hj (i : Fin h) : uniformMass X (z i)=(X.card:ℝ)⁻¹ := by + simp [uniformMass,hz i] + simp only [rowWeight,hi,hj,prod_const,card_univ,Fintype.card_fin] + rw [←mul_pow] + congr 1 + field_simp + · simp only [hz,ite_false] + have hn : ∃ i,z i∉X := by simpa only [allIn,not_forall] using hz + obtain ⟨i,hi⟩ := hn + have he : rowWeight (uniformMass X) z=0 := by + apply prod_eq_zero (mem_univ i) + simp [uniformMass,hi] + rw [he,mul_zero] + +def implementAccept (X : Finset Ω) {h : ℕ} + (Good : (Fin h → Ω) → Prop) (z : Fin h → Ω) : Prop := allIn X z ∧ Good z + +theorem accepted_scaling (X W : Finset Ω) (hX : X.Nonempty) (hW : W.Nonempty) + (hsub : X⊆W) (h : ℕ) (Good : (Fin h → Ω) → Prop) (f : (Fin h → Ω) → ℝ) : + PublicTables.accepted (rowLaw W hW h) (implementAccept X Good) f = + ((X.card:ℝ)/(W.card:ℝ))^h * + (∑ z : Fin h → Ω, if Good z then rowWeight (uniformMass X) z*f z else 0) := by + rw [PublicTables.accepted,mul_sum] + apply sum_congr rfl + intro z _ + simp only [implementAccept,rowLaw] + by_cases hg : Good z + · simp only [hg,and_true,ite_true] + rw [show (if allIn X z then rowWeight (uniformMass W) z*f z else 0) = + (if allIn X z then rowWeight (uniformMass W) z else 0)*f z by + split_ifs <;> ring,contained_row_scaling X W hX hsub] + ring + · simp [hg] + +theorem proposal_acceptance (X W : Finset Ω) (hX : X.Nonempty) (hW : W.Nonempty) + (hsub : X⊆W) (h : ℕ) (Good : (Fin h → Ω) → Prop) : + PublicTables.acceptProb (rowLaw W hW h) (implementAccept X Good) = + ((X.card:ℝ)/(W.card:ℝ))^h * prob (uniformMass X) h Good := by + simpa only [PublicTables.acceptProb,mul_one,prob] using + accepted_scaling X W hX hW hsub h Good (fun _ => 1) + +theorem public_iid_domination (X W : Finset Ω) (hX : X.Nonempty) (hW : W.Nonempty) + (hsub : X⊆W) (h : ℕ) (Good : (Fin h → Ω) → Prop) + (hGood : (9/10:ℝ) ≤ prob (uniformMass X) h Good) + (f : (Fin h → Ω) → ℝ) (hf : ∀ z,0≤f z) (m : ℕ) : + PublicTables.integral (rowLaw W hW h) (implementAccept X Good) f m ≤ + (10/9:ℝ) * (∑ z : Fin h → Ω,rowWeight (uniformMass X) z*f z) := by + let r : ℝ := ((X.card:ℝ)/(W.card:ℝ))^h + let I : ℝ := ∑ z : Fin h → Ω,rowWeight (uniformMass X) z*f z + have hr : 0 mul_nonneg (rowWeight_nonneg _ (uniform_nonneg X) z) (hf z)) + have ha : r*(9/10) ≤ PublicTables.acceptProb (rowLaw W hW h) (implementAccept X Good) := by + rw [proposal_acceptance X W hX hW hsub h Good] + exact mul_le_mul_of_nonneg_left hGood hr.le + have ha0 : 0 simp [mul_nonneg (rowWeight_nonneg _ (uniform_nonneg X) z) (hf z)] + calc + _ ≤ (r*I)/PublicTables.acceptProb (rowLaw W hW h) (implementAccept X Good) := + div_le_div_of_nonneg_right hn ha0.le + _ ≤ (r*I)/(r*(9/10)) := + div_le_div_of_nonneg_left (mul_nonneg hr.le hI) (by positivity) ha + _ = _ := by field_simp; ring + +end +end SharpLogRamsey.Validation +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Windows/BalancedWindows.lean b/lean/OAI/Combinatorics/SharpRamsey/Windows/BalancedWindows.lean new file mode 100644 index 0000000000000000000000000000000000000000..7cedd323e674b465a532f75353fc6c72d6944b1d --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Windows/BalancedWindows.lean @@ -0,0 +1,122 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.ExecutedSecondTrim + +namespace OAI + +section +namespace SharpLogRamsey.ChronologicalTree +open BinaryTree Finset FreshExecution +open scoped Classical +noncomputable section + +lemma balanced_inorder (lo n : ℕ) : inorder (balanced lo n)=List.range' lo n := by + induction n using Nat.strong_induction_on generalizing lo with + | h n ih => + rw [balanced] + split_ifs with hn + · simp [hn,inorder] + · simp only [inorder] + rw [ih (n/2) (Nat.div_lt_self (Nat.pos_of_ne_zero hn) (by decide)), + ih (n-n/2-1) (by omega)] + rw [←List.range'_succ, List.range'_append_1] + congr 1 + have : n/2 rfl + | node a l r hl hr => simp [BinaryTree.map,inorder,hl,hr] + +lemma map_range_getD {A : Type*} (l : List A) (a : A) : + (List.range l.length).map (fun i=>l.getD i a)=l := by + apply List.ext_getElem + · simp + · intro i hi ho + simp only [List.getElem_map,List.getElem_range] + exact List.getD_eq_getElem l a ho + +variable {I : Type*} [LinearOrder I] +local instance liveEq : DecidableEq I := Classical.decEq _ + +def liveTree (S : Finset I) (fallback : I) : BinaryTree I := + (balanced 0 S.card).map (fun j=>(S.sort (·≤·)).getD j fallback) + +lemma liveTree_inorder (S : Finset I) (fallback : I) : + inorder (liveTree S fallback)=S.sort (·≤·) := by + rw [liveTree,inorder_map,balanced_inorder,←List.range_eq_range'] + simpa only [length_sort] using map_range_getD (S.sort (·≤·)) fallback + +lemma liveTree_labels (S : Finset I) (fallback : I) : labels (liveTree S fallback)=S := by + rw [labels,liveTree_inorder] + exact sort_toFinset _ _ + +lemma liveTree_nodes (S : Finset I) (fallback : I) : (liveTree S fallback).numNodes=S.card := by + rw [←inorder_length,liveTree_inorder,length_sort] + +lemma map_height {A B : Type*} (f : A→B) (t : BinaryTree A) : (t.map f).height=t.height := by + induction t with + | nil => rfl + | node a l r hl hr => simp [BinaryTree.map,height,hl,hr] + +lemma liveTree_height (S : Finset I) (fallback : I) : + (liveTree S fallback).height≤Nat.log 2 S.card+1 := by + rw [liveTree,map_height] + exact balanced_height _ _ + +lemma liveTree_nodup (S : Finset I) (fallback : I) : + (inorder (liveTree S fallback)).Nodup := by + rw [liveTree_inorder] + exact sort_nodup _ _ + +lemma liveTree_separated (S : Finset I) (fallback : I) : Separated (liveTree S fallback) := + separated_of_nodup _ (liveTree_nodup S fallback) + +lemma ordered_leftPath (t : BinaryTree I) (ht : (inorder t).Pairwise (·<·)) + (target i : I) (hi : i∈leftPath target t) : target < i := by + induction t with + | nil => simp [leftPath] at hi + | node a l r hl hr => + simp only [inorder,List.pairwise_append,List.pairwise_cons] at ht + rw [leftPath] at hi + split_ifs at hi with ha hL + · simp at hi + · rcases mem_insert.mp hi with rfl|hi + · exact ht.2.2 target (by simpa only [labels,List.mem_toFinset] using hL) i (List.mem_cons_self ..) + · exact hl ht.1 hi + · exact hr ht.2.1.2 hi + +lemma ordered_rightPath (t : BinaryTree I) (ht : (inorder t).Pairwise (·<·)) + (target i : I) (hi : i∈rightPath target t) : i < target := by + induction t with + | nil => simp [rightPath] at hi + | node a l r hl hr => + simp only [inorder,List.pairwise_append,List.pairwise_cons] at ht + rw [rightPath] at hi + split_ifs at hi with ha hR + · simp at hi + · rcases mem_insert.mp hi with rfl|hi + · exact ht.2.1.1 target (by simpa only [labels,List.mem_toFinset] using hR) + · exact hr ht.2.1.2 hi + · exact hl ht.1 hi + +lemma liveTree_ordered (S : Finset I) (fallback : I) : + (inorder (liveTree S fallback)).Pairwise (·<·) := by + rw [liveTree_inorder] + exact S.sortedLT_sort.pairwise + +lemma liveTree_left (S : Finset I) (fallback target i : I) + (hi : i∈leftPath target (liveTree S fallback)) : target < i := + ordered_leftPath _ (liveTree_ordered S fallback) target i hi + +lemma liveTree_right (S : Finset I) (fallback target i : I) + (hi : i∈rightPath target (liveTree S fallback)) : i < target := + ordered_rightPath _ (liveTree_ordered S fallback) target i hi + +end +end SharpLogRamsey.ChronologicalTree + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Windows/ExposureWindows.lean b/lean/OAI/Combinatorics/SharpRamsey/Windows/ExposureWindows.lean new file mode 100644 index 0000000000000000000000000000000000000000..3e5206e1400833139c3debc38ea5837747c6e1dd --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Windows/ExposureWindows.lean @@ -0,0 +1,94 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Exposure.SourceExposure +import OAI.Combinatorics.SharpRamsey.Windows.WindowLayout +import OAI.Combinatorics.SharpRamsey.Windows.WindowDeletion + +namespace OAI + +section +namespace SharpLogRamsey.Selection +open Finset +open scoped Classical BigOperators +noncomputable section +variable {ι β C X : Type} [Fintype β] +namespace ExposureModel + +def lift (M : ExposureModel ι β C) (z : M.History) (e : X↪ι) + (h : ∀ x,∃ i,M.origin z i=e x) : X↪M.Index z where + toFun x := (h x).choose + inj' := by + intro x y he + apply e.injective + rw [←(h x).choose_spec,←(h y).choose_spec] + exact congrArg (M.origin z) he + +lemma lift_origin (M : ExposureModel ι β C) (z : M.History) (e : X↪ι) + (h : ∀ x,∃ i,M.origin z i=e x) (x : X) : M.origin z (M.lift z e h x)=e x := + (h x).choose_spec + +lemma lift_restore (M : ExposureModel ι β C) (z : M.History) (e : X↪ι) + (h : ∀ x,∃ i,M.origin z i=e x) (x : X) (y : M.Index z→β) : + y (M.lift z e h x)=M.restore z y (e x) := by + rw [←M.lift_origin z e h x,M.restore_origin] + +def representative (M : ExposureModel ι β C) (x : M.FreshHistory) : C↪M.Index x.1 where + toFun b := M.embedding x.1 (b,x.2 b) + inj' := by + intro b c h + exact congrArg Prod.fst ((M.embedding x.1).injective h) + +lemma representative_selected [Fintype C] (M : ExposureModel ι β C) (x : M.FreshHistory) : + univ.map (M.representative x)=M.freshSelected x := by + ext i + simp only [mem_map,mem_univ,true_and,freshSelected,freshRepresentatives,mem_image] + rfl + +end ExposureModel + +namespace Windows +variable [Fintype C] + +lemma owner_early {w n : ℕ} (j : Slot w n) (i : Fin w) + (h : owner w n j=some (i,false)) : j.1=i ∧ j.2.val omega + +lemma owner_before_next {w n : ℕ} (i j : Fin w) (hij : i rfl + | node i l r hl hr => simp [population,inorder,hl,hr] +end SharpLogRamsey.FreshExecution + +namespace SharpLogRamsey.Selection.Windows +open Finset ExposureModel ChronologicalTree FreshExecution TreeDecoder BinaryTree +open scoped Classical BigOperators +noncomputable section +variable {Ω Θ β : Type} [Fintype Ω] [Fintype Θ] [Fintype β] +variable (w n k : ℕ) (p : Law Ω) (θ : Ω→Θ) (G : Ω→Slot w (n+k)→β) (t : Fin k) +local instance finDecC (j : ℕ) : DecidableEq (Fin j) := Classical.decEq _ +local instance indexDecC (z : (model w n k p θ G t).FreshHistory) : + DecidableEq ((model w n k p θ G t).Index z.1) := Classical.decEq _ + +abbrev goodMiddle (z : (model w n k p θ G t).FreshHistory) + (bad : Finset ((model w n k p θ G t).Index z.1)) (i : Fin w) : Finset (Fin (2*(n+k))) := + univ.filter (fun x=>target w n k p θ G t z.1 (i,x)∉bad) + +def goodTarget (z : (model w n k p θ G t).FreshHistory) + (bad : Finset ((model w n k p θ G t).Index z.1)) (i : Fin w) : + Fin (goodMiddle w n k p θ G t z bad i).card ↪ (model w n k p θ G t).Index z.1 := + { toFun := fun j=>target w n k p θ G t z.1 (i,(goodMiddle w n k p θ G t z bad i).orderEmbOfFin rfl j) + inj' := by + intro a b h + exact ((goodMiddle w n k p θ G t z bad i).orderEmbOfFin rfl).injective + (congrArg Prod.snd ((target w n k p θ G t z.1).injective h)) } + +lemma goodTarget_eq (z : (model w n k p θ G t).FreshHistory) + (bad : Finset ((model w n k p θ G t).Index z.1)) (i : Fin w) + (j : Fin (goodMiddle w n k p θ G t z bad i).card) : + goodTarget w n k p θ G t z bad i j=target w n k p θ G t z.1 + (i,(goodMiddle w n k p θ G t z bad i).orderEmbOfFin rfl j) := rfl + +lemma goodTarget_not_bad (z : (model w n k p θ G t).FreshHistory) + (bad : Finset ((model w n k p θ G t).Index z.1)) (i : Fin w) + (j : Fin (goodMiddle w n k p θ G t z bad i).card) : + goodTarget w n k p θ G t z bad i j∉bad := by + exact (mem_filter.mp ((goodMiddle w n k p θ G t z bad i).orderEmbOfFin_mem rfl j)).2 + +lemma goodTarget_before (z : (model w n k p θ G t).FreshHistory) + (bad : Finset ((model w n k p θ G t).Index z.1)) (i : Fin w) + (a b : Fin (goodMiddle w n k p θ G t z bad i).card) (hab : aList.ofFn (fun j=>F (goodTarget w n k p θ G t z bad i j))) + (liveTree live fallback)).Pairwise Q := by + rw [population_flatMap,List.pairwise_flatMap] + constructor + · intro i hi + rw [List.pairwise_ofFn] + exact fun a b hab=>hQ _ _ (goodTarget_before w n k p θ G t z bad i a b hab) + · apply (liveTree_ordered live fallback).imp + intro i j hij x hx y hy + obtain ⟨a,rfl⟩:=List.mem_ofFn.mp hx + obtain ⟨b,rfl⟩:=List.mem_ofFn.mp hy + exact hQ _ _ (goodTarget_before_next w n k p θ G t z bad i j hij a b) + +lemma goodPopulation_length {A B : Type*} (z : (model w n k p θ G t).FreshHistory) + (bad : Finset ((model w n k p θ G t).Index z.1)) (live : Finset (Fin w)) (fallback : Fin w) + (F : (model w n k p θ G t).Index z.1→A×B) : + (population (fun i=>List.ofFn (fun j=>F (goodTarget w n k p θ G t z bad i j))) + (liveTree live fallback)).length=∑ i∈live,(goodMiddle w n k p θ G t z bad i).card := by + have hh:=population_length_sum (fun i=>List.ofFn (fun j=>F (goodTarget w n k p θ G t z bad i j))) + _ (liveTree_separated live fallback) + rw [liveTree_labels] at hh + simp only [List.length_ofFn] at hh + exact_mod_cast hh + +lemma goodMiddle_card (z : (model w n k p θ G t).FreshHistory) + (bad : Finset ((model w n k p θ G t).Index z.1)) (live : Finset (Fin w)) : + (∑ i∈live,(goodMiddle w n k p θ G t z bad i).card)= + (goodTargets (target w n k p θ G t z.1) live bad).card := by + rw [←card_sigma] + apply card_bij (fun a _=>target w n k p θ G t z.1 (a.1,a.2)) + · intro a ha + obtain ⟨hi,hx⟩:=mem_sigma.mp ha + exact mem_sdiff.mpr ⟨mem_map.mpr ⟨(a.1,a.2),mem_product.mpr ⟨hi,mem_univ _⟩,rfl⟩, + (mem_filter.mp hx).2⟩ + · intro a ha b hb he + have hh:=(target w n k p θ G t z.1).injective he + exact Sigma.ext (congrArg Prod.fst hh) (heq_of_eq (congrArg Prod.snd hh)) + · intro a ha + obtain ⟨ha,hb⟩:=mem_sdiff.mp ha + obtain ⟨⟨i,x⟩,hx,rfl⟩:=mem_map.mp ha + exact ⟨⟨i,x⟩,mem_sigma.mpr ⟨(mem_product.mp hx).1,mem_filter.mpr ⟨mem_univ _,hb⟩⟩,rfl⟩ + +lemma goodPopulation_size (z : (model w n k p θ G t).FreshHistory) + (bad : Finset ((model w n k p θ G t).Index z.1)) (live : Finset (Fin w)) : + (∑ i∈live,(goodMiddle w n k p θ G t z bad i).card)≤w*(2*(n+k)) := by + calc + _ ≤ ∑ _i∈live,2*(n+k) := by + apply sum_le_sum + intro i hi + simpa using card_le_univ (goodMiddle w n k p θ G t z bad i) + _ = live.card*(2*(n+k)) := by simp + _ ≤ w*(2*(n+k)) := Nat.mul_le_mul_right _ (by simpa using card_le_univ live) + +lemma goodPopulation_predeletion (z : (model w n k p θ G t).FreshHistory) + (bad : Finset ((model w n k p θ G t).Index z.1)) (lost : Finset (Fin w)) : + w*(2*(n+k))≤(∑ i∈univ\lost,(goodMiddle w n k p θ G t z bad i).card)+ + bad.card+lost.card*(2*(n+k)) := by + rw [goodMiddle_card] + simpa only [Fintype.card_fin] using goodTargets_loss (target w n k p θ G t z.1) lost bad + +end +end SharpLogRamsey.Selection.Windows + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Windows/IntegerExperiment.lean b/lean/OAI/Combinatorics/SharpRamsey/Windows/IntegerExperiment.lean new file mode 100644 index 0000000000000000000000000000000000000000..ed46bd1802e647ea98dbe9be802d3d69c0abda3f --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Windows/IntegerExperiment.lean @@ -0,0 +1,168 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Windows.UniformInteger +import OAI.Combinatorics.SharpRamsey.Exposure.PreparedMixture + +namespace OAI + +section +namespace SharpLogRamsey.Selection.Windows +open Finset Real Filter ExposureModel ChronologicalTree FreshExecution TreeDecoder BinaryTree ActualPivot ReciprocalBands SourceScales +open scoped Classical BigOperators Topology +noncomputable section +variable {K V Ω Θ : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] + [Fintype Ω] [Fintype Θ] {d : ℕ} {b τ P H : ℝ} +local instance experimentBanks : Fintype (Banks (K:=K) (V:=V) b) := inferInstance +local instance experimentFinDec (j : ℕ) : DecidableEq (Fin j) := Classical.decEq _ +local instance experimentSlotDec (w L : ℕ) : DecidableEq (Slot w L) := + @instDecidableEqProd (Fin w) (Fin (4*L)) (@instDecidableEqFin w) (@instDecidableEqFin (4*L)) +local instance experimentBlockDec (w : ℕ) : DecidableEq (Block w) := Classical.decEq _ +variable (w n k : ℕ) (p : Law Ω) (θ : Ω→Θ) + (G : Ω→Slot w (n+k)→Projectivization K (Module.Dual K V)×Projectivization K V) (t : Fin k) + +def integerBad (r : ℕ) (J D a : ℝ) (z : (model w n k p θ G t).FreshHistory) := + badIndices ((model w n k p θ G t).tupleLaw z.1) ((model w n k p θ G t).embedding z.1) + ((model w n k p θ G t).owner z.1) + (reciprocalCharges ((model w n k p θ G t).tupleLaw z.1) Projectivization.rep Projectivization.rep + (1/(100*((d:ℝ)+3))) r (d+3-r)) J D a z.2 + +def integerLive (r : ℕ) (J D a : ℝ) (z : (model w n k p θ G t).FreshHistory) := + univ\badWindows ((model w n k p θ G t).representative z) (integerBad (d:=d) w n k p θ G t r J D a z) + +def integerPop (r : ℕ) (J D a : ℝ) (z : (model w n k p θ G t).FreshHistory) : ℕ := + ∑ i∈integerLive (d:=d) w n k p θ G t r J D a z, + (goodMiddle w n k p θ G t z (integerBad (d:=d) w n k p θ G t r J D a z) i).card + +variable (hp : ∀ z,0<(model w n k p θ G t).remaining z) + (e : ∀ z : PositiveHistory w n k p θ G t hp, + Realization (K:=K) (V:=V) (I:=Fin w) (d:=d) (b:=b) + (ExposureModel.tupleLaw (model w n k p θ G t) (Sigma.fst (Subtype.val z)))) + +def integerTargets (r : ℕ) (J D a : ℝ) (y : (mixedPrepared w n k p θ G t hp e).Ω) : + Fin w→List (Projectivization K (Module.Dual K V)×Projectivization K V) := fun i=> + List.ofFn (fun j=>(e y.1).source y.2 + (goodTarget w n k p θ G t y.1.val (integerBad (d:=d) w n k p θ G t r J D a y.1.val) i j)) + +def integerTree (r : ℕ) (J D a : ℝ) (fallback : Fin w) + (y : (mixedPrepared w n k p θ G t hp e).Ω) := + liveTree (integerLive (d:=d) w n k p θ G t r J D a y.1.val) fallback + +omit [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma integerPopulation_size (r : ℕ) (J D a : ℝ) (fallback : Fin w) + (y : (mixedPrepared w n k p θ G t hp e).Ω) : + (population (integerTargets w n k p θ G t hp e r J D a y) + (integerTree w n k p θ G t hp e r J D a fallback y)).length≤w*(2*(n+k)) := by + change (population (fun i=>List.ofFn (fun j=>(e y.1).source y.2 + (goodTarget w n k p θ G t y.1.val (integerBad (d:=d) w n k p θ G t r J D a y.1.val) i j))) + (liveTree (integerLive (d:=d) w n k p θ G t r J D a y.1.val) fallback)).length≤_ + rw [goodPopulation_length] + exact goodPopulation_size w n k p θ G t y.1.val _ _ + +omit [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma integerPopulation_length (r : ℕ) (J D a : ℝ) (fallback : Fin w) + (y : (mixedPrepared w n k p θ G t hp e).Ω) : + (population (integerTargets w n k p θ G t hp e r J D a y) + (integerTree w n k p θ G t hp e r J D a fallback y)).length= + integerPop (d:=d) w n k p θ G t r J D a y.1.val := by + exact goodPopulation_length w n k p θ G t y.1.val _ _ _ _ + +theorem eventually_integer_experiment (d : ℕ) (η C A loss : ℝ) + (hη : 0<η) (hC : 0G ω i∈orthogonalRectangle Projectivization.rep Projectivization.rep W)).card:ℝ)≤M) → + (∑ z,(p.map θ).mass z*((Fintype.card (Slot w (n+k)):ℝ)*J- + entropy ((p.cond θ z).map G)))≤budget → + ∀ fallback : Fin w, ∃ t : Fin k, + let hp:=contextual_positive n k (by omega : 0embedding w (n+k)) (fun _=>owner w (n+k)) t + ∃ e : ∀ z : PositiveHistory w n k p θ G t hp, + Realization (K:=K) (V:=V) (I:=Fin w) (d:=d) (b:=b) + (ExposureModel.tupleLaw (model w n k p θ G t) (Sigma.fst (Subtype.val z))), + let a:=σ^(-2000*beta η)/(Nat.card K:ℝ) + let expmt:=attachedPrepared w n k p θ G t hp e + (∑ tab,(PublicTables.piLaw (fun _ : Fin w=>banksLaw (K:=K) (V:=V) b)).mass tab* + ∑ ω,expmt.μ.mass ω*((w*(2*(n+k)):ℝ)- + (fullOutput (fun y x=>SharpLogRamsey.Incidence.Incident x y) + (fun i=>book.chronoChoose hdim hτ hτsmall ((e ω.1.1).supports ω.1.2 i)) + (fun _=>chronoRead b) (integerTargets w n k p θ G t hp e r J (D*σ^beta η) a ω.1) tab + (integerTree w n k p θ G t hp e r J (D*σ^beta η) a fallback ω.1) (univ,univ)).length))≤ + 5*(budget/(D*σ^beta η)+2*budget/((k:ℝ)*a)+ + 2*Fintype.card (Slot w (n+k))*M/((n:ℝ)*a))+(w*(2*(n+k)):ℝ)*loss := by + filter_upwards [eventually_integer_decoder d η C A loss hη hC hloss, + eventually_ge_atTop (1:ℝ)] with σ hdec hσ + intro K V _ _ _ _ _ _ _ _ hdim hlog D P H hDl hDu + dsimp only + intro book hτ hτsmall Ω Θ _ _ w n k p θ G S u r J M budget hn hk hkn hw hr hJ hM hSJ hS hf hcon hcap hband ho hbudget fallback + let a:=σ^(-2000*beta η)/(Nat.card K:ℝ) + have hσ0 : 0<σ := by linarith + have hD : 0embedding w (n+k)) (fun _=>owner w (n+k)) (fun _=>embedding_owner w (n+k)) + S hS hSJ hf ho hbudget + let hp:=contextual_positive n k (by omega : 0embedding w (n+k)) (fun _=>owner w (n+k)) t + have hh := hdec K V hdim hlog D P H hDl hDu book hτ hτsmall Ω Θ w n k p θ G S u r J + hw hr hJ hS hf hcon hcap hband t hp + choose e he using fun z : PositiveHistory w n k p θ G t hp=>hh z.val z.property fallback + refine ⟨t,e,?_⟩ + let pop:=integerPop (d:=d) w n k p θ G t r J (D*σ^beta η) a + let out:=fun tab (y : (mixedPrepared w n k p θ G t hp e).Ω)=> + (fullOutput (fun y x=>SharpLogRamsey.Incidence.Incident x y) + (fun i=>book.chronoChoose hdim hτ hτsmall ((e y.1).supports y.2 i)) + (fun _=>chronoRead (16*scaleKstar σ η D)) + (integerTargets w n k p θ G t hp e r J (D*σ^beta η) a y) tab + (integerTree w n k p θ G t hp e r J (D*σ^beta η) a fallback y) (univ,univ)).length + have hlocal : ∀ z,(∑ tab,(PublicTables.piLaw (fun _ : Fin w=>banksLaw (K:=K) (V:=V) (16*scaleKstar σ η D))).mass tab* + ∑ y,(e z).μ.mass y*((pop z.val:ℝ)-(out tab ⟨z,y⟩:ℝ)))≤(pop z.val:ℝ)*loss := by + intro z + dsimp only [pop,out,integerPop,integerTree,integerLive,integerBad] + unfold integerTargets + convert he z using 1 <;> simp only [integerBad,Nat.cast_sum] <;> rfl + have hdelete := bad_predeletion_five w n k p θ G t hkn hp + (integerBad (d:=d) w n k p θ G t r J (D*σ^beta η) a) _ hbad hrep + have hres := attachedPrepared_loss w n k p θ G t hp e + (Law.ofPublic (PublicTables.piLaw (fun _ : Fin w=>banksLaw (K:=K) (V:=V) (16*scaleKstar σ η D)))) + (w*(2*(n+k))) pop out loss _ hloss.le + (fun z=>goodPopulation_size w n k p θ G t z _ _) hlocal + (by simpa only [pop,integerPop,integerLive,Nat.cast_mul,Nat.cast_add,Nat.cast_ofNat] using hdelete) + simpa only [Law.ofPublic,out,Nat.cast_mul,Nat.cast_add,Nat.cast_ofNat] using hres +end +end SharpLogRamsey.Selection.Windows + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Windows/IntegerOutput.lean b/lean/OAI/Combinatorics/SharpRamsey/Windows/IntegerOutput.lean new file mode 100644 index 0000000000000000000000000000000000000000..723d90ec22622eca061fb82f22887910546e4357 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Windows/IntegerOutput.lean @@ -0,0 +1,80 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Windows.IntegerQuarter +import OAI.Combinatorics.SharpRamsey.Execution.PreparedOutput + +namespace OAI + +section +namespace SharpLogRamsey.Selection.Windows +open Finset Real Filter ExposureModel ChronologicalTree FreshExecution TreeDecoder BinaryTree ActualPivot ReciprocalBands SourceScales +open scoped Classical BigOperators Topology +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] {b : ℝ} +local instance outputBanks : Fintype (Banks (K:=K) (V:=V) b) := inferInstance +local instance outputFinDec (j : ℕ) : DecidableEq (Fin j) := Classical.decEq _ +local instance outputSlotDec (w L : ℕ) : DecidableEq (Slot w L) := + @instDecidableEqProd (Fin w) (Fin (4*L)) (@instDecidableEqFin w) (@instDecidableEqFin (4*L)) +local instance outputBlockDec (w : ℕ) : DecidableEq (Block w) := Classical.decEq _ + +theorem eventually_integer_output (d : ℕ) (η C A C0 c : ℝ) + (hη : 0<η) (hC : 0G ω i∈orthogonalRectangle Projectivization.rep Projectivization.rep W)).card:ℝ)≤M) → + (∑ z,(p.map θ).mass z*((Fintype.card (Slot w (n+k)):ℝ)*J- + entropy ((p.cond θ z).map G)))≤budget → + budget≤C0*(w*(2*(n+k)):ℝ)*D*σ^(-beta η) → M≤C0*σ → + c*(Nat.card K:ℝ)*D*σ^(3000*beta η)≤k → + c*(Nat.card K:ℝ)*σ^(1+η/2)≤n → + Fin w → + Nonempty (ContextOutput p (fun ω=>flattenTuple (G ω)) (w*(n+k)) + (8000000*(Nat.card K:ℝ)^(d+2)*exp b) + (reciprocalOutputCost (K:=K) (V:=V) (I:=Fin w) (d:=d) (b:=b) (P:=P) (H:=H) + w (Nat.log 2 w+1) (2*(n+k))) 2) := by + filter_upwards [eventually_integer_quarter d η C A C0 c hη hC hC0 hc] with σ hex + intro K V _ _ _ _ _ _ _ _ hdim hlog D P H hDl hDu + dsimp only + intro book hb hH hP haP hτ hτsmall Ω Θ _ _ w n k p θ G S u r J M budget hn hk hkn hw hr hJ hM hSJ hS hf hcon hcap hband ho hbudget hbudget0 hM0 hk0 hn0 fallback + obtain ⟨t,e,he⟩:=hex K V hdim hlog D P H hDl hDu book hτ hτsmall Ω Θ w n k p θ G S u r J M budget + hn hk hkn hw hr hJ hM hSJ hS hf hcon hcap hband ho hbudget hbudget0 hM0 hk0 hn0 fallback + let hp:=contextual_positive n k (by omega : 0embedding w (n+k)) (fun _=>owner w (n+k)) t + exact prepared_context_of_mean w n k p θ G t hp e + (integerBad (d:=d) w n k p θ G t r J (D*σ^beta η) (σ^(-2000*beta η)/(Nat.card K:ℝ))) + (integerLive (d:=d) w n k p θ G t r J (D*σ^beta η) (σ^(-2000*beta η)/(Nat.card K:ℝ))) + fallback hdim book hb hH hP haP hτ hτsmall (by omega) he +end +end SharpLogRamsey.Selection.Windows + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Windows/IntegerQuarter.lean b/lean/OAI/Combinatorics/SharpRamsey/Windows/IntegerQuarter.lean new file mode 100644 index 0000000000000000000000000000000000000000..23710f98d580cc31936a38691c10abca627978c2 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Windows/IntegerQuarter.lean @@ -0,0 +1,99 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Windows.IntegerExperiment +import OAI.Combinatorics.SharpRamsey.Parameters.ExposureScales + +namespace OAI + +section +namespace SharpLogRamsey.Selection.Windows +open Finset Real Filter ExposureModel ChronologicalTree FreshExecution TreeDecoder BinaryTree ActualPivot ReciprocalBands SourceScales +open scoped Classical BigOperators Topology +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] {b : ℝ} +local instance quarterBanks : Fintype (Banks (K:=K) (V:=V) b) := inferInstance +local instance quarterFinDec (j : ℕ) : DecidableEq (Fin j) := Classical.decEq _ +local instance quarterSlotDec (w L : ℕ) : DecidableEq (Slot w L) := + @instDecidableEqProd (Fin w) (Fin (4*L)) (@instDecidableEqFin w) (@instDecidableEqFin (4*L)) +local instance quarterBlockDec (w : ℕ) : DecidableEq (Block w) := Classical.decEq _ + +theorem eventually_integer_quarter (d : ℕ) (η C A C0 c : ℝ) + (hη : 0<η) (hC : 0G ω i∈orthogonalRectangle Projectivization.rep Projectivization.rep W)).card:ℝ)≤M) → + (∑ z,(p.map θ).mass z*((Fintype.card (Slot w (n+k)):ℝ)*J- + entropy ((p.cond θ z).map G)))≤budget → + budget≤C0*(w*(2*(n+k)):ℝ)*D*σ^(-beta η) → M≤C0*σ → + c*(Nat.card K:ℝ)*D*σ^(3000*beta η)≤k → + c*(Nat.card K:ℝ)*σ^(1+η/2)≤n → + ∀ fallback : Fin w, ∃ t : Fin k, + let hp:=contextual_positive n k (by omega : 0embedding w (n+k)) (fun _=>owner w (n+k)) t + ∃ e : ∀ z : PositiveHistory w n k p θ G t hp, + Realization (K:=K) (V:=V) (I:=Fin w) (d:=d) (b:=b) + (ExposureModel.tupleLaw (model w n k p θ G t) (Sigma.fst (Subtype.val z))), + let a:=σ^(-2000*beta η)/(Nat.card K:ℝ) + let expmt:=attachedPrepared w n k p θ G t hp e + (∑ tab,(PublicTables.piLaw (fun _ : Fin w=>banksLaw (K:=K) (V:=V) b)).mass tab* + ∑ ω,expmt.μ.mass ω*((w*(2*(n+k)):ℝ)- + (fullOutput (fun y x=>SharpLogRamsey.Incidence.Incident x y) + (fun i=>book.chronoChoose hdim hτ hτsmall ((e ω.1.1).supports ω.1.2 i)) + (fun _=>chronoRead b) (integerTargets w n k p θ G t hp e r J (D*σ^beta η) a ω.1) tab + (integerTree w n k p θ G t hp e r J (D*σ^beta η) a fallback ω.1) (univ,univ)).length))≤ + (w*(2*(n+k)):ℝ)/4 := by + filter_upwards [eventually_integer_experiment d η C A (1/8) hη hC (by norm_num), + eventually_integer_bad_small η C0 c (1/40) hη hC0 hc (by norm_num), + eventually_ge_atTop (1:ℝ)] with σ hex hsmall hσ + intro K V _ _ _ _ _ _ _ _ hdim hlog D P H hDl hDu + dsimp only + intro book hτ hτsmall Ω Θ _ _ w n k p θ G S u r J M budget hn hk hkn hw hr hJ hM hSJ hS hf hcon hcap hband ho hbudget hb hM0 hk0 hn0 fallback + obtain ⟨t,e,he⟩:=hex K V hdim hlog D P H hDl hDu book hτ hτsmall Ω Θ w n k p θ G S u r J M budget + hn hk hkn hw hr hJ hM hSJ hS hf hcon hcap hband ho hbudget fallback + refine ⟨t,e,?_⟩ + have hq : (0:ℝ) model w n k p θ G t +local notation "q" => ExposureModel.tupleLaw (model w n k p θ G t) (Sigma.fst z) + +include hp hz + +theorem integer_population_realization + (hdim : Module.finrank K V=d+3) + (book : Book (K:=K) (V:=V) (Nat.card K) b τ P H (d+3)) + (hb : 0≤b) (hτ : 0<τ) (hτsmall : τ≤1/40000) + (r : ℕ) (hr : r≤d+3) (κ gap J D a δ : ℝ) + (u : (M).Index z.1→ℝ) + (hband : ∀ i,IntegerBand r (log (Nat.card K)) gap (u i)) + (hsmall : log 1024+3*κ+gap¬goodFirst qi MA L κ (1/50) x))≤δ ∧ + qi.snd.event (univ.filter (fun x=>¬goodSecond qi MB L κ (1/50) x))≤δ) : + let c:=reciprocalCharges q Projectivization.rep Projectivization.rep + (1/(100*((d:ℝ)+3))) r (d+3-r) + let bad:=badIndices q ((M).embedding z.1) ((M).owner z.1) c J D a z.2 + let live:=univ\badWindows ((M).representative z) bad + ∃ e : Realization (K:=K) (V:=V) (I:=Fin w) (d:=d) (b:=b) q, + (∑ tab,(PublicTables.piLaw (fun _ : Fin w=>banksLaw (K:=K) (V:=V) b)).mass tab* + ∑ ω,e.μ.mass ω*((∑ i∈live,((goodMiddle w n k p θ G t z bad i).card:ℝ))- + (fullOutput (fun y x=>SharpLogRamsey.Incidence.Incident x y) + (fun i=>book.chronoChoose hdim hτ.le hτsmall (e.supports ω i)) + (fun _=>chronoRead b) + (fun i=>List.ofFn (fun j=>e.source ω (goodTarget w n k p θ G t z bad i j))) tab + (liveTree live fallback) (univ,univ)).length))≤ + (∑ i∈live,((goodMiddle w n k p θ G t z bad i).card:ℝ))* + treeError (Nat.card K) τ (liveTree live fallback).height + ((20000*((d:ℝ)+3)^2+8)*a) ((20000*((d:ℝ)+3)^2+8)*a) + ((20000*((d:ℝ)+3)^2+8)*a) δ δ := by + dsimp only + let c:=reciprocalCharges q Projectivization.rep Projectivization.rep + (1/(100*((d:ℝ)+3))) r (d+3-r) + let bad:=badIndices q ((M).embedding z.1) ((M).owner z.1) c J D a z.2 + let live:=univ\badWindows ((M).representative z) bad + let MA:=fun i=>1024*exp (((d+3:ℕ):ℝ)*log (Nat.card K)-u i) + let MB:=fun i=>1024*exp (u i) + let L:=((d+2:ℕ):ℝ)*log (Nat.card K) + let GA:=fun i=>univ.filter (goodFirst ((q).marginal i) (MA i) L κ (1/50)) + let GB:=fun i=>univ.filter (goodSecond ((q).marginal i) (MB i) L κ (1/50)) + have hgood : ∀ i∈live,∀ c,(M).representative z (i,c)∉bad := by + intro i hi v + have hh:¬((M).representative z (i,false)∈bad ∨ (M).representative z (i,true)∈bad) := by + simpa only [live,mem_sdiff,mem_univ,true_and,badWindows,mem_filter,true_and] using hi + cases v + · exact fun h=>hh (Or.inl h) + · exact fun h=>hh (Or.inr h) + apply good_population_realization w n k p θ G t z hdim book hb hτ hτsmall bad live fallback hgood + GA GB MA MB (fun _=>κ) (fun _=>κ) + (fun i hi=>(hsupp i hi).1.some) (fun i hi=>(hsupp i hi).2.1.some) + (fun i=>by dsimp [MA]; positivity) (fun i=>by dsimp [MB]; positivity) + · intro i hi + exact reciprocal_window_product (Nat.card K) (d+3) (by exact_mod_cast Finite.card_pos) + 1024 κ _ _ (2*gap) b (by norm_num) + (integer_window_difference (hband _) (hband _)) hbudget + · intro y hy i + exact prepared_pair_property n k p θ G (fun _=>embedding w (n+k)) + (fun _=>owner w (n+k)) t hp z hz (fun _ _ _ x _=>x.1.rep x.2.rep=0) + (fun ω h i _=>hf ω h i) i i y hy + · exact mul_nonneg (by positivity) ha + · intro i j hij hgood + have hh:=prepared_integer_event n k p θ G (fun _=>embedding w (n+k)) + (fun _=>owner w (n+k)) t hp z hz position hcon i j hij 1024 κ gap (u i) (u j) J D a + (d+2) r (by simpa [Nat.add_assoc] using hdim) (by norm_num) (by omega) + (hband i) (hband j) hsmall hκ + specialize hh (by simpa only [Nat.add_assoc,Nat.cast_add,Nat.cast_ofNat, + show (d:ℝ)+2+1=(d:ℝ)+3 by ring] using hgood) + simpa only [goodIncidence,GA,GB,MA,MB,L,mem_filter,mem_univ,true_and, + Nat.cast_add,Nat.cast_ofNat,show (d:ℝ)+2+1=(d:ℝ)+3 by ring] using hh + · intro i hi + have he : univ\GA i=univ.filter (fun x=>¬goodFirst ((q).marginal i) (MA i) L κ (1/50) x) := by + ext x + simp only [GA,mem_sdiff,mem_univ,true_and,mem_filter] + rw [he] + exact (hsupp i hi).2.2.1 + · intro i hi + have he : univ\GB i=univ.filter (fun x=>¬goodSecond ((q).marginal i) (MB i) L κ (1/50) x) := by + ext x + simp only [GB,mem_sdiff,mem_univ,true_and,mem_filter] + rw [he] + exact (hsupp i hi).2.2.2 +end +end SharpLogRamsey.Selection.Windows + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Windows/LogWindow.lean b/lean/OAI/Combinatorics/SharpRamsey/Windows/LogWindow.lean new file mode 100644 index 0000000000000000000000000000000000000000..47587e971db35245526a9040a5c63b29f9bbf227 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Windows/LogWindow.lean @@ -0,0 +1,35 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Marking.CostContraction + +namespace OAI + +section +namespace SharpLogRamsey.SourceScales +open Real Filter +open scoped Topology +noncomputable section + +lemma eventually_log_window (C a : ℝ) (hC : 00) J D a z.2 + +def openKeep (u : Θ→Slot w (n+k)→ℝ) (gap : ℝ) (z : (model w n k p θ G t).FreshHistory) (i : Fin w) : Prop := + u z.1.1 ((model w n k p θ G t).origin z.1 ((model w n k p θ G t).representative z (i,false)))- + u z.1.1 ((model w n k p θ G t).origin z.1 ((model w n k p θ G t).representative z (i,true)))≤gap + +def openLive (u : Θ→Slot w (n+k)→ℝ) (gap J D a : ℝ) (z : (model w n k p θ G t).FreshHistory) := + (univ\badWindows ((model w n k p θ G t).representative z) (openBad w n k p θ G t J D a z)).filter + (openKeep w n k p θ G t u gap z) + +def openPop (u : Θ→Slot w (n+k)→ℝ) (gap J D a : ℝ) (z : (model w n k p θ G t).FreshHistory) : ℕ := + ∑ i∈openLive w n k p θ G t u gap J D a z, + (goodMiddle w n k p θ G t z (openBad w n k p θ G t J D a z) i).card + +variable (hp : ∀ z,0<(model w n k p θ G t).remaining z) + (e : ∀ z : PositiveHistory w n k p θ G t hp, + Realization (K:=K) (V:=V) (I:=Fin w) (d:=d) (b:=b) + (ExposureModel.tupleLaw (model w n k p θ G t) (Sigma.fst (Subtype.val z)))) + +def openTargets (J D a : ℝ) (y : (mixedPrepared w n k p θ G t hp e).Ω) : + Fin w→List (Projectivization K (Module.Dual K V)×Projectivization K V) := fun i=> + List.ofFn (fun j=>(e y.1).source y.2 + (goodTarget w n k p θ G t y.1.val (openBad w n k p θ G t J D a y.1.val) i j)) + +def openTree (u : Θ→Slot w (n+k)→ℝ) (gap J D a : ℝ) (fallback : Fin w) + (y : (mixedPrepared w n k p θ G t hp e).Ω) := + liveTree (openLive w n k p θ G t u gap J D a y.1.val) fallback + +omit [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma openPopulation_size (u : Θ→Slot w (n+k)→ℝ) (gap J D a : ℝ) (fallback : Fin w) + (y : (mixedPrepared w n k p θ G t hp e).Ω) : + (population (openTargets w n k p θ G t hp e J D a y) + (openTree w n k p θ G t hp e u gap J D a fallback y)).length≤w*(2*(n+k)) := by + change (population (fun i=>List.ofFn (fun j=>(e y.1).source y.2 + (goodTarget w n k p θ G t y.1.val (openBad w n k p θ G t J D a y.1.val) i j))) + (liveTree (openLive w n k p θ G t u gap J D a y.1.val) fallback)).length≤_ + rw [goodPopulation_length] + exact goodPopulation_size w n k p θ G t y.1.val _ _ + +omit [Finite K] [FiniteDimensional K V] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in +lemma openPopulation_length (u : Θ→Slot w (n+k)→ℝ) (gap J D a : ℝ) (fallback : Fin w) + (y : (mixedPrepared w n k p θ G t hp e).Ω) : + (population (openTargets w n k p θ G t hp e J D a y) + (openTree w n k p θ G t hp e u gap J D a fallback y)).length= + openPop w n k p θ G t u gap J D a y.1.val := by + exact goodPopulation_length w n k p θ G t y.1.val _ _ _ _ + +theorem eventually_open_experiment (d : ℕ) (η C A c loss : ℝ) + (hη : 0<η) (hC : 0embedding w (n+k)) (fun _=>owner w (n+k)) t + ∃ e : ∀ z : PositiveHistory w n k p θ G t hp, + Realization (K:=K) (V:=V) (I:=Fin w) (d:=d) (b:=b) + (ExposureModel.tupleLaw (model w n k p θ G t) (Sigma.fst (Subtype.val z))), + let a:=σ^(-2000*beta η)/(Nat.card K:ℝ) + let expmt:=attachedPrepared w n k p θ G t hp e + (∑ tab,(PublicTables.piLaw (fun _ : Fin w=>banksLaw (K:=K) (V:=V) b)).mass tab* + ∑ ω,expmt.μ.mass ω*((w*(2*(n+k)):ℝ)- + (fullOutput (fun y x=>SharpLogRamsey.Incidence.Incident x y) + (fun i=>book.chronoChoose hdim hτ hτsmall ((e ω.1.1).supports ω.1.2 i)) + (fun _=>chronoRead b) (openTargets w n k p θ G t hp e J (D*σ^beta η) a ω.1) tab + (openTree w n k p θ G t hp e u (scaleKstar σ η D) J (D*σ^beta η) a fallback ω.1) (univ,univ)).length))≤ + 5*(budget/(D*σ^beta η)+2*budget/((k:ℝ)*a))+(w*(2*(n+k)):ℝ)*(2*loss) := by + filter_upwards [eventually_open_decoder d η C A loss hη hC hloss, + eventually_open_movement d η c loss hη hc hloss, + eventually_ge_atTop (1:ℝ)] with σ hdec hmove hσ + intro K V _ _ _ _ _ _ _ _ hdim hlog D P H hDl hDu + dsimp only + intro book hτ hτsmall Ω Θ _ _ w n k p θ G S u r J budget hn hk hkn hw hcw hr hJ hSJ hS hf hcon hcap hband hbudget fallback + let a:=σ^(-2000*beta η)/(Nat.card K:ℝ) + have hσ0 : 0<σ := by linarith + have hD : 0embedding w (n+k)) (fun _=>owner w (n+k)) (fun _=>embedding_owner w (n+k)) + S hS hSJ hbudget + let hp:=contextual_positive n k (by omega : 0embedding w (n+k)) (fun _=>owner w (n+k)) t + have hh := hdec K V hdim hlog D P H hDl hDu book hτ hτsmall Ω Θ w n k p θ G S u r J + hw hr hJ hS hf hcon hcap hband t hp + choose e he using fun z : PositiveHistory w n k p θ G t hp=>hh z.val z.property fallback + refine ⟨t,e,?_⟩ + let pop:=openPop w n k p θ G t u (scaleKstar σ η D) J (D*σ^beta η) a + let out:=fun tab (y : (mixedPrepared w n k p θ G t hp e).Ω)=> + (fullOutput (fun y x=>SharpLogRamsey.Incidence.Incident x y) + (fun i=>book.chronoChoose hdim hτ hτsmall ((e y.1).supports y.2 i)) + (fun _=>chronoRead (16*scaleKstar σ η D)) + (openTargets w n k p θ G t hp e J (D*σ^beta η) a y) tab + (openTree w n k p θ G t hp e u (scaleKstar σ η D) J (D*σ^beta η) a fallback y) (univ,univ)).length + have hlocal : ∀ z,(∑ tab,(PublicTables.piLaw (fun _ : Fin w=>banksLaw (K:=K) (V:=V) (16*scaleKstar σ η D))).mass tab* + ∑ y,(e z).μ.mass y*((pop z.val:ℝ)-(out tab ⟨z,y⟩:ℝ)))≤(pop z.val:ℝ)*loss := by + intro z + dsimp only [pop,out,openPop,openTree,openLive,openKeep,openBad] + unfold openTargets + convert he z using 1 <;> simp only [openBad,Nat.cast_sum] <;> rfl + have hdrop:=hmove K V hdim hlog D hDl hDu Ω Θ w n k p θ G S u r J + hcw hr hJ hS hf hcon hcap hband t hp + have hdelete := filtered_predeletion_mean w n k p θ G t hkn hp + (openBad w n k p θ G t J (D*σ^beta η) a) + (openKeep w n k p θ G t u (scaleKstar σ η D)) _ loss hbad hrep (by + intro z hz + simpa only [openBad,openKeep,not_le] using hdrop z hz) + have hres := attachedPrepared_loss w n k p θ G t hp e + (Law.ofPublic (PublicTables.piLaw (fun _ : Fin w=>banksLaw (K:=K) (V:=V) (16*scaleKstar σ η D)))) + (w*(2*(n+k))) pop out loss _ hloss.le + (fun z=>goodPopulation_size w n k p θ G t z _ _) hlocal + (by simpa only [pop,openPop,openLive,Nat.cast_mul,Nat.cast_add,Nat.cast_ofNat] using hdelete) + dsimp only [Law.ofPublic,out] at hres + convert hres using 1 <;> push_cast <;> ring +end +end SharpLogRamsey.Selection.Windows + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Windows/OpenMovement.lean b/lean/OAI/Combinatorics/SharpRamsey/Windows/OpenMovement.lean new file mode 100644 index 0000000000000000000000000000000000000000..bb405f595ce185006be179b8ea1a14f0ce92c0e0 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Windows/OpenMovement.lean @@ -0,0 +1,100 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Windows.IntegerRealization + +namespace OAI + +section +namespace SharpLogRamsey.Selection.Windows +open Finset Real ExposureModel ReciprocalBands +open scoped Classical BigOperators +noncomputable section +variable {K V Ω Θ : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype Ω] [Fintype Θ] {d : ℕ} +local instance moveDec (j : ℕ) : DecidableEq (Fin j) := Classical.decEq _ +variable (w n k : ℕ) (p : Law Ω) (θ : Ω→Θ) + (G : Ω→Slot w (n+k)→Projectivization K (Module.Dual K V)×Projectivization K V) (t : Fin k) +local instance moveSlotDec : DecidableEq (Slot w (n+k)) := + @instDecidableEqProd (Fin w) (Fin (4*(n+k))) (@instDecidableEqFin w) (@instDecidableEqFin (4*(n+k))) +local instance moveBlockDec : DecidableEq (Block w) := Classical.decEq _ +variable (hp : ∀ z,0<(model w n k p θ G t).remaining z) + (z : (model w n k p θ G t).FreshHistory) + (hz : ((model w n k p θ G t).freshLaw hp).mass z≠0) +local notation "M" => model w n k p θ G t +local notation "q" => ExposureModel.tupleLaw (model w n k p θ G t) (Sigma.fst z) + +include hp hz + +theorem open_window_deletion + (hdim : Module.finrank K V=d+3) + (r : ℕ) (hr : r≤d+3) (κ gap J D a : ℝ) (hgap : 0≤gap) + (u : (M).Index z.1→ℝ) + (hband : ∀ i,OpenBand r (log (Nat.card K)) gap (u i)) + (hsmall : log 1024+3*κ0) J D a z.2 + ∀ i,i∉bad→ + let qi:=(q).marginal i + let MA:=1024*exp (((d+3:ℕ):ℝ)*log (Nat.card K)-u i) + let MB:=1024*exp (u i) + let L:=((d+2:ℕ):ℝ)*log (Nat.card K) + Nonempty (AuxiliarySupport qi.fst (univ.filter (goodFirst qi MA L κ (1/50))) MA κ) ∧ + Nonempty (AuxiliarySupport qi.snd (univ.filter (goodSecond qi MB L κ (1/50))) MB κ)) : + let bad:=badIndices q ((M).embedding z.1) ((M).owner z.1) (fun _ _=>0) J D a z.2 + let live:=univ\badWindows ((M).representative z) bad + gap*((live.filter (fun i=>gap0) J D a z.2 + let live:=univ\badWindows ((M).representative z) bad + have hgood : ∀ i∈live,∀ c,(M).representative z (i,c)∉bad := by + intro i hi v + have hh:¬((M).representative z (i,false)∈bad ∨ (M).representative z (i,true)∈bad) := by + simpa only [live,mem_sdiff,mem_univ,true_and,badWindows,mem_filter,true_and] using hi + cases v + · exact fun h=>hh (Or.inl h) + · exact fun h=>hh (Or.inr h) + have hcross : ∀ i∈live,∀ j∈live,iembedding w (n+k)) + (fun _=>owner w (n+k)) t hp z hz position hcon ii jj + (representative_before w n k p θ G t z i j hij true false) + 1024 κ gap (u ii) (u jj) J D a (d+2) r + (by simpa [Nat.add_assoc] using hdim) (by norm_num) (by omega) + (hband ii) (hband jj) hsmall hκ + (Or.inl ⟨hgood i hi true,representative_other w n k p θ G t z (j,false) (i,true) (by simp)⟩) + have hh:=chronological_order_of_good_event hdim q ii jj 1024 κ (u ii) (u jj) + (((d+2:ℕ):ℝ)*log (Nat.card K)) (1/50) (20000*((d:ℝ)+3)^2*a) (by norm_num) + (hsupp ii (hgood i hi true)).1.some (hsupp jj (hgood j hj false)).2.some + (by simpa only [Nat.cast_add,Nat.cast_ofNat,show (d:ℝ)+2+1=(d:ℝ)+3 by ring] using he) + hsparse + simpa only [add_assoc] using hh + have hlog : 0≤log (Nat.card K:ℝ) := by + apply log_nonneg + exact_mod_cast (show 1≤Nat.card K from Finite.card_pos) + have hκ0 : 0≤κ := (log_nonneg (by norm_num : (1:ℝ)≤200/97)).trans hκ + have hh:=downward_deleted live + (fun i=>u ((M).representative z (i,false))) + (fun i=>u ((M).representative z (i,true))) + (((r:ℝ)-1)*log (Nat.card K)) ((r:ℝ)*log (Nat.card K)) (2*κ+log 64) gap + (by nlinarith) (by have hl:=log_nonneg (show (1:ℝ)≤64 by norm_num); linarith) + (by intro i hi; have hb:=(hband ((M).representative z (i,true))).1; linarith) + (by intro i hi; have hb:=(hband ((M).representative z (i,false))).2; linarith) + hcross + simp only [Fintype.card_fin] at hh + convert hh using 1 + ring +end +end SharpLogRamsey.Selection.Windows + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Windows/OpenOutput.lean b/lean/OAI/Combinatorics/SharpRamsey/Windows/OpenOutput.lean new file mode 100644 index 0000000000000000000000000000000000000000..526e29c651efca8297347abce89c697b3e914c1a --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Windows/OpenOutput.lean @@ -0,0 +1,77 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.PreparedOutput +import OAI.Combinatorics.SharpRamsey.Windows.OpenQuarter + +namespace OAI + +section +namespace SharpLogRamsey.Selection.Windows +open Finset Real Filter ExposureModel ChronologicalTree FreshExecution TreeDecoder BinaryTree ActualPivot ReciprocalBands SourceScales +open scoped Classical BigOperators Topology +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] {b : ℝ} +local instance openOutputBanks : Fintype (Banks (K:=K) (V:=V) b) := inferInstance +local instance openOutputFinDec (j : ℕ) : DecidableEq (Fin j) := Classical.decEq _ +local instance openOutputSlotDec (w L : ℕ) : DecidableEq (Slot w L) := + @instDecidableEqProd (Fin w) (Fin (4*L)) (@instDecidableEqFin w) (@instDecidableEqFin (4*L)) +local instance openOutputBlockDec (w : ℕ) : DecidableEq (Block w) := Classical.decEq _ + +theorem eventually_open_output (d : ℕ) (η C A C0 c : ℝ) + (hη : 0<η) (hC : 0flattenTuple (G ω)) (w*(n+k)) + (8000000*(Nat.card K:ℝ)^(d+2)*exp b) + (reciprocalOutputCost (K:=K) (V:=V) (I:=Fin w) (d:=d) (b:=b) (P:=P) (H:=H) + w (Nat.log 2 w+1) (2*(n+k))) 2) := by + filter_upwards [eventually_open_quarter d η C A C0 c hη hC hC0 hc] with σ hex + intro K V _ _ _ _ _ _ _ _ hdim hlog D P H hDl hDu + dsimp only + intro book hb hH hP haP hτ hτsmall Ω Θ _ _ w n k p θ G S u r J budget hn hk hkn hw hcw hr hJ hSJ hS hf hcon hcap hband hbudget hbudget0 hk0 fallback + obtain ⟨t,e,he⟩:=hex K V hdim hlog D P H hDl hDu book hτ hτsmall Ω Θ w n k p θ G S u r J budget + hn hk hkn hw hcw hr hJ hSJ hS hf hcon hcap hband hbudget hbudget0 hk0 fallback + let hp:=contextual_positive n k (lt_of_lt_of_le (by decide : 0<2) hn) p θ G + (fun _=>embedding w (n+k)) (fun _=>owner w (n+k)) t + exact prepared_context_of_mean w n k p θ G t hp e + (openBad w n k p θ G t J (D*σ^beta η) (σ^(-2000*beta η)/(Nat.card K:ℝ))) + (openLive w n k p θ G t u (scaleKstar σ η D) J (D*σ^beta η) (σ^(-2000*beta η)/(Nat.card K:ℝ))) + fallback hdim book hb hH hP haP hτ hτsmall (by omega) he +end +end SharpLogRamsey.Selection.Windows + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Windows/OpenQuarter.lean b/lean/OAI/Combinatorics/SharpRamsey/Windows/OpenQuarter.lean new file mode 100644 index 0000000000000000000000000000000000000000..da9cd03dfe657c3dff61033ec88bc47fa3c8692d --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Windows/OpenQuarter.lean @@ -0,0 +1,89 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Windows.OpenExperiment +import OAI.Combinatorics.SharpRamsey.Entropy.InformationScales + +namespace OAI + +section +namespace SharpLogRamsey.Selection.Windows +open Finset Real Filter ExposureModel ChronologicalTree FreshExecution TreeDecoder BinaryTree ActualPivot ReciprocalBands SourceScales +open scoped Classical BigOperators Topology +noncomputable section +variable {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] {b : ℝ} +local instance openQuarterBanks : Fintype (Banks (K:=K) (V:=V) b) := inferInstance +local instance openQuarterFinDec (j : ℕ) : DecidableEq (Fin j) := Classical.decEq _ +local instance openQuarterSlotDec (w L : ℕ) : DecidableEq (Slot w L) := + @instDecidableEqProd (Fin w) (Fin (4*L)) (@instDecidableEqFin w) (@instDecidableEqFin (4*L)) +local instance openQuarterBlockDec (w : ℕ) : DecidableEq (Block w) := Classical.decEq _ + +theorem eventually_open_quarter (d : ℕ) (η C A C0 c : ℝ) + (hη : 0<η) (hC : 0embedding w (n+k)) (fun _=>owner w (n+k)) t + ∃ e : ∀ z : PositiveHistory w n k p θ G t hp, + Realization (K:=K) (V:=V) (I:=Fin w) (d:=d) (b:=b) + (ExposureModel.tupleLaw (model w n k p θ G t) (Sigma.fst (Subtype.val z))), + let a:=σ^(-2000*beta η)/(Nat.card K:ℝ) + let expmt:=attachedPrepared w n k p θ G t hp e + (∑ tab,(PublicTables.piLaw (fun _ : Fin w=>banksLaw (K:=K) (V:=V) b)).mass tab* + ∑ ω,expmt.μ.mass ω*((w*(2*(n+k)):ℝ)- + (fullOutput (fun y x=>SharpLogRamsey.Incidence.Incident x y) + (fun i=>book.chronoChoose hdim hτ hτsmall ((e ω.1.1).supports ω.1.2 i)) + (fun _=>chronoRead b) (openTargets w n k p θ G t hp e J (D*σ^beta η) a ω.1) tab + (openTree w n k p θ G t hp e u (scaleKstar σ η D) J (D*σ^beta η) a fallback ω.1) (univ,univ)).length))≤ + (w*(2*(n+k)):ℝ)/4 := by + filter_upwards [eventually_open_experiment d η C A c (1/16) hη hC hc (by norm_num), + eventually_information_bad_small η C0 c (1/40) hη hC0 hc (by norm_num), + eventually_ge_atTop (1:ℝ)] with σ hex hsmall hσ + intro K V _ _ _ _ _ _ _ _ hdim hlog D P H hDl hDu + dsimp only + intro book hτ hτsmall Ω Θ _ _ w n k p θ G S u r J budget hn hk hkn hw hcw hr hJ hSJ hS hf hcon hcap hband hbudget hb hk0 fallback + obtain ⟨t,e,he⟩:=hex K V hdim hlog D P H hDl hDu book hτ hτsmall Ω Θ w n k p θ G S u r J budget + hn hk hkn hw hcw hr hJ hSJ hS hf hcon hcap hband hbudget fallback + refine ⟨t,e,?_⟩ + have hq : (0:ℝ) model w n k p θ G t +local notation "q" => ExposureModel.tupleLaw (model w n k p θ G t) (Sigma.fst z) + +include hp hz + +theorem open_population_realization + (hdim : Module.finrank K V=d+3) + (book : Book (K:=K) (V:=V) (Nat.card K) b τ P H (d+3)) + (hb : 0≤b) (hτ : 0<τ) (hτsmall : τ≤1/40000) + (r : ℕ) (hr : r≤d+3) (κ gap J D a δ : ℝ) + (u : (M).Index z.1→ℝ) + (hband : ∀ i,OpenBand r (log (Nat.card K)) gap (u i)) + (hsmall : log 1024+3*κ (0 : NNReal) + let bad:=badIndices q ((M).embedding z.1) ((M).owner z.1) c J D a z.2 + ∀ i,i∉bad→ + let qi:=(q).marginal i + let MA:=1024*exp (((d+3:ℕ):ℝ)*log (Nat.card K)-u i) + let MB:=1024*exp (u i) + let L:=((d+2:ℕ):ℝ)*log (Nat.card K) + Nonempty (AuxiliarySupport qi.fst (univ.filter (goodFirst qi MA L κ (1/50))) MA κ) ∧ + Nonempty (AuxiliarySupport qi.snd (univ.filter (goodSecond qi MB L κ (1/50))) MB κ) ∧ + qi.fst.event (univ.filter (fun x=>¬goodFirst qi MA L κ (1/50) x))≤δ ∧ + qi.snd.event (univ.filter (fun x=>¬goodSecond qi MB L κ (1/50) x))≤δ) : + let c:=fun (_ _ : (M).Index z.1)=> (0 : NNReal) + let bad:=badIndices q ((M).embedding z.1) ((M).owner z.1) c J D a z.2 + let live:=(univ\badWindows ((M).representative z) bad).filter + (fun i=>u ((M).representative z (i,false))-u ((M).representative z (i,true))≤gap) + ∃ e : Realization (K:=K) (V:=V) (I:=Fin w) (d:=d) (b:=b) q, + (∑ tab,(PublicTables.piLaw (fun _ : Fin w=>banksLaw (K:=K) (V:=V) b)).mass tab* + ∑ ω,e.μ.mass ω*((∑ i∈live,((goodMiddle w n k p θ G t z bad i).card:ℝ))- + (fullOutput (fun y x=>SharpLogRamsey.Incidence.Incident x y) + (fun i=>book.chronoChoose hdim hτ.le hτsmall (e.supports ω i)) + (fun _=>chronoRead b) + (fun i=>List.ofFn (fun j=>e.source ω (goodTarget w n k p θ G t z bad i j))) tab + (liveTree live fallback) (univ,univ)).length))≤ + (∑ i∈live,((goodMiddle w n k p θ G t z bad i).card:ℝ))* + treeError (Nat.card K) τ (liveTree live fallback).height + ((20000*((d:ℝ)+3)^2)*a) ((20000*((d:ℝ)+3)^2)*a) + ((20000*((d:ℝ)+3)^2)*a) δ δ := by + dsimp only + let c:=fun (_ _ : (M).Index z.1)=> (0 : NNReal) + let bad:=badIndices q ((M).embedding z.1) ((M).owner z.1) c J D a z.2 + let live:=(univ\badWindows ((M).representative z) bad).filter + (fun i=>u ((M).representative z (i,false))-u ((M).representative z (i,true))≤gap) + let MA:=fun i=>1024*exp (((d+3:ℕ):ℝ)*log (Nat.card K)-u i) + let MB:=fun i=>1024*exp (u i) + let L:=((d+2:ℕ):ℝ)*log (Nat.card K) + let GA:=fun i=>univ.filter (goodFirst ((q).marginal i) (MA i) L κ (1/50)) + let GB:=fun i=>univ.filter (goodSecond ((q).marginal i) (MB i) L κ (1/50)) + have hgood : ∀ i∈live,∀ c,(M).representative z (i,c)∉bad := by + intro i hi v + have hh:¬((M).representative z (i,false)∈bad ∨ (M).representative z (i,true)∈bad) := by + simpa only [mem_sdiff,mem_univ,true_and,badWindows,mem_filter,true_and] using (mem_filter.mp hi).1 + cases v + · exact fun h=>hh (Or.inl h) + · exact fun h=>hh (Or.inr h) + apply good_population_realization w n k p θ G t z hdim book hb hτ hτsmall bad live fallback hgood + GA GB MA MB (fun _=>κ) (fun _=>κ) + (fun i hi=>(hsupp i hi).1.some) (fun i hi=>(hsupp i hi).2.1.some) + (fun i=>by dsimp [MA]; positivity) (fun i=>by dsimp [MB]; positivity) + · intro i hi + exact reciprocal_window_product (Nat.card K) (d+3) (by exact_mod_cast Finite.card_pos) + 1024 κ _ _ gap b (by norm_num) (mem_filter.mp hi).2 hbudget + · intro y hy i + exact prepared_pair_property n k p θ G (fun _=>embedding w (n+k)) + (fun _=>owner w (n+k)) t hp z hz (fun _ _ _ x _=>x.1.rep x.2.rep=0) + (fun ω h i _=>hf ω h i) i i y hy + · exact mul_nonneg (by positivity) ha + · intro i j hij hgood + have hh:=prepared_open_event n k p θ G (fun _=>embedding w (n+k)) + (fun _=>owner w (n+k)) t hp z hz position hcon i j hij 1024 κ gap (u i) (u j) J D a + (d+2) r (by simpa [Nat.add_assoc] using hdim) (by norm_num) (by omega) + (hband i) (hband j) hsmall hκ + specialize hh (by simpa only [Nat.add_assoc,Nat.cast_add,Nat.cast_ofNat, + show (d:ℝ)+2+1=(d:ℝ)+3 by ring] using hgood) + simpa only [goodIncidence,GA,GB,MA,MB,L,mem_filter,mem_univ,true_and, + Nat.cast_add,Nat.cast_ofNat,show (d:ℝ)+2+1=(d:ℝ)+3 by ring] using hh + · intro i hi + have he : univ\GA i=univ.filter (fun x=>¬goodFirst ((q).marginal i) (MA i) L κ (1/50) x) := by + ext x + simp only [GA,mem_sdiff,mem_univ,true_and,mem_filter] + rw [he] + exact (hsupp i hi).2.2.1 + · intro i hi + have he : univ\GB i=univ.filter (fun x=>¬goodSecond ((q).marginal i) (MB i) L κ (1/50) x) := by + ext x + simp only [GB,mem_sdiff,mem_univ,true_and,mem_filter] + rw [he] + exact (hsupp i hi).2.2.2 +end +end SharpLogRamsey.Selection.Windows + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Windows/PopulationSublist.lean b/lean/OAI/Combinatorics/SharpRamsey/Windows/PopulationSublist.lean new file mode 100644 index 0000000000000000000000000000000000000000..e0e1b4edeb77dea325dc0d23ba94fb0aa84b4454 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Windows/PopulationSublist.lean @@ -0,0 +1,56 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Windows.GoodPopulation + +namespace OAI + +section +namespace SharpLogRamsey.Selection.Windows +open Finset ExposureModel ChronologicalTree FreshExecution TreeDecoder BinaryTree +open scoped Classical BigOperators +noncomputable section + +lemma finProd_position {w n : ℕ} (i : Slot w n) : + (finProdFinEquiv i).val=position i := by + simp [finProdFinEquiv,position,Nat.mul_comm,Nat.add_comm] + +def flattenTuple {β : Type*} {w n : ℕ} (F : Slot w n→β) : Fin (w*(4*n))→β := + fun i=>F (finProdFinEquiv.symm i) + +variable {Ω Θ β : Type} [Fintype Ω] [Fintype Θ] [Fintype β] +variable (w n k : ℕ) (p : Law Ω) (θ : Ω→Θ) (G : Ω→Slot w (n+k)→β) (t : Fin k) +local instance sublistFinDec (j : ℕ) : DecidableEq (Fin j) := Classical.decEq _ +local instance sublistIndexDec (z : (model w n k p θ G t).FreshHistory) : + DecidableEq ((model w n k p θ G t).Index z.1) := Classical.decEq _ + +theorem goodPopulation_sublist {A B : Type*} (z : (model w n k p θ G t).FreshHistory) + (bad : Finset ((model w n k p θ G t).Index z.1)) + (live : Finset (Fin w)) (fallback : Fin w) + (F : (model w n k p θ G t).Index z.1→A×B) (F0 : Slot w (n+k)→A×B) + (hF : ∀ i,F i=F0 ((model w n k p θ G t).origin z.1 i)) : + (population (fun i=>List.ofFn (fun j=>F (goodTarget w n k p θ G t z bad i j))) + (liveTree live fallback)).Sublist (List.ofFn (flattenTuple F0)) := by + let l:=population (fun i=>List.ofFn (fun j=>(model w n k p θ G t).origin z.1 + (goodTarget w n k p θ G t z bad i j))) (liveTree live fallback) + have hl : l.Pairwise (fun i j=>position iposition ih) + have hl' : (l.map finProdFinEquiv).Pairwise (·<·) := by + rw [List.pairwise_map] + apply hl.imp + intro i j hij + change (finProdFinEquiv i).val<(finProdFinEquiv j).val + simpa only [finProd_position] using hij + have hs : (l.map finProdFinEquiv).Sublist (List.finRange (w*(4*(n+k)))) := + List.sublist_of_subperm_of_pairwise + (List.subperm_of_subset hl'.nodup (by intro i hi;exact List.mem_finRange i)) + hl' (List.sortedLT_finRange _).pairwise + have hm:=hs.map (flattenTuple F0) + rw [←List.ofFn_eq_map] at hm + simpa [l,population_flatMap,List.map_flatMap,List.map_ofFn,Function.comp_def, + flattenTuple,←hF] using hm +end +end SharpLogRamsey.Selection.Windows + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Windows/PreparedWindows.lean b/lean/OAI/Combinatorics/SharpRamsey/Windows/PreparedWindows.lean new file mode 100644 index 0000000000000000000000000000000000000000..151fa0c4c8a4cab3a18c4d8c2f031605b08779da --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Windows/PreparedWindows.lean @@ -0,0 +1,105 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Windows.ExposureWindows + +namespace OAI + +section +namespace SharpLogRamsey.Selection.Windows +open Finset ExposureModel +open scoped Classical BigOperators +noncomputable section +variable {Ω Θ β : Type} [Fintype Ω] [Fintype Θ] [Fintype β] + +abbrev model (w n k : ℕ) (p : Law Ω) (θ : Ω→Θ) (G : Ω→Slot w (n+k)→β) (t : Fin k) := + contextual n k p θ G (fun _=>embedding w (n+k)) (fun _=>owner w (n+k)) t + +variable (w n k : ℕ) (p : Law Ω) (θ : Ω→Θ) (G : Ω→Slot w (n+k)→β) (t : Fin k) + +local instance flat_ActualPreparedWindows_1 : DecidableEq (Block w) := Classical.decEq _ + +lemma model_owner (z : (model w n k p θ G t).History) (i : (model w n k p θ G t).Index z) : + (model w n k p θ G t).owner z i=owner w (n+k) ((model w n k p θ G t).origin z i) := + atRound_owner n k ((p.cond θ z.1).map G) (embedding w (n+k)) (owner w (n+k)) t z.2 i + +lemma model_embedding_owner (z : (model w n k p θ G t).History) (b : Block w) + (x : Fin ((model w n k p θ G t).remaining z)) : + (model w n k p θ G t).owner z ((model w n k p θ G t).embedding z (b,x))=some b := + atRound_embedding_owner n k ((p.cond θ z.1).map G) (embedding w (n+k)) (owner w (n+k)) + (embedding_owner w (n+k)) t z.2 b x + +lemma target_exists (z : (model w n k p θ G t).History) (x : Fin w×Fin (2*(n+k))) : + ∃ i,(model w n k p θ G t).origin z i=middle w (n+k) x := + atRound_unowned n k ((p.cond θ z.1).map G) (embedding w (n+k)) (owner w (n+k)) + (embedding_owner w (n+k)) t z.2 _ (middle_unowned w (n+k) x.1 x.2) + +def target (z : (model w n k p θ G t).History) : Fin w×Fin (2*(n+k)) ↪ (model w n k p θ G t).Index z := + (model w n k p θ G t).lift z (middle w (n+k)) (target_exists w n k p θ G t z) + +lemma target_origin (z : (model w n k p θ G t).History) (i : Fin w) (x : Fin (2*(n+k))) : + (model w n k p θ G t).origin z (target w n k p θ G t z (i,x))=middle w (n+k) (i,x) := + lift_origin _ _ _ _ _ + +lemma target_owner (z : (model w n k p θ G t).History) (i : Fin w) (x : Fin (2*(n+k))) : + (model w n k p θ G t).owner z (target w n k p θ G t z (i,x))=none := by + rw [model_owner,target_origin,middle_unowned] + +lemma representative_owner (z : (model w n k p θ G t).FreshHistory) (b : Block w) : + (model w n k p θ G t).owner z.1 ((model w n k p θ G t).representative z b)=some b := + model_embedding_owner w n k p θ G t z.1 b (z.2 b) + +lemma representative_origin_owner (z : (model w n k p θ G t).FreshHistory) (b : Block w) : + owner w (n+k) ((model w n k p θ G t).origin z.1 + ((model w n k p θ G t).representative z b))=some b := by + rw [←model_owner,representative_owner] + +lemma target_between (z : (model w n k p θ G t).FreshHistory) (i : Fin w) (x : Fin (2*(n+k))) : + position ((model w n k p θ G t).origin z.1 ((model w n k p θ G t).representative z (i,false))) < + position ((model w n k p θ G t).origin z.1 (target w n k p θ G t z.1 (i,x))) ∧ + position ((model w n k p θ G t).origin z.1 (target w n k p θ G t z.1 (i,x))) < + position ((model w n k p θ G t).origin z.1 ((model w n k p θ G t).representative z (i,true))) := by + rw [target_origin] + exact owner_between i _ _ (representative_origin_owner w n k p θ G t z (i,false)) + (representative_origin_owner w n k p θ G t z (i,true)) x + +lemma representative_other (z : (model w n k p θ G t).FreshHistory) (b c : Block w) (hbc : b≠c) : + (model w n k p θ G t).representative z b∈otherRepresentatives + ((model w n k p θ G t).embedding z.1) ((model w n k p θ G t).owner z.1) z.2 + ((model w n k p θ G t).representative z c) := by + apply mem_image.mpr + refine ⟨b,mem_filter.mpr ⟨mem_univ _,?_⟩,rfl⟩ + rw [representative_owner] + exact fun h=>hbc (Option.some.inj h) + +lemma target_other (z : (model w n k p θ G t).FreshHistory) (b : Block w) + (i : Fin w) (x : Fin (2*(n+k))) : + (model w n k p θ G t).representative z b∈otherRepresentatives + ((model w n k p θ G t).embedding z.1) ((model w n k p θ G t).owner z.1) z.2 + (target w n k p θ G t z.1 (i,x)) := by + apply mem_image.mpr + refine ⟨b,mem_filter.mpr ⟨mem_univ _,?_⟩,rfl⟩ + rw [target_owner] + exact Option.some_ne_none _ + +theorem bad_windows_mean (hp : ∀ z,0<(model w n k p θ G t).remaining z) + (bad : ∀ z : (model w n k p θ G t).FreshHistory,Finset ((model w n k p θ G t).Index z.1)) : + (∑ z,((model w n k p θ G t).freshLaw hp).mass z* + ((badWindows ((model w n k p θ G t).representative z) (bad z)).card:ℝ))≤ + ∑ z,((model w n k p θ G t).freshLaw hp).mass z* + (((model w n k p θ G t).freshSelected z∩bad z).card:ℝ) := by + apply sum_le_sum + intro z _ + apply mul_le_mul_of_nonneg_left _ (((model w n k p θ G t).freshLaw hp).nonneg z) + have hh := badWindows_card ((model w n k p θ G t).representative z) (bad z) + rw [representative_selected] at hh + apply (Nat.cast_le (α:=ℝ)).mpr + convert! (preTransparency := .all) hh using 1 + congr 1 + ext index + simp only [mem_inter] + +end +end SharpLogRamsey.Selection.Windows + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Windows/SuppliedBook.lean b/lean/OAI/Combinatorics/SharpRamsey/Windows/SuppliedBook.lean new file mode 100644 index 0000000000000000000000000000000000000000..76d8e9e9edce3ba58f5f9d2f54c582db759b8891 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Windows/SuppliedBook.lean @@ -0,0 +1,41 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Parameters.BookScales + +namespace OAI + +section +namespace SharpLogRamsey.ActualPivot +open Real Filter SourceScales +open scoped Topology +noncomputable section + +theorem supplied_book (i : ℕ) : ∃ H : ℝ, 0 ≤ H ∧ + ∀ η : ℝ, 0 < η → ∀ᶠ σ : ℝ in atTop, + ∀ (q : ℕ) [Fact q.Prime], 3 ≤ q → exp σ = (q:ℝ) → + ∀ (V : Type) [AddCommGroup V] [Module (ZMod q) V] [FiniteDimensional (ZMod q) V], + Module.finrank (ZMod q) V = i+4 → ∀ D R, Admissible σ η D R → + let b := 16*scaleKstar σ η D + let τ := σ^(-100*beta η) + 0 ≤ b ∧ 4 ≤ scaleP σ η D R ∧ b+log 1000000 ≤ scaleP σ η D R ∧ + 0 ≤ τ ∧ τ ≤ 1/40000 ∧ + Nonempty (Book (K:=ZMod q) (V:=V) (Nat.card (ZMod q)) b τ + (scaleP σ η D R) H ((i+1)+3)) := by + obtain ⟨H,hH,hbook⟩ := uniform_book i + refine ⟨H,hH,?_⟩ + intro η hη + filter_upwards [hbook η hη 16 (by norm_num), eventually_book_scales hη, + eventually_ge_atTop (1:ℝ)] with σ hb hs hσ + intro q _ hq he V _ _ _ hd D R had + obtain ⟨h0,hP,hbP,hτ,hτsmall⟩ := hs D R had + dsimp only + refine ⟨h0,hP,hbP,hτ.le,hτsmall,?_⟩ + simpa only [Nat.card_zmod] using hb q hq he V hd D R had + (16*scaleKstar σ η D) (σ^(-100*beta η)) h0 le_rfl hτ (by + have hh := rpow_nonneg (by linarith : 0 ≤ σ) (-100*beta η) + linarith) +end +end SharpLogRamsey.ActualPivot + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Windows/UniformBook.lean b/lean/OAI/Combinatorics/SharpRamsey/Windows/UniformBook.lean new file mode 100644 index 0000000000000000000000000000000000000000..1147d673941a94c4edf1b83a00c0d202865ed07e --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Windows/UniformBook.lean @@ -0,0 +1,49 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Trees.Pivot + +namespace OAI + +section +namespace SharpLogRamsey.ActualPivot +open Finset Real GeometricCover SourceScales Filter +open scoped Classical Topology +noncomputable section + +theorem uniform_book (i : ℕ) : ∃ H : ℝ,0≤H ∧ + ∀ η : ℝ,0<η → ∀ C : ℝ,1≤C → + ∀ᶠ σ : ℝ in atTop,∀ (q : ℕ) [Fact q.Prime],3≤q → exp σ=(q:ℝ) → + ∀ (V : Type) [AddCommGroup V] [Module (ZMod q) V] [FiniteDimensional (ZMod q) V], + Module.finrank (ZMod q) V=i+4 → ∀ D R,Admissible σ η D R → + ∀ b τ : ℝ,0≤b → b≤C*scaleKstar σ η D → 0<τ → τ≤C*σ^(-100*beta η) → + Nonempty (Book (K:=ZMod q) (V:=V) q b τ (scaleP σ η D R) H (i+4)) := by + obtain ⟨H,hH,huniform⟩ := uniform_all i + refine ⟨H,hH,?_⟩ + intro η hη C hC + let C' := 4*C+4 + have hC' : 1≤C' := by dsimp only [C']; linarith + filter_upwards [huniform η hη C' hC',eventually_ge_atTop (1:ℝ)] with σ hs hσ + intro q _ hq hex V _ _ _ hdim D R had b τ hb hbC hτ hτC + have hK : 1≤ scaleKstar σ η D := by + have hD : 1≤D := (one_le_rpow hσ (beta_pos hη).le).trans had.D_lower + exact one_le_mul_of_one_le_of_one_le hD (one_le_rpow hσ (by have hb := beta_pos hη; positivity)) + have hlog : 0≤log (4:ℝ) := log_nonneg (by norm_num) + have hlog' : log (4:ℝ)≤3 := by + have hh := log_le_sub_one_of_pos (by norm_num : (0:ℝ)<4) + linarith + have hb' : b+log 4≤C'*scaleKstar σ η D := by dsimp only [C']; nlinarith + have hτ' : 4*τ≤C'*σ^(-100*beta η) := by + have hpow := rpow_nonneg (show 0≤σ by linarith) (-100*beta η) + dsimp only [C'] + nlinarith + refine ⟨Book.ofValidated q b τ (scaleP σ η D R) H (i+4) ?_⟩ + intro U s t hh + rcases hh with ⟨hs0,ht0,hsU,htU,hlo,hhi⟩ + exact hs q hq hex V hdim D R had U.1 U.2 s t (b+log 4) (4*τ) + hs0 ht0 hsU htU (add_nonneg hb hlog) hb' (by positivity) hτ' hlo hhi + +end +end SharpLogRamsey.ActualPivot + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Windows/UniformInteger.lean b/lean/OAI/Combinatorics/SharpRamsey/Windows/UniformInteger.lean new file mode 100644 index 0000000000000000000000000000000000000000..36e56c6229bc5f10fb715b7f6393281fe0ef4674 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Windows/UniformInteger.lean @@ -0,0 +1,136 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Windows.IntegerRealization +import OAI.Combinatorics.SharpRamsey.Parameters.IntegerScales +import OAI.Combinatorics.SharpRamsey.Trees.TreeHeight + +namespace OAI + +section +namespace SharpLogRamsey.Selection.Windows +open Finset Real Filter ExposureModel ChronologicalTree FreshExecution TreeDecoder BinaryTree ActualPivot ReciprocalBands SourceScales +open scoped Classical BigOperators Topology +noncomputable section +local instance uniformIntBanks {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] + (b : ℝ) : Fintype (Banks (K:=K) (V:=V) b) := inferInstance +local instance uniformIntFinDec (j : ℕ) : DecidableEq (Fin j) := Classical.decEq _ +local instance uniformIntSlotDec (w L : ℕ) : DecidableEq (Slot w L) := + @instDecidableEqProd (Fin w) (Fin (4*L)) (@instDecidableEqFin w) (@instDecidableEqFin (4*L)) +local instance uniformIntBlockDec (w : ℕ) : DecidableEq (Block w) := Classical.decEq _ + +theorem eventually_integer_decoder (d : ℕ) (η C A loss : ℝ) + (hη : 0<η) (hC : 0banksLaw (K:=K) (V:=V) b)).mass tab* + ∑ ω,e.μ.mass ω*((∑ i∈live,((goodMiddle w n k p θ G t z bad i).card:ℝ))- + (fullOutput (fun y x=>SharpLogRamsey.Incidence.Incident x y) + (fun i=>book.chronoChoose hdim hτ hτsmall (e.supports ω i)) + (fun _=>chronoRead b) + (fun i=>List.ofFn (fun j=>e.source ω (goodTarget w n k p θ G t z bad i j))) tab + (liveTree live fallback) (univ,univ)).length))≤ + (∑ i∈live,((goodMiddle w n k p θ G t z bad i).card:ℝ))*loss := by + let E:=20000*((d:ℝ)+3)^2+8 + let CE:=E+3251 + have hb:=beta_pos hη + have hCE : 0≤CE := by dsimp [CE,E]; positivity + filter_upwards [eventually_prepared_reciprocal d (beta η) hb, + eventually_integer_regime η hη,eventually_liveTree_height (beta η) C A hb hC, + eventually_tree_small (beta η) CE loss hb hCE hloss, + eventually_ge_atTop (1:ℝ)] with σ hsupp hreg hheight htree hσ + intro K V _ _ _ _ _ _ _ _ hdim hlog D P H hDl hDu + dsimp only + intro book hτ0 hτsmall Ω Θ _ _ w n k p θ G S u r J hw hr hJ hS hf hcon hcap hband t hp z hz fallback + let M:=model w n k p θ G t + let q:=M.tupleLaw z.1 + let a:=σ^(-2000*beta η)/(Nat.card K:ℝ) + let κ:=scaleK σ η D + let gap:=scaleKstar σ η D + let b:=16*gap + let τ:=σ^(-100*beta η) + let c:=reciprocalCharges q Projectivization.rep Projectivization.rep (1/(100*((d:ℝ)+3))) r (d+3-r) + let bad:=badIndices q (M.embedding z.1) (M.owner z.1) c J (D*σ^beta η) a z.2 + let live:=univ\badWindows (M.representative z) bad + have hσ0 : 0<σ := by linarith + have hD : 0embedding w (n+k)) + (fun _=>owner w (n+k)) t hp z hz + (fun θ=>∀ i,IntegerBand r σ gap (u θ i)) hband + intro i + rw [hlog] + exact hh _ + obtain ⟨e,he⟩:=integer_population_realization w n k p θ G t hp z hz hdim book + (by dsimp [b,gap,scaleKstar]; positivity) hreg'.2.2.2.1 hreg'.2.2.2.2 + r hr κ gap J (D*σ^beta η) a (3251*σ^(-2*beta η)) + (fun i=>u z.1.1 (M.origin z.1 i)) hpb + (by simpa only [κ,gap,hlog] using hreg'.1) hreg'.2.1 hreg'.2.2.1 + (by dsimp [a]; positivity) hcon hf fallback (by + dsimp only + intro i hi + have hh:=hsupp K V hdim hlog Ω Θ (Slot w (n+k)) (Block w) p θ G S u n k + (fun _=>embedding w (n+k)) (fun _=>owner w (n+k)) t hp D J a hS hf hcap hDl hJ z c hz i hi + simpa only [hlog,κ,scaleK] using hh) + refine ⟨e,he.trans ?_⟩ + apply mul_le_mul_of_nonneg_left _ (by positivity) + apply htree (Nat.card K) ((liveTree live fallback).height:ℝ) (E*a) (E*a) (E*a) + (3251*σ^(-2*beta η)) (3251*σ^(-2*beta η)) + · rw [←hlog] + exact (log_le_sub_one_of_pos hq0).trans (by linarith) + · positivity + · exact hheight w hw live fallback + · dsimp [E,a]; positivity + · dsimp [E,a]; positivity + · dsimp [E,a]; positivity + all_goals first + | (have heq : (Nat.card K:ℝ)*(E*a)=E*σ^(-2000*beta η) := by dsimp [a]; field_simp [ne_of_gt hq0] + rw [heq] + apply mul_le_mul_of_nonneg_right _ (by positivity) + dsimp [CE]; linarith) + | (apply mul_le_mul_of_nonneg_right _ (by positivity) + dsimp [CE,E] + nlinarith [sq_nonneg ((d:ℝ)+3)]) +end +end SharpLogRamsey.Selection.Windows + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Windows/UniformMovement.lean b/lean/OAI/Combinatorics/SharpRamsey/Windows/UniformMovement.lean new file mode 100644 index 0000000000000000000000000000000000000000..96c6d9da7163edb28b5fe6379d957b6fff37f341 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Windows/UniformMovement.lean @@ -0,0 +1,87 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Parameters.OpenScales +import OAI.Combinatorics.SharpRamsey.Windows.OpenMovement + +namespace OAI + +section +namespace SharpLogRamsey.Selection.Windows +open Finset Real Filter ExposureModel ReciprocalBands SourceScales +open scoped Classical BigOperators Topology +noncomputable section +local instance movementFinDec (j : ℕ) : DecidableEq (Fin j) := Classical.decEq _ +local instance movementSlotDec (w L : ℕ) : DecidableEq (Slot w L) := + @instDecidableEqProd (Fin w) (Fin (4*L)) (@instDecidableEqFin w) (@instDecidableEqFin (4*L)) +local instance movementBlockDec (w : ℕ) : DecidableEq (Block w) := Classical.decEq _ + +theorem eventually_open_movement (d : ℕ) (η c ε : ℝ) + (hη : 0<η) (hc : 00) J (D*σ^beta η) a z.2 + let live:=univ\badWindows (M.representative z) bad + ((live.filter (fun i=>scaleKstar σ η D< + u z.1.1 (M.origin z.1 (M.representative z (i,false)))- + u z.1.1 (M.origin z.1 (M.representative z (i,true))))).card:ℝ)≤ε*w := by + filter_upwards [eventually_prepared_reciprocal d (beta η) (beta_pos hη), + eventually_integer_regime η hη,eventually_open_regime η d hη, + eventually_open_deletion_small η c ε hη hc hε,eventually_ge_atTop (1:ℝ)] + with σ hsupp hreg hopen hdelete hσ + intro K V _ _ _ _ _ _ _ hdim hlog D hDl hDu Ω Θ _ _ w n k p θ G S u r J hw hr hJ hS hf hcon hcap hband t hp z hz + let M:=model w n k p θ G t + let a:=σ^(-2000*beta η)/(Nat.card K:ℝ) + let κ:=scaleK σ η D + let gap:=scaleKstar σ η D + have hσ0 : 0<σ := lt_of_lt_of_le zero_lt_one hσ + have hD : 0embedding w (n+k)) + (fun _=>owner w (n+k)) t hp z hz (fun θ=>∀ i,OpenBand r σ gap (u θ i)) hband + intro i + rw [hlog] + exact hh _ + have hh:=open_window_deletion w n k p θ G t hp z hz hdim r hr κ gap J (D*σ^beta η) a hg.le + (fun i=>u z.1.1 (M.origin z.1 i)) hpb (hopen D (Nat.card K) hDl hq).1 + (hreg D hDl hDu).2.1 (hopen D (Nat.card K) hDl hq).2 hcon (by + dsimp only + intro i hi + have hh:=hsupp K V hdim hlog Ω Θ (Slot w (n+k)) (Block w) p θ G S u n k + (fun _=>embedding w (n+k)) (fun _=>owner w (n+k)) t hp D J a hS hf hcap hDl hJ z (fun _ _=>0) hz i hi + simpa only [hlog,κ,scaleK] using And.intro hh.1 hh.2.1) + rw [hlog] at hh + have hb:=hdelete D (w:ℝ) hDl (by positivity) hw + dsimp only [gap,κ] at hh hg + dsimp only + nlinarith +end +end SharpLogRamsey.Selection.Windows + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Windows/UniformOpen.lean b/lean/OAI/Combinatorics/SharpRamsey/Windows/UniformOpen.lean new file mode 100644 index 0000000000000000000000000000000000000000..677ab3c3d6a21d73cddb932d61144dd290b453ae --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Windows/UniformOpen.lean @@ -0,0 +1,141 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Trees.TreeHeight +import OAI.Combinatorics.SharpRamsey.Windows.OpenRealization +import OAI.Combinatorics.SharpRamsey.Parameters.OpenScales + +namespace OAI + +section +namespace SharpLogRamsey.Selection.Windows +open Finset Real Filter ExposureModel ChronologicalTree FreshExecution TreeDecoder BinaryTree ActualPivot ReciprocalBands SourceScales +open scoped Classical BigOperators Topology +noncomputable section +local instance uniformIntOpenBanks {K V : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] + (b : ℝ) : Fintype (Banks (K:=K) (V:=V) b) := inferInstance +local instance uniformIntOpenFinDec (j : ℕ) : DecidableEq (Fin j) := Classical.decEq _ +local instance uniformIntOpenSlotDec (w L : ℕ) : DecidableEq (Slot w L) := + @instDecidableEqProd (Fin w) (Fin (4*L)) (@instDecidableEqFin w) (@instDecidableEqFin (4*L)) +local instance uniformIntOpenBlockDec (w : ℕ) : DecidableEq (Block w) := Classical.decEq _ + +theorem eventually_open_decoder (d : ℕ) (η C A loss : ℝ) + (hη : 0<η) (hC : 0(0:NNReal) + let bad:=badIndices q (M.embedding z.1) (M.owner z.1) c J (D*σ^beta η) a z.2 + let live:=(univ\badWindows (M.representative z) bad).filter + (fun i=>u z.1.1 (M.origin z.1 (M.representative z (i,false)))- + u z.1.1 (M.origin z.1 (M.representative z (i,true)))≤ scaleKstar σ η D) + ∃ e : Realization (K:=K) (V:=V) (I:=Fin w) (d:=d) (b:=b) q, + (∑ tab,(PublicTables.piLaw (fun _ : Fin w=>banksLaw (K:=K) (V:=V) b)).mass tab* + ∑ ω,e.μ.mass ω*((∑ i∈live,((goodMiddle w n k p θ G t z bad i).card:ℝ))- + (fullOutput (fun y x=>SharpLogRamsey.Incidence.Incident x y) + (fun i=>book.chronoChoose hdim hτ hτsmall (e.supports ω i)) + (fun _=>chronoRead b) + (fun i=>List.ofFn (fun j=>e.source ω (goodTarget w n k p θ G t z bad i j))) tab + (liveTree live fallback) (univ,univ)).length))≤ + (∑ i∈live,((goodMiddle w n k p θ G t z bad i).card:ℝ))*loss := by + let E:=20000*((d:ℝ)+3)^2 + let CE:=E+3251 + have hb:=beta_pos hη + have hCE : 0≤CE := by dsimp [CE,E]; positivity + filter_upwards [eventually_prepared_reciprocal d (beta η) hb, + eventually_integer_regime η hη,eventually_open_regime η d hη,eventually_liveTree_height (beta η) C A hb hC, + eventually_tree_small (beta η) CE loss hb hCE hloss, + eventually_ge_atTop (1:ℝ)] with σ hsupp hreg hopen hheight htree hσ + intro K V _ _ _ _ _ _ _ _ hdim hlog D P H hDl hDu + dsimp only + intro book hτ0 hτsmall Ω Θ _ _ w n k p θ G S u r J hw hr hJ hS hf hcon hcap hband t hp z hz fallback + let M:=model w n k p θ G t + let q:=M.tupleLaw z.1 + let a:=σ^(-2000*beta η)/(Nat.card K:ℝ) + let κ:=scaleK σ η D + let gap:=scaleKstar σ η D + let b:=16*gap + let τ:=σ^(-100*beta η) + let c:=fun (_ _ : M.Index z.1)=>(0:NNReal) + let bad:=badIndices q (M.embedding z.1) (M.owner z.1) c J (D*σ^beta η) a z.2 + let live:=(univ\badWindows (M.representative z) bad).filter + (fun i=>u z.1.1 (M.origin z.1 (M.representative z (i,false)))- + u z.1.1 (M.origin z.1 (M.representative z (i,true)))≤ scaleKstar σ η D) + have hσ0 : 0<σ := by linarith + have hD : 0embedding w (n+k)) + (fun _=>owner w (n+k)) t hp z hz + (fun θ=>∀ i,OpenBand r σ gap (u θ i)) hband + intro i + rw [hlog] + exact hh _ + obtain ⟨e,he⟩:=open_population_realization w n k p θ G t hp z hz hdim book + (by dsimp [b,gap,scaleKstar]; positivity) hreg'.2.2.2.1 hreg'.2.2.2.2 + r hr κ gap J (D*σ^beta η) a (3251*σ^(-2*beta η)) + (fun i=>u z.1.1 (M.origin z.1 i)) hpb + (hopen D (Nat.card K) hDl hq0).1 hreg'.2.1 + (by have hg : 0≤gap := by dsimp [gap,scaleKstar]; positivity + have hh:=hreg'.2.2.1; dsimp only [gap,b] at *; linarith) + (by dsimp [a]; positivity) hcon hf fallback (by + dsimp only + intro i hi + have hh:=hsupp K V hdim hlog Ω Θ (Slot w (n+k)) (Block w) p θ G S u n k + (fun _=>embedding w (n+k)) (fun _=>owner w (n+k)) t hp D J a hS hf hcap hDl hJ z c hz i hi + simpa only [hlog,κ,scaleK] using hh) + refine ⟨e,he.trans ?_⟩ + apply mul_le_mul_of_nonneg_left _ (by positivity) + apply htree (Nat.card K) ((liveTree live fallback).height:ℝ) (E*a) (E*a) (E*a) + (3251*σ^(-2*beta η)) (3251*σ^(-2*beta η)) + · rw [←hlog] + exact (log_le_sub_one_of_pos hq0).trans (by linarith) + · positivity + · exact hheight w hw live fallback + · dsimp [E,a]; positivity + · dsimp [E,a]; positivity + · dsimp [E,a]; positivity + all_goals first + | (have heq : (Nat.card K:ℝ)*(E*a)=E*σ^(-2000*beta η) := by dsimp [a]; field_simp [ne_of_gt hq0] + rw [heq] + apply mul_le_mul_of_nonneg_right _ (by positivity) + dsimp [CE]; linarith) + | (apply mul_le_mul_of_nonneg_right _ (by positivity) + dsimp [CE,E] + nlinarith [sq_nonneg ((d:ℝ)+3)]) +end +end SharpLogRamsey.Selection.Windows + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Windows/WindowChoices.lean b/lean/OAI/Combinatorics/SharpRamsey/Windows/WindowChoices.lean new file mode 100644 index 0000000000000000000000000000000000000000..329f8fdeef31d3776f1000be0e3b89ec674583e6 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Windows/WindowChoices.lean @@ -0,0 +1,146 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Windows.WindowPacking +import OAI.Combinatorics.SharpRamsey.Parameters.BookScales + +namespace OAI + +section +namespace SharpLogRamsey.Selection.Windows +open Real Filter SourceScales +open scoped Topology +noncomputable section + +lemma rounded_window {x y : ℝ} (hx : 2 ≤ x) (hy : 2 ≤ y) (hyx : y ≤ x) : + 2 ≤ ⌈x⌉₊ ∧ 0 < ⌊y⌋₊ ∧ ⌊y⌋₊ ≤ ⌈x⌉₊ ∧ + y/2 ≤ (⌊y⌋₊:ℝ) ∧ + x ≤ (4*(⌈x⌉₊+⌊y⌋₊):ℕ) ∧ (4*(⌈x⌉₊+⌊y⌋₊):ℕ) ≤ 12*x := by + have hx0 : 0 ≤ x := by linarith + have hy0 : 0 ≤ y := by linarith + have hn := Nat.le_ceil x + have hn' := Nat.ceil_lt_add_one hx0 + have hk := Nat.floor_le hy0 + have hk' := Nat.lt_floor_add_one y + have hn2 : 2 ≤ ⌈x⌉₊ := by exact_mod_cast (show (2:ℝ) ≤ ⌈x⌉₊ by linarith) + have hkpos : 0 < ⌊y⌋₊ := by exact_mod_cast (show (0:ℝ) < ⌊y⌋₊ by linarith) + have hkn : ⌊y⌋₊ ≤ ⌈x⌉₊ := by exact_mod_cast (show (⌊y⌋₊:ℝ) ≤ ⌈x⌉₊ by linarith) + refine ⟨hn2,hkpos,hkn,by linarith,?_,?_⟩ <;> push_cast <;> linarith + +theorem eventually_reciprocal_windows (η c C : ℝ) (hη : 0 < η) (hηu : η ≤ 1) + (hc : 0 < c) (hC : 0 < C) : + ∀ᶠ σ : ℝ in atTop, ∀ (q D : ℝ) (m : ℕ) (integer : Bool), + exp σ = q → σ^beta η ≤ D → D ≤ σ^(1-η/2) → + c*q*σ^(1+η) ≤ (m:ℝ) → (m:ℝ) ≤ C*q*σ^(1+η) → + let x := if integer then q*σ^(1+η/2) else q*D*σ^(η/2) + let n := ⌈x⌉₊ + let k := ⌊q*D*σ^(3000*beta η)⌋₊ + let L := 4*(n+k) + let w := m/L + 2 ≤ n ∧ 0 < k ∧ k ≤ n ∧ 1 ≤ w ∧ w*L ≤ m ∧ (m:ℝ)/2 ≤ (w*L:ℕ) ∧ + (1/2)*q*D*σ^(3000*beta η) ≤ (k:ℝ) ∧ + (w:ℝ)*D ≤ max C 12*σ^(1+η/2) ∧ + (w:ℝ) ≤ max C 12*σ^(1+η/2) ∧ + (if integer then q*σ^(1+η/2) ≤ (n:ℝ) + else (c/(2*max C 12))*σ^(1+η/2) ≤ (w:ℝ)*D) ∧ + (L:ℝ) ≤ 12*q*σ^(1+η/2) := by + have ht : Tendsto (fun σ : ℝ => σ^(η/2)) atTop atTop := tendsto_rpow_atTop (by positivity) + filter_upwards [ht.eventually_ge_atTop (24/c), eventually_ge_atTop (1:ℝ)] + with σ hlarge hσ q D m integer he hDl hDu hmlo hmhi + have hσ0 : 0 < σ := lt_of_lt_of_le hη (hηu.trans hσ) + have hb := beta_pos hη + have hD : 1 ≤ D := (one_le_rpow hσ hb.le).trans hDl + have hD0 : 0 < D := by linarith + have hq0 : 0 < q := he ▸ exp_pos _ + have hq2 : 2 ≤ q := by + have h := add_one_le_exp σ + rw [he] at h + linarith + have h3000 : 0 ≤ 3000*beta η := by positivity + have hpow3 : 1 ≤ σ^(3000*beta η) := one_le_rpow hσ h3000 + let x := if integer then q*σ^(1+η/2) else q*D*σ^(η/2) + let y := q*D*σ^(3000*beta η) + have hqD : 2 ≤ q*D := hq2.trans (le_mul_of_one_le_right hq0.le hD) + have hy : 2 ≤ y := hqD.trans (le_mul_of_one_le_right (by positivity) hpow3) + have hx : 2 ≤ x := by + have ha := one_le_rpow hσ (show 0 ≤ η/2 by positivity) + have hb := one_le_rpow hσ (show 0 ≤ 1+η/2 by positivity) + cases integer + · exact hqD.trans (le_mul_of_one_le_right (by positivity) ha) + · exact hq2.trans (le_mul_of_one_le_right hq0.le hb) + have hyx : y ≤ x := by + have h3 : σ^(3000*beta η) ≤ σ^(η/2) := rpow_le_rpow_of_exponent_le hσ (by unfold beta; linarith) + have h4 : σ^((1-η/2)+3000*beta η) ≤ σ^(1+η/2) := + rpow_le_rpow_of_exponent_le hσ (by unfold beta; linarith) + cases integer + · exact mul_le_mul_of_nonneg_left h3 (by positivity) + · calc + y ≤ q*(σ^(1-η/2))*σ^(3000*beta η) := by dsimp only [y]; gcongr + _ = q*σ^((1-η/2)+3000*beta η) := by rw [mul_assoc, ←rpow_add hσ0] + _ ≤ _ := mul_le_mul_of_nonneg_left h4 hq0.le + obtain ⟨hn,hk,hkn,hklo,hLlo,hLhi⟩ := rounded_window hx hy hyx + let L := 4*(⌈x⌉₊+⌊y⌋₊) + have hL : 0 < L := by dsimp only [L]; omega + have hxup : x ≤ q*σ^(1+η/2) := by + cases integer + · change q*D*σ^(η/2) ≤ _ + calc + _ ≤ q*σ^(1-η/2)*σ^(η/2) := by gcongr + _ = q*σ := by rw [mul_assoc, ←rpow_add hσ0]; congr 1; convert rpow_one σ using 2; ring + _ ≤ _ := mul_le_mul_of_nonneg_left (by + calc + σ = σ^(1:ℝ) := (rpow_one _).symm + _ ≤ _ := rpow_le_rpow_of_exponent_le hσ (by linarith)) hq0.le + · exact le_rfl + have hLup : (L:ℝ) ≤ 12*q*σ^(1+η/2) := by dsimp only [L]; nlinarith + have hscale : 24*q*σ^(1+η/2) ≤ c*q*σ^(1+η) := by + have hh := (div_le_iff₀ hc).mp hlarge + have hh' := mul_le_mul_of_nonneg_right hh (mul_nonneg hq0.le (rpow_nonneg hσ0.le (1+η/2))) + have hp : σ^(η/2)*σ^(1+η/2) = σ^(1+η) := by rw [←rpow_add hσ0]; congr 1; ring + nlinarith [show c*q*(σ^(η/2)*σ^(1+η/2))=c*q*σ^(1+η) by rw [hp]] + have hpack : 2*L ≤ m := by exact_mod_cast (show (2:ℝ)*L ≤ m by linarith) + obtain ⟨hw,hwm,hh⟩ := packing_bounds m L hL hpack + have hbase : q*D*σ^(η/2) ≤ (L:ℝ) := by + have hb : q*D*σ^(η/2) ≤ x := by + cases integer + · rfl + · change q*D*σ^(η/2) ≤ q*σ^(1+η/2) + calc + _ ≤ q*σ^(1-η/2)*σ^(η/2) := by gcongr + _ ≤ _ := by + rw [mul_assoc, ←rpow_add hσ0] + exact mul_le_mul_of_nonneg_left (rpow_le_rpow_of_exponent_le hσ (by linarith)) hq0.le + exact hb.trans hLlo + have hwd : ((m/L:ℕ):ℝ)*D ≤ max C 12*σ^(1+η/2) := by + have hu : ((m/L:ℕ):ℝ)*(q*D*σ^(η/2)) ≤ C*q*σ^(1+η) := + (mul_le_mul_of_nonneg_left hbase (Nat.cast_nonneg _)).trans + ((by exact_mod_cast hwm : ((m/L:ℕ):ℝ)*(L:ℝ) ≤ m).trans hmhi) + have hp : σ^(1+η)=σ^(1+η/2)*σ^(η/2) := by rw [←rpow_add hσ0]; congr 1; ring + rw [hp] at hu + have hwa : ((m/L:ℕ):ℝ)*D ≤ C*σ^(1+η/2) := by + apply (mul_le_mul_iff_right₀ (mul_pos hq0 (rpow_pos_of_pos hσ0 (η/2)))).mp + nlinarith only [hu] + exact hwa.trans (mul_le_mul_of_nonneg_right (le_max_left _ _) (rpow_nonneg hσ0.le _)) + dsimp only + change _ ∧ _ ∧ _ ∧ 1 ≤ m/L ∧ (m/L)*L ≤ m ∧ _ ∧ _ ∧ _ ∧ _ ∧ _ ∧ _ + refine ⟨hn,hk,hkn,hw,hwm,hh,by dsimp only [y] at hklo; linarith,hwd,?_,?_,hLup⟩ + · have hw0 : (0:ℝ) ≤ (m/L:ℕ) := Nat.cast_nonneg _ + nlinarith + · cases integer + · simp only [Bool.false_eq_true,ite_false] + have hA : 0 < max C 12 := lt_of_lt_of_le hC (le_max_left _ _) + have hmA : (m:ℝ) ≤ max C 12*q*σ^(1+η) := hmhi.trans (by gcongr; exact le_max_left _ _) + have hLA : (L:ℝ) ≤ max C 12*q*D*σ^(η/2) := by + have hh : (L:ℝ) ≤ 12*(q*D*σ^(η/2)) := hLhi + calc + _ ≤ _ := hh + _ ≤ _ := by + have hp := mul_le_mul_of_nonneg_right (le_max_right C 12) + (by positivity : 0 ≤ q*D*σ^(η/2)) + nlinarith only [hp] + exact (packing_scales m L hq0 hσ0 hD0 hc hA hL hpack hmlo hmA hbase hLA).2.2.2.1 + · simpa only [ite_true] using Nat.le_ceil (q*σ^(1+η/2)) +end +end SharpLogRamsey.Selection.Windows + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Windows/WindowDeletion.lean b/lean/OAI/Combinatorics/SharpRamsey/Windows/WindowDeletion.lean new file mode 100644 index 0000000000000000000000000000000000000000..99ba0316be7a5b28b6374d0e0d9a1245e50629f6 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Windows/WindowDeletion.lean @@ -0,0 +1,113 @@ +import Mathlib + +namespace OAI + +section +namespace SharpLogRamsey.Selection.Windows +open Finset +open scoped Classical BigOperators +noncomputable section +variable {W ι X : Type*} [Fintype W] [Fintype ι] [Fintype X] + +def badWindows (e : W×Bool↪ι) (bad : Finset ι) : Finset W := + univ.filter (fun i=>e (i,false)∈bad ∨ e (i,true)∈bad) + +omit [Fintype ι] in +lemma badWindows_image (e : W×Bool↪ι) (bad : Finset ι) : + badWindows e bad=(univ.filter (fun z:W×Bool=>e z∈bad)).image Prod.fst := by + ext i + simp only [badWindows,mem_filter,mem_univ,true_and,mem_image] + constructor + · rintro (h|h) + · exact ⟨(i,false),h,rfl⟩ + · exact ⟨(i,true),h,rfl⟩ + · rintro ⟨⟨j,b⟩,h,rfl⟩ + cases b + · exact Or.inl h + · exact Or.inr h + +omit [Fintype ι] in +lemma badWindows_card (e : W×Bool↪ι) (bad : Finset ι) : + (badWindows e bad).card≤((univ.map e)∩bad).card := by + rw [badWindows_image] + have he : (univ.filter (fun z:W×Bool=>e z∈bad)).map e=(univ.map e)∩bad := by + ext i + simp only [mem_map,mem_filter,mem_univ,true_and,mem_inter] + constructor + · rintro ⟨z,h,rfl⟩ + exact ⟨⟨z,rfl⟩,h⟩ + · rintro ⟨⟨z,rfl⟩,h⟩ + exact ⟨z,h,rfl⟩ + calc + _ ≤ (univ.filter (fun z:W×Bool=>e z∈bad)).card := card_image_le + _ = _ := by rw [←he,card_map] + +omit [Fintype W] in +theorem downward_sum [LinearOrder W] (S : Finset W) (early late : W→ℝ) + (lo hi R : ℝ) (hlohi : lo≤hi) (hR : 0≤R) + (hl : ∀ i∈S,lo≤late i) (hh : ∀ i∈S,early i≤hi) + (hcross : ∀ i∈S,∀ j∈S,i simpa using sub_nonneg.mpr hlohi + | @insert i S hmin ih => + have hin : i∉S := by intro h; exact (lt_irrefl i) (hmin i h) + have hli := hl i (mem_insert_self _ _) + have hhi := hh i (mem_insert_self _ _) + have hs := ih (late i+R) (by linarith) + (fun j hj=>hl j (mem_insert_of_mem hj)) + (fun j hj=>hcross i (mem_insert_self _ _) j (mem_insert_of_mem hj) (hmin j hj)) + (fun j hj k hk h=>hcross j (mem_insert_of_mem hj) k (mem_insert_of_mem hk) h) + rw [sum_insert hin,card_insert_of_notMem hin,Nat.cast_add,Nat.cast_one] + linarith + +theorem downward_deleted [LinearOrder W] (S : Finset W) (early late : W→ℝ) + (lo hi R D : ℝ) (hlohi : lo≤hi) (hR : 0≤R) + (hl : ∀ i∈S,lo≤late i) (hh : ∀ i∈S,early i≤hi) + (hcross : ∀ i∈S,∀ j∈S,iDD(mem_filter.mp hi).2.le) + have hsum:=downward_sum T early late lo hi R hlohi hR + (fun i hi=>hl i (mem_filter.mp hi).1) (fun i hi=>hh i (mem_filter.mp hi).1) + (fun i hi j hj hij=>hcross i (mem_filter.mp hi).1 j (mem_filter.mp hj).1 hij) + have hc : (T.card:ℝ) ≤ (Fintype.card W:ℝ) := by exact_mod_cast card_le_univ T + exact hlow.trans (hsum.trans (add_le_add le_rfl + (mul_le_mul_of_nonneg_left hc hR))) + +def goodTargets (target : W×X↪ι) (keep : Finset W) (bad : Finset ι) : Finset ι := + ((keep×ˢ(univ:Finset X)).map target)\bad + +omit [Fintype W] [Fintype ι] in +lemma goodTargets_card (target : W×X↪ι) (keep : Finset W) (bad : Finset ι) : + (keep.card*Fintype.card X)≤(goodTargets target keep bad).card+bad.card := by + have hsub : ((keep×ˢ(univ:Finset X)).map target) ⊆ + goodTargets target keep bad ∪ bad := by + intro i hi + by_cases hb : i∈bad + · exact mem_union_right _ hb + · exact mem_union_left _ (mem_sdiff.mpr ⟨hi,hb⟩) + have h:=card_le_card hsub + have hh : ((keep×ˢ(univ:Finset X)).map target).card≤ + (goodTargets target keep bad).card+bad.card := by + simpa only [goodTargets,add_comm] using h.trans (card_union_le _ _) + simpa only [card_map,card_product,card_univ] using hh + +omit [Fintype ι] in +lemma goodTargets_loss (target : W×X↪ι) (lost : Finset W) (bad : Finset ι) : + Fintype.card W*Fintype.card X≤ + (goodTargets target (univ\lost) bad).card+bad.card+lost.card*Fintype.card X := by + have h:=goodTargets_card target (univ\lost) bad + have hc : (univ\lost).card+lost.card=Fintype.card W := by + simpa using card_sdiff_add_card_eq_card (subset_univ lost) + nlinarith + +end +end SharpLogRamsey.Selection.Windows + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Windows/WindowLayout.lean b/lean/OAI/Combinatorics/SharpRamsey/Windows/WindowLayout.lean new file mode 100644 index 0000000000000000000000000000000000000000..a098a5c45ae9ae6995479e10215bc9112648d600 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Windows/WindowLayout.lean @@ -0,0 +1,109 @@ +import Mathlib + +namespace OAI + +section +namespace SharpLogRamsey.Selection.Windows +open Finset +open scoped Classical BigOperators +noncomputable section + +abbrev Slot (w n : ℕ) := Fin w × Fin (4*n) +abbrev Block (w : ℕ) := Fin w × Bool + +def quarter (n : ℕ) (b : Bool) (x : Fin n) : Fin (4*n) := + if b then ⟨3*n+x.val,by omega⟩ else ⟨x.val,by omega⟩ + +lemma quarter_injective (n : ℕ) : Function.Injective (fun bx : Bool×Fin n=>quarter n bx.1 bx.2) := by + rintro ⟨b,x⟩ ⟨c,y⟩ h + have hv : (quarter n b x).val = (quarter n c y).val := congrArg Fin.val h + cases b <;> cases c <;> simp only [quarter,Bool.false_eq_true,↓reduceIte] at hv + · have hh : x = y := Fin.ext hv + cases hh + rfl + · omega + · omega + · have hh : x = y := Fin.ext (by omega) + cases hh + rfl + +def embedding (w n : ℕ) : Block w × Fin n ↪ Slot w n where + toFun bx := (bx.1.1,quarter n bx.1.2 bx.2) + inj' := by + rintro ⟨⟨i,b⟩,x⟩ ⟨⟨j,c⟩,y⟩ h + have hi : i = j := congrArg Prod.fst h + have hb : (b,x) = (c,y) := quarter_injective n (congrArg Prod.snd h) + cases hi + cases hb + rfl + +def owner (w n : ℕ) (i : Slot w n) : Option (Block w) := + if i.2.val < n then some (i.1,false) else + if 3*n ≤ i.2.val then some (i.1,true) else none + +lemma embedding_owner (w n : ℕ) (b : Block w) (x : Fin n) : + owner w n (embedding w n (b,x))=some b := by + rcases b with ⟨i,b⟩ + cases b + · change (if x.val < n then some (i,false) else + if 3*n ≤ x.val then some (i,true) else none) = some (i,false) + rw [ite_eq_left x.isLt] + · change (if 3*n+x.val < n then some (i,false) else + if 3*n ≤ 3*n+x.val then some (i,true) else none) = some (i,true) + rw [ite_eq_right (by omega),ite_eq_left (by omega)] + +def middle (w n : ℕ) : Fin w × Fin (2*n) ↪ Slot w n where + toFun ix := (ix.1,⟨n+ix.2.val,by omega⟩) + inj' := by + rintro ⟨i,x⟩ ⟨j,y⟩ h + have hi : i = j := congrArg Prod.fst h + have hx : n+x.val = n+y.val := congrArg (fun z:Slot w n=>z.2.val) h + have hxy : x = y := Fin.ext (by omega) + exact Prod.ext hi hxy + +lemma middle_unowned (w n : ℕ) (i : Fin w) (x : Fin (2*n)) : + owner w n (middle w n (i,x))=none := by + change (if n+x.val < n then some (i,false) else + if 3*n ≤ n+x.val then some (i,true) else none) = none + rw [ite_eq_right (by omega),ite_eq_right (by omega)] + +def position {w n : ℕ} (x : Slot w n) : ℕ := x.1.val*(4*n)+x.2.val + +lemma position_injective (w n : ℕ) : Function.Injective (@position w n) := by + rintro ⟨i,x⟩ ⟨j,y⟩ h + have hi : i.val=j.val := by + dsimp [position] at h + have hx:=x.isLt + have hy:=y.isLt + rcases lt_trichotomy i.val j.val with hh|hh|hh + · have : i.val+1 ≤ j.val := by omega + nlinarith + · exact hh + · have : j.val+1 ≤ i.val := by omega + nlinarith + have hxy : x = y := Fin.ext (by dsimp [position] at h; rw [hi] at h; omega) + exact Prod.ext (Fin.ext hi) hxy + +lemma between (w n : ℕ) (i : Fin w) (x y : Fin n) (t : Fin (2*n)) : + position (embedding w n ((i,false),x)) < position (middle w n (i,t)) ∧ + position (middle w n (i,t)) < position (embedding w n ((i,true),y)) := by + change i.val*(4*n)+x.val < i.val*(4*n)+(n+t.val) ∧ + i.val*(4*n)+(n+t.val) < i.val*(4*n)+(3*n+y.val) + constructor <;> omega + +lemma before_next (w n : ℕ) (i j : Fin w) (hij : i < j) (b c : Bool) (x y : Fin n) : + position (embedding w n ((i,b),x)) < position (embedding w n ((j,c),y)) := by + have hix : (quarter n b x).val < 4*n := (quarter n b x).isLt + have hiy : 0 ≤ (quarter n c y).val := Nat.zero_le _ + change i.val*(4*n)+(quarter n b x).val < j.val*(4*n)+(quarter n c y).val + have hi : i.val+1 ≤ j.val := hij + nlinarith + +lemma middle_card (w n : ℕ) : (univ.map (middle w n)).card=w*(2*n) := by simp + +end +end SharpLogRamsey.Selection.Windows + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Windows/WindowPacking.lean b/lean/OAI/Combinatorics/SharpRamsey/Windows/WindowPacking.lean new file mode 100644 index 0000000000000000000000000000000000000000..284cf2182c9e899d13c96d6ae3df304d0b8dd068 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Windows/WindowPacking.lean @@ -0,0 +1,63 @@ +import Mathlib + +namespace OAI + +section +namespace SharpLogRamsey.Selection.Windows +open Real +noncomputable section + +lemma packing_bounds (m L : ℕ) (hL : 0 < L) (hm : 2*L ≤ m) : + 1 ≤ m/L ∧ (m/L)*L ≤ m ∧ (m:ℝ)/2 ≤ ((m/L)*L:ℕ) := by + have hw : 1 ≤ m/L := (Nat.le_div_iff_mul_le hL).mpr (by omega) + have hlt:=Nat.mod_lt m hL + have he:=Nat.mod_add_div m L + have hl:=(Nat.div_mul_le_self m L) + refine ⟨hw,hl,?_⟩ + have hv : m ≤ 2*((m/L)*L) := by + have hh : L ≤ (m/L)*L:=by nlinarith + nlinarith + have hv' : (m:ℝ) ≤ 2*((m/L)*L:ℕ):=by exact_mod_cast hv + linarith + +lemma packing_scales (m L : ℕ) {q σ η D c C : ℝ} + (hq : 0 < q) (hσ : 0 < σ) (_ : 0 < D) (hc : 0 < c) (hC : 0 < C) + (hL : 0 < L) (hm : 2*L ≤ m) + (hmlo : c*q*σ^(1+η) ≤ m) (hmhi : (m:ℝ) ≤ C*q*σ^(1+η)) + (hLlo : q*D*σ^(η/2) ≤ L) (hLhi : (L:ℝ) ≤ C*q*D*σ^(η/2)) : + 1 ≤ m/L ∧ (m/L)*L ≤ m ∧ (m:ℝ)/2 ≤ ((m/L)*L:ℕ) ∧ + (c/(2*C))*σ^(1+η/2) ≤ (m/L:ℕ)*D ∧ + (m/L:ℕ)*D ≤ C*σ^(1+η/2) := by + obtain ⟨hw,hpack,hhalf⟩:=packing_bounds m L hL hm + have hp : 0 < σ^(η/2):=rpow_pos_of_pos hσ _ + have hr : σ^(1+η)=σ^(1+η/2)*σ^(η/2) := by + rw [←rpow_add hσ] + congr 1 + ring + have hqP : 0 < q*σ^(η/2):=mul_pos hq hp + have hw0 : (0:ℝ) ≤ (m/L:ℕ):=Nat.cast_nonneg _ + have hpcast : ((m/L)*L:ℕ)=(m/L:ℕ)*(L:ℝ):=by norm_cast + have hlow : c*q*σ^(1+η) ≤ 2*(m/L:ℕ)*(L:ℝ) := by + rw [hpcast] at hhalf + linarith + have hupp : (m/L:ℕ)*(q*D*σ^(η/2)) ≤ C*q*σ^(1+η) := by + have hpc : (m/L:ℕ)*(L:ℝ) ≤ m:=by exact_mod_cast hpack + exact (mul_le_mul_of_nonneg_left hLlo hw0).trans (hpc.trans hmhi) + have hlarg := hlow.trans (mul_le_mul_of_nonneg_left hLhi (by positivity : (0:ℝ) ≤ 2*(m/L:ℕ))) + rw [hr] at hupp hlarg + have hi : (m/L:ℕ)*D ≤ C*σ^(1+η/2) := by + apply (mul_le_mul_iff_right₀ hqP).mp + nlinarith only [hupp] + have hlo : (c/(2*C))*σ^(1+η/2) ≤ (m/L:ℕ)*D := by + apply (mul_le_mul_iff_right₀ (mul_pos (by positivity : 0 < 2*C) hqP)).mp + have he : (2*C*(q*σ^(η/2)))*((c/(2*C))*σ^(1+η/2))= + c*q*(σ^(1+η/2)*σ^(η/2)) := by field_simp + rw [he] + nlinarith only [hlarg] + exact ⟨hw,hpack,hhalf,hlo,hi⟩ +end +end SharpLogRamsey.Selection.Windows + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpRamsey/Windows/WindowTransport.lean b/lean/OAI/Combinatorics/SharpRamsey/Windows/WindowTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..556ef81066ff1fc50b1667af847a48d4cee5c1dc --- /dev/null +++ b/lean/OAI/Combinatorics/SharpRamsey/Windows/WindowTransport.lean @@ -0,0 +1,83 @@ +import Mathlib +import OAI.Combinatorics.SharpRamsey.Execution.OutputComposition +import OAI.Combinatorics.SharpRamsey.Marking.ClassTransport +import OAI.Combinatorics.SharpRamsey.Windows.PopulationSublist + +namespace OAI + +section +namespace SharpLogRamsey.Selection.Windows +open Finset +open scoped Classical BigOperators +noncomputable section +variable {α Ω Θ : Type} [Fintype Ω] [Fintype Θ] [Fintype α] + +def windowTuple {w n : ℕ} (F : Fin (w*(4*n))→α) : Slot w n→α := + fun i=>F (finProdFinEquiv i) + +omit [Fintype α] in +lemma flatten_window {w n : ℕ} (F : Fin (w*(4*n))→α) : + flattenTuple (windowTuple F)=F := by + funext i + simp only [flattenTuple,windowTuple,Equiv.apply_symm_apply] + +lemma window_entropy {w n : ℕ} (p : Law Ω) (F : Ω→Fin (w*(4*n))→α) : + entropy (p.map (fun x=>windowTuple (F x)))=entropy (p.map F) := by + rw [show (fun x=>windowTuple (F x))=windowTuple∘F from rfl,←Law.map_map] + apply entropy_map_eq_of_injective + intro f g h + funext i + have hh:=congrFun h (finProdFinEquiv.symm i) + simpa only [windowTuple,Equiv.apply_symm_apply] using hh + +end +end SharpLogRamsey.Selection.Windows + +namespace SharpLogRamsey.Marking +open Finset Selection Selection.Windows ReciprocalBands +open scoped Classical BigOperators +noncomputable section +variable {K V Ω Θ : Type} [Field K] [Finite K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] [Fintype Ω] [Fintype Θ] + [Fintype (Projectivization K V)] [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] + +omit [Fintype Θ] [Finite K] [FiniteDimensional K V] [Fintype (Projectivization K V)] + [Fintype (Projectivization K (Module.Dual K V))] + [Fintype (Projectivization K (Module.Dual K (Module.Dual K V)))] in + +theorem reciprocal_parameters {N d : ℕ} (p : Law Ω) (θ : Ω→Θ) + (S : Θ→Fin N→Finset (ProjectivePair (K:=K) (V:=V))) + (integer : Bool) (r : Fin (d+1)) (gap : ℝ) (hN : 0if h : ValidSlotClass d gap (S z i) (.inl (integer,r)) then + (covectorDomain_reciprocal (S z i) integer r h).2.2.choose else 0 + · intro x hx i + simp only [dite_eq_left (hclass x hx i)] + have huv:=(covectorDomain_reciprocal (S (θ x) i) integer r (hclass x hx i)).2.2.choose_spec + refine ⟨huv.2.2.1,huv.2.2.2.1,?_⟩ + cases integer <;> simp only [Bool.false_eq_true,ite_false,ite_true] at huv ⊢ + · exact huv.2.2.2.2.2 + · exact huv.2.2.2.2 +end +end SharpLogRamsey.Marking + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/BlockAverage.lean b/lean/OAI/Combinatorics/SharpThreshold/BlockAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..15133328b8d7b63ecd6feab80d85fd104d53366f --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/BlockAverage.lean @@ -0,0 +1,185 @@ +import Mathlib + +namespace OAI + +universe u v w + +noncomputable section + +namespace Problem313.BlockAverage + +open scoped BigOperators + +/-- Exchange the average over blocks with a sum over objects detected by a block. -/ +theorem weighted_incidence_sum + {α : Type u} {β : Type v} [Fintype α] [Fintype β] + (μ : β → ℝ) (w : α → ℝ) (P : β → α → Prop) + [DecidableRel P] : + (∑ b, μ b * ∑ s, if P b s then w s else 0) = + ∑ s, (∑ b, if P b s then μ b else 0) * w s := by + simp_rw [Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro s hs + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro b hb + by_cases h : P b s <;> simp [h] + +/-- Nonnegative block weights give nonnegative incidence probabilities. -/ +theorem incidence_sum_nonneg + {β : Type v} [Fintype β] (μ : β → ℝ) (P : β → Prop) + [DecidablePred P] (hμ : ∀ b, 0 ≤ μ b) : + 0 ≤ ∑ b, if P b then μ b else 0 := by + apply Finset.sum_nonneg + intro b hb + split_ifs + · exact hμ b + · exact le_rfl + +/-- A collection of nonnegative masses detected with probability at least `c` +contributes at least `c` times its total mass to the average detected mass. -/ +theorem capture_lower_bound + {α : Type u} {β : Type v} [Fintype α] [Fintype β] + (μ : β → ℝ) (w : α → ℝ) (P : β → α → Prop) + [DecidableRel P] (low : Finset α) (c : ℝ) + (hμ : ∀ b, 0 ≤ μ b) (hw : ∀ s, 0 ≤ w s) + (hcapture : ∀ s ∈ low, c ≤ ∑ b, if P b s then μ b else 0) : + c * ∑ s ∈ low, w s ≤ ∑ b, μ b * ∑ s, if P b s then w s else 0 := by + rw [weighted_incidence_sum, Finset.mul_sum] + calc + ∑ s ∈ low, c * w s ≤ + ∑ s ∈ low, (∑ b, if P b s then μ b else 0) * w s := by + apply Finset.sum_le_sum + intro s hs + exact mul_le_mul_of_nonneg_right (hcapture s hs) (hw s) + _ ≤ ∑ s, (∑ b, if P b s then μ b else 0) * w s := by + apply Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ low) + intro s hs hnot + exact mul_nonneg (incidence_sum_nonneg μ (fun b => P b s) hμ) (hw s) + +/-- Pointwise block bounds average to a global bound using the incidence +probability of each coordinate. No normalization assumption is required. -/ +theorem block_upper_bound + {α : Type u} {β : Type v} {ι : Type w} [Fintype α] [Fintype β] [Fintype ι] + (μ : β → ℝ) (w : α → ℝ) (I : ι → ℝ) + (P : β → α → Prop) (E : β → ι → Prop) + [DecidableRel P] [DecidableRel E] (a d : ℝ) + (hμ : ∀ b, 0 ≤ μ b) (hI : ∀ i, 0 ≤ I i) (ha : 0 ≤ a) + (hblock : ∀ b, (∑ s, if P b s then w s else 0) ≤ + a * ∑ i, if E b i then I i else 0) + (hincidence : ∀ i, (∑ b, if E b i then μ b else 0) ≤ d) : + (∑ b, μ b * ∑ s, if P b s then w s else 0) ≤ a * d * ∑ i, I i := by + calc + (∑ b, μ b * ∑ s, if P b s then w s else 0) ≤ + ∑ b, μ b * (a * ∑ i, if E b i then I i else 0) := by + apply Finset.sum_le_sum + intro b hb + exact mul_le_mul_of_nonneg_left (hblock b) (hμ b) + _ = a * ∑ b, μ b * ∑ i, if E b i then I i else 0 := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro b hb + ring + _ = a * ∑ i, (∑ b, if E b i then μ b else 0) * I i := by + rw [weighted_incidence_sum] + _ ≤ a * ∑ i, d * I i := by + apply mul_le_mul_of_nonneg_left _ ha + apply Finset.sum_le_sum + intro i hi + exact mul_le_mul_of_nonneg_right (hincidence i) (hI i) + _ = a * d * ∑ i, I i := by rw [← Finset.mul_sum]; ring + +/-- The algebraic block-capture argument, with arbitrary capture and incidence +constants. It separates all finite averaging from the Fourier and graph input. -/ +theorem captured_mass_le + {α : Type u} {β : Type v} {ι : Type w} [Fintype α] [Fintype β] [Fintype ι] + (μ : β → ℝ) (w : α → ℝ) (I : ι → ℝ) + (P : β → α → Prop) (E : β → ι → Prop) + [DecidableRel P] [DecidableRel E] (low : Finset α) (a c d : ℝ) + (hμ : ∀ b, 0 ≤ μ b) (hw : ∀ s, 0 ≤ w s) + (hI : ∀ i, 0 ≤ I i) (ha : 0 ≤ a) (hc : 0 < c) + (hcapture : ∀ s ∈ low, c ≤ ∑ b, if P b s then μ b else 0) + (hblock : ∀ b, (∑ s, if P b s then w s else 0) ≤ + a * ∑ i, if E b i then I i else 0) + (hincidence : ∀ i, (∑ b, if E b i then μ b else 0) ≤ d) : + (∑ s ∈ low, w s) ≤ (a * d / c) * ∑ i, I i := by + have hlow := capture_lower_bound μ w P low c hμ hw hcapture + have hupp := block_upper_bound μ w I P E a d hμ hI ha hblock hincidence + have hcombined := hlow.trans hupp + apply (mul_le_mul_iff_right₀ hc).mp + calc + c * ∑ s ∈ low, w s ≤ a * d * ∑ i, I i := hcombined + _ = c * ((a * d / c) * ∑ i, I i) := by field_simp [ne_of_gt hc] + +/-- The factor-four consequence used for uniform vertex blocks: +capture at least `m/(2*n)` and edge incidence at most `2*m/n`. -/ +theorem captured_mass_le_four + {α : Type u} {β : Type v} {ι : Type w} [Fintype α] [Fintype β] [Fintype ι] + (μ : β → ℝ) (w : α → ℝ) (I : ι → ℝ) + (P : β → α → Prop) (E : β → ι → Prop) + [DecidableRel P] [DecidableRel E] (low : Finset α) (a c : ℝ) + (hμ : ∀ b, 0 ≤ μ b) (hw : ∀ s, 0 ≤ w s) + (hI : ∀ i, 0 ≤ I i) (ha : 0 ≤ a) (hc : 0 < c) + (hcapture : ∀ s ∈ low, c ≤ ∑ b, if P b s then μ b else 0) + (hblock : ∀ b, (∑ s, if P b s then w s else 0) ≤ + a * ∑ i, if E b i then I i else 0) + (hincidence : ∀ i, (∑ b, if E b i then μ b else 0) ≤ 4 * c) : + (∑ s ∈ low, w s) ≤ 4 * a * ∑ i, I i := by + have h := captured_mass_le μ w I P E low a c (4 * c) + hμ hw hI ha hc hcapture hblock hincidence + have hc0 : c ≠ 0 := ne_of_gt hc + have heq : a * (4 * c) / c = 4 * a := by field_simp [ne_of_gt hc] + simpa only [heq] using h + +/-- Uniform finite sampling agrees with the normalized cardinality used by the +vertex-block counting lemmas. This also holds for an empty sampling family. -/ +theorem uniform_incidence_sum + {β : Type v} [DecidableEq β] (Ω : Finset β) (P : β → Prop) + [DecidablePred P] : + (∑ b : Ω, if P b.val then (1 : ℝ) / Ω.card else 0) = + ((Ω.filter P).card : ℝ) / Ω.card := by + rw [← Finset.sum_subtype Ω (fun _ => Iff.rfl) + (fun b => if P b then (1 : ℝ) / Ω.card else 0)] + rw [← Finset.sum_filter] + simp [div_eq_mul_inv] + +/-- Uniform-block version of the factor-four capture argument, stated entirely +with cardinal-ratio probabilities to match the combinatorial counting API. -/ +theorem captured_mass_le_four_uniform + {α : Type u} {β : Type v} {ι : Type w} [Fintype α] [DecidableEq β] [Fintype ι] + (Ω : Finset β) (w : α → ℝ) (I : ι → ℝ) + (P : β → α → Prop) (E : β → ι → Prop) + [DecidableRel P] [DecidableRel E] (low : Finset α) (a c : ℝ) + (hw : ∀ s, 0 ≤ w s) (hI : ∀ i, 0 ≤ I i) + (ha : 0 ≤ a) (hc : 0 < c) + (hcapture : ∀ s ∈ low, c ≤ + ((Ω.filter (fun b => P b s)).card : ℝ) / Ω.card) + (hblock : ∀ b ∈ Ω, (∑ s, if P b s then w s else 0) ≤ + a * ∑ i, if E b i then I i else 0) + (hincidence : ∀ i, + ((Ω.filter (fun b => E b i)).card : ℝ) / Ω.card ≤ 4 * c) : + (∑ s ∈ low, w s) ≤ 4 * a * ∑ i, I i := by + apply captured_mass_le_four + (fun _ : Ω => (1 : ℝ) / Ω.card) w I + (fun b s => P b.val s) (fun b i => E b.val i) low a c + · intro b + positivity + · exact hw + · exact hI + · exact ha + · exact hc + · intro s hs + rw [uniform_incidence_sum Ω (fun b => P b s)] + exact hcapture s hs + · intro b + exact hblock b.val b.property + · intro i + rw [uniform_incidence_sum Ω (fun b => E b i)] + exact hincidence i + +end Problem313.BlockAverage + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/BlockCapture.lean b/lean/OAI/Combinatorics/SharpThreshold/BlockCapture.lean new file mode 100644 index 0000000000000000000000000000000000000000..8cd8b5ebd1de7c2d6f8e145e5cdb1e64465d2b87 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/BlockCapture.lean @@ -0,0 +1,91 @@ +import Mathlib + +namespace OAI + +universe u v + +/-! +# Averaging and capture of nonnegative spectral mass + +For any finite family of nonnegative masses and random detection events, +if every low-degree support is detected with probability at least `a`, an +upper bound on the average detected mass bounds the low-degree mass. +-/ + +namespace Problem313 + +open scoped BigOperators + +section FiniteCapture + +variable {ι : Type u} {β : Type v} [Fintype ι] [Fintype β] + +/-- Interchange averaging over blocks and summing the mass of captured supports. -/ +theorem weighted_capture_sum_swap + (w : β → ℝ) (mass : ι → ℝ) (detect : β → ι → Prop) + [DecidableRel detect] : + (∑ b, w b * ∑ i, if detect b i then mass i else 0) = + ∑ i, (∑ b, if detect b i then w b else 0) * mass i := by + simp_rw [Finset.mul_sum, Finset.sum_mul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro i hi + apply Finset.sum_congr rfl + intro b hb + split_ifs <;> simp + +/-- A pointwise detection lower bound controls the mass on any chosen finite set. -/ +theorem capture_mass_mul_le + (low : Finset ι) (mass detection : ι → ℝ) (a : ℝ) + (hmass : ∀ i, 0 ≤ mass i) (hdet : ∀ i, 0 ≤ detection i) + (hlow : ∀ i ∈ low, a ≤ detection i) : + a * ∑ i ∈ low, mass i ≤ ∑ i, detection i * mass i := by + rw [Finset.mul_sum] + calc + ∑ i ∈ low, a * mass i ≤ ∑ i ∈ low, detection i * mass i := by + exact Finset.sum_le_sum fun i hi => mul_le_mul_of_nonneg_right (hlow i hi) (hmass i) + _ ≤ ∑ i, detection i * mass i := by + exact Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ low) + (fun i hi hnot => mul_nonneg (hdet i) (hmass i)) + +/-- The same capture inequality stated directly with finite block averaging. -/ +theorem averaged_capture_mass_mul_le + (low : Finset ι) (w : β → ℝ) (mass : ι → ℝ) + (detect : β → ι → Prop) [DecidableRel detect] (a : ℝ) + (hw : ∀ b, 0 ≤ w b) (hmass : ∀ i, 0 ≤ mass i) + (hlow : ∀ i ∈ low, a ≤ ∑ b, if detect b i then w b else 0) : + a * ∑ i ∈ low, mass i ≤ + ∑ b, w b * ∑ i, if detect b i then mass i else 0 := by + rw [weighted_capture_sum_swap] + apply capture_mass_mul_le low mass _ a hmass + · intro i + apply Finset.sum_nonneg + intro b hb + split_ifs + · exact hw b + · exact le_rfl + · exact hlow + +/-- Cancel the random-block detection factor. The factor `4` is exactly the +ratio between the edge-touch upper bound `2*m/n` and detection `m/(2*n)`. -/ +theorem block_capture_mass_le + (low : Finset ι) (w : β → ℝ) (mass : ι → ℝ) + (detect : β → ι → Prop) [DecidableRel detect] + (m n Q : ℝ) (hm : 0 < m) (hn : 0 < n) + (hw : ∀ b, 0 ≤ w b) (hmass : ∀ i, 0 ≤ mass i) + (hlow : ∀ i ∈ low, m / (2 * n) ≤ ∑ b, if detect b i then w b else 0) + (haverage : (∑ b, w b * ∑ i, if detect b i then mass i else 0) ≤ + (2 * m / n) * Q) : + (∑ i ∈ low, mass i) ≤ 4 * Q := by + have ha : 0 < m / (2 * n) := div_pos hm (mul_pos (by norm_num) hn) + have h := (averaged_capture_mass_mul_le low w mass detect (m / (2 * n)) + hw hmass hlow).trans haverage + have heq : (2 * m / n) * Q = (m / (2 * n)) * (4 * Q) := by ring + rw [heq] at h + exact (mul_le_mul_iff_right₀ ha).mp h + +end FiniteCapture + +end Problem313 + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/BlockCounting.lean b/lean/OAI/Combinatorics/SharpThreshold/BlockCounting.lean new file mode 100644 index 0000000000000000000000000000000000000000..b898c5e33b12ed5da0e9c6e89ea56102fd10ffd1 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/BlockCounting.lean @@ -0,0 +1,268 @@ +import Mathlib + +namespace OAI + +universe u + +noncomputable section + +namespace Problem313 + +open Finset + +variable {α : Type u} [DecidableEq α] + +/-- Probability of an event for a uniformly chosen fixed-size subset. -/ +def blockProbability (U : Finset α) (m : ℕ) (P : Finset α → Prop) : ℝ := by + classical + exact (((U.powersetCard m).filter P).card : ℝ) / (U.powersetCard m).card + +omit [DecidableEq α] in +theorem blockProbability_eq (U : Finset α) (m : ℕ) (P : Finset α → Prop) + [DecidablePred P] : blockProbability U m P = + (((U.powersetCard m).filter P).card : ℝ) / (U.powersetCard m).card := by + unfold blockProbability + congr + +omit [DecidableEq α] in +theorem blockProbability_nonneg (U : Finset α) (m : ℕ) (P : Finset α → Prop) : + 0 ≤ blockProbability U m P := by + unfold blockProbability + positivity + +omit [DecidableEq α] in +theorem blockProbability_mono (U : Finset α) (m : ℕ) + {P Q : Finset α → Prop} + (hPQ : ∀ B ∈ U.powersetCard m, P B → Q B) : + blockProbability U m P ≤ blockProbability U m Q := by + classical + unfold blockProbability + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) + exact_mod_cast Finset.card_le_card (show (U.powersetCard m).filter P ⊆ + (U.powersetCard m).filter Q from by + intro B hB + obtain ⟨hB, hP⟩ := Finset.mem_filter.mp hB + exact Finset.mem_filter.mpr ⟨hB, hPQ B hB hP⟩) + +theorem blockProbability_mem_count (U : Finset α) {m : ℕ} {u : α} + (hu : u ∈ U) (hm : 1 ≤ m) : + ((U.powersetCard m).filter (fun B => u ∈ B)).card = + (U.card - 1).choose (m - 1) := by + classical + simpa using Finset.card_filter_powersetCard_subset {u} U m + (Finset.singleton_subset_iff.mpr hu) (by simpa using hm) + +theorem choose_pred_ratio {n m : ℕ} (hm : 1 ≤ m) (hmn : m ≤ n) : + ((n - 1).choose (m - 1) : ℝ) / n.choose m = (m : ℝ) / n := by + have hn : 1 ≤ n := hm.trans hmn + have hchoose : (n.choose m : ℝ) ≠ 0 := by + exact_mod_cast (Nat.choose_pos hmn).ne' + have hn0 : (n : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt hn) + have hid := Nat.add_one_mul_choose_eq (n - 1) (m - 1) + rw [Nat.sub_add_cancel hn, Nat.sub_add_cancel hm] at hid + have hid' : (n : ℝ) * ((n - 1).choose (m - 1) : ℝ) = + (n.choose m : ℝ) * m := by exact_mod_cast hid + apply (div_eq_div_iff hchoose hn0).mpr + nlinarith + +theorem blockProbability_mem (U : Finset α) {m : ℕ} {u : α} + (hu : u ∈ U) (hm : 1 ≤ m) (hmn : m ≤ U.card) : + blockProbability U m (fun B => u ∈ B) = (m : ℝ) / U.card := by + classical + rw [blockProbability_eq, blockProbability_mem_count U hu hm, Finset.card_powersetCard] + exact choose_pred_ratio hm hmn + +theorem blockProbability_pair_count (U : Finset α) {m : ℕ} {u v : α} + (hu : u ∈ U) (hv : v ∈ U) (huv : u ≠ v) (hm : 2 ≤ m) : + ((U.powersetCard m).filter (fun B => u ∈ B ∧ v ∈ B)).card = + (U.card - 2).choose (m - 2) := by + simpa [huv, Finset.insert_subset_iff, Finset.singleton_subset_iff] using Finset.card_filter_powersetCard_subset {u, v} U m + (by simp only [Finset.insert_subset_iff, Finset.singleton_subset_iff]; exact ⟨hu, hv⟩) (by simpa [huv] using hm) + +theorem choose_two_pred_ratio {n m : ℕ} (hm : 2 ≤ m) (hmn : m ≤ n) : + ((n - 2).choose (m - 2) : ℝ) / n.choose m = + (m : ℝ) / n * ((m : ℝ) - 1) / ((n : ℝ) - 1) := by + have hm1 : 1 ≤ m := by omega + have hn1 : 1 ≤ n := hm1.trans hmn + have hmid : ((n - 1).choose (m - 1) : ℝ) ≠ 0 := by + exact_mod_cast (Nat.choose_pos (show m - 1 ≤ n - 1 by omega)).ne' + calc + ((n - 2).choose (m - 2) : ℝ) / n.choose m = + (((n - 1 - 1).choose (m - 1 - 1) : ℝ) / (n - 1).choose (m - 1)) * + (((n - 1).choose (m - 1) : ℝ) / n.choose m) := by + simp only [Nat.sub_sub]; norm_num only at * + field_simp + _ = ((m - 1 : ℕ) : ℝ) / (n - 1 : ℕ) * ((m : ℝ) / n) := by + rw [choose_pred_ratio (by omega : 1 ≤ m - 1) (by omega : m - 1 ≤ n - 1), + choose_pred_ratio hm1 hmn] + _ = _ := by + rw [Nat.cast_sub hm1, Nat.cast_sub hn1] + push_cast + ring + +theorem blockProbability_pair (U : Finset α) {m : ℕ} {u v : α} + (hu : u ∈ U) (hv : v ∈ U) (huv : u ≠ v) (hm : 2 ≤ m) + (hmn : m ≤ U.card) : + blockProbability U m (fun B => u ∈ B ∧ v ∈ B) = + (m : ℝ) / U.card * ((m : ℝ) - 1) / ((U.card : ℝ) - 1) := by + classical + rw [blockProbability_eq, blockProbability_pair_count U hu hv huv hm, + Finset.card_powersetCard] + exact choose_two_pred_ratio hm hmn + +omit [DecidableEq α] in +theorem blockProbability_congr (U : Finset α) (m : ℕ) + {P Q : Finset α → Prop} + (hPQ : ∀ B ∈ U.powersetCard m, P B ↔ Q B) : + blockProbability U m P = blockProbability U m Q := by + apply le_antisymm + · exact blockProbability_mono U m (fun B hB => (hPQ B hB).mp) + · exact blockProbability_mono U m (fun B hB => (hPQ B hB).mpr) + +omit [DecidableEq α] in +@[simp] theorem blockProbability_false (U : Finset α) (m : ℕ) : + blockProbability U m (fun _ => False) = 0 := by + simp [blockProbability] + +theorem blockProbability_or_le (U : Finset α) (m : ℕ) + (P Q : Finset α → Prop) : + blockProbability U m (fun B => P B ∨ Q B) ≤ + blockProbability U m P + blockProbability U m Q := by + classical + simp only [blockProbability_eq, Finset.filter_or] + rw [← add_div] + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) + exact_mod_cast Finset.card_union_le ((U.powersetCard m).filter P) + ((U.powersetCard m).filter Q) + +theorem blockProbability_exists_le (U : Finset α) (m : ℕ) + (V : Finset α) (P : α → Finset α → Prop) : + blockProbability U m (fun B => ∃ v ∈ V, P v B) ≤ + ∑ v ∈ V, blockProbability U m (P v) := by + classical + induction V using Finset.induction_on with + | empty => simp + | @insert v V hv ih => + have hcongr : blockProbability U m (fun B => ∃ w ∈ insert v V, P w B) = + blockProbability U m (fun B => P v B ∨ ∃ w ∈ V, P w B) := by + apply blockProbability_congr + intro B hB + simp + rw [hcongr, Finset.sum_insert hv] + exact (blockProbability_or_le U m _ _).trans (add_le_add le_rfl ih) + +theorem blockProbability_avoid_ge (U : Finset α) (m : ℕ) + (V : Finset α) (P : Finset α → Prop) (Q : α → Finset α → Prop) : + blockProbability U m P - ∑ v ∈ V, blockProbability U m (fun B => P B ∧ Q v B) ≤ + blockProbability U m (fun B => P B ∧ ∀ v ∈ V, ¬ Q v B) := by + classical + have hcover : blockProbability U m P ≤ + blockProbability U m (fun B => (P B ∧ ∀ v ∈ V, ¬ Q v B) ∨ + ∃ v ∈ V, P B ∧ Q v B) := by + apply blockProbability_mono + intro B hB hP + by_cases h : ∀ v ∈ V, ¬ Q v B + · exact Or.inl ⟨hP, h⟩ + · push Not at h + obtain ⟨v, hv, hQ⟩ := h + exact Or.inr ⟨v, hv, hP, hQ⟩ + have hbound := hcover.trans ((blockProbability_or_le U m _ _).trans + (add_le_add le_rfl (blockProbability_exists_le U m V (fun v B => P B ∧ Q v B)))) + linarith + +theorem inter_eq_singleton_iff_mem_avoid (B V : Finset α) {u : α} (hu : u ∈ V) : + B ∩ V = {u} ↔ u ∈ B ∧ ∀ v ∈ V.erase u, v ∉ B := by + constructor + · intro h + constructor + · have hmem : u ∈ B ∩ V := by rw [h]; simp + exact (Finset.mem_inter.mp hmem).1 + · intro v hv hvB + have hvV := (Finset.mem_erase.mp hv).2 + have hmem : v ∈ B ∩ V := Finset.mem_inter.mpr ⟨hvB, hvV⟩ + rw [h, Finset.mem_singleton] at hmem + exact (Finset.mem_erase.mp hv).1 hmem + · rintro ⟨huB, havoid⟩ + ext v + simp only [Finset.mem_inter, Finset.mem_singleton] + constructor + · rintro ⟨hvB, hvV⟩ + by_contra hvu + exact havoid v (Finset.mem_erase.mpr ⟨hvu, hvV⟩) hvB + · rintro rfl + exact ⟨huB, hu⟩ + +/-- A union bound conditioned on containing a specified vertex. -/ +theorem blockProbability_singleton_inter_ge (U V : Finset α) {m : ℕ} {u : α} + (hVU : V ⊆ U) (hu : u ∈ V) (hm : 2 ≤ m) (hmn : m ≤ U.card) : + (m : ℝ) / U.card * + (1 - ((V.card : ℝ) - 1) * ((m : ℝ) - 1) / ((U.card : ℝ) - 1)) ≤ + blockProbability U m (fun B => B ∩ V = {u}) := by + classical + have h := blockProbability_avoid_ge U m (V.erase u) (fun B => u ∈ B) + (fun v B => v ∈ B) + have hevent : blockProbability U m (fun B => u ∈ B ∧ ∀ v ∈ V.erase u, v ∉ B) = + blockProbability U m (fun B => B ∩ V = {u}) := by + apply blockProbability_congr + intro B hB + exact (inter_eq_singleton_iff_mem_avoid B V hu).symm + rw [hevent, blockProbability_mem U (hVU hu) (by omega) hmn] at h + have hsum : (∑ v ∈ V.erase u, blockProbability U m (fun B => u ∈ B ∧ v ∈ B)) = + ((V.card : ℝ) - 1) * + ((m : ℝ) / U.card * ((m : ℝ) - 1) / ((U.card : ℝ) - 1)) := by + calc + _ = ∑ _v ∈ V.erase u, + ((m : ℝ) / U.card * ((m : ℝ) - 1) / ((U.card : ℝ) - 1)) := by + apply Finset.sum_congr rfl + intro v hv + exact blockProbability_pair U (hVU hu) (hVU (Finset.mem_erase.mp hv).2) + (Ne.symm (Finset.mem_erase.mp hv).1) hm hmn + _ = _ := by + simp only [Finset.sum_const, nsmul_eq_mul, Finset.card_erase_of_mem hu] + rw [Nat.cast_sub (Finset.one_le_card.mpr ⟨u, hu⟩)] + norm_num + rw [hsum] at h + convert h using 1; ring + +/-- At most the sum of the individual inclusion probabilities can touch a fixed set. -/ +theorem blockProbability_inter_nonempty_le (U E : Finset α) {m : ℕ} + (hEU : E ⊆ U) (hm : 1 ≤ m) (hmn : m ≤ U.card) : + blockProbability U m (fun B => (B ∩ E).Nonempty) ≤ + (E.card : ℝ) * m / U.card := by + classical + calc + _ = blockProbability U m (fun B => ∃ v ∈ E, v ∈ B) := by + apply blockProbability_congr + intro B hB + simp only [Finset.Nonempty, Finset.mem_inter] + aesop + _ ≤ ∑ v ∈ E, blockProbability U m (fun B => v ∈ B) := + blockProbability_exists_le U m E (fun v B => v ∈ B) + _ = ∑ _v ∈ E, (m : ℝ) / U.card := by + apply Finset.sum_congr rfl + intro v hv + exact blockProbability_mem U (hEU hv) hm hmn + _ = _ := by simp [nsmul_eq_mul, mul_div_assoc] + +/-- The graph-edge touch bound used when averaging the block restriction. -/ +theorem blockProbability_edge_touch_le (U E : Finset α) {m : ℕ} + (hEU : E ⊆ U) (hE : E.card = 2) (hm : 1 ≤ m) (hmn : m ≤ U.card) : + blockProbability U m (fun B => (B ∩ E).Nonempty) ≤ (2 : ℝ) * m / U.card := by + simpa [hE] using blockProbability_inter_nonempty_le U E hEU hm hmn + +/-- Collision estimate reduced to a half yields the usual capture lower bound. -/ +theorem blockProbability_singleton_inter_ge_half (U V : Finset α) {m : ℕ} {u : α} + (hVU : V ⊆ U) (hu : u ∈ V) (hm : 2 ≤ m) (hmn : m ≤ U.card) + (hcollision : ((V.card : ℝ) - 1) * ((m : ℝ) - 1) / ((U.card : ℝ) - 1) ≤ 1 / 2) : + (m : ℝ) / (2 * U.card) ≤ blockProbability U m (fun B => B ∩ V = {u}) := by + have hn : 0 ≤ (m : ℝ) / U.card := div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _) + apply le_trans _ (blockProbability_singleton_inter_ge U V hVU hu hm hmn) + calc + (m : ℝ) / (2 * U.card) = ((m : ℝ) / U.card) * (1 / 2) := by ring + _ ≤ _ := mul_le_mul_of_nonneg_left (by linarith) hn + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/BlockIncidence.lean b/lean/OAI/Combinatorics/SharpThreshold/BlockIncidence.lean new file mode 100644 index 0000000000000000000000000000000000000000..534e7cd2b70468c53a6db60eccc24df046e08d75 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/BlockIncidence.lean @@ -0,0 +1,96 @@ +import OAI.Combinatorics.SharpThreshold.Model + +namespace OAI + +noncomputable section + +namespace Problem313 + +/-- If a block meets the vertex support in one vertex, precisely that vertex's +incident support edges survive restriction to the block. -/ +theorem block_filter_eq_vertex_filter {n : ℕ} + (S : Finset (GraphEdge n)) (B : Finset (Fin n)) (u : Fin n) + (h : B ∩ S.biUnion (fun e => e.val) = {u}) : + S.filter (fun e => (e.val ∩ B).Nonempty) = + S.filter (fun e => u ∈ e.val) := by + classical + ext e + simp only [Finset.mem_filter] + constructor + · rintro ⟨he, v, hv⟩ + have hvB : v ∈ B := (Finset.mem_inter.mp hv).2 + have hvE : v ∈ e.val := (Finset.mem_inter.mp hv).1 + have hvS : v ∈ S.biUnion (fun e => e.val) := + Finset.mem_biUnion.mpr ⟨e, he, hvE⟩ + have hvu : v = u := by + have : v ∈ ({u} : Finset (Fin n)) := h ▸ Finset.mem_inter.mpr ⟨hvB, hvS⟩ + exact Finset.mem_singleton.mp this + exact ⟨he, hvu ▸ hvE⟩ + · rintro ⟨he, huE⟩ + have hu : u ∈ B ∩ S.biUnion (fun e => e.val) := by rw [h]; simp + exact ⟨he, u, Finset.mem_inter.mpr ⟨huE, (Finset.mem_inter.mp hu).1⟩⟩ + +/-- Cardinal version of deterministic capture by a singleton vertex intersection. -/ +theorem block_filter_card_eq_vertex_degree {n : ℕ} + (S : Finset (GraphEdge n)) (B : Finset (Fin n)) (u : Fin n) + (h : B ∩ S.biUnion (fun e => e.val) = {u}) : + (S.filter (fun e => (e.val ∩ B).Nonempty)).card = + (S.filter (fun e => u ∈ e.val)).card := by + rw [block_filter_eq_vertex_filter S B u h] + +/-- The singleton-intersection event detects every support with a vertex +of degree between one and the requested cutoff. -/ +theorem block_captures_of_singleton_inter {n : ℕ} + (S : Finset (GraphEdge n)) (B : Finset (Fin n)) (u : Fin n) (k : ℝ) + (h : B ∩ S.biUnion (fun e => e.val) = {u}) + (hpos : 1 ≤ (S.filter (fun e => u ∈ e.val)).card) + (hdeg : ((S.filter (fun e => u ∈ e.val)).card : ℝ) ≤ k) : + 1 ≤ (S.filter (fun e => (e.val ∩ B).Nonempty)).card ∧ + ((S.filter (fun e => (e.val ∩ B).Nonempty)).card : ℝ) ≤ k := by + rw [block_filter_card_eq_vertex_degree S B u h] + exact ⟨hpos, hdeg⟩ + +/-- The same capture identity with the disjointness predicate used for free edges. -/ +theorem block_not_disjoint_filter_eq_vertex_filter {n : ℕ} + (S : Finset (GraphEdge n)) (B : Finset (Fin n)) (u : Fin n) + (h : B ∩ S.biUnion (fun e => e.val) = {u}) : + S.filter (fun e => ¬Disjoint e.val B) = + S.filter (fun e => u ∈ e.val) := by + classical + simpa only [Finset.not_disjoint_iff, Finset.Nonempty, Finset.mem_inter] using + block_filter_eq_vertex_filter S B u h + +/-- The free-edge intersection formulation of deterministic block capture. -/ +theorem block_inter_free_edges_eq_vertex_filter {n : ℕ} + (S : Finset (GraphEdge n)) (B : Finset (Fin n)) (u : Fin n) + (h : B ∩ S.biUnion (fun e => e.val) = {u}) : + S ∩ Finset.univ.filter (fun e : GraphEdge n => ¬Disjoint e.val B) = + S.filter (fun e => u ∈ e.val) := by + classical + rw [← block_not_disjoint_filter_eq_vertex_filter S B u h] + ext e + simp + +/-- Counting singleton-intersection blocks gives a lower bound for counting +blocks that capture the support in the desired degree range. -/ +theorem count_capturing_blocks_ge_singleton_inter {n : ℕ} + (S : Finset (GraphEdge n)) (blocks : Finset (Finset (Fin n))) + (u : Fin n) (k : ℝ) + (hpos : 1 ≤ (S.filter (fun e => u ∈ e.val)).card) + (hdeg : ((S.filter (fun e => u ∈ e.val)).card : ℝ) ≤ k) : + (blocks.filter (fun B => B ∩ S.biUnion (fun e => e.val) = {u})).card ≤ + (blocks.filter (fun B => + 1 ≤ (S.filter (fun e => (e.val ∩ B).Nonempty)).card ∧ + ((S.filter (fun e => (e.val ∩ B).Nonempty)).card : ℝ) ≤ k)).card := by + classical + apply Finset.card_le_card + intro B hB + obtain ⟨hmem, hsingle⟩ := Finset.mem_filter.mp hB + exact Finset.mem_filter.mpr + ⟨hmem, block_captures_of_singleton_inter S B u k hsingle hpos hdeg⟩ + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/BlockInfluence.lean b/lean/OAI/Combinatorics/SharpThreshold/BlockInfluence.lean new file mode 100644 index 0000000000000000000000000000000000000000..da386fd0e54b447c6df7a2af9059e051ff1b69c7 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/BlockInfluence.lean @@ -0,0 +1,94 @@ +import OAI.Combinatorics.SharpThreshold.BlockSymmetry +import OAI.Combinatorics.SharpThreshold.InfluenceReindex +import OAI.Combinatorics.SharpThreshold.BlockRestrictionSymmetry +import OAI.Combinatorics.SharpThreshold.Permutation +import OAI.Combinatorics.SharpThreshold.BlockOrbitSubtype + +namespace OAI + +universe u + +noncomputable section + +namespace Problem313 + +/-- Pivotal influences of a conditioned function are invariant under every +coordinate permutation that preserves the free set and fixes its complement. -/ +theorem restrictCube_influence_reindex {α : Type u} [Fintype α] + (P : α → Prop) [DecidablePred P] + (π : Equiv.Perm α) (hP : ∀ i, P i ↔ P (π i)) + (hfix : ∀ i, ¬ P i → π i = i) (f : (α → Bool) → Bool) + (hf : ∀ z, f (fun i => z (π.symm i)) = f z) + (p : ℝ) (y : {i // ¬ P i} → Bool) (i : {i // P i}) : + Reindex.influence p (restrictCube P f y) ((π.subtypeEquiv hP) i) = + Reindex.influence p (restrictCube P f y) i := by + apply Reindex.influence_config (π.subtypeEquiv hP) + intro x + exact restrictCube_invariant P π hP hfix f hf x y + +/-- Conditional edge influences respect vertex permutations supported on the block. -/ +theorem restrictCube_influence_permEdge {n : ℕ} + (B : Finset (Fin n)) [DecidablePred (EdgeTouches B)] + (π : Equiv.Perm (Fin n)) (hπ : SupportedOnBlock B π) + (f : GraphConfig n → Bool) (hf : VertexInvariant f) + (p : ℝ) (y : {e : GraphEdge n // ¬ EdgeTouches B e} → Bool) + (e : {e : GraphEdge n // EdgeTouches B e}) : + Reindex.influence p (restrictCube (EdgeTouches B) f y) + ⟨permEdge π e.val, (edgeTouches_permEdge_iff hπ e.val).mpr e.property⟩ = + Reindex.influence p (restrictCube (EdgeTouches B) f y) e := by + let hP : ∀ i, EdgeTouches B i ↔ EdgeTouches B ((permEdgeEquiv π) i) := + fun i => (edgeTouches_permEdge_iff hπ i).symm + exact restrictCube_influence_reindex (EdgeTouches B) (permEdgeEquiv π) hP + (fun i hi => permEdge_eq_self_of_not_touches hπ i hi) f (hf π) p y e + +/-- Quantitative conditional influence bound from a finite collection of edges in +one block orbit. The collection may be supplied on the original edge type. -/ +theorem restrictCube_influence_le_of_orbit {n : ℕ} + (B : Finset (Fin n)) [DecidablePred (EdgeTouches B)] + (f : GraphConfig n → Bool) (hf : VertexInvariant f) + {p : ℝ} (hp0 : 0 ≤ p) (hp1 : p ≤ 1) + (y : {e : GraphEdge n // ¬ EdgeTouches B e} → Bool) + (e : {e : GraphEdge n // EdgeTouches B e}) (S : Finset (GraphEdge n)) + {m : ℝ} (hm : 0 < m) (hcard : m ≤ (S.card : ℝ)) + (horbit : ∀ d ∈ S, ∃ π : Equiv.Perm (Fin n), + SupportedOnBlock B π ∧ permEdge π e.val = d) : + Reindex.influence p (restrictCube (EdgeTouches B) f y) e ≤ + (∑ d, Reindex.influence p (restrictCube (EdgeTouches B) f y) d) / m := by + classical + have htouch : ∀ d ∈ S, EdgeTouches B d := by + intro d hd + obtain ⟨π, hπ, hmap⟩ := horbit d hd + rw [← hmap] + exact (edgeTouches_permEdge_iff hπ e.val).mpr e.property + have hcard' : m ≤ ((S.subtype (EdgeTouches B)).card : ℝ) := by + simpa only [Finset.card_subtype, Finset.filter_true_of_mem htouch] using hcard + apply Reindex.influence_le_total_div hp0 hp1 _ e + (S.subtype (EdgeTouches B)) hm hcard' + intro d hd + obtain ⟨π, hπ, hmap⟩ := horbit d.val (Finset.mem_subtype.mp hd) + simpa only [hmap] using restrictCube_influence_permEdge B π hπ f hf p y e + +/-- Every conditional influence on edges touching a block is at most the total +conditional influence divided by the number of block vertices. -/ +theorem block_restricted_influence_le {n : ℕ} + (B : Finset (Fin n)) [DecidablePred (EdgeTouches B)] (hB : 3 ≤ B.card) + (f : GraphConfig n → Bool) (hf : VertexInvariant f) + {p : ℝ} (hp0 : 0 ≤ p) (hp1 : p ≤ 1) + (y : {e : GraphEdge n // ¬ EdgeTouches B e} → Bool) + (e : {e : GraphEdge n // EdgeTouches B e}) : + Reindex.influence p (restrictCube (EdgeTouches B) f y) e ≤ + (∑ d, Reindex.influence p (restrictCube (EdgeTouches B) f y) d) / + (B.card : ℝ) := by + classical + obtain ⟨S, hcard, horbit⟩ := exists_freeEdge_orbit_family B hB e + have hm : (0 : ℝ) < B.card := by exact_mod_cast (by omega : 0 < B.card) + apply Reindex.influence_le_total_div hp0 hp1 _ e S hm (by exact_mod_cast hcard) + intro d hd + obtain ⟨π, hπ, hmap⟩ := horbit d hd + simpa only [hmap] using restrictCube_influence_permEdge B π hπ f hf p y e + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/BlockLowDegree.lean b/lean/OAI/Combinatorics/SharpThreshold/BlockLowDegree.lean new file mode 100644 index 0000000000000000000000000000000000000000..fe297a0de998ea1e3f5b5b1b773cc004a6d259d6 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/BlockLowDegree.lean @@ -0,0 +1,195 @@ +import OAI.Combinatorics.SharpThreshold.Model +import OAI.Combinatorics.SharpThreshold.FourierBasis +import OAI.Combinatorics.SharpThreshold.RestrictionInfluence +import OAI.Combinatorics.SharpThreshold.BlockInfluence +import OAI.Combinatorics.SharpThreshold.GraphRestrictionInfluence +import OAI.Combinatorics.SharpThreshold.RestrictionMassSubtype +import OAI.Combinatorics.SharpThreshold.LowDegree + +namespace OAI + +universe u + +noncomputable section +open scoped BigOperators + +namespace Problem313 + +/-- Averaging the low-degree estimate over exterior configurations preserves its +linear influence bound. This is the fixed-block averaging step, before averaging +in the choice of the vertex block. -/ +theorem average_conditional_low_degree_bound + {ι : Type u} [Fintype ι] [DecidableEq ι] + (P : ι → Prop) [DecidablePred P] + (p k C : ℝ) (f : (ι → Bool) → Bool) + (hp : 0 ≤ p) (hp1 : p ≤ 1) + (hbound : ∀ y : {i // ¬ P i} → Bool, + (∑ A : Finset {i // P i}, + if A.Nonempty ∧ (A.card : ℝ) ≤ k then + BiasedFourier.coeff p + (fun x => boolReal (f (RestrictionInfluence.join P x y))) A ^ 2 + else 0) ≤ + C * ∑ i : {i // P i}, RestrictionInfluence.influence p + (fun x => f (RestrictionInfluence.join P x y)) i) : + (∑ y : {i // ¬ P i} → Bool, BiasedFourier.weight p y * + ∑ A : Finset {i // P i}, + if A.Nonempty ∧ (A.card : ℝ) ≤ k then + BiasedFourier.coeff p + (fun x => boolReal (f (RestrictionInfluence.join P x y))) A ^ 2 + else 0) ≤ + C * ∑ i : {i // P i}, RestrictionInfluence.influence p f i.val := by + classical + have hw (y : {i // ¬ P i} → Bool) : 0 ≤ BiasedFourier.weight p y := by + apply Finset.prod_nonneg + intro i hi + unfold BiasedFourier.scalarWeight + split_ifs <;> linarith + calc + _ ≤ ∑ y : {i // ¬ P i} → Bool, BiasedFourier.weight p y * + (C * ∑ i : {i // P i}, RestrictionInfluence.influence p + (fun x => f (RestrictionInfluence.join P x y)) i) := by + exact Finset.sum_le_sum (fun y _ => mul_le_mul_of_nonneg_left (hbound y) (hw y)) + _ = C * ∑ y : {i // ¬ P i} → Bool, RestrictionInfluence.weight p y * + ∑ i : {i // P i}, RestrictionInfluence.influence p + (fun x => f (RestrictionInfluence.join P x y)) i := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro y hy + change BiasedFourier.weight p y * (C * _) = + C * (BiasedFourier.weight p y * _) + ring + _ = _ := by rw [RestrictionInfluence.average_totalInfluence] + +/-- The same averaging step with the original Fourier mass supplied by the exact +restriction identity. Both premises are equalities/inequalities about the actual +canonical product cube, not an abstract replacement for graph probability. -/ +theorem original_mass_bound_of_conditional + {ι : Type u} [Fintype ι] [DecidableEq ι] + (P : ι → Prop) [DecidablePred P] + (p k C M : ℝ) (f : (ι → Bool) → Bool) + (hp : 0 ≤ p) (hp1 : p ≤ 1) + (hmass : M = + ∑ y : {i // ¬ P i} → Bool, BiasedFourier.weight p y * + ∑ A : Finset {i // P i}, + if A.Nonempty ∧ (A.card : ℝ) ≤ k then + BiasedFourier.coeff p + (fun x => boolReal (f (RestrictionInfluence.join P x y))) A ^ 2 + else 0) + (hbound : ∀ y : {i // ¬ P i} → Bool, + (∑ A : Finset {i // P i}, + if A.Nonempty ∧ (A.card : ℝ) ≤ k then + BiasedFourier.coeff p + (fun x => boolReal (f (RestrictionInfluence.join P x y))) A ^ 2 + else 0) ≤ + C * ∑ i : {i // P i}, RestrictionInfluence.influence p + (fun x => f (RestrictionInfluence.join P x y)) i) : + M ≤ C * ∑ i : {i // P i}, RestrictionInfluence.influence p f i.val := by + rw [hmass] + exact average_conditional_low_degree_bound P p k C f hp hp1 hbound + +/-- The conditional influence premise for the low-degree theorem follows from +vertex invariance and the low-degree estimate on the restricted cube. -/ +theorem block_conditional_low_degree_bound_of_estimate + {n : ℕ} (B : Finset (Fin n)) [DecidablePred (EdgeTouches B)] + (hB : 3 ≤ B.card) (f : GraphConfig n → Bool) (hf : VertexInvariant f) + (p k C : ℝ) (hp : 0 ≤ p) (hp1 : p ≤ 1) + (hestimate : ∀ g : ({e : GraphEdge n // EdgeTouches B e} → Bool) → Bool, + (∀ e, Reindex.influence p g e ≤ + (∑ d, Reindex.influence p g d) / (B.card : ℝ)) → + (∑ A : Finset {e : GraphEdge n // EdgeTouches B e}, + if A.Nonempty ∧ (A.card : ℝ) ≤ k then + BiasedFourier.coeff p (fun x => boolReal (g x)) A ^ 2 else 0) ≤ + C * ∑ e, Reindex.influence p g e) : + (∑ y : {e : GraphEdge n // ¬ EdgeTouches B e} → Bool, + BiasedFourier.weight p y * + ∑ A : Finset {e : GraphEdge n // EdgeTouches B e}, + if A.Nonempty ∧ (A.card : ℝ) ≤ k then + BiasedFourier.coeff p + (fun x => boolReal (restrictCube (EdgeTouches B) f y x)) A ^ 2 + else 0) ≤ + C * ∑ e : {e : GraphEdge n // EdgeTouches B e}, edgeInfluence p f e.val := by + have hb (y : {e : GraphEdge n // ¬ EdgeTouches B e} → Bool) := + hestimate (restrictCube (EdgeTouches B) f y) + (fun e => block_restricted_influence_le B hB f hf hp hp1 y e) + calc + _ ≤ ∑ y : {e : GraphEdge n // ¬ EdgeTouches B e} → Bool, + Reindex.weight p y * + (C * ∑ e, Reindex.influence p (restrictCube (EdgeTouches B) f y) e) := by + apply Finset.sum_le_sum + intro y hy + exact mul_le_mul_of_nonneg_left (hb y) (Reindex.weight_nonneg hp hp1 y) + _ = C * ∑ y : {e : GraphEdge n // ¬ EdgeTouches B e} → Bool, + Reindex.weight p y * + ∑ e, Reindex.influence p (restrictCube (EdgeTouches B) f y) e := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro y hy + ring + _ = _ := by rw [block_average_totalInfluence] + +/-- Fixed-block Fourier estimate: all exterior Fourier degrees are retained. +The only analytic input is the ordinary low-degree estimate on the free cube. -/ +theorem block_low_degree_bound_of_estimate + {n : ℕ} (B : Finset (Fin n)) [DecidablePred (EdgeTouches B)] + (hB : 3 ≤ B.card) (f : GraphConfig n → Bool) (hf : VertexInvariant f) + (p k C : ℝ) (hp : 0 < p) (hp1 : p < 1) + (hestimate : ∀ g : ({e : GraphEdge n // EdgeTouches B e} → Bool) → Bool, + (∀ e, Reindex.influence p g e ≤ + (∑ d, Reindex.influence p g d) / (B.card : ℝ)) → + (∑ A : Finset {e : GraphEdge n // EdgeTouches B e}, + if A.Nonempty ∧ (A.card : ℝ) ≤ k then + BiasedFourier.coeff p (fun x => boolReal (g x)) A ^ 2 else 0) ≤ + C * ∑ e, Reindex.influence p g e) : + (∑ S : Finset (GraphEdge n), + if (S.filter (EdgeTouches B)).Nonempty ∧ + ((S.filter (EdgeTouches B)).card : ℝ) ≤ k then + BiasedFourier.coeff p (fun x => boolReal (f x)) S ^ 2 else 0) ≤ + C * ∑ e : {e : GraphEdge n // EdgeTouches B e}, edgeInfluence p f e.val := by + rw [BiasedFourier.restriction_low_degree_mass_subtype (EdgeTouches B) hp hp1] + exact block_conditional_low_degree_bound_of_estimate B hB f hf p k C + hp.le hp1.le hestimate + +/-- The fixed-block low-degree Fourier bound for invariant graph properties. +All symmetry, restriction and analytic premises are discharged. -/ +theorem block_low_degree_bound + {n : ℕ} (B : Finset (Fin n)) [DecidablePred (EdgeTouches B)] + (hB : 3 ≤ B.card) (f : GraphConfig n → Bool) (hf : VertexInvariant f) + {p : ℝ} (hp : 0 < p) (hp1 : p < 1) : + (∑ S : Finset (GraphEdge n), + if (S.filter (EdgeTouches B)).Nonempty ∧ + ((S.filter (EdgeTouches B)).card : ℝ) ≤ + Real.sqrt (p * (1 - p)) * Real.log (B.card : ℝ) / 64 then + BiasedFourier.coeff p (fun x => boolReal (f x)) S ^ 2 else 0) ≤ + (B.card : ℝ) ^ (-1 / 4 : ℝ) * + ∑ e : {e : GraphEdge n // EdgeTouches B e}, edgeInfluence p f e.val := by + have hm : (1 : ℝ) ≤ B.card := by exact_mod_cast (by omega : 1 ≤ B.card) + exact block_low_degree_bound_of_estimate B hB f hf p + (Real.sqrt (p * (1 - p)) * Real.log (B.card : ℝ) / 64) + ((B.card : ℝ) ^ (-1 / 4 : ℝ)) hp hp1 + (fun g hg => BiasedFourier.low_degree_estimate hp hp1 g (B.card : ℝ) hm hg) + +/-- Filtered finite-sum version of the fixed-block low-degree bound. -/ +theorem block_low_degree_bound_filter + {n : ℕ} (B : Finset (Fin n)) [DecidablePred (EdgeTouches B)] + (hB : 3 ≤ B.card) (f : GraphConfig n → Bool) (hf : VertexInvariant f) + {p : ℝ} (hp : 0 < p) (hp1 : p < 1) : + (∑ S ∈ Finset.univ.filter (fun S : Finset (GraphEdge n) => + 1 ≤ (S.filter (EdgeTouches B)).card ∧ + ((S.filter (EdgeTouches B)).card : ℝ) ≤ + Real.sqrt (p * (1 - p)) * Real.log (B.card : ℝ) / 64), + BiasedFourier.coeff p (fun x => boolReal (f x)) S ^ 2) ≤ + (B.card : ℝ) ^ (-1 / 4 : ℝ) * + ∑ e ∈ Finset.univ.filter (EdgeTouches B), edgeInfluence p f e := by + have h := block_low_degree_bound B hB f hf hp hp1 + have hs : (∑ e : {e : GraphEdge n // EdgeTouches B e}, edgeInfluence p f e.val) = + ∑ e ∈ Finset.univ.filter (EdgeTouches B), edgeInfluence p f e := + (Finset.sum_subtype (Finset.univ.filter (EdgeTouches B)) + (by intro e; simp) (edgeInfluence p f)).symm + rw [hs] at h + simpa only [Finset.sum_filter, Finset.one_le_card] using h + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/BlockOrbit.lean b/lean/OAI/Combinatorics/SharpThreshold/BlockOrbit.lean new file mode 100644 index 0000000000000000000000000000000000000000..17c01eaa66b8902200134a8416afa8897573d51b --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/BlockOrbit.lean @@ -0,0 +1,158 @@ +import OAI.Combinatorics.SharpThreshold.Model + +namespace OAI + +universe u + +noncomputable section + +namespace Problem313 + +/-- A permutation of a block, extended by the identity away from the block. -/ +def extendBlockPerm {α : Type u} [DecidableEq α] (B : Finset α) + (σ : Equiv.Perm B) : Equiv.Perm α := + σ.extendDomain (Equiv.refl B) + +@[simp] +theorem extendBlockPerm_apply_mem {α : Type u} [DecidableEq α] + (B : Finset α) (σ : Equiv.Perm B) (x : B) : + extendBlockPerm B σ x = (σ x : α) := by + exact Equiv.Perm.extendDomain_apply_image σ (Equiv.refl B) x + +@[simp] +theorem extendBlockPerm_apply_notMem {α : Type u} [DecidableEq α] + (B : Finset α) (σ : Equiv.Perm B) (x : α) (hx : x ∉ B) : + extendBlockPerm B σ x = x := by + exact Equiv.Perm.extendDomain_apply_not_subtype σ (Equiv.refl B) hx + +/-- Equal-sized subsets of a block can be mapped to one another while fixing its complement. -/ +theorem exists_blockPerm_map {α : Type u} [DecidableEq α] + (B s t : Finset α) (hs : s ⊆ B) (ht : t ⊆ B) (hc : s.card = t.card) : + ∃ σ : Equiv.Perm B, s.map (extendBlockPerm B σ).toEmbedding = t := by + classical + have hs' : s.filter (· ∈ B) = s := Finset.filter_true_of_mem (fun _ hx => hs hx) + have ht' : t.filter (· ∈ B) = t := Finset.filter_true_of_mem (fun _ hx => ht hx) + obtain ⟨σ, hσ⟩ := Equiv.Perm.exists_map_finset_eq + (s.subtype (· ∈ B)) (t.subtype (· ∈ B)) (by simpa [hs', ht'] using hc) + refine ⟨σ, ?_⟩ + have hmap := congrArg (fun u : Finset B => u.map (Function.Embedding.subtype _)) hσ + rw [Finset.subtype_map, ht'] at hmap + rw [← Finset.subtype_map_of_mem (fun _ hx => hs hx)] + simp only [Finset.map_map] at * + convert hmap using 1 + congr 1 + ext x + simp + +/-- A block permutation fixes any finite set disjoint from the block. -/ +theorem extendBlockPerm_map_disjoint {α : Type u} [DecidableEq α] + (B s : Finset α) (σ : Equiv.Perm B) (hs : Disjoint s B) : + s.map (extendBlockPerm B σ).toEmbedding = s := by + classical + have hfix : ∀ x ∈ s, extendBlockPerm B σ x = x := fun x hx => + extendBlockPerm_apply_notMem B σ x (Finset.disjoint_left.mp hs hx) + ext x + constructor + · intro hx + obtain ⟨y, hy, hxy⟩ := Finset.mem_map.mp hx + change extendBlockPerm B σ y = x at hxy + rw [hfix y hy] at hxy + exact hxy ▸ hy + · intro hx + exact Finset.mem_map.mpr ⟨x, hx, hfix x hx⟩ + +/-- Equal-sized finite sets with the same exterior part are in the same block orbit. -/ +theorem exists_blockPerm_map_of_sdiff_eq {α : Type u} [DecidableEq α] + (B s t : Finset α) (hc : s.card = t.card) (hout : s \ B = t \ B) : + ∃ σ : Equiv.Perm B, s.map (extendBlockPerm B σ).toEmbedding = t := by + classical + have hci : (s ∩ B).card = (t ∩ B).card := by + have hs := Finset.card_sdiff_add_card_inter s B + have ht := Finset.card_sdiff_add_card_inter t B + rw [hout, hc] at hs + omega + obtain ⟨σ, hσ⟩ := exists_blockPerm_map B (s ∩ B) (t ∩ B) + Finset.inter_subset_right Finset.inter_subset_right hci + refine ⟨σ, ?_⟩ + have hs : s = (s ∩ B) ∪ (s \ B) := by ext x; simp; tauto + calc + s.map (extendBlockPerm B σ).toEmbedding = + ((s ∩ B) ∪ (s \ B)).map (extendBlockPerm B σ).toEmbedding := congrArg _ hs + _ = (t ∩ B) ∪ (t \ B) := by + rw [Finset.map_union, hσ, extendBlockPerm_map_disjoint B (s \ B) σ + Finset.sdiff_disjoint, hout] + _ = t := by ext x; simp; tauto + +/-- Edge transport preserving the vertices outside the selected block. -/ +theorem exists_blockPerm_permEdge {n : ℕ} (B : Finset (Fin n)) + (e e' : GraphEdge n) (hout : e.1 \ B = e'.1 \ B) : + ∃ σ : Equiv.Perm B, permEdge (extendBlockPerm B σ) e = e' := by + obtain ⟨σ, hσ⟩ := exists_blockPerm_map_of_sdiff_eq B e.1 e'.1 + (e.2.trans e'.2.symm) hout + exact ⟨σ, Subtype.ext hσ⟩ + +/-- Every edge not touching the block is fixed pointwise by the block action. -/ +theorem permEdge_extendBlockPerm_of_disjoint {n : ℕ} (B : Finset (Fin n)) + (σ : Equiv.Perm B) (e : GraphEdge n) (he : Disjoint e.1 B) : + permEdge (extendBlockPerm B σ) e = e := by + exact Subtype.ext (extendBlockPerm_map_disjoint B e.1 σ he) + +@[simp] +theorem extendBlockPerm_mem_iff {α : Type u} [DecidableEq α] + (B : Finset α) (σ : Equiv.Perm B) (x : α) : + extendBlockPerm B σ x ∈ B ↔ x ∈ B := by + by_cases hx : x ∈ B + · have h := extendBlockPerm_apply_mem B σ ⟨x, hx⟩ + rw [h] + exact iff_of_true (σ ⟨x, hx⟩).2 hx + · simp [extendBlockPerm_apply_notMem B σ x hx, hx] + +@[simp] +theorem extendBlockPerm_map_block {α : Type u} [DecidableEq α] + (B : Finset α) (σ : Equiv.Perm B) : + B.map (extendBlockPerm B σ).toEmbedding = B := by + apply Finset.eq_of_subset_of_card_le + · intro x hx + obtain ⟨y, hy, rfl⟩ := Finset.mem_map.mp hx + exact (extendBlockPerm_mem_iff B σ y).mpr hy + · simp + +/-- Block-supported permutations leave the exterior part of every finite set unchanged. -/ +theorem extendBlockPerm_sdiff {α : Type u} [DecidableEq α] + (B s : Finset α) (σ : Equiv.Perm B) : + s.map (extendBlockPerm B σ).toEmbedding \ B = s \ B := by + calc + s.map (extendBlockPerm B σ).toEmbedding \ B = + (s \ B).map (extendBlockPerm B σ).toEmbedding := by + rw [Finset.map_sdiff, extendBlockPerm_map_block] + _ = s \ B := extendBlockPerm_map_disjoint B (s \ B) σ Finset.sdiff_disjoint + +/-- Two graph edges belong to the same block orbit exactly when their exterior vertices agree. -/ +theorem exists_blockPerm_permEdge_iff {n : ℕ} (B : Finset (Fin n)) + (e e' : GraphEdge n) : + (∃ σ : Equiv.Perm B, permEdge (extendBlockPerm B σ) e = e') ↔ + e.1 \ B = e'.1 \ B := by + constructor + · rintro ⟨σ, rfl⟩ + exact (extendBlockPerm_sdiff B e.1 σ).symm + · exact exists_blockPerm_permEdge B e e' + +@[simp] +theorem extendBlockPerm_symm {α : Type u} [DecidableEq α] + (B : Finset α) (σ : Equiv.Perm B) : + (extendBlockPerm B σ).symm = extendBlockPerm B σ.symm := by + exact Equiv.Perm.extendDomain_symm σ (Equiv.refl B) + +/-- Relabeling inside the block leaves each exterior configuration coordinate unchanged. -/ +theorem permuteConfig_extendBlockPerm_apply_of_disjoint {n : ℕ} + (B : Finset (Fin n)) (σ : Equiv.Perm B) (x : GraphConfig n) + (e : GraphEdge n) (he : Disjoint e.1 B) : + permuteConfig (extendBlockPerm B σ) x e = x e := by + rw [permuteConfig, extendBlockPerm_symm, + permEdge_extendBlockPerm_of_disjoint B σ.symm e he] + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/BlockOrbitSubtype.lean b/lean/OAI/Combinatorics/SharpThreshold/BlockOrbitSubtype.lean new file mode 100644 index 0000000000000000000000000000000000000000..e60dd5238505e2fe08e3384915b475e3a7f02808 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/BlockOrbitSubtype.lean @@ -0,0 +1,42 @@ +import OAI.Combinatorics.SharpThreshold.BlockOrbits +import OAI.Combinatorics.SharpThreshold.BlockRestrictionSymmetry + +namespace OAI + +noncomputable section +namespace Problem313 + +/-- The supported permutation orbit of a free edge consists only of free edges. -/ +theorem blockEdgeOrbit_touches {n : ℕ} {B : Finset (Fin n)} + {e d : GraphEdge n} (he : EdgeTouches B e) (hd : d ∈ blockEdgeOrbit B e) : + EdgeTouches B d := by + obtain ⟨π, hπ, rfl⟩ := mem_blockEdgeOrbit.mp hd + exact (edgeTouches_permEdge_iff hπ e).mpr he + +/-- A free edge has at least `B.card` free-edge orbit mates, with explicit +supported-permutation witnesses. This is the finite-coordinate interface for +conditional influence bounds. -/ +theorem exists_freeEdge_orbit_family {n : ℕ} (B : Finset (Fin n)) + (hB : 3 ≤ B.card) (e : {e : GraphEdge n // EdgeTouches B e}) : + ∃ S : Finset {d : GraphEdge n // EdgeTouches B d}, + B.card ≤ S.card ∧ ∀ d ∈ S, ∃ π : Equiv.Perm (Fin n), + SupportedOnBlock B π ∧ permEdge π e.val = d.val := by + classical + let S := (blockEdgeOrbit B e.val).subtype (EdgeTouches B) + have hmap : S.map (Function.Embedding.subtype _) = blockEdgeOrbit B e.val := + Finset.subtype_map_of_mem (fun d hd => blockEdgeOrbit_touches e.property hd) + have hcard : S.card = (blockEdgeOrbit B e.val).card := by + simpa using congrArg Finset.card hmap + refine ⟨S, ?_, ?_⟩ + · rw [hcard] + apply blockEdgeOrbit_card_lower hB + obtain ⟨v, hve, hvB⟩ := e.property + exact ⟨v, Finset.mem_inter.mpr ⟨hve, hvB⟩⟩ + · intro d hd + exact mem_blockEdgeOrbit.mp (Finset.mem_subtype.mp hd) + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/BlockOrbits.lean b/lean/OAI/Combinatorics/SharpThreshold/BlockOrbits.lean new file mode 100644 index 0000000000000000000000000000000000000000..f1dd10241efc47e4e26b1c451a8674f5d2bbf7f5 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/BlockOrbits.lean @@ -0,0 +1,176 @@ +import OAI.Combinatorics.SharpThreshold.Model + +namespace OAI + +universe u + +noncomputable section + +namespace Problem313 + +/-- A permutation supported on a finite block can map any two equally sized +subsets of the block to one another. -/ +theorem exists_block_perm_map {α : Type u} [Fintype α] [DecidableEq α] + (B s t : Finset α) (hs : s ⊆ B) (ht : t ⊆ B) + (hc : s.card = t.card) : + ∃ π : Equiv.Perm α, (∀ u, u ∉ B → π u = u) ∧ + s.map π.toEmbedding = t := by + classical + let sB := s.subtype (· ∈ B) + let tB := t.subtype (· ∈ B) + have hsmap : sB.map (Function.Embedding.subtype _) = s := + Finset.subtype_map_of_mem hs + have htmap : tB.map (Function.Embedding.subtype _) = t := + Finset.subtype_map_of_mem ht + have hcB : sB.card = tB.card := by + have hsc := congrArg Finset.card hsmap + have htc := congrArg Finset.card htmap + simpa using hsc.trans (hc.trans htc.symm) + obtain ⟨σ, hσ⟩ := Equiv.Perm.exists_map_finset_eq sB tB hcB + let π : Equiv.Perm α := σ.extendDomain (Equiv.refl {u // u ∈ B}) + refine ⟨π, ?_, ?_⟩ + · intro u hu + exact Equiv.Perm.extendDomain_apply_not_subtype _ _ hu + · calc + s.map π.toEmbedding = (sB.map (Function.Embedding.subtype _)).map π.toEmbedding := by + rw [hsmap] + _ = (sB.map σ.toEmbedding).map (Function.Embedding.subtype _) := by + rw [Finset.map_map, Finset.map_map] + congr 1 + ext u + exact Equiv.Perm.extendDomain_apply_image σ (Equiv.refl _) u + _ = t := by rw [hσ, htmap] + +/-- The edge orbit under permutations fixing the complement of `B` pointwise. -/ +def blockEdgeOrbit {n : ℕ} (B : Finset (Fin n)) (e : GraphEdge n) : + Finset (GraphEdge n) := by + classical + exact Finset.univ.filter (fun e' => ∃ π : Equiv.Perm (Fin n), + (∀ u, u ∉ B → π u = u) ∧ permEdge π e = e') + +@[simp] theorem mem_blockEdgeOrbit {n : ℕ} {B : Finset (Fin n)} + {e e' : GraphEdge n} : e' ∈ blockEdgeOrbit B e ↔ + ∃ π : Equiv.Perm (Fin n), (∀ u, u ∉ B → π u = u) ∧ permEdge π e = e' := by + classical + simp [blockEdgeOrbit] + +/-- All edges wholly contained in a block are in one supported-permutation orbit. -/ +theorem block_internal_mem_orbit {n : ℕ} {B : Finset (Fin n)} + {e e' : GraphEdge n} (he : e.val ⊆ B) (he' : e'.val ⊆ B) : + e' ∈ blockEdgeOrbit B e := by + obtain ⟨π, hπ, hmap⟩ := exists_block_perm_map B e.val e'.val he he' (e.property.trans e'.property.symm) + exact mem_blockEdgeOrbit.mpr ⟨π, hπ, Subtype.ext hmap⟩ + +/-- The number of graph edges wholly contained in a vertex block. -/ +theorem card_block_internal_edges {n : ℕ} (B : Finset (Fin n)) : + (Finset.univ.filter (fun e : GraphEdge n => e.val ⊆ B)).card = B.card.choose 2 := by + classical + rw [← Finset.card_powersetCard] + apply Finset.card_bij (fun e _ => e.val) + · intro e he + exact Finset.mem_powersetCard.mpr ⟨(Finset.mem_filter.mp he).2, e.property⟩ + · intro e he e' he' h + exact Subtype.ext h + · intro s hs + obtain ⟨hsB, hsc⟩ := Finset.mem_powersetCard.mp hs + exact ⟨⟨s, hsc⟩, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hsB⟩, rfl⟩ + +theorem block_card_le_choose_two (m : ℕ) (hm : 3 ≤ m) : m ≤ m.choose 2 := by + rw [Nat.choose_two_right] + apply (Nat.le_div_iff_mul_le (by omega : 0 < 2)).mpr + exact Nat.mul_le_mul_left m (by omega) + +/-- Internal edge orbits have at least as many edges as the block has vertices. -/ +theorem block_internal_orbit_card {n : ℕ} {B : Finset (Fin n)} + {e : GraphEdge n} (hB : 3 ≤ B.card) (he : e.val ⊆ B) : + B.card ≤ (blockEdgeOrbit B e).card := by + classical + calc + B.card ≤ B.card.choose 2 := block_card_le_choose_two _ hB + _ = (Finset.univ.filter (fun e' : GraphEdge n => e'.val ⊆ B)).card := + (card_block_internal_edges B).symm + _ ≤ (blockEdgeOrbit B e).card := Finset.card_le_card (by + intro e' he' + exact block_internal_mem_orbit he (Finset.mem_filter.mp he').2) + +/-- The boundary edge joining a vertex of the block to a fixed exterior vertex. -/ +def blockBoundaryEdge {n : ℕ} {B : Finset (Fin n)} (w : Fin n) (hw : w ∉ B) + (u : B) : GraphEdge n := + ⟨{u.val, w}, Finset.card_pair (by + intro h + exact hw (h ▸ u.property))⟩ + +theorem blockBoundaryEdge_injective {n : ℕ} {B : Finset (Fin n)} + (w : Fin n) (hw : w ∉ B) : Function.Injective (blockBoundaryEdge w hw) := by + intro u v h + have he : ({u.val, w} : Finset (Fin n)) = {v.val, w} := congrArg Subtype.val h + have hu : u.val ∈ ({v.val, w} : Finset (Fin n)) := by rw [← he]; simp + rcases (show u.val = v.val ∨ u.val = w by simpa using hu) with huv | huw + · exact Subtype.ext huv + · exact False.elim (hw (huw ▸ u.property)) + +/-- Boundary edges with the same exterior endpoint are in one block orbit. -/ +theorem block_boundary_mem_orbit {n : ℕ} {B : Finset (Fin n)} + {e : GraphEdge n} {u w : Fin n} (hu : u ∈ B) (hw : w ∉ B) + (he : e.val = {u, w}) (v : B) : + blockBoundaryEdge w hw v ∈ blockEdgeOrbit B e := by + classical + refine mem_blockEdgeOrbit.mpr ⟨Equiv.swap u v.val, ?_, ?_⟩ + · intro z hz + apply Equiv.swap_apply_of_ne_of_ne + · intro hzu + exact hz (hzu ▸ hu) + · intro hzv + exact hz (hzv ▸ v.property) + · apply Subtype.ext + have hwu : w ≠ u := by intro h; exact hw (h ▸ hu) + have hwv : w ≠ v.val := by intro h; exact hw (h ▸ v.property) + simp [permEdge, blockBoundaryEdge, he, Equiv.swap_apply_of_ne_of_ne hwu hwv] + +/-- Boundary edge orbits contain at least one edge for every block vertex. -/ +theorem block_boundary_orbit_card {n : ℕ} {B : Finset (Fin n)} + {e : GraphEdge n} {u w : Fin n} (hu : u ∈ B) (hw : w ∉ B) + (he : e.val = {u, w}) : B.card ≤ (blockEdgeOrbit B e).card := by + classical + let emb : B ↪ GraphEdge n := ⟨blockBoundaryEdge w hw, blockBoundaryEdge_injective w hw⟩ + calc + B.card = (Finset.univ.map emb).card := by simp + _ ≤ (blockEdgeOrbit B e).card := Finset.card_le_card (by + intro e' he' + obtain ⟨v, hv, rfl⟩ := Finset.mem_map.mp he' + exact block_boundary_mem_orbit hu hw he v) + +/-- Every edge incident with a block of at least three vertices has a +supported-permutation orbit of cardinality at least the block cardinality. -/ +theorem blockEdgeOrbit_card_lower {n : ℕ} {B : Finset (Fin n)} + {e : GraphEdge n} (hB : 3 ≤ B.card) (hmeet : (e.val ∩ B).Nonempty) : + B.card ≤ (blockEdgeOrbit B e).card := by + classical + by_cases he : e.val ⊆ B + · exact block_internal_orbit_card hB he + obtain ⟨a, b, hab, heab⟩ := Finset.card_eq_two.mp e.property + by_cases ha : a ∈ B + · have hb : b ∉ B := by + intro hb + apply he + intro z hz + rw [heab] at hz + rcases (show z = a ∨ z = b by simpa using hz) with rfl | rfl + · exact ha + · exact hb + exact block_boundary_orbit_card ha hb heab + · have hb : b ∈ B := by + obtain ⟨z, hz⟩ := hmeet + obtain ⟨hze, hzB⟩ := Finset.mem_inter.mp hz + rw [heab] at hze + rcases (show z = a ∨ z = b by simpa using hze) with rfl | rfl + · exact False.elim (ha hzB) + · exact hzB + apply block_boundary_orbit_card hb ha + simpa [Finset.pair_comm] using heab + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/BlockParameters.lean b/lean/OAI/Combinatorics/SharpThreshold/BlockParameters.lean new file mode 100644 index 0000000000000000000000000000000000000000..0d8f3d76d95e5b4b5310dabe64b4568a8b448a93 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/BlockParameters.lean @@ -0,0 +1,145 @@ +import OAI.Combinatorics.SharpThreshold.BlockSize +import OAI.Combinatorics.SharpThreshold.VarianceConstants + +namespace OAI + +noncomputable section + +namespace Problem313 + +lemma block_scale_pos {p : ℝ} (hp : 0 < p) (hp1 : p < 1) : + 0 < Real.sqrt (p * (1 - p)) := + Real.sqrt_pos.mpr (mul_pos hp (sub_pos.mpr hp1)) + +lemma block_scale_le_half (p : ℝ) : + Real.sqrt (p * (1 - p)) ≤ 1 / 2 := by + apply Real.sqrt_le_iff.mpr + constructor + · norm_num + · nlinarith [sq_nonneg (p - 1 / 2)] + +lemma block_cutoff_pos (n : ℕ) (p : ℝ) (hn : 2 ≤ n) + (ht : 16 ≤ Real.log (n : ℝ)) (hp : 0 < p) (hp1 : p < 1) : + 0 < Real.sqrt (p * (1 - p)) * + Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) / 64 := by + have hscale := block_scale_pos hp hp1 + have hlog := log_sqrt_block_lower n hn ht + have hlogpos : 0 < Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) := by linarith + positivity + +lemma block_cutoff_le_log_div_128 (n : ℕ) (p : ℝ) (hn : 2 ≤ n) + (ht : 16 ≤ Real.log (n : ℝ)) : + Real.sqrt (p * (1 - p)) * + Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) / 64 ≤ Real.log (n : ℝ) / 128 := by + have hsize := sqrt_block_size_bounds n hn ht + have hmpos : 0 < (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) := by + exact_mod_cast (by omega : 0 < ⌊Real.sqrt (n : ℝ)⌋₊) + have hmn : (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) ≤ (n : ℝ) := by + exact_mod_cast hsize.2.1 + have hlogupper := Real.log_le_log hmpos hmn + have hloglower := log_sqrt_block_lower n hn ht + have hlognonneg : 0 ≤ Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) := by linarith + have hmul := mul_le_mul_of_nonneg_right (block_scale_le_half p) hlognonneg + linarith + +lemma block_cutoff_le_log (n : ℕ) (p : ℝ) (hn : 2 ≤ n) + (ht : 16 ≤ Real.log (n : ℝ)) : + Real.sqrt (p * (1 - p)) * + Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) / 64 ≤ Real.log (n : ℝ) := by + have h := block_cutoff_le_log_div_128 n p hn ht + linarith + +/-- A global logarithmic bound which avoids any large-parameter decay calculus. -/ +lemma log_sq_le_sixteen_sqrt (x : ℝ) (hx : 1 ≤ x) : + (Real.log x) ^ 2 ≤ 16 * Real.sqrt x := by + have hxpos : 0 < x := by linarith + have hlog : 0 ≤ Real.log x := Real.log_nonneg hx + have hlin : Real.log x / 4 ≤ Real.exp (Real.log x / 4) := by + have h := Real.add_one_le_exp (Real.log x / 4) + linarith + have hsquare := pow_le_pow_left₀ (by positivity : 0 ≤ Real.log x / 4) hlin 2 + have hexp : (Real.exp (Real.log x / 4)) ^ 2 = Real.sqrt x := by + rw [pow_two, ← Real.exp_add] + have harg : Real.log x / 4 + Real.log x / 4 = Real.log x / 2 := by ring + rw [harg, Real.exp_half, Real.exp_log hxpos] + rw [hexp] at hsquare + nlinarith + +/-- The support-size correction in the random block capture estimate. -/ +lemma block_cutoff_sq_div_sqrt_le_half (n : ℕ) (p : ℝ) (hn : 2 ≤ n) + (ht : 16 ≤ Real.log (n : ℝ)) : + (Real.sqrt (p * (1 - p)) * + Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) / 64) ^ 2 / + Real.sqrt (n : ℝ) ≤ 1 / 2 := by + have hcut := block_cutoff_le_log_div_128 n p hn ht + have hlog := log_sqrt_block_lower n hn ht + have hlogpos : 0 ≤ Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) := by linarith + have hk : 0 ≤ Real.sqrt (p * (1 - p)) * + Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) / 64 := by positivity + have htsquare := mul_le_mul hcut hcut hk (by linarith : 0 ≤ Real.log (n : ℝ) / 128) + have hsqrt := log_sq_le_sixteen_sqrt (n : ℝ) (by exact_mod_cast (by omega : 1 ≤ n)) + have hsqrtpos : 0 < Real.sqrt (n : ℝ) := by positivity + apply (div_le_iff₀ hsqrtpos).mpr + nlinarith + +/-- The exact pair-correction form needed by uniform block counting. -/ +lemma block_cutoff_sq_pair_ratio_le_half (n : ℕ) (p : ℝ) (hn : 2 ≤ n) + (ht : 16 ≤ Real.log (n : ℝ)) : + (Real.sqrt (p * (1 - p)) * + Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) / 64) ^ 2 * + (((⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) - 1) / ((n : ℝ) - 1)) ≤ 1 / 2 := by + have hratio := sqrt_block_pair_ratio n hn + have hmul := mul_le_mul_of_nonneg_left hratio + (sq_nonneg (Real.sqrt (p * (1 - p)) * + Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) / 64)) + have hbound := block_cutoff_sq_div_sqrt_le_half n p hn ht + rw [mul_one_div] at hmul + exact hmul.trans hbound + +lemma block_support_pair_correction_le_half (n v : ℕ) (p : ℝ) (hn : 2 ≤ n) + (ht : 16 ≤ Real.log (n : ℝ)) + (hv : (v : ℝ) ≤ (Real.sqrt (p * (1 - p)) * + Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) / 64) ^ 2) : + ((v : ℝ) - 1) * + (((⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) - 1) / ((n : ℝ) - 1)) ≤ 1 / 2 := by + have hsize := sqrt_block_size_bounds n hn ht + have hm : (3 : ℝ) ≤ (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) := by exact_mod_cast hsize.1 + have hnreal : (2 : ℝ) ≤ n := by exact_mod_cast hn + have hratio : 0 ≤ ((⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) - 1) / ((n : ℝ) - 1) := by + apply div_nonneg <;> linarith + have hv' : (v : ℝ) - 1 ≤ (Real.sqrt (p * (1 - p)) * + Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) / 64) ^ 2 := by linarith + exact (mul_le_mul_of_nonneg_right hv' hratio).trans + (block_cutoff_sq_pair_ratio_le_half n p hn ht) + +/-- The full numerical coefficient for the actual square-root block parameters. -/ +theorem graph_block_preconstant_bound (n : ℕ) (p : ℝ) (hn : 2 ≤ n) + (ht : 16 ≤ Real.log (n : ℝ)) (hp : 0 < p) (hp1 : p < 1) : + 4 * (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) ^ (-(1 : ℝ) / 4) + + 2 * (Real.sqrt (p * (1 - p))) ^ 2 / + (Real.sqrt (p * (1 - p)) * + Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) / 64) ^ 2 ≤ + (2 : ℝ) ^ 17 / (Real.log (n : ℝ)) ^ 2 := by + have hsize := sqrt_block_size_bounds n hn ht + exact variance_constant_bound (by linarith) + (by exact_mod_cast (by omega : 0 < ⌊Real.sqrt (n : ℝ)⌋₊)) + (log_sqrt_block_lower n hn ht) (block_scale_pos hp hp1) + +/-- The elementary coefficient comparison in the small-logarithm branch. -/ +theorem small_log_poincare_coefficient (n : ℕ) (p : ℝ) (hn : 2 ≤ n) + (ht : Real.log (n : ℝ) ≤ 16) : + p * (1 - p) ≤ (2 : ℝ) ^ 17 / (Real.log (n : ℝ)) ^ 2 := by + have hnreal : (1 : ℝ) < n := by exact_mod_cast (by omega : 1 < n) + have hlogpos := Real.log_pos hnreal + have hvar : p * (1 - p) ≤ 1 / 4 := by nlinarith [sq_nonneg (p - 1 / 2)] + apply hvar.trans + apply (le_div_iff₀ (sq_pos_of_pos hlogpos)).mpr + have hsquare := mul_le_mul ht ht hlogpos.le (by norm_num : (0 : ℝ) ≤ 16) + norm_num at hsquare ⊢ + nlinarith + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/BlockRestrictionSymmetry.lean b/lean/OAI/Combinatorics/SharpThreshold/BlockRestrictionSymmetry.lean new file mode 100644 index 0000000000000000000000000000000000000000..43a65a6581b9537393368c5a61be81a639e8eb88 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/BlockRestrictionSymmetry.lean @@ -0,0 +1,110 @@ +import OAI.Combinatorics.SharpThreshold.Model + +namespace OAI + +noncomputable section +namespace Problem313 + +/-- An edge is free in a block restriction when it touches the block. -/ +def EdgeTouches {n : ℕ} (B : Finset (Fin n)) (e : GraphEdge n) : Prop := + ∃ v, v ∈ e.val ∧ v ∈ B + +/-- The vertex permutation is supported on the block. -/ +def SupportedOnBlock {n : ℕ} (B : Finset (Fin n)) + (π : Equiv.Perm (Fin n)) : Prop := + ∀ v, v ∉ B → π v = v + +lemma supportedOnBlock_mem_iff {n : ℕ} {B : Finset (Fin n)} + {π : Equiv.Perm (Fin n)} (hπ : SupportedOnBlock B π) (v : Fin n) : + π v ∈ B ↔ v ∈ B := by + constructor + · intro h + by_contra hn + exact hn (by simpa [hπ v hn] using h) + · intro h + by_contra hn + have he := hπ (π v) hn + have he' : π v = v := π.injective he + exact hn (he'.symm ▸ h) + +lemma supportedOnBlock_symm {n : ℕ} {B : Finset (Fin n)} + {π : Equiv.Perm (Fin n)} (hπ : SupportedOnBlock B π) : + SupportedOnBlock B π.symm := by + intro v hv + apply π.injective + simpa using (hπ v hv).symm + +lemma block_mem_permEdge_iff {n : ℕ} (π : Equiv.Perm (Fin n)) + (e : GraphEdge n) (v : Fin n) : + v ∈ (permEdge π e).val ↔ π.symm v ∈ e.val := by + simp [permEdge] + +lemma edgeTouches_permEdge_iff {n : ℕ} {B : Finset (Fin n)} + {π : Equiv.Perm (Fin n)} (hπ : SupportedOnBlock B π) (e : GraphEdge n) : + EdgeTouches B (permEdge π e) ↔ EdgeTouches B e := by + constructor + · rintro ⟨v, hv, hB⟩ + refine ⟨π.symm v, (block_mem_permEdge_iff π e v).mp hv, ?_⟩ + exact (supportedOnBlock_mem_iff (supportedOnBlock_symm hπ) v).mpr hB + · rintro ⟨v, hv, hB⟩ + refine ⟨π v, ?_, (supportedOnBlock_mem_iff hπ v).mpr hB⟩ + simpa [block_mem_permEdge_iff] using hv + +lemma permEdge_eq_self_of_not_touches {n : ℕ} {B : Finset (Fin n)} + {π : Equiv.Perm (Fin n)} (hπ : SupportedOnBlock B π) + (e : GraphEdge n) (he : ¬ EdgeTouches B e) : permEdge π e = e := by + apply Subtype.ext + ext v + rw [block_mem_permEdge_iff] + constructor + · intro hv + have hn : π.symm v ∉ B := fun h => he ⟨π.symm v, hv, h⟩ + have hf := hπ (π.symm v) hn + have hf' : v = π.symm v := by simpa using hf + exact hf'.symm ▸ hv + · intro hv + have hn : v ∉ B := fun h => he ⟨v, hv, h⟩ + have hf := supportedOnBlock_symm hπ v hn + simpa [hf] using hv + +lemma edgeTouches_iff_not_disjoint {n : ℕ} (B : Finset (Fin n)) + (e : GraphEdge n) : EdgeTouches B e ↔ ¬ Disjoint e.val B := by + classical + simp [EdgeTouches, Finset.disjoint_left] + +lemma supportedOnBlock_one {n : ℕ} (B : Finset (Fin n)) : + SupportedOnBlock B (1 : Equiv.Perm (Fin n)) := by + intro v _ + rfl + +lemma supportedOnBlock_mul {n : ℕ} {B : Finset (Fin n)} + {π σ : Equiv.Perm (Fin n)} (hπ : SupportedOnBlock B π) + (hσ : SupportedOnBlock B σ) : SupportedOnBlock B (π * σ) := by + intro v hv + change π (σ v) = v + rw [hσ v hv, hπ v hv] + +/-- The subgroup of permutations supported on a given vertex block. -/ +def blockPermutationSubgroup {n : ℕ} (B : Finset (Fin n)) : + Subgroup (Equiv.Perm (Fin n)) where + carrier := {π | SupportedOnBlock B π} + one_mem' := supportedOnBlock_one B + mul_mem' := supportedOnBlock_mul + inv_mem' := supportedOnBlock_symm + +@[simp] lemma mem_blockPermutationSubgroup {n : ℕ} (B : Finset (Fin n)) + (π : Equiv.Perm (Fin n)) : π ∈ blockPermutationSubgroup B ↔ SupportedOnBlock B π := + Iff.rfl + +lemma supportedOnBlock_swap {n : ℕ} {B : Finset (Fin n)} {u v : Fin n} + (hu : u ∈ B) (hv : v ∈ B) : SupportedOnBlock B (Equiv.swap u v) := by + intro w hw + have hwu : w ≠ u := fun h => hw (h ▸ hu) + have hwv : w ≠ v := fun h => hw (h ▸ hv) + simp [Equiv.swap_apply_def, hwu, hwv] + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/BlockSize.lean b/lean/OAI/Combinatorics/SharpThreshold/BlockSize.lean new file mode 100644 index 0000000000000000000000000000000000000000..705adc699a8a68883a1559a4b3a775ba6faf44fb --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/BlockSize.lean @@ -0,0 +1,122 @@ +import Mathlib + +namespace OAI + +noncomputable section + +namespace Problem313 + +theorem half_le_nat_floor {x : ℝ} (hx : 2 ≤ x) : + x / 2 ≤ (⌊x⌋₊ : ℝ) := by + have hfloor := Nat.sub_one_lt_floor x + linarith + +/-- Elementary size estimates for the square-root vertex block. -/ +theorem sqrt_block_size_bounds (n : ℕ) (hn : 2 ≤ n) + (ht : 16 ≤ Real.log (n : ℝ)) : + 3 ≤ ⌊Real.sqrt (n : ℝ)⌋₊ ∧ + ⌊Real.sqrt (n : ℝ)⌋₊ ≤ n ∧ + Real.sqrt (n : ℝ) / 2 ≤ (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) := by + have hnpos : 0 < (n : ℝ) := by exact_mod_cast (by omega : 0 < n) + have hnlarge : 17 ≤ (n : ℝ) := by + have := Real.log_le_sub_one_of_pos hnpos + linarith + have hsqrt : 4 ≤ Real.sqrt (n : ℝ) := + (Real.le_sqrt (by norm_num) (le_of_lt hnpos)).2 (by linarith) + refine ⟨Nat.le_floor (by norm_num; linarith), ?_, half_le_nat_floor (by linarith)⟩ + apply Nat.floor_le_of_le + apply Real.sqrt_le_iff.mpr + constructor + · positivity + · nlinarith + +/-- The square-root block retains at least one third of the original logarithm. -/ +theorem log_sqrt_block_lower (n : ℕ) (hn : 2 ≤ n) + (ht : 16 ≤ Real.log (n : ℝ)) : + Real.log (n : ℝ) / 3 ≤ Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) := by + have hnpos : 0 < (n : ℝ) := by exact_mod_cast (by omega : 0 < n) + have hsqrtpos : 0 < Real.sqrt (n : ℝ) := Real.sqrt_pos.2 hnpos + have hhalf := (sqrt_block_size_bounds n hn ht).2.2 + have hlog := Real.log_le_log (by positivity : 0 < Real.sqrt (n : ℝ) / 2) hhalf + rw [Real.log_div (ne_of_gt hsqrtpos) (by norm_num), + Real.log_sqrt (le_of_lt hnpos)] at hlog + have htwo : Real.log 2 ≤ 1 := by + have h := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2) + linarith + linarith + +/-- Pair-inclusion correction for the square-root-sized uniform block. -/ +theorem sqrt_block_pair_ratio (n : ℕ) (hn : 2 ≤ n) : + ((⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) - 1) / ((n : ℝ) - 1) ≤ + 1 / Real.sqrt (n : ℝ) := by + have hnreal : 2 ≤ (n : ℝ) := by exact_mod_cast hn + have hnpos : 0 < (n : ℝ) := by linarith + have hsqrtpos : 0 < Real.sqrt (n : ℝ) := Real.sqrt_pos.2 hnpos + have hsqrtone : 1 ≤ Real.sqrt (n : ℝ) := + (Real.le_sqrt (by norm_num) (le_of_lt hnpos)).2 (by linarith) + have hfloor := Nat.floor_le (Real.sqrt_nonneg (n : ℝ)) + have hprod := mul_le_mul_of_nonneg_right hfloor (le_of_lt hsqrtpos) + have hsquare := Real.sq_sqrt (le_of_lt hnpos) + apply (div_le_div_iff₀ (by linarith : 0 < (n : ℝ) - 1) hsqrtpos).2 + nlinarith + +/-- A coarse exponential estimate sufficient for the block-capture union bound. -/ +theorem block_capture_exp_lower (t : ℝ) (ht : 16 ≤ t) : + 2 * t ^ 2 ≤ Real.exp (t / 2) := by + have htpos : 0 ≤ t := by linarith + have hsq : 16 * t ≤ t ^ 2 := by + nlinarith [mul_nonneg htpos (sub_nonneg.mpr ht)] + have hcube : 256 * t ≤ t ^ 3 := by + calc + 256 * t ≤ 16 * t ^ 2 := by linarith + _ ≤ t * t ^ 2 := mul_le_mul_of_nonneg_right ht (sq_nonneg t) + _ = t ^ 3 := by ring + have hexp := Real.sum_le_exp_of_nonneg (by positivity : 0 ≤ t / 4) 4 + norm_num [Finset.sum_range_succ, Nat.factorial] at hexp + have hlower : (17 / 12 : ℝ) * t ≤ Real.exp (t / 4) := by + nlinarith + have hsquare : ((17 / 12 : ℝ) * t) ^ 2 ≤ (Real.exp (t / 4)) ^ 2 := + pow_le_pow_left₀ (by positivity) hlower 2 + have hid : Real.exp (t / 2) = (Real.exp (t / 4)) ^ 2 := by + rw [show t / 2 = t / 4 + t / 4 by ring, Real.exp_add] + ring + rw [hid] + nlinarith [sq_nonneg t] + +theorem block_capture_decay (t : ℝ) (ht : 16 ≤ t) : + t ^ 2 * Real.exp (-t / 2) ≤ (1 / 2 : ℝ) := by + rw [show -t / 2 = -(t / 2) by ring, Real.exp_neg, + ← div_eq_mul_inv] + apply (div_le_iff₀ (Real.exp_pos (t / 2))).2 + have := block_capture_exp_lower t ht + linarith + +theorem log_square_div_sqrt_le_half (n : ℕ) (hn : 2 ≤ n) + (ht : 16 ≤ Real.log (n : ℝ)) : + (Real.log (n : ℝ)) ^ 2 / Real.sqrt (n : ℝ) ≤ (1 / 2 : ℝ) := by + have hnpos : 0 < (n : ℝ) := by exact_mod_cast (by omega : 0 < n) + have h := block_capture_exp_lower (Real.log (n : ℝ)) ht + rw [Real.exp_half, Real.exp_log hnpos] at h + apply (div_le_iff₀ (Real.sqrt_pos.2 hnpos)).2 + linarith + +/-- The numerical loss in the singleton-capture union bound is at most one half. -/ +theorem sqrt_block_capture_correction (n : ℕ) (v : ℝ) (hn : 2 ≤ n) + (ht : 16 ≤ Real.log (n : ℝ)) (hvone : 1 ≤ v) + (hv : v ≤ (Real.log (n : ℝ)) ^ 2) : + (v - 1) * (((⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) - 1) / ((n : ℝ) - 1)) ≤ + (1 / 2 : ℝ) := by + calc + (v - 1) * (((⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) - 1) / ((n : ℝ) - 1)) + ≤ (v - 1) * (1 / Real.sqrt (n : ℝ)) := + mul_le_mul_of_nonneg_left (sqrt_block_pair_ratio n hn) (by linarith) + _ ≤ (Real.log (n : ℝ)) ^ 2 * (1 / Real.sqrt (n : ℝ)) := + mul_le_mul_of_nonneg_right (by linarith) (by positivity) + _ = (Real.log (n : ℝ)) ^ 2 / Real.sqrt (n : ℝ) := by ring + _ ≤ 1 / 2 := log_square_div_sqrt_le_half n hn ht + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/BlockSymmetry.lean b/lean/OAI/Combinatorics/SharpThreshold/BlockSymmetry.lean new file mode 100644 index 0000000000000000000000000000000000000000..b780805fb5e4145304ff848b6333fa2d2fc25604 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/BlockSymmetry.lean @@ -0,0 +1,66 @@ +import Mathlib + +namespace OAI + +universe u v w + +noncomputable section + +namespace Problem313 + +/-- Assemble a configuration on a coordinate subset and its complement. -/ +def pasteCube {α : Type u} {β : Type v} (P : α → Prop) [DecidablePred P] + (x : {i // P i} → β) (y : {i // ¬ P i} → β) : α → β := + fun i => if hi : P i then x ⟨i, hi⟩ else y ⟨i, hi⟩ + +@[simp] +theorem pasteCube_of_pos {α : Type u} {β : Type v} (P : α → Prop) [DecidablePred P] + (x : {i // P i} → β) (y : {i // ¬ P i} → β) (i : α) (hi : P i) : + pasteCube P x y i = x ⟨i, hi⟩ := by + simp [pasteCube, hi] + +@[simp] +theorem pasteCube_of_neg {α : Type u} {β : Type v} (P : α → Prop) [DecidablePred P] + (x : {i // P i} → β) (y : {i // ¬ P i} → β) (i : α) (hi : ¬ P i) : + pasteCube P x y i = y ⟨i, hi⟩ := by + simp [pasteCube, hi] + +/-- A permutation preserving the free coordinates and fixing all exterior coordinates +commutes with pasting, without changing the fixed exterior configuration. -/ +theorem pasteCube_reindex {α : Type u} {β : Type v} (P : α → Prop) [DecidablePred P] + (π : Equiv.Perm α) (hP : ∀ i, P i ↔ P (π i)) + (hfix : ∀ i, ¬ P i → π i = i) + (x : {i // P i} → β) (y : {i // ¬ P i} → β) : + (fun i => pasteCube P x y (π.symm i)) = + pasteCube P (fun i => x ((π.subtypeEquiv hP).symm i)) y := by + funext i + by_cases hi : P i + · have hi' : P (π.symm i) := (hP _).mpr (by simpa using hi) + simp only [pasteCube, dite_eq_left hi, dite_eq_left hi'] + rfl + · have hsi : π.symm i = i := (π.symm_apply_eq).mpr (hfix i hi).symm + simp [pasteCube, hi, hsi] + +/-- Restriction of a function to a coordinate subset, with exterior values fixed. -/ +def restrictCube {α : Type u} {β : Type v} {γ : Type w} (P : α → Prop) [DecidablePred P] + (f : (α → β) → γ) (y : {i // ¬ P i} → β) : ({i // P i} → β) → γ := + fun x => f (pasteCube P x y) + +/-- Coordinate symmetry survives conditioning outside a set when the symmetry +fixes every exterior coordinate individually. -/ +theorem restrictCube_invariant {α : Type u} {β : Type v} {γ : Type w} (P : α → Prop) [DecidablePred P] + (π : Equiv.Perm α) (hP : ∀ i, P i ↔ P (π i)) + (hfix : ∀ i, ¬ P i → π i = i) (f : (α → β) → γ) + (hf : ∀ z, f (fun i => z (π.symm i)) = f z) + (x : {i // P i} → β) (y : {i // ¬ P i} → β) : + restrictCube P f y (fun i => x ((π.subtypeEquiv hP).symm i)) = + restrictCube P f y x := by + unfold restrictCube + rw [← pasteCube_reindex P π hP hfix x y] + exact hf _ + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/BooleanDerivative.lean b/lean/OAI/Combinatorics/SharpThreshold/BooleanDerivative.lean new file mode 100644 index 0000000000000000000000000000000000000000..fece2e2998f7f28c2f8aef4e2435c72b325616fa --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/BooleanDerivative.lean @@ -0,0 +1,64 @@ +import OAI.Combinatorics.SharpThreshold.Probability +import OAI.Combinatorics.SharpThreshold.InfluenceReindex + +namespace OAI + +universe u + +noncomputable section +namespace Problem313 + +@[simp] theorem boolReal_sub_abs (a b : Bool) : + |boolReal a - boolReal b| = if a ≠ b then 1 else 0 := by + cases a <;> cases b <;> norm_num [boolReal] + +@[simp] theorem boolReal_sub_sq (a b : Bool) : + (boolReal a - boolReal b) ^ 2 = if a ≠ b then 1 else 0 := by + cases a <;> cases b <;> norm_num [boolReal] + +@[simp] theorem boolReal_sub_fourth (a b : Bool) : + (boolReal a - boolReal b) ^ 4 = if a ≠ b then 1 else 0 := by + cases a <;> cases b <;> norm_num [boolReal] + +theorem boolReal_sub_mem (a b : Bool) : + boolReal a - boolReal b = -1 ∨ boolReal a - boolReal b = 0 ∨ + boolReal a - boolReal b = 1 := by + cases a <;> cases b <;> norm_num [boolReal] + +theorem boolReal_sub_abs_le_one (a b : Bool) : |boolReal a - boolReal b| ≤ 1 := by + rw [boolReal_sub_abs] + split_ifs <;> norm_num + +namespace Reindex +variable {ι : Type u} [Fintype ι] [dι : DecidableEq ι] + +theorem boolean_delta_abs_moment (p : ℝ) (f : (ι → Bool) → Bool) (i : ι) : + (∑ x, weight p x * |boolReal (f (Function.update x i true)) - + boolReal (f (Function.update x i false))|) = influence p f i := by + classical + have hd : dι = Classical.decEq ι := Subsingleton.elim _ _ + subst dι + simp only [boolReal_sub_abs, mul_ite, mul_one, mul_zero, influence] + +theorem boolean_delta_sq_moment (p : ℝ) (f : (ι → Bool) → Bool) (i : ι) : + (∑ x, weight p x * (boolReal (f (Function.update x i true)) - + boolReal (f (Function.update x i false))) ^ 2) = influence p f i := by + classical + have hd : dι = Classical.decEq ι := Subsingleton.elim _ _ + subst dι + simp only [boolReal_sub_sq, mul_ite, mul_one, mul_zero, influence] + +theorem boolean_delta_fourth_moment (p : ℝ) (f : (ι → Bool) → Bool) (i : ι) : + (∑ x, weight p x * (boolReal (f (Function.update x i true)) - + boolReal (f (Function.update x i false))) ^ 4) = influence p f i := by + classical + have hd : dι = Classical.decEq ι := Subsingleton.elim _ _ + subst dι + simp only [boolReal_sub_fourth, mul_ite, mul_one, mul_zero, influence] + +end Reindex +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/BooleanProjection.lean b/lean/OAI/Combinatorics/SharpThreshold/BooleanProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..2185c04907a23007ea7bd5b820898284c1730411 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/BooleanProjection.lean @@ -0,0 +1,68 @@ +import OAI.Combinatorics.SharpThreshold.FourierProjection +import OAI.Combinatorics.SharpThreshold.InfluenceReindex +import OAI.Combinatorics.SharpThreshold.Model + +namespace OAI + +universe u + +noncomputable section + +namespace Problem313.BiasedFourier + +open scoped BigOperators Classical + +variable {ι : Type u} [Fintype ι] + +/-- Low-degree projection bound for a Boolean coordinate difference, with the +pivotal probability expressed by the shared generic influence definition. -/ +theorem booleanDifference_project_energy_le {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (rho k : ℝ) (hrho : 0 < rho) (hrho1 : rho ≤ 1) + (hnoise : ∀ a : Finset ι → ℝ, + (∑ x, weight p x * + (∑ S, rho ^ S.card * a S * char p S x) ^ 4) ≤ + (∑ S, (a S) ^ 2) ^ 2) + (L : Finset (Finset ι)) (f : (ι → Bool) → Bool) (i : ι) + (hdegree : ∀ S ∈ L, (S.card : ℝ) ≤ k) : + (∑ S ∈ L, (coeff p + (fun x => boolReal (f (Function.update x i true)) - + boolReal (f (Function.update x i false))) S) ^ 2) ≤ + rho ^ (-2 * k) * (Reindex.influence p f i) ^ (3 / 2 : ℝ) := by + let g : (ι → Bool) → ℝ := fun x => + boolReal (f (Function.update x i true)) - + boolReal (f (Function.update x i false)) + have hg (x : ι → Bool) : g x = -1 ∨ g x = 0 ∨ g x = 1 := by + cases ht : f (Function.update x i true) <;> + cases hf : f (Function.update x i false) <;> simp [g, ht, hf, boolReal] + have hpiv : (∑ x, if g x ≠ 0 then weight p x else 0) = + Reindex.influence p f i := by + unfold Reindex.influence + apply Finset.sum_congr rfl + intro x hx + cases ht : f (Function.update x i true) <;> + cases hf : f (Function.update x i false) <;> + simp [g, ht, hf, boolReal, weight, scalarWeight, Reindex.weight] + simpa only [hpiv] using + project_energy_le_of_noise hp hp1 rho k hrho hrho1 hnoise L g hg hdegree + +/-- The Boolean coordinate-difference energy bound with a real degree cutoff. -/ +theorem booleanDifference_lowDegree_energy_le {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (rho k : ℝ) (hrho : 0 < rho) (hrho1 : rho ≤ 1) + (hnoise : ∀ a : Finset ι → ℝ, + (∑ x, weight p x * + (∑ S, rho ^ S.card * a S * char p S x) ^ 4) ≤ + (∑ S, (a S) ^ 2) ^ 2) + (f : (ι → Bool) → Bool) (i : ι) : + (∑ S ∈ (Finset.univ.filter fun S : Finset ι => (S.card : ℝ) ≤ k), + (coeff p (fun x => boolReal (f (Function.update x i true)) - + boolReal (f (Function.update x i false))) S) ^ 2) ≤ + rho ^ (-2 * k) * (Reindex.influence p f i) ^ (3 / 2 : ℝ) := by + apply booleanDifference_project_energy_le hp hp1 rho k hrho hrho1 hnoise _ f i + intro S hS + exact (Finset.mem_filter.mp hS).2 + +end Problem313.BiasedFourier + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/DirichletEnergy.lean b/lean/OAI/Combinatorics/SharpThreshold/DirichletEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..503048c85da8983eaee91591d06cbb74621d363e --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/DirichletEnergy.lean @@ -0,0 +1,64 @@ +import Mathlib + +namespace OAI + +universe u + +noncomputable section +namespace Problem313 +open Finset +variable {ι : Type u} [Fintype ι] [DecidableEq ι] + +/-- Delete a distinguished coordinate to reindex all supports containing it. -/ +theorem sum_supports_containing (i : ι) (a : Finset ι → ℝ) : + (∑ S : Finset ι, if i ∈ S then a S else 0) = + ∑ S : Finset ι, if i ∉ S then a (insert i S) else 0 := by + classical + rw [← Finset.sum_filter, ← Finset.sum_filter] + refine Finset.sum_bij' (fun S _ => S.erase i) (fun S _ => insert i S) ?_ ?_ ?_ ?_ ?_ + · intro S hS + simp + · intro S hS + simp + · intro S hS + exact Finset.insert_erase (Finset.mem_filter.mp hS).2 + · intro S hS + exact Finset.erase_insert (Finset.mem_filter.mp hS).2 + · intro S hS + rw [Finset.insert_erase (Finset.mem_filter.mp hS).2] + +/-- Algebraic coordinate energy identity from the derivative Fourier identities. -/ +theorem spectral_coordinate_energy (i : ι) (a b : Finset ι → ℝ) (σ : ℝ) + (hzero : ∀ S, i ∈ S → b S = 0) + (hinsert : ∀ S, i ∉ S → a (insert i S) = σ * b S) : + (∑ S : Finset ι, if i ∈ S then (a S)^2 else 0) = + σ^2 * ∑ S : Finset ι, (b S)^2 := by + rw [sum_supports_containing, Finset.mul_sum] + apply Finset.sum_congr rfl + intro S hS + by_cases hi : i ∈ S + · simp [hi, hzero S hi] + · simp [hi, hinsert S hi, mul_pow] + +/-- Counting each spectral support once for every coordinate it contains. -/ +theorem sum_card_mul_eq_sum_mem (a : Finset ι → ℝ) : + (∑ S : Finset ι, (S.card : ℝ) * a S) = + ∑ i : ι, ∑ S : Finset ι, if i ∈ S then a S else 0 := by + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro S hS + simp [Finset.sum_ite_mem, nsmul_eq_mul] + +/-- Summing coordinate energies gives the finite Dirichlet identity. -/ +theorem spectral_dirichlet (a : Finset ι → ℝ) (I : ι → ℝ) (σ : ℝ) + (hcoord : ∀ i, (∑ S : Finset ι, if i ∈ S then (a S)^2 else 0) = σ^2 * I i) : + (∑ S : Finset ι, (S.card : ℝ) * (a S)^2) = σ^2 * ∑ i, I i := by + rw [sum_card_mul_eq_sum_mem] + simp_rw [hcoord] + rw [Finset.mul_sum] + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/ExpQuadratic.lean b/lean/OAI/Combinatorics/SharpThreshold/ExpQuadratic.lean new file mode 100644 index 0000000000000000000000000000000000000000..9588f35304b658332827537bcb27799eca379339 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/ExpQuadratic.lean @@ -0,0 +1,72 @@ +import Mathlib + +namespace OAI + +noncomputable section + +namespace Problem313 + +/-- A deliberately generous quadratic-exponential estimate. -/ +lemma quadratic_mul_exp_neg_eighth_le (t : ℝ) (ht : 0 ≤ t) : + t ^ 2 * Real.exp (-t / 8) ≤ 256 := by + have hlin : t / 16 ≤ Real.exp (t / 16) := by + have h := Real.add_one_le_exp (t / 16) + linarith + have hsquare : (t / 16) ^ 2 ≤ (Real.exp (t / 16)) ^ 2 := by + exact pow_le_pow_left₀ (by positivity) hlin 2 + have hexp : (Real.exp (t / 16)) ^ 2 = Real.exp (t / 8) := by + rw [pow_two, ← Real.exp_add] + congr 1 + ring + rw [hexp] at hsquare + have hquad : t ^ 2 ≤ 256 * Real.exp (t / 8) := by + nlinarith + have hmul := mul_le_mul_of_nonneg_right hquad (le_of_lt (Real.exp_pos (-t / 8))) + have hcancel : Real.exp (t / 8) * Real.exp (-t / 8) = 1 := by + rw [← Real.exp_add] + have hzero : t / 8 + -t / 8 = 0 := by ring + rw [hzero, Real.exp_zero] + nlinarith [hcancel] + +/-- The exponentially small term in the block argument, with ample constant slack. -/ +lemma block_exponential_remainder_le (t ell : ℝ) (ht : 0 ≤ t) + (hell : t / 2 - Real.log 2 ≤ ell) : + (4 * Real.exp (-ell / 4)) * t ^ 2 ≤ 2048 := by + have hlog : 0 ≤ Real.log (2 : ℝ) := Real.log_nonneg (by norm_num) + have harg : -ell / 4 ≤ Real.log 2 - t / 8 := by linarith + have hmono : Real.exp (-ell / 4) ≤ 2 * Real.exp (-t / 8) := by + calc + Real.exp (-ell / 4) ≤ Real.exp (Real.log 2 + (-t / 8)) := + Real.exp_le_exp.mpr (by linarith) + _ = 2 * Real.exp (-t / 8) := by + rw [Real.exp_add, Real.exp_log (by norm_num : (0 : ℝ) < 2)] + have hquad := quadratic_mul_exp_neg_eighth_le t ht + have hmul := mul_le_mul_of_nonneg_right hmono (sq_nonneg t) + nlinarith + +/-- A form requiring only the logarithmic lower bound used for the spectral tail. -/ +lemma block_exponential_remainder_le_of_third (t ell : ℝ) (ht : 0 ≤ t) + (hell : t / 3 ≤ ell) : + (4 * Real.exp (-ell / 4)) * t ^ 2 ≤ 2304 := by + have hquad := quadratic_mul_exp_neg_eighth_le (2 * t / 3) (by positivity) + have harg : -(2 * t / 3) / 8 = -t / 12 := by ring + rw [harg] at hquad + have hmono : Real.exp (-ell / 4) ≤ Real.exp (-t / 12) := + Real.exp_le_exp.mpr (by linarith) + have hmul := mul_le_mul_of_nonneg_right hmono (sq_nonneg t) + nlinarith + +/-- The fractional-power form of the block remainder estimate. -/ +lemma block_rpow_remainder_le (t m : ℝ) (ht : 0 ≤ t) (hm : 0 < m) + (hm_log : t / 3 ≤ Real.log m) : + (4 * m ^ (-1 / 4 : ℝ)) * t ^ 2 ≤ 2304 := by + rw [Real.rpow_def_of_pos hm] + have harg : Real.log m * (-1 / 4 : ℝ) = -Real.log m / 4 := by ring + rw [harg] + exact block_exponential_remainder_le_of_third t (Real.log m) ht hm_log + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/FiniteParseval.lean b/lean/OAI/Combinatorics/SharpThreshold/FiniteParseval.lean new file mode 100644 index 0000000000000000000000000000000000000000..79d2302a4a8625eb38315373e42f8a4243b4ba67 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/FiniteParseval.lean @@ -0,0 +1,143 @@ +import Mathlib + +namespace OAI + +universe u v + +noncomputable section + +namespace Problem313.FiniteParseval + +open Finset Matrix + +variable {α : Type u} {Ω : Type v} [Fintype α] [Fintype Ω] [DecidableEq α] [DecidableEq Ω] + +/-- Fourier coefficient for an arbitrary finite weighted system. -/ +def coefficient (w : Ω → ℝ) (χ : α → Ω → ℝ) (f : Ω → ℝ) (a : α) : ℝ := + ∑ x, w x * f x * χ a x + +/-- A square weighted orthonormal system is complete. No positivity is needed +for this algebraic statement. -/ +theorem expansion (w : Ω → ℝ) (χ : α → Ω → ℝ) + (hcard : Fintype.card α = Fintype.card Ω) + (horth : ∀ a b, (∑ x, w x * χ a x * χ b x) = if a = b then 1 else 0) + (f : Ω → ℝ) (x : Ω) : + (∑ a, coefficient w χ f a * χ a x) = f x := by + let A : Matrix α Ω ℝ := fun a x => w x * χ a x + let B : Matrix Ω α ℝ := fun x a => χ a x + have hAB : A * B = 1 := by + ext a b + change (∑ x, w x * χ a x * χ b x) = if a = b then 1 else 0 + exact horth a b + have hBA : B * A = 1 := (Matrix.mul_eq_one_comm_of_equiv (Fintype.equivOfCardEq hcard)).mp hAB + have hAf : A *ᵥ f = fun a => coefficient w χ f a := by + funext a + simp only [Matrix.mulVec, dotProduct, A, coefficient] + apply Finset.sum_congr rfl + intro y hy + ring + calc + (∑ a, coefficient w χ f a * χ a x) = (B *ᵥ (A *ᵥ f)) x := by + rw [hAf] + simp only [Matrix.mulVec, dotProduct, B] + apply Finset.sum_congr rfl + intro a ha + ring + _ = f x := by rw [Matrix.mulVec_mulVec, hBA, Matrix.one_mulVec] + +/-- Parseval's bilinear identity for a finite weighted orthonormal system. -/ +theorem parseval_bilinear (w : Ω → ℝ) (χ : α → Ω → ℝ) + (hcard : Fintype.card α = Fintype.card Ω) + (horth : ∀ a b, (∑ x, w x * χ a x * χ b x) = if a = b then 1 else 0) + (f g : Ω → ℝ) : + (∑ a, coefficient w χ f a * coefficient w χ g a) = ∑ x, w x * f x * g x := by + simp only [coefficient, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro x hx + calc + (∑ a, (∑ y, w y * f y * χ a y) * (w x * g x * χ a x)) = + w x * g x * (∑ a, coefficient w χ f a * χ a x) := by + simp only [Finset.mul_sum, coefficient] + apply Finset.sum_congr rfl + intro a ha + ring + _ = w x * f x * g x := by rw [expansion w χ hcard horth]; ring + +/-- The usual sum-of-squares Parseval identity. -/ +theorem parseval (w : Ω → ℝ) (χ : α → Ω → ℝ) + (hcard : Fintype.card α = Fintype.card Ω) + (horth : ∀ a b, (∑ x, w x * χ a x * χ b x) = if a = b then 1 else 0) + (f : Ω → ℝ) : + (∑ a, (coefficient w χ f a)^2) = ∑ x, w x * (f x)^2 := by + simpa only [pow_two, mul_assoc] using parseval_bilinear w χ hcard horth f f + +/-- Synthesis using only a selected finite set of spectral coordinates. -/ +def synthesis (χ : α → Ω → ℝ) (c : α → ℝ) (s : Finset α) (x : Ω) : ℝ := + ∑ a ∈ s, c a * χ a x + +omit [Fintype α] [DecidableEq Ω] in +theorem coefficient_synthesis (w : Ω → ℝ) (χ : α → Ω → ℝ) + (horth : ∀ a b, (∑ x, w x * χ a x * χ b x) = if a = b then 1 else 0) + (c : α → ℝ) (s : Finset α) (a : α) : + coefficient w χ (synthesis χ c s) a = if a ∈ s then c a else 0 := by + unfold coefficient synthesis + simp_rw [Finset.mul_sum, Finset.sum_mul] + rw [Finset.sum_comm] + calc + (∑ b ∈ s, ∑ x, w x * (c b * χ b x) * χ a x) = + ∑ b ∈ s, c b * (∑ x, w x * χ b x * χ a x) := by + apply Finset.sum_congr rfl + intro b hb + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro x hx + ring + _ = if a ∈ s then c a else 0 := by simp_rw [horth]; simp + +omit [Fintype α] [DecidableEq α] [DecidableEq Ω] in +theorem inner_synthesis (w : Ω → ℝ) (χ : α → Ω → ℝ) + (f : Ω → ℝ) (c : α → ℝ) (s : Finset α) : + (∑ x, w x * f x * synthesis χ c s x) = + ∑ a ∈ s, c a * coefficient w χ f a := by + simp only [synthesis, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro a ha + simp only [coefficient, Finset.mul_sum] + apply Finset.sum_congr rfl + intro x hx + ring + +omit [Fintype α] [DecidableEq Ω] in +theorem synthesis_sq (w : Ω → ℝ) (χ : α → Ω → ℝ) + (horth : ∀ a b, (∑ x, w x * χ a x * χ b x) = if a = b then 1 else 0) + (c : α → ℝ) (s : Finset α) : + (∑ x, w x * (synthesis χ c s x)^2) = ∑ a ∈ s, (c a)^2 := by + calc + (∑ x, w x * (synthesis χ c s x)^2) = + ∑ x, w x * synthesis χ c s x * synthesis χ c s x := by + simp only [pow_two, mul_assoc] + _ = ∑ a ∈ s, c a * coefficient w χ (synthesis χ c s) a := + inner_synthesis w χ (synthesis χ c s) c s + _ = ∑ a ∈ s, (c a)^2 := by + apply Finset.sum_congr rfl + intro a ha + rw [coefficient_synthesis w χ horth, ite_eq_left ha, pow_two] + +omit [Fintype α] [DecidableEq Ω] in +/-- The algebraic orthogonal-projection identity used by the low-degree +Hölder estimate. -/ +theorem projection_inner_eq_sq (w : Ω → ℝ) (χ : α → Ω → ℝ) + (horth : ∀ a b, (∑ x, w x * χ a x * χ b x) = if a = b then 1 else 0) + (f : Ω → ℝ) (s : Finset α) : + (∑ x, w x * f x * synthesis χ (coefficient w χ f) s x) = + ∑ x, w x * (synthesis χ (coefficient w χ f) s x)^2 := by + rw [inner_synthesis, synthesis_sq w χ horth] + simp only [pow_two] + +end Problem313.FiniteParseval + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/FourierAnalysis.lean b/lean/OAI/Combinatorics/SharpThreshold/FourierAnalysis.lean new file mode 100644 index 0000000000000000000000000000000000000000..8834f5421411bc1b6b60a2f8c678accf44155f63 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/FourierAnalysis.lean @@ -0,0 +1,11 @@ +import OAI.Combinatorics.SharpThreshold.FourierBasis +import OAI.Combinatorics.SharpThreshold.FourierOrthogonality +import OAI.Combinatorics.SharpThreshold.FourierOption +import OAI.Combinatorics.SharpThreshold.FourierRestriction +import OAI.Combinatorics.SharpThreshold.FourierNoise +import OAI.Combinatorics.SharpThreshold.TwoPoint +import OAI.Combinatorics.SharpThreshold.HypercontractiveTensor + +/-! +Finite biased Fourier analysis and scalar and tensor fourth-moment estimates. +-/ diff --git a/lean/OAI/Combinatorics/SharpThreshold/FourierBasis.lean b/lean/OAI/Combinatorics/SharpThreshold/FourierBasis.lean new file mode 100644 index 0000000000000000000000000000000000000000..fe00373b079ab5e488e901342d81fb8b58f28b5c --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/FourierBasis.lean @@ -0,0 +1,164 @@ +import Mathlib + +namespace OAI + +universe u v + +noncomputable section + +open scoped BigOperators + +namespace Problem313.BiasedFourier + +variable {ι : Type u} [Fintype ι] + +def scalarWeight (p : ℝ) (b : Bool) : ℝ := + if b = true then p else 1 - p + +def weight (p : ℝ) (x : ι → Bool) : ℝ := + ∏ i, scalarWeight p (x i) + +def chi (p : ℝ) (b : Bool) : ℝ := + ((if b = true then (1 : ℝ) else 0) - p) / Real.sqrt (p * (1 - p)) + +def char (p : ℝ) (S : Finset ι) (x : ι → Bool) : ℝ := + ∏ i ∈ S, chi p (x i) + +def coeff (p : ℝ) (g : (ι → Bool) → ℝ) (S : Finset ι) : ℝ := by + classical + exact ∑ x, weight p x * g x * char p S x + +@[simp] theorem scalarWeight_false (p : ℝ) : scalarWeight p false = 1 - p := rfl +@[simp] theorem scalarWeight_true (p : ℝ) : scalarWeight p true = p := rfl +@[simp] theorem chi_false (p : ℝ) : + chi p false = -p / Real.sqrt (p * (1 - p)) := by simp [chi] +@[simp] theorem chi_true (p : ℝ) : + chi p true = (1 - p) / Real.sqrt (p * (1 - p)) := rfl +omit [Fintype ι] in +@[simp] theorem char_empty (p : ℝ) (x : ι → Bool) : char p ∅ x = 1 := by + simp [char] + +theorem scalar_kernel {p : ℝ} (hp : 0 < p) (hp1 : p < 1) (b c : Bool) : + scalarWeight p c * (1 + chi p b * chi p c) = if b = c then 1 else 0 := by + have hpos : 0 < p * (1 - p) := mul_pos hp (sub_pos.mpr hp1) + have hs : Real.sqrt (p * (1 - p)) ^ 2 = p * (1 - p) := + Real.sq_sqrt hpos.le + have hn : Real.sqrt (p * (1 - p)) ≠ 0 := ne_of_gt (Real.sqrt_pos.2 hpos) + cases b <;> cases c <;> simp only [scalarWeight, chi, Bool.false_eq_true, + Bool.true_eq_false, ite_false, ite_true, zero_sub] + all_goals field_simp + all_goals nlinarith [hs] + +theorem character_kernel {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (x y : ι → Bool) : + weight p y * (∑ S : Finset ι, char p S x * char p S y) = + if x = y then 1 else 0 := by + classical + have hk : (∑ S : Finset ι, char p S x * char p S y) = + ∏ i, (1 + chi p (x i) * chi p (y i)) := by + simpa [char, Finset.prod_mul_distrib] using + (Finset.prod_one_add (f := fun i : ι => chi p (x i) * chi p (y i)) + Finset.univ).symm + rw [hk, weight, ← Finset.prod_mul_distrib] + simp_rw [scalar_kernel hp hp1] + simp [Fintype.prod_ite_zero, funext_iff] + +theorem inversion {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (g : (ι → Bool) → ℝ) (x : ι → Bool) : + ∑ S : Finset ι, coeff p g S * char p S x = g x := by + classical + simp_rw [coeff, Finset.sum_mul] + rw [Finset.sum_comm] + calc + (∑ y, ∑ S : Finset ι, weight p y * g y * char p S y * char p S x) = + ∑ y, g y * (weight p y * ∑ S : Finset ι, char p S x * char p S y) := by + apply Finset.sum_congr rfl + intro y hy + simp_rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro S hS + ring + _ = ∑ y, g y * (if x = y then 1 else 0) := by + simp_rw [character_kernel hp hp1] + _ = g x := by simp + +theorem parseval [DecidableEq ι] {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (g : (ι → Bool) → ℝ) : + (∑ S : Finset ι, coeff p g S ^ 2) = ∑ x, weight p x * (g x) ^ 2 := by + classical + calc + (∑ S : Finset ι, coeff p g S ^ 2) = + ∑ S : Finset ι, ∑ x, weight p x * g x * (coeff p g S * char p S x) := by + apply Finset.sum_congr rfl + intro S hS + conv_lhs => rw [pow_two, coeff] + rw [Finset.sum_mul] + apply Finset.sum_congr (by ext; simp) + intro x hx + dsimp [coeff] + ring + _ = ∑ x, weight p x * g x * (∑ S : Finset ι, coeff p g S * char p S x) := by + rw [Finset.sum_comm] + simp_rw [Finset.mul_sum] + _ = ∑ x, weight p x * (g x) ^ 2 := by + simp_rw [inversion hp hp1] + apply Finset.sum_congr rfl + intro x hx + ring + +theorem coeff_zero (p : ℝ) (S : Finset ι) : + coeff p (fun _ : ι → Bool => 0) S = 0 := by + classical + simp [coeff] + +theorem coeff_add (p : ℝ) (g h : (ι → Bool) → ℝ) (S : Finset ι) : + coeff p (fun x => g x + h x) S = coeff p g S + coeff p h S := by + classical + simp [coeff, mul_add, add_mul, Finset.sum_add_distrib] + +theorem coeff_sub (p : ℝ) (g h : (ι → Bool) → ℝ) (S : Finset ι) : + coeff p (fun x => g x - h x) S = coeff p g S - coeff p h S := by + classical + simp [coeff, mul_sub, sub_mul, Finset.sum_sub_distrib] + +theorem coeff_smul (p c : ℝ) (g : (ι → Bool) → ℝ) (S : Finset ι) : + coeff p (fun x => c * g x) S = c * coeff p g S := by + classical + simp only [coeff, Finset.mul_sum] + apply Finset.sum_congr rfl + intro x hx + ring + +theorem coeff_sum {κ : Type v} (p : ℝ) (s : Finset κ) + (g : κ → (ι → Bool) → ℝ) (S : Finset ι) : + coeff p (fun x => ∑ j ∈ s, g j x) S = ∑ j ∈ s, coeff p (g j) S := by + classical + simp only [coeff, Finset.mul_sum, Finset.sum_mul] + rw [Finset.sum_comm] + +theorem inner_parseval [DecidableEq ι] {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (g h : (ι → Bool) → ℝ) : + (∑ S : Finset ι, coeff p g S * coeff p h S) = + ∑ x, weight p x * g x * h x := by + classical + calc + (∑ S : Finset ι, coeff p g S * coeff p h S) = + ∑ S : Finset ι, ∑ x, weight p x * g x * (coeff p h S * char p S x) := by + apply Finset.sum_congr rfl + intro S hS + conv_lhs => lhs; unfold coeff + rw [Finset.sum_mul] + apply Finset.sum_congr (by ext; simp) + intro x hx + ring + _ = ∑ x, weight p x * g x * (∑ S : Finset ι, coeff p h S * char p S x) := by + rw [Finset.sum_comm] + simp_rw [Finset.mul_sum] + _ = ∑ x, weight p x * g x * h x := by + simp_rw [inversion hp hp1] + +end Problem313.BiasedFourier + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/FourierDerivative.lean b/lean/OAI/Combinatorics/SharpThreshold/FourierDerivative.lean new file mode 100644 index 0000000000000000000000000000000000000000..8c26f223117a79d8a088d9534940b4dcfbc476f3 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/FourierDerivative.lean @@ -0,0 +1,150 @@ +import OAI.Combinatorics.SharpThreshold.FourierBasis +import OAI.Combinatorics.SharpThreshold.RussoReindex + +namespace OAI + +universe u + +noncomputable section +open scoped BigOperators +namespace Problem313.BiasedFourier + +variable {ι : Type u} [DecidableEq ι] + +/-- The discrete derivative, retained as a function on the full cube. -/ +def delta (i : ι) (g : (ι → Bool) → ℝ) (x : ι → Bool) : ℝ := + g (Function.update x i true) - g (Function.update x i false) + +@[simp] theorem delta_update (i : ι) (g : (ι → Bool) → ℝ) + (x : ι → Bool) (b : Bool) : + delta i g (Function.update x i b) = delta i g x := by + simp [delta, Function.update_idem] + +@[simp] theorem delta_delta_fun (i : ι) (g : (ι → Bool) → ℝ) : + delta i (delta i g) = 0 := by + funext x + simp [delta, Function.update_idem] + +@[simp] theorem delta_delta (i : ι) (g : (ι → Bool) → ℝ) (x : ι → Bool) : + delta i (delta i g) x = 0 := by simp [delta] + +private theorem char_update_aux (p : ℝ) (S : Finset ι) (i : ι) (hi : i ∉ S) + (x : ι → Bool) (b : Bool) : char p S (Function.update x i b) = char p S x := by + unfold char + apply Finset.prod_congr rfl + intro j hj + rw [Function.update_of_ne (ne_of_mem_of_not_mem hj hi)] + +theorem char_update_of_not_mem (p : ℝ) (S : Finset ι) (x : ι → Bool) + (i : ι) (b : Bool) (hi : i ∉ S) : + char p S (Function.update x i b) = char p S x := + char_update_aux p S i hi x b + +variable [Fintype ι] + +/-- Integration by parts against one normalized biased character. -/ +theorem integral_chi_eq_sqrt_mul_delta {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (i : ι) (g : (ι → Bool) → ℝ) : + (∑ x, weight p x * g x * chi p (x i)) = + Real.sqrt (p * (1-p)) * ∑ x, weight p x * delta i g x := by + have hpos : 0 < p * (1-p) := mul_pos hp (sub_pos.mpr hp1) + have hs : Real.sqrt (p * (1-p)) ≠ 0 := ne_of_gt (Real.sqrt_pos.2 hpos) + have hsq : Real.sqrt (p * (1-p)) ^ 2 = p * (1-p) := Real.sq_sqrt hpos.le + calc + _ = (∑ x, weight p x * g x * ((if x i = true then (1:ℝ) else 0)-p)) / + Real.sqrt (p * (1-p)) := by + simp only [chi, Finset.sum_div, mul_div_assoc] + _ = (p * (1-p) * ∑ x, weight p x * delta i g x) / + Real.sqrt (p * (1-p)) := by + congr 1 + exact sum_weight_centered_coordinate p i g + _ = _ := by + apply (div_eq_iff hs).2 + calc + _ = Real.sqrt (p * (1-p)) ^ 2 * (∑ x, weight p x * delta i g x) := by rw [hsq] + _ = _ := by ring + +/-- Fourier coefficients of a coordinate derivative, with the same full cube on both sides. -/ +theorem coeff_insert_eq_sqrt_mul_delta {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (g : (ι → Bool) → ℝ) (i : ι) (A : Finset ι) (hi : i ∉ A) : + coeff p g (insert i A) = + Real.sqrt (p * (1-p)) * coeff p (delta i g) A := by + classical + have hpos : 0 < p * (1-p) := mul_pos hp (sub_pos.mpr hp1) + have hs : Real.sqrt (p * (1-p)) ^ 2 = p * (1-p) := Real.sq_sqrt hpos.le + have hn : Real.sqrt (p * (1-p)) ≠ 0 := ne_of_gt (Real.sqrt_pos.2 hpos) + have hc := Problem313.sum_weight_centered_coordinate p i (fun x => g x * char p A x) + have hcenter : + (∑ x, weight p x * (g x * char p A x) * + ((if x i = true then (1 : ℝ) else 0)-p)) = + p * (1-p) * coeff p (delta i g) A := by + calc + _ = p * (1-p) * ∑ x, weight p x * + (g (Function.update x i true) * char p A (Function.update x i true) - + g (Function.update x i false) * char p A (Function.update x i false)) := hc + _ = _ := by + congr 1 + unfold coeff + apply Finset.sum_congr (by ext; simp) + intro x hx + rw [char_update_aux p A i hi, char_update_aux p A i hi] + unfold delta + ring + apply mul_left_cancel₀ hn + calc + Real.sqrt (p * (1-p)) * coeff p g (insert i A) = + ∑ x, weight p x * (g x * char p A x) * + ((if x i = true then (1 : ℝ) else 0)-p) := by + rw [coeff, Finset.mul_sum] + apply Finset.sum_congr (by ext; simp) + intro x hx + rw [char, Finset.prod_insert hi] + change Real.sqrt (p * (1-p)) * + (weight p x * g x * (chi p (x i) * char p A x)) = _ + unfold chi + field_simp + _ = p * (1-p) * coeff p (delta i g) A := hcenter + _ = Real.sqrt (p * (1-p)) * + (Real.sqrt (p * (1-p)) * coeff p (delta i g) A) := by rw [← mul_assoc, ← pow_two, hs] + +/-- Erasing a coordinate from a nonzero-degree coefficient gives the derivative coefficient. -/ +theorem coeff_eq_sqrt_mul_delta_erase {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (g : (ι → Bool) → ℝ) (i : ι) (S : Finset ι) (hi : i ∈ S) : + coeff p g S = Real.sqrt (p * (1-p)) * coeff p (delta i g) (S.erase i) := by + conv_lhs => rw [← Finset.insert_erase hi] + exact coeff_insert_eq_sqrt_mul_delta hp hp1 g i (S.erase i) (Finset.notMem_erase i S) + +/-- Squared Fourier derivative identity, in the normalization used by Dirichlet energy. -/ +theorem coeff_sq_eq_variance_mul_delta_erase_sq {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (g : (ι → Bool) → ℝ) (i : ι) (S : Finset ι) (hi : i ∈ S) : + coeff p g S ^ 2 = p * (1-p) * coeff p (delta i g) (S.erase i) ^ 2 := by + rw [coeff_eq_sqrt_mul_delta_erase hp hp1 g i S hi, mul_pow, + Real.sq_sqrt (mul_nonneg hp.le (sub_nonneg.mpr hp1.le))] + +/-- A coordinate derivative has no Fourier support containing that coordinate. -/ +theorem coeff_delta_eq_zero_of_mem {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (g : (ι → Bool) → ℝ) (i : ι) (S : Finset ι) (hi : i ∈ S) : + coeff p (delta i g) S = 0 := by + classical + rw [← Finset.insert_erase hi] + rw [coeff_insert_eq_sqrt_mul_delta hp hp1 (delta i g) i (S.erase i) + (Finset.notMem_erase i S)] + simp [coeff] + +/-- The Fourier derivative identity with coordinate-first parameter order. -/ +theorem coeff_insert_eq_sqrt_mul_coeff_delta {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (i : ι) (g : (ι → Bool) → ℝ) (A : Finset ι) (hi : i ∉ A) : + coeff p g (insert i A) = Real.sqrt (p * (1-p)) * coeff p (delta i g) A := + coeff_insert_eq_sqrt_mul_delta hp hp1 g i A hi + +/-- The Fourier derivative identity with coordinate-first parameter order. -/ +theorem coeff_delta_eq_zero {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (i : ι) (g : (ι → Bool) → ℝ) (S : Finset ι) (hi : i ∈ S) : + coeff p (delta i g) S = 0 := + coeff_delta_eq_zero_of_mem hp hp1 g i S hi + +end Problem313.BiasedFourier + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/FourierDirichlet.lean b/lean/OAI/Combinatorics/SharpThreshold/FourierDirichlet.lean new file mode 100644 index 0000000000000000000000000000000000000000..47f1930eb57baac52a31d54bf2457801b8c45c8a --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/FourierDirichlet.lean @@ -0,0 +1,103 @@ +import OAI.Combinatorics.SharpThreshold.FourierDerivative +import OAI.Combinatorics.SharpThreshold.BooleanDerivative +import OAI.Combinatorics.SharpThreshold.DirichletEnergy + +namespace OAI + +universe u + +noncomputable section + +namespace Problem313.BiasedFourier + +open Finset +variable {ι : Type u} [Fintype ι] [DecidableEq ι] + +/-- The coordinate Dirichlet identity, with only the two derivative coefficient +identities isolated as hypotheses. -/ +theorem coordinate_energy_of_coeff_derivative {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (g dg : (ι → Bool) → ℝ) (i : ι) + (hzero : ∀ S, i ∈ S → coeff p dg S = 0) + (hinsert : ∀ S, i ∉ S → coeff p g (insert i S) = + Real.sqrt (p * (1 - p)) * coeff p dg S) : + (∑ S : Finset ι, if i ∈ S then (coeff p g S)^2 else 0) = + p * (1 - p) * ∑ x, weight p x * (dg x)^2 := by + rw [Problem313.spectral_coordinate_energy i (coeff p g) (coeff p dg) + (Real.sqrt (p * (1 - p))) hzero hinsert] + rw [parseval hp hp1, Real.sq_sqrt (mul_nonneg hp.le (sub_nonneg.mpr hp1.le))] + +/-- Summing coordinate Dirichlet identities gives degree-weighted Fourier energy. -/ +theorem total_energy_of_coordinate_energy {p : ℝ} + (g : (ι → Bool) → ℝ) (E : ι → ℝ) + (hcoord : ∀ i, (∑ S : Finset ι, if i ∈ S then (coeff p g S)^2 else 0) = + p * (1 - p) * E i) : + (∑ S : Finset ι, (S.card : ℝ) * (coeff p g S)^2) = + p * (1 - p) * ∑ i, E i := by + rw [Problem313.sum_card_mul_eq_sum_mem] + simp_rw [hcoord] + rw [Finset.mul_sum] + +/-- The Fourier mass on supports containing a fixed coordinate equals its +weighted squared discrete derivative. -/ +theorem coordinate_dirichlet {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (g : (ι → Bool) → ℝ) (i : ι) : + (∑ S : Finset ι, if i ∈ S then (coeff p g S)^2 else 0) = + p * (1 - p) * ∑ x, weight p x * (delta i g x)^2 := by + exact coordinate_energy_of_coeff_derivative hp hp1 g (delta i g) i + (fun S hS => coeff_delta_eq_zero_of_mem hp hp1 g i S hS) + (fun S hS => coeff_insert_eq_sqrt_mul_delta hp hp1 g i S hS) + +/-- The full finite-cube Fourier Dirichlet identity for real observables. -/ +theorem dirichlet {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (g : (ι → Bool) → ℝ) : + (∑ S : Finset ι, (S.card : ℝ) * (coeff p g S)^2) = + p * (1 - p) * ∑ i, ∑ x, weight p x * (delta i g x)^2 := by + exact total_energy_of_coordinate_energy g _ (coordinate_dirichlet hp hp1 g) + +/-- For Boolean observables, squared derivative energy is pivotal influence. -/ +theorem boolean_coordinate_dirichlet {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (f : (ι → Bool) → Bool) (i : ι) : + (∑ S : Finset ι, if i ∈ S then (coeff p (fun x => boolReal (f x)) S)^2 else 0) = + p * (1 - p) * Reindex.influence p f i := by + rw [coordinate_dirichlet hp hp1] + congr 1 + simpa only [delta, weight, scalarWeight, Reindex.weight] using + Reindex.boolean_delta_sq_moment p f i + +/-- The degree-weighted Fourier mass of a Boolean function is its total pivotal +influence times the Bernoulli variance. -/ +theorem boolean_dirichlet {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (f : (ι → Bool) → Bool) : + (∑ S : Finset ι, (S.card : ℝ) * (coeff p (fun x => boolReal (f x)) S)^2) = + p * (1 - p) * ∑ i, Reindex.influence p f i := by + exact total_energy_of_coordinate_energy _ _ (boolean_coordinate_dirichlet hp hp1 f) + +end Problem313.BiasedFourier + +namespace Problem313 + +/-- The graph Dirichlet identity for pivotal total influence. -/ +theorem graph_fourier_dirichlet {n : ℕ} {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (f : GraphConfig n → Bool) : + (∑ S : Finset (GraphEdge n), (S.card : ℝ) * + (BiasedFourier.coeff p (fun x => boolReal (f x)) S)^2) = + p * (1 - p) * totalInfluence p f := by + classical + have hi : (∑ e : GraphEdge n, Reindex.influence p f e) = totalInfluence p f := by + unfold totalInfluence + apply Finset.sum_congr rfl + intro e he + unfold Reindex.influence edgeInfluence + apply Finset.sum_congr (by ext; simp) + intro x hx + congr 1 + congr 4 <;> exact Subsingleton.elim _ _ + have h := BiasedFourier.boolean_dirichlet hp hp1 f + rw [hi] at h + exact h + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/FourierHypercontractive.lean b/lean/OAI/Combinatorics/SharpThreshold/FourierHypercontractive.lean new file mode 100644 index 0000000000000000000000000000000000000000..9dcdfce3fae1b4b54bc0a1a6a5085947855852ba --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/FourierHypercontractive.lean @@ -0,0 +1,129 @@ +import OAI.Combinatorics.SharpThreshold.FourierOption +import OAI.Combinatorics.SharpThreshold.FourierOptionExpectation +import OAI.Combinatorics.SharpThreshold.FourierReindex +import OAI.Combinatorics.SharpThreshold.TwoPoint +import OAI.Combinatorics.SharpThreshold.HypercontractiveTensor + +namespace OAI + +universe u + +noncomputable section + +namespace Problem313.BiasedFourier + +attribute [local instance] Classical.propDecidable +attribute [local instance] Classical.decEq + +/-- The scalar hypercontractive estimate in normalized character notation. -/ +theorem scalar_synthesis_fourth {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (a b : ℝ) : + (1 - p) * (a + (Real.sqrt (p * (1-p)) / 4) * chi p false * b) ^ 4 + + p * (a + (Real.sqrt (p * (1-p)) / 4) * chi p true * b) ^ 4 ≤ + (a ^ 2 + b ^ 2) ^ 2 := by + have hs : Real.sqrt (p * (1 - p)) ≠ 0 := + ne_of_gt (Real.sqrt_pos.2 (mul_pos hp (sub_pos.mpr hp1))) + have hfalse : (Real.sqrt (p * (1-p)) / 4) * chi p false = -p / 4 := by + rw [chi_false] + field_simp + have htrue : (Real.sqrt (p * (1-p)) / 4) * chi p true = (1-p) / 4 := by + rw [chi_true] + field_simp + rw [hfalse, htrue] + convert Problem313.biased_two_point_fourth_moment p a b hp.le hp1.le using 1; ring + +/-- Tensorization step for an additional Boolean coordinate, in spectral form. -/ +theorem synthesis_fourth_option_of_split {ι : Type u} [Fintype ι] + {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (hsplit : ∀ g : (Option ι → Bool) → ℝ, + (∑ x, weight p x * g x) = + (1-p) * (∑ y : ι → Bool, weight p y * g (fun t => Option.elim t false y)) + + p * (∑ y : ι → Bool, weight p y * g (fun t => Option.elim t true y))) + (ih : ∀ c : Finset ι → ℝ, + (∑ x, weight p x * (∑ S, (Real.sqrt (p*(1-p))/4) ^ S.card * + c S * char p S x) ^ 4) ≤ (∑ S, c S ^ 2) ^ 2) + (c : Finset (Option ι) → ℝ) : + (∑ x, weight p x * (∑ S, (Real.sqrt (p*(1-p))/4) ^ S.card * + c S * char p S x) ^ 4) ≤ (∑ S, c S ^ 2) ^ 2 := by + classical + let ρ := Real.sqrt (p*(1-p))/4 + let c₀ : Finset ι → ℝ := fun S => c (S.map Function.Embedding.some) + let c₁ : Finset ι → ℝ := fun S => c (Finset.insertNone S) + let A : (ι → Bool) → ℝ := fun x => ∑ S, ρ ^ S.card * c₀ S * char p S x + let B : (ι → Bool) → ℝ := fun x => ∑ S, ρ ^ S.card * c₁ S * char p S x + have hw : ∀ x : ι → Bool, 0 ≤ weight p x := by + intro x + apply Finset.prod_nonneg + intro i hi + cases x i <;> simp [scalarWeight] <;> linarith + have hA : (∑ x, weight p x * (A x) ^ 4) ≤ (∑ S, c₀ S ^ 2) ^ 2 := ih c₀ + have hB : (∑ x, weight p x * (B x) ^ 4) ≤ (∑ S, c₁ S ^ 2) ^ 2 := ih c₁ + have hbound := Problem313.weighted_fourth_moment_add_sq Finset.univ + (weight p) A B (∑ S, c₀ S ^ 2) (∑ S, c₁ S ^ 2) + (fun x _ => hw x) (Finset.sum_nonneg (fun _ _ => sq_nonneg _)) + (Finset.sum_nonneg (fun _ _ => sq_nonneg _)) hA hB + rw [coefficient_energy_option] + change _ ≤ ((∑ S, c₀ S ^ 2) + ∑ S, c₁ S ^ 2) ^ 2 + calc + _ = (1-p) * (∑ x, weight p x * (A x + ρ * chi p false * B x) ^ 4) + + p * (∑ x, weight p x * (A x + ρ * chi p true * B x) ^ 4) := by + rw [hsplit] + simp only [synthesis_option] + rfl + _ = ∑ x, weight p x * ((1-p) * (A x + ρ * chi p false * B x) ^ 4 + + p * (A x + ρ * chi p true * B x) ^ 4) := by + simp only [Finset.mul_sum, ← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro x hx + ring + _ ≤ ∑ x, weight p x * ((A x) ^ 2 + (B x) ^ 2) ^ 2 := by + apply Finset.sum_le_sum + intro x hx + exact mul_le_mul_of_nonneg_left (scalar_synthesis_fourth hp hp1 (A x) (B x)) (hw x) + _ ≤ _ := hbound + +/-- Initial case of the finite-coordinate tensorization induction. -/ +theorem synthesis_fourth_empty {ι : Type u} [Fintype ι] [IsEmpty ι] + (p : ℝ) (c : Finset ι → ℝ) : + (∑ x : ι → Bool, weight p x * + (∑ S, (Real.sqrt (p*(1-p))/4) ^ S.card * c S * char p S x) ^ 4) ≤ + (∑ S, c S ^ 2) ^ 2 := by + have he : (default : Finset ι) = ∅ := Subsingleton.elim _ _ + simp [weight, char, he] + ring_nf + exact le_rfl + +/-- Biased product hypercontractivity in its root-free, arbitrary-coefficient form. -/ +theorem synthesis_fourth_bound {ι : Type u} [Fintype ι] + {p : ℝ} (hp : 0 < p) (hp1 : p < 1) (c : Finset ι → ℝ) : + (∑ x, weight p x * (∑ S, (Real.sqrt (p*(1-p))/4) ^ S.card * + c S * char p S x) ^ 4) ≤ (∑ S, c S ^ 2) ^ 2 := by + classical + refine Fintype.induction_empty_option + (P := fun α _ => ∀ c : Finset α → ℝ, + (∑ x, weight p x * (∑ S, (Real.sqrt (p*(1-p))/4) ^ S.card * + c S * char p S x) ^ 4) ≤ (∑ S, c S ^ 2) ^ 2) ?_ ?_ ?_ ι c + · intro α β _ e h d + let : Fintype α := Fintype.ofEquiv β e.symm + exact synthesis_contraction_reindex e p (Real.sqrt (p*(1-p))/4) h d + · exact synthesis_fourth_empty p + · intro α _ h d + convert! synthesis_fourth_option_of_split hp hp1 (weighted_sum_option p) h d using 1 + apply Finset.sum_congr (by ext x; simp) + intro x hx + rfl + +/-- The noise operator contracts the weighted second moment into the fourth moment. -/ +theorem noise_fourth_bound {ι : Type u} [Fintype ι] + {p : ℝ} (hp : 0 < p) (hp1 : p < 1) (g : (ι → Bool) → ℝ) : + (∑ x, weight p x * (∑ S, (Real.sqrt (p*(1-p))/4) ^ S.card * + coeff p g S * char p S x) ^ 4) ≤ (∑ x, weight p x * (g x) ^ 2) ^ 2 := by + have h := synthesis_fourth_bound hp hp1 (coeff p g) + rw [parseval hp hp1 g] at h + exact h + +end Problem313.BiasedFourier + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/FourierNoise.lean b/lean/OAI/Combinatorics/SharpThreshold/FourierNoise.lean new file mode 100644 index 0000000000000000000000000000000000000000..a3800974b192baef910797a2b384a8a9324cc3a2 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/FourierNoise.lean @@ -0,0 +1,130 @@ +import OAI.Combinatorics.SharpThreshold.FourierBasis + +namespace OAI + +universe u v w + +noncomputable section + +namespace Problem313.Spectral + +variable {Ω : Type u} {S : Type v} [Fintype Ω] [Fintype S] [DecidableEq S] + +def coefficient (w : Ω → ℝ) (χ : S → Ω → ℝ) (f : Ω → ℝ) (s : S) : ℝ := + ∑ x, w x * f x * χ s x + +def synthesis (χ : S → Ω → ℝ) (a : S → ℝ) (x : Ω) : ℝ := + ∑ s, a s * χ s x + +def multiplier (w : Ω → ℝ) (χ : S → Ω → ℝ) (symbol : S → ℝ) + (f : Ω → ℝ) : Ω → ℝ := + synthesis χ (fun s => symbol s * coefficient w χ f s) + +/-- Orthogonality diagonalizes every spectral multiplier. -/ +theorem coefficient_synthesis (w : Ω → ℝ) (χ : S → Ω → ℝ) + (horth : ∀ s t, (∑ x, w x * χ s x * χ t x) = if s = t then 1 else 0) + (a : S → ℝ) (t : S) : + coefficient w χ (synthesis χ a) t = a t := by + classical + unfold coefficient synthesis + calc + (∑ x, w x * (∑ s, a s * χ s x) * χ t x) = + ∑ x, ∑ s, a s * (w x * χ s x * χ t x) := by + apply Finset.sum_congr rfl + intro x hx + rw [Finset.mul_sum, Finset.sum_mul] + apply Finset.sum_congr rfl + intro s hs + ring + _ = ∑ s, a s * (∑ x, w x * χ s x * χ t x) := by + rw [Finset.sum_comm] + simp_rw [Finset.mul_sum] + _ = a t := by simp [horth] + +/-- The Fourier coefficient of a multiplier is multiplied by its symbol. -/ +theorem coefficient_multiplier (w : Ω → ℝ) (χ : S → Ω → ℝ) + (horth : ∀ s t, (∑ x, w x * χ s x * χ t x) = if s = t then 1 else 0) + (symbol : S → ℝ) (f : Ω → ℝ) (t : S) : + coefficient w χ (multiplier w χ symbol f) t = symbol t * coefficient w χ f t := + coefficient_synthesis w χ horth _ t + +omit [DecidableEq S] in +/-- Finite synthesis/analysis duality, without any orthogonality assumption. -/ +theorem inner_synthesis (w : Ω → ℝ) (χ : S → Ω → ℝ) + (a : S → ℝ) (g : Ω → ℝ) : + (∑ x, w x * synthesis χ a x * g x) = + ∑ s, a s * coefficient w χ g s := by + unfold synthesis coefficient + calc + (∑ x, w x * (∑ s, a s * χ s x) * g x) = + ∑ x, ∑ s, a s * (w x * g x * χ s x) := by + apply Finset.sum_congr rfl + intro x hx + rw [Finset.mul_sum, Finset.sum_mul] + apply Finset.sum_congr rfl + intro s hs + ring + _ = ∑ s, a s * (∑ x, w x * g x * χ s x) := by + rw [Finset.sum_comm] + simp_rw [Finset.mul_sum] + +omit [DecidableEq S] in +/-- Every real spectral multiplier is self-adjoint. -/ +theorem multiplier_self_adjoint (w : Ω → ℝ) (χ : S → Ω → ℝ) + (symbol : S → ℝ) (f g : Ω → ℝ) : + (∑ x, w x * multiplier w χ symbol f x * g x) = + ∑ x, w x * f x * multiplier w χ symbol g x := by + calc + _ = ∑ s, (symbol s * coefficient w χ f s) * coefficient w χ g s := + inner_synthesis w χ _ g + _ = ∑ s, (symbol s * coefficient w χ g s) * coefficient w χ f s := by + apply Finset.sum_congr rfl + intro s hs + ring + _ = ∑ x, w x * multiplier w χ symbol g x * f x := + (inner_synthesis w χ _ f).symm + _ = _ := by + apply Finset.sum_congr rfl + intro x hx + ring + +/-- Parseval for an explicitly synthesized function. -/ +theorem synthesis_energy (w : Ω → ℝ) (χ : S → Ω → ℝ) + (horth : ∀ s t, (∑ x, w x * χ s x * χ t x) = if s = t then 1 else 0) + (a : S → ℝ) : + (∑ x, w x * (synthesis χ a x)^2) = ∑ s, (a s)^2 := by + calc + _ = ∑ x, w x * synthesis χ a x * synthesis χ a x := by + apply Finset.sum_congr rfl + intro x hx + ring + _ = ∑ s, a s * coefficient w χ (synthesis χ a) s := + inner_synthesis w χ a _ + _ = ∑ s, (a s)^2 := by + simp_rw [coefficient_synthesis w χ horth, pow_two] + +end Problem313.Spectral + +namespace Problem313.BiasedFourier + +variable {ι : Type w} [Fintype ι] + +open scoped Classical + +/-- The biased noise operator, defined by its Fourier multiplier. -/ +def noise (p ρ : ℝ) (g : (ι → Bool) → ℝ) (x : ι → Bool) : ℝ := by + classical + exact ∑ S : Finset ι, ρ ^ S.card * coeff p g S * char p S x + +theorem noise_self_adjoint (p ρ : ℝ) (f g : (ι → Bool) → ℝ) : + (∑ x, weight p x * noise p ρ f x * g x) = + ∑ x, weight p x * f x * noise p ρ g x := by + classical + have h := Spectral.multiplier_self_adjoint (weight p) (char p) (fun S => ρ ^ S.card) f g + simpa only [Spectral.multiplier, Spectral.synthesis, Spectral.coefficient, noise, coeff] using h + +end Problem313.BiasedFourier + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/FourierOption.lean b/lean/OAI/Combinatorics/SharpThreshold/FourierOption.lean new file mode 100644 index 0000000000000000000000000000000000000000..f5ffa0e9b7aa29242aac8a0a82b53818317d1d94 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/FourierOption.lean @@ -0,0 +1,80 @@ +import OAI.Combinatorics.SharpThreshold.FourierBasis + +namespace OAI + +universe u + +noncomputable section + +open scoped BigOperators + +namespace Problem313.BiasedFourier + +variable {ι : Type u} [Fintype ι] + +/-- Separate Fourier supports according to whether the distinguished coordinate occurs. -/ +def optionFinsetEquiv : Finset (Option ι) ≃ Finset ι ⊕ Finset ι := by + classical + refine + { toFun := fun S => if none ∈ S then Sum.inr S.eraseNone else Sum.inl S.eraseNone + invFun := Sum.elim (fun S => S.map Function.Embedding.some) Finset.insertNone + left_inv := ?_ + right_inv := ?_ } + · intro S + by_cases h : none ∈ S + · simp [h, Finset.insert_eq_of_mem h] + · simp [h] + · intro S + cases S <;> simp + +theorem sum_option_finset (F : Finset (Option ι) → ℝ) : + (∑ S, F S) = + (∑ S : Finset ι, F (S.map Function.Embedding.some)) + + ∑ S : Finset ι, F (Finset.insertNone S) := by + classical + rw [← optionFinsetEquiv.symm.sum_comp F] + simp [Fintype.sum_sum_type, optionFinsetEquiv] + +omit [Fintype ι] in +@[simp] theorem char_map_some (p : ℝ) (S : Finset ι) (x : Option ι → Bool) : + char p (S.map Function.Embedding.some) x = char p S (fun i => x (some i)) := by + classical + simp [char] + +omit [Fintype ι] in +@[simp] theorem char_insertNone (p : ℝ) (S : Finset ι) (x : Option ι → Bool) : + char p (Finset.insertNone S) x = + chi p (x none) * char p S (fun i => x (some i)) := by + classical + simp [char, Finset.insertNone] + +/-- A noise-weighted Fourier polynomial separates into its two first-coordinate pieces. -/ +theorem synthesis_option (p ρ : ℝ) (c : Finset (Option ι) → ℝ) + (x : Option ι → Bool) : + (∑ S, ρ ^ S.card * c S * char p S x) = + (∑ S : Finset ι, ρ ^ S.card * c (S.map Function.Embedding.some) * + char p S (fun i => x (some i))) + + ρ * chi p (x none) * + ∑ S : Finset ι, ρ ^ S.card * c (Finset.insertNone S) * + char p S (fun i => x (some i)) := by + classical + rw [sum_option_finset] + simp only [Finset.card_map, char_map_some, Finset.card_insertNone, char_insertNone, + pow_succ] + congr 1 + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro S _ + ring + +theorem coefficient_energy_option (c : Finset (Option ι) → ℝ) : + (∑ S, c S ^ 2) = + (∑ S : Finset ι, c (S.map Function.Embedding.some) ^ 2) + + ∑ S : Finset ι, c (Finset.insertNone S) ^ 2 := + sum_option_finset _ + +end Problem313.BiasedFourier + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/FourierOptionExpectation.lean b/lean/OAI/Combinatorics/SharpThreshold/FourierOptionExpectation.lean new file mode 100644 index 0000000000000000000000000000000000000000..59d20321ab187de592c4e889f63f22e82bb8cfc8 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/FourierOptionExpectation.lean @@ -0,0 +1,46 @@ +import OAI.Combinatorics.SharpThreshold.FourierBasis + +namespace OAI + +universe u + +noncomputable section + +open scoped BigOperators +open Classical + +namespace Problem313.BiasedFourier + +variable {ι : Type u} [Fintype ι] + +/-- Separate the new coordinate from the product Bernoulli weight. -/ +theorem weight_option (p : ℝ) (x : Option ι → Bool) : + weight p x = scalarWeight p (x none) * weight p (fun i => x (some i)) := by + simp only [weight, Fintype.prod_option] + +@[simp] theorem weight_option_elim (p : ℝ) (b : Bool) (x : ι → Bool) : + weight p ((fun i : Option ι => Option.elim i b x)) = scalarWeight p b * weight p x := by + rw [weight_option] + rfl + +/-- Exact expectation splitting at the distinguished `none` coordinate. +This identity is polynomial and requires no restriction on the bias. -/ +theorem weighted_sum_option (p : ℝ) (g : (Option ι → Bool) → ℝ) : + (∑ x, weight p x * g x) = + (1 - p) * (∑ y, weight p y * g ((fun i : Option ι => Option.elim i false y))) + + p * (∑ y, weight p y * g ((fun i : Option ι => Option.elim i true y))) := by + let e : (Option ι → Bool) ≃ Bool × (ι → Bool) := Equiv.piOptionEquivProd + rw [← e.symm.sum_comp (fun x => weight p x * g x), Fintype.sum_prod_type, + Fintype.sum_bool] + have he (b : Bool) (y : ι → Bool) : e.symm (b, y) = (fun i : Option ι => Option.elim i b y) := by + funext i + cases i <;> rfl + simp_rw [he, weight_option_elim, scalarWeight_true, scalarWeight_false, + mul_assoc, ← Finset.mul_sum] + ring + +end Problem313.BiasedFourier + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/FourierOrthogonality.lean b/lean/OAI/Combinatorics/SharpThreshold/FourierOrthogonality.lean new file mode 100644 index 0000000000000000000000000000000000000000..d9653aa4297b0f589d88085d9aa352ecdf156690 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/FourierOrthogonality.lean @@ -0,0 +1,87 @@ +import OAI.Combinatorics.SharpThreshold.FourierBasis + +namespace OAI + +universe u + +noncomputable section +open scoped BigOperators + +namespace Problem313.BiasedFourier + +variable {ι : Type u} [Fintype ι] [DecidableEq ι] + +lemma sqrt_variance_pos {p : ℝ} (hp : 0 < p) (hp1 : p < 1) : 0 < Real.sqrt (p * (1 - p)) := + Real.sqrt_pos.2 (mul_pos hp (sub_pos.2 hp1)) + +lemma sqrt_variance_sq {p : ℝ} (hp : 0 ≤ p) (hp1 : p ≤ 1) : + Real.sqrt (p * (1 - p)) ^ 2 = p * (1 - p) := + Real.sq_sqrt (mul_nonneg hp (sub_nonneg.2 hp1)) + +@[simp] lemma scalarWeight_sum (p : ℝ) : ∑ b : Bool, scalarWeight p b = 1 := by + simp [scalarWeight] + +@[simp] lemma chi_mean (p : ℝ) : + ∑ b : Bool, scalarWeight p b * chi p b = 0 := by + simp only [Fintype.sum_bool, scalarWeight, chi, ite_true, + Bool.false_eq_true, ite_false] + ring + +lemma chi_second_moment {p : ℝ} (hp : 0 < p) (hp1 : p < 1) : + ∑ b : Bool, scalarWeight p b * (chi p b) ^ 2 = 1 := by + have hs : Real.sqrt (p * (1 - p)) ≠ 0 := ne_of_gt (sqrt_variance_pos hp hp1) + have hsq := sqrt_variance_sq (le_of_lt hp) (le_of_lt hp1) + simp only [Fintype.sum_bool, scalarWeight, chi, ite_true, + Bool.false_eq_true, ite_false] + field_simp + nlinarith + +lemma expectation_product (p : ℝ) (g : ι → Bool → ℝ) : + (∑ x : ι → Bool, weight p x * ∏ i, g i (x i)) = + ∏ i, ∑ b : Bool, scalarWeight p b * g i b := by + classical + simpa only [weight, Finset.prod_mul_distrib] using + (Fintype.prod_sum (fun i b => scalarWeight p b * g i b)).symm + +lemma char_eq_univ_prod (p : ℝ) (S : Finset ι) (x : ι → Bool) : + char p S x = ∏ i, if i ∈ S then chi p (x i) else 1 := by + classical + simp [char, Finset.prod_ite_mem] + +lemma char_inner_product {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (S T : Finset ι) : + (∑ x : ι → Bool, weight p x * char p S x * char p T x) = + if S = T then 1 else 0 := by + classical + have hfactor : + (∑ x : ι → Bool, weight p x * char p S x * char p T x) = + ∏ i, ∑ b : Bool, scalarWeight p b * + ((if i ∈ S then chi p b else 1) * + (if i ∈ T then chi p b else 1)) := by + simpa only [char_eq_univ_prod, Finset.prod_mul_distrib, mul_assoc] using + expectation_product p (fun i b => + (if i ∈ S then chi p b else 1) * + (if i ∈ T then chi p b else 1)) + rw [hfactor] + by_cases hST : S = T + · subst T + simp only [ite_true] + apply Finset.prod_eq_one + intro i hi + by_cases hiS : i ∈ S + · simpa only [hiS, ite_true, ← pow_two] using chi_second_moment hp hp1 + · simpa only [hiS, ite_false, mul_one] using scalarWeight_sum p + · simp only [hST, ite_false] + obtain ⟨i, hi⟩ := not_forall.mp (Finset.ext_iff.not.mp hST) + apply Finset.prod_eq_zero (Finset.mem_univ i) + by_cases hiS : i ∈ S + · have hiT : i ∉ T := by tauto + simpa only [hiS, hiT, ite_true, ite_false, mul_one, one_mul] using chi_mean p + · have hiT : i ∈ T := by tauto + simpa only [hiS, hiT, ite_true, ite_false, mul_one, one_mul] using chi_mean p + +end Problem313.BiasedFourier + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/FourierProjection.lean b/lean/OAI/Combinatorics/SharpThreshold/FourierProjection.lean new file mode 100644 index 0000000000000000000000000000000000000000..977309ab2b9f11f1773952021f4acaff9fcd5582 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/FourierProjection.lean @@ -0,0 +1,124 @@ +import OAI.Combinatorics.SharpThreshold.FourierOrthogonality +import OAI.Combinatorics.SharpThreshold.ProjectionIdentities +import OAI.Combinatorics.SharpThreshold.LowDegreeL4 +import OAI.Combinatorics.SharpThreshold.ProjectionNorm + +namespace OAI + +universe u + +noncomputable section + +namespace Problem313.BiasedFourier + +open scoped BigOperators Classical + +variable {ι : Type u} [Fintype ι] + +/-- The projection onto the specified finite collection of Fourier characters. -/ +def project (p : ℝ) (L : Finset (Finset ι)) + (g : (ι → Bool) → ℝ) (x : ι → Bool) : ℝ := + ∑ S ∈ L, coeff p g S * char p S x + +/-- Pairing a function with its projection gives its selected Fourier energy. -/ +theorem project_inner (p : ℝ) (L : Finset (Finset ι)) (g : (ι → Bool) → ℝ) : + (∑ x, weight p x * g x * project p L g x) = + ∑ S ∈ L, (coeff p g S) ^ 2 := by + classical + unfold project + simp only [Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro S hS + calc + (∑ x, weight p x * g x * (coeff p g S * char p S x)) = + coeff p g S * (∑ x, weight p x * g x * char p S x) := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro x hx + ring + _ = (coeff p g S) ^ 2 := by + change coeff p g S * coeff p g S = (coeff p g S) ^ 2 + ring + +/-- The squared norm of a Fourier projection is its selected Fourier energy. -/ +theorem project_second_moment {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (L : Finset (Finset ι)) (g : (ι → Bool) → ℝ) : + (∑ x, weight p x * (project p L g x) ^ 2) = + ∑ S ∈ L, (coeff p g S) ^ 2 := by + classical + simpa only [project, WeightedProjection.synthesis] using + WeightedProjection.second_moment_synthesis (weight p) (char p) + (char_inner_product hp hp1) L (coeff p g) + +/-- The defining orthogonality identity needed by the projection/Hölder estimate. -/ +theorem project_inner_eq_second_moment {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (L : Finset (Finset ι)) (g : (ι → Bool) → ℝ) : + (∑ x, weight p x * g x * project p L g x) = + ∑ x, weight p x * (project p L g x) ^ 2 := by + rw [project_inner, project_second_moment hp hp1] + +/-- Specialization of inverse-noise hypercontractivity to the canonical Fourier +projection. The hypothesis is precisely the coefficient-form noise estimate. -/ +theorem project_fourth_moment_of_noise (p rho k : ℝ) + (hrho : 0 < rho) (hrho1 : rho ≤ 1) + (hnoise : ∀ a : Finset ι → ℝ, + (∑ x, weight p x * + (∑ S, rho ^ S.card * a S * char p S x) ^ 4) ≤ + (∑ S, (a S) ^ 2) ^ 2) + (L : Finset (Finset ι)) (g : (ι → Bool) → ℝ) + (hdegree : ∀ S ∈ L, (S.card : ℝ) ≤ k) : + (∑ x, weight p x * (project p L g x) ^ 4) ≤ + rho ^ (-4 * k) * (∑ S ∈ L, (coeff p g S) ^ 2) ^ 2 := by + classical + let c : Finset ι → ℝ := fun S => if S ∈ L then coeff p g S else 0 + have hdegree' : ∀ S, c S ≠ 0 → (S.card : ℝ) ≤ k := by + intro S hc + by_cases hS : S ∈ L + · exact hdegree S hS + · simp [c, hS] at hc + have hnoise' : ∀ a : Finset ι → ℝ, + (∑ x, weight p x * + (∑ S, rho ^ (S.card : ℝ) * a S * char p S x) ^ 4) ≤ + (∑ S, (a S) ^ 2) ^ 2 := by + intro a + simpa only [Real.rpow_natCast] using hnoise a + have hbound := Problem313.lowDegree_fourth_of_noise Finset.card (char p) + (weight p) rho k hrho hrho1 hnoise' c hdegree' + have hsynth (x : ι → Bool) : (∑ S, c S * char p S x) = project p L g x := by + simp [c, project, ite_mul, Finset.sum_ite_mem] + have henergy : (∑ S, (c S) ^ 2) = ∑ S ∈ L, (coeff p g S) ^ 2 := by + simp [c, ite_pow, Finset.sum_ite_mem] + simpa only [hsynth, henergy] using hbound + +/-- The concrete Fourier projection estimate for ternary-valued functions, +including Boolean coordinate differences. -/ +theorem project_energy_le_of_noise {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (rho k : ℝ) (hrho : 0 < rho) (hrho1 : rho ≤ 1) + (hnoise : ∀ a : Finset ι → ℝ, + (∑ x, weight p x * + (∑ S, rho ^ S.card * a S * char p S x) ^ 4) ≤ + (∑ S, (a S) ^ 2) ^ 2) + (L : Finset (Finset ι)) (g : (ι → Bool) → ℝ) + (hg : ∀ x, g x = -1 ∨ g x = 0 ∨ g x = 1) + (hdegree : ∀ S ∈ L, (S.card : ℝ) ≤ k) : + (∑ S ∈ L, (coeff p g S) ^ 2) ≤ + rho ^ (-2 * k) * + (∑ x, if g x ≠ 0 then weight p x else 0) ^ (3 / 2 : ℝ) := by + have hw (x : ι → Bool) : 0 ≤ weight p x := by + unfold weight + apply Finset.prod_nonneg + intro i hi + unfold scalarWeight + split_ifs <;> linarith + have hfour := project_fourth_moment_of_noise p rho k hrho hrho1 hnoise L g hdegree + have hbound := Problem313.weighted_projection_noise_bound (weight p) g (project p L g) + hw hg rho k hrho.le (project_inner_eq_second_moment hp hp1 L g) + (by simpa only [project_second_moment hp hp1] using hfour) + simpa only [project_second_moment hp hp1] using hbound + +end Problem313.BiasedFourier + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/FourierReindex.lean b/lean/OAI/Combinatorics/SharpThreshold/FourierReindex.lean new file mode 100644 index 0000000000000000000000000000000000000000..626fba4b998ac6ede4ad6cffcf786b256c848f9c --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/FourierReindex.lean @@ -0,0 +1,150 @@ +import OAI.Combinatorics.SharpThreshold.FourierBasis +import OAI.Combinatorics.SharpThreshold.InfluenceReindex + +namespace OAI + +universe u v + +noncomputable section + +open scoped BigOperators + +namespace Problem313.BiasedFourier + +variable {ι : Type u} {κ : Type v} [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] + +omit [DecidableEq ι] [DecidableEq κ] in +/-- Product Bernoulli weight is unchanged by renaming its coordinates. -/ +theorem weight_reindex (e : ι ≃ κ) (p : ℝ) (x : ι → Bool) : + weight p (Reindex.config e x) = weight p x := by + unfold weight + exact (Fintype.prod_equiv e _ _ (fun i => by simp)).symm + +omit [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] in +/-- Fourier characters are natural under a bijection of coordinate sets. -/ +theorem char_reindex (e : ι ≃ κ) (p : ℝ) (S : Finset ι) (x : ι → Bool) : + char p (S.map e.toEmbedding) (Reindex.config e x) = char p S x := by + simp [char, Finset.prod_map] + +/-- Every weighted finite expectation is unchanged by coordinate transport. -/ +theorem expectation_reindex (e : ι ≃ κ) (p : ℝ) + (f : (ι → Bool) → ℝ) (g : (κ → Bool) → ℝ) + (hfg : ∀ x, g (Reindex.config e x) = f x) : + (∑ y, weight p y * g y) = ∑ x, weight p x * f x := by + classical + symm + apply Fintype.sum_equiv (Reindex.configEquiv e) + intro x + simp only [Reindex.configEquiv_apply, weight_reindex, hfg] + +omit [DecidableEq ι] [DecidableEq κ] in +/-- Transport of Fourier coefficients, with the support transported by `Finset.map`. -/ +theorem coeff_reindex (e : ι ≃ κ) (p : ℝ) + (f : (ι → Bool) → ℝ) (g : (κ → Bool) → ℝ) + (hfg : ∀ x, g (Reindex.config e x) = f x) (S : Finset ι) : + coeff p g (S.map e.toEmbedding) = coeff p f S := by + classical + unfold coeff + symm + apply Fintype.sum_equiv (Reindex.configEquiv e) + intro x + simp only [Reindex.configEquiv_apply, weight_reindex, hfg, char_reindex] + +omit [DecidableEq ι] [DecidableEq κ] in +/-- Coordinate transport of spectral synthesis, including a degree-dependent multiplier. -/ +theorem spectral_sum_reindex (e : ι ≃ κ) (p : ℝ) (M : ℕ → ℝ) + (c : Finset ι → ℝ) (d : Finset κ → ℝ) + (hcd : ∀ S, d (S.map e.toEmbedding) = c S) (x : ι → Bool) : + (∑ T : Finset κ, M T.card * d T * char p T (Reindex.config e x)) = + ∑ S : Finset ι, M S.card * c S * char p S x := by + classical + symm + apply Fintype.sum_equiv e.finsetCongr + intro S + simp only [Equiv.finsetCongr_apply, Finset.card_map, hcd, char_reindex] + +omit [DecidableEq ι] [DecidableEq κ] in +/-- Spectral noise is natural under arbitrary finite-coordinate equivalences. -/ +theorem noise_sum_reindex (e : ι ≃ κ) (p ρ : ℝ) + (f : (ι → Bool) → ℝ) (g : (κ → Bool) → ℝ) + (hfg : ∀ x, g (Reindex.config e x) = f x) (x : ι → Bool) : + (∑ T : Finset κ, ρ ^ T.card * coeff p g T * char p T (Reindex.config e x)) = + ∑ S : Finset ι, ρ ^ S.card * coeff p f S * char p S x := by + apply spectral_sum_reindex e p (fun k => ρ ^ k) + exact coeff_reindex e p f g hfg + +/-- The fourth-moment hypercontractive statement transports along coordinate equivalences. -/ +theorem noise_fourth_moment_reindex (e : ι ≃ κ) (p ρ : ℝ) + (f : (ι → Bool) → ℝ) (g : (κ → Bool) → ℝ) + (hfg : ∀ x, g (Reindex.config e x) = f x) + (hf : (∑ x, weight p x * + (∑ S : Finset ι, ρ ^ S.card * coeff p f S * char p S x) ^ 4) ≤ + (∑ x, weight p x * (f x) ^ 2) ^ 2) : + (∑ y, weight p y * + (∑ T : Finset κ, ρ ^ T.card * coeff p g T * char p T y) ^ 4) ≤ + (∑ y, weight p y * (g y) ^ 2) ^ 2 := by + classical + rw [expectation_reindex e p (fun x => + (∑ S : Finset ι, ρ ^ S.card * coeff p f S * char p S x) ^ 4) + (fun y => (∑ T : Finset κ, ρ ^ T.card * coeff p g T * char p T y) ^ 4) + (fun x => congrArg (fun z : ℝ => z ^ 4) (noise_sum_reindex e p ρ f g hfg x))] + rw [expectation_reindex e p (fun x => (f x) ^ 2) (fun y => (g y) ^ 2) + (fun x => congrArg (fun z : ℝ => z ^ 2) (hfg x))] + exact hf + +/-- A proof of spectral hypercontractivity on every `Fin n` cube suffices for every +finite coordinate type. This isolates the reindexing burden from the product induction. -/ +theorem noise_fourth_moment_of_fin (p ρ : ℝ) + (hfin : ∀ (n : ℕ) (f : (Fin n → Bool) → ℝ), + (∑ x, weight p x * + (∑ S : Finset (Fin n), ρ ^ S.card * coeff p f S * char p S x) ^ 4) ≤ + (∑ x, weight p x * (f x) ^ 2) ^ 2) + (g : (ι → Bool) → ℝ) : + (∑ x, weight p x * + (∑ S : Finset ι, ρ ^ S.card * coeff p g S * char p S x) ^ 4) ≤ + (∑ x, weight p x * (g x) ^ 2) ^ 2 := by + let e : Fin (Fintype.card ι) ≃ ι := (Fintype.equivFin ι).symm + exact noise_fourth_moment_reindex e p ρ + (fun x => g (Reindex.config e x)) g (fun _ => rfl) (hfin _ _) + +omit [DecidableEq ι] [DecidableEq κ] in +/-- Every degree-weighted squared coefficient sum is invariant under coordinate transport. -/ +theorem coefficient_energy_reindex (e : ι ≃ κ) (M : ℕ → ℝ) + (c : Finset ι → ℝ) (d : Finset κ → ℝ) + (hcd : ∀ S, d (S.map e.toEmbedding) = c S) : + (∑ T : Finset κ, M T.card * (d T) ^ 2) = + ∑ S : Finset ι, M S.card * (c S) ^ 2 := by + classical + symm + apply Fintype.sum_equiv e.finsetCongr + intro S + simp only [Equiv.finsetCongr_apply, Finset.card_map, hcd] + +/-- The universal coefficient form of hypercontractivity transports along coordinate +bijections. It is the equivalence branch of finite-type induction. -/ +theorem synthesis_contraction_reindex (e : ι ≃ κ) (p ρ : ℝ) + (hι : ∀ c : Finset ι → ℝ, + (∑ x, weight p x * + (∑ S : Finset ι, ρ ^ S.card * c S * char p S x) ^ 4) ≤ + (∑ S : Finset ι, (c S) ^ 2) ^ 2) + (d : Finset κ → ℝ) : + (∑ y, weight p y * + (∑ T : Finset κ, ρ ^ T.card * d T * char p T y) ^ 4) ≤ + (∑ T : Finset κ, (d T) ^ 2) ^ 2 := by + classical + let c : Finset ι → ℝ := fun S => d (S.map e.toEmbedding) + have he := spectral_sum_reindex e p (fun k => ρ ^ k) c d (fun _ => rfl) + rw [expectation_reindex e p + (fun x => (∑ S : Finset ι, ρ ^ S.card * c S * char p S x) ^ 4) + (fun y => (∑ T : Finset κ, ρ ^ T.card * d T * char p T y) ^ 4) + (fun x => congrArg (fun z : ℝ => z ^ 4) (he x))] + have hc : (∑ T : Finset κ, (d T) ^ 2) = ∑ S : Finset ι, (c S) ^ 2 := by + simpa using coefficient_energy_reindex e (fun _ => 1) c d (fun _ => rfl) + rw [hc] + exact hι c + +end Problem313.BiasedFourier + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/FourierRestriction.lean b/lean/OAI/Combinatorics/SharpThreshold/FourierRestriction.lean new file mode 100644 index 0000000000000000000000000000000000000000..2db591b61c6d9e61b3d2de488d508f672398d4c3 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/FourierRestriction.lean @@ -0,0 +1,83 @@ +import OAI.Combinatorics.SharpThreshold.FourierBasis + +namespace OAI + +universe u v + +noncomputable section + +open scoped BigOperators + +namespace Problem313.BiasedFourier + +variable {ι : Type u} {κ : Type v} [Fintype ι] [Fintype κ] + +/-- Fourier transformation in the exterior variables of a conditional Fourier +coefficient recovers the full Fourier coefficient on the disjoint support. -/ +theorem coeff_restricted_coeff (p : ℝ) (f : (ι ⊕ κ → Bool) → ℝ) + (A : Finset ι) (D : Finset κ) : + coeff p (fun y => coeff p (fun x => f (Sum.elim x y)) A) D = + coeff p f (A.disjSum D) := by + classical + let : DecidableEq ι := Classical.decEq _ + let : DecidableEq κ := Classical.decEq _ + let : DecidableEq (ι ⊕ κ) := Classical.decEq _ + unfold coeff + symm + calc + (∑ z, weight p z * f z * char p (A.disjSum D) z) = + ∑ x : ι → Bool, ∑ y : κ → Bool, + weight p (Sum.elim x y) * f (Sum.elim x y) * + char p (A.disjSum D) (Sum.elim x y) := by + calc + _ = ∑ xy : (ι → Bool) × (κ → Bool), + weight p (Sum.elim xy.1 xy.2) * f (Sum.elim xy.1 xy.2) * + char p (A.disjSum D) (Sum.elim xy.1 xy.2) := by + apply Fintype.sum_equiv (Equiv.sumArrowEquivProdArrow ι κ Bool) + intro z + have hz : Sum.elim (fun i => z (Sum.inl i)) (fun j => z (Sum.inr j)) = z := by + funext i + cases i <;> rfl + simpa only [Equiv.sumArrowEquivProdArrow, Equiv.coe_fn_mk, Function.comp_def] using + congrArg (fun z => weight p z * f z * char p (A.disjSum D) z) hz.symm + _ = _ := Fintype.sum_prod_type _ + _ = ∑ y, weight p y * (∑ x, weight p x * f (Sum.elim x y) * char p A x) * + char p D y := by + simp_rw [Finset.mul_sum, Finset.sum_mul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro y hy + apply Finset.sum_congr rfl + intro x hx + simp only [weight, Fintype.prod_sum_type, Sum.elim_inl, Sum.elim_inr, + char, Finset.prod_disjSum] + ring + +/-- A conditional Fourier coefficient expands in the exterior characters, +with full Fourier coefficients and no cutoff on the exterior degree. -/ +theorem restricted_coeff_expansion {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (f : (ι ⊕ κ → Bool) → ℝ) (A : Finset ι) (y : κ → Bool) : + coeff p (fun x => f (Sum.elim x y)) A = + ∑ D : Finset κ, coeff p f (A.disjSum D) * char p D y := by + classical + symm + simpa only [coeff_restricted_coeff] using + inversion hp hp1 (fun y => coeff p (fun x => f (Sum.elim x y)) A) y + +/-- Averaging the square of a conditional coefficient retains all exterior +Fourier degrees. This is the single-coefficient restriction identity. -/ +theorem restricted_coeff_sq_average [DecidableEq κ] {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (f : (ι ⊕ κ → Bool) → ℝ) (A : Finset ι) : + (∑ y : κ → Bool, weight p y * + (coeff p (fun x => f (Sum.elim x y)) A) ^ 2) = + ∑ D : Finset κ, (coeff p f (A.disjSum D)) ^ 2 := by + classical + symm + simpa only [coeff_restricted_coeff] using + parseval hp hp1 (fun y => coeff p (fun x => f (Sum.elim x y)) A) + +end Problem313.BiasedFourier + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/FourierRestrictionMass.lean b/lean/OAI/Combinatorics/SharpThreshold/FourierRestrictionMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..30c97fdeb70c9003404993c1e1cb223db05416de --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/FourierRestrictionMass.lean @@ -0,0 +1,60 @@ +import OAI.Combinatorics.SharpThreshold.FourierRestriction +import OAI.Combinatorics.SharpThreshold.FourierSupportSplit + +namespace OAI + +universe u v + +noncomputable section + +open scoped BigOperators + +namespace Problem313.BiasedFourier + +variable {ι : Type u} {κ : Type v} [Fintype ι] [Fintype κ] [DecidableEq κ] + +/-- Exact averaging of any selected family of conditional Fourier levels. -/ +theorem restricted_mass_average {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (f : (ι ⊕ κ → Bool) → ℝ) (L : Finset (Finset ι)) : + (∑ y : κ → Bool, weight p y * + ∑ A ∈ L, (coeff p (fun x => f (Sum.elim x y)) A) ^ 2) = + ∑ A ∈ L, ∑ D : Finset κ, (coeff p f (A.disjSum D)) ^ 2 := by + classical + simp only [Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro A hA + exact restricted_coeff_sq_average hp hp1 f A + +/-- The restriction identity reindexed by full supports. The condition is +placed only on the free-coordinate part, never on exterior Fourier degree. -/ +theorem restricted_mass_condition {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (f : (ι ⊕ κ → Bool) → ℝ) (P : Finset ι → Prop) [DecidablePred P] : + (∑ y : κ → Bool, weight p y * + ∑ A : Finset ι, if P A then + (coeff p (fun x => f (Sum.elim x y)) A) ^ 2 else 0) = + ∑ S : Finset (ι ⊕ κ), if P S.toLeft then (coeff p f S) ^ 2 else 0 := by + classical + calc + _ = ∑ A : Finset ι, if P A then + ∑ D : Finset κ, (coeff p f (A.disjSum D)) ^ 2 else 0 := by + simpa only [Finset.sum_filter] using + restricted_mass_average hp hp1 f (Finset.univ.filter P) + _ = _ := (sum_support_condition_disjSum (fun S => (coeff p f S) ^ 2) P).symm + +/-- Literal real-valued conditional degree cutoff, including the case `k < 1`. -/ +theorem restricted_low_degree_mass_average {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (f : (ι ⊕ κ → Bool) → ℝ) (k : ℝ) : + (∑ y : κ → Bool, weight p y * + ∑ A : Finset ι, if 1 ≤ A.card ∧ (A.card : ℝ) ≤ k then + (coeff p (fun x => f (Sum.elim x y)) A) ^ 2 else 0) = + ∑ S : Finset (ι ⊕ κ), if 1 ≤ S.toLeft.card ∧ (S.toLeft.card : ℝ) ≤ k then + (coeff p f S) ^ 2 else 0 := by + classical + exact restricted_mass_condition hp hp1 f (fun A => 1 ≤ A.card ∧ (A.card : ℝ) ≤ k) + +end Problem313.BiasedFourier + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/FourierSupportSplit.lean b/lean/OAI/Combinatorics/SharpThreshold/FourierSupportSplit.lean new file mode 100644 index 0000000000000000000000000000000000000000..6966236c602b70f10670444a2696c683d19d8899 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/FourierSupportSplit.lean @@ -0,0 +1,45 @@ +import Mathlib + +namespace OAI + +universe u v w + +noncomputable section +open scoped BigOperators + +namespace Problem313.BiasedFourier + +variable {ι : Type u} {κ : Type v} {M : Type w} [Fintype ι] [Fintype κ] [AddCommMonoid M] + +/-- Reindex all Fourier supports on a sum coordinate set by their two parts. -/ +theorem sum_support_disjSum (a : Finset (ι ⊕ κ) → M) : + (∑ S : Finset (ι ⊕ κ), a S) = + ∑ A : Finset ι, ∑ D : Finset κ, a (A.disjSum D) := by + classical + rw [← Fintype.sum_prod_type (fun AD : Finset ι × Finset κ => a (AD.1.disjSum AD.2))] + exact ((Finset.sumEquiv (α := ι) (β := κ)).toEquiv.symm.sum_comp a).symm + +/-- Restricting the free-coordinate support commutes with the support split. -/ +theorem sum_support_condition_disjSum (a : Finset (ι ⊕ κ) → M) + (P : Finset ι → Prop) [DecidablePred P] : + (∑ S : Finset (ι ⊕ κ), if P S.toLeft then a S else 0) = + ∑ A : Finset ι, if P A then + ∑ D : Finset κ, a (A.disjSum D) else 0 := by + classical + rw [sum_support_disjSum] + simp only [Finset.toLeft_disjSum, Finset.sum_ite_irrel, Finset.sum_const_zero] + +/-- Filter formulation of the same identity, useful for degree cutoffs. -/ +theorem sum_support_filter_disjSum (a : Finset (ι ⊕ κ) → M) + (P : Finset ι → Prop) [DecidablePred P] : + (∑ S ∈ Finset.univ.filter (fun S : Finset (ι ⊕ κ) => P S.toLeft), a S) = + ∑ A ∈ Finset.univ.filter P, ∑ D : Finset κ, a (A.disjSum D) := by + classical + simp only [Finset.sum_filter] + exact sum_support_condition_disjSum a P + +end Problem313.BiasedFourier + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/FourierVariance.lean b/lean/OAI/Combinatorics/SharpThreshold/FourierVariance.lean new file mode 100644 index 0000000000000000000000000000000000000000..0cedaeb7c60c1ef2313f418cb556f05e3bf27788 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/FourierVariance.lean @@ -0,0 +1,166 @@ +import OAI.Combinatorics.SharpThreshold.FourierBasis +import OAI.Combinatorics.SharpThreshold.Probability + +namespace OAI + +universe u v + +noncomputable section + +open scoped BigOperators Classical + +namespace Problem313.BiasedFourier + +variable {ι : Type u} [Fintype ι] + +@[simp] theorem coeff_empty (p : ℝ) (g : (ι → Bool) → ℝ) : + coeff p g ∅ = ∑ x, weight p x * g x := by + classical + simp [coeff] + +/-- Algebraic expansion of finite weighted variance. Positivity is not needed. -/ +theorem weighted_variance_eq_second_moment {α : Type v} [Fintype α] + (w g : α → ℝ) (hw : ∑ x, w x = 1) : + (∑ x, w x * (g x - ∑ y, w y * g y) ^ 2) = + (∑ x, w x * g x ^ 2) - (∑ x, w x * g x) ^ 2 := by + classical + let μ := ∑ x, w x * g x + change (∑ x, w x * (g x - μ) ^ 2) = (∑ x, w x * g x ^ 2) - μ ^ 2 + calc + (∑ x, w x * (g x - μ) ^ 2) = + ∑ x, (w x * g x ^ 2 - 2 * μ * (w x * g x) + μ ^ 2 * w x) := by + apply Finset.sum_congr rfl + intro x hx + ring + _ = (∑ x, w x * g x ^ 2) - 2 * μ * (∑ x, w x * g x) + + μ ^ 2 * (∑ x, w x) := by + simp only [Finset.sum_add_distrib, Finset.sum_sub_distrib, ← Finset.mul_sum] + _ = (∑ x, w x * g x ^ 2) - μ ^ 2 := by + rw [hw] + change (∑ x, w x * g x ^ 2) - 2 * μ * μ + μ ^ 2 * 1 = _ + ring + +/-- The total mass of the finite Bernoulli product is one, algebraically for every bias. -/ +theorem weight_mass_one (p : ℝ) : ∑ x : ι → Bool, weight p x = 1 := by + unfold weight + rw [← Fintype.prod_sum] + simp [scalarWeight] + +/-- Parseval implies that the variance is exactly the nonconstant spectral mass. -/ +theorem variance_eq_nonempty_of_parseval (p : ℝ) (g : (ι → Bool) → ℝ) + (hparseval : (∑ x, weight p x * g x ^ 2) = ∑ S : Finset ι, coeff p g S ^ 2) : + (∑ x, weight p x * (g x - coeff p g ∅) ^ 2) = + ∑ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, coeff p g S ^ 2 := by + rw [coeff_empty, weighted_variance_eq_second_moment _ _ (weight_mass_one p), hparseval] + rw [Finset.sum_erase_eq_sub (Finset.mem_univ ∅), coeff_empty] + +/-- The same identity with a nonempty filter, convenient for degree cutoffs. -/ +theorem variance_eq_nonempty_filter_of_parseval (p : ℝ) (g : (ι → Bool) → ℝ) + (hparseval : (∑ x, weight p x * g x ^ 2) = ∑ S : Finset ι, coeff p g S ^ 2) : + (∑ x, weight p x * (g x - coeff p g ∅) ^ 2) = + ∑ S ∈ (Finset.univ : Finset (Finset ι)).filter (fun S => S ≠ ∅), coeff p g S ^ 2 := by + rw [Finset.filter_ne'] + exact variance_eq_nonempty_of_parseval p g hparseval + +theorem variance_eq_nonempty {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (g : (ι → Bool) → ℝ) : + (∑ x, weight p x * (g x - coeff p g ∅) ^ 2) = + ∑ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, coeff p g S ^ 2 := by + exact variance_eq_nonempty_of_parseval p g (parseval hp hp1 g).symm + +theorem weight_nonneg {p : ℝ} (hp : 0 ≤ p) (hp1 : p ≤ 1) (x : ι → Bool) : + 0 ≤ weight p x := by + apply Finset.prod_nonneg + intro i hi + unfold scalarWeight + split_ifs <;> linarith + +/-- A Boolean function has total Fourier mass at most one. -/ +theorem boolean_spectral_mass_le_one {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (f : (ι → Bool) → Bool) : + (∑ S : Finset ι, coeff p (fun x => boolReal (f x)) S ^ 2) ≤ 1 := by + rw [parseval hp hp1] + calc + (∑ x, weight p x * boolReal (f x) ^ 2) ≤ ∑ x : ι → Bool, weight p x := by + apply Finset.sum_le_sum + intro x hx + rw [boolReal_sq] + exact mul_le_of_le_one_right (weight_nonneg hp.le hp1.le x) (boolReal_le_one (f x)) + _ = 1 := weight_mass_one p + +end Problem313.BiasedFourier + +namespace Problem313 + +open BiasedFourier + +@[simp] theorem fourier_weight_eq_graphWeight {n : ℕ} (p : ℝ) (x : GraphConfig n) : + BiasedFourier.weight p x = graphWeight p x := rfl + +@[simp] theorem fourier_coeff_empty_eq_graphMean {n : ℕ} (p : ℝ) + (f : GraphConfig n → Bool) : + coeff p (fun x => boolReal (f x)) ∅ = graphMean p f := by + rw [coeff_empty] + unfold graphMean + apply Finset.sum_congr (by ext; simp) + intro x hx + rw [fourier_weight_eq_graphWeight] + +theorem graph_second_moment_eq_mean {n : ℕ} (p : ℝ) (f : GraphConfig n → Bool) : + (∑ x, BiasedFourier.weight p x * boolReal (f x) ^ 2) = graphMean p f := by + apply Finset.sum_congr rfl + intro x hx + simp only [fourier_weight_eq_graphWeight] + congr 1 + cases f x <;> norm_num [boolReal] + +/-- The graph variance bridge needs only Parseval on the real-valued Boolean encoding. -/ +theorem graphVariance_eq_fourier_nonempty_of_parseval {n : ℕ} (p : ℝ) + (f : GraphConfig n → Bool) + (hparseval : (∑ x, BiasedFourier.weight p x * boolReal (f x) ^ 2) = + ∑ S : Finset (GraphEdge n), coeff p (fun x => boolReal (f x)) S ^ 2) : + graphVariance p f = + ∑ S ∈ (Finset.univ : Finset (Finset (GraphEdge n))).erase ∅, + coeff p (fun x => boolReal (f x)) S ^ 2 := by + rw [Finset.sum_erase_eq_sub (Finset.mem_univ ∅), ← hparseval, + graph_second_moment_eq_mean, fourier_coeff_empty_eq_graphMean, + graphVariance_eq_mean_mul] + ring + +theorem graphVariance_eq_fourier_nonempty {n : ℕ} {p : ℝ} + (hp : 0 < p) (hp1 : p < 1) (f : GraphConfig n → Bool) : + graphVariance p f = + ∑ S ∈ (Finset.univ : Finset (Finset (GraphEdge n))).erase ∅, + coeff p (fun x => boolReal (f x)) S ^ 2 := by + exact graphVariance_eq_fourier_nonempty_of_parseval p f + (parseval hp hp1 (fun x : GraphConfig n => boolReal (f x))).symm + +theorem graphVariance_eq_fourier_nonempty_filter {n : ℕ} {p : ℝ} + (hp : 0 < p) (hp1 : p < 1) (f : GraphConfig n → Bool) : + graphVariance p f = + ∑ S ∈ (Finset.univ : Finset (Finset (GraphEdge n))).filter (fun S => S ≠ ∅), + coeff p (fun x => boolReal (f x)) S ^ 2 := by + rw [Finset.filter_ne'] + exact graphVariance_eq_fourier_nonempty hp hp1 f + +theorem graph_fourier_mass_eq_mean {n : ℕ} {p : ℝ} + (hp : 0 < p) (hp1 : p < 1) (f : GraphConfig n → Bool) : + (∑ S : Finset (GraphEdge n), coeff p (fun x => boolReal (f x)) S ^ 2) = + graphMean p f := by + rw [parseval hp hp1] + exact graph_second_moment_eq_mean p f + +/-- The variance identity as a sum over nonempty Fourier supports. -/ +theorem graphVariance_eq_fourier_sum_nonempty {n : ℕ} {p : ℝ} + (hp : 0 < p) (hp1 : p < 1) (f : GraphConfig n → Bool) : + graphVariance p f = + ∑ S : Finset (GraphEdge n) with S.Nonempty, + coeff p (fun x => boolReal (f x)) S ^ 2 := by + simpa only [Finset.nonempty_iff_ne_empty] using + graphVariance_eq_fourier_nonempty_filter hp hp1 f + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/GraphBlockAverage.lean b/lean/OAI/Combinatorics/SharpThreshold/GraphBlockAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..7ef3d8f98ac750bb6f829f1c6d590a1e0318d5d5 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/GraphBlockAverage.lean @@ -0,0 +1,153 @@ +import OAI.Combinatorics.SharpThreshold.BlockAverage +import OAI.Combinatorics.SharpThreshold.BlockCounting +import OAI.Combinatorics.SharpThreshold.BlockRestrictionSymmetry +import OAI.Combinatorics.SharpThreshold.FourierBasis +import OAI.Combinatorics.SharpThreshold.Probability +import OAI.Combinatorics.SharpThreshold.GraphBlockCapture +import OAI.Combinatorics.SharpThreshold.BlockLowDegree + +namespace OAI + +noncomputable section + +open scoped BigOperators Classical + +namespace Problem313 + +/-- The fixed-block Fourier estimate and the pointwise support-capture estimate +combine into the global captured-mass bound. All graph sampling probabilities +are the canonical `blockProbability`; the edge-touch bound is discharged here. +The two hypotheses are precisely the analytic and combinatorial inputs, with +no requirement that a single block capture every support simultaneously. -/ +theorem graph_fourier_capture_of_block_bounds + {n m : ℕ} (f : GraphConfig n → Bool) {p : ℝ} + (hp : 0 ≤ p) (hp1 : p ≤ 1) (hm : 1 ≤ m) (hmn : m ≤ n) + (k a : ℝ) (ha : 0 ≤ a) + (hcapture : ∀ S : Finset (GraphEdge n), S.Nonempty → + (S.card : ℝ) ≤ k ^ 2 / 2 → + (m : ℝ) / (2 * n) ≤ + blockProbability (Finset.univ : Finset (Fin n)) m (fun B => + 1 ≤ (S.filter (EdgeTouches B)).card ∧ + ((S.filter (EdgeTouches B)).card : ℝ) ≤ k)) + (hblock : ∀ B : Finset (Fin n), B.card = m → + (∑ S : Finset (GraphEdge n), + if 1 ≤ (S.filter (EdgeTouches B)).card ∧ + ((S.filter (EdgeTouches B)).card : ℝ) ≤ k + then BiasedFourier.coeff p (fun x => boolReal (f x)) S ^ 2 else 0) ≤ + a * ∑ e : GraphEdge n, if EdgeTouches B e then edgeInfluence p f e else 0) : + (∑ S : Finset (GraphEdge n), + if S.Nonempty ∧ (S.card : ℝ) ≤ k ^ 2 / 2 + then BiasedFourier.coeff p (fun x => boolReal (f x)) S ^ 2 else 0) ≤ + 4 * a * totalInfluence p f := by + classical + let Ω := (Finset.univ : Finset (Fin n)).powersetCard m + let low := (Finset.univ : Finset (Finset (GraphEdge n))).filter + (fun S => S.Nonempty ∧ (S.card : ℝ) ≤ k ^ 2 / 2) + let mass := fun S : Finset (GraphEdge n) => + BiasedFourier.coeff p (fun x => boolReal (f x)) S ^ 2 + let detect := fun (B : Finset (Fin n)) (S : Finset (GraphEdge n)) => + 1 ≤ (S.filter (EdgeTouches B)).card ∧ + ((S.filter (EdgeTouches B)).card : ℝ) ≤ k + have hn : 0 < n := lt_of_lt_of_le (Nat.zero_lt_of_lt hm) hmn + have hmR : 0 < (m : ℝ) := by exact_mod_cast (Nat.zero_lt_of_lt hm) + have hnR : 0 < (n : ℝ) := by exact_mod_cast hn + have hc : 0 < (m : ℝ) / (2 * n) := by positivity + have hcap : ∀ S ∈ low, + (m : ℝ) / (2 * n) ≤ + ((Ω.filter (fun B => detect B S)).card : ℝ) / Ω.card := by + intro S hS + obtain ⟨_, hSne, hScard⟩ := Finset.mem_filter.mp hS + simpa only [blockProbability_eq] using hcapture S hSne hScard + have hb : ∀ B ∈ Ω, + (∑ S, if detect B S then mass S else 0) ≤ + a * ∑ e : GraphEdge n, if EdgeTouches B e then edgeInfluence p f e else 0 := by + intro B hB + exact hblock B (Finset.mem_powersetCard.mp hB).2 + have hi : ∀ e : GraphEdge n, + ((Ω.filter (fun B => EdgeTouches B e)).card : ℝ) / Ω.card ≤ + 4 * ((m : ℝ) / (2 * n)) := by + intro e + have htouch := blockProbability_edge_touch_le + (Finset.univ : Finset (Fin n)) e.val (Finset.subset_univ _) e.property hm + (by simpa using hmn) + have hevent : blockProbability (Finset.univ : Finset (Fin n)) m + (fun B => EdgeTouches B e) = + blockProbability (Finset.univ : Finset (Fin n)) m + (fun B => (B ∩ e.val).Nonempty) := by + apply blockProbability_congr + intro B hB + simp only [EdgeTouches, Finset.Nonempty, Finset.mem_inter] + exact exists_congr (fun _ => and_comm) + change blockProbability (Finset.univ : Finset (Fin n)) m + (fun B => EdgeTouches B e) ≤ _ + rw [hevent] + calc + _ ≤ (2 : ℝ) * m / (Finset.univ : Finset (Fin n)).card := htouch + _ = 4 * ((m : ℝ) / (2 * n)) := by simp; ring + have h := BlockAverage.captured_mass_le_four_uniform Ω mass + (edgeInfluence p f) detect EdgeTouches low a ((m : ℝ) / (2 * n)) + (fun S => sq_nonneg _) (edgeInfluence_nonneg hp hp1 f) ha hc hcap hb hi + simpa only [low, mass, Finset.sum_filter, totalInfluence] using h + +/-- At the square-root block size all counting and numerical capture premises +are discharged. Only the fixed-block analytic estimate remains as input. -/ +theorem graph_fourier_captured_mass_of_block_bound + {n : ℕ} (f : GraphConfig n → Bool) {p : ℝ} + (hn : 2 ≤ n) (ht : 16 ≤ Real.log (n : ℝ)) + (hp : 0 < p) (hp1 : p < 1) + (hblock : ∀ B : Finset (Fin n), B.card = ⌊Real.sqrt (n : ℝ)⌋₊ → + (∑ S : Finset (GraphEdge n), + if 1 ≤ (S.filter (EdgeTouches B)).card ∧ + ((S.filter (EdgeTouches B)).card : ℝ) ≤ + Real.sqrt (p * (1 - p)) * Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) / 64 + then BiasedFourier.coeff p (fun x => boolReal (f x)) S ^ 2 else 0) ≤ + (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) ^ (-1 / 4 : ℝ) * + ∑ e : GraphEdge n, if EdgeTouches B e then edgeInfluence p f e else 0) : + (∑ S : Finset (GraphEdge n), + if S.Nonempty ∧ (S.card : ℝ) ≤ + (Real.sqrt (p * (1 - p)) * Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) / 64) ^ 2 / 2 + then BiasedFourier.coeff p (fun x => boolReal (f x)) S ^ 2 else 0) ≤ + 4 * (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) ^ (-1 / 4 : ℝ) * totalInfluence p f := by + have hm := sqrt_block_size_bounds n hn ht + apply graph_fourier_capture_of_block_bounds f hp.le hp1.le + (show 1 ≤ ⌊Real.sqrt (n : ℝ)⌋₊ by omega) hm.2.1 + (Real.sqrt (p * (1 - p)) * Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) / 64) + ((⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) ^ (-1 / 4 : ℝ)) (by positivity) + · intro S hS hcard + have hsigma1 : Real.sqrt (p * (1 - p)) ≤ (1 / 2 : ℝ) := by + apply Real.sqrt_le_iff.mpr + constructor + · norm_num + · nlinarith [sq_nonneg (p - 1 / 2)] + have hdet := sqrt_block_detection_probability n (Real.sqrt (p * (1 - p))) + hn ht (Real.sqrt_nonneg _) hsigma1 S hS hcard + refine hdet.trans_eq ?_ + apply blockProbability_congr + intro B hB + simp only [BlockDetects, edgeTouches_iff_not_disjoint] + · exact hblock + +/-- The complete captured Fourier-mass bound for a vertex-invariant graph +property. The bias is unrestricted within `(0,1)` and no monotonicity is used. -/ +theorem graph_fourier_captured_mass + {n : ℕ} (f : GraphConfig n → Bool) {p : ℝ} + (hn : 2 ≤ n) (ht : 16 ≤ Real.log (n : ℝ)) (hf : VertexInvariant f) + (hp : 0 < p) (hp1 : p < 1) : + (∑ S : Finset (GraphEdge n), + if S.Nonempty ∧ (S.card : ℝ) ≤ + (Real.sqrt (p * (1 - p)) * Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) / 64) ^ 2 / 2 + then BiasedFourier.coeff p (fun x => boolReal (f x)) S ^ 2 else 0) ≤ + 4 * (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) ^ (-1 / 4 : ℝ) * totalInfluence p f := by + apply graph_fourier_captured_mass_of_block_bound f hn ht hp hp1 + intro B hB + have hBm : 3 ≤ B.card := by + rw [hB] + exact (sqrt_block_size_bounds n hn ht).1 + simpa only [hB, Finset.sum_filter] using + block_low_degree_bound_filter B hBm f hf hp hp1 + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/GraphBlockCapture.lean b/lean/OAI/Combinatorics/SharpThreshold/GraphBlockCapture.lean new file mode 100644 index 0000000000000000000000000000000000000000..8d0d301326d5d3c801e1dcd2b9814fbd820955f4 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/GraphBlockCapture.lean @@ -0,0 +1,198 @@ +import OAI.Combinatorics.SharpThreshold.SupportDegreeGraph +import OAI.Combinatorics.SharpThreshold.BlockIncidence +import OAI.Combinatorics.SharpThreshold.BlockCapture +import OAI.Combinatorics.SharpThreshold.BlockSize +import OAI.Combinatorics.SharpThreshold.BlockCounting + +namespace OAI + +/-! The graph-combinatorial input to capture of low Fourier levels. -/ + +namespace Problem313 + +noncomputable section + +/-- A block detects a support when the restricted Fourier degree is positive +and no larger than the specified real cutoff. -/ +def BlockDetects {n : ℕ} (k : ℝ) (S : Finset (GraphEdge n)) + (B : Finset (Fin n)) : Prop := + 1 ≤ (S.filter (fun e => ¬Disjoint e.val B)).card ∧ + ((S.filter (fun e => ¬Disjoint e.val B)).card : ℝ) ≤ k + +instance blockDetects_decidable {n : ℕ} (k : ℝ) (S : Finset (GraphEdge n)) + (B : Finset (Fin n)) : Decidable (BlockDetects k S B) := + Classical.propDecidable _ + +/-- For a low-degree support, choose one positive-degree vertex whose isolation +by the random block guarantees detection. -/ +theorem exists_vertex_singleton_implies_detection {n : ℕ} + (S : Finset (GraphEdge n)) (hS : S.Nonempty) {k : ℝ} + (hk : 0 ≤ k) (hcard : (S.card : ℝ) ≤ k ^ 2 / 2) : + ∃ u ∈ S.biUnion (fun e => e.val), ∀ B : Finset (Fin n), + B ∩ S.biUnion (fun e => e.val) = {u} → BlockDetects k S B := by + classical + obtain ⟨u, hu, hpos, hdeg⟩ := support_exists_degree_le_cutoff S hS hk hcard + refine ⟨u, hu, ?_⟩ + intro B hB + unfold BlockDetects + rw [block_not_disjoint_filter_eq_vertex_filter S B u hB] + exact ⟨hpos, hdeg⟩ + +/-- Transfer any uniform singleton-intersection bound to a detection bound. -/ +theorem block_detection_probability_of_singleton {n : ℕ} + (blocks : Finset (Finset (Fin n))) (S : Finset (GraphEdge n)) + (hS : S.Nonempty) {k a : ℝ} (hk : 0 ≤ k) + (hcard : (S.card : ℝ) ≤ k ^ 2 / 2) + (hsingle : ∀ u ∈ S.biUnion (fun e => e.val), + a ≤ ((blocks.filter (fun B => B ∩ S.biUnion (fun e => e.val) = {u})).card : ℝ) / + blocks.card) : + a ≤ ((blocks.filter (BlockDetects k S)).card : ℝ) / blocks.card := by + classical + obtain ⟨u, hu, hdetect⟩ := exists_vertex_singleton_implies_detection S hS hk hcard + apply (hsingle u hu).trans + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg blocks.card) + exact_mod_cast Finset.card_le_card (show + blocks.filter (fun B => B ∩ S.biUnion (fun e => e.val) = {u}) ⊆ + blocks.filter (BlockDetects k S) from by + intro B hB + obtain ⟨hBmem, hBsingle⟩ := Finset.mem_filter.mp hB + exact Finset.mem_filter.mpr ⟨hBmem, hdetect B hBsingle⟩) + +/-- The support-vertex bound turns the random-block union-bound error into a +uniform error at most one half. -/ +theorem support_singleton_error_le_half {n : ℕ} + (S : Finset (GraphEdge n)) (k r : ℝ) + (hcard : (S.card : ℝ) ≤ k ^ 2 / 2) + (hr : 0 ≤ r) (hbudget : k ^ 2 * r ≤ 1 / 2) : + (((S.biUnion (fun e => e.val)).card : ℝ) - 1) * r ≤ 1 / 2 := by + have hv : ((S.biUnion (fun e => e.val)).card : ℝ) ≤ 2 * S.card := by + exact_mod_cast support_vertices_card_le S + have hvk : ((S.biUnion (fun e => e.val)).card : ℝ) - 1 ≤ k ^ 2 := by + linarith + exact (mul_le_mul_of_nonneg_right hvk hr).trans hbudget + +/-- Quantitative detection from the singleton-intersection union bound. The +scalar `r` will be `(m-1)/(n-1)` for a uniformly chosen `m`-vertex block. -/ +theorem block_detection_probability_lower {n : ℕ} + (blocks : Finset (Finset (Fin n))) (S : Finset (GraphEdge n)) + (hS : S.Nonempty) (k q r : ℝ) (hk : 0 ≤ k) (hq : 0 ≤ q) + (hcard : (S.card : ℝ) ≤ k ^ 2 / 2) (hr : 0 ≤ r) + (hbudget : k ^ 2 * r ≤ 1 / 2) + (hsingle : ∀ u ∈ S.biUnion (fun e => e.val), + q * (1 - (((S.biUnion (fun e => e.val)).card : ℝ) - 1) * r) ≤ + ((blocks.filter (fun B => B ∩ S.biUnion (fun e => e.val) = {u})).card : ℝ) / + blocks.card) : + q / 2 ≤ ((blocks.filter (BlockDetects k S)).card : ℝ) / blocks.card := by + apply block_detection_probability_of_singleton blocks S hS hk hcard + intro u hu + apply le_trans _ (hsingle u hu) + have he := support_singleton_error_le_half S k r hcard hr hbudget + have := mul_le_mul_of_nonneg_left (show (1 / 2 : ℝ) ≤ + 1 - (((S.biUnion (fun e => e.val)).card : ℝ) - 1) * r by linarith) hq + linarith + +/-- The biased Fourier cutoff for a square-root block never exceeds `log n`. -/ +theorem sqrt_block_cutoff_le_log (n : ℕ) (sigma : ℝ) (hn : 2 ≤ n) + (ht : 16 ≤ Real.log (n : ℝ)) (hsigma : 0 ≤ sigma) (hsigma1 : sigma ≤ 1 / 2) : + 0 ≤ sigma * Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) / 64 ∧ + sigma * Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) / 64 ≤ Real.log (n : ℝ) := by + have hm := sqrt_block_size_bounds n hn ht + have hmreal : (1 : ℝ) ≤ (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) := by + exact_mod_cast (show 1 ≤ ⌊Real.sqrt (n : ℝ)⌋₊ by omega) + have hlogm : 0 ≤ Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) := Real.log_nonneg hmreal + have hlogmn : Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) ≤ Real.log (n : ℝ) := by + apply Real.log_le_log (by linarith) + exact_mod_cast hm.2.1 + have hprod := mul_le_mul_of_nonneg_right hsigma1 hlogm + exact ⟨div_nonneg (mul_nonneg hsigma hlogm) (by norm_num), by linarith⟩ + +/-- Uniform numerical budget used in detecting supports of at most `k²/2` edges. -/ +theorem sqrt_block_cutoff_budget (n : ℕ) (sigma : ℝ) (hn : 2 ≤ n) + (ht : 16 ≤ Real.log (n : ℝ)) (hsigma : 0 ≤ sigma) (hsigma1 : sigma ≤ 1 / 2) : + (sigma * Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) / 64) ^ 2 * + (((⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) - 1) / ((n : ℝ) - 1)) ≤ 1 / 2 := by + have hk := sqrt_block_cutoff_le_log n sigma hn ht hsigma hsigma1 + have hsq := pow_le_pow_left₀ hk.1 hk.2 2 + calc + (sigma * Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) / 64) ^ 2 * + (((⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) - 1) / ((n : ℝ) - 1)) ≤ + (sigma * Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) / 64) ^ 2 * + (1 / Real.sqrt (n : ℝ)) := + mul_le_mul_of_nonneg_left (sqrt_block_pair_ratio n hn) (sq_nonneg _) + _ ≤ (Real.log (n : ℝ)) ^ 2 * (1 / Real.sqrt (n : ℝ)) := + mul_le_mul_of_nonneg_right hsq (by positivity) + _ = (Real.log (n : ℝ)) ^ 2 / Real.sqrt (n : ℝ) := by ring + _ ≤ 1 / 2 := log_square_div_sqrt_le_half n hn ht + +/-- Every nonempty support of degree at most `k²/2` is detected with probability +at least `m/(2*n)` by the square-root-sized random block. -/ +theorem sqrt_block_detection_probability (n : ℕ) (sigma : ℝ) (hn : 2 ≤ n) + (ht : 16 ≤ Real.log (n : ℝ)) (hsigma : 0 ≤ sigma) (hsigma1 : sigma ≤ 1 / 2) + (S : Finset (GraphEdge n)) (hS : S.Nonempty) + (hcard : (S.card : ℝ) ≤ + (sigma * Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) / 64) ^ 2 / 2) : + (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) / (2 * n) ≤ + blockProbability (Finset.univ : Finset (Fin n)) ⌊Real.sqrt (n : ℝ)⌋₊ + (BlockDetects (sigma * Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) / 64) S) := by + classical + let m := ⌊Real.sqrt (n : ℝ)⌋₊ + let k := sigma * Real.log (m : ℝ) / 64 + have hm := sqrt_block_size_bounds n hn ht + have hk := sqrt_block_cutoff_le_log n sigma hn ht hsigma hsigma1 + obtain ⟨u, hu, hdetect⟩ := exists_vertex_singleton_implies_detection S hS hk.1 hcard + have hnreal : (2 : ℝ) ≤ n := by exact_mod_cast hn + have hmreal : (3 : ℝ) ≤ m := by exact_mod_cast hm.1 + have hr : 0 ≤ ((m : ℝ) - 1) / ((n : ℝ) - 1) := + div_nonneg (by linarith) (by linarith) + have hcollision := support_singleton_error_le_half S k + (((m : ℝ) - 1) / ((n : ℝ) - 1)) hcard hr + (sqrt_block_cutoff_budget n sigma hn ht hsigma hsigma1) + have hsingle := blockProbability_singleton_inter_ge_half + (Finset.univ : Finset (Fin n)) (S.biUnion (fun e => e.val)) + (Finset.subset_univ _) hu (show 2 ≤ m by omega) + (show m ≤ (Finset.univ : Finset (Fin n)).card by + simpa only [Finset.card_univ, Fintype.card_fin] using hm.2.1) + (by simpa only [Finset.card_univ, Fintype.card_fin, mul_div_assoc] using hcollision) + have hmono := blockProbability_mono (Finset.univ : Finset (Fin n)) m + (fun B _ hB => hdetect B hB) + simpa only [Finset.card_univ, Fintype.card_fin] using hsingle.trans hmono + +/-- The graph-bias version, with the normalized cardinal ratio exposed for the +finite averaging lemma. No restriction on `p` is needed for this combinatorics. -/ +theorem graph_block_detection_probability (n : ℕ) (p : ℝ) (hn : 2 ≤ n) + (ht : 16 ≤ Real.log (n : ℝ)) + (S : Finset (GraphEdge n)) (hS : S.Nonempty) + (hcard : (S.card : ℝ) ≤ + (Real.sqrt (p * (1 - p)) * Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) / 64) ^ 2 / 2) : + (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) / (2 * n) ≤ + ((((Finset.univ : Finset (Fin n)).powersetCard ⌊Real.sqrt (n : ℝ)⌋₊).filter + (BlockDetects (Real.sqrt (p * (1 - p)) * + Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) / 64) S)).card : ℝ) / + ((Finset.univ : Finset (Fin n)).powersetCard ⌊Real.sqrt (n : ℝ)⌋₊).card := by + have hsigma1 : Real.sqrt (p * (1 - p)) ≤ (1 / 2 : ℝ) := by + apply Real.sqrt_le_iff.mpr + constructor + · norm_num + · nlinarith [sq_nonneg (p - 1 / 2)] + simpa only [blockProbability_eq] using sqrt_block_detection_probability n + (Real.sqrt (p * (1 - p))) hn ht (Real.sqrt_nonneg _) hsigma1 S hS hcard + +/-- An equivalent presentation using intersection with the finite free-edge set. -/ +theorem blockDetects_iff_inter_free_edges {n : ℕ} (k : ℝ) + (S : Finset (GraphEdge n)) (B : Finset (Fin n)) : + BlockDetects k S B ↔ + 1 ≤ (S ∩ Finset.univ.filter (fun e : GraphEdge n => ¬Disjoint e.val B)).card ∧ + ((S ∩ Finset.univ.filter (fun e : GraphEdge n => ¬Disjoint e.val B)).card : ℝ) ≤ k := by + classical + have h : S ∩ Finset.univ.filter (fun e : GraphEdge n => ¬Disjoint e.val B) = + S.filter (fun e => ¬Disjoint e.val B) := by + ext e + simp + rw [h] + rfl + +end + +end Problem313 + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/GraphQuantile.lean b/lean/OAI/Combinatorics/SharpThreshold/GraphQuantile.lean new file mode 100644 index 0000000000000000000000000000000000000000..6eedadebfa8171186779a62abc3922abccece351 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/GraphQuantile.lean @@ -0,0 +1,39 @@ +import OAI.Combinatorics.SharpThreshold.Quantile +import OAI.Combinatorics.SharpThreshold.MeanEndpoints + +namespace OAI + +noncomputable section +namespace Problem313 + +theorem graphQuantile_eq_unitQuantile {n : ℕ} (f : GraphConfig n → Bool) (a : ℝ) : + graphQuantile a f = unitQuantile (fun p => graphMean p f) a := rfl + +theorem graphMean_graphQuantile {n : ℕ} {f : GraphConfig n → Bool} + (hmono : IncreasingGraphProperty f) (hnt : NontrivialGraphProperty f) + {a : ℝ} (ha0 : 0 ≤ a) (ha1 : a ≤ 1) : + graphMean (graphQuantile a f) f = a := + unitQuantile_eq_level (continuous_graphMean f) + (graphMean_zero_of_increasing_nontrivial hmono hnt) + (graphMean_one_of_increasing_nontrivial hmono hnt) ha0 ha1 + +theorem graphQuantile_mem_Ioo {n : ℕ} {f : GraphConfig n → Bool} + (hmono : IncreasingGraphProperty f) (hnt : NontrivialGraphProperty f) + {a : ℝ} (ha0 : 0 < a) (ha1 : a < 1) : + graphQuantile a f ∈ Set.Ioo (0 : ℝ) 1 := + unitQuantile_mem_Ioo (continuous_graphMean f) + (graphMean_zero_of_increasing_nontrivial hmono hnt) + (graphMean_one_of_increasing_nontrivial hmono hnt) ha0 ha1 + +theorem graphQuantile_strictMonoOn {n : ℕ} {f : GraphConfig n → Bool} + (hmono : IncreasingGraphProperty f) (hnt : NontrivialGraphProperty f) : + StrictMonoOn (fun a => graphQuantile a f) (Set.Icc (0 : ℝ) 1) := + unitQuantile_strictMonoOn (continuous_graphMean f) + (graphMean_zero_of_increasing_nontrivial hmono hnt) + (graphMean_one_of_increasing_nontrivial hmono hnt) + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/GraphRestrictionInfluence.lean b/lean/OAI/Combinatorics/SharpThreshold/GraphRestrictionInfluence.lean new file mode 100644 index 0000000000000000000000000000000000000000..2a65ece56a30202b397c6f10cefd48fead5b0f30 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/GraphRestrictionInfluence.lean @@ -0,0 +1,79 @@ +import OAI.Combinatorics.SharpThreshold.RestrictionInfluence +import OAI.Combinatorics.SharpThreshold.InfluenceReindex +import OAI.Combinatorics.SharpThreshold.BlockRestrictionSymmetry +import OAI.Combinatorics.SharpThreshold.BlockSymmetry + +namespace OAI + +universe u + +noncomputable section +open scoped Classical BigOperators + +namespace Problem313 + +/-- The generic restriction weight agrees with the qualified graph weight. -/ +theorem restrictionWeight_eq_graphWeight {n : ℕ} (p : ℝ) (x : GraphConfig n) : + RestrictionInfluence.weight p x = graphWeight p x := rfl + +/-- The generic restriction influence agrees with the qualified graph influence. -/ +theorem restrictionInfluence_eq_edgeInfluence {n : ℕ} (p : ℝ) + (f : GraphConfig n → Bool) (e : GraphEdge n) : + RestrictionInfluence.influence p f e = edgeInfluence p f e := rfl + +/-- The two generic influence interfaces have definitionally identical weights. -/ +theorem restrictionWeight_eq_reindexWeight {ι : Type u} [Fintype ι] [DecidableEq ι] + (p : ℝ) (x : ι → Bool) : + RestrictionInfluence.weight p x = Reindex.weight p x := rfl + +/-- The two generic influence interfaces have equal influences after identifying their decidable-equality instances. -/ +theorem restrictionInfluence_eq_reindexInfluence {ι : Type u} [Fintype ι] [d : DecidableEq ι] + (p : ℝ) (f : (ι → Bool) → Bool) (i : ι) : + RestrictionInfluence.influence p f i = Reindex.influence p f i := by + cases Subsingleton.elim d (Classical.typeDecidableEq ι) + rfl + +/-- Averaging a conditional free-edge influence recovers its original graph influence. -/ +theorem block_average_edgeInfluence {n : ℕ} (B : Finset (Fin n)) [DecidablePred (EdgeTouches B)] (p : ℝ) + (f : GraphConfig n → Bool) (e : {e : GraphEdge n // EdgeTouches B e}) : + (∑ y : {e : GraphEdge n // ¬ EdgeTouches B e} → Bool, + Reindex.weight p y * Reindex.influence p (restrictCube (EdgeTouches B) f y) e) = + edgeInfluence p f e.val := by + have h := RestrictionInfluence.average_influence (EdgeTouches B) p f e + unfold RestrictionInfluence.join at h + unfold restrictCube pasteCube + simpa only [← restrictionWeight_eq_reindexWeight, + ← restrictionInfluence_eq_reindexInfluence, + ← restrictionInfluence_eq_edgeInfluence] using h + +/-- Averaging conditional total influence gives precisely the original influences of +edges touching the block; no invariance or monotonicity is needed. -/ +theorem block_average_totalInfluence {n : ℕ} (B : Finset (Fin n)) [DecidablePred (EdgeTouches B)] (p : ℝ) + (f : GraphConfig n → Bool) : + (∑ y : {e : GraphEdge n // ¬ EdgeTouches B e} → Bool, + Reindex.weight p y * ∑ e : {e : GraphEdge n // EdgeTouches B e}, + Reindex.influence p (restrictCube (EdgeTouches B) f y) e) = + ∑ e : {e : GraphEdge n // EdgeTouches B e}, edgeInfluence p f e.val := by + have h := RestrictionInfluence.average_totalInfluence (EdgeTouches B) p f + unfold RestrictionInfluence.join at h + unfold restrictCube pasteCube + simpa only [← restrictionWeight_eq_reindexWeight, + ← restrictionInfluence_eq_reindexInfluence, + ← restrictionInfluence_eq_edgeInfluence] using h + +/-- The conditional total-influence identity, with a filtered finite edge sum. -/ +theorem block_average_totalInfluence_filter {n : ℕ} (B : Finset (Fin n)) + [DecidablePred (EdgeTouches B)] (p : ℝ) (f : GraphConfig n → Bool) : + (∑ y : {e : GraphEdge n // ¬ EdgeTouches B e} → Bool, + Reindex.weight p y * ∑ e : {e : GraphEdge n // EdgeTouches B e}, + Reindex.influence p (restrictCube (EdgeTouches B) f y) e) = + ∑ e ∈ Finset.univ.filter (EdgeTouches B), edgeInfluence p f e := by + rw [block_average_totalInfluence] + exact (Finset.sum_subtype (Finset.univ.filter (EdgeTouches B)) + (by intro e; simp) (edgeInfluence p f)).symm + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/GraphSupport.lean b/lean/OAI/Combinatorics/SharpThreshold/GraphSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..3e95f12eb1476a1d564ede56626f6ede7fed93e6 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/GraphSupport.lean @@ -0,0 +1,6 @@ +import OAI.Combinatorics.SharpThreshold.SupportIncidence +import OAI.Combinatorics.SharpThreshold.BlockIncidence +import OAI.Combinatorics.SharpThreshold.BlockCounting +import OAI.Combinatorics.SharpThreshold.BlockSize + +import OAI.Combinatorics.SharpThreshold.GraphBlockCapture diff --git a/lean/OAI/Combinatorics/SharpThreshold/GraphSymmetry.lean b/lean/OAI/Combinatorics/SharpThreshold/GraphSymmetry.lean new file mode 100644 index 0000000000000000000000000000000000000000..9bff504fc9ca10d9611d56d32d20b3fb54cb59c3 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/GraphSymmetry.lean @@ -0,0 +1,13 @@ +import OAI.Combinatorics.SharpThreshold.Permutation +import OAI.Combinatorics.SharpThreshold.InfluenceReindex +import OAI.Combinatorics.SharpThreshold.BlockRestrictionSymmetry +import OAI.Combinatorics.SharpThreshold.BlockSymmetry +import OAI.Combinatorics.SharpThreshold.BlockOrbits +import OAI.Combinatorics.SharpThreshold.BlockOrbitSubtype +import OAI.Combinatorics.SharpThreshold.BlockInfluence +import OAI.Combinatorics.SharpThreshold.SupportDegreeGraph +import OAI.Combinatorics.SharpThreshold.BlockIncidence +import OAI.Combinatorics.SharpThreshold.BlockCounting + +/-! Canonical graph symmetry, supported-edge orbits, support-degree bounds, +and fixed-size vertex-block counting used by the variance proof. -/ diff --git a/lean/OAI/Combinatorics/SharpThreshold/GraphVarianceBound.lean b/lean/OAI/Combinatorics/SharpThreshold/GraphVarianceBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..305076b44dddd83cb35fd25dd51c0907a34538ff --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/GraphVarianceBound.lean @@ -0,0 +1,101 @@ +import OAI.Combinatorics.SharpThreshold.Probability +import OAI.Combinatorics.SharpThreshold.FourierVariance +import OAI.Combinatorics.SharpThreshold.FourierDirichlet +import OAI.Combinatorics.SharpThreshold.BlockSize +import OAI.Combinatorics.SharpThreshold.VarianceReduction +import OAI.Combinatorics.SharpThreshold.GraphBlockAverage + +namespace OAI + +noncomputable section + +namespace Problem313 + +/-- The graph-level variance reduction, with the two spectral identities and +large-scale block capture supplied explicitly. No symmetry is needed after +these inputs have been obtained. -/ +theorem graphVariance_bound_of_spectral_inputs {n : ℕ} + (f : GraphConfig n → Bool) (p : ℝ) (hn : 2 ≤ n) (hp : 0 < p) (hp1 : p < 1) + (hvariance : graphVariance p f = + ∑ S : Finset (GraphEdge n) with S.Nonempty, + BiasedFourier.coeff p (fun x => boolReal (f x)) S ^ 2) + (hdirichlet : (∑ S : Finset (GraphEdge n), (S.card : ℝ) * + BiasedFourier.coeff p (fun x => boolReal (f x)) S ^ 2) = + p * (1 - p) * totalInfluence p f) + (hcapture : 16 ≤ Real.log (n : ℝ) → + (∑ S : Finset (GraphEdge n) with S.Nonempty ∧ + (S.card : ℝ) ≤ (Real.sqrt (p * (1 - p)) * + Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) / 64) ^ 2 / 2, + BiasedFourier.coeff p (fun x => boolReal (f x)) S ^ 2) ≤ + (4 * (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) ^ (-1 / 4 : ℝ)) * totalInfluence p f) : + graphVariance p f ≤ + ((2 : ℝ) ^ 17 / (Real.log (n : ℝ)) ^ 2) * totalInfluence p f := by + classical + have hbias : 0 < p * (1 - p) := mul_pos hp (sub_pos.mpr hp1) + have hsigma : 0 < Real.sqrt (p * (1 - p)) := Real.sqrt_pos.2 hbias + have hsigma_sq : Real.sqrt (p * (1 - p)) ^ 2 ≤ 1 / 4 := by + rw [Real.sq_sqrt hbias.le] + nlinarith [sq_nonneg (p - 1 / 2)] + have hnreal : (2 : ℝ) ≤ n := by exact_mod_cast hn + have hlog : 0 < Real.log (n : ℝ) := Real.log_pos (by linarith) + apply variance_bound_of_fourier_inputs + (BiasedFourier.coeff p (fun x => boolReal (f x))) + (graphVariance p f) (Real.sqrt (p * (1 - p))) + (totalInfluence p f) (Real.log (n : ℝ)) + hsigma hsigma_sq (totalInfluence_nonneg hp.le hp1.le f) hlog hvariance + · simpa only [Real.sq_sqrt hbias.le] using hdirichlet + · intro ht + refine ⟨(⌊Real.sqrt (n : ℝ)⌋₊ : ℝ), ?_, log_sqrt_block_lower n hn ht, hcapture ht⟩ + have hm := (sqrt_block_size_bounds n hn ht).1 + exact_mod_cast (by omega : 0 < ⌊Real.sqrt (n : ℝ)⌋₊) + +/-- Parseval discharges the variance identity, leaving the Dirichlet and captured-mass inputs. -/ +theorem graphVariance_bound_of_dirichlet_capture {n : ℕ} + (f : GraphConfig n → Bool) (p : ℝ) (hn : 2 ≤ n) (hp : 0 < p) (hp1 : p < 1) + (hdirichlet : (∑ S : Finset (GraphEdge n), (S.card : ℝ) * + BiasedFourier.coeff p (fun x => boolReal (f x)) S ^ 2) = + p * (1 - p) * totalInfluence p f) + (hcapture : 16 ≤ Real.log (n : ℝ) → + (∑ S : Finset (GraphEdge n) with S.Nonempty ∧ + (S.card : ℝ) ≤ (Real.sqrt (p * (1 - p)) * + Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) / 64) ^ 2 / 2, + BiasedFourier.coeff p (fun x => boolReal (f x)) S ^ 2) ≤ + (4 * (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) ^ (-1 / 4 : ℝ)) * totalInfluence p f) : + graphVariance p f ≤ + ((2 : ℝ) ^ 17 / (Real.log (n : ℝ)) ^ 2) * totalInfluence p f := by + exact graphVariance_bound_of_spectral_inputs f p hn hp hp1 + (graphVariance_eq_fourier_sum_nonempty hp hp1 f) hdirichlet hcapture + +/-- All spectral and numerical ingredients are discharged; only the graph-specific +large-scale captured-mass estimate remains. -/ +theorem graphVariance_bound_of_capture {n : ℕ} + (f : GraphConfig n → Bool) (p : ℝ) (hn : 2 ≤ n) (hp : 0 < p) (hp1 : p < 1) + (hcapture : 16 ≤ Real.log (n : ℝ) → + (∑ S : Finset (GraphEdge n) with S.Nonempty ∧ + (S.card : ℝ) ≤ (Real.sqrt (p * (1 - p)) * + Real.log (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) / 64) ^ 2 / 2, + BiasedFourier.coeff p (fun x => boolReal (f x)) S ^ 2) ≤ + (4 * (⌊Real.sqrt (n : ℝ)⌋₊ : ℝ) ^ (-1 / 4 : ℝ)) * totalInfluence p f) : + graphVariance p f ≤ + ((2 : ℝ) ^ 17 / (Real.log (n : ℝ)) ^ 2) * totalInfluence p f := by + exact graphVariance_bound_of_dirichlet_capture f p hn hp hp1 + (graph_fourier_dirichlet hp hp1 f) hcapture + +/-- The graph variance bound, with all spectral, analytic, counting, and +numerical inputs discharged. -/ +theorem variance_influence_bound_core + (n : ℕ) (f : GraphConfig n → Bool) (p : ℝ) + (hn : 2 ≤ n) (hf : VertexInvariant f) (hp : 0 < p) (hp1 : p < 1) : + graphVariance p f ≤ + ((2 : ℝ) ^ 17 / (Real.log (n : ℝ)) ^ 2) * totalInfluence p f := by + classical + apply graphVariance_bound_of_capture f p hn hp hp1 + intro ht + simpa only [Finset.sum_filter] using + graph_fourier_captured_mass f hn ht hf hp hp1 + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/HypercontractiveTensor.lean b/lean/OAI/Combinatorics/SharpThreshold/HypercontractiveTensor.lean new file mode 100644 index 0000000000000000000000000000000000000000..601e95b74c109a61a390a5d827292f2d2c8bd57f --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/HypercontractiveTensor.lean @@ -0,0 +1,129 @@ +import Mathlib + +namespace OAI + +universe u + +noncomputable section + +namespace Problem313 + +/-- Weighted Cauchy--Schwarz in a form useful for finite product measures. -/ +theorem weighted_cauchy_schwarz_sq {α : Type u} (s : Finset α) + (w u v : α → ℝ) (hw : ∀ x ∈ s, 0 ≤ w x) : + (∑ x ∈ s, w x * u x * v x) ^ 2 ≤ + (∑ x ∈ s, w x * (u x) ^ 2) * (∑ x ∈ s, w x * (v x) ^ 2) := by + apply Finset.sum_sq_le_sum_mul_sum_of_sq_le_mul s + · intro x hx + exact mul_nonneg (hw x hx) (sq_nonneg _) + · intro x hx + exact mul_nonneg (hw x hx) (sq_nonneg _) + · intro x hx + exact le_of_eq (by ring) + +/-- The root-free Minkowski step in tensorization of the fourth moment. -/ +theorem weighted_fourth_moment_add_sq {α : Type u} (s : Finset α) + (w A B : α → ℝ) (a b : ℝ) (hw : ∀ x ∈ s, 0 ≤ w x) + (ha : 0 ≤ a) (hb : 0 ≤ b) + (hA : (∑ x ∈ s, w x * (A x) ^ 4) ≤ a ^ 2) + (hB : (∑ x ∈ s, w x * (B x) ^ 4) ≤ b ^ 2) : + (∑ x ∈ s, w x * ((A x) ^ 2 + (B x) ^ 2) ^ 2) ≤ (a + b) ^ 2 := by + have hcs := weighted_cauchy_schwarz_sq s w (fun x => (A x) ^ 2) + (fun x => (B x) ^ 2) hw + have hA0 : 0 ≤ ∑ x ∈ s, w x * (A x) ^ 4 := + Finset.sum_nonneg (fun x hx => mul_nonneg (hw x hx) (by positivity)) + have hB0 : 0 ≤ ∑ x ∈ s, w x * (B x) ^ 4 := + Finset.sum_nonneg (fun x hx => mul_nonneg (hw x hx) (by positivity)) + have hprod := mul_le_mul hA hB hB0 (sq_nonneg a) + have hpow : ∀ x : ℝ, (x ^ 2) ^ 2 = x ^ 4 := fun x => by ring + simp_rw [hpow] at hcs + have hab : 0 ≤ a * b := mul_nonneg ha hb + have hcross : (∑ x ∈ s, w x * (A x) ^ 2 * (B x) ^ 2) ≤ a * b := by + nlinarith [sq_nonneg ((∑ x ∈ s, w x * (A x) ^ 2 * (B x) ^ 2) - a * b)] + have hexpand : (∑ x ∈ s, w x * ((A x) ^ 2 + (B x) ^ 2) ^ 2) = + (∑ x ∈ s, w x * (A x) ^ 4) + + 2 * (∑ x ∈ s, w x * (A x) ^ 2 * (B x) ^ 2) + + (∑ x ∈ s, w x * (B x) ^ 4) := by + simp only [Finset.mul_sum, ← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro x hx + ring + rw [hexpand] + nlinarith + +/-- A version of the fourth-moment Minkowski step with two nonnegative coefficients. -/ +theorem weighted_fourth_moment_combo {α : Type u} (s : Finset α) + (w A B : α → ℝ) (a b c d : ℝ) (hw : ∀ x ∈ s, 0 ≤ w x) + (ha : 0 ≤ a) (hb : 0 ≤ b) (hc : 0 ≤ c) (hd : 0 ≤ d) + (hA : (∑ x ∈ s, w x * (A x) ^ 4) ≤ a ^ 2) + (hB : (∑ x ∈ s, w x * (B x) ^ 4) ≤ b ^ 2) : + (∑ x ∈ s, w x * (c * (A x) ^ 2 + d * (B x) ^ 2) ^ 2) ≤ + (c * a + d * b) ^ 2 := by + have hA' : (∑ x ∈ s, w x * (Real.sqrt c * A x) ^ 4) ≤ (c * a) ^ 2 := by + calc + _ = c ^ 2 * (∑ x ∈ s, w x * (A x) ^ 4) := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro x hx + rw [mul_pow, show Real.sqrt c ^ 4 = c ^ 2 by + rw [show (4 : ℕ) = 2 * 2 by norm_num, pow_mul, Real.sq_sqrt hc]] + ring + _ ≤ c ^ 2 * a ^ 2 := mul_le_mul_of_nonneg_left hA (sq_nonneg c) + _ = _ := by ring + have hB' : (∑ x ∈ s, w x * (Real.sqrt d * B x) ^ 4) ≤ (d * b) ^ 2 := by + calc + _ = d ^ 2 * (∑ x ∈ s, w x * (B x) ^ 4) := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro x hx + rw [mul_pow, show Real.sqrt d ^ 4 = d ^ 2 by + rw [show (4 : ℕ) = 2 * 2 by norm_num, pow_mul, Real.sq_sqrt hd]] + ring + _ ≤ d ^ 2 * b ^ 2 := mul_le_mul_of_nonneg_left hB (sq_nonneg d) + _ = _ := by ring + have h := weighted_fourth_moment_add_sq s w + (fun x => Real.sqrt c * A x) (fun x => Real.sqrt d * B x) + (c * a) (d * b) hw (mul_nonneg hc ha) (mul_nonneg hd hb) hA' hB' + simpa only [mul_pow, Real.sq_sqrt hc, Real.sq_sqrt hd] using h + +/-- A fourth-moment contraction tensorizes with a two-point contraction. +No linearity assumptions are needed for this analytic step. -/ +theorem fourth_moment_tensor_bool {α : Type u} [Fintype α] + (w : α → ℝ) (q : Bool → ℝ) + (T : (α → ℝ) → α → ℝ) (S : (Bool → ℝ) → Bool → ℝ) + (hw : ∀ x, 0 ≤ w x) (hq : ∀ b, 0 ≤ q b) + (hT : ∀ g, (∑ x, w x * (T g x) ^ 4) ≤ (∑ x, w x * (g x) ^ 2) ^ 2) + (hS : ∀ g, (∑ b, q b * (S g b) ^ 4) ≤ (∑ b, q b * (g b) ^ 2) ^ 2) + (g : Bool → α → ℝ) : + (∑ x, ∑ b, w x * q b * (S (fun c => T (g c) x) b) ^ 4) ≤ + (∑ b, ∑ x, q b * w x * (g b x) ^ 2) ^ 2 := by + classical + have ha : 0 ≤ ∑ x, w x * (g false x) ^ 2 := + Finset.sum_nonneg (fun x _ => mul_nonneg (hw x) (sq_nonneg _)) + have hb : 0 ≤ ∑ x, w x * (g true x) ^ 2 := + Finset.sum_nonneg (fun x _ => mul_nonneg (hw x) (sq_nonneg _)) + calc + _ = ∑ x, w x * (∑ b, q b * (S (fun c => T (g c) x) b) ^ 4) := by + simp only [Finset.mul_sum, mul_assoc] + _ ≤ ∑ x, w x * (∑ b, q b * (T (g b) x) ^ 2) ^ 2 := by + apply Finset.sum_le_sum + intro x hx + exact mul_le_mul_of_nonneg_left (hS _) (hw x) + _ = ∑ x, w x * (q false * (T (g false) x) ^ 2 + + q true * (T (g true) x) ^ 2) ^ 2 := by + simp only [Fintype.sum_bool, add_comm] + _ ≤ (q false * (∑ x, w x * (g false x) ^ 2) + + q true * (∑ x, w x * (g true x) ^ 2)) ^ 2 := + weighted_fourth_moment_combo Finset.univ w (T (g false)) (T (g true)) + _ _ (q false) (q true) (fun x _ => hw x) ha hb (hq false) (hq true) + (hT _) (hT _) + _ = _ := by + simp only [Fintype.sum_bool, Finset.mul_sum] + congr 1 + ring_nf + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/InfluenceReindex.lean b/lean/OAI/Combinatorics/SharpThreshold/InfluenceReindex.lean new file mode 100644 index 0000000000000000000000000000000000000000..a50869fcb0b7c780a7258a44023dcfa4ce6fcf80 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/InfluenceReindex.lean @@ -0,0 +1,109 @@ +import Mathlib + +namespace OAI + +universe u v + +noncomputable section + +namespace Problem313 +namespace Reindex + +variable {ι : Type u} {κ : Type v} + +def config (e : ι ≃ κ) (x : ι → Bool) : κ → Bool := fun j => x (e.symm j) + +def configEquiv (e : ι ≃ κ) : (ι → Bool) ≃ (κ → Bool) where + toFun := config e + invFun := config e.symm + left_inv x := by ext i; simp [config] + right_inv x := by ext i; simp [config] + +@[simp] theorem config_apply (e : ι ≃ κ) (x : ι → Bool) (i : ι) : + config e x (e i) = x i := by simp [config] + +@[simp] theorem configEquiv_apply (e : ι ≃ κ) (x : ι → Bool) : + configEquiv e x = config e x := rfl + +theorem config_update [DecidableEq ι] [DecidableEq κ] (e : ι ≃ κ) (x : ι → Bool) (i : ι) (b : Bool) : + config e (Function.update x i b) = Function.update (config e x) (e i) b := by + classical + ext j + by_cases h : j = e i + · subst j; simp [config] + · have h' : e.symm j ≠ i := by + intro he + apply h + simpa using congrArg e he + simp [config, h, h'] + +def weight [Fintype ι] (p : ℝ) (x : ι → Bool) : ℝ := + ∏ i, if x i = true then p else 1 - p + +def influence [Fintype ι] (p : ℝ) (f : (ι → Bool) → Bool) (i : ι) : ℝ := by + classical + exact ∑ x, if f (Function.update x i true) ≠ f (Function.update x i false) + then weight p x else 0 + +theorem weight_config [Fintype ι] [Fintype κ] (e : ι ≃ κ) + (p : ℝ) (x : ι → Bool) : weight p (config e x) = weight p x := by + unfold weight + exact (Fintype.prod_equiv e _ _ (fun i => by simp)).symm + +theorem influence_config [Fintype ι] [Fintype κ] (e : ι ≃ κ) + (p : ℝ) (f : (ι → Bool) → Bool) (g : (κ → Bool) → Bool) + (hfg : ∀ x, g (config e x) = f x) (i : ι) : + influence p g (e i) = influence p f i := by + classical + unfold influence + apply Eq.symm + apply Fintype.sum_equiv (configEquiv e) + intro x + simp only [configEquiv_apply, ← config_update, hfg, weight_config] + +theorem weight_nonneg [Fintype ι] {p : ℝ} (hp0 : 0 ≤ p) (hp1 : p ≤ 1) + (x : ι → Bool) : 0 ≤ weight p x := by + unfold weight + apply Finset.prod_nonneg + intro i hi + split_ifs <;> linarith + +theorem influence_nonneg [Fintype ι] {p : ℝ} (hp0 : 0 ≤ p) (hp1 : p ≤ 1) + (f : (ι → Bool) → Bool) (i : ι) : 0 ≤ influence p f i := by + classical + unfold influence + apply Finset.sum_nonneg + intro x hx + split_ifs + · exact weight_nonneg hp0 hp1 x + · exact le_rfl + +/-- An orbit of at least `m` equally influential coordinates bounds each influence. -/ +theorem influence_le_total_div [Fintype ι] {p : ℝ} + (hp0 : 0 ≤ p) (hp1 : p ≤ 1) (f : (ι → Bool) → Bool) (i : ι) + (S : Finset ι) {m : ℝ} (hm : 0 < m) (hcard : m ≤ (S.card : ℝ)) + (heq : ∀ j ∈ S, influence p f j = influence p f i) : + influence p f i ≤ (∑ j, influence p f j) / m := by + classical + have hi := influence_nonneg hp0 hp1 f i + have hS : (S.card : ℝ) * influence p f i = ∑ j ∈ S, influence p f j := by + calc + (S.card : ℝ) * influence p f i = ∑ _j ∈ S, influence p f i := by simp + _ = ∑ j ∈ S, influence p f j := Finset.sum_congr rfl (fun j hj => (heq j hj).symm) + have hsum : (∑ j ∈ S, influence p f j) ≤ ∑ j, influence p f j := by + apply Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ S) + intro j hj hjS + exact influence_nonneg hp0 hp1 f j + apply (le_div_iff₀ hm).2 + calc + influence p f i * m = m * influence p f i := mul_comm _ _ + _ ≤ (S.card : ℝ) * influence p f i := mul_le_mul_of_nonneg_right hcard hi + _ = ∑ j ∈ S, influence p f j := hS + _ ≤ ∑ j, influence p f j := hsum + +end Reindex +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/LowDegree.lean b/lean/OAI/Combinatorics/SharpThreshold/LowDegree.lean new file mode 100644 index 0000000000000000000000000000000000000000..918e21fe472d4151f35b99276bd0ab1188ae1d19 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/LowDegree.lean @@ -0,0 +1,106 @@ +import OAI.Combinatorics.SharpThreshold.LowDegreeBounds +import OAI.Combinatorics.SharpThreshold.FourierDerivative +import OAI.Combinatorics.SharpThreshold.FourierVariance +import OAI.Combinatorics.SharpThreshold.BooleanProjection +import OAI.Combinatorics.SharpThreshold.FourierHypercontractive + +namespace OAI + +universe u + +noncomputable section + +namespace Problem313.BiasedFourier + +open scoped BigOperators Classical + +variable {ι : Type u} [Fintype ι] + +/-- The biased low-degree influence estimate, with the product noise +contraction as its only remaining analytic premise. -/ +theorem low_degree_estimate_of_noise {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (f : (ι → Bool) → Bool) (m : ℝ) (hm : 1 ≤ m) + (horbit : ∀ i, Reindex.influence p f i ≤ (∑ j, Reindex.influence p f j) / m) + (hnoise : ∀ a : Finset ι → ℝ, + (∑ x, weight p x * + (∑ S, (Real.sqrt (p * (1 - p)) / 4) ^ S.card * a S * char p S x) ^ 4) ≤ + (∑ S, (a S) ^ 2) ^ 2) : + (∑ S : Finset ι, + if S.Nonempty ∧ (S.card : ℝ) ≤ Real.sqrt (p * (1 - p)) * Real.log m / 64 + then coeff p (fun x => boolReal (f x)) S ^ 2 else 0) ≤ + m ^ (-1 / 4 : ℝ) * ∑ i, Reindex.influence p f i := by + have hvar : 0 < p * (1 - p) := mul_pos hp (sub_pos.mpr hp1) + have hσ : 0 < Real.sqrt (p * (1 - p)) := Real.sqrt_pos.mpr hvar + have hσhalf : Real.sqrt (p * (1 - p)) ≤ 1 / 2 := by + apply Real.sqrt_le_iff.mpr + constructor + · norm_num + · nlinarith [sq_nonneg (p - 1 / 2)] + have hρ : 0 < Real.sqrt (p * (1 - p)) / 4 := by positivity + have hρ1 : Real.sqrt (p * (1 - p)) / 4 ≤ 1 := by linarith + refine lowDegree_bound_of_projection + (fun S => coeff p (fun x => boolReal (f x)) S ^ 2) + (fun i S => coeff p (delta i (fun x => boolReal (f x))) S ^ 2) + (Reindex.influence p f) (Real.sqrt (p * (1 - p))) m hσ hσhalf hm + (fun S => sq_nonneg _) (fun i S => sq_nonneg _) + (Reindex.influence_nonneg hp.le hp1.le f) horbit + (boolean_spectral_mass_le_one hp hp1 f) ?_ ?_ + · intro i S hi + rw [Real.sq_sqrt hvar.le] + exact coeff_sq_eq_variance_mul_delta_erase_sq hp hp1 + (fun x => boolReal (f x)) i S hi + · intro i + change (∑ S : Finset ι, + if (S.card : ℝ) ≤ Real.sqrt (p * (1 - p)) * Real.log m / 64 + then coeff p (fun x => boolReal (f (Function.update x i true)) - + boolReal (f (Function.update x i false))) S ^ 2 else 0) ≤ _ + simpa only [Finset.sum_filter] using + booleanDifference_lowDegree_energy_le hp hp1 + (Real.sqrt (p * (1 - p)) / 4) + (Real.sqrt (p * (1 - p)) * Real.log m / 64) + hρ hρ1 hnoise f i + +/-- Version of the low-degree estimate written as a filtered sum with the +literal positive integer degree condition. -/ +theorem low_degree_estimate_filter_of_noise {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (f : (ι → Bool) → Bool) (m : ℝ) (hm : 1 ≤ m) + (horbit : ∀ i, Reindex.influence p f i ≤ (∑ j, Reindex.influence p f j) / m) + (hnoise : ∀ a : Finset ι → ℝ, + (∑ x, weight p x * + (∑ S, (Real.sqrt (p * (1 - p)) / 4) ^ S.card * a S * char p S x) ^ 4) ≤ + (∑ S, (a S) ^ 2) ^ 2) : + (∑ S ∈ (Finset.univ.filter fun S : Finset ι => + 1 ≤ S.card ∧ (S.card : ℝ) ≤ Real.sqrt (p * (1 - p)) * Real.log m / 64), + coeff p (fun x => boolReal (f x)) S ^ 2) ≤ + m ^ (-1 / 4 : ℝ) * ∑ i, Reindex.influence p f i := by + simpa only [Finset.sum_filter, Finset.one_le_card] using + low_degree_estimate_of_noise hp hp1 f m hm horbit hnoise + +/-- The biased Boolean low-degree estimate. No monotonicity or symmetry +is required beyond the displayed bound on each coordinate influence. -/ +theorem low_degree_estimate {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (f : (ι → Bool) → Bool) (m : ℝ) (hm : 1 ≤ m) + (horbit : ∀ i, Reindex.influence p f i ≤ (∑ j, Reindex.influence p f j) / m) : + (∑ S : Finset ι, + if S.Nonempty ∧ (S.card : ℝ) ≤ Real.sqrt (p * (1 - p)) * Real.log m / 64 + then coeff p (fun x => boolReal (f x)) S ^ 2 else 0) ≤ + m ^ (-1 / 4 : ℝ) * ∑ i, Reindex.influence p f i := by + exact low_degree_estimate_of_noise hp hp1 f m hm horbit + (synthesis_fourth_bound hp hp1) + +/-- The literal integer-degree filtered-sum form of the low-degree estimate. -/ +theorem low_degree_estimate_filter {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (f : (ι → Bool) → Bool) (m : ℝ) (hm : 1 ≤ m) + (horbit : ∀ i, Reindex.influence p f i ≤ (∑ j, Reindex.influence p f j) / m) : + (∑ S ∈ (Finset.univ.filter fun S : Finset ι => + 1 ≤ S.card ∧ (S.card : ℝ) ≤ Real.sqrt (p * (1 - p)) * Real.log m / 64), + coeff p (fun x => boolReal (f x)) S ^ 2) ≤ + m ^ (-1 / 4 : ℝ) * ∑ i, Reindex.influence p f i := by + exact low_degree_estimate_filter_of_noise hp hp1 f m hm horbit + (synthesis_fourth_bound hp hp1) + +end Problem313.BiasedFourier + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/LowDegreeBounds.lean b/lean/OAI/Combinatorics/SharpThreshold/LowDegreeBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..11a041d932dd5a75639a2335f7c9e555d67c59c9 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/LowDegreeBounds.lean @@ -0,0 +1,163 @@ +import OAI.Combinatorics.SharpThreshold.LowDegreeConstants +import OAI.Combinatorics.SharpThreshold.LowDegreeInfluence + +namespace OAI + +universe u + +noncomputable section + +namespace Problem313 + +open Finset + +/-- Every nonempty low-degree Fourier support is counted by at least one of +its incident coordinate sums. This is purely finite, nonnegative double counting. -/ +theorem lowDegree_mass_le_incident_mass + {ι : Type u} [Fintype ι] [DecidableEq ι] + (a : Finset ι → ℝ) (ha : ∀ S, 0 ≤ a S) (k : ℝ) : + (∑ S : Finset ι, if S.Nonempty ∧ (S.card : ℝ) ≤ k then a S else 0) ≤ + ∑ i : ι, ∑ S : Finset ι, if i ∈ S ∧ (S.card : ℝ) ≤ k then a S else 0 := by + rw [Finset.sum_comm] + apply Finset.sum_le_sum + intro S hS + by_cases h : S.Nonempty ∧ (S.card : ℝ) ≤ k + · rw [ite_eq_left h] + obtain ⟨i, hi⟩ := h.1 + calc + a S = (if i ∈ S ∧ (S.card : ℝ) ≤ k then a S else 0) := by simp [hi, h.2] + _ ≤ ∑ j : ι, if j ∈ S ∧ (S.card : ℝ) ≤ k then a S else 0 := by + apply Finset.single_le_sum (f := fun j : ι => + if j ∈ S ∧ (S.card : ℝ) ≤ k then a S else 0) (s := Finset.univ) + · intro j hj + split_ifs + · exact ha S + · exact le_refl 0 + · exact Finset.mem_univ i + · rw [ite_eq_right h] + apply Finset.sum_nonneg + intro i hi + split_ifs + · exact ha S + · exact le_refl 0 + +/-- Assemble coordinatewise low-degree estimates without any choice of a +single coordinate common to all supports. -/ +theorem lowDegree_mass_le_of_coordinate_bound + {ι : Type u} [Fintype ι] [DecidableEq ι] + (a : Finset ι → ℝ) (ha : ∀ S, 0 ≤ a S) (k C : ℝ) + (J : ι → ℝ) + (hcoord : ∀ i, (∑ S : Finset ι, + if i ∈ S ∧ (S.card : ℝ) ≤ k then a S else 0) ≤ C * J i) : + (∑ S : Finset ι, if S.Nonempty ∧ (S.card : ℝ) ≤ k then a S else 0) ≤ + C * ∑ i : ι, J i := by + calc + _ ≤ ∑ i : ι, ∑ S : Finset ι, + if i ∈ S ∧ (S.card : ℝ) ≤ k then a S else 0 := + lowDegree_mass_le_incident_mass a ha k + _ ≤ ∑ i : ι, C * J i := Finset.sum_le_sum (fun i _ => hcoord i) + _ = C * ∑ i : ι, J i := (Finset.mul_sum _ _ _).symm + +/-- A cutoff below one contains no nonconstant Boolean Fourier supports. -/ +theorem lowDegree_mass_eq_zero_of_lt_one + {ι : Type u} [Fintype ι] [DecidableEq ι] + (a : Finset ι → ℝ) {k : ℝ} (hk : k < 1) : + (∑ S : Finset ι, if S.Nonempty ∧ (S.card : ℝ) ≤ k then a S else 0) = 0 := by + apply Finset.sum_eq_zero + intro S hS + apply ite_eq_right + rintro ⟨hne, hcard⟩ + have hc : (1 : ℝ) ≤ S.card := by exact_mod_cast hne.card_pos + linarith + +/-- Erasing a fixed coordinate injects supports containing it into supports +of no larger degree. This transports a derivative coefficient identity to +a low-degree mass bound, without changing the ambient coordinate type. -/ +theorem incident_mass_le_erase_mass + {ι : Type u} [Fintype ι] [DecidableEq ι] + (a b : Finset ι → ℝ) (hb : ∀ T, 0 ≤ b T) (i : ι) (k C : ℝ) + (hC : 0 ≤ C) + (hderiv : ∀ S, i ∈ S → a S = C * b (S.erase i)) : + (∑ S : Finset ι, if i ∈ S ∧ (S.card : ℝ) ≤ k then a S else 0) ≤ + C * ∑ T : Finset ι, if (T.card : ℝ) ≤ k then b T else 0 := by + let s : Finset (Finset ι) := univ.filter (fun S => i ∈ S ∧ (S.card : ℝ) ≤ k) + let t : Finset (Finset ι) := univ.filter (fun T => (T.card : ℝ) ≤ k) + have hinj : Set.InjOn (fun S : Finset ι => S.erase i) (s : Set (Finset ι)) := by + intro S hS T hT hST + have hiS : i ∈ S := (Finset.mem_filter.mp hS).2.1 + have hiT : i ∈ T := (Finset.mem_filter.mp hT).2.1 + simpa only [Finset.insert_erase hiS, Finset.insert_erase hiT] using + congrArg (fun U : Finset ι => insert i U) hST + have hsub : s.image (fun S => S.erase i) ⊆ t := by + intro T hT + obtain ⟨S, hS, rfl⟩ := Finset.mem_image.mp hT + apply Finset.mem_filter.mpr + refine ⟨Finset.mem_univ _, ?_⟩ + have hcard : ((S.erase i).card : ℝ) ≤ S.card := by + exact_mod_cast Finset.card_erase_le (s := S) (a := i) + exact hcard.trans (Finset.mem_filter.mp hS).2.2 + calc + _ = ∑ S ∈ s, a S := (Finset.sum_filter _ _).symm + _ = ∑ S ∈ s, C * b (S.erase i) := by + apply Finset.sum_congr rfl + intro S hS + exact hderiv S (Finset.mem_filter.mp hS).2.1 + _ = C * ∑ S ∈ s, b (S.erase i) := (Finset.mul_sum _ _ _).symm + _ = C * ∑ T ∈ s.image (fun S => S.erase i), b T := by + rw [Finset.sum_image hinj] + _ ≤ C * ∑ T ∈ t, b T := by + apply mul_le_mul_of_nonneg_left _ hC + exact Finset.sum_le_sum_of_subset_of_nonneg hsub (fun T _ _ => hb T) + _ = _ := by rw [Finset.sum_filter] + +/-- The complete low-degree estimate once the analytic Fourier ingredients +are supplied: the derivative coefficient identity and the low-degree +projection bound. All incidence counting, bias constants, and the +small/large total-influence split are discharged here. -/ +theorem lowDegree_bound_of_projection + {ι : Type u} [Fintype ι] [DecidableEq ι] + (a : Finset ι → ℝ) (b : ι → Finset ι → ℝ) (J : ι → ℝ) + (σ m : ℝ) (hσ : 0 < σ) (hσhalf : σ ≤ 1 / 2) (hm : 1 ≤ m) + (ha : ∀ S, 0 ≤ a S) (hb : ∀ i S, 0 ≤ b i S) + (hJ : ∀ i, 0 ≤ J i) (horbit : ∀ i, J i ≤ (∑ j, J j) / m) + (henergy : (∑ S : Finset ι, a S) ≤ 1) + (hderiv : ∀ i S, i ∈ S → a S = σ ^ 2 * b i (S.erase i)) + (hprojection : ∀ i, + (∑ S : Finset ι, if (S.card : ℝ) ≤ σ * Real.log m / 64 then b i S else 0) ≤ + (σ / 4) ^ (-(2 : ℝ) * (σ * Real.log m / 64)) * (J i) ^ (3 / 2 : ℝ)) : + (∑ S : Finset ι, + if S.Nonempty ∧ (S.card : ℝ) ≤ σ * Real.log m / 64 then a S else 0) ≤ + m ^ (-1 / 4 : ℝ) * ∑ i, J i := by + let k : ℝ := σ * Real.log m / 64 + let R : ℝ := (σ / 4) ^ (-(2 : ℝ) * k) + let L : ℝ := ∑ S : Finset ι, if S.Nonempty ∧ (S.card : ℝ) ≤ k then a S else 0 + have hL1 : L ≤ 1 := by + apply le_trans _ henergy + apply Finset.sum_le_sum + intro S hS + split_ifs + · exact le_refl _ + · exact ha S + have hcoord : ∀ i, + (∑ S : Finset ι, if i ∈ S ∧ (S.card : ℝ) ≤ k then a S else 0) ≤ + (σ ^ 2 * R) * (J i) ^ (3 / 2 : ℝ) := by + intro i + calc + _ ≤ σ ^ 2 * ∑ S : Finset ι, if (S.card : ℝ) ≤ k then b i S else 0 := + incident_mass_le_erase_mass a (b i) (hb i) i k (σ ^ 2) + (sq_nonneg σ) (hderiv i) + _ ≤ σ ^ 2 * (R * (J i) ^ (3 / 2 : ℝ)) := + mul_le_mul_of_nonneg_left (hprojection i) (sq_nonneg σ) + _ = _ := by ring + have hproj : L ≤ σ ^ 2 * R * ∑ i, (J i) ^ (3 / 2 : ℝ) := + lowDegree_mass_le_of_coordinate_bound a ha k (σ ^ 2 * R) + (fun i => (J i) ^ (3 / 2 : ℝ)) hcoord + have hσsq : σ ^ 2 ≤ 1 := by nlinarith + exact low_degree_influence_bound_of_factor J m (∑ i, J i) (σ ^ 2) R L + hm hJ rfl horbit (sq_nonneg σ) hσsq (noise_loss_le_rpow hσ hσhalf hm) hL1 hproj + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/LowDegreeConstants.lean b/lean/OAI/Combinatorics/SharpThreshold/LowDegreeConstants.lean new file mode 100644 index 0000000000000000000000000000000000000000..359abfa96155aad7f7d68d90fa5dcb58478479b1 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/LowDegreeConstants.lean @@ -0,0 +1,110 @@ +import Mathlib + +namespace OAI + +universe u + +noncomputable section + +namespace Problem313 + +/-- Uniform bias-dependent logarithmic bound used in the low-degree estimate. -/ +theorem sigma_mul_log_four_div_le_two {σ : ℝ} (hσ : 0 < σ) + (hσhalf : σ ≤ 1 / 2) : σ * Real.log (4 / σ) ≤ 2 := by + have hσne : σ ≠ 0 := ne_of_gt hσ + have hlog2 : Real.log (2 : ℝ) ≤ 1 := by + have h := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2) + linarith + have hinv : 0 < 1 / (2 * σ) := by positivity + have hloginv := Real.log_le_sub_one_of_pos hinv + have hlogsplit : Real.log (4 / σ) = + 3 * Real.log 2 + Real.log (1 / (2 * σ)) := by + rw [Real.log_div (by norm_num) hσne, + Real.log_div (by norm_num) (by positivity : 2 * σ ≠ 0), + Real.log_mul (by norm_num) hσne] + have hlog4 : Real.log (4 : ℝ) = 2 * Real.log 2 := by + have := Real.log_pow (2 : ℝ) 2 + norm_num at this + exact this + rw [hlog4, Real.log_one] + ring + have hscaled := mul_le_mul_of_nonneg_left hloginv (le_of_lt hσ) + have hcancel : σ * (1 / (2 * σ) - 1) = 1 / 2 - σ := by + field_simp + rw [hcancel] at hscaled + rw [hlogsplit] + nlinarith [mul_le_mul_of_nonneg_left hlog2 (le_of_lt hσ)] + +/-- The noise loss has a uniformly small power of the orbit-size parameter. -/ +theorem noise_loss_le_rpow {σ m : ℝ} (hσ : 0 < σ) + (hσhalf : σ ≤ 1 / 2) (hm : 1 ≤ m) : + (σ / 4) ^ (-(2 : ℝ) * (σ * Real.log m / 64)) ≤ m ^ (1 / 16 : ℝ) := by + have hmpos : 0 < m := lt_of_lt_of_le zero_lt_one hm + have hlogm : 0 ≤ Real.log m := Real.log_nonneg hm + have hσne : σ ≠ 0 := ne_of_gt hσ + have hlogneg : Real.log (σ / 4) = -Real.log (4 / σ) := by + rw [Real.log_div hσne (by norm_num), Real.log_div (by norm_num) hσne] + ring + rw [Real.rpow_def_of_pos (by positivity : 0 < σ / 4), + Real.rpow_def_of_pos hmpos] + apply Real.exp_le_exp.mpr + rw [hlogneg] + have hbound := sigma_mul_log_four_div_le_two hσ hσhalf + have hmul := mul_le_mul_of_nonneg_right hbound hlogm + nlinarith + +/-- Absorb the residual quarter-variance factor and the stronger exponent. -/ +theorem sigma_sq_mul_rpow_le {σ m : ℝ} (hσ : 0 ≤ σ) + (hσhalf : σ ≤ 1 / 2) (hm : 1 ≤ m) : + σ ^ 2 * m ^ (-5 / 16 : ℝ) ≤ m ^ (-1 / 4 : ℝ) := by + have hσsq : σ ^ 2 ≤ 1 := by nlinarith + have hmpos : 0 < m := lt_of_lt_of_le zero_lt_one hm + calc + σ ^ 2 * m ^ (-5 / 16 : ℝ) ≤ 1 * m ^ (-5 / 16 : ℝ) := + mul_le_mul_of_nonneg_right hσsq (Real.rpow_nonneg (le_of_lt hmpos) _) + _ = m ^ (-5 / 16 : ℝ) := one_mul _ + _ ≤ m ^ (-1 / 4 : ℝ) := + Real.rpow_le_rpow_of_exponent_le hm (by norm_num) + +/-- An individual influence contributes a small extra factor when total influence is small. -/ +theorem influence_three_halves_le {a I m : ℝ} (ha : 0 ≤ a) (hm : 1 ≤ m) + (hai : a ≤ I / m) (hI : I ≤ m ^ (1 / 4 : ℝ)) : + a ^ (3 / 2 : ℝ) ≤ m ^ (-3 / 8 : ℝ) * a := by + have hmpos : 0 < m := lt_of_lt_of_le zero_lt_one hm + have hpow : m ^ (-3 / 4 : ℝ) * m = m ^ (1 / 4 : ℝ) := by + calc + m ^ (-3 / 4 : ℝ) * m = m ^ (-3 / 4 : ℝ) * m ^ (1 : ℝ) := by + rw [Real.rpow_one] + _ = m ^ ((-3 / 4 : ℝ) + 1) := (Real.rpow_add hmpos _ _).symm + _ = m ^ (1 / 4 : ℝ) := by norm_num + have hratio : I / m ≤ m ^ (-3 / 4 : ℝ) := by + apply (div_le_iff₀ hmpos).2 + rwa [hpow] + have hhalf : a ^ (1 / 2 : ℝ) ≤ m ^ (-3 / 8 : ℝ) := by + have h := Real.rpow_le_rpow ha (hai.trans hratio) (by norm_num : (0 : ℝ) ≤ 1 / 2) + rw [← Real.rpow_mul (le_of_lt hmpos)] at h + norm_num at h ⊢ + exact h + have hsplit : a ^ (3 / 2 : ℝ) = a * a ^ (1 / 2 : ℝ) := by + have h := Real.rpow_add_of_nonneg ha (by norm_num : (0 : ℝ) ≤ 1) + (by norm_num : (0 : ℝ) ≤ 1 / 2) + norm_num at h + exact h + rw [hsplit, mul_comm (m ^ _) a] + exact mul_le_mul_of_nonneg_left hhalf ha + +/-- Sum the individual three-halves estimate without a cardinality loss. -/ +theorem sum_influence_three_halves_le {ι : Type u} (s : Finset ι) (a : ι → ℝ) + {m : ℝ} (hm : 1 ≤ m) (ha : ∀ i ∈ s, 0 ≤ a i) + (horbit : ∀ i ∈ s, a i ≤ (∑ j ∈ s, a j) / m) + (hsmall : (∑ j ∈ s, a j) ≤ m ^ (1 / 4 : ℝ)) : + (∑ i ∈ s, a i ^ (3 / 2 : ℝ)) ≤ m ^ (-3 / 8 : ℝ) * (∑ i ∈ s, a i) := by + rw [Finset.mul_sum] + exact Finset.sum_le_sum fun i hi => + influence_three_halves_le (ha i hi) hm (horbit i hi) hsmall + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/LowDegreeCounting.lean b/lean/OAI/Combinatorics/SharpThreshold/LowDegreeCounting.lean new file mode 100644 index 0000000000000000000000000000000000000000..f65b246c47fc79e1708c98663e39eda0b7a418d3 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/LowDegreeCounting.lean @@ -0,0 +1,95 @@ +import Mathlib + +namespace OAI + +universe u + +noncomputable section + +namespace Problem313 + +/-- Removing one specified coordinate injects supports containing it into the +set of supports of no larger degree. This is the finite-sum step behind the +low-degree derivative estimate. -/ +theorem sum_squares_le_derivative_sum + {ι : Type u} [Fintype ι] [DecidableEq ι] + (L : Finset (Finset ι)) (c : Finset ι → ℝ) + (d : ι → Finset ι → ℝ) (σ k : ℝ) (i : ι) + (hdegree : ∀ S ∈ L, (S.card : ℝ) ≤ k) + (hcoeff : ∀ A : Finset ι, i ∉ A → c (insert i A) = σ * d i A) : + (∑ S ∈ L.filter (fun S => i ∈ S), c S ^ 2) ≤ + σ ^ 2 * ∑ A ∈ (Finset.univ : Finset (Finset ι)).filter + (fun A => (A.card : ℝ) ≤ k), d i A ^ 2 := by + classical + let T := L.filter (fun S => i ∈ S) + let U := (Finset.univ : Finset (Finset ι)).filter (fun A => (A.card : ℝ) ≤ k) + have hT : ∀ S ∈ T, i ∈ S := by + intro S hS + exact (Finset.mem_filter.mp hS).2 + have hinj : Set.InjOn (fun S : Finset ι => S.erase i) (T : Set (Finset ι)) := by + intro S hS R hR h + have h' := congrArg (insert i) h + simpa [Finset.insert_erase (hT S hS), Finset.insert_erase (hT R hR)] using h' + have hsub : T.image (fun S => S.erase i) ⊆ U := by + intro A hA + obtain ⟨S, hS, rfl⟩ := Finset.mem_image.mp hA + apply Finset.mem_filter.mpr + refine ⟨Finset.mem_univ _, ?_⟩ + have hcard : ((S.erase i).card : ℝ) ≤ (S.card : ℝ) := by + exact_mod_cast Finset.card_le_card (Finset.erase_subset i S) + exact hcard.trans (hdegree S (Finset.mem_filter.mp hS).1) + have heq : (∑ S ∈ T, c S ^ 2) = + σ ^ 2 * ∑ A ∈ T.image (fun S => S.erase i), d i A ^ 2 := by + rw [Finset.sum_image hinj, Finset.mul_sum] + apply Finset.sum_congr rfl + intro S hS + have hc := hcoeff (S.erase i) (Finset.notMem_erase i S) + rw [Finset.insert_erase (hT S hS)] at hc + rw [hc] + ring + change (∑ S ∈ T, c S ^ 2) ≤ σ ^ 2 * ∑ A ∈ U, d i A ^ 2 + rw [heq] + apply mul_le_mul_of_nonneg_left _ (sq_nonneg σ) + exact Finset.sum_le_sum_of_subset_of_nonneg hsub (fun A _ _ => sq_nonneg (d i A)) + +/-- Every nonempty support is counted by at least one coordinate. Combining +this double counting with the insertion identity bounds its Fourier mass by +the sum of the low-degree masses of all coordinate derivatives. -/ +theorem low_degree_derivative_counting + {ι : Type u} [Fintype ι] [DecidableEq ι] + (L : Finset (Finset ι)) (c : Finset ι → ℝ) + (d : ι → Finset ι → ℝ) (σ k : ℝ) + (hne : ∀ S ∈ L, S.Nonempty) + (hdegree : ∀ S ∈ L, (S.card : ℝ) ≤ k) + (hcoeff : ∀ (i : ι) (A : Finset ι), i ∉ A → c (insert i A) = σ * d i A) : + (∑ S ∈ L, c S ^ 2) ≤ + σ ^ 2 * ∑ i : ι, ∑ A ∈ (Finset.univ : Finset (Finset ι)).filter + (fun A => (A.card : ℝ) ≤ k), d i A ^ 2 := by + classical + have hcount : (∑ S ∈ L, c S ^ 2) ≤ + ∑ i : ι, ∑ S ∈ L.filter (fun S => i ∈ S), c S ^ 2 := by + simp_rw [Finset.sum_filter] + rw [Finset.sum_comm] + apply Finset.sum_le_sum + intro S hS + obtain ⟨i, hi⟩ := hne S hS + have h := Finset.single_le_sum + (s := (Finset.univ : Finset ι)) + (f := fun j => if j ∈ S then c S ^ 2 else 0) + (fun j _ => by split_ifs <;> positivity) (Finset.mem_univ i) + simpa [hi] using h + calc + (∑ S ∈ L, c S ^ 2) ≤ + ∑ i : ι, ∑ S ∈ L.filter (fun S => i ∈ S), c S ^ 2 := hcount + _ ≤ ∑ i : ι, σ ^ 2 * ∑ A ∈ (Finset.univ : Finset (Finset ι)).filter + (fun A => (A.card : ℝ) ≤ k), d i A ^ 2 := by + apply Finset.sum_le_sum + intro i _ + exact sum_squares_le_derivative_sum L c d σ k i hdegree (hcoeff i) + _ = _ := by rw [Finset.mul_sum] + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/LowDegreeInfluence.lean b/lean/OAI/Combinatorics/SharpThreshold/LowDegreeInfluence.lean new file mode 100644 index 0000000000000000000000000000000000000000..0054900f49eb764c3c651adfe137e3719e26b6f3 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/LowDegreeInfluence.lean @@ -0,0 +1,109 @@ +import Mathlib + +namespace OAI + +universe u + +noncomputable section + +namespace Problem313 + +/-- Summing pivotal-event three-halves powers using a uniform influence bound. -/ +theorem sum_mul_sqrt_le {ι : Type u} [Fintype ι] (a : ι → ℝ) (B : ℝ) + (ha : ∀ i, 0 ≤ a i) (hB : ∀ i, a i ≤ B) : + (∑ i, a i * Real.sqrt (a i)) ≤ Real.sqrt B * ∑ i, a i := by + calc + (∑ i, a i * Real.sqrt (a i)) ≤ ∑ i, a i * Real.sqrt B := by + exact Finset.sum_le_sum fun i _ => mul_le_mul_of_nonneg_left + (Real.sqrt_le_sqrt (hB i)) (ha i) + _ = Real.sqrt B * ∑ i, a i := by rw [Finset.mul_sum]; congr 1; ext i; ring + +/-- A convenient conversion between real three-halves powers and square roots. -/ +theorem rpow_three_halves_eq_mul_sqrt (x : ℝ) (hx : 0 ≤ x) : + x ^ (3/2 : ℝ) = x * Real.sqrt x := by + rw [Real.sqrt_eq_rpow] + convert Real.rpow_add_of_nonneg hx (show (0:ℝ) ≤ 1 by norm_num) + (show (0:ℝ) ≤ 1/2 by norm_num) using 1 <;> norm_num + +/-- The small-total-influence regime turns the individual influence bound into a power of `m`. -/ +theorem sqrt_influence_ratio_le (m I : ℝ) (hm : 0 < m) + (hI : I ≤ m ^ (1/4 : ℝ)) : + Real.sqrt (I/m) ≤ m ^ (-3/8 : ℝ) := by + apply Real.sqrt_le_iff.mpr + refine ⟨Real.rpow_nonneg hm.le _, ?_⟩ + have hsq : (m ^ (-3/8 : ℝ))^2 = m ^ (-3/4 : ℝ) := by + rw [← Real.rpow_two, ← Real.rpow_mul hm.le] + norm_num + rw [hsq] + calc + I/m ≤ m ^ (1/4 : ℝ) / m := div_le_div_of_nonneg_right hI hm.le + _ = m ^ (-3/4 : ℝ) := by + convert (Real.rpow_sub hm (1/4 : ℝ) 1).symm using 1 <;> norm_num + +/-- The numerical case split at the end of the low-degree Fourier estimate. +The factor `A` can be instantiated with `σ²`. -/ +theorem low_degree_influence_bound {ι : Type u} [Fintype ι] + (a : ι → ℝ) (m I A L : ℝ) + (hm : 1 ≤ m) (ha : ∀ i, 0 ≤ a i) + (hsum : ∑ i, a i = I) (hindividual : ∀ i, a i ≤ I/m) + (hA0 : 0 ≤ A) (hA1 : A ≤ 1) + (hL1 : L ≤ 1) + (hprojection : L ≤ A * m ^ (1/16 : ℝ) * ∑ i, (a i) ^ (3/2 : ℝ)) : + L ≤ m ^ (-1/4 : ℝ) * I := by + have hmpos : 0 < m := lt_of_lt_of_le zero_lt_one hm + have hI0 : 0 ≤ I := by rw [← hsum]; exact Finset.sum_nonneg fun i _ => ha i + have hpow0 : 0 ≤ m ^ (1/16 : ℝ) := Real.rpow_nonneg hmpos.le _ + by_cases hsmall : I ≤ m ^ (1/4 : ℝ) + · have hsum_bound : (∑ i, (a i) ^ (3/2 : ℝ)) ≤ m ^ (-3/8 : ℝ) * I := by + calc + (∑ i, (a i) ^ (3/2 : ℝ)) = ∑ i, a i * Real.sqrt (a i) := by + apply Finset.sum_congr rfl + intro i _ + exact rpow_three_halves_eq_mul_sqrt (a i) (ha i) + _ ≤ Real.sqrt (I/m) * I := by + simpa [hsum] using sum_mul_sqrt_le a (I/m) ha hindividual + _ ≤ m ^ (-3/8 : ℝ) * I := mul_le_mul_of_nonneg_right + (sqrt_influence_ratio_le m I hmpos hsmall) hI0 + have hcoefficient : A * m ^ (1/16 : ℝ) * m ^ (-3/8 : ℝ) ≤ m ^ (-1/4 : ℝ) := by + calc + A * m ^ (1/16 : ℝ) * m ^ (-3/8 : ℝ) ≤ + m ^ (1/16 : ℝ) * m ^ (-3/8 : ℝ) := by + exact mul_le_mul_of_nonneg_right + (by simpa using mul_le_mul_of_nonneg_right hA1 hpow0) + (Real.rpow_nonneg hmpos.le _) + _ = m ^ (-5/16 : ℝ) := by rw [← Real.rpow_add hmpos]; norm_num + _ ≤ m ^ (-1/4 : ℝ) := Real.rpow_le_rpow_of_exponent_le hm (by norm_num) + calc + L ≤ A * m ^ (1/16 : ℝ) * ∑ i, (a i) ^ (3/2 : ℝ) := hprojection + _ ≤ A * m ^ (1/16 : ℝ) * (m ^ (-3/8 : ℝ) * I) := + mul_le_mul_of_nonneg_left hsum_bound (mul_nonneg hA0 hpow0) + _ = (A * m ^ (1/16 : ℝ) * m ^ (-3/8 : ℝ)) * I := by ring + _ ≤ m ^ (-1/4 : ℝ) * I := mul_le_mul_of_nonneg_right hcoefficient hI0 + · have hinverse : m ^ (-1/4 : ℝ) * m ^ (1/4 : ℝ) = 1 := by + rw [← Real.rpow_add hmpos] + norm_num + calc + L ≤ 1 := hL1 + _ = m ^ (-1/4 : ℝ) * m ^ (1/4 : ℝ) := hinverse.symm + _ ≤ m ^ (-1/4 : ℝ) * I := mul_le_mul_of_nonneg_left + (le_of_lt (lt_of_not_ge hsmall)) (Real.rpow_nonneg hmpos.le _) + +/-- Version accepting the hypercontractive factor before its power bound is substituted. -/ +theorem low_degree_influence_bound_of_factor {ι : Type u} [Fintype ι] + (a : ι → ℝ) (m I A R L : ℝ) + (hm : 1 ≤ m) (ha : ∀ i, 0 ≤ a i) + (hsum : ∑ i, a i = I) (hindividual : ∀ i, a i ≤ I/m) + (hA0 : 0 ≤ A) (hA1 : A ≤ 1) + (hR : R ≤ m ^ (1/16 : ℝ)) (hL1 : L ≤ 1) + (hprojection : L ≤ A * R * ∑ i, (a i) ^ (3/2 : ℝ)) : + L ≤ m ^ (-1/4 : ℝ) * I := by + apply low_degree_influence_bound a m I A L hm ha hsum hindividual hA0 hA1 hL1 + exact hprojection.trans (mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left hR hA0) + (Finset.sum_nonneg fun i _ => Real.rpow_nonneg (ha i) _)) + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/LowDegreeL4.lean b/lean/OAI/Combinatorics/SharpThreshold/LowDegreeL4.lean new file mode 100644 index 0000000000000000000000000000000000000000..f9c31e754347652dd9dd1ded4076dec27345bfb2 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/LowDegreeL4.lean @@ -0,0 +1,77 @@ +import Mathlib + +namespace OAI + +universe u v + +noncomputable section + +namespace Problem313 + +open scoped BigOperators + +/-- Removing a diagonal noise multiplier costs at most `rho ^ (-2*k)` +in squared coefficient norm on coefficients supported in degrees at most `k`. -/ +theorem inverse_noise_energy_le {ι : Type u} [Fintype ι] + (degree : ι → ℕ) (c : ι → ℝ) (rho k : ℝ) + (hrho : 0 < rho) (hrho1 : rho ≤ 1) + (hdegree : ∀ i, c i ≠ 0 → (degree i : ℝ) ≤ k) : + (∑ i, (rho ^ (-(degree i : ℝ)) * c i) ^ 2) ≤ + rho ^ (-2 * k) * ∑ i, (c i) ^ 2 := by + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro i hi + by_cases hc : c i = 0 + · simp [hc] + have hexp : -2 * k ≤ -(degree i : ℝ) * 2 := by + linarith [hdegree i hc] + have hrpow := Real.rpow_le_rpow_of_exponent_ge hrho hrho1 hexp + have hsq : (rho ^ (-(degree i : ℝ))) ^ 2 = + rho ^ (-(degree i : ℝ) * 2) := by + rw [Real.rpow_mul hrho.le, Real.rpow_two] + rw [mul_pow, hsq] + exact mul_le_mul_of_nonneg_right hrpow (sq_nonneg (c i)) + +/-- Spectral inversion turns a diagonal-noise `L² → L⁴` estimate into an +`L⁴` estimate for a low-degree expansion. This version is independent of +any particular construction of the orthonormal basis. -/ +theorem lowDegree_fourth_of_noise + {ι : Type u} {X : Type v} [Fintype ι] [Fintype X] + (degree : ι → ℕ) (basis : ι → X → ℝ) (weight : X → ℝ) + (rho k : ℝ) (hrho : 0 < rho) (hrho1 : rho ≤ 1) + (hnoise : ∀ a : ι → ℝ, + (∑ x, weight x * (∑ i, rho ^ (degree i : ℝ) * a i * basis i x) ^ 4) ≤ + (∑ i, (a i) ^ 2) ^ 2) + (c : ι → ℝ) (hdegree : ∀ i, c i ≠ 0 → (degree i : ℝ) ≤ k) : + (∑ x, weight x * (∑ i, c i * basis i x) ^ 4) ≤ + rho ^ (-4 * k) * (∑ i, (c i) ^ 2) ^ 2 := by + let a : ι → ℝ := fun i => rho ^ (-(degree i : ℝ)) * c i + have hinv (i : ι) : rho ^ (degree i : ℝ) * a i = c i := by + dsimp [a] + rw [← mul_assoc, ← Real.rpow_add hrho] + simp + have hnoise' : + (∑ x, weight x * (∑ i, c i * basis i x) ^ 4) ≤ + (∑ i, (a i) ^ 2) ^ 2 := by + simpa only [hinv] using hnoise a + have henergy : (∑ i, (a i) ^ 2) ≤ + rho ^ (-2 * k) * ∑ i, (c i) ^ 2 := + inverse_noise_energy_le degree c rho k hrho hrho1 hdegree + have hnonneg : 0 ≤ ∑ i, (a i) ^ 2 := by positivity + have hsq : (∑ i, (a i) ^ 2) ^ 2 ≤ + (rho ^ (-2 * k) * ∑ i, (c i) ^ 2) ^ 2 := by + exact pow_le_pow_left₀ hnonneg henergy 2 + have hscale : (rho ^ (-2 * k) * ∑ i, (c i) ^ 2) ^ 2 = + rho ^ (-4 * k) * (∑ i, (c i) ^ 2) ^ 2 := by + rw [mul_pow] + congr 1 + rw [← Real.rpow_two, ← Real.rpow_mul hrho.le] + congr 1 + ring + exact hnoise'.trans (hsq.trans_eq hscale) + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/LowDegreeNumerical.lean b/lean/OAI/Combinatorics/SharpThreshold/LowDegreeNumerical.lean new file mode 100644 index 0000000000000000000000000000000000000000..504a9717fc57e3774c80b81719bcf7b306d50e81 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/LowDegreeNumerical.lean @@ -0,0 +1,56 @@ +import OAI.Combinatorics.SharpThreshold.LowDegreeConstants +import OAI.Combinatorics.SharpThreshold.LowDegreeInfluence + +namespace OAI + +universe u + +noncomputable section + +namespace Problem313 + +/-- The numerical part of the biased low-degree estimate, with its original noise loss. -/ +theorem low_degree_bound_of_noise_projection {ι : Type u} [Fintype ι] + (a : ι → ℝ) (m I σ L : ℝ) + (hm : 1 ≤ m) (hσ : 0 < σ) (hσhalf : σ ≤ 1 / 2) + (ha : ∀ i, 0 ≤ a i) (hsum : ∑ i, a i = I) + (hindividual : ∀ i, a i ≤ I / m) (hL1 : L ≤ 1) + (hprojection : L ≤ σ ^ 2 * (σ / 4) ^ + (-(2 : ℝ) * (σ * Real.log m / 64)) * ∑ i, (a i) ^ (3 / 2 : ℝ)) : + L ≤ m ^ (-1 / 4 : ℝ) * I := by + apply low_degree_influence_bound a m I (σ ^ 2) L hm ha hsum hindividual + (sq_nonneg σ) (by nlinarith) hL1 + apply hprojection.trans + apply mul_le_mul_of_nonneg_right + · exact mul_le_mul_of_nonneg_left (noise_loss_le_rpow hσ hσhalf hm) (sq_nonneg σ) + · exact Finset.sum_nonneg fun i _ => Real.rpow_nonneg (ha i) _ + +/-- The Bernoulli standard deviation lies in the range required by the noise estimate. -/ +theorem bernoulli_stddev_bounds {p : ℝ} (hp : 0 < p) (hp1 : p < 1) : + 0 < Real.sqrt (p * (1 - p)) ∧ Real.sqrt (p * (1 - p)) ≤ 1 / 2 := by + constructor + · exact Real.sqrt_pos.2 (mul_pos hp (sub_pos.2 hp1)) + · apply Real.sqrt_le_iff.2 + refine ⟨by norm_num, ?_⟩ + nlinarith [sq_nonneg (p - 1 / 2)] + +/-- Bias-parameter form of the numerical low-degree estimate. -/ +theorem low_degree_bound_of_biased_projection {ι : Type u} [Fintype ι] + (a : ι → ℝ) (m I p L : ℝ) + (hm : 1 ≤ m) (hp : 0 < p) (hp1 : p < 1) + (ha : ∀ i, 0 ≤ a i) (hsum : ∑ i, a i = I) + (hindividual : ∀ i, a i ≤ I / m) (hL1 : L ≤ 1) + (hprojection : L ≤ (p * (1 - p)) * (Real.sqrt (p * (1 - p)) / 4) ^ + (-(2 : ℝ) * (Real.sqrt (p * (1 - p)) * Real.log m / 64)) * + ∑ i, (a i) ^ (3 / 2 : ℝ)) : + L ≤ m ^ (-1 / 4 : ℝ) * I := by + obtain ⟨hσ, hσhalf⟩ := bernoulli_stddev_bounds hp hp1 + apply low_degree_bound_of_noise_projection a m I (Real.sqrt (p * (1 - p))) L + hm hσ hσhalf ha hsum hindividual hL1 + simpa only [Real.sq_sqrt (le_of_lt (mul_pos hp (sub_pos.2 hp1)))] using hprojection + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/LowDegreeSupport.lean b/lean/OAI/Combinatorics/SharpThreshold/LowDegreeSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..5bdfa30e54464ec1e2212192a2dee152a096321c --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/LowDegreeSupport.lean @@ -0,0 +1,6 @@ +import OAI.Combinatorics.SharpThreshold.LowDegreeInfluence +import OAI.Combinatorics.SharpThreshold.LowDegreeConstants +import OAI.Combinatorics.SharpThreshold.LowDegreeNumerical +import OAI.Combinatorics.SharpThreshold.LowDegreeBounds + +/-! Numerical and incidence estimates for low Fourier degrees. -/ diff --git a/lean/OAI/Combinatorics/SharpThreshold/Main.lean b/lean/OAI/Combinatorics/SharpThreshold/Main.lean new file mode 100644 index 0000000000000000000000000000000000000000..521192a7b91503183b1ebb3973e5dd957553bdb6 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/Main.lean @@ -0,0 +1,36 @@ +import OAI.Combinatorics.SharpThreshold.BlockOrbit +import OAI.Combinatorics.SharpThreshold.BlockParameters +import OAI.Combinatorics.SharpThreshold.FiniteParseval +import OAI.Combinatorics.SharpThreshold.FourierAnalysis +import OAI.Combinatorics.SharpThreshold.GraphSupport +import OAI.Combinatorics.SharpThreshold.GraphSymmetry +import OAI.Combinatorics.SharpThreshold.GraphVarianceBound +import OAI.Combinatorics.SharpThreshold.LowDegreeCounting +import OAI.Combinatorics.SharpThreshold.LowDegreeSupport +import OAI.Combinatorics.SharpThreshold.NoiseKernel +import OAI.Combinatorics.SharpThreshold.OrbitInfluence +import OAI.Combinatorics.SharpThreshold.ProductReindex +import OAI.Combinatorics.SharpThreshold.ProductRestriction +import OAI.Combinatorics.SharpThreshold.QuantileAnalysis +import OAI.Combinatorics.SharpThreshold.RestrictionMass +import OAI.Combinatorics.SharpThreshold.SharpThreshold + +namespace OAI + +noncomputable section + +namespace Problem313 + +theorem variance_influence_bound : + ∀ (n : ℕ) (f : GraphConfig n → Bool) (p : ℝ), 2 ≤ n → VertexInvariant f → 0 < p → p < 1 → graphVariance p f ≤ ((2 : ℝ) ^ 17 / (Real.log (n : ℝ)) ^ 2) * totalInfluence p f := by + exact variance_influence_bound_core + +theorem sharp_threshold_width : + ∀ (n : ℕ) (f : GraphConfig n → Bool) (ε : ℝ), 2 ≤ n → VertexInvariant f → IncreasingGraphProperty f → NontrivialGraphProperty f → 0 < ε → ε < (1 / 2 : ℝ) → graphQuantile (1 - ε) f - graphQuantile ε f ≤ ((2 : ℝ) ^ 19 / (Real.log (n : ℝ)) ^ 2) * Real.log (1 / (2 * ε)) := by + exact sharp_threshold_width_of_variance_bound variance_influence_bound + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/MeanEndpoints.lean b/lean/OAI/Combinatorics/SharpThreshold/MeanEndpoints.lean new file mode 100644 index 0000000000000000000000000000000000000000..6e78f1e08bea7d6be32bca2fde5680e61384d165 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/MeanEndpoints.lean @@ -0,0 +1,103 @@ +import OAI.Combinatorics.SharpThreshold.Model + +namespace OAI + +noncomputable section + +namespace Problem313 + +lemma continuous_graphWeight {n : ℕ} (x : GraphConfig n) : + Continuous (fun p : ℝ => graphWeight p x) := by + classical + unfold graphWeight + apply continuous_finsetProd + intro e he + split_ifs <;> fun_prop + +lemma continuous_graphMean {n : ℕ} (f : GraphConfig n → Bool) : + Continuous (fun p : ℝ => graphMean p f) := by + classical + unfold graphMean + apply continuous_finsetSum + intro x hx + exact (continuous_graphWeight x).mul continuous_const + +lemma increasing_nontrivial_false {n : ℕ} {f : GraphConfig n → Bool} + (hmono : IncreasingGraphProperty f) (hnt : NontrivialGraphProperty f) : + f (fun _ => false) = false := by + obtain ⟨x, hx⟩ := hnt.2 + cases h : f (fun _ => false) + · rfl + · have hh := hmono (fun _ => false) x (by intro e he; cases he) h + rw [hx] at hh + contradiction + +lemma increasing_nontrivial_true {n : ℕ} {f : GraphConfig n → Bool} + (hmono : IncreasingGraphProperty f) (hnt : NontrivialGraphProperty f) : + f (fun _ => true) = true := by + obtain ⟨x, hx⟩ := hnt.1 + exact hmono x (fun _ => true) (by intro e he; rfl) hx + +lemma graphWeight_zero {n : ℕ} (x : GraphConfig n) : + graphWeight 0 x = if x = (fun _ => false) then 1 else 0 := by + classical + by_cases hx : x = (fun _ => false) + · subst x + simp [graphWeight] + · rw [ite_eq_right hx] + obtain ⟨e, he⟩ : ∃ e, x e = true := by + by_contra h + apply hx + funext e + cases hxe : x e + · rfl + · exact False.elim (h ⟨e, hxe⟩) + unfold graphWeight + apply Finset.prod_eq_zero (Finset.mem_univ e) + simp [he] + +lemma graphWeight_one {n : ℕ} (x : GraphConfig n) : + graphWeight 1 x = if x = (fun _ => true) then 1 else 0 := by + classical + by_cases hx : x = (fun _ => true) + · subst x + simp [graphWeight] + · rw [ite_eq_right hx] + obtain ⟨e, he⟩ : ∃ e, x e = false := by + by_contra h + apply hx + funext e + cases hxe : x e + · exact False.elim (h ⟨e, hxe⟩) + · rfl + unfold graphWeight + apply Finset.prod_eq_zero (Finset.mem_univ e) + simp [he] + +lemma graphMean_zero_eq {n : ℕ} (f : GraphConfig n → Bool) : + graphMean 0 f = boolReal (f (fun _ => false)) := by + classical + simp [graphMean, graphWeight_zero] + +lemma graphMean_one_eq {n : ℕ} (f : GraphConfig n → Bool) : + graphMean 1 f = boolReal (f (fun _ => true)) := by + classical + simp [graphMean, graphWeight_one] + +lemma graphMean_zero_of_increasing_nontrivial {n : ℕ} {f : GraphConfig n → Bool} + (hmono : IncreasingGraphProperty f) (hnt : NontrivialGraphProperty f) : + graphMean 0 f = 0 := by + rw [graphMean_zero_eq, increasing_nontrivial_false hmono hnt] + rfl + +lemma graphMean_one_of_increasing_nontrivial {n : ℕ} {f : GraphConfig n → Bool} + (hmono : IncreasingGraphProperty f) (hnt : NontrivialGraphProperty f) : + graphMean 1 f = 1 := by + rw [graphMean_one_eq, increasing_nontrivial_true hmono hnt] + rfl + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/Model.lean b/lean/OAI/Combinatorics/SharpThreshold/Model.lean new file mode 100644 index 0000000000000000000000000000000000000000..635b528dce20b4a43e6ed5c83644c90464717208 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/Model.lean @@ -0,0 +1,71 @@ +import Mathlib + +namespace OAI + +noncomputable section + +namespace Problem313 + +abbrev GraphEdge (n : ℕ) := {e : Finset (Fin n) // e.card = 2} + +abbrev GraphConfig (n : ℕ) := GraphEdge n → Bool + +def permEdge {n : ℕ} (π : Equiv.Perm (Fin n)) (e : GraphEdge n) : GraphEdge n := + ⟨e.1.map π.toEmbedding, by simpa using e.2⟩ + +def permuteConfig {n : ℕ} (π : Equiv.Perm (Fin n)) + (x : GraphConfig n) : GraphConfig n := + fun e => x (permEdge π.symm e) + +def VertexInvariant {n : ℕ} (f : GraphConfig n → Bool) : Prop := + ∀ (π : Equiv.Perm (Fin n)) (x : GraphConfig n), + f (permuteConfig π x) = f x + +def ConfigLE {n : ℕ} (x y : GraphConfig n) : Prop := + ∀ e, x e = true → y e = true + +def IncreasingGraphProperty {n : ℕ} (f : GraphConfig n → Bool) : Prop := + ∀ x y, ConfigLE x y → f x = true → f y = true + +def NontrivialGraphProperty {n : ℕ} (f : GraphConfig n → Bool) : Prop := + (∃ x, f x = true) ∧ (∃ x, f x = false) + +def boolReal (b : Bool) : ℝ := + match b with + | false => 0 + | true => 1 + +def graphWeight {n : ℕ} (p : ℝ) (x : GraphConfig n) : ℝ := by + classical + exact Finset.univ.prod (fun e : GraphEdge n => + if x e = true then p else 1 - p) + +def graphMean {n : ℕ} (p : ℝ) (f : GraphConfig n → Bool) : ℝ := by + classical + exact Finset.univ.sum (fun x : GraphConfig n => + graphWeight p x * boolReal (f x)) + +def graphQuantile {n : ℕ} (a : ℝ) (f : GraphConfig n → Bool) : ℝ := + sInf {p : ℝ | p ∈ Set.Icc (0 : ℝ) 1 ∧ graphMean p f ≥ a} + +def graphVariance {n : ℕ} (p : ℝ) (f : GraphConfig n → Bool) : ℝ := by + classical + exact Finset.univ.sum (fun x : GraphConfig n => + graphWeight p x * (boolReal (f x) - graphMean p f) ^ 2) + +def edgeInfluence {n : ℕ} (p : ℝ) (f : GraphConfig n → Bool) + (e : GraphEdge n) : ℝ := by + classical + exact Finset.univ.sum (fun x : GraphConfig n => + if f (Function.update x e true) ≠ f (Function.update x e false) + then graphWeight p x else 0) + +def totalInfluence {n : ℕ} (p : ℝ) (f : GraphConfig n → Bool) : ℝ := by + classical + exact Finset.univ.sum (fun e : GraphEdge n => edgeInfluence p f e) + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/NoiseKernel.lean b/lean/OAI/Combinatorics/SharpThreshold/NoiseKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..41f73b30dbc07a2c030602eca9203a5a31e59ee7 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/NoiseKernel.lean @@ -0,0 +1,48 @@ +import Mathlib + +namespace OAI + +universe u v + +noncomputable section + +open scoped BigOperators + +namespace Problem313.NoiseKernel + +variable {ι : Type u} {α : Type v} [Fintype ι] [Fintype α] + +omit [Fintype α] in +/-- The subset-indexed spectral kernel factors coordinatewise. -/ +theorem spectral_kernel (ρ : ℝ) (φ : ι → α → ℝ) (x y : α) : + (∑ S : Finset ι, ρ ^ S.card * (∏ i ∈ S, φ i x) * (∏ i ∈ S, φ i y)) = + ∏ i, (1 + ρ * φ i x * φ i y) := by + classical + rw [Finset.prod_one_add] + simp only [Finset.powerset_univ] + apply Finset.sum_congr rfl + intro S hS + simp only [Finset.prod_mul_distrib, Finset.prod_const] + +/-- A spectral multiplier by `ρ ^ |S|` is the corresponding weighted +product-kernel operator. No orthogonality hypotheses are needed for this +algebraic identity. -/ +theorem spectral_eq_kernel (ρ : ℝ) (φ : ι → α → ℝ) (w g : α → ℝ) (x : α) : + (∑ S : Finset ι, ρ ^ S.card * + (∑ y, w y * g y * (∏ i ∈ S, φ i y)) * (∏ i ∈ S, φ i x)) = + ∑ y, w y * g y * ∏ i, (1 + ρ * φ i x * φ i y) := by + classical + simp_rw [Finset.mul_sum, Finset.sum_mul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro y hy + rw [← spectral_kernel ρ φ x y, Finset.mul_sum] + apply Finset.sum_congr rfl + intro S hS + ring + +end Problem313.NoiseKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/OrbitInfluence.lean b/lean/OAI/Combinatorics/SharpThreshold/OrbitInfluence.lean new file mode 100644 index 0000000000000000000000000000000000000000..fb92fda9908558263ba61746592cc1b763735dad --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/OrbitInfluence.lean @@ -0,0 +1,52 @@ +import Mathlib + +namespace OAI + +universe u v + +noncomputable section + +namespace Problem313 + +/-- A nonnegative weight which is constant on a sufficiently large finite set +is at most the total weight divided by the size lower bound. -/ +theorem weight_le_sum_div_of_constant_on + {ι : Type u} [Fintype ι] (w : ι → ℝ) (O : Finset ι) (e : ι) (m : ℝ) + (hm : 0 < m) (hw : ∀ j, 0 ≤ w j) + (hcard : m ≤ (O.card : ℝ)) + (hconstant : ∀ j ∈ O, w j = w e) : + w e ≤ (∑ j, w j) / m := by + classical + apply (le_div_iff₀ hm).2 + have hsum : ∑ j ∈ O, w j = (O.card : ℝ) * w e := by + calc + ∑ j ∈ O, w j = ∑ _j ∈ O, w e := by + apply Finset.sum_congr rfl + intro j hj + exact hconstant j hj + _ = (O.card : ℝ) * w e := by simp + have hle : ∑ j ∈ O, w j ≤ ∑ j, w j := + Finset.sum_le_univ_sum_of_nonneg hw + have hmul := mul_le_mul_of_nonneg_right hcard (hw e) + nlinarith + +/-- The same bound when each point of a finite injectively indexed family has +weight equal to the distinguished point. This form avoids constructing an orbit. -/ +theorem weight_le_sum_div_of_injective_family + {ι : Type u} {κ : Type v} [Fintype ι] [Fintype κ] + (w : ι → ℝ) (e : ι) (φ : κ → ι) (hφ : Function.Injective φ) + (m : ℝ) (hm : 0 < m) (hcard : m ≤ (Fintype.card κ : ℝ)) + (hw : ∀ j, 0 ≤ w j) (hconstant : ∀ j, w (φ j) = w e) : + w e ≤ (∑ j, w j) / m := by + classical + apply weight_le_sum_div_of_constant_on w (Finset.univ.image φ) e m hm hw + · simpa [Finset.card_image_of_injective _ hφ] using hcard + · intro j hj + obtain ⟨k, _, rfl⟩ := Finset.mem_image.mp hj + exact hconstant k + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/Permutation.lean b/lean/OAI/Combinatorics/SharpThreshold/Permutation.lean new file mode 100644 index 0000000000000000000000000000000000000000..b6fd310799705e78af8395d6967a58f505a6351e --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/Permutation.lean @@ -0,0 +1,107 @@ +import OAI.Combinatorics.SharpThreshold.Model + +namespace OAI + +noncomputable section +namespace Problem313 + +@[simp] theorem permEdge_refl {n : ℕ} (e : GraphEdge n) : + permEdge (Equiv.refl _) e = e := by + apply Subtype.ext + simp [permEdge] + +@[simp] theorem permEdge_permEdge {n : ℕ} (π ρ : Equiv.Perm (Fin n)) + (e : GraphEdge n) : + permEdge π (permEdge ρ e) = permEdge (ρ.trans π) e := by + apply Subtype.ext + simp [permEdge, Finset.map_map] + +@[simp] theorem permEdge_symm_permEdge {n : ℕ} (π : Equiv.Perm (Fin n)) + (e : GraphEdge n) : permEdge π.symm (permEdge π e) = e := by + simp + +@[simp] theorem permEdge_permEdge_symm {n : ℕ} (π : Equiv.Perm (Fin n)) + (e : GraphEdge n) : permEdge π (permEdge π.symm e) = e := by + simp + +def permEdgeEquiv {n : ℕ} (π : Equiv.Perm (Fin n)) : GraphEdge n ≃ GraphEdge n where + toFun := permEdge π + invFun := permEdge π.symm + left_inv := permEdge_symm_permEdge π + right_inv := permEdge_permEdge_symm π + +@[simp] theorem permuteConfig_refl {n : ℕ} (x : GraphConfig n) : + permuteConfig (Equiv.refl _) x = x := by + funext e + simp [permuteConfig] + +@[simp] theorem permuteConfig_perm {n : ℕ} (π ρ : Equiv.Perm (Fin n)) + (x : GraphConfig n) : + permuteConfig π (permuteConfig ρ x) = permuteConfig (ρ.trans π) x := by + funext e + simp [permuteConfig, permEdge_permEdge] + +@[simp] theorem permuteConfig_symm_permuteConfig {n : ℕ} (π : Equiv.Perm (Fin n)) + (x : GraphConfig n) : permuteConfig π.symm (permuteConfig π x) = x := by + simp + +@[simp] theorem permuteConfig_permuteConfig_symm {n : ℕ} (π : Equiv.Perm (Fin n)) + (x : GraphConfig n) : permuteConfig π (permuteConfig π.symm x) = x := by + simp + +def permuteConfigEquiv {n : ℕ} (π : Equiv.Perm (Fin n)) : + GraphConfig n ≃ GraphConfig n where + toFun := permuteConfig π + invFun := permuteConfig π.symm + left_inv := permuteConfig_symm_permuteConfig π + right_inv := permuteConfig_permuteConfig_symm π + +theorem permEdge_transitive {n : ℕ} (e e' : GraphEdge n) : + ∃ π : Equiv.Perm (Fin n), permEdge π e = e' := by + obtain ⟨π, hπ⟩ := Equiv.Perm.exists_map_finset_eq e.val e'.val (e.property.trans e'.property.symm) + exact ⟨π, Subtype.ext hπ⟩ + +@[simp] theorem graphWeight_permuteConfig {n : ℕ} (p : ℝ) + (π : Equiv.Perm (Fin n)) (x : GraphConfig n) : + graphWeight p (permuteConfig π x) = graphWeight p x := by + classical + exact (permEdgeEquiv π.symm).prod_comp (fun e => if x e = true then p else 1 - p) + +@[simp] theorem permuteConfig_update {n : ℕ} (π : Equiv.Perm (Fin n)) + (x : GraphConfig n) (e : GraphEdge n) (b : Bool) : + permuteConfig π (Function.update x e b) = + Function.update (permuteConfig π x) (permEdge π e) b := by + classical + exact Function.update_comp_equiv x (permEdgeEquiv π.symm) e b + +theorem edgeInfluence_permEdge {n : ℕ} (p : ℝ) (f : GraphConfig n → Bool) + (hf : VertexInvariant f) (π : Equiv.Perm (Fin n)) (e : GraphEdge n) : + edgeInfluence p f (permEdge π e) = edgeInfluence p f e := by + classical + unfold edgeInfluence + rw [← (permuteConfigEquiv π).sum_comp] + change (∑ x : GraphConfig n, + if f (Function.update (permuteConfig π x) (permEdge π e) true) ≠ + f (Function.update (permuteConfig π x) (permEdge π e) false) + then graphWeight p (permuteConfig π x) else 0) = _ + simp_rw [← permuteConfig_update, hf π, graphWeight_permuteConfig] + +theorem edgeInfluence_eq {n : ℕ} (p : ℝ) (f : GraphConfig n → Bool) + (hf : VertexInvariant f) (e e' : GraphEdge n) : + edgeInfluence p f e = edgeInfluence p f e' := by + obtain ⟨π, rfl⟩ := permEdge_transitive e e' + exact (edgeInfluence_permEdge p f hf π e).symm + +theorem totalInfluence_eq_card_mul {n : ℕ} (p : ℝ) (f : GraphConfig n → Bool) + (hf : VertexInvariant f) (e : GraphEdge n) : + totalInfluence p f = Fintype.card (GraphEdge n) * edgeInfluence p f e := by + classical + unfold totalInfluence + simp_rw [edgeInfluence_eq p f hf _ e] + simp + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/Probability.lean b/lean/OAI/Combinatorics/SharpThreshold/Probability.lean new file mode 100644 index 0000000000000000000000000000000000000000..0e4aab4e9b516d2070092b029360b29ad3a6e7be --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/Probability.lean @@ -0,0 +1,140 @@ +import OAI.Combinatorics.SharpThreshold.Model + +namespace OAI + +noncomputable section +namespace Problem313 + +@[simp] theorem boolReal_nonneg (b : Bool) : 0 ≤ boolReal b := by + cases b <;> norm_num [boolReal] + +@[simp] theorem boolReal_le_one (b : Bool) : boolReal b ≤ 1 := by + cases b <;> norm_num [boolReal] + +@[simp] theorem boolReal_sq (b : Bool) : boolReal b ^ 2 = boolReal b := by + cases b <;> norm_num [boolReal] + +theorem graphWeight_sum {n : ℕ} (p : ℝ) : + (∑ x : GraphConfig n, graphWeight p x) = 1 := by + classical + unfold graphWeight + rw [← Fintype.prod_sum (fun (_ : GraphEdge n) (b : Bool) => if b = true then p else 1 - p)] + simp only [Fintype.sum_bool, Bool.false_eq_true, ↓reduceIte] + simp + +theorem graphWeight_nonneg {n : ℕ} {p : ℝ} (hp : 0 ≤ p) (hp1 : p ≤ 1) + (x : GraphConfig n) : 0 ≤ graphWeight p x := by + classical + apply Finset.prod_nonneg + intro e he + split_ifs <;> linarith + +theorem graphWeight_pos {n : ℕ} {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (x : GraphConfig n) : 0 < graphWeight p x := by + classical + apply Finset.prod_pos + intro e he + split_ifs <;> linarith + +theorem graphMean_nonneg {n : ℕ} {p : ℝ} (hp : 0 ≤ p) (hp1 : p ≤ 1) + (f : GraphConfig n → Bool) : 0 ≤ graphMean p f := by + classical + apply Finset.sum_nonneg + intro x hx + exact mul_nonneg (graphWeight_nonneg hp hp1 x) (boolReal_nonneg (f x)) + +theorem graphMean_le_one {n : ℕ} {p : ℝ} (hp : 0 ≤ p) (hp1 : p ≤ 1) + (f : GraphConfig n → Bool) : graphMean p f ≤ 1 := by + classical + calc + graphMean p f ≤ ∑ x : GraphConfig n, graphWeight p x := by + apply Finset.sum_le_sum + intro x hx + exact mul_le_of_le_one_right (graphWeight_nonneg hp hp1 x) (boolReal_le_one (f x)) + _ = 1 := graphWeight_sum p + +theorem graphMean_mem_Icc {n : ℕ} {p : ℝ} (hp : 0 ≤ p) (hp1 : p ≤ 1) + (f : GraphConfig n → Bool) : graphMean p f ∈ Set.Icc (0 : ℝ) 1 := + ⟨graphMean_nonneg hp hp1 f, graphMean_le_one hp hp1 f⟩ + +theorem graphVariance_eq_mean_mul {n : ℕ} (p : ℝ) (f : GraphConfig n → Bool) : + graphVariance p f = graphMean p f * (1 - graphMean p f) := by + classical + let m := graphMean p f + change (∑ x : GraphConfig n, graphWeight p x * (boolReal (f x) - m) ^ 2) = m * (1 - m) + calc + (∑ x : GraphConfig n, graphWeight p x * (boolReal (f x) - m) ^ 2) = + ∑ x : GraphConfig n, + ((1 - 2 * m) * (graphWeight p x * boolReal (f x)) + m ^ 2 * graphWeight p x) := by + apply Finset.sum_congr rfl + intro x hx + simp only [sub_sq, mul_add, mul_sub, boolReal_sq] + ring + _ = (1 - 2 * m) * m + m ^ 2 := by + simp only [Finset.sum_add_distrib, ← Finset.mul_sum, graphWeight_sum, mul_one] + rfl + _ = m * (1 - m) := by ring + +@[simp] theorem boolReal_not (b : Bool) : boolReal (!b) = 1 - boolReal b := by + cases b <;> norm_num [boolReal] + +theorem graphMean_not {n : ℕ} (p : ℝ) (f : GraphConfig n → Bool) : + graphMean p (fun x => !(f x)) = 1 - graphMean p f := by + classical + simp only [graphMean, boolReal_not, mul_sub, mul_one, Finset.sum_sub_distrib, + graphWeight_sum] + +theorem graphMean_pos {n : ℕ} {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + {f : GraphConfig n → Bool} (hf : ∃ x, f x = true) : 0 < graphMean p f := by + classical + obtain ⟨x, hx⟩ := hf + apply Finset.sum_pos' + · intro y hy + exact mul_nonneg (graphWeight_nonneg hp.le hp1.le y) (boolReal_nonneg (f y)) + · refine ⟨x, Finset.mem_univ x, ?_⟩ + simpa [hx, boolReal] using graphWeight_pos hp hp1 x + +theorem graphMean_lt_one {n : ℕ} {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + {f : GraphConfig n → Bool} (hf : ∃ x, f x = false) : graphMean p f < 1 := by + obtain ⟨x, hx⟩ := hf + have ht : ∃ x, (!(f x)) = true := ⟨x, by simp [hx]⟩ + have h := graphMean_pos hp hp1 ht + rw [graphMean_not] at h + linarith + +theorem graphMean_mem_Ioo {n : ℕ} {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + {f : GraphConfig n → Bool} (hf : NontrivialGraphProperty f) : + graphMean p f ∈ Set.Ioo (0 : ℝ) 1 := + ⟨graphMean_pos hp hp1 hf.1, graphMean_lt_one hp hp1 hf.2⟩ + +theorem graphVariance_nonneg {n : ℕ} {p : ℝ} (hp : 0 ≤ p) (hp1 : p ≤ 1) + (f : GraphConfig n → Bool) : 0 ≤ graphVariance p f := by + rw [graphVariance_eq_mean_mul] + exact mul_nonneg (graphMean_nonneg hp hp1 f) (sub_nonneg.mpr (graphMean_le_one hp hp1 f)) + +theorem graphVariance_le_quarter {n : ℕ} (p : ℝ) (f : GraphConfig n → Bool) : + graphVariance p f ≤ 1 / 4 := by + rw [graphVariance_eq_mean_mul] + nlinarith [sq_nonneg (graphMean p f - 1 / 2)] + +theorem edgeInfluence_nonneg {n : ℕ} {p : ℝ} (hp : 0 ≤ p) (hp1 : p ≤ 1) + (f : GraphConfig n → Bool) (e : GraphEdge n) : 0 ≤ edgeInfluence p f e := by + classical + apply Finset.sum_nonneg + intro x hx + split_ifs + · exact graphWeight_nonneg hp hp1 x + · exact le_rfl + +theorem totalInfluence_nonneg {n : ℕ} {p : ℝ} (hp : 0 ≤ p) (hp1 : p ≤ 1) + (f : GraphConfig n → Bool) : 0 ≤ totalInfluence p f := by + classical + apply Finset.sum_nonneg + intro e he + exact edgeInfluence_nonneg hp hp1 f e + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/ProductReindex.lean b/lean/OAI/Combinatorics/SharpThreshold/ProductReindex.lean new file mode 100644 index 0000000000000000000000000000000000000000..0d56e7a1e525dfa6e709b19b5fe1104c10b54584 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/ProductReindex.lean @@ -0,0 +1,65 @@ +import OAI.Combinatorics.SharpThreshold.InfluenceReindex + +namespace OAI + +universe u v + +/-! Reindexing real-valued expectations and Dirichlet energies on finite Boolean products. -/ +noncomputable section +open scoped BigOperators + +namespace Problem313.Reindex + +variable {ι : Type u} {κ : Type v} [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] + +/-- A coordinate equivalence preserves each weighted real-valued expectation. -/ +theorem sum_weight_config (e : ι ≃ κ) (p : ℝ) + (f : (ι → Bool) → ℝ) (g : (κ → Bool) → ℝ) + (hfg : ∀ x, g (config e x) = f x) : + (∑ y, weight p y * g y) = ∑ x, weight p x * f x := by + classical + apply Eq.symm + apply Fintype.sum_equiv (configEquiv e) + intro x + simp only [configEquiv_apply, weight_config, hfg] + +/-- The squared energy at a single coordinate is preserved by reindexing. -/ +theorem coordinate_energy_config + (e : ι ≃ κ) (p : ℝ) (f : (ι → Bool) → ℝ) (g : (κ → Bool) → ℝ) + (hfg : ∀ x, g (config e x) = f x) (i : ι) : + (∑ y, weight p y * + (g (Function.update y (e i) true) - g (Function.update y (e i) false)) ^ 2) = + ∑ x, weight p x * + (f (Function.update x i true) - f (Function.update x i false)) ^ 2 := by + apply sum_weight_config e p + intro x + simp only [← config_update, hfg] + +/-- The full Dirichlet energy is invariant under a finite coordinate equivalence. -/ +theorem energy_config + (e : ι ≃ κ) (p : ℝ) (f : (ι → Bool) → ℝ) (g : (κ → Bool) → ℝ) + (hfg : ∀ x, g (config e x) = f x) : + (∑ j, ∑ y, weight p y * + (g (Function.update y j true) - g (Function.update y j false)) ^ 2) = + ∑ i, ∑ x, weight p x * + (f (Function.update x i true) - f (Function.update x i false)) ^ 2 := by + apply Eq.symm + apply Fintype.sum_equiv e + intro i + exact (coordinate_energy_config e p f g hfg i).symm + +/-- Centered second moments are invariant, for any specified center. -/ +theorem centered_sum_config (e : ι ≃ κ) (p c : ℝ) + (f : (ι → Bool) → ℝ) (g : (κ → Bool) → ℝ) + (hfg : ∀ x, g (config e x) = f x) : + (∑ y, weight p y * (g y - c) ^ 2) = + ∑ x, weight p x * (f x - c) ^ 2 := by + apply sum_weight_config e p + intro x + rw [hfg] + +end Problem313.Reindex + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/ProductRestriction.lean b/lean/OAI/Combinatorics/SharpThreshold/ProductRestriction.lean new file mode 100644 index 0000000000000000000000000000000000000000..c8ccf28222b8ad371d00ef4021552abee18c0a16 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/ProductRestriction.lean @@ -0,0 +1,12 @@ +import OAI.Combinatorics.SharpThreshold.FourierRestriction +import OAI.Combinatorics.SharpThreshold.FourierSupportSplit +import OAI.Combinatorics.SharpThreshold.FourierRestrictionMass +import OAI.Combinatorics.SharpThreshold.FourierReindex +import OAI.Combinatorics.SharpThreshold.RestrictionMassSubtype +import OAI.Combinatorics.SharpThreshold.RestrictionInfluence +import OAI.Combinatorics.SharpThreshold.GraphRestrictionInfluence + +/-! +Finite-product restriction identities: exact Fourier mass averaging, +coordinate transport, and pivotal-influence averaging. +-/ diff --git a/lean/OAI/Combinatorics/SharpThreshold/ProjectionIdentities.lean b/lean/OAI/Combinatorics/SharpThreshold/ProjectionIdentities.lean new file mode 100644 index 0000000000000000000000000000000000000000..14a727f427b1a6396eb2693afd7f9682da77674a --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/ProjectionIdentities.lean @@ -0,0 +1,88 @@ +import Mathlib + +namespace OAI + +universe u v + +noncomputable section + +namespace Problem313.WeightedProjection + +open scoped BigOperators + +variable {ι : Type u} {X : Type v} [Fintype X] + +def coefficient (w : X → ℝ) (basis : ι → X → ℝ) (f : X → ℝ) (i : ι) : ℝ := + ∑ x, w x * f x * basis i x + +def synthesis (basis : ι → X → ℝ) (L : Finset ι) (c : ι → ℝ) (x : X) : ℝ := + ∑ i ∈ L, c i * basis i x + +/-- Pairing a function with a finite spectral expansion pairs its coefficients. -/ +theorem inner_synthesis (w : X → ℝ) (basis : ι → X → ℝ) + (f : X → ℝ) (L : Finset ι) (c : ι → ℝ) : + (∑ x, w x * f x * synthesis basis L c x) = + ∑ i ∈ L, c i * coefficient w basis f i := by + simp only [synthesis, coefficient, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro i hi + apply Finset.sum_congr rfl + intro x hx + ring + +/-- Orthonormality computes the coefficient of a finite spectral expansion. -/ +theorem coefficient_synthesis [DecidableEq ι] + (w : X → ℝ) (basis : ι → X → ℝ) + (horth : ∀ i j, (∑ x, w x * basis i x * basis j x) = if i = j then 1 else 0) + (L : Finset ι) (c : ι → ℝ) (i : ι) : + coefficient w basis (synthesis basis L c) i = if i ∈ L then c i else 0 := by + unfold coefficient synthesis + simp only [Finset.mul_sum, Finset.sum_mul] + rw [Finset.sum_comm] + have hterm (j : ι) : + (∑ x, w x * (c j * basis j x) * basis i x) = + c j * (if j = i then 1 else 0) := by + rw [← horth j i, Finset.mul_sum] + apply Finset.sum_congr rfl + intro x hx + ring + simp only [hterm] + simp + +/-- The squared norm of a finite orthonormal expansion is its coefficient energy. -/ +theorem second_moment_synthesis [DecidableEq ι] + (w : X → ℝ) (basis : ι → X → ℝ) + (horth : ∀ i j, (∑ x, w x * basis i x * basis j x) = if i = j then 1 else 0) + (L : Finset ι) (c : ι → ℝ) : + (∑ x, w x * (synthesis basis L c x) ^ 2) = ∑ i ∈ L, (c i) ^ 2 := by + have hid := inner_synthesis w basis (synthesis basis L c) L c + simp only [coefficient_synthesis w basis horth] at hid + calc + (∑ x, w x * (synthesis basis L c x) ^ 2) = + ∑ x, w x * synthesis basis L c x * synthesis basis L c x := by + apply Finset.sum_congr rfl + intro x hx + ring + _ = ∑ i ∈ L, c i * (if i ∈ L then c i else 0) := hid + _ = ∑ i ∈ L, (c i) ^ 2 := by + apply Finset.sum_congr rfl + intro i hi + simp [hi, pow_two] + +/-- A spectral projection has the same inner product with the original function +as its squared norm. -/ +theorem inner_projection (w : X → ℝ) (basis : ι → X → ℝ) + (f : X → ℝ) (L : Finset ι) : + (∑ x, w x * f x * synthesis basis L (coefficient w basis f) x) = + ∑ i ∈ L, (coefficient w basis f i) ^ 2 := by + rw [inner_synthesis] + apply Finset.sum_congr rfl + intro i hi + ring + +end Problem313.WeightedProjection + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/ProjectionNorm.lean b/lean/OAI/Combinatorics/SharpThreshold/ProjectionNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..4c1b3b79315d9c18d89eb00f5cb7547e7420fb2a --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/ProjectionNorm.lean @@ -0,0 +1,155 @@ +import Mathlib + +namespace OAI + +universe u + +noncomputable section +open scoped BigOperators +namespace Problem313 + +/-- Weighted finite Hölder inequality with conjugate exponents `4/3` and `4`. +Weights need not be normalized. -/ +theorem weighted_holder_four_thirds {ι : Type u} [Fintype ι] + (w v u : ι → ℝ) (hw : ∀ i, 0 ≤ w i) : + |∑ i, w i * v i * u i| ≤ + (∑ i, w i * |v i| ^ (4 / 3 : ℝ)) ^ (3 / 4 : ℝ) * + (∑ i, w i * u i ^ 4) ^ (1 / 4 : ℝ) := by + classical + have hpq : Real.HolderConjugate (4 / 3 : ℝ) 4 := by + rw [Real.holderConjugate_iff] + norm_num + have h := Real.inner_le_Lp_mul_Lq_of_nonneg Finset.univ + (f := fun i => w i ^ (3 / 4 : ℝ) * |v i|) + (g := fun i => w i ^ (1 / 4 : ℝ) * |u i|) hpq + (fun i _ => mul_nonneg (Real.rpow_nonneg (hw i) _) (abs_nonneg _)) + (fun i _ => mul_nonneg (Real.rpow_nonneg (hw i) _) (abs_nonneg _)) + have hleft : (∑ i, (w i ^ (3 / 4 : ℝ) * |v i|) * + (w i ^ (1 / 4 : ℝ) * |u i|)) = ∑ i, w i * |v i| * |u i| := by + apply Finset.sum_congr rfl + intro i _ + calc + _ = (w i ^ (3 / 4 : ℝ) * w i ^ (1 / 4 : ℝ)) * |v i| * |u i| := by ring + _ = w i * |v i| * |u i| := by + rw [← Real.rpow_add' (hw i) (by norm_num : (3 / 4 : ℝ) + 1 / 4 ≠ 0)] + norm_num + have hfirst : (∑ i, (w i ^ (3 / 4 : ℝ) * |v i|) ^ (4 / 3 : ℝ)) = + ∑ i, w i * |v i| ^ (4 / 3 : ℝ) := by + apply Finset.sum_congr rfl + intro i _ + rw [Real.mul_rpow (Real.rpow_nonneg (hw i) _) (abs_nonneg _), + ← Real.rpow_mul (hw i)] + norm_num + have hsecond : (∑ i, (w i ^ (1 / 4 : ℝ) * |u i|) ^ (4 : ℝ)) = + ∑ i, w i * u i ^ 4 := by + apply Finset.sum_congr rfl + intro i _ + rw [Real.mul_rpow (Real.rpow_nonneg (hw i) _) (abs_nonneg _), + ← Real.rpow_mul (hw i)] + have habs : |u i| ^ (4 : ℕ) = u i ^ 4 := by + rcases le_total 0 (u i) with hi | hi + · rw [abs_of_nonneg hi] + · rw [abs_of_nonpos hi] + ring + norm_num [Real.rpow_natCast, habs] + rw [hleft, hfirst, hsecond] at h + norm_num at h + refine (Finset.abs_sum_le_sum_abs (fun i => w i * v i * u i) Finset.univ).trans ?_ + simpa only [abs_mul, abs_of_nonneg (hw _)] using h + +/-- The scalar cancellation behind the `L⁴` duality argument. -/ +theorem projection_moment_bound {M V H A : ℝ} + (hM : 0 ≤ M) (hV : 0 ≤ V) (hH : 0 ≤ H) (hA : 0 ≤ A) + (hdual : M ≤ V ^ (3 / 4 : ℝ) * H ^ (1 / 4 : ℝ)) + (hfour : H ≤ A ^ 4 * M ^ 2) : + M ≤ A ^ 2 * V ^ (3 / 2 : ℝ) := by + have hroot : H ^ (1 / 4 : ℝ) ≤ A * M ^ (1 / 2 : ℝ) := by + calc + _ ≤ (A ^ 4 * M ^ 2) ^ (1 / 4 : ℝ) := + Real.rpow_le_rpow hH hfour (by norm_num) + _ = A * M ^ (1 / 2 : ℝ) := by + rw [Real.mul_rpow (pow_nonneg hA _) (sq_nonneg M), + ← Real.rpow_natCast_mul hA, ← Real.rpow_natCast_mul hM] + norm_num + have hv : 0 ≤ V ^ (3 / 4 : ℝ) := Real.rpow_nonneg hV _ + have hs : 0 ≤ M ^ (1 / 2 : ℝ) := Real.rpow_nonneg hM _ + have hs2 : (M ^ (1 / 2 : ℝ)) ^ 2 = M := by + rw [← Real.rpow_mul_natCast hM] + norm_num + have hbound : M ≤ (A * V ^ (3 / 4 : ℝ)) * M ^ (1 / 2 : ℝ) := by + calc + _ ≤ V ^ (3 / 4 : ℝ) * H ^ (1 / 4 : ℝ) := hdual + _ ≤ V ^ (3 / 4 : ℝ) * (A * M ^ (1 / 2 : ℝ)) := mul_le_mul_of_nonneg_left hroot hv + _ = _ := by ring + have hsbound : M ^ (1 / 2 : ℝ) ≤ A * V ^ (3 / 4 : ℝ) := by + nlinarith [mul_nonneg hA hv] + have hsq := pow_le_pow_left₀ hs hsbound 2 + have hv2 : (V ^ (3 / 4 : ℝ)) ^ 2 = V ^ (3 / 2 : ℝ) := by + rw [← Real.rpow_mul_natCast hV] + norm_num + simpa only [hs2, mul_pow, hv2] using hsq + +/-- A low-degree fourth-moment bound implies the dual projection estimate. +The hypothesis `hproj` is the usual orthogonal-projection identity +`⟨v,u⟩ = ⟨u,u⟩`; this formulation avoids choosing a normalized dual vector. -/ +theorem weighted_projection_bound {ι : Type u} [Fintype ι] + (w v u : ι → ℝ) (hw : ∀ i, 0 ≤ w i) (A : ℝ) (hA : 0 ≤ A) + (hproj : (∑ i, w i * v i * u i) = ∑ i, w i * u i ^ 2) + (hfour : (∑ i, w i * u i ^ 4) ≤ A ^ 4 * (∑ i, w i * u i ^ 2) ^ 2) : + (∑ i, w i * u i ^ 2) ≤ + A ^ 2 * (∑ i, w i * |v i| ^ (4 / 3 : ℝ)) ^ (3 / 2 : ℝ) := by + have hM : 0 ≤ ∑ i, w i * u i ^ 2 := + Finset.sum_nonneg fun i _ => mul_nonneg (hw i) (sq_nonneg _) + have hV : 0 ≤ ∑ i, w i * |v i| ^ (4 / 3 : ℝ) := + Finset.sum_nonneg fun i _ => mul_nonneg (hw i) (Real.rpow_nonneg (abs_nonneg _) _) + have hH : 0 ≤ ∑ i, w i * u i ^ 4 := + Finset.sum_nonneg fun i _ => mul_nonneg (hw i) (by positivity) + apply projection_moment_bound hM hV hH hA _ hfour + have h := weighted_holder_four_thirds w v u hw + simpa only [hproj, abs_of_nonneg hM] using h + +/-- Dual projection estimate for functions taking their values in `{-1,0,1}`, +as Boolean coordinate differences do. -/ +theorem weighted_projection_pivotal_bound {ι : Type u} [Fintype ι] + (w v u : ι → ℝ) (hw : ∀ i, 0 ≤ w i) + (hv : ∀ i, v i = -1 ∨ v i = 0 ∨ v i = 1) + (A : ℝ) (hA : 0 ≤ A) + (hproj : (∑ i, w i * v i * u i) = ∑ i, w i * u i ^ 2) + (hfour : (∑ i, w i * u i ^ 4) ≤ A ^ 4 * (∑ i, w i * u i ^ 2) ^ 2) : + (∑ i, w i * u i ^ 2) ≤ + A ^ 2 * (∑ i, if v i ≠ 0 then w i else 0) ^ (3 / 2 : ℝ) := by + classical + have hnorm : (∑ i, w i * |v i| ^ (4 / 3 : ℝ)) = + ∑ i, if v i ≠ 0 then w i else 0 := by + apply Finset.sum_congr rfl + intro i _ + rcases hv i with hi | hi | hi <;> simp [hi] + simpa only [hnorm] using weighted_projection_bound w v u hw A hA hproj hfour + +/-- The exponent form used for low-degree projections of Boolean derivatives. -/ +theorem weighted_projection_noise_bound {ι : Type u} [Fintype ι] + (w v u : ι → ℝ) (hw : ∀ i, 0 ≤ w i) + (hv : ∀ i, v i = -1 ∨ v i = 0 ∨ v i = 1) + (ρ d : ℝ) (hρ : 0 ≤ ρ) + (hproj : (∑ i, w i * v i * u i) = ∑ i, w i * u i ^ 2) + (hfour : (∑ i, w i * u i ^ 4) ≤ + ρ ^ (-4 * d) * (∑ i, w i * u i ^ 2) ^ 2) : + (∑ i, w i * u i ^ 2) ≤ + ρ ^ (-2 * d) * (∑ i, if v i ≠ 0 then w i else 0) ^ (3 / 2 : ℝ) := by + have hfourpow : (ρ ^ (-d)) ^ (4 : ℕ) = ρ ^ (-4 * d) := by + rw [← Real.rpow_mul_natCast hρ] + congr 1 + ring + have htwopow : (ρ ^ (-d)) ^ (2 : ℕ) = ρ ^ (-2 * d) := by + rw [← Real.rpow_mul_natCast hρ] + congr 1 + ring + have h := weighted_projection_pivotal_bound w v u hw hv (ρ ^ (-d)) + (Real.rpow_nonneg hρ _) hproj (by simpa only [hfourpow] using hfour) + simpa only [htwopow] using h + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/Quantile.lean b/lean/OAI/Combinatorics/SharpThreshold/Quantile.lean new file mode 100644 index 0000000000000000000000000000000000000000..cd84dc34d545cfa0f18d03f203982618fa236a9d --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/Quantile.lean @@ -0,0 +1,82 @@ +import Mathlib + +namespace OAI + +noncomputable section +namespace Problem313 + +def unitQuantile (μ : ℝ → ℝ) (a : ℝ) : ℝ := + sInf {p : ℝ | p ∈ Set.Icc (0 : ℝ) 1 ∧ a ≤ μ p} + +theorem unitQuantile_set_bddBelow (μ : ℝ → ℝ) (a : ℝ) : + BddBelow {p : ℝ | p ∈ Set.Icc (0 : ℝ) 1 ∧ a ≤ μ p} := + ⟨0, fun _ hp => hp.1.1⟩ + +theorem unitQuantile_set_nonempty {μ : ℝ → ℝ} {a : ℝ} + (h1 : μ 1 = 1) (ha : a ≤ 1) : + {p : ℝ | p ∈ Set.Icc (0 : ℝ) 1 ∧ a ≤ μ p}.Nonempty := by + refine ⟨1, ⟨by norm_num, le_rfl⟩, ?_⟩ + simpa only [h1] using ha + +theorem unitQuantile_mem {μ : ℝ → ℝ} {a : ℝ} + (hμ : Continuous μ) (h1 : μ 1 = 1) (ha : a ≤ 1) : + unitQuantile μ a ∈ Set.Icc (0 : ℝ) 1 ∧ a ≤ μ (unitQuantile μ a) := by + have hc : IsClosed {p : ℝ | p ∈ Set.Icc (0 : ℝ) 1 ∧ a ≤ μ p} := + isClosed_Icc.inter (isClosed_le continuous_const hμ) + exact hc.csInf_mem (unitQuantile_set_nonempty h1 ha) (unitQuantile_set_bddBelow μ a) + +theorem unitQuantile_eq_level {μ : ℝ → ℝ} {a : ℝ} + (hμ : Continuous μ) (h0 : μ 0 = 0) (h1 : μ 1 = 1) + (ha0 : 0 ≤ a) (ha1 : a ≤ 1) : + μ (unitQuantile μ a) = a := by + have hq := unitQuantile_mem hμ h1 ha1 + have ha : a ∈ Set.Icc (μ 0) (μ (unitQuantile μ a)) := by + exact ⟨by simpa only [h0] using ha0, hq.2⟩ + obtain ⟨x, hx, heq⟩ := intermediate_value_Icc hq.1.1 hμ.continuousOn ha + have hqx : unitQuantile μ a ≤ x := by + apply csInf_le (unitQuantile_set_bddBelow μ a) + exact ⟨⟨hx.1, hx.2.trans hq.1.2⟩, heq.ge⟩ + have hxq : x = unitQuantile μ a := le_antisymm hx.2 hqx + simpa only [hxq] using heq + +theorem unitQuantile_mem_Ioo {μ : ℝ → ℝ} {a : ℝ} + (hμ : Continuous μ) (h0 : μ 0 = 0) (h1 : μ 1 = 1) + (ha0 : 0 < a) (ha1 : a < 1) : + unitQuantile μ a ∈ Set.Ioo (0 : ℝ) 1 := by + have hq := (unitQuantile_mem hμ h1 ha1.le).1 + have heq := unitQuantile_eq_level hμ h0 h1 ha0.le ha1.le + constructor + · refine lt_of_le_of_ne hq.1 ?_ + intro he + rw [← he, h0] at heq + exact ha0.ne heq + · refine lt_of_le_of_ne hq.2 ?_ + intro he + rw [he, h1] at heq + exact ha1.ne heq.symm + +theorem unitQuantile_mono {μ : ℝ → ℝ} {a b : ℝ} + (h1 : μ 1 = 1) (hab : a ≤ b) (hb : b ≤ 1) : + unitQuantile μ a ≤ unitQuantile μ b := by + apply csInf_le_csInf (unitQuantile_set_bddBelow μ a) + (unitQuantile_set_nonempty h1 hb) + intro p hp + exact ⟨hp.1, hab.trans hp.2⟩ + +theorem unitQuantile_strictMonoOn {μ : ℝ → ℝ} + (hμ : Continuous μ) (h0 : μ 0 = 0) (h1 : μ 1 = 1) : + StrictMonoOn (unitQuantile μ) (Set.Icc (0 : ℝ) 1) := by + intro a ha b hb hab + have hle := unitQuantile_mono h1 hab.le hb.2 + refine lt_of_le_of_ne hle ?_ + intro heq + have haeq := unitQuantile_eq_level hμ h0 h1 ha.1 ha.2 + have hbeq := unitQuantile_eq_level hμ h0 h1 hb.1 hb.2 + rw [heq, hbeq] at haeq + exact hab.ne haeq.symm + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/QuantileAnalysis.lean b/lean/OAI/Combinatorics/SharpThreshold/QuantileAnalysis.lean new file mode 100644 index 0000000000000000000000000000000000000000..a24ffd91cd3973759165440dbaa4c84abf2767e9 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/QuantileAnalysis.lean @@ -0,0 +1,79 @@ +import Mathlib + +namespace OAI + +noncomputable section + +namespace Problem313 + +/-- A continuous strictly increasing distribution on the unit interval attains +its infimum-defined quantiles at unique interior points. -/ +theorem quantile_attainment_of_strictMonoOn + {μ : ℝ → ℝ} (hcont : ContinuousOn μ (Set.Icc 0 1)) + (hmono : StrictMonoOn μ (Set.Icc 0 1)) + (hzero : μ 0 = 0) (hone : μ 1 = 1) + {a : ℝ} (ha0 : 0 < a) (ha1 : a < 1) : + let q := sInf {p : ℝ | p ∈ Set.Icc (0 : ℝ) 1 ∧ a ≤ μ p} + q ∈ Set.Ioo (0 : ℝ) 1 ∧ μ q = a := by + have ha : a ∈ Set.Icc (μ 0) (μ 1) := by + rw [hzero, hone] + exact ⟨ha0.le, ha1.le⟩ + obtain ⟨r, hr, hra⟩ := intermediate_value_Icc (by norm_num : (0 : ℝ) ≤ 1) hcont ha + have hr0 : 0 < r := by + by_contra h + have heq : r = 0 := le_antisymm (le_of_not_gt h) hr.1 + rw [heq, hzero] at hra + linarith + have hr1 : r < 1 := by + by_contra h + have heq : r = 1 := le_antisymm hr.2 (le_of_not_gt h) + rw [heq, hone] at hra + linarith + have hset : {p : ℝ | p ∈ Set.Icc (0 : ℝ) 1 ∧ a ≤ μ p} = Set.Icc r 1 := by + ext p + constructor + · rintro ⟨hp, hap⟩ + refine ⟨?_, hp.2⟩ + by_contra h + have hlt := hmono hp hr (lt_of_not_ge h) + rw [hra] at hlt + exact (not_lt_of_ge hap) hlt + · intro hp + have hpunit : p ∈ Set.Icc (0 : ℝ) 1 := ⟨hr.1.trans hp.1, hp.2⟩ + refine ⟨hpunit, ?_⟩ + rw [← hra] + exact hmono.monotoneOn hr hpunit hp.1 + dsimp only + rw [hset, csInf_Icc hr.2] + exact ⟨⟨hr0, hr1⟩, hra⟩ + +/-- Positive derivatives in the interior imply the strict monotonicity required +by the quantile attainment theorem; endpoints only require continuity. -/ +theorem strictMonoOn_unit_of_hasDerivAt_pos + {μ D : ℝ → ℝ} (hcont : ContinuousOn μ (Set.Icc 0 1)) + (hderiv : ∀ p ∈ Set.Ioo (0 : ℝ) 1, HasDerivAt μ (D p) p) + (hpos : ∀ p ∈ Set.Ioo (0 : ℝ) 1, 0 < D p) : + StrictMonoOn μ (Set.Icc (0 : ℝ) 1) := by + apply strictMonoOn_of_deriv_pos (convex_Icc 0 1) hcont + intro p hp + have hp' : p ∈ Set.Ioo (0 : ℝ) 1 := by simpa only [interior_Icc] using hp + rw [(hderiv p hp').deriv] + exact hpos p hp' + +/-- The quantile width estimate in derivative form. -/ +theorem quantile_attainment_of_hasDerivAt_pos + {μ D : ℝ → ℝ} (hcont : ContinuousOn μ (Set.Icc 0 1)) + (hderiv : ∀ p ∈ Set.Ioo (0 : ℝ) 1, HasDerivAt μ (D p) p) + (hpos : ∀ p ∈ Set.Ioo (0 : ℝ) 1, 0 < D p) + (hzero : μ 0 = 0) (hone : μ 1 = 1) + {a : ℝ} (ha0 : 0 < a) (ha1 : a < 1) : + let q := sInf {p : ℝ | p ∈ Set.Icc (0 : ℝ) 1 ∧ a ≤ μ p} + q ∈ Set.Ioo (0 : ℝ) 1 ∧ μ q = a := + quantile_attainment_of_strictMonoOn hcont + (strictMonoOn_unit_of_hasDerivAt_pos hcont hderiv hpos) hzero hone ha0 ha1 + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/RestrictionInfluence.lean b/lean/OAI/Combinatorics/SharpThreshold/RestrictionInfluence.lean new file mode 100644 index 0000000000000000000000000000000000000000..a0f1fab38ff29be14d584f65b7c132b2c8b0647b --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/RestrictionInfluence.lean @@ -0,0 +1,119 @@ +import Mathlib + +namespace OAI + +universe u + +/-! Finite-product averaging for pivotal influences under restrictions. -/ +noncomputable section +open scoped BigOperators + +namespace Problem313.RestrictionInfluence + +variable {ι : Type u} [Fintype ι] [DecidableEq ι] + +/-- Bernoulli weight on an arbitrary finite set of coordinates. -/ +def weight (p : ℝ) (x : ι → Bool) : ℝ := + ∏ i, if x i = true then p else 1 - p + +/-- The pivotal influence, with the redundant pivotal coordinate included in the sum. -/ +def influence (p : ℝ) (f : (ι → Bool) → Bool) (i : ι) : ℝ := by + classical + exact ∑ x, if f (Function.update x i true) ≠ f (Function.update x i false) + then weight p x else 0 + +variable (P : ι → Prop) [DecidablePred P] + +/-- Glue a free and an exterior configuration into a full configuration. -/ +def join (x : {i // P i} → Bool) (y : {i // ¬ P i} → Bool) : ι → Bool := + fun i => if h : P i then x ⟨i, h⟩ else y ⟨i, h⟩ + +omit [Fintype ι] [DecidableEq ι] in +@[simp] theorem join_pos (x : {i // P i} → Bool) (y : {i // ¬ P i} → Bool) + (i : {i // P i}) : join P x y i = x i := by + simp [join, i.property] + +omit [Fintype ι] [DecidableEq ι] in +@[simp] theorem join_neg (x : {i // P i} → Bool) (y : {i // ¬ P i} → Bool) + (i : {i // ¬ P i}) : join P x y i = y i := by + simp [join, i.property] + +omit [DecidableEq ι] in +/-- Product weights factor across any coordinate partition. -/ +theorem weight_join (p : ℝ) (x : {i // P i} → Bool) + (y : {i // ¬ P i} → Bool) : + weight p (join P x y) = weight p x * weight p y := by + unfold weight + rw [← Fintype.prod_subtype_mul_prod_subtype P] + simp only [join_pos, join_neg] + +/-- Fubini for a coordinate restriction, with the exterior sum outermost. -/ +theorem sum_weight_join (p : ℝ) (g : (ι → Bool) → ℝ) : + (∑ z, weight p z * g z) = + ∑ y : {i // ¬ P i} → Bool, weight p y * + ∑ x : {i // P i} → Bool, weight p x * g (join P x y) := by + classical + let e := Equiv.piEquivPiSubtypeProd P (fun _ => Bool) + rw [← e.symm.sum_comp (fun z => weight p z * g z)] + change (∑ z : ({i // P i} → Bool) × ({i // ¬ P i} → Bool), + weight p (join P z.1 z.2) * g (join P z.1 z.2)) = _ + rw [Fintype.sum_prod_type, Finset.sum_comm] + apply Finset.sum_congr rfl + intro y hy + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro x hx + rw [weight_join] + ring + +omit [Fintype ι] in +/-- Updating a free coordinate commutes with gluing an exterior configuration. -/ +theorem join_update (x : {i // P i} → Bool) (y : {i // ¬ P i} → Bool) + (i : {i // P i}) (b : Bool) : + join P (Function.update x i b) y = Function.update (join P x y) i.val b := by + classical + funext j + by_cases hji : j = i.val + · subst j + simp [join, i.property] + · by_cases hj : P j + · have hsub : (⟨j, hj⟩ : {i // P i}) ≠ i := by + intro h + exact hji (congrArg Subtype.val h) + simp [join, hj, hji, hsub] + · simp [join, hj, hji] + +/-- Averaging one pivotal influence over the exterior recovers the full influence. -/ +theorem average_influence (p : ℝ) (f : (ι → Bool) → Bool) (i : {i // P i}) : + (∑ y : {i // ¬ P i} → Bool, + weight p y * influence p (fun x => f (join P x y)) i) = + influence p f i.val := by + classical + unfold influence + have h := sum_weight_join P p (fun z => + if f (Function.update z i.val true) ≠ f (Function.update z i.val false) + then (1 : ℝ) else 0) + simp only [mul_ite, mul_one, mul_zero] at h + rw [h] + apply Finset.sum_congr rfl + intro y hy + congr 1 + apply Finset.sum_congr rfl + intro x hx + simp only [join_update] + +/-- Averaging total influence on the free coordinates gives the sum of their original influences. -/ +theorem average_totalInfluence (p : ℝ) (f : (ι → Bool) → Bool) : + (∑ y : {i // ¬ P i} → Bool, weight p y * + ∑ i : {i // P i}, influence p (fun x => f (join P x y)) i) = + ∑ i : {i // P i}, influence p f i.val := by + classical + simp_rw [Finset.mul_sum] + rw [Finset.sum_comm] + exact Finset.sum_congr rfl (fun i _ => average_influence P p f i) + +end Problem313.RestrictionInfluence + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/RestrictionMass.lean b/lean/OAI/Combinatorics/SharpThreshold/RestrictionMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..5cc1ecd9345146fac1d9723fe76f44a47406695c --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/RestrictionMass.lean @@ -0,0 +1,72 @@ +import Mathlib + +namespace OAI + +universe u v w + +noncomputable section + +namespace Problem313.RestrictionMass + +open scoped BigOperators + +/-- Parseval for a finite orthonormal family, with an explicit real weight. -/ +theorem weighted_sum_sq_expansion + {B : Type u} {Y : Type v} [Fintype B] [DecidableEq B] [Fintype Y] + (w : Y → ℝ) (χ : B → Y → ℝ) + (horth : ∀ b d, (∑ y, w y * χ b y * χ d y) = if b = d then 1 else 0) + (c : B → ℝ) : + (∑ y, w y * (∑ b, c b * χ b y) ^ 2) = ∑ b, c b ^ 2 := by + classical + calc + (∑ y, w y * (∑ b, c b * χ b y) ^ 2) = + ∑ y, ∑ b, ∑ d, c b * c d * (w y * χ b y * χ d y) := by + apply Finset.sum_congr rfl + intro y hy + simp only [pow_two, Finset.mul_sum, Finset.sum_mul] + apply Finset.sum_congr rfl + intro b hb + apply Finset.sum_congr rfl + intro d hd + ring + _ = ∑ b, ∑ d, c b * c d * (∑ y, w y * χ b y * χ d y) := by + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro b hb + rw [Finset.sum_comm] + simp only [Finset.mul_sum] + _ = ∑ b, c b ^ 2 := by + simp [horth, pow_two] + +/-- Averaging the squared restricted coefficients eliminates exterior Fourier +cross terms. No sign or normalization assumption on `w` is needed here. -/ +theorem average_restriction_mass + {A : Type w} {B : Type u} {Y : Type v} [Fintype B] [DecidableEq B] [Fintype Y] + (w : Y → ℝ) (χ : B → Y → ℝ) + (horth : ∀ b d, (∑ y, w y * χ b y * χ d y) = if b = d then 1 else 0) + (c : A → B → ℝ) (L : Finset A) : + (∑ y, w y * ∑ a ∈ L, (∑ b, c a b * χ b y) ^ 2) = + ∑ a ∈ L, ∑ b, c a b ^ 2 := by + classical + simp only [Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro a ha + exact weighted_sum_sq_expansion w χ horth (c a) + +/-- The same identity with restricted coefficients supplied as a separate function. -/ +theorem average_restriction_mass_of_expansion + {A : Type w} {B : Type u} {Y : Type v} [Fintype B] [DecidableEq B] [Fintype Y] + (w : Y → ℝ) (χ : B → Y → ℝ) + (horth : ∀ b d, (∑ y, w y * χ b y * χ d y) = if b = d then 1 else 0) + (c : A → B → ℝ) (r : A → Y → ℝ) + (hr : ∀ a y, r a y = ∑ b, c a b * χ b y) (L : Finset A) : + (∑ y, w y * ∑ a ∈ L, r a y ^ 2) = ∑ a ∈ L, ∑ b, c a b ^ 2 := by + simp_rw [hr] + exact average_restriction_mass w χ horth c L + +end Problem313.RestrictionMass + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/RestrictionMassSubtype.lean b/lean/OAI/Combinatorics/SharpThreshold/RestrictionMassSubtype.lean new file mode 100644 index 0000000000000000000000000000000000000000..f2dc8ca4c19fe3f404aa40b5866b922e3fd065fe --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/RestrictionMassSubtype.lean @@ -0,0 +1,162 @@ +import OAI.Combinatorics.SharpThreshold.FourierRestriction +import OAI.Combinatorics.SharpThreshold.FourierReindex +import OAI.Combinatorics.SharpThreshold.BlockSymmetry + +namespace OAI + +universe u + +noncomputable section + +open scoped BigOperators + +namespace Problem313 + +variable {ι : Type u} [Fintype ι] (P : ι → Prop) [DecidablePred P] + +omit [Fintype ι] in +/-- The coordinate equivalence from a predicate and its complement is ordinary pasting. -/ +theorem config_sumCompl_eq_pasteCube + (x : {i // P i} → Bool) (y : {i // ¬P i} → Bool) : + Reindex.config (Equiv.sumCompl P) (Sum.elim x y) = pasteCube P x y := by + funext i + by_cases hi : P i <;> simp [Reindex.config, pasteCube, hi] + +namespace BiasedFourier + +/-- The ambient support obtained by adjoining free and exterior supports. -/ +def subtypeSupport (A : Finset {i // P i}) (D : Finset {i // ¬P i}) : Finset ι := + (A.disjSum D).map (Equiv.sumCompl P).toEmbedding + +/-- Conditional Fourier coefficients on arbitrary coordinate subtypes agree with +full coefficients after Fourier transformation in the exterior coordinates. -/ +theorem coeff_restricted_coeff_subtype (p : ℝ) (f : (ι → Bool) → ℝ) + (A : Finset {i // P i}) (D : Finset {i // ¬P i}) : + coeff p (fun y => coeff p (restrictCube P f y) A) D = + coeff p f (subtypeSupport P A D) := by + classical + let F : ({i // P i} ⊕ {i // ¬P i} → Bool) → ℝ := + fun z => f (Reindex.config (Equiv.sumCompl P) z) + have hsplit : ∀ x y, F (Sum.elim x y) = restrictCube P f y x := by + intro x y + simp [F, config_sumCompl_eq_pasteCube, restrictCube] + calc + coeff p (fun y => coeff p (restrictCube P f y) A) D = + coeff p (fun y => coeff p (fun x => F (Sum.elim x y)) A) D := by + simp only [hsplit] + _ = coeff p F (A.disjSum D) := coeff_restricted_coeff p F A D + _ = coeff p f (subtypeSupport P A D) := + (coeff_reindex (Equiv.sumCompl P) p F f (fun _ => rfl) (A.disjSum D)).symm + +/-- Exact squared-coefficient averaging over arbitrary exterior coordinate subtypes. -/ +theorem restricted_coeff_sq_average_subtype [DecidableEq ι] {p : ℝ} (hp : 0 < p) (hp1 : p < 1) + (f : (ι → Bool) → ℝ) (A : Finset {i // P i}) : + (∑ y : {i // ¬P i} → Bool, weight p y * + (coeff p (restrictCube P f y) A) ^ 2) = + ∑ D : Finset {i // ¬P i}, (coeff p f (subtypeSupport P A D)) ^ 2 := by + classical + symm + simpa only [coeff_restricted_coeff_subtype] using + parseval hp hp1 (fun y => coeff p (restrictCube P f y) A) + +/-- Free and exterior support sets give each ambient support exactly once. -/ +def subtypeSupportEquiv : + (Finset {i // P i} × Finset {i // ¬P i}) ≃ Finset ι := + Finset.sumEquiv.toEquiv.symm.trans (Equiv.sumCompl P).finsetCongr + +omit [Fintype ι] in +@[simp] +theorem subtypeSupportEquiv_apply + (A : Finset {i // P i}) (D : Finset {i // ¬P i}) : + subtypeSupportEquiv P (A,D) = subtypeSupport P A D := rfl + +omit [Fintype ι] in +@[simp] +theorem subtype_subtypeSupport + (A : Finset {i // P i}) (D : Finset {i // ¬P i}) : + (subtypeSupport P A D).subtype P = A := by + ext i + simp [subtypeSupport] + +omit [Fintype ι] in +@[simp] +theorem subtype_not_subtypeSupport + (A : Finset {i // P i}) (D : Finset {i // ¬P i}) : + (subtypeSupport P A D).subtype (fun i => ¬P i) = D := by + ext i + simp [subtypeSupport] + +/-- Sum over each ambient support by its free and exterior pieces. -/ +theorem sum_subtypeSupport [DecidableEq ι] (h : Finset ι → ℝ) : + (∑ A : Finset {i // P i}, ∑ D : Finset {i // ¬P i}, h (subtypeSupport P A D)) = + ∑ S : Finset ι, h S := by + classical + calc + _ = ∑ AD : Finset {i // P i} × Finset {i // ¬P i}, + h (subtypeSupport P AD.1 AD.2) := + (Fintype.sum_prod_type (fun AD : Finset {i // P i} × Finset {i // ¬P i} => + h (subtypeSupport P AD.1 AD.2))).symm + _ = _ := by + apply Fintype.sum_equiv (subtypeSupportEquiv P) + rintro ⟨A,D⟩ + rfl + +/-- Exact restriction-mass transport for any statistic of the free support. +There is deliberately no restriction on exterior Fourier degree. -/ +theorem restriction_mass_subtype [DecidableEq ι] {p : ℝ} + (hp : 0 < p) (hp1 : p < 1) (f : (ι → Bool) → ℝ) + (L : Finset {i // P i} → ℝ) : + (∑ y : {i // ¬P i} → Bool, weight p y * + ∑ A : Finset {i // P i}, L A * coeff p (restrictCube P f y) A ^ 2) = + ∑ S : Finset ι, L (S.subtype P) * coeff p f S ^ 2 := by + classical + calc + (∑ y : {i // ¬P i} → Bool, weight p y * + ∑ A : Finset {i // P i}, L A * coeff p (restrictCube P f y) A ^ 2) = + ∑ A : Finset {i // P i}, L A * + ∑ y : {i // ¬P i} → Bool, weight p y * coeff p (restrictCube P f y) A ^ 2 := by + simp only [Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro A hA + apply Finset.sum_congr rfl + intro y hy + ring + _ = ∑ A : Finset {i // P i}, ∑ D : Finset {i // ¬P i}, + L A * coeff p f (subtypeSupport P A D) ^ 2 := by + simp_rw [restricted_coeff_sq_average_subtype P hp hp1, Finset.mul_sum] + _ = ∑ S : Finset ι, L (S.subtype P) * coeff p f S ^ 2 := by + simpa only [subtype_subtypeSupport] using + sum_subtypeSupport P (fun S => L (S.subtype P) * coeff p f S ^ 2) + +/-- Exact restricted Fourier mass at any selection of free-coordinate degrees. -/ +theorem restriction_mass_subtype_filter [DecidableEq ι] {p : ℝ} + (hp : 0 < p) (hp1 : p < 1) (f : (ι → Bool) → ℝ) + (Q : ℕ → Prop) [DecidablePred Q] : + (∑ y : {i // ¬P i} → Bool, weight p y * + ∑ A ∈ Finset.univ.filter (fun A : Finset {i // P i} => Q A.card), + coeff p (restrictCube P f y) A ^ 2) = + ∑ S ∈ Finset.univ.filter (fun S : Finset ι => Q (S.filter P).card), + coeff p f S ^ 2 := by + classical + simpa only [Finset.sum_filter, Finset.card_subtype, ite_mul, one_mul, zero_mul] using + restriction_mass_subtype P hp hp1 f (fun A => if Q A.card then 1 else 0) + +/-- The low-degree restriction identity in conditional-sum format. -/ +theorem restriction_low_degree_mass_subtype [DecidableEq ι] {p : ℝ} + (hp : 0 < p) (hp1 : p < 1) (f : (ι → Bool) → ℝ) (k : ℝ) : + (∑ S : Finset ι, if (S.filter P).Nonempty ∧ ((S.filter P).card : ℝ) ≤ k + then coeff p f S ^ 2 else 0) = + ∑ y : {i // ¬P i} → Bool, weight p y * + ∑ A : Finset {i // P i}, if A.Nonempty ∧ (A.card : ℝ) ≤ k + then coeff p (restrictCube P f y) A ^ 2 else 0 := by + classical + simpa only [Finset.sum_filter, Finset.card_pos] using + (restriction_mass_subtype_filter P hp hp1 f (fun d => 0 < d ∧ (d : ℝ) ≤ k)).symm + +end BiasedFourier +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/Russo.lean b/lean/OAI/Combinatorics/SharpThreshold/Russo.lean new file mode 100644 index 0000000000000000000000000000000000000000..a8132c863c8a4f5598f0b060b72536270a9658e3 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/Russo.lean @@ -0,0 +1,108 @@ +import OAI.Combinatorics.SharpThreshold.Model +import OAI.Combinatorics.SharpThreshold.RussoReindex + +namespace OAI + +noncomputable section + +namespace Problem313 + +/-- Derivative of the Bernoulli mass of a single graph configuration. -/ +theorem hasDerivAt_graphWeight {n : ℕ} (p : ℝ) (x : GraphConfig n) : + HasDerivAt (fun q => graphWeight q x) + (∑ e : GraphEdge n, (if x e = true then (1 : ℝ) else -1) * + ∏ j ∈ Finset.univ.erase e, if x j = true then p else 1 - p) p := by + classical + have h (e : GraphEdge n) : + HasDerivAt (fun q : ℝ => if x e = true then q else 1 - q) + (if x e = true then (1 : ℝ) else -1) p := by + split_ifs + · exact hasDerivAt_id p + · simpa using (hasDerivAt_id p).const_sub (1 : ℝ) + simpa only [graphWeight, smul_eq_mul, mul_comm] using + (HasDerivAt.fun_finsetProd (u := Finset.univ) (fun e _ => h e)) + +/-- The finite product rule for the graph probability polynomial. -/ +theorem hasDerivAt_graphMean_raw {n : ℕ} (f : GraphConfig n → Bool) (p : ℝ) : + HasDerivAt (fun q => graphMean q f) + (∑ e : GraphEdge n, ∑ x : GraphConfig n, + ((if x e = true then (1 : ℝ) else -1) * + ∏ j ∈ Finset.univ.erase e, if x j = true then p else 1 - p) * + boolReal (f x)) p := by + classical + have h := HasDerivAt.fun_sum (u := (Finset.univ : Finset (GraphConfig n))) + (fun x _ => (hasDerivAt_graphWeight p x).mul_const (boolReal (f x))) + simp_rw [Finset.sum_mul] at h + rw [Finset.sum_comm] at h + exact h + +/-- The graph probability is a differentiable polynomial, without a monotonicity assumption. -/ +theorem differentiable_graphMean {n : ℕ} (f : GraphConfig n → Bool) : + Differentiable ℝ (fun p => graphMean p f) := + fun p => (hasDerivAt_graphMean_raw f p).differentiableAt + +/-- Continuity of graph probability as a function of the edge bias. -/ +theorem continuous_graphMean_russo {n : ℕ} (f : GraphConfig n → Bool) : + Continuous (fun p => graphMean p f) := + (differentiable_graphMean f).continuous + +/-- Every increasing property has nonnegative Boolean coordinate differences. -/ +theorem increasing_update_false_true {n : ℕ} {f : GraphConfig n → Bool} + (hf : IncreasingGraphProperty f) (x : GraphConfig n) (e : GraphEdge n) : + f (Function.update x e false) = true → f (Function.update x e true) = true := by + classical + apply hf + intro j hj + by_cases hje : j = e + · subst j + simp + · simpa [Function.update_of_ne hje] using hj + +/-- For an increasing Boolean function the coordinate difference is its pivotal indicator. -/ +theorem boolReal_update_sub_eq_indicator {n : ℕ} {f : GraphConfig n → Bool} + (hf : IncreasingGraphProperty f) (x : GraphConfig n) (e : GraphEdge n) : + boolReal (f (Function.update x e true)) - boolReal (f (Function.update x e false)) = + if f (Function.update x e true) ≠ f (Function.update x e false) then 1 else 0 := by + classical + have h := increasing_update_false_true hf x e + cases ht : f (Function.update x e true) <;> + cases he : f (Function.update x e false) <;> + simp_all [boolReal] + +/-- Monotone pivotal influence is the expectation of the oriented coordinate difference. -/ +theorem edgeInfluence_eq_sum_boolReal_sub {n : ℕ} {f : GraphConfig n → Bool} + (hf : IncreasingGraphProperty f) (p : ℝ) (e : GraphEdge n) : + edgeInfluence p f e = ∑ x : GraphConfig n, graphWeight p x * + (boolReal (f (Function.update x e true)) - + boolReal (f (Function.update x e false))) := by + classical + unfold edgeInfluence + apply Finset.sum_congr rfl + intro x _ + rw [boolReal_update_sub_eq_indicator hf] + split_ifs <;> simp + +/-- Russo--Margulis formula with pivotal total influence. +The identity is polynomial, so no restriction to biases in `[0,1]` is necessary. -/ +theorem hasDerivAt_graphMean {n : ℕ} {f : GraphConfig n → Bool} + (hf : IncreasingGraphProperty f) (p : ℝ) : + HasDerivAt (fun q => graphMean q f) (totalInfluence p f) p := by + classical + convert hasDerivAt_graphMean_raw f p using 1 + unfold totalInfluence + apply Finset.sum_congr rfl + intro e _ + rw [edgeInfluence_eq_sum_boolReal_sub hf] + exact (russo_sum_reindex p e (fun x => boolReal (f x))).symm + +/-- Derivative form of the Russo--Margulis identity. -/ +theorem deriv_graphMean {n : ℕ} {f : GraphConfig n → Bool} + (hf : IncreasingGraphProperty f) (p : ℝ) : + deriv (fun q => graphMean q f) p = totalInfluence p f := + (hasDerivAt_graphMean hf p).deriv + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/RussoReindex.lean b/lean/OAI/Combinatorics/SharpThreshold/RussoReindex.lean new file mode 100644 index 0000000000000000000000000000000000000000..ee5fc36f80a0d3272024e56e9daf4ebd3f450f91 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/RussoReindex.lean @@ -0,0 +1,121 @@ +import Mathlib + +namespace OAI + +universe u + +noncomputable section +open scoped BigOperators +namespace Problem313 + +variable {ι : Type u} [DecidableEq ι] + +/-- Reinsert one Boolean coordinate in a function on the remaining coordinates. -/ +def russoInsert (i : ι) (b : Bool) (z : {j : ι // j ≠ i} → Bool) : ι → Bool := + (Equiv.funSplitAt i Bool).symm (b, z) + +@[simp] theorem russoInsert_self (i : ι) (b : Bool) + (z : {j : ι // j ≠ i} → Bool) : russoInsert i b z i = b := by + simp [russoInsert, Equiv.funSplitAt_symm_apply] + +@[simp] theorem russoInsert_of_ne (i : ι) (b : Bool) + (z : {j : ι // j ≠ i} → Bool) (j : ι) (h : j ≠ i) : + russoInsert i b z j = z ⟨j,h⟩ := by + simp [russoInsert, Equiv.funSplitAt_symm_apply, h] + +@[simp] theorem update_russoInsert (i : ι) (b c : Bool) + (z : {j : ι // j ≠ i} → Bool) : + Function.update (russoInsert i b z) i c = russoInsert i c z := by + funext j + by_cases h : j = i + · subst j; simp + · simp [h] + +variable [Fintype ι] + +/-- Splitting a finite Boolean cube at one coordinate. -/ +theorem sum_bool_split (i : ι) (g : (ι → Bool) → ℝ) : + (∑ x, g x) = ∑ z : {j : ι // j ≠ i} → Bool, + (g (russoInsert i true z) + g (russoInsert i false z)) := by + rw [← (Equiv.funSplitAt i Bool).symm.sum_comp g] + rw [Fintype.sum_prod_type, Fintype.sum_bool, ← Finset.sum_add_distrib] + rfl + +/-- The product excluding a coordinate does not depend on that coordinate. -/ +theorem prod_erase_russoInsert (p : ℝ) (i : ι) (b c : Bool) + (z : {j : ι // j ≠ i} → Bool) : + (∏ j ∈ Finset.univ.erase i, if russoInsert i b z j = true then p else 1-p) = + ∏ j ∈ Finset.univ.erase i, if russoInsert i c z j = true then p else 1-p := by + apply Finset.prod_congr rfl + intro j hj + have hji : j ≠ i := (Finset.mem_erase.mp hj).1 + simp [hji] + +/-- A Bernoulli weight factors at a chosen coordinate. -/ +theorem prod_russoInsert (p : ℝ) (i : ι) (b : Bool) + (z : {j : ι // j ≠ i} → Bool) : + (∏ j, if russoInsert i b z j = true then p else 1-p) = + (if b = true then p else 1-p) * + ∏ j ∈ Finset.univ.erase i, if russoInsert i false z j = true then p else 1-p := by + rw [← Finset.mul_prod_erase Finset.univ + (fun j => if russoInsert i b z j = true then p else 1-p) (Finset.mem_univ i)] + rw [prod_erase_russoInsert p i b false] + simp + +/-- Finite reindexing identity behind the Russo--Margulis derivative formula. +No positivity assumptions on the bias or the observable are needed. -/ +theorem russo_sum_reindex (p : ℝ) (i : ι) (g : (ι → Bool) → ℝ) : + (∑ x : ι → Bool, (if x i = true then (1 : ℝ) else -1) * + (∏ j ∈ Finset.univ.erase i, if x j = true then p else 1-p) * g x) = + ∑ x : ι → Bool, (∏ j, if x j = true then p else 1-p) * + (g (Function.update x i true) - g (Function.update x i false)) := by + rw [sum_bool_split i, sum_bool_split i] + apply Finset.sum_congr rfl + intro z hz + simp only [russoInsert_self, Bool.false_eq_true, + ↓reduceIte, update_russoInsert, prod_russoInsert] + rw [prod_erase_russoInsert p i true false] + ring + +/-- Integrating out one coordinate is unchanged by Bernoulli resampling. -/ +theorem sum_weight_conditioning (p : ℝ) (i : ι) (g : (ι → Bool) → ℝ) : + (∑ x : ι → Bool, (∏ j, if x j = true then p else 1-p) * g x) = + ∑ x : ι → Bool, (∏ j, if x j = true then p else 1-p) * + ((1-p) * g (Function.update x i false) + p * g (Function.update x i true)) := by + rw [sum_bool_split i, sum_bool_split i] + apply Finset.sum_congr rfl + intro z hz + simp only [update_russoInsert, prod_russoInsert, Bool.false_eq_true, ↓reduceIte] + ring + +/-- A reset observable can be integrated on the cube with that coordinate removed. -/ +theorem sum_weight_update (p : ℝ) (i : ι) (b : Bool) (g : (ι → Bool) → ℝ) : + (∑ x : ι → Bool, (∏ j, if x j = true then p else 1-p) * + g (Function.update x i b)) = + ∑ z : {j : ι // j ≠ i} → Bool, + (∏ j ∈ Finset.univ.erase i, if russoInsert i false z j = true then p else 1-p) * + g (russoInsert i b z) := by + rw [sum_bool_split i] + apply Finset.sum_congr rfl + intro z hz + simp only [update_russoInsert, prod_russoInsert, Bool.false_eq_true, ↓reduceIte] + ring + +/-- Discrete integration by parts for a centered Bernoulli coordinate. -/ +theorem sum_weight_centered_coordinate (p : ℝ) (i : ι) (g : (ι → Bool) → ℝ) : + (∑ x : ι → Bool, (∏ j, if x j = true then p else 1-p) * g x * + ((if x i = true then (1 : ℝ) else 0) - p)) = + p * (1-p) * ∑ x : ι → Bool, (∏ j, if x j = true then p else 1-p) * + (g (Function.update x i true) - g (Function.update x i false)) := by + rw [sum_bool_split i, sum_bool_split i, Finset.mul_sum] + apply Finset.sum_congr rfl + intro z hz + simp only [russoInsert_self, update_russoInsert, prod_russoInsert, + Bool.false_eq_true, ↓reduceIte] + ring + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/SharpThreshold.lean b/lean/OAI/Combinatorics/SharpThreshold/SharpThreshold.lean new file mode 100644 index 0000000000000000000000000000000000000000..8a99ed7b5bb71c27bbb228a8b8cebaad18cc5c54 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/SharpThreshold.lean @@ -0,0 +1,74 @@ +import OAI.Combinatorics.SharpThreshold.GraphQuantile +import OAI.Combinatorics.SharpThreshold.Probability +import OAI.Combinatorics.SharpThreshold.Russo +import OAI.Combinatorics.SharpThreshold.ThresholdODE +import OAI.Combinatorics.SharpThreshold.ThresholdConstants + +namespace OAI + +noncomputable section +namespace Problem313 + +/-- The entire threshold-width deduction, with the variance estimate as its only +additional quantitative hypothesis. -/ +theorem graphQuantile_width_of_variance_bound {n : ℕ} {f : GraphConfig n → Bool} + {C ε : ℝ} (hC : 0 ≤ C) + (hmono : IncreasingGraphProperty f) (hnt : NontrivialGraphProperty f) + (hε : 0 < ε) (hεhalf : ε < (1 / 2 : ℝ)) + (hvariance : ∀ p ∈ Set.Ioo (0 : ℝ) 1, + graphVariance p f ≤ C * totalInfluence p f) : + graphQuantile (1 - ε) f - graphQuantile ε f ≤ + (4 * C) * Real.log (1 / (2 * ε)) := by + have hεone : ε < 1 := by linarith + have hother0 : 0 < 1 - ε := by linarith + have hother1 : 1 - ε < 1 := by linarith + have ha := graphQuantile_mem_Ioo hmono hnt hε hεone + have hb := graphQuantile_mem_Ioo hmono hnt hother0 hother1 + have hab : graphQuantile ε f ≤ graphQuantile (1 - ε) f := by + exact (graphQuantile_strictMonoOn hmono hnt + ⟨hε.le, hεone.le⟩ ⟨hother0.le, hother1.le⟩ (by linarith)).le + have hrange : ∀ p ∈ Set.Icc (graphQuantile ε f) (graphQuantile (1 - ε) f), + p ∈ Set.Ioo (0 : ℝ) 1 := by + intro p hp + exact ⟨ha.1.trans_le hp.1, hp.2.trans_lt hb.2⟩ + have hlog : graphQuantile (1 - ε) f - graphQuantile ε f ≤ + 2 * C * Real.log ((1 - ε) / ε) := by + apply logistic_width_of_hasDerivAt + (μ := fun p => graphMean p f) (μ' := fun p => totalInfluence p f) + hab hε hεone (continuous_graphMean f).continuousOn + · intro p hp + exact graphMean_mem_Ioo (hrange p hp).1 (hrange p hp).2 hnt + · intro p hp + exact hasDerivAt_graphMean hmono p + · intro p hp + have hv := hvariance p (hrange p (Set.Ioo_subset_Icc_self hp)) + simpa only [graphVariance_eq_mean_mul] using hv + · exact graphMean_graphQuantile hmono hnt hε.le hεone.le + · exact graphMean_graphQuantile hmono hnt hother0.le hother1.le + exact threshold_log_conversion C ε + (graphQuantile (1 - ε) f - graphQuantile ε f) hC hε hεhalf hlog + +/-- The logarithmic-square threshold-width bound follows from the variance bound. -/ +theorem sharp_threshold_width_of_variance_bound + (hvariance : ∀ (n : ℕ) (f : GraphConfig n → Bool) (p : ℝ), + 2 ≤ n → VertexInvariant f → 0 < p → p < 1 → + graphVariance p f ≤ ((2 : ℝ) ^ 17 / (Real.log (n : ℝ)) ^ 2) * + totalInfluence p f) : + ∀ (n : ℕ) (f : GraphConfig n → Bool) (ε : ℝ), + 2 ≤ n → VertexInvariant f → IncreasingGraphProperty f → + NontrivialGraphProperty f → 0 < ε → ε < (1 / 2 : ℝ) → + graphQuantile (1 - ε) f - graphQuantile ε f ≤ + ((2 : ℝ) ^ 19 / (Real.log (n : ℝ)) ^ 2) * + Real.log (1 / (2 * ε)) := by + intro n f ε hn hinvariant hmono hnt hε hεhalf + have h := graphQuantile_width_of_variance_bound + (C := (2 : ℝ) ^ 17 / (Real.log (n : ℝ)) ^ 2) + (by positivity) hmono hnt hε hεhalf + (fun p hp => hvariance n f p hn hinvariant hp.1 hp.2) + convert h using 1; ring + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/SpectralBounds.lean b/lean/OAI/Combinatorics/SharpThreshold/SpectralBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..8a761bb0170267609df754a05ef33ee2af395ee3 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/SpectralBounds.lean @@ -0,0 +1,182 @@ +import Mathlib + +namespace OAI + +universe u + +noncomputable section + +namespace Problem313 + +/-- A finite spectral tail is controlled by its first degree moment. -/ +theorem finite_spectral_tail {ι : Type u} (s : Finset ι) + (mass degree : ι → ℝ) (cutoff : ℝ) (hcutoff : 0 < cutoff) + (hmass : ∀ i ∈ s, 0 ≤ mass i) + (hdegree : ∀ i ∈ s, 0 ≤ degree i) : + (∑ i ∈ s with cutoff < degree i, mass i) ≤ + (∑ i ∈ s, degree i * mass i) / cutoff := by + classical + apply (le_div_iff₀ hcutoff).2 + rw [Finset.sum_mul] + calc + ∑ i ∈ s with cutoff < degree i, mass i * cutoff ≤ + ∑ i ∈ s with cutoff < degree i, degree i * mass i := by + apply Finset.sum_le_sum + intro i hi + obtain ⟨his, hiq⟩ := Finset.mem_filter.mp hi + nlinarith [hmass i his] + _ ≤ ∑ i ∈ s, degree i * mass i := by + apply Finset.sum_le_sum_of_subset_of_nonneg (Finset.filter_subset _ _) + intro i hi _ + exact mul_nonneg (hdegree i hi) (hmass i hi) + +/-- Splitting at a positive spectral cutoff gives a low-degree term and a tail. -/ +theorem finite_spectral_split {ι : Type u} (s : Finset ι) + (mass degree : ι → ℝ) (cutoff : ℝ) (hcutoff : 0 < cutoff) + (hmass : ∀ i ∈ s, 0 ≤ mass i) + (hdegree : ∀ i ∈ s, 0 ≤ degree i) : + (∑ i ∈ s, mass i) ≤ + (∑ i ∈ s with degree i ≤ cutoff, mass i) + + (∑ i ∈ s, degree i * mass i) / cutoff := by + classical + have hsplit := Finset.sum_filter_add_sum_filter_not s (fun i => degree i ≤ cutoff) mass + simp only [not_le] at hsplit + rw [← hsplit] + exact add_le_add le_rfl (finite_spectral_tail s mass degree cutoff hcutoff hmass hdegree) + +/-- The bias cancels exactly in the tail term at the bias-dependent cutoff. -/ +theorem variance_tail_bias_cancellation (sigma ell : ℝ) + (hsigma : sigma ≠ 0) (hell : ell ≠ 0) : + sigma ^ 2 / ((sigma * ell / 64) ^ 2 / 2) = 8192 / ell ^ 2 := by + field_simp + ring + +/-- Assemble low-degree capture and the Dirichlet identity into a variance bound. -/ +theorem variance_from_spectral_capture {ι : Type u} (s : Finset ι) + (mass degree : ι → ℝ) (sigma ell influence lowConstant : ℝ) + (hsigma : 0 < sigma) (hell : 0 < ell) + (hmass : ∀ i ∈ s, 0 ≤ mass i) + (hdegree : ∀ i ∈ s, 0 ≤ degree i) + (hcapture : (∑ i ∈ s with degree i ≤ (sigma * ell / 64) ^ 2 / 2, mass i) + ≤ lowConstant * influence) + (hdirichlet : (∑ i ∈ s, degree i * mass i) = sigma ^ 2 * influence) : + (∑ i ∈ s, mass i) ≤ (lowConstant + 8192 / ell ^ 2) * influence := by + have hcutoff : 0 < (sigma * ell / 64) ^ 2 / 2 := by positivity + have hsplit := finite_spectral_split s mass degree _ hcutoff hmass hdegree + have htail : sigma ^ 2 * influence / ((sigma * ell / 64) ^ 2 / 2) = + (8192 / ell ^ 2) * influence := by + calc + _ = (sigma ^ 2 / ((sigma * ell / 64) ^ 2 / 2)) * influence := by ring + _ = _ := by rw [variance_tail_bias_cancellation sigma ell hsigma.ne' hell.ne'] + rw [hdirichlet, htail] at hsplit + nlinarith + +/-- The two numerical terms fit inside the advertised universal constant. -/ +theorem variance_constant_assembly (t ell lowConstant : ℝ) + (ht : 0 < t) (hell : t / 3 ≤ ell) + (hlow : lowConstant ≤ 256 / t ^ 2) : + lowConstant + 8192 / ell ^ 2 ≤ (2 : ℝ) ^ 17 / t ^ 2 := by + have hellpos : 0 < ell := lt_of_lt_of_le (by positivity : 0 < t / 3) hell + have hsq := mul_self_le_mul_self (by positivity : 0 ≤ t / 3) hell + have htail : 8192 / ell ^ 2 ≤ 73728 / t ^ 2 := by + apply (div_le_div_iff₀ (sq_pos_of_pos hellpos) (sq_pos_of_pos ht)).2 + nlinarith + have hbudget : 256 / t ^ 2 + 73728 / t ^ 2 ≤ (2 : ℝ) ^ 17 / t ^ 2 := by + rw [← add_div] + apply div_le_div_of_nonneg_right + · norm_num + · positivity + linarith + +/-- A more flexible numerical budget, useful with coarse exponential estimates. -/ +theorem variance_constant_assembly_budget (t ell lowConstant budget : ℝ) + (ht : 0 < t) (hell : t / 3 ≤ ell) + (hlow : lowConstant ≤ budget / t ^ 2) + (hbudget : budget + 73728 ≤ (2 : ℝ) ^ 17) : + lowConstant + 8192 / ell ^ 2 ≤ (2 : ℝ) ^ 17 / t ^ 2 := by + have hellpos : 0 < ell := lt_of_lt_of_le (by positivity : 0 < t / 3) hell + have hsq := mul_self_le_mul_self (by positivity : 0 ≤ t / 3) hell + have htail : 8192 / ell ^ 2 ≤ 73728 / t ^ 2 := by + apply (div_le_div_iff₀ (sq_pos_of_pos hellpos) (sq_pos_of_pos ht)).2 + nlinarith + calc + lowConstant + 8192 / ell ^ 2 ≤ budget / t ^ 2 + 73728 / t ^ 2 := + add_le_add hlow htail + _ = (budget + 73728) / t ^ 2 := by ring + _ ≤ _ := div_le_div_of_nonneg_right hbudget (sq_nonneg t) + +/-- A small logarithm only needs the elementary Poincaré bound. -/ +theorem variance_small_log_assembly (t variance influence : ℝ) + (ht : 0 < t) (htsmall : t ≤ 16) (hinfluence : 0 ≤ influence) + (hpoincare : variance ≤ influence / 4) : + variance ≤ ((2 : ℝ) ^ 17 / t ^ 2) * influence := by + have hsq : t ^ 2 ≤ 256 := by nlinarith + have hfactor : (1 / 4 : ℝ) ≤ (2 : ℝ) ^ 17 / t ^ 2 := by + apply (le_div_iff₀ (sq_pos_of_pos ht)).2 + norm_num + nlinarith + calc + variance ≤ (1 / 4 : ℝ) * influence := by linarith + _ ≤ _ := mul_le_mul_of_nonneg_right hfactor hinfluence + +/-- Final algebraic combination, leaving only the graph-specific spectral input. -/ +theorem variance_large_log_assembly (t ell variance influence lowConstant : ℝ) + (ht : 0 < t) (hell : t / 3 ≤ ell) (hinfluence : 0 ≤ influence) + (hlow : lowConstant ≤ 256 / t ^ 2) + (hvariance : variance ≤ (lowConstant + 8192 / ell ^ 2) * influence) : + variance ≤ ((2 : ℝ) ^ 17 / t ^ 2) * influence := + hvariance.trans (mul_le_mul_of_nonneg_right + (variance_constant_assembly t ell lowConstant ht hell hlow) hinfluence) + +/-- The spectral variance bound for Fourier coefficients indexed by finite supports. -/ +theorem variance_from_fourier_capture {ι : Type u} [Fintype ι] [DecidableEq ι] + (coeff : Finset ι → ℝ) (variance sigma ell influence lowConstant : ℝ) + (hsigma : 0 < sigma) (hell : 0 < ell) + (hvariance : variance = ∑ S : Finset ι with S.Nonempty, coeff S ^ 2) + (hdirichlet : (∑ S : Finset ι, (S.card : ℝ) * coeff S ^ 2) = sigma ^ 2 * influence) + (hcapture : (∑ S : Finset ι with S.Nonempty ∧ + (S.card : ℝ) ≤ (sigma * ell / 64) ^ 2 / 2, coeff S ^ 2) + ≤ lowConstant * influence) : + variance ≤ (lowConstant + 8192 / ell ^ 2) * influence := by + classical + let s : Finset (Finset ι) := Finset.univ.filter Finset.Nonempty + have hdir : (∑ S ∈ s, (S.card : ℝ) * coeff S ^ 2) = sigma ^ 2 * influence := by + rw [← hdirichlet] + apply Finset.sum_subset (Finset.filter_subset _ _) + intro S _ hS + have hSempty : S = ∅ := by simpa [s, Finset.not_nonempty_iff_eq_empty] using hS + simp [hSempty] + have hcap : (∑ S ∈ s with (S.card : ℝ) ≤ (sigma * ell / 64) ^ 2 / 2, coeff S ^ 2) + ≤ lowConstant * influence := by + simpa only [s, Finset.filter_filter] using hcapture + rw [hvariance] + exact variance_from_spectral_capture s (fun S => coeff S ^ 2) + (fun S => (S.card : ℝ)) sigma ell influence lowConstant hsigma hell + (fun S _ => sq_nonneg _) (fun S _ => Nat.cast_nonneg _) hcap hdir + +/-- Parseval and the first spectral moment immediately imply Poincaré. -/ +theorem variance_le_dirichlet_of_fourier {ι : Type u} [Fintype ι] [DecidableEq ι] + (coeff : Finset ι → ℝ) (variance dirichlet : ℝ) + (hvariance : variance = ∑ S : Finset ι with S.Nonempty, coeff S ^ 2) + (hdirichlet : (∑ S : Finset ι, (S.card : ℝ) * coeff S ^ 2) = dirichlet) : + variance ≤ dirichlet := by + classical + rw [hvariance, ← hdirichlet] + calc + (∑ S : Finset ι with S.Nonempty, coeff S ^ 2) ≤ + ∑ S : Finset ι with S.Nonempty, (S.card : ℝ) * coeff S ^ 2 := by + apply Finset.sum_le_sum + intro S hS + have hpos : 0 < S.card := Finset.card_pos.mpr (Finset.mem_filter.mp hS).2 + have hcard : (1 : ℝ) ≤ S.card := by exact_mod_cast hpos + nlinarith [sq_nonneg (coeff S)] + _ ≤ ∑ S : Finset ι, (S.card : ℝ) * coeff S ^ 2 := by + apply Finset.sum_le_sum_of_subset_of_nonneg (Finset.filter_subset _ _) + intro S _ _ + exact mul_nonneg (Nat.cast_nonneg _) (sq_nonneg _) + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/SupportDegree.lean b/lean/OAI/Combinatorics/SharpThreshold/SupportDegree.lean new file mode 100644 index 0000000000000000000000000000000000000000..1e58e91c9372052b0f0b7707c25db8d96658b2db --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/SupportDegree.lean @@ -0,0 +1,112 @@ +import Mathlib + +namespace OAI + +universe u + +/-! Elementary support-graph combinatorics, independent of probability. -/ + +namespace Problem313.SupportCombinatorics + +open Finset + +variable {α : Type u} [DecidableEq α] + +/-- The non-isolated vertices of a finite edge family. -/ +def vertices (S : Finset (Finset α)) : Finset α := S.biUnion id + +/-- The number of support edges incident to a vertex. -/ +def degree (S : Finset (Finset α)) (u : α) : ℕ := + (S.filter (fun e => u ∈ e)).card + +lemma edge_subset_vertices {S : Finset (Finset α)} {e : Finset α} + (he : e ∈ S) : e ⊆ vertices S := by + intro u hu + exact mem_biUnion.mpr ⟨e, he, hu⟩ + +lemma card_vertices_le {S : Finset (Finset α)} + (hS : ∀ e ∈ S, e.card = 2) : (vertices S).card ≤ 2 * S.card := by + calc + (vertices S).card ≤ ∑ e ∈ S, e.card := card_biUnion_le + _ = 2 * S.card := by + rw [sum_congr rfl hS] + simp [Nat.mul_comm] + +lemma degree_pos_iff {S : Finset (Finset α)} {u : α} : + 0 < degree S u ↔ u ∈ vertices S := by + simp [degree, vertices, card_pos, Finset.Nonempty] + +lemma degree_le_card_vertices_sub_one {S : Finset (Finset α)} + (hS : ∀ e ∈ S, e.card = 2) (u : α) : + degree S u ≤ (vertices S).card - 1 := by + have hinj : Set.InjOn (fun e : Finset α => e.erase u) (S.filter (fun e => u ∈ e)) := by + intro e he f hf hef + have he' := (mem_filter.mp he).2 + have hf' := (mem_filter.mp hf).2 + calc + e = insert u (e.erase u) := (insert_erase he').symm + _ = insert u (f.erase u) := congrArg (insert u) hef + _ = f := insert_erase hf' + have hsub : (S.filter (fun e => u ∈ e)).image (fun e => e.erase u) ⊆ + ((vertices S).erase u).powersetCard 1 := by + intro e he + obtain ⟨f, hf, rfl⟩ := mem_image.mp he + obtain ⟨hfS, huf⟩ := mem_filter.mp hf + apply mem_powersetCard.mpr + constructor + · exact erase_subset_erase u (edge_subset_vertices hfS) + · rw [card_erase_of_mem huf, hS f hfS] + have hcard := card_le_card hsub + rw [card_image_of_injOn hinj, card_powersetCard, Nat.choose_one_right] at hcard + by_cases hu : u ∈ vertices S + · simpa [degree, card_erase_of_mem hu] using hcard + · have hd : degree S u = 0 := by + have := degree_pos_iff.not.mpr hu + omega + simp [hd] + +lemma sum_degrees {S : Finset (Finset α)} + (hS : ∀ e ∈ S, e.card = 2) : + ∑ u ∈ vertices S, degree S u = 2 * S.card := by + classical + conv_lhs => simp only [degree, card_eq_sum_ones, sum_filter] + rw [sum_comm] + calc + ∑ e ∈ S, ∑ u ∈ vertices S, (if u ∈ e then (1 : ℕ) else 0) = ∑ e ∈ S, e.card := by + apply sum_congr rfl + intro e he + rw [← sum_filter] + have hh : (vertices S).filter (fun u => u ∈ e) = e := by + ext u + simp only [mem_filter] + exact and_iff_right_of_imp (fun hu => edge_subset_vertices he hu) + simp [hh] + _ = 2 * S.card := by + rw [sum_congr rfl hS] + simp [Nat.mul_comm] + +lemma exists_small_positive_degree {S : Finset (Finset α)} + (hS : ∀ e ∈ S, e.card = 2) (hne : S.Nonempty) : + ∃ u ∈ vertices S, 1 ≤ degree S u ∧ (degree S u)^2 ≤ 2 * S.card := by + have hv : (vertices S).Nonempty := by + obtain ⟨e, he⟩ := hne + have hepos : 0 < e.card := by rw [hS e he]; omega + obtain ⟨u, hu⟩ := card_pos.mp hepos + exact ⟨u, edge_subset_vertices he hu⟩ + obtain ⟨u, hu, hmin⟩ := exists_min_image (vertices S) (degree S) hv + refine ⟨u, hu, degree_pos_iff.mpr hu, ?_⟩ + have hsum : (vertices S).card * degree S u ≤ 2 * S.card := by + calc + (vertices S).card * degree S u = ∑ v ∈ vertices S, degree S u := by simp + _ ≤ ∑ v ∈ vertices S, degree S v := sum_le_sum (fun v hv => hmin v hv) + _ = 2 * S.card := sum_degrees hS + have hdeg := degree_le_card_vertices_sub_one hS u + have hle : degree S u ≤ (vertices S).card := hdeg.trans (Nat.sub_le _ _) + calc + (degree S u)^2 = degree S u * degree S u := pow_two _ + _ ≤ (vertices S).card * degree S u := Nat.mul_le_mul_right _ hle + _ ≤ 2 * S.card := hsum + +end Problem313.SupportCombinatorics + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/SupportDegreeGraph.lean b/lean/OAI/Combinatorics/SharpThreshold/SupportDegreeGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..0f099d756cb7ac9fec52e927bf8921283989c479 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/SupportDegreeGraph.lean @@ -0,0 +1,59 @@ +import OAI.Combinatorics.SharpThreshold.Model +import OAI.Combinatorics.SharpThreshold.SupportDegree + +namespace OAI + +namespace Problem313 + +open Finset + +lemma support_vertices_card_le {n : ℕ} (S : Finset (GraphEdge n)) : + (S.biUnion (fun e => e.val)).card ≤ 2 * S.card := by + classical + have h := SupportCombinatorics.card_vertices_le + (S := S.image Subtype.val) (by + intro e he + obtain ⟨f, hf, rfl⟩ := mem_image.mp he + exact f.property) + have hv : SupportCombinatorics.vertices (S.image Subtype.val) = + S.biUnion (fun e => e.val) := by + ext u + simp [SupportCombinatorics.vertices] + simpa [hv, card_image_of_injective S Subtype.val_injective] using h + +lemma support_exists_small_positive_degree {n : ℕ} (S : Finset (GraphEdge n)) + (hS : S.Nonempty) : + ∃ u ∈ S.biUnion (fun e => e.val), + 1 ≤ (S.filter (fun e => u ∈ e.val)).card ∧ + (S.filter (fun e => u ∈ e.val)).card ^ 2 ≤ 2 * S.card := by + classical + obtain ⟨u, hu, hpos, hsmall⟩ := SupportCombinatorics.exists_small_positive_degree + (S := S.image Subtype.val) (by + intro e he + obtain ⟨f, hf, rfl⟩ := mem_image.mp he + exact f.property) (hS.image Subtype.val) + have hdeg : SupportCombinatorics.degree (S.image Subtype.val) u = + (S.filter (fun e => u ∈ e.val)).card := by + unfold SupportCombinatorics.degree + rw [filter_image] + exact card_image_of_injective _ Subtype.val_injective + refine ⟨u, ?_, ?_, ?_⟩ + · simpa [SupportCombinatorics.vertices] using hu + · simpa [hdeg] using hpos + · simpa [hdeg, card_image_of_injective S Subtype.val_injective] using hsmall + +lemma support_exists_degree_le_cutoff {n : ℕ} (S : Finset (GraphEdge n)) + (hS : S.Nonempty) {k : ℝ} (hk : 0 ≤ k) + (hcard : (S.card : ℝ) ≤ k ^ 2 / 2) : + ∃ u ∈ S.biUnion (fun e => e.val), + 1 ≤ (S.filter (fun e => u ∈ e.val)).card ∧ + ((S.filter (fun e => u ∈ e.val)).card : ℝ) ≤ k := by + obtain ⟨u, hu, hpos, hsquare⟩ := support_exists_small_positive_degree S hS + refine ⟨u, hu, hpos, ?_⟩ + have hsquare' : ((S.filter (fun e => u ∈ e.val)).card : ℝ)^2 ≤ 2 * S.card := + by exact_mod_cast hsquare + nlinarith [Nat.cast_nonneg (α := ℝ) (S.filter (fun e => u ∈ e.val)).card] + +end Problem313 + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/SupportIncidence.lean b/lean/OAI/Combinatorics/SharpThreshold/SupportIncidence.lean new file mode 100644 index 0000000000000000000000000000000000000000..da060b18185c8fd235caf3a8c71389f0317ac155 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/SupportIncidence.lean @@ -0,0 +1,77 @@ +import OAI.Combinatorics.SharpThreshold.Model +import OAI.Combinatorics.SharpThreshold.SupportDegree + +namespace OAI + +noncomputable section + +namespace Problem313 + +open Finset + +lemma support_vertices_image {n : ℕ} (S : Finset (GraphEdge n)) : + SupportCombinatorics.vertices (S.image Subtype.val) = S.biUnion Subtype.val := by + ext u + simp [SupportCombinatorics.vertices] + +lemma support_degree_image {n : ℕ} (S : Finset (GraphEdge n)) (u : Fin n) : + SupportCombinatorics.degree (S.image Subtype.val) u = + (S.filter (fun e => u ∈ e.val)).card := by + classical + unfold SupportCombinatorics.degree + rw [Finset.filter_image] + exact Finset.card_image_of_injective _ Subtype.val_injective + +lemma graph_support_vertices_card_le {n : ℕ} (S : Finset (GraphEdge n)) : + (S.biUnion Subtype.val).card ≤ 2 * S.card := by + classical + have hS : ∀ e ∈ S.image Subtype.val, e.card = 2 := by + intro e he + obtain ⟨e, _, rfl⟩ := Finset.mem_image.mp he + exact e.property + have h := SupportCombinatorics.card_vertices_le hS + rw [support_vertices_image, Finset.card_image_of_injective _ Subtype.val_injective] at h + exact h + +lemma exists_graph_support_degree_sq_le {n : ℕ} (S : Finset (GraphEdge n)) + (hne : S.Nonempty) : + ∃ u ∈ S.biUnion Subtype.val, + 1 ≤ (S.filter (fun e => u ∈ e.val)).card ∧ + (S.filter (fun e => u ∈ e.val)).card ^ 2 ≤ 2 * S.card := by + classical + have hS : ∀ e ∈ S.image Subtype.val, e.card = 2 := by + intro e he + obtain ⟨e, _, rfl⟩ := Finset.mem_image.mp he + exact e.property + obtain ⟨u, hu, hd, hsq⟩ := SupportCombinatorics.exists_small_positive_degree + hS (hne.image Subtype.val) + rw [support_vertices_image] at hu + rw [support_degree_image] at hd hsq + rw [Finset.card_image_of_injective _ Subtype.val_injective] at hsq + exact ⟨u, hu, hd, hsq⟩ + +/-- The graph support vertex needed in block-capture, already in the real cutoff form. -/ +lemma exists_graph_support_degree_le {n : ℕ} (S : Finset (GraphEdge n)) + (hne : S.Nonempty) {k : ℝ} (hk : 0 ≤ k) + (hcard : (S.card : ℝ) ≤ k ^ 2 / 2) : + ∃ u ∈ S.biUnion Subtype.val, + 1 ≤ (S.filter (fun e => u ∈ e.val)).card ∧ + ((S.filter (fun e => u ∈ e.val)).card : ℝ) ≤ k := by + obtain ⟨u, hu, hd, hsq⟩ := exists_graph_support_degree_sq_le S hne + refine ⟨u, hu, hd, ?_⟩ + have hsq' : ((S.filter (fun e => u ∈ e.val)).card : ℝ) ^ 2 ≤ + 2 * (S.card : ℝ) := by exact_mod_cast hsq + nlinarith [sq_nonneg (((S.filter (fun e => u ∈ e.val)).card : ℝ) - k)] + +lemma graph_support_vertices_card_le_cutoff {n : ℕ} (S : Finset (GraphEdge n)) + {k : ℝ} (hcard : (S.card : ℝ) ≤ k ^ 2 / 2) : + ((S.biUnion Subtype.val).card : ℝ) ≤ k ^ 2 := by + have h : ((S.biUnion Subtype.val).card : ℝ) ≤ 2 * (S.card : ℝ) := by + exact_mod_cast graph_support_vertices_card_le S + linarith + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/ThresholdConstants.lean b/lean/OAI/Combinatorics/SharpThreshold/ThresholdConstants.lean new file mode 100644 index 0000000000000000000000000000000000000000..752c366c5dfeb8415f4828913bf68d21aa393afb --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/ThresholdConstants.lean @@ -0,0 +1,51 @@ +import Mathlib + +namespace OAI + +noncomputable section + +namespace Problem313 + +/-- The logarithmic simplification used in the threshold-width estimate. -/ +theorem log_odds_le_two_log_half_inv (ε : ℝ) (hε : 0 < ε) + (hεhalf : ε < (1 / 2 : ℝ)) : + Real.log ((1 - ε) / ε) ≤ 2 * Real.log (1 / (2 * ε)) := by + have hnum : 0 < 1 - ε := by linarith + have hden : 0 < 2 * ε := by positivity + have hratio : (1 - ε) / ε ≤ (1 / (2 * ε)) ^ 2 := by + rw [div_pow, one_pow] + apply (div_le_div_iff₀ hε (sq_pos_of_pos hden)).2 + nlinarith [mul_nonneg (le_of_lt hε) (sq_nonneg (1 - 2 * ε))] + have hlog := Real.log_le_log (div_pos hnum hε) hratio + simpa only [Real.log_pow, Nat.cast_ofNat] using hlog + +/-- Multiplying the logarithmic estimate by a nonnegative constant. -/ +theorem threshold_log_conversion (C ε w : ℝ) (hC : 0 ≤ C) + (hε : 0 < ε) (hεhalf : ε < (1 / 2 : ℝ)) + (hw : w ≤ (2 * C) * Real.log ((1 - ε) / ε)) : + w ≤ (4 * C) * Real.log (1 / (2 * ε)) := by + calc + w ≤ (2 * C) * Real.log ((1 - ε) / ε) := hw + _ ≤ (2 * C) * (2 * Real.log (1 / (2 * ε))) := + mul_le_mul_of_nonneg_left (log_odds_le_two_log_half_inv ε hε hεhalf) + (by positivity) + _ = (4 * C) * Real.log (1 / (2 * ε)) := by ring + +/-- The numerical constants relating the variance and threshold-width bounds. -/ +theorem threshold_constant_conversion (t ε w : ℝ) + (hε : 0 < ε) (hεhalf : ε < (1 / 2 : ℝ)) + (hw : w ≤ ((2 * (2 : ℝ) ^ 17) / t ^ 2) * + Real.log ((1 - ε) / ε)) : + w ≤ ((2 : ℝ) ^ 19 / t ^ 2) * Real.log (1 / (2 * ε)) := by + have hC : 0 ≤ (2 : ℝ) ^ 17 / t ^ 2 := by positivity + have hw' : w ≤ (2 * ((2 : ℝ) ^ 17 / t ^ 2)) * + Real.log ((1 - ε) / ε) := by + convert hw using 1; ring + have h := threshold_log_conversion ((2 : ℝ) ^ 17 / t ^ 2) ε w hC hε hεhalf hw' + convert h using 1; ring + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/ThresholdODE.lean b/lean/OAI/Combinatorics/SharpThreshold/ThresholdODE.lean new file mode 100644 index 0000000000000000000000000000000000000000..0822d7514dcabd71afeb1c27bec036bf833bc251 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/ThresholdODE.lean @@ -0,0 +1,76 @@ +import Mathlib + +namespace OAI + +noncomputable section + +namespace Problem313 + +/-- The derivative of log odds, stated without any probability-specific definitions. -/ +theorem hasDerivAt_log_odds {μ : ℝ → ℝ} {d x : ℝ} + (hd : HasDerivAt μ d x) (hpos : 0 < μ x) (hone : μ x < 1) : + HasDerivAt (fun t => Real.log (μ t) - Real.log (1 - μ t)) + (d / (μ x * (1 - μ x))) x := by + have hne : μ x ≠ 0 := ne_of_gt hpos + have hne' : 1 - μ x ≠ 0 := ne_of_gt (sub_pos.mpr hone) + convert! (hd.log hne).sub (((hasDerivAt_const x (1 : ℝ)).sub hd).log hne') using 1 + dsimp only [Pi.sub_apply] + field_simp + ring + +/-- Integrating a logistic differential inequality by the mean value theorem. +Continuity is needed on the closed interval, differentiability only in its interior. -/ +theorem logistic_coordinate_width {μ μ' : ℝ → ℝ} {a b C : ℝ} + (hab : a ≤ b) (hcont : ContinuousOn μ (Set.Icc a b)) + (hμ : ∀ x ∈ Set.Icc a b, 0 < μ x ∧ μ x < 1) + (hd : ∀ x ∈ Set.Ioo a b, HasDerivAt μ (μ' x) x) + (hbound : ∀ x ∈ Set.Ioo a b, μ x * (1 - μ x) ≤ C * μ' x) : + b - a ≤ C * ((Real.log (μ b) - Real.log (1 - μ b)) - + (Real.log (μ a) - Real.log (1 - μ a))) := by + rcases eq_or_lt_of_le hab with heq | hlt + · subst b + simp + let g : ℝ → ℝ := fun x => C * (Real.log (μ x) - Real.log (1 - μ x)) + let g' : ℝ → ℝ := fun x => C * (μ' x / (μ x * (1 - μ x))) + have hg : ContinuousOn g (Set.Icc a b) := by + apply ContinuousOn.const_mul + exact (hcont.log (fun x hx => ne_of_gt (hμ x hx).1)).sub + ((continuousOn_const.sub hcont).log + (fun x hx => ne_of_gt (sub_pos.mpr (hμ x hx).2))) + have hgd : ∀ x ∈ Set.Ioo a b, HasDerivAt g (g' x) x := by + intro x hx + have hμx := hμ x (Set.Ioo_subset_Icc_self hx) + exact (hasDerivAt_log_odds (hd x hx) hμx.1 hμx.2).const_mul C + obtain ⟨x, hx, hslope⟩ := exists_hasDerivAt_eq_slope g g' hlt hg hgd + have hμx := hμ x (Set.Ioo_subset_Icc_self hx) + have hden : 0 < μ x * (1 - μ x) := mul_pos hμx.1 (sub_pos.mpr hμx.2) + have hg' : 1 ≤ g' x := by + dsimp [g'] + rw [← mul_div_assoc] + exact (le_div_iff₀ hden).2 (by simpa using hbound x hx) + rw [hslope] at hg' + have hle := (le_div_iff₀ (sub_pos.mpr hlt)).1 hg' + dsimp [g] at hle + linarith + +/-- The symmetric endpoint form used in sharp-threshold estimates. -/ +theorem logistic_width_of_hasDerivAt {μ μ' : ℝ → ℝ} {a b C ε : ℝ} + (hab : a ≤ b) (hε : 0 < ε) (hεone : ε < 1) + (hcont : ContinuousOn μ (Set.Icc a b)) + (hμ : ∀ x ∈ Set.Icc a b, 0 < μ x ∧ μ x < 1) + (hd : ∀ x ∈ Set.Ioo a b, HasDerivAt μ (μ' x) x) + (hbound : ∀ x ∈ Set.Ioo a b, μ x * (1 - μ x) ≤ C * μ' x) + (ha : μ a = ε) (hb : μ b = 1 - ε) : + b - a ≤ 2 * C * Real.log ((1 - ε) / ε) := by + have h := logistic_coordinate_width hab hcont hμ hd hbound + rw [ha, hb] at h + have hsub : 1 - (1 - ε) = ε := by ring + rw [hsub] at h + rw [Real.log_div (ne_of_gt (sub_pos.mpr hεone)) (ne_of_gt hε)] + linarith + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/TwoPoint.lean b/lean/OAI/Combinatorics/SharpThreshold/TwoPoint.lean new file mode 100644 index 0000000000000000000000000000000000000000..8da2d4b7f33ea35ef9ebd545f913480f0926d961 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/TwoPoint.lean @@ -0,0 +1,82 @@ +import Mathlib + +namespace OAI + +noncomputable section + +namespace Problem313 + +/-- A pointwise fourth-power estimate with the linear term retained for averaging. -/ +lemma fourth_power_centered_bound (a z : ℝ) : + (a + z) ^ 4 ≤ a ^ 4 + 4 * a ^ 3 * z + 8 * a ^ 2 * z ^ 2 + 3 * z ^ 4 := by + nlinarith only [sq_nonneg (z * (a - z))] + +/-- The scalar two-point estimate used to tensorize biased hypercontractivity. +The noise parameter is `sqrt (p * (1-p)) / 4`; after cancellation of the +normalization in the biased character, its two values are `-p / 4` and +`(1-p) / 4`. This formulation also includes the endpoint biases. -/ +theorem biased_two_point_fourth_moment (p a b : ℝ) (hp : 0 ≤ p) (hp1 : p ≤ 1) : + (1 - p) * (a - p * b / 4) ^ 4 + p * (a + (1 - p) * b / 4) ^ 4 ≤ + (a ^ 2 + b ^ 2) ^ 2 := by + have hq : 0 ≤ 1 - p := sub_nonneg.mpr hp1 + have h1 := fourth_power_centered_bound a (-p * b / 4) + have h2 := fourth_power_centered_bound a ((1 - p) * b / 4) + have h3 := mul_le_mul_of_nonneg_left h1 hq + have h4 := mul_le_mul_of_nonneg_left h2 hp + have hvar : 0 ≤ p * (1 - p) := mul_nonneg hp hq + have hvar1 : p * (1 - p) ≤ 1 / 4 := by nlinarith [sq_nonneg (p - 1 / 2)] + have hpq : (1 - p) ^ 3 + p ^ 3 ≤ 1 := by nlinarith + have hab : 0 ≤ a ^ 2 * b ^ 2 := mul_nonneg (sq_nonneg a) (sq_nonneg b) + have hb4 : 0 ≤ b ^ 4 := by positivity + have hvarab := mul_le_mul_of_nonneg_right hvar1 hab + have hfour := mul_le_mul_of_nonneg_left hpq hvar + have hfourb := mul_le_mul_of_nonneg_right hfour hb4 + have hvarb := mul_le_mul_of_nonneg_right hvar1 hb4 + nlinarith only [h3, h4, hvarab, hfourb, hvarb, hab, hb4] + +/-- Mean and variance decomposition for a two-point law, without division. -/ +lemma two_point_second_moment (p u v : ℝ) : + ((1 - p) * u + p * v) ^ 2 + p * (1 - p) * (v - u) ^ 2 = + (1 - p) * u ^ 2 + p * v ^ 2 := by + ring + +/-- The scalar noise contraction in raw function values. This is the +`(1 - ρ) * expectation + ρ * identity` form, suitable for tensor products. -/ +theorem biased_two_point_noise_fourth (p ρ u v : ℝ) + (hp : 0 ≤ p) (hp1 : p ≤ 1) (hρ : 16 * ρ ^ 2 ≤ p * (1 - p)) : + let μ := (1 - p) * u + p * v + (1 - p) * (μ + ρ * (u - μ)) ^ 4 + p * (μ + ρ * (v - μ)) ^ 4 ≤ + ((1 - p) * u ^ 2 + p * v ^ 2) ^ 2 := by + dsimp only + have h := biased_two_point_fourth_moment p ((1 - p) * u + p * v) + (4 * ρ * (v - u)) hp hp1 + have hleft : (1 - p) * u + p * v - p * (4 * ρ * (v - u)) / 4 = + (1 - p) * u + p * v + ρ * (u - ((1 - p) * u + p * v)) := by ring + have hright : (1 - p) * u + p * v + (1 - p) * (4 * ρ * (v - u)) / 4 = + (1 - p) * u + p * v + ρ * (v - ((1 - p) * u + p * v)) := by ring + rw [hleft, hright] at h + refine h.trans ?_ + have hc := mul_le_mul_of_nonneg_right hρ (sq_nonneg (v - u)) + have hm := two_point_second_moment p u v + have hbound : ((1 - p) * u + p * v) ^ 2 + (4 * ρ * (v - u)) ^ 2 ≤ + (1 - p) * u ^ 2 + p * v ^ 2 := by nlinarith only [hc, hm] + exact pow_le_pow_left₀ (by positivity) hbound 2 + +/-- Finite-sum formulation of the two-point noise contraction. -/ +theorem biased_bool_noise_fourth (p ρ : ℝ) (f : Bool → ℝ) + (hp : 0 ≤ p) (hp1 : p ≤ 1) (hρ : 16 * ρ ^ 2 ≤ p * (1 - p)) : + let w : Bool → ℝ := fun b => if b = true then p else 1 - p + let μ := ∑ b, w b * f b + ∑ b, w b * ((1 - ρ) * μ + ρ * f b) ^ 4 ≤ + (∑ b, w b * (f b) ^ 2) ^ 2 := by + dsimp only + simp only [Fintype.sum_bool, ↓reduceIte, Bool.false_eq_true] + have h := biased_two_point_noise_fourth p ρ (f false) (f true) hp hp1 hρ + dsimp only at h + convert h using 1 <;> ring + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/VarianceConstants.lean b/lean/OAI/Combinatorics/SharpThreshold/VarianceConstants.lean new file mode 100644 index 0000000000000000000000000000000000000000..2af2263c34154f506b129ba6f08c6e3f806e0703 --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/VarianceConstants.lean @@ -0,0 +1,66 @@ +import Mathlib + +namespace OAI + +noncomputable section + +namespace Problem313 + +/-- A coarse bound sufficient for absorbing the low Fourier levels. -/ +theorem variance_decay_constant {t m : ℝ} (ht : 0 < t) (hm : 0 < m) + (hlog : t / 3 ≤ Real.log m) : + 4 * m ^ (-(1 : ℝ) / 4) ≤ 1152 / t ^ 2 := by + have hexp : t ^ 2 / 288 ≤ Real.exp (t / 12) := by + have h := Real.pow_div_factorial_le_exp (t / 12) (show 0 ≤ t / 12 by positivity) 2 + norm_num at h + nlinarith + have hcancel : Real.exp (t / 12) * Real.exp (-(t / 12)) = 1 := by + rw [← Real.exp_add] + simp + have hdecay : t ^ 2 * Real.exp (-(t / 12)) ≤ 288 := by + have h := mul_le_mul_of_nonneg_right hexp (Real.exp_nonneg (-(t / 12))) + rw [hcancel] at h + nlinarith + have hpow : m ^ (-(1 : ℝ) / 4) ≤ Real.exp (-(t / 12)) := by + rw [Real.rpow_def_of_pos hm] + apply Real.exp_le_exp.mpr + linarith + apply (le_div_iff₀ (sq_pos_of_pos ht)).mpr + have h := mul_le_mul_of_nonneg_left hpow (sq_nonneg t) + nlinarith + +/-- Cancellation of the bias and comparison of logarithms in the Fourier tail. -/ +theorem variance_tail_constant {t m σ : ℝ} (ht : 0 < t) + (hlog : t / 3 ≤ Real.log m) (hσ : 0 < σ) : + 2 * σ ^ 2 / (σ * Real.log m / 64) ^ 2 ≤ 73728 / t ^ 2 := by + have hl : 0 < Real.log m := by linarith + have heq : 2 * σ ^ 2 / (σ * Real.log m / 64) ^ 2 = + 8192 / (Real.log m) ^ 2 := by + field_simp + ring + rw [heq] + apply (div_le_div_iff₀ (sq_pos_of_pos hl) (sq_pos_of_pos ht)).mpr + have htl : t ≤ 3 * Real.log m := by linarith + have hs := mul_le_mul htl htl ht.le (by positivity : 0 ≤ 3 * Real.log m) + nlinarith + +/-- A numerical bound for the sum of low-degree and spectral-tail contributions. +Only the lower bound on `log m` is needed; no floor or exponential monotonicity +arguments enter this estimate. -/ +theorem variance_constant_bound {t m σ : ℝ} (ht : 0 < t) (hm : 0 < m) + (hlog : t / 3 ≤ Real.log m) (hσ : 0 < σ) : + 4 * m ^ (-(1 : ℝ) / 4) + 2 * σ ^ 2 / (σ * Real.log m / 64) ^ 2 ≤ + (2 : ℝ) ^ 17 / t ^ 2 := by + have h₁ := variance_decay_constant ht hm hlog + have h₂ := variance_tail_constant ht hlog hσ + have h₃ : (1152 : ℝ) / t ^ 2 + 73728 / t ^ 2 ≤ (2 : ℝ) ^ 17 / t ^ 2 := by + rw [← add_div] + apply div_le_div_of_nonneg_right _ (sq_nonneg t) + norm_num + linarith + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SharpThreshold/VarianceReduction.lean b/lean/OAI/Combinatorics/SharpThreshold/VarianceReduction.lean new file mode 100644 index 0000000000000000000000000000000000000000..3b52b607561cf0cd6564788579c95066507999bf --- /dev/null +++ b/lean/OAI/Combinatorics/SharpThreshold/VarianceReduction.lean @@ -0,0 +1,64 @@ +import OAI.Combinatorics.SharpThreshold.SpectralBounds +import OAI.Combinatorics.SharpThreshold.ExpQuadratic + +namespace OAI + +universe u + +noncomputable section + +namespace Problem313 + +/-- The graph-independent final step of the variance proof: capture at squared +logarithmic degree, together with Parseval and the Dirichlet identity, yields +the exact advertised numerical constant. -/ +theorem variance_bound_of_fourier_capture {ι : Type u} [Fintype ι] [DecidableEq ι] + (coeff : Finset ι → ℝ) (variance sigma influence t m : ℝ) + (hsigma : 0 < sigma) (hinfluence : 0 ≤ influence) + (ht : 0 < t) (hm : 0 < m) (hlog : t / 3 ≤ Real.log m) + (hvariance : variance = ∑ S : Finset ι with S.Nonempty, coeff S ^ 2) + (hdirichlet : (∑ S : Finset ι, (S.card : ℝ) * coeff S ^ 2) = sigma ^ 2 * influence) + (hcapture : (∑ S : Finset ι with S.Nonempty ∧ + (S.card : ℝ) ≤ (sigma * Real.log m / 64) ^ 2 / 2, coeff S ^ 2) + ≤ (4 * m ^ (-1 / 4 : ℝ)) * influence) : + variance ≤ ((2 : ℝ) ^ 17 / t ^ 2) * influence := by + have hell : 0 < Real.log m := lt_of_lt_of_le (by positivity : 0 < t / 3) hlog + have hpre := variance_from_fourier_capture coeff variance sigma (Real.log m) + influence (4 * m ^ (-1 / 4 : ℝ)) hsigma hell hvariance hdirichlet hcapture + have hrem : 4 * m ^ (-1 / 4 : ℝ) ≤ 2304 / t ^ 2 := by + apply (le_div_iff₀ (sq_pos_of_pos ht)).2 + exact block_rpow_remainder_le t m ht.le hm hlog + have hconstant := variance_constant_assembly_budget t (Real.log m) + (4 * m ^ (-1 / 4 : ℝ)) 2304 ht hlog hrem (by norm_num) + exact hpre.trans (mul_le_mul_of_nonneg_right hconstant hinfluence) + +/-- A complete numerical reduction for all logarithmic scales. The only +large-scale input remaining is capture of low Fourier supports. -/ +theorem variance_bound_of_fourier_inputs {ι : Type u} [Fintype ι] [DecidableEq ι] + (coeff : Finset ι → ℝ) (variance sigma influence t : ℝ) + (hsigma : 0 < sigma) (hsigma_sq : sigma ^ 2 ≤ 1 / 4) + (hinfluence : 0 ≤ influence) (ht : 0 < t) + (hvariance : variance = ∑ S : Finset ι with S.Nonempty, coeff S ^ 2) + (hdirichlet : (∑ S : Finset ι, (S.card : ℝ) * coeff S ^ 2) = sigma ^ 2 * influence) + (hcapture : 16 ≤ t → ∃ m : ℝ, 0 < m ∧ t / 3 ≤ Real.log m ∧ + (∑ S : Finset ι with S.Nonempty ∧ + (S.card : ℝ) ≤ (sigma * Real.log m / 64) ^ 2 / 2, coeff S ^ 2) + ≤ (4 * m ^ (-1 / 4 : ℝ)) * influence) : + variance ≤ ((2 : ℝ) ^ 17 / t ^ 2) * influence := by + by_cases hlarge : 16 ≤ t + · obtain ⟨m, hm, hlog, hcap⟩ := hcapture hlarge + exact variance_bound_of_fourier_capture coeff variance sigma influence t m + hsigma hinfluence ht hm hlog hvariance hdirichlet hcap + · have hpoincare := variance_le_dirichlet_of_fourier coeff variance + (sigma ^ 2 * influence) hvariance hdirichlet + have hquarter : variance ≤ influence / 4 := by + have h := mul_le_mul_of_nonneg_right hsigma_sq hinfluence + linarith + exact variance_small_log_assembly t variance influence ht (by linarith) + hinfluence hquarter + +end Problem313 + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/Activation.lean b/lean/OAI/Combinatorics/Sidorenko/Activation.lean new file mode 100644 index 0000000000000000000000000000000000000000..0a24cf09e549add0462c8394bb4668b083a104a5 --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/Activation.lean @@ -0,0 +1,828 @@ +import OAI.Combinatorics.Sidorenko.GlobalMoments + +namespace OAI + + +section + +namespace SidorenkoCounterexample +open Classical +open scoped BigOperators symmDiff + +abbrev ActCorner := Fin 22 × Fin 3 +def cornerPoint (k : ActCorner) : Fin 13 := faceVertex k.1 k.2 +def cornerPairL (k : ActCorner) : Fin 33 := facePair k.1 (slotLeft k.2) +def cornerPairR (k : ActCorner) : Fin 33 := facePair k.1 (slotRight k.2) +def pairCorners (e : Fin 33) : Finset ActCorner := + Finset.univ.filter fun k => cornerPairL k=e ∨ cornerPairR k=e +def cornerMax (k : ActCorner) : Finset ActCorner := pairCorners (cornerPairL k) ∪ pairCorners (cornerPairR k) +def cornerGamma (k : ActCorner) : Finset ActCorner := pairCorners (cornerPairL k) ∆ pairCorners (cornerPairR k) + +theorem pairCorners_mem (k : ActCorner) (e : Fin 33) : + k∈pairCorners e ↔ cornerPairL k=e ∨ cornerPairR k=e := by simp [pairCorners] +def pairCornerTable : Fin 33 → Finset ActCorner := ![{(2,0), (2,1), (3,0), (3,1)}, + {(0,0), (0,2), (2,0), (2,2)}, + {(2,1), (2,2), (8,0), (8,1)}, + {(1,0), (1,2), (3,0), (3,2)}, + {(3,1), (3,2), (9,0), (9,2)}, + {(0,0), (0,1), (1,0), (1,1)}, + {(0,1), (0,2), (4,0), (4,1)}, + {(8,0), (8,2), (9,0), (9,1)}, + {(8,1), (8,2), (10,0), (10,1)}, + {(1,1), (1,2), (7,0), (7,1)}, + {(9,1), (9,2), (12,0), (12,2)}, + {(4,0), (4,2), (5,0), (5,2)}, + {(4,1), (4,2), (11,0), (11,1)}, + {(10,0), (10,2), (11,0), (11,2)}, + {(10,1), (10,2), (13,0), (13,2)}, + {(6,0), (6,2), (7,0), (7,2)}, + {(7,1), (7,2), (21,1), (21,2)}, + {(12,0), (12,1), (13,0), (13,1)}, + {(12,1), (12,2), (21,0), (21,1)}, + {(5,0), (5,1), (6,0), (6,1)}, + {(5,1), (5,2), (16,1), (16,2)}, + {(11,1), (11,2), (17,1), (17,2)}, + {(13,1), (13,2), (19,1), (19,2)}, + {(6,1), (6,2), (18,1), (18,2)}, + {(20,1), (20,2), (21,0), (21,2)}, + {(14,0), (14,2), (16,0), (16,1)}, + {(16,0), (16,2), (17,0), (17,1)}, + {(15,0), (15,2), (17,0), (17,2)}, + {(19,0), (19,1), (20,0), (20,1)}, + {(15,1), (15,2), (19,0), (19,2)}, + {(14,1), (14,2), (18,0), (18,1)}, + {(18,0), (18,2), (20,0), (20,2)}, + {(14,0), (14,1), (15,0), (15,1)}] +lemma pairCorners_table_0 : pairCorners 0=pairCornerTable 0 := by decide +lemma pairCorners_table_1 : pairCorners 1=pairCornerTable 1 := by decide +lemma pairCorners_table_2 : pairCorners 2=pairCornerTable 2 := by decide +lemma pairCorners_table_3 : pairCorners 3=pairCornerTable 3 := by decide +lemma pairCorners_table_4 : pairCorners 4=pairCornerTable 4 := by decide +lemma pairCorners_table_5 : pairCorners 5=pairCornerTable 5 := by decide +lemma pairCorners_table_6 : pairCorners 6=pairCornerTable 6 := by decide +lemma pairCorners_table_7 : pairCorners 7=pairCornerTable 7 := by decide +lemma pairCorners_table_8 : pairCorners 8=pairCornerTable 8 := by decide +lemma pairCorners_table_9 : pairCorners 9=pairCornerTable 9 := by decide +lemma pairCorners_table_10 : pairCorners 10=pairCornerTable 10 := by decide +lemma pairCorners_table_11 : pairCorners 11=pairCornerTable 11 := by decide +lemma pairCorners_table_12 : pairCorners 12=pairCornerTable 12 := by decide +lemma pairCorners_table_13 : pairCorners 13=pairCornerTable 13 := by decide +lemma pairCorners_table_14 : pairCorners 14=pairCornerTable 14 := by decide +lemma pairCorners_table_15 : pairCorners 15=pairCornerTable 15 := by decide +lemma pairCorners_table_16 : pairCorners 16=pairCornerTable 16 := by decide +lemma pairCorners_table_17 : pairCorners 17=pairCornerTable 17 := by decide +lemma pairCorners_table_18 : pairCorners 18=pairCornerTable 18 := by decide +lemma pairCorners_table_19 : pairCorners 19=pairCornerTable 19 := by decide +lemma pairCorners_table_20 : pairCorners 20=pairCornerTable 20 := by decide +lemma pairCorners_table_21 : pairCorners 21=pairCornerTable 21 := by decide +lemma pairCorners_table_22 : pairCorners 22=pairCornerTable 22 := by decide +lemma pairCorners_table_23 : pairCorners 23=pairCornerTable 23 := by decide +lemma pairCorners_table_24 : pairCorners 24=pairCornerTable 24 := by decide +lemma pairCorners_table_25 : pairCorners 25=pairCornerTable 25 := by decide +lemma pairCorners_table_26 : pairCorners 26=pairCornerTable 26 := by decide +lemma pairCorners_table_27 : pairCorners 27=pairCornerTable 27 := by decide +lemma pairCorners_table_28 : pairCorners 28=pairCornerTable 28 := by decide +lemma pairCorners_table_29 : pairCorners 29=pairCornerTable 29 := by decide +lemma pairCorners_table_30 : pairCorners 30=pairCornerTable 30 := by decide +lemma pairCorners_table_31 : pairCorners 31=pairCornerTable 31 := by decide +lemma pairCorners_table_32 : pairCorners 32=pairCornerTable 32 := by decide +theorem pairCorners_table (e : Fin 33) : pairCorners e=pairCornerTable e := by + fin_cases e + · exact pairCorners_table_0 + · exact pairCorners_table_1 + · exact pairCorners_table_2 + · exact pairCorners_table_3 + · exact pairCorners_table_4 + · exact pairCorners_table_5 + · exact pairCorners_table_6 + · exact pairCorners_table_7 + · exact pairCorners_table_8 + · exact pairCorners_table_9 + · exact pairCorners_table_10 + · exact pairCorners_table_11 + · exact pairCorners_table_12 + · exact pairCorners_table_13 + · exact pairCorners_table_14 + · exact pairCorners_table_15 + · exact pairCorners_table_16 + · exact pairCorners_table_17 + · exact pairCorners_table_18 + · exact pairCorners_table_19 + · exact pairCorners_table_20 + · exact pairCorners_table_21 + · exact pairCorners_table_22 + · exact pairCorners_table_23 + · exact pairCorners_table_24 + · exact pairCorners_table_25 + · exact pairCorners_table_26 + · exact pairCorners_table_27 + · exact pairCorners_table_28 + · exact pairCorners_table_29 + · exact pairCorners_table_30 + · exact pairCorners_table_31 + · exact pairCorners_table_32 +theorem cornerPair_ne (k : ActCorner) : cornerPairL k≠cornerPairR k := by + intro h + have he := facePair_injective k.1 h + have hn : ∀ k : Fin 3,slotLeft k≠slotRight k := by decide + exact hn k.2 he +lemma pairCorners_inter_0_0 : pairCorners (cornerPairL (0,0)) ∩ pairCorners (cornerPairR (0,0))={(0,0)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_0_1 : pairCorners (cornerPairL (0,1)) ∩ pairCorners (cornerPairR (0,1))={(0,1)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_0_2 : pairCorners (cornerPairL (0,2)) ∩ pairCorners (cornerPairR (0,2))={(0,2)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_1_0 : pairCorners (cornerPairL (1,0)) ∩ pairCorners (cornerPairR (1,0))={(1,0)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_1_1 : pairCorners (cornerPairL (1,1)) ∩ pairCorners (cornerPairR (1,1))={(1,1)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_1_2 : pairCorners (cornerPairL (1,2)) ∩ pairCorners (cornerPairR (1,2))={(1,2)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_2_0 : pairCorners (cornerPairL (2,0)) ∩ pairCorners (cornerPairR (2,0))={(2,0)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_2_1 : pairCorners (cornerPairL (2,1)) ∩ pairCorners (cornerPairR (2,1))={(2,1)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_2_2 : pairCorners (cornerPairL (2,2)) ∩ pairCorners (cornerPairR (2,2))={(2,2)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_3_0 : pairCorners (cornerPairL (3,0)) ∩ pairCorners (cornerPairR (3,0))={(3,0)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_3_1 : pairCorners (cornerPairL (3,1)) ∩ pairCorners (cornerPairR (3,1))={(3,1)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_3_2 : pairCorners (cornerPairL (3,2)) ∩ pairCorners (cornerPairR (3,2))={(3,2)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_4_0 : pairCorners (cornerPairL (4,0)) ∩ pairCorners (cornerPairR (4,0))={(4,0)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_4_1 : pairCorners (cornerPairL (4,1)) ∩ pairCorners (cornerPairR (4,1))={(4,1)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_4_2 : pairCorners (cornerPairL (4,2)) ∩ pairCorners (cornerPairR (4,2))={(4,2)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_5_0 : pairCorners (cornerPairL (5,0)) ∩ pairCorners (cornerPairR (5,0))={(5,0)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_5_1 : pairCorners (cornerPairL (5,1)) ∩ pairCorners (cornerPairR (5,1))={(5,1)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_5_2 : pairCorners (cornerPairL (5,2)) ∩ pairCorners (cornerPairR (5,2))={(5,2)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_6_0 : pairCorners (cornerPairL (6,0)) ∩ pairCorners (cornerPairR (6,0))={(6,0)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_6_1 : pairCorners (cornerPairL (6,1)) ∩ pairCorners (cornerPairR (6,1))={(6,1)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_6_2 : pairCorners (cornerPairL (6,2)) ∩ pairCorners (cornerPairR (6,2))={(6,2)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_7_0 : pairCorners (cornerPairL (7,0)) ∩ pairCorners (cornerPairR (7,0))={(7,0)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_7_1 : pairCorners (cornerPairL (7,1)) ∩ pairCorners (cornerPairR (7,1))={(7,1)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_7_2 : pairCorners (cornerPairL (7,2)) ∩ pairCorners (cornerPairR (7,2))={(7,2)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_8_0 : pairCorners (cornerPairL (8,0)) ∩ pairCorners (cornerPairR (8,0))={(8,0)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_8_1 : pairCorners (cornerPairL (8,1)) ∩ pairCorners (cornerPairR (8,1))={(8,1)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_8_2 : pairCorners (cornerPairL (8,2)) ∩ pairCorners (cornerPairR (8,2))={(8,2)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_9_0 : pairCorners (cornerPairL (9,0)) ∩ pairCorners (cornerPairR (9,0))={(9,0)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_9_1 : pairCorners (cornerPairL (9,1)) ∩ pairCorners (cornerPairR (9,1))={(9,1)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_9_2 : pairCorners (cornerPairL (9,2)) ∩ pairCorners (cornerPairR (9,2))={(9,2)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_10_0 : pairCorners (cornerPairL (10,0)) ∩ pairCorners (cornerPairR (10,0))={(10,0)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_10_1 : pairCorners (cornerPairL (10,1)) ∩ pairCorners (cornerPairR (10,1))={(10,1)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_10_2 : pairCorners (cornerPairL (10,2)) ∩ pairCorners (cornerPairR (10,2))={(10,2)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_11_0 : pairCorners (cornerPairL (11,0)) ∩ pairCorners (cornerPairR (11,0))={(11,0)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_11_1 : pairCorners (cornerPairL (11,1)) ∩ pairCorners (cornerPairR (11,1))={(11,1)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_11_2 : pairCorners (cornerPairL (11,2)) ∩ pairCorners (cornerPairR (11,2))={(11,2)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_12_0 : pairCorners (cornerPairL (12,0)) ∩ pairCorners (cornerPairR (12,0))={(12,0)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_12_1 : pairCorners (cornerPairL (12,1)) ∩ pairCorners (cornerPairR (12,1))={(12,1)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_12_2 : pairCorners (cornerPairL (12,2)) ∩ pairCorners (cornerPairR (12,2))={(12,2)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_13_0 : pairCorners (cornerPairL (13,0)) ∩ pairCorners (cornerPairR (13,0))={(13,0)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_13_1 : pairCorners (cornerPairL (13,1)) ∩ pairCorners (cornerPairR (13,1))={(13,1)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_13_2 : pairCorners (cornerPairL (13,2)) ∩ pairCorners (cornerPairR (13,2))={(13,2)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_14_0 : pairCorners (cornerPairL (14,0)) ∩ pairCorners (cornerPairR (14,0))={(14,0)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_14_1 : pairCorners (cornerPairL (14,1)) ∩ pairCorners (cornerPairR (14,1))={(14,1)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_14_2 : pairCorners (cornerPairL (14,2)) ∩ pairCorners (cornerPairR (14,2))={(14,2)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_15_0 : pairCorners (cornerPairL (15,0)) ∩ pairCorners (cornerPairR (15,0))={(15,0)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_15_1 : pairCorners (cornerPairL (15,1)) ∩ pairCorners (cornerPairR (15,1))={(15,1)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_15_2 : pairCorners (cornerPairL (15,2)) ∩ pairCorners (cornerPairR (15,2))={(15,2)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_16_0 : pairCorners (cornerPairL (16,0)) ∩ pairCorners (cornerPairR (16,0))={(16,0)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_16_1 : pairCorners (cornerPairL (16,1)) ∩ pairCorners (cornerPairR (16,1))={(16,1)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_16_2 : pairCorners (cornerPairL (16,2)) ∩ pairCorners (cornerPairR (16,2))={(16,2)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_17_0 : pairCorners (cornerPairL (17,0)) ∩ pairCorners (cornerPairR (17,0))={(17,0)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_17_1 : pairCorners (cornerPairL (17,1)) ∩ pairCorners (cornerPairR (17,1))={(17,1)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_17_2 : pairCorners (cornerPairL (17,2)) ∩ pairCorners (cornerPairR (17,2))={(17,2)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_18_0 : pairCorners (cornerPairL (18,0)) ∩ pairCorners (cornerPairR (18,0))={(18,0)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_18_1 : pairCorners (cornerPairL (18,1)) ∩ pairCorners (cornerPairR (18,1))={(18,1)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_18_2 : pairCorners (cornerPairL (18,2)) ∩ pairCorners (cornerPairR (18,2))={(18,2)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_19_0 : pairCorners (cornerPairL (19,0)) ∩ pairCorners (cornerPairR (19,0))={(19,0)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_19_1 : pairCorners (cornerPairL (19,1)) ∩ pairCorners (cornerPairR (19,1))={(19,1)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_19_2 : pairCorners (cornerPairL (19,2)) ∩ pairCorners (cornerPairR (19,2))={(19,2)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_20_0 : pairCorners (cornerPairL (20,0)) ∩ pairCorners (cornerPairR (20,0))={(20,0)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_20_1 : pairCorners (cornerPairL (20,1)) ∩ pairCorners (cornerPairR (20,1))={(20,1)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_20_2 : pairCorners (cornerPairL (20,2)) ∩ pairCorners (cornerPairR (20,2))={(20,2)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_21_0 : pairCorners (cornerPairL (21,0)) ∩ pairCorners (cornerPairR (21,0))={(21,0)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_21_1 : pairCorners (cornerPairL (21,1)) ∩ pairCorners (cornerPairR (21,1))={(21,1)} := by + simp only [pairCorners_table] + decide +lemma pairCorners_inter_21_2 : pairCorners (cornerPairL (21,2)) ∩ pairCorners (cornerPairR (21,2))={(21,2)} := by + simp only [pairCorners_table] + decide +theorem pairCorners_inter (k : ActCorner) : pairCorners (cornerPairL k) ∩ pairCorners (cornerPairR k)={k} := by + rcases k with ⟨j,k⟩ + fin_cases j <;> fin_cases k + · exact pairCorners_inter_0_0 + · exact pairCorners_inter_0_1 + · exact pairCorners_inter_0_2 + · exact pairCorners_inter_1_0 + · exact pairCorners_inter_1_1 + · exact pairCorners_inter_1_2 + · exact pairCorners_inter_2_0 + · exact pairCorners_inter_2_1 + · exact pairCorners_inter_2_2 + · exact pairCorners_inter_3_0 + · exact pairCorners_inter_3_1 + · exact pairCorners_inter_3_2 + · exact pairCorners_inter_4_0 + · exact pairCorners_inter_4_1 + · exact pairCorners_inter_4_2 + · exact pairCorners_inter_5_0 + · exact pairCorners_inter_5_1 + · exact pairCorners_inter_5_2 + · exact pairCorners_inter_6_0 + · exact pairCorners_inter_6_1 + · exact pairCorners_inter_6_2 + · exact pairCorners_inter_7_0 + · exact pairCorners_inter_7_1 + · exact pairCorners_inter_7_2 + · exact pairCorners_inter_8_0 + · exact pairCorners_inter_8_1 + · exact pairCorners_inter_8_2 + · exact pairCorners_inter_9_0 + · exact pairCorners_inter_9_1 + · exact pairCorners_inter_9_2 + · exact pairCorners_inter_10_0 + · exact pairCorners_inter_10_1 + · exact pairCorners_inter_10_2 + · exact pairCorners_inter_11_0 + · exact pairCorners_inter_11_1 + · exact pairCorners_inter_11_2 + · exact pairCorners_inter_12_0 + · exact pairCorners_inter_12_1 + · exact pairCorners_inter_12_2 + · exact pairCorners_inter_13_0 + · exact pairCorners_inter_13_1 + · exact pairCorners_inter_13_2 + · exact pairCorners_inter_14_0 + · exact pairCorners_inter_14_1 + · exact pairCorners_inter_14_2 + · exact pairCorners_inter_15_0 + · exact pairCorners_inter_15_1 + · exact pairCorners_inter_15_2 + · exact pairCorners_inter_16_0 + · exact pairCorners_inter_16_1 + · exact pairCorners_inter_16_2 + · exact pairCorners_inter_17_0 + · exact pairCorners_inter_17_1 + · exact pairCorners_inter_17_2 + · exact pairCorners_inter_18_0 + · exact pairCorners_inter_18_1 + · exact pairCorners_inter_18_2 + · exact pairCorners_inter_19_0 + · exact pairCorners_inter_19_1 + · exact pairCorners_inter_19_2 + · exact pairCorners_inter_20_0 + · exact pairCorners_inter_20_1 + · exact pairCorners_inter_20_2 + · exact pairCorners_inter_21_0 + · exact pairCorners_inter_21_1 + · exact pairCorners_inter_21_2 +theorem pairCorners_card (e : Fin 33) : (pairCorners e).card=4 := by + rw [pairCorners_table] + have ht : ∀ e,(pairCornerTable e).card=4 := by decide + exact ht e + +theorem cornerPairL_mem (k : ActCorner) : k∈pairCorners (cornerPairL k) := (pairCorners_mem _ _).mpr (Or.inl rfl) +theorem cornerPairR_mem (k : ActCorner) : k∈pairCorners (cornerPairR k) := (pairCorners_mem _ _).mpr (Or.inr rfl) + +theorem cornerGamma_nonempty (k : ActCorner) : cornerGamma k≠∅ := by + intro he + have he : pairCorners (cornerPairL k)=pairCorners (cornerPairR k) := Finset.symmDiff_eq_empty.mp he + have hi := pairCorners_inter k + rw [he,Finset.inter_self] at hi + have hc := pairCorners_card (cornerPairR k) + rw [hi] at hc + simp at hc + +theorem cornerMax_not_sub (k : ActCorner) : ¬cornerMax k⊆cornerGamma k := by + intro h + have hk := h (Finset.mem_union_left _ (cornerPairL_mem k)) + have hn : k∉cornerGamma k := by + simp only [cornerGamma,Finset.mem_symmDiff,cornerPairL_mem,cornerPairR_mem,not_true_eq_false,and_false,or_self,not_false_eq_true] + exact hn hk +lemma supportIntersect_0 : cornerMax (2,0) ∩ cornerMax (2,1) ∩ cornerMax (3,0) ∩ cornerMax (3,1)=pairCorners 0 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_0 (k : ActCorner) : (∀ b∈pairCorners 0,k∈cornerMax b) ↔ k∈pairCorners 0 := by + have h := Finset.ext_iff.mp supportIntersect_0 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_0] at h ⊢ + change (∀ b∈{(2,0),(2,1),(3,0),(3,1)},k∈cornerMax b) ↔ k∈pairCornerTable 0 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_1 : cornerMax (0,0) ∩ cornerMax (0,2) ∩ cornerMax (2,0) ∩ cornerMax (2,2)=pairCorners 1 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_1 (k : ActCorner) : (∀ b∈pairCorners 1,k∈cornerMax b) ↔ k∈pairCorners 1 := by + have h := Finset.ext_iff.mp supportIntersect_1 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_1] at h ⊢ + change (∀ b∈{(0,0),(0,2),(2,0),(2,2)},k∈cornerMax b) ↔ k∈pairCornerTable 1 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_2 : cornerMax (2,1) ∩ cornerMax (2,2) ∩ cornerMax (8,0) ∩ cornerMax (8,1)=pairCorners 2 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_2 (k : ActCorner) : (∀ b∈pairCorners 2,k∈cornerMax b) ↔ k∈pairCorners 2 := by + have h := Finset.ext_iff.mp supportIntersect_2 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_2] at h ⊢ + change (∀ b∈{(2,1),(2,2),(8,0),(8,1)},k∈cornerMax b) ↔ k∈pairCornerTable 2 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_3 : cornerMax (1,0) ∩ cornerMax (1,2) ∩ cornerMax (3,0) ∩ cornerMax (3,2)=pairCorners 3 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_3 (k : ActCorner) : (∀ b∈pairCorners 3,k∈cornerMax b) ↔ k∈pairCorners 3 := by + have h := Finset.ext_iff.mp supportIntersect_3 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_3] at h ⊢ + change (∀ b∈{(1,0),(1,2),(3,0),(3,2)},k∈cornerMax b) ↔ k∈pairCornerTable 3 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_4 : cornerMax (3,1) ∩ cornerMax (3,2) ∩ cornerMax (9,0) ∩ cornerMax (9,2)=pairCorners 4 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_4 (k : ActCorner) : (∀ b∈pairCorners 4,k∈cornerMax b) ↔ k∈pairCorners 4 := by + have h := Finset.ext_iff.mp supportIntersect_4 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_4] at h ⊢ + change (∀ b∈{(3,1),(3,2),(9,0),(9,2)},k∈cornerMax b) ↔ k∈pairCornerTable 4 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_5 : cornerMax (0,0) ∩ cornerMax (0,1) ∩ cornerMax (1,0) ∩ cornerMax (1,1)=pairCorners 5 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_5 (k : ActCorner) : (∀ b∈pairCorners 5,k∈cornerMax b) ↔ k∈pairCorners 5 := by + have h := Finset.ext_iff.mp supportIntersect_5 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_5] at h ⊢ + change (∀ b∈{(0,0),(0,1),(1,0),(1,1)},k∈cornerMax b) ↔ k∈pairCornerTable 5 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_6 : cornerMax (0,1) ∩ cornerMax (0,2) ∩ cornerMax (4,0) ∩ cornerMax (4,1)=pairCorners 6 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_6 (k : ActCorner) : (∀ b∈pairCorners 6,k∈cornerMax b) ↔ k∈pairCorners 6 := by + have h := Finset.ext_iff.mp supportIntersect_6 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_6] at h ⊢ + change (∀ b∈{(0,1),(0,2),(4,0),(4,1)},k∈cornerMax b) ↔ k∈pairCornerTable 6 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_7 : cornerMax (8,0) ∩ cornerMax (8,2) ∩ cornerMax (9,0) ∩ cornerMax (9,1)=pairCorners 7 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_7 (k : ActCorner) : (∀ b∈pairCorners 7,k∈cornerMax b) ↔ k∈pairCorners 7 := by + have h := Finset.ext_iff.mp supportIntersect_7 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_7] at h ⊢ + change (∀ b∈{(8,0),(8,2),(9,0),(9,1)},k∈cornerMax b) ↔ k∈pairCornerTable 7 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_8 : cornerMax (8,1) ∩ cornerMax (8,2) ∩ cornerMax (10,0) ∩ cornerMax (10,1)=pairCorners 8 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_8 (k : ActCorner) : (∀ b∈pairCorners 8,k∈cornerMax b) ↔ k∈pairCorners 8 := by + have h := Finset.ext_iff.mp supportIntersect_8 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_8] at h ⊢ + change (∀ b∈{(8,1),(8,2),(10,0),(10,1)},k∈cornerMax b) ↔ k∈pairCornerTable 8 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_9 : cornerMax (1,1) ∩ cornerMax (1,2) ∩ cornerMax (7,0) ∩ cornerMax (7,1)=pairCorners 9 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_9 (k : ActCorner) : (∀ b∈pairCorners 9,k∈cornerMax b) ↔ k∈pairCorners 9 := by + have h := Finset.ext_iff.mp supportIntersect_9 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_9] at h ⊢ + change (∀ b∈{(1,1),(1,2),(7,0),(7,1)},k∈cornerMax b) ↔ k∈pairCornerTable 9 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_10 : cornerMax (9,1) ∩ cornerMax (9,2) ∩ cornerMax (12,0) ∩ cornerMax (12,2)=pairCorners 10 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_10 (k : ActCorner) : (∀ b∈pairCorners 10,k∈cornerMax b) ↔ k∈pairCorners 10 := by + have h := Finset.ext_iff.mp supportIntersect_10 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_10] at h ⊢ + change (∀ b∈{(9,1),(9,2),(12,0),(12,2)},k∈cornerMax b) ↔ k∈pairCornerTable 10 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_11 : cornerMax (4,0) ∩ cornerMax (4,2) ∩ cornerMax (5,0) ∩ cornerMax (5,2)=pairCorners 11 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_11 (k : ActCorner) : (∀ b∈pairCorners 11,k∈cornerMax b) ↔ k∈pairCorners 11 := by + have h := Finset.ext_iff.mp supportIntersect_11 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_11] at h ⊢ + change (∀ b∈{(4,0),(4,2),(5,0),(5,2)},k∈cornerMax b) ↔ k∈pairCornerTable 11 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_12 : cornerMax (4,1) ∩ cornerMax (4,2) ∩ cornerMax (11,0) ∩ cornerMax (11,1)=pairCorners 12 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_12 (k : ActCorner) : (∀ b∈pairCorners 12,k∈cornerMax b) ↔ k∈pairCorners 12 := by + have h := Finset.ext_iff.mp supportIntersect_12 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_12] at h ⊢ + change (∀ b∈{(4,1),(4,2),(11,0),(11,1)},k∈cornerMax b) ↔ k∈pairCornerTable 12 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_13 : cornerMax (10,0) ∩ cornerMax (10,2) ∩ cornerMax (11,0) ∩ cornerMax (11,2)=pairCorners 13 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_13 (k : ActCorner) : (∀ b∈pairCorners 13,k∈cornerMax b) ↔ k∈pairCorners 13 := by + have h := Finset.ext_iff.mp supportIntersect_13 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_13] at h ⊢ + change (∀ b∈{(10,0),(10,2),(11,0),(11,2)},k∈cornerMax b) ↔ k∈pairCornerTable 13 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_14 : cornerMax (10,1) ∩ cornerMax (10,2) ∩ cornerMax (13,0) ∩ cornerMax (13,2)=pairCorners 14 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_14 (k : ActCorner) : (∀ b∈pairCorners 14,k∈cornerMax b) ↔ k∈pairCorners 14 := by + have h := Finset.ext_iff.mp supportIntersect_14 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_14] at h ⊢ + change (∀ b∈{(10,1),(10,2),(13,0),(13,2)},k∈cornerMax b) ↔ k∈pairCornerTable 14 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_15 : cornerMax (6,0) ∩ cornerMax (6,2) ∩ cornerMax (7,0) ∩ cornerMax (7,2)=pairCorners 15 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_15 (k : ActCorner) : (∀ b∈pairCorners 15,k∈cornerMax b) ↔ k∈pairCorners 15 := by + have h := Finset.ext_iff.mp supportIntersect_15 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_15] at h ⊢ + change (∀ b∈{(6,0),(6,2),(7,0),(7,2)},k∈cornerMax b) ↔ k∈pairCornerTable 15 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_16 : cornerMax (7,1) ∩ cornerMax (7,2) ∩ cornerMax (21,1) ∩ cornerMax (21,2)=pairCorners 16 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_16 (k : ActCorner) : (∀ b∈pairCorners 16,k∈cornerMax b) ↔ k∈pairCorners 16 := by + have h := Finset.ext_iff.mp supportIntersect_16 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_16] at h ⊢ + change (∀ b∈{(7,1),(7,2),(21,1),(21,2)},k∈cornerMax b) ↔ k∈pairCornerTable 16 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_17 : cornerMax (12,0) ∩ cornerMax (12,1) ∩ cornerMax (13,0) ∩ cornerMax (13,1)=pairCorners 17 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_17 (k : ActCorner) : (∀ b∈pairCorners 17,k∈cornerMax b) ↔ k∈pairCorners 17 := by + have h := Finset.ext_iff.mp supportIntersect_17 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_17] at h ⊢ + change (∀ b∈{(12,0),(12,1),(13,0),(13,1)},k∈cornerMax b) ↔ k∈pairCornerTable 17 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_18 : cornerMax (12,1) ∩ cornerMax (12,2) ∩ cornerMax (21,0) ∩ cornerMax (21,1)=pairCorners 18 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_18 (k : ActCorner) : (∀ b∈pairCorners 18,k∈cornerMax b) ↔ k∈pairCorners 18 := by + have h := Finset.ext_iff.mp supportIntersect_18 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_18] at h ⊢ + change (∀ b∈{(12,1),(12,2),(21,0),(21,1)},k∈cornerMax b) ↔ k∈pairCornerTable 18 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_19 : cornerMax (5,0) ∩ cornerMax (5,1) ∩ cornerMax (6,0) ∩ cornerMax (6,1)=pairCorners 19 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_19 (k : ActCorner) : (∀ b∈pairCorners 19,k∈cornerMax b) ↔ k∈pairCorners 19 := by + have h := Finset.ext_iff.mp supportIntersect_19 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_19] at h ⊢ + change (∀ b∈{(5,0),(5,1),(6,0),(6,1)},k∈cornerMax b) ↔ k∈pairCornerTable 19 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_20 : cornerMax (5,1) ∩ cornerMax (5,2) ∩ cornerMax (16,1) ∩ cornerMax (16,2)=pairCorners 20 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_20 (k : ActCorner) : (∀ b∈pairCorners 20,k∈cornerMax b) ↔ k∈pairCorners 20 := by + have h := Finset.ext_iff.mp supportIntersect_20 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_20] at h ⊢ + change (∀ b∈{(5,1),(5,2),(16,1),(16,2)},k∈cornerMax b) ↔ k∈pairCornerTable 20 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_21 : cornerMax (11,1) ∩ cornerMax (11,2) ∩ cornerMax (17,1) ∩ cornerMax (17,2)=pairCorners 21 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_21 (k : ActCorner) : (∀ b∈pairCorners 21,k∈cornerMax b) ↔ k∈pairCorners 21 := by + have h := Finset.ext_iff.mp supportIntersect_21 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_21] at h ⊢ + change (∀ b∈{(11,1),(11,2),(17,1),(17,2)},k∈cornerMax b) ↔ k∈pairCornerTable 21 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_22 : cornerMax (13,1) ∩ cornerMax (13,2) ∩ cornerMax (19,1) ∩ cornerMax (19,2)=pairCorners 22 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_22 (k : ActCorner) : (∀ b∈pairCorners 22,k∈cornerMax b) ↔ k∈pairCorners 22 := by + have h := Finset.ext_iff.mp supportIntersect_22 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_22] at h ⊢ + change (∀ b∈{(13,1),(13,2),(19,1),(19,2)},k∈cornerMax b) ↔ k∈pairCornerTable 22 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_23 : cornerMax (6,1) ∩ cornerMax (6,2) ∩ cornerMax (18,1) ∩ cornerMax (18,2)=pairCorners 23 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_23 (k : ActCorner) : (∀ b∈pairCorners 23,k∈cornerMax b) ↔ k∈pairCorners 23 := by + have h := Finset.ext_iff.mp supportIntersect_23 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_23] at h ⊢ + change (∀ b∈{(6,1),(6,2),(18,1),(18,2)},k∈cornerMax b) ↔ k∈pairCornerTable 23 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_24 : cornerMax (20,1) ∩ cornerMax (20,2) ∩ cornerMax (21,0) ∩ cornerMax (21,2)=pairCorners 24 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_24 (k : ActCorner) : (∀ b∈pairCorners 24,k∈cornerMax b) ↔ k∈pairCorners 24 := by + have h := Finset.ext_iff.mp supportIntersect_24 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_24] at h ⊢ + change (∀ b∈{(20,1),(20,2),(21,0),(21,2)},k∈cornerMax b) ↔ k∈pairCornerTable 24 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_25 : cornerMax (14,0) ∩ cornerMax (14,2) ∩ cornerMax (16,0) ∩ cornerMax (16,1)=pairCorners 25 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_25 (k : ActCorner) : (∀ b∈pairCorners 25,k∈cornerMax b) ↔ k∈pairCorners 25 := by + have h := Finset.ext_iff.mp supportIntersect_25 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_25] at h ⊢ + change (∀ b∈{(14,0),(14,2),(16,0),(16,1)},k∈cornerMax b) ↔ k∈pairCornerTable 25 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_26 : cornerMax (16,0) ∩ cornerMax (16,2) ∩ cornerMax (17,0) ∩ cornerMax (17,1)=pairCorners 26 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_26 (k : ActCorner) : (∀ b∈pairCorners 26,k∈cornerMax b) ↔ k∈pairCorners 26 := by + have h := Finset.ext_iff.mp supportIntersect_26 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_26] at h ⊢ + change (∀ b∈{(16,0),(16,2),(17,0),(17,1)},k∈cornerMax b) ↔ k∈pairCornerTable 26 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_27 : cornerMax (15,0) ∩ cornerMax (15,2) ∩ cornerMax (17,0) ∩ cornerMax (17,2)=pairCorners 27 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_27 (k : ActCorner) : (∀ b∈pairCorners 27,k∈cornerMax b) ↔ k∈pairCorners 27 := by + have h := Finset.ext_iff.mp supportIntersect_27 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_27] at h ⊢ + change (∀ b∈{(15,0),(15,2),(17,0),(17,2)},k∈cornerMax b) ↔ k∈pairCornerTable 27 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_28 : cornerMax (19,0) ∩ cornerMax (19,1) ∩ cornerMax (20,0) ∩ cornerMax (20,1)=pairCorners 28 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_28 (k : ActCorner) : (∀ b∈pairCorners 28,k∈cornerMax b) ↔ k∈pairCorners 28 := by + have h := Finset.ext_iff.mp supportIntersect_28 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_28] at h ⊢ + change (∀ b∈{(19,0),(19,1),(20,0),(20,1)},k∈cornerMax b) ↔ k∈pairCornerTable 28 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_29 : cornerMax (15,1) ∩ cornerMax (15,2) ∩ cornerMax (19,0) ∩ cornerMax (19,2)=pairCorners 29 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_29 (k : ActCorner) : (∀ b∈pairCorners 29,k∈cornerMax b) ↔ k∈pairCorners 29 := by + have h := Finset.ext_iff.mp supportIntersect_29 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_29] at h ⊢ + change (∀ b∈{(15,1),(15,2),(19,0),(19,2)},k∈cornerMax b) ↔ k∈pairCornerTable 29 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_30 : cornerMax (14,1) ∩ cornerMax (14,2) ∩ cornerMax (18,0) ∩ cornerMax (18,1)=pairCorners 30 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_30 (k : ActCorner) : (∀ b∈pairCorners 30,k∈cornerMax b) ↔ k∈pairCorners 30 := by + have h := Finset.ext_iff.mp supportIntersect_30 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_30] at h ⊢ + change (∀ b∈{(14,1),(14,2),(18,0),(18,1)},k∈cornerMax b) ↔ k∈pairCornerTable 30 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_31 : cornerMax (18,0) ∩ cornerMax (18,2) ∩ cornerMax (20,0) ∩ cornerMax (20,2)=pairCorners 31 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_31 (k : ActCorner) : (∀ b∈pairCorners 31,k∈cornerMax b) ↔ k∈pairCorners 31 := by + have h := Finset.ext_iff.mp supportIntersect_31 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_31] at h ⊢ + change (∀ b∈{(18,0),(18,2),(20,0),(20,2)},k∈cornerMax b) ↔ k∈pairCornerTable 31 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +lemma supportIntersect_32 : cornerMax (14,0) ∩ cornerMax (14,1) ∩ cornerMax (15,0) ∩ cornerMax (15,1)=pairCorners 32 := by + simp only [cornerMax,pairCorners_table] + decide +lemma corner_support_32 (k : ActCorner) : (∀ b∈pairCorners 32,k∈cornerMax b) ↔ k∈pairCorners 32 := by + have h := Finset.ext_iff.mp supportIntersect_32 k + simp only [Finset.mem_inter] at h + rw [pairCorners_table_32] at h ⊢ + change (∀ b∈{(14,0),(14,1),(15,0),(15,1)},k∈cornerMax b) ↔ k∈pairCornerTable 32 + simp only [Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq] + tauto +theorem corner_support (e : Fin 33) (k : ActCorner) : (∀ b∈pairCorners e,k∈cornerMax b) ↔ k∈pairCorners e := by + fin_cases e + · exact corner_support_0 k + · exact corner_support_1 k + · exact corner_support_2 k + · exact corner_support_3 k + · exact corner_support_4 k + · exact corner_support_5 k + · exact corner_support_6 k + · exact corner_support_7 k + · exact corner_support_8 k + · exact corner_support_9 k + · exact corner_support_10 k + · exact corner_support_11 k + · exact corner_support_12 k + · exact corner_support_13 k + · exact corner_support_14 k + · exact corner_support_15 k + · exact corner_support_16 k + · exact corner_support_17 k + · exact corner_support_18 k + · exact corner_support_19 k + · exact corner_support_20 k + · exact corner_support_21 k + · exact corner_support_22 k + · exact corner_support_23 k + · exact corner_support_24 k + · exact corner_support_25 k + · exact corner_support_26 k + · exact corner_support_27 k + · exact corner_support_28 k + · exact corner_support_29 k + · exact corner_support_30 k + · exact corner_support_31 k + · exact corner_support_32 k + +theorem cornerGamma_sub (k : ActCorner) : cornerGamma k⊆cornerMax k := + Finset.symmDiff_subset_union + +def cornerSigma (k : ActCorner) : ℝ := if k=(0,0) then -1 else 1 +lemma cornerSigma_abs (k : ActCorner) : |cornerSigma k|=1 := by unfold cornerSigma; split <;> norm_num +noncomputable def cornerLaw (k : ActCorner) : FiniteLaw (Activation ActCorner) := + baseActivation (cornerMax k) (cornerGamma k) (cornerGamma_nonempty k) (cornerSigma k/2) + (by rw [abs_div,cornerSigma_abs]; norm_num) +lemma cornerLaw_zero (k : ActCorner) (α : Finset ActCorner) (hα : α≠∅) : + (cornerLaw k).mean (activationPhi α)=0 := + baseActivation_zero _ _ _ _ (cornerGamma_sub k) _ _ hα +lemma cornerLaw_moment (k : ActCorner) (α β : Finset ActCorner) : + activationMoment (cornerLaw k) α β= + (1/2)*(if α∪β⊆cornerMax k then (if α=β then 1 else 0)+(cornerSigma k/2)*(if α ∆ β=cornerGamma k then 1 else 0) else 0)+ + (1/2)*(if α∪β⊆cornerGamma k then (if α=β then 1 else 0)-(cornerSigma k/2)*(if α ∆ β=cornerGamma k then 1 else 0) else 0) := + baseActivation_moment .. +lemma cornerLaw_support (k : ActCorner) (α β : Finset ActCorner) + (h : activationMoment (cornerLaw k) α β≠0) : α∪β⊆cornerMax k := by + by_contra hn + have hn' : ¬α∪β⊆cornerGamma k := fun h => hn (h.trans (cornerGamma_sub k)) + rw [cornerLaw_moment] at h + simp only [hn,hn',ite_false,mul_zero,add_zero,ne_self_iff_false] at h +lemma cornerLaw_disjoint (k : ActCorner) (α β : Finset ActCorner) + (hd : Disjoint α β) (hn : α∪β≠∅) : activationMoment (cornerLaw k) α β=0 := + activationMoment_disjoint _ (cornerLaw_zero k) α β hd hn +lemma cornerLaw_value (k : ActCorner) : + activationMoment (cornerLaw k) (pairCorners (cornerPairL k)) (pairCorners (cornerPairR k))=cornerSigma k/4 := by + have hn : pairCorners (cornerPairL k)≠pairCorners (cornerPairR k) := by + intro h + have hi := pairCorners_inter k + rw [h,Finset.inter_self] at hi + have hc := pairCorners_card (cornerPairR k) + rw [hi] at hc + simp at hc + rw [cornerLaw_moment] + change (1/2)*(if cornerMax k⊆cornerMax k then (if _ then 1 else 0)+(cornerSigma k/2)*(if cornerGamma k=cornerGamma k then 1 else 0) else 0)+ + (1/2)*(if cornerMax k⊆cornerGamma k then (if _ then 1 else 0)-(cornerSigma k/2)*(if cornerGamma k=cornerGamma k then 1 else 0) else 0)=_ + simp only [le_refl,ite_true,hn,ite_false,cornerMax_not_sub,mul_one,zero_add,mul_zero,add_zero] + ring +end SidorenkoCounterexample + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/Basic.lean b/lean/OAI/Combinatorics/Sidorenko/Basic.lean new file mode 100644 index 0000000000000000000000000000000000000000..4ef6eb75d078ab313bbf99538b5df35583f45135 --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/Basic.lean @@ -0,0 +1,36 @@ +import Mathlib + +namespace OAI + +namespace SidorenkoCounterexample + +def faces : Fin 22 → Finset (Fin 13) := ![ + {0,1,3}, {0,1,9}, {0,2,3}, {0,2,9}, {1,3,10}, {1,7,10}, + {1,7,12}, {1,9,12}, {2,3,4}, {2,4,9}, {3,4,11}, {3,10,11}, + {4,8,9}, {4,8,11}, {5,6,7}, {5,6,11}, {5,7,10}, {5,10,11}, + {6,7,12}, {6,8,11}, {6,8,12}, {8,9,12}] + +abbrev PatternVertex := Fin 13 ⊕ Fin 22 + +def incidence : PatternVertex → PatternVertex → Prop + | .inl i, .inr j => i ∈ faces j + | .inr j, .inl i => i ∈ faces j + | _, _ => False + +def H : SimpleGraph PatternVertex where + Adj := incidence + symm.symm := by intro u v; cases u <;> cases v <;> simp [incidence] + loopless.irrefl := by intro u; cases u <;> simp [incidence] + +noncomputable def homCount {V W : Type*} (F : SimpleGraph V) (G : SimpleGraph W) : ℕ := + Nat.card {f : V → W // ∀ u v, F.Adj u v → G.Adj (f u) (f v)} + +noncomputable def homDensity {V W : Type*} (F : SimpleGraph V) (G : SimpleGraph W) : ℝ := + (homCount F G : ℝ) / (Nat.card W : ℝ) ^ Nat.card V + +noncomputable def edgeDensity {W : Type*} (G : SimpleGraph W) : ℝ := + 2 * (Nat.card G.edgeSet : ℝ) / (Nat.card W : ℝ) ^ 2 + +end SidorenkoCounterexample + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/Charts.lean b/lean/OAI/Combinatorics/Sidorenko/Charts.lean new file mode 100644 index 0000000000000000000000000000000000000000..b5d14da69eb5831ce9ebccd62c48e1f385b5e268 --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/Charts.lean @@ -0,0 +1,588 @@ +import OAI.Combinatorics.Sidorenko.Monomials + +namespace OAI + + +section + +namespace SidorenkoCounterexample +open Module Classical Filter +open scoped BigOperators +section Mean +variable {A B : Type*} [Fintype A] [Fintype B] [Nonempty B] +theorem uniformMean_injection (i : A → B) (hi : Function.Injective i) (f : B → ℝ) + (hf : ∀ b,0≤f b) : uniformMean (f ∘ i) ≤ + ((Fintype.card B : ℝ)/Fintype.card A)*uniformMean f := by + classical + have hs : ∑ a, f (i a) ≤ ∑ b, f b := by + rw [←Finset.sum_image (fun a _ b _ h => hi h)] + exact Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) (fun b _ _ => hf b) + unfold uniformMean + dsimp only [Function.comp_def] + have hn : (Fintype.card B : ℝ)≠0 := by exact_mod_cast (Fintype.card_pos (α := B)).ne' + have he : ((Fintype.card B : ℝ)/Fintype.card A)*((∑ b,f b)/Fintype.card B)= + (∑ b,f b)/Fintype.card A := by + calc + _ = ((∑ b,f b)/Fintype.card A)*((Fintype.card B : ℝ)/Fintype.card B) := by ring + _ = _ := by rw [div_self hn,mul_one] + rw [he] + exact div_le_div_of_nonneg_right hs (Nat.cast_nonneg _) +end Mean +section Norm +variable {K : Type*} [Field K] [Fintype K] [DecidableEq K] +noncomputable def canonicalStratumMass (D r : ℕ) : ℝ := + (Nat.card (CenterStratum (K := K) (V := Fin D → K) r) : ℝ)/ + Nat.card (Lagrangian (K := K) (V := Fin D → K)) +noncomputable def chartRatio (D : ℕ) : ℝ := + (Nat.card (Lagrangian (K := K) (V := Fin D → K)) : ℝ)/ + Fintype.card (SymMatrix K D) + +omit [DecidableEq K] in +theorem chartRatio_nonneg (D : ℕ) : 0≤chartRatio (K := K) D := by unfold chartRatio; positivity + +omit [DecidableEq K] in +theorem chartRatio_bound (D : ℕ) : chartRatio (K := K) D≤lagrangianConstant D := by + have hc : (Fintype.card (SymMatrix K D) : ℝ)=(Fintype.card K : ℝ)^((D+1).choose 2) := by + rw [←Nat.card_eq_fintype_card,symMatrix_card,Nat.cast_pow] + have hn : (0 : ℝ)<(Fintype.card K : ℝ)^((D+1).choose 2) := by positivity + unfold chartRatio + rw [hc] + apply (div_le_iff₀ hn).mpr + simpa only [Module.finrank_pi,Fintype.card_fin] using lagrangian_card_upper (K := K) (V := Fin D → K) + +omit [DecidableEq K] in +theorem canonicalStratum_card (D r : ℕ) (hr : r≤D) : + Nat.card (CenterStratum (K := K) (V := Fin D → K) r) = + Nat.card (DimSubspace K (Fin D → K) (D-r)) * (Fintype.card K)^((D-r+1).choose 2) := by + have hD : r≤finrank K (Fin D → K) := by simpa only [Module.finrank_pi,Fintype.card_fin] using hr + have h := vertical_pair_count (K := K) (V := Fin D → K) r hD + simpa only [Module.finrank_pi,Fintype.card_fin,CenterStratum,DimSubspace] using h + +omit [DecidableEq K] in +theorem canonicalLag_card_pos (D : ℕ) : (0 : ℝ) ∏ k∈T, rankKernel K (2*r) r (ξ k) (X k-Y)) + +@[simp] theorem faceLocal_empty (r : ℕ) (ξ : Fin 3 → ℤ) (X : Fin 3 → SymMatrix K (2*r)) : + faceLocal r ∅ ξ X=1 := by simp [faceLocal,uniformMean_const] + +theorem faceLocal_singleton (hK : ringChar K≠2) (r : ℕ) (hr : 0 rankKernel K (2*r) r (ξ k) A * + rankKernel K (2*r) r (ξ l) (A-(X k-X l))) + +theorem faceLocal_full (r : ℕ) (ξ : Fin 3 → ℤ) (X : Fin 3 → SymMatrix K (2*r)) : + faceLocal r Finset.univ ξ X=tripleLocal r (ξ 0) (ξ 1) (ξ 2) (X 0-X 1) (X 0-X 2) := by + simp only [faceLocal,Fin.prod_univ_three,tripleLocal] + have h1 (Y : SymMatrix K (2*r)) : X 1-Y=(X 0-Y)-(X 0-X 1) := by abel + have h2 (Y : SymMatrix K (2*r)) : X 2-Y=(X 0-Y)-(X 0-X 2) := by abel + simp_rw [h1,h2] + exact uniformMean_subLeft (X 0) (fun A => rankKernel K (2*r) r (ξ 0) A * + rankKernel K (2*r) r (ξ 1) (A-(X 0-X 1))*rankKernel K (2*r) r (ξ 2) (A-(X 0-X 2))) + +noncomputable def pairPolynomial (r : ℕ) (ξ ζ : ℤ) (B : SymMatrix K (2*r)) : ℝ := + 1+(quadraticChar K ((-1 : K)^r) : ℝ)*(quadraticChar K B.val.det : ℝ)*(ξ : ℝ)*(ζ : ℝ) + +theorem signs_polynomial (c x ξ ζ : ℤ) (hc : c=1 ∨ c= -1) (hx : x=1 ∨ x= -1) + (hξ : ξ=1 ∨ ξ= -1) (hζ : ζ=1 ∨ ζ= -1) : + (1+(c : ℝ)*(x : ℝ)*(ξ : ℝ)*(ζ : ℝ))=(if x=c*ξ*ζ then 2 else 0) := by + rcases hc with rfl|rfl <;> rcases hx with rfl|rfl <;> + rcases hξ with rfl|rfl <;> rcases hζ with rfl|rfl <;> norm_num + +theorem pairPolynomial_eq (r : ℕ) {ξ ζ : ℤ} (hξ : ξ=1 ∨ ξ= -1) (hζ : ζ=1 ∨ ζ= -1) + (B : SymMatrix K (2*r)) (hB : B.val.det≠0) : + pairPolynomial r ξ ζ B=if pairMatch r ξ ζ B then 2 else 0 := by + have he := signs_polynomial _ _ _ _ (quadraticChar_dichotomy (F := K) (pow_ne_zero r (neg_ne_zero.mpr one_ne_zero))) + (quadraticChar_dichotomy hB) hξ hζ + unfold pairPolynomial pairMatch + split_ifs with hm + · rw [ite_eq_left hm] at he; exact he + · rw [ite_eq_right hm] at he; exact he + +noncomputable def facePolynomial (r : ℕ) (T : Finset (Fin 3)) (ξ : Fin 3 → ℤ) + (X : Fin 3 → SymMatrix K (2*r)) : ℝ := + (if 0∈T ∧ 1∈T then pairPolynomial r (ξ 0) (ξ 1) (X 0-X 1) else 1)* + (if 0∈T ∧ 2∈T then pairPolynomial r (ξ 0) (ξ 2) (X 0-X 2) else 1)* + (if 1∈T ∧ 2∈T then pairPolynomial r (ξ 1) (ξ 2) (X 1-X 2) else 1) + +def faceTransverse (r : ℕ) (X : Fin 3 → SymMatrix K (2*r)) : Prop := + (X 0-X 1).val.det≠0 ∧ (X 0-X 2).val.det≠0 ∧ (X 1-X 2).val.det≠0 + +theorem facePolynomial_full (r : ℕ) (ξ : Fin 3 → ℤ) (hξ : ∀ k, ξ k=1 ∨ ξ k= -1) + (X : Fin 3 → SymMatrix K (2*r)) (hX : faceTransverse r X) : + facePolynomial r Finset.univ ξ X= + if tripleMatch r (ξ 0) (ξ 1) (ξ 2) (X 0-X 1) (X 0-X 2) then 8 else 0 := by + unfold facePolynomial + simp only [Finset.mem_univ,and_self,ite_true] + rw [pairPolynomial_eq r (hξ 0) (hξ 1) _ hX.1, + pairPolynomial_eq r (hξ 0) (hξ 2) _ hX.2.1,pairPolynomial_eq r (hξ 1) (hξ 2) _ hX.2.2] + have he : X 0-X 2-(X 0-X 1)=X 1-X 2 := by abel + simp only [tripleMatch,he] + split_ifs <;> norm_num <;> tauto + +noncomputable def faceError (r : ℕ) (ξ : Fin 3 → ℤ) (X : Fin 3 → SymMatrix K (2*r)) : ℝ := + pairError r (ξ 0) (ξ 1) (X 0-X 1)+pairError r (ξ 0) (ξ 2) (X 0-X 2)+ + pairError r (ξ 1) (ξ 2) (X 1-X 2)+tripleError r (ξ 0) (ξ 1) (ξ 2) (X 0-X 1) (X 0-X 2) + +theorem faceError_nonneg (r : ℕ) (ξ : Fin 3 → ℤ) (X : Fin 3 → SymMatrix K (2*r)) : + 0≤faceError r ξ X := by + exact add_nonneg (add_nonneg (add_nonneg (pairError_nonneg ..) (pairError_nonneg ..)) + (pairError_nonneg ..)) (tripleError_nonneg ..) + +theorem faceLocal_error (hK : ringChar K≠2) (r : ℕ) (hr : 0 cases b <;> norm_num [boolSign] + +omit [DecidableEq I] in +theorem bool_indicator_product (η ε : I → Bool) : + (if η=ε then 1 else 0 : ℝ) = (2^Fintype.card I : ℝ)⁻¹ * + ∏ i, (1+boolSign (η i)*boolSign (ε i)) := by + simp_rw [bool_factor] + by_cases h : η=ε + · subst ε + simp + · rw [ite_eq_right h] + obtain ⟨i,hi⟩ := Function.ne_iff.mp h + have hp : (∏ i, (if η i=ε i then 2 else 0 : ℝ))=0 := + Finset.prod_eq_zero (Finset.mem_univ i) (ite_eq_right hi) + rw [hp,mul_zero] + +omit [DecidableEq I] in +theorem bool_indicator_expansion (η ε : I → Bool) : + (if η=ε then 1 else 0 : ℝ) = (2^Fintype.card I : ℝ)⁻¹ * + ∑ F : Finset I, boolMonomial F η * boolMonomial F ε := by + rw [bool_indicator_product,Finset.prod_one_add] + simp only [Finset.powerset_univ,Finset.prod_mul_distrib,boolMonomial] + +variable {A : Type*} [Fintype A] +omit [DecidableEq I] in +theorem bool_law_expansion (T : A → I → Bool) (ε : I → Bool) : + uniformMean (fun a => if T a=ε then 1 else 0)= + (2^Fintype.card I : ℝ)⁻¹ * ∑ F : Finset I, + (uniformMean fun a => boolMonomial F (T a))*boolMonomial F ε := by + simp_rw [bool_indicator_expansion] + rw [uniformMean_mul,uniformMean_sum] + simp_rw [uniformMean_mul_right] + +theorem uniformMean_test_fibers (T : A → I → Bool) (g : (I → Bool) → ℝ) : + uniformMean (fun a => g (T a))= + ∑ ε : I → Bool, g ε * uniformMean (fun a => if T a=ε then 1 else 0) := by + have he (a : A) : g (T a)=∑ ε : I → Bool, g ε*(if T a=ε then 1 else 0) := by simp + simp_rw [he] + rw [uniformMean_sum] + apply Finset.sum_congr rfl + intro ε _ + rw [uniformMean_mul] +end Boolean +section Convergence +variable {I Q : Type*} [Fintype I] [DecidableEq I] {l : Filter Q} + {A : Q → Type*} [∀ q, Fintype (A q)] [∀ q, Nonempty (A q)] + +theorem boolean_law_tendsto (T : (q : Q) → A q → I → Bool) + (h : ∀ F : Finset I, F.Nonempty → Tendsto + (fun q => uniformMean (fun a => boolMonomial F (T q a))) l (nhds 0)) + (ε : I → Bool) : Tendsto + (fun q => uniformMean (fun a => if T q a=ε then 1 else 0)) l + (nhds ((Fintype.card (I → Bool) : ℝ)⁻¹)) := by + have hm (F : Finset I) : Tendsto + (fun q => (uniformMean fun a => boolMonomial F (T q a))*boolMonomial F ε) l + (nhds (if F=∅ then (1:ℝ) else 0)) := by + by_cases hF : F=∅ + · subst F; simp only [boolMonomial_empty,uniformMean_const,mul_one,↓reduceIte]; exact tendsto_const_nhds + · simpa only [hF,ite_false,zero_mul] using (h F (Finset.nonempty_iff_ne_empty.mpr hF)).mul_const (boolMonomial F ε) + have hs := (tendsto_finsetSum Finset.univ (fun F _ => hm F)).const_mul ((2^Fintype.card I : ℝ)⁻¹) + simp only [Finset.sum_ite_eq',Finset.mem_univ,ite_true,mul_one] at hs + simp only [bool_law_expansion,Fintype.card_fun,Fintype.card_bool,Nat.cast_pow,Nat.cast_ofNat] + exact hs + +theorem boolean_test_tendsto (T : (q : Q) → A q → I → Bool) + (h : ∀ F : Finset I, F.Nonempty → Tendsto + (fun q => uniformMean (fun a => boolMonomial F (T q a))) l (nhds 0)) + (g : (I → Bool) → ℝ) : Tendsto + (fun q => uniformMean (fun a => g (T q a))) l (nhds (uniformMean g)) := by + have hm (ε : I → Bool) := (boolean_law_tendsto T h ε).const_mul (g ε) + have hs := tendsto_finsetSum Finset.univ (fun ε _ => hm ε) + have he (q : Q) : uniformMean (fun a => g (T q a)) = + ∑ ε : I → Bool, g ε * uniformMean (fun a => if T q a=ε then 1 else 0) := + uniformMean_test_fibers (T q) g + simp only [he] + convert hs using 1 + simp only [uniformMean,div_eq_mul_inv,Finset.sum_mul] +end Convergence + +theorem pairBool_test_tendsto (D : ℕ) (hD : Even D) (hbig : 12≤D) (g : (Fin 33 → Bool) → ℝ) : + Tendsto (fun q : OddPrime => uniformMean (fun X : Fin 13 → SymMatrix (ZMod q.val) D => + g (pairBool X))) primeInfinity (nhds (uniformMean g)) := by + have hm (F : Finset (Fin 33)) (hF : F.Nonempty) : + Tendsto (fun q : OddPrime => uniformMean (fun X : Fin 13 → SymMatrix (ZMod q.val) D => + boolMonomial F (pairBool X))) primeInfinity (nhds 0) := by + simpa only [boolMonomial] using pairBool_moment_tendsto D hD hbig F hF + exact boolean_test_tendsto (I := Fin 33) (Q := OddPrime) (l := primeInfinity) + (A := fun q : OddPrime => Fin 13 → SymMatrix (ZMod q.val) D) + (fun (q : OddPrime) (X : Fin 13 → SymMatrix (ZMod q.val) D) => pairBool X) hm g +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module Classical Filter +open scoped BigOperators +section Means +variable {K I W : Type*} [Field K] [Fintype I] [DecidableEq I] + [AddCommGroup W] [Module K W] [Fintype W] +include K in +theorem uniformMean_two_differences (v : Fin 3 → I) (hv : Function.Injective v) (f : W → W → ℝ) : + uniformMean (fun X : I → W => f (X (v 0)-X (v 1)) (X (v 0)-X (v 2)))= + uniformMean (fun B : W => uniformMean (f B)) := by + let k : Fin 2 → I := fun j => v j.succ + have hk : Function.Injective k := hv.comp (Fin.succ_injective 2) + have hn : ∀ j, k j≠v 0 := fun j => hv.ne (Fin.succ_ne_zero j) + have he := uniformMean_starDifference (K := K) (W := W) (v 0) k hk hn (fun M => f (M 0) (M 1)) + change uniformMean (fun X : I → W => f (X (v 0)-X (v 1)) (X (v 0)-X (v 2))) = + uniformMean (fun M : Fin 2 → W => f (M 0) (M 1)) at he + rw [he,←uniformMean_equiv (finTwoArrowEquiv W).symm,uniformMean_prod] + rfl +end Means +section Bounds +variable {K : Type*} [Field K] [Fintype K] [DecidableEq K] +noncomputable def faceBound (r : ℕ) (ξ : Fin 3 → ℤ) : ℝ := 1+ + pairCoefficient (K := K) r (ξ 0) (ξ 1)+pairCoefficient (K := K) r (ξ 0) (ξ 2)+ + pairCoefficient (K := K) r (ξ 1) (ξ 2)+tripleCoefficient (K := K) r (ξ 0) (ξ 1) (ξ 2) + +theorem faceBound_one (r : ℕ) (ξ : Fin 3 → ℤ) : 1≤faceBound (K := K) r ξ := by + have := pairCoefficient_nonneg (K := K) r (ξ 0) (ξ 1) + have := pairCoefficient_nonneg (K := K) r (ξ 0) (ξ 2) + have := pairCoefficient_nonneg (K := K) r (ξ 1) (ξ 2) + have := tripleCoefficient_nonneg (K := K) r (ξ 0) (ξ 1) (ξ 2) + unfold faceBound; linarith + +theorem faceLocal_nonneg (r : ℕ) (T : Finset (Fin 3)) (ξ : Fin 3 → ℤ) + (X : Fin 3 → SymMatrix K (2*r)) : 0≤faceLocal r T ξ X := by + exact uniformMean_nonneg fun Y => Finset.prod_nonneg fun k _ => rankKernel_nonneg .. + +theorem faceLocal_bound (hK : ringChar K≠2) (r : ℕ) (hr : 0 norm_num + +theorem facePolynomial_abs_le (r : ℕ) (T : Finset (Fin 3)) (ξ : Fin 3 → ℤ) + (hξ : ∀ k, ξ k=1 ∨ ξ k= -1) (X : Fin 3 → SymMatrix K (2*r)) : + |facePolynomial r T ξ X|≤8 := by + have hpair (k l : Fin 3) : |if k∈T ∧ l∈T then pairPolynomial r (ξ k) (ξ l) (X k-X l) else 1|≤2 := by + split + · exact pairPolynomial_abs_le r (hξ k) (hξ l) _ + · norm_num + unfold facePolynomial + rw [abs_mul,abs_mul] + have ha := mul_le_mul (hpair 0 1) (hpair 0 2) (abs_nonneg _) (by norm_num : (0:ℝ)≤2) + have hb := mul_le_mul ha (hpair 1 2) (abs_nonneg _) (by norm_num : (0:ℝ)≤2*2) + norm_num only at hb + exact hb +end Bounds + +theorem faceBound_tendsto (r : ℕ) (hr : 0 faceBound (K := ZMod q.val) r ξ) primeInfinity (nhds 29) := by + have h01 := pairCoefficient_tendsto r hr (hξ 0) (hξ 1) + have h02 := pairCoefficient_tendsto r hr (hξ 0) (hξ 2) + have h12 := pairCoefficient_tendsto r hr (hξ 1) (hξ 2) + have ht := tripleCoefficient_tendsto r hr (hξ 0) (hξ 1) (hξ 2) + simpa only [faceBound,show (1:ℝ)+4+4+4+16=29 by norm_num] using + (((h01.const_add 1).add h02).add h12).add ht + +theorem faceError_mean_tendsto (r : ℕ) (hr : 1 uniformMean (fun X : Fin 13 → SymMatrix (ZMod q.val) (2*r) => + faceError r ξ (X ∘ v))) primeInfinity (nhds 0) := by + have he (q : OddPrime) : uniformMean (fun X : Fin 13 → SymMatrix (ZMod q.val) (2*r) => + faceError r ξ (X ∘ v)) = uniformMean (pairError (K := ZMod q.val) r (ξ 0) (ξ 1))+ + uniformMean (pairError (K := ZMod q.val) r (ξ 0) (ξ 2))+ + uniformMean (pairError (K := ZMod q.val) r (ξ 1) (ξ 2))+ + uniformMean (fun B => uniformMean (fun C => tripleError (K := ZMod q.val) r (ξ 0) (ξ 1) (ξ 2) B C)) := by + simp only [faceError,Function.comp_def,uniformMean_add] + rw [uniformMean_point_difference (K := ZMod q.val) _ _ (hv.ne (by decide)) (pairError r (ξ 0) (ξ 1)), + uniformMean_point_difference (K := ZMod q.val) _ _ (hv.ne (by decide)) (pairError r (ξ 0) (ξ 2)), + uniformMean_point_difference (K := ZMod q.val) _ _ (hv.ne (by decide)) (pairError r (ξ 1) (ξ 2)), + uniformMean_two_differences (K := ZMod q.val) v hv (tripleError r (ξ 0) (ξ 1) (ξ 2))] + simp only [he] + have h := (((pairError_tendsto r (by omega) (hξ 0) (hξ 1)).add + (pairError_tendsto r (by omega) (hξ 0) (hξ 2))).add + (pairError_tendsto r (by omega) (hξ 1) (hξ 2))).add + (tripleError_tendsto r hr (hξ 0) (hξ 1) (hξ 2)) + simpa only [add_zero] using h +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module Classical +open scoped BigOperators +section ChartFace +variable {K : Type*} [Field K] [Fintype K] [DecidableEq K] +abbrev CanonicalLag (D : ℕ) := Lagrangian (K := K) (V := Fin D → K) +instance canonicalDual_finite (D : ℕ) : Finite (Module.Dual K (Fin D → K)) := + Finite.of_injective (fun f : Module.Dual K (Fin D → K) => (f : (Fin D → K) → K)) DFunLike.coe_injective +noncomputable def canonicalKernel (D r : ℕ) (A Y : CanonicalLag (K := K) D) : ℝ := + if finrank K ↥(A.val⊓Y.val)=r then (canonicalStratumMass (K := K) D r)⁻¹ else 0 + +omit [Fintype K] [DecidableEq K] in +theorem canonicalKernel_nonneg (D r : ℕ) (A Y : CanonicalLag (K := K) D) : + 0≤canonicalKernel D r A Y := by + unfold canonicalKernel canonicalStratumMass + split <;> positivity + +theorem rankKernel_chart_bound (r : ℕ) (ξ : ℤ) (A Y : SymMatrix K (2*r)) {C : ℝ} + (hC : 0≤C) (hξ : canonicalStratumMass (K := K) (2*r) r / layerMass K (2*r) r ξ≤C) : + rankKernel K (2*r) r ξ (A-Y) ≤ C*canonicalKernel (2*r) r (matrixLagrangian A) (matrixLagrangian Y) := by + have hm := canonicalStratumMass_pos (K := K) (2*r) r (by omega) + unfold rankKernel + split_ifs with hAY + · have hrank : (A-Y).val.rank=r := (Finset.mem_filter.mp hAY).2.1 + have hdim := matrixLagrangian_pair_rank (2*r) A Y + have hi : finrank K ↥((matrixLagrangian A).val⊓(matrixLagrangian Y).val)=r := by omega + rw [canonicalKernel,ite_eq_left hi] + have he : (layerMass K (2*r) r ξ)⁻¹ = + (canonicalStratumMass (K := K) (2*r) r / layerMass K (2*r) r ξ) * + (canonicalStratumMass (K := K) (2*r) r)⁻¹ := by field_simp + rw [he] + exact mul_le_mul_of_nonneg_right hξ (inv_nonneg.mpr hm.le) + · exact mul_nonneg hC (canonicalKernel_nonneg ..) + +omit [Fintype K] [DecidableEq K] in +theorem canonicalKernel_prod (D r : ℕ) (L : Fin 3 → CanonicalLag (K := K) D) + (T : Finset (Fin 3)) (Y : CanonicalLag (K := K) D) : + (∏ i∈T, canonicalKernel D r (L i) Y)= + (if ∀ i∈T,finrank K ↥((L i).val⊓Y.val)=r then 1 else 0)* + ((canonicalStratumMass (K := K) D r)⁻¹)^T.card := by + by_cases h : ∀ i∈T,finrank K ↥((L i).val⊓Y.val)=r + · rw [ite_eq_left h,one_mul] + calc + _ = ∏ _i∈T, (canonicalStratumMass (K := K) D r)⁻¹ := + Finset.prod_congr rfl (fun i hi => by rw [canonicalKernel,ite_eq_left (h i hi)]) + _ = _ := by rw [Finset.prod_const] + · rw [ite_eq_right h,zero_mul] + push Not at h + obtain ⟨i,hi,hh⟩ := h + exact Finset.prod_eq_zero hi (by rw [canonicalKernel,ite_eq_right hh]) + +omit [Fintype K] [DecidableEq K] in +theorem canonicalKernel_mean (D r : ℕ) [Fintype (CanonicalLag (K := K) D)] + (L : Fin 3 → CanonicalLag (K := K) D) (T : Finset (Fin 3)) : + uniformMean (fun Y => ∏ i∈T, canonicalKernel D r (L i) Y)= + activeFaceDensity (canonicalSymplectic (K := K) (V := Fin D → K)) r + (verticalLagrangian (K := K) (V := Fin D → K)) L T := by + simp_rw [canonicalKernel_prod] + rw [uniformMean_mul_right,uniformMean_indicator] + unfold activeFaceDensity canonicalStratumMass + simp only [inv_div,Nat.card_eq_fintype_card] + rfl + +theorem faceLocal_chart_bound (r : ℕ) (T : Finset (Fin 3)) (ξ : Fin 3 → ℤ) + (X : Fin 3 → SymMatrix K (2*r)) {C : ℝ} (hC : 1≤C) + (hξ : ∀ i∈T, canonicalStratumMass (K := K) (2*r) r / layerMass K (2*r) r (ξ i)≤C) : + faceLocal r T ξ X ≤ C^3 * lagrangianConstant (2*r) * + activeFaceDensity (canonicalSymplectic (K := K) (V := Fin (2*r) → K)) r + (verticalLagrangian (K := K) (V := Fin (2*r) → K)) (matrixLagrangian ∘ X) T := by + let := Fintype.ofFinite (CanonicalLag (K := K) (2*r)) + let : Nonempty (CanonicalLag (K := K) (2*r)) := ⟨verticalLagrangian⟩ + let f (Y : CanonicalLag (K := K) (2*r)) := ∏ i∈T, canonicalKernel (2*r) r (matrixLagrangian (X i)) Y + have hf (Y) : 0≤f Y := Finset.prod_nonneg (fun i _ => canonicalKernel_nonneg ..) + have hp (Y : SymMatrix K (2*r)) : (∏ i∈T,rankKernel K (2*r) r (ξ i) (X i-Y))≤C^3*f (matrixLagrangian Y) := by + calc + _ ≤ ∏ i∈T,C*canonicalKernel (2*r) r (matrixLagrangian (X i)) (matrixLagrangian Y) := + Finset.prod_le_prod₀ (fun _ _ => rankKernel_nonneg ..) + (fun i hi => rankKernel_chart_bound r (ξ i) (X i) Y (by linarith) (hξ i hi)) + _ = C^T.card*f (matrixLagrangian Y) := by rw [Finset.prod_mul_distrib,Finset.prod_const] + _ ≤ _ := mul_le_mul_of_nonneg_right (pow_le_pow_right₀ hC (by have := Finset.card_le_univ T; simpa using this)) (hf _) + have hi := uniformMean_injection (matrixLagrangian (K := K) (D := 2*r)) + (matrixLagrangian_injective (2*r)) f hf + have he : ((Fintype.card (CanonicalLag (K := K) (2*r)) : ℝ)/Fintype.card (SymMatrix K (2*r)))= + chartRatio (K := K) (2*r) := by rw [chartRatio,Nat.card_eq_fintype_card] + rw [he] at hi + change faceLocal r T ξ X ≤ _ + calc + _ ≤ C^3*uniformMean (f ∘ matrixLagrangian) := by + rw [←uniformMean_mul]; exact uniformMean_mono hp + _ ≤ C^3*(chartRatio (K := K) (2*r)*uniformMean f) := + mul_le_mul_of_nonneg_left hi (by positivity) + _ ≤ C^3*(lagrangianConstant (2*r)*uniformMean f) := + mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right (chartRatio_bound (2*r)) (uniformMean_nonneg hf)) (by positivity) + _ = _ := by rw [show uniformMean f=activeFaceDensity (canonicalSymplectic (K := K) (V := Fin (2*r) → K)) r + (verticalLagrangian (K := K) (V := Fin (2*r) → K)) (matrixLagrangian ∘ X) T from canonicalKernel_mean (2*r) r _ T]; ring +end ChartFace +end SidorenkoCounterexample + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/Coefficients.lean b/lean/OAI/Combinatorics/Sidorenko/Coefficients.lean new file mode 100644 index 0000000000000000000000000000000000000000..71ce7790c1cc53b730db39ad58643d8f9dee14b1 --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/Coefficients.lean @@ -0,0 +1,804 @@ +import OAI.Combinatorics.Sidorenko.Activation + +namespace OAI + + +section + +namespace SidorenkoCounterexample +open Classical +open scoped BigOperators symmDiff +section Coefficients +variable {K : Type*} [Fintype K] [DecidableEq K] +noncomputable def labelProduct (A : ActCorner → Finset K → Finset K → ℝ) (α : Fin 33 → Finset K) : ℝ := + ∏ k,A k (α (cornerPairL k)) (α (cornerPairR k)) +noncomputable def nonemptyLabels : Finset (Fin 33 → Finset K) := Finset.univ.filter (fun α => ∀ e,α e≠∅) +lemma mem_nonemptyLabels (α : Fin 33 → Finset K) : α∈nonemptyLabels ↔ ∀ e,α e≠∅ := by + simp only [nonemptyLabels,Finset.mem_filter,Finset.mem_univ,true_and] +noncomputable def activeCoefficient (A : ActCorner → Finset K → Finset K → ℝ) : ℝ := + ∑ α∈nonemptyLabels,labelProduct A α + +omit [Fintype K] [DecidableEq K] in +lemma labelProduct_nonzero (A : ActCorner → Finset K → Finset K → ℝ) (α : Fin 33 → Finset K) + (h : labelProduct A α≠0) (k : ActCorner) : A k (α (cornerPairL k)) (α (cornerPairR k))≠0 := + (Finset.prod_ne_zero_iff.mp h) k (Finset.mem_univ k) + +lemma empty_propagation (P : Fin 33 → Prop) (hs : ∀ j p q,P (facePair j p) ↔ P (facePair j q)) : + ∀ e,P e ↔ P 0 := by + have hstep (e : Fin 33) : P e ↔ P (pairParent e) := by + obtain ⟨i,hi⟩ := (facePair_correct (pairBridge e) e).mp (pairBridge_self e) + obtain ⟨k,hk⟩ := (facePair_correct (pairBridge e) (pairParent e)).mp (pairBridge_parent e) + simpa only [hi,hk] using hs (pairBridge e) i k + have hmain : ∀ m,∀ e : Fin 33,e.val=m → (P e ↔ P 0) := by + intro m + induction m using Nat.strong_induction_on with + | h m ih => + intro e hem + by_cases he : e=0 + · subst e; rfl + · exact (hstep e).trans (ih _ (by simpa only [hem] using pairParent_lt e he) _ rfl) + intro e; exact hmain e.val e rfl + +lemma labelProduct_empty_dichotomy (p : ActCorner → FiniteLaw (Activation K)) + (hp : ∀ k α,α≠∅ → (p k).mean (activationPhi α)=0) (α : Fin 33 → Finset K) + (h : labelProduct (fun k => activationMoment (p k)) α≠0) : + (∀ e,α e=∅) ∨ (∀ e,α e≠∅) := by + have hs (k : ActCorner) : α (cornerPairL k)=∅ ↔ α (cornerPairR k)=∅ := by + have hn := labelProduct_nonzero _ _ h k + constructor + · intro he + by_contra hr + rw [he,activationMoment] at hn + simp only [activationPhi_empty,one_mul] at hn + exact hn (hp k _ hr) + · intro he + by_contra hl + rw [he,activationMoment] at hn + simp only [activationPhi_empty,mul_one] at hn + exact hn (hp k _ hl) + have hf (j : Fin 22) (a b : Fin 3) : α (facePair j a)=∅ ↔ α (facePair j b)=∅ := by + have h0 := hs (j,0); have h1 := hs (j,1); have h2 := hs (j,2) + change (α (facePair j 0)=∅ ↔ α (facePair j 1)=∅) at h0 + change (α (facePair j 0)=∅ ↔ α (facePair j 2)=∅) at h1 + change (α (facePair j 1)=∅ ↔ α (facePair j 2)=∅) at h2 + fin_cases a <;> fin_cases b <;> tauto + have ht := empty_propagation (fun e => α e=∅) hf + by_cases hz : α 0=∅ + · exact Or.inl (fun e => (ht e).mpr hz) + · exact Or.inr (fun e he => hz ((ht e).mp he)) + +lemma allCoefficient_eq (p : ActCorner → FiniteLaw (Activation K)) + (hp : ∀ k α,α≠∅ → (p k).mean (activationPhi α)=0) : + (∑ α : Fin 33 → Finset K,labelProduct (fun k => activationMoment (p k)) α)= + 1+activeCoefficient (fun k => activationMoment (p k)) := by + classical + let z : Fin 33 → Finset K := fun _ => ∅ + have hz : z∉(nonemptyLabels : Finset (Fin 33 → Finset K)) := by simp [nonemptyLabels,z] + have hi : (insert z nonemptyLabels : Finset (Fin 33 → Finset K))⊆Finset.univ := Finset.subset_univ _ + have he := Finset.sum_subset hi (f := labelProduct (fun k => activationMoment (p k))) + rw [←he,Finset.sum_insert hz] + · simp [labelProduct,z,activeCoefficient] + · intro α _ hα + by_contra hn + rcases labelProduct_empty_dichotomy p hp α hn with h|h + · have : α=z := funext h + exact hα (by simp [this]) + · exact hα (Finset.mem_insert_of_mem (by simpa [nonemptyLabels] using h)) +lemma activeCoefficient_unique (A : ActCorner → Finset K → Finset K → ℝ) + (α₀ : Fin 33 → Finset K) (h₀ : ∀ e,α₀ e≠∅) + (hu : ∀ α,(∀ e,α e≠∅) → labelProduct A α≠0 → α=α₀) : + activeCoefficient A=labelProduct A α₀ := by + unfold activeCoefficient + apply Finset.sum_eq_single α₀ + · intro α hα hne + by_contra hn + exact hne (hu α ((mem_nonemptyLabels α).mp hα) hn) + · intro hn; exact (hn ((mem_nonemptyLabels α₀).mpr h₀)).elim + +end Coefficients + +lemma identity_labels_forced (α : Fin 33 → Finset ActCorner) (hne : ∀ e,α e≠∅) + (h : labelProduct (fun k => activationMoment (cornerLaw k)) α≠0) : α=pairCorners := by + have hl (k : ActCorner) := labelProduct_nonzero _ _ h k + have hsub (e : Fin 33) : α e⊆pairCorners e := by + intro k hk + apply (corner_support e k).mp + intro b hb + have hs := cornerLaw_support b _ _ (hl b) + rcases (pairCorners_mem b e).mp hb with hb|hb + · exact hs (Finset.mem_union_left _ (by simpa only [hb] using hk)) + · exact hs (Finset.mem_union_right _ (by simpa only [hb] using hk)) + have hmem (k : ActCorner) : k∈α (cornerPairL k) ∧ k∈α (cornerPairR k) := by + have hd : ¬Disjoint (α (cornerPairL k)) (α (cornerPairR k)) := by + intro hd + apply hl k + exact cornerLaw_disjoint k _ _ hd (fun he => hne _ ((Finset.union_eq_empty.mp he).1)) + obtain ⟨b,hbl,hbr⟩ := Finset.not_disjoint_iff.mp hd + have hb : b∈pairCorners (cornerPairL k) ∩ pairCorners (cornerPairR k) := + Finset.mem_inter.mpr ⟨hsub _ hbl,hsub _ hbr⟩ + rw [pairCorners_inter,Finset.mem_singleton] at hb + simpa only [hb] using And.intro hbl hbr + funext e + apply Finset.Subset.antisymm (hsub e) + intro k hk + rcases (pairCorners_mem k e).mp hk with hk|hk + · simpa only [hk] using (hmem k).1 + · simpa only [hk] using (hmem k).2 + +lemma identity_labelProduct : labelProduct (fun k => activationMoment (cornerLaw k)) pairCorners= -(1/4:ℝ)^66 := by + unfold labelProduct + simp_rw [cornerLaw_value,div_eq_mul_inv] + rw [Finset.prod_mul_distrib] + have hs : (∏ k : ActCorner,cornerSigma k)= -1 := by + rw [Finset.prod_eq_single (0,0)] + · simp [cornerSigma] + · intro b _ hb; simp [cornerSigma,hb] + · simp + rw [hs] + simp [Fintype.card_prod] + +lemma pairCorners_nonempty (e : Fin 33) : pairCorners e≠∅ := by + intro he + have := pairCorners_card e + rw [he] at this + simp at this + +lemma identity_activeCoefficient : activeCoefficient (fun k => activationMoment (cornerLaw k))= -(1/4:ℝ)^66 := by + rw [activeCoefficient_unique _ pairCorners pairCorners_nonempty identity_labels_forced] + exact identity_labelProduct +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Classical +open scoped BigOperators +variable {K : Type*} [Fintype K] [DecidableEq K] +noncomputable def activationEntry (z : Activation K) (k : K) : ℝ := if k∈z.1 then boolSign (z.2 k) else 0 +omit [Fintype K] in +lemma activationPhi_product (α : Finset K) (z : Activation K) : + activationPhi α z=∏ k∈α,activationEntry z k := by + unfold activationPhi + by_cases h : α⊆z.1 + · simp only [h,ite_true,boolMonomial] + apply Finset.prod_congr rfl; intro k hk + simp only [activationEntry,h hk,ite_true] + · rw [ite_eq_right h] + obtain ⟨k,hk,hz⟩ := Finset.not_subset.mp h + symm; apply Finset.prod_eq_zero hk + simp only [activationEntry,hz,ite_false] +omit [Fintype K] in +lemma activationEntry_abs (z : Activation K) (k : K) : |activationEntry z k|≤1 := by + unfold activationEntry; split <;> simp +lemma bool_double_mean (a b : ℝ) : uniformMean (fun η : Bool => (1+boolSign η*a)*(1+boolSign η*b))=1+a*b := by + simp [uniformMean,Fintype.card_bool,boolSign] + ring +omit [DecidableEq K] in +lemma product_one_add_expansion {I : Type*} [Fintype I] [DecidableEq I] (f : I → K → ℝ) : + (∏ i,∏ k,(1+f i k))=∑ α : I → Finset K,∏ i,∏ k∈α i,f i k := by + simp_rw [Finset.prod_one_add,Finset.powerset_univ] + exact Fintype.prod_sum _ +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Classical +open scoped BigOperators +def faceSlot : Fin 33 → Fin 2 → Fin 3 := ![![0, 0], ![1, 1], ![2, 0], ![1, 1], ![2, 1], ![0, 0], ![2, 0], ![1, 0], ![2, 0], ![2, 0], ![2, 1], ![1, 1], ![2, 0], ![1, 1], ![2, 1], ![1, 1], ![2, 2], ![0, 0], ![2, 0], ![0, 0], ![2, 2], ![2, 2], ![2, 2], ![2, 2], ![2, 1], ![1, 0], ![1, 0], ![1, 1], ![0, 0], ![2, 1], ![2, 0], ![1, 1], ![0, 0]] +def faceSide : Fin 22 → Fin 3 → Fin 2 := ![![0, 0, 0], ![1, 0, 0], ![0, 1, 0], ![1, 1, 0], ![1, 0, 0], ![0, 1, 0], ![1, 0, 0], ![1, 1, 0], ![1, 0, 0], ![1, 1, 0], ![1, 0, 0], ![1, 1, 0], ![0, 1, 0], ![1, 1, 0], ![0, 0, 0], ![1, 0, 0], ![1, 0, 1], ![1, 1, 1], ![1, 0, 1], ![0, 1, 1], ![1, 1, 0], ![1, 1, 1]] +theorem faceSlot_correct : ∀ e b,facePair (pairFace e b) (faceSlot e b)=e := by decide +theorem faceSide_correct : ∀ j k,pairFace (facePair j k) (faceSide j k)=j := by decide +theorem faceSlot_side : ∀ j k,faceSlot (facePair j k) (faceSide j k)=k := by decide +theorem faceSide_slot : ∀ e b,faceSide (pairFace e b) (faceSlot e b)=b := by decide + +def occurrencePairEquiv : (Fin 22 × Fin 3) ≃ (Fin 33 × Fin 2) where + toFun a := (facePair a.1 a.2,faceSide a.1 a.2) + invFun b := (pairFace b.1 b.2,faceSlot b.1 b.2) + left_inv a := by simp only [faceSide_correct,faceSlot_side] + right_inv b := by simp only [faceSlot_correct,faceSide_slot] + +def pairCorner (e : Fin 33) (a : Fin 2 × Fin 2) : ActCorner := + (pairFace e a.1,if a.2=0 then slotLeft (faceSlot e a.1) else slotRight (faceSlot e a.1)) +lemma pairCorner_image_0 : Finset.univ.image (pairCorner 0)=pairCorners 0 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_1 : Finset.univ.image (pairCorner 1)=pairCorners 1 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_2 : Finset.univ.image (pairCorner 2)=pairCorners 2 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_3 : Finset.univ.image (pairCorner 3)=pairCorners 3 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_4 : Finset.univ.image (pairCorner 4)=pairCorners 4 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_5 : Finset.univ.image (pairCorner 5)=pairCorners 5 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_6 : Finset.univ.image (pairCorner 6)=pairCorners 6 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_7 : Finset.univ.image (pairCorner 7)=pairCorners 7 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_8 : Finset.univ.image (pairCorner 8)=pairCorners 8 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_9 : Finset.univ.image (pairCorner 9)=pairCorners 9 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_10 : Finset.univ.image (pairCorner 10)=pairCorners 10 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_11 : Finset.univ.image (pairCorner 11)=pairCorners 11 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_12 : Finset.univ.image (pairCorner 12)=pairCorners 12 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_13 : Finset.univ.image (pairCorner 13)=pairCorners 13 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_14 : Finset.univ.image (pairCorner 14)=pairCorners 14 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_15 : Finset.univ.image (pairCorner 15)=pairCorners 15 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_16 : Finset.univ.image (pairCorner 16)=pairCorners 16 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_17 : Finset.univ.image (pairCorner 17)=pairCorners 17 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_18 : Finset.univ.image (pairCorner 18)=pairCorners 18 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_19 : Finset.univ.image (pairCorner 19)=pairCorners 19 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_20 : Finset.univ.image (pairCorner 20)=pairCorners 20 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_21 : Finset.univ.image (pairCorner 21)=pairCorners 21 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_22 : Finset.univ.image (pairCorner 22)=pairCorners 22 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_23 : Finset.univ.image (pairCorner 23)=pairCorners 23 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_24 : Finset.univ.image (pairCorner 24)=pairCorners 24 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_25 : Finset.univ.image (pairCorner 25)=pairCorners 25 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_26 : Finset.univ.image (pairCorner 26)=pairCorners 26 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_27 : Finset.univ.image (pairCorner 27)=pairCorners 27 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_28 : Finset.univ.image (pairCorner 28)=pairCorners 28 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_29 : Finset.univ.image (pairCorner 29)=pairCorners 29 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_30 : Finset.univ.image (pairCorner 30)=pairCorners 30 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_31 : Finset.univ.image (pairCorner 31)=pairCorners 31 := by + rw [pairCorners_table] + decide +lemma pairCorner_image_32 : Finset.univ.image (pairCorner 32)=pairCorners 32 := by + rw [pairCorners_table] + decide +theorem pairCorner_image (e : Fin 33) : Finset.univ.image (pairCorner e)=pairCorners e := by + fin_cases e + · exact pairCorner_image_0 + · exact pairCorner_image_1 + · exact pairCorner_image_2 + · exact pairCorner_image_3 + · exact pairCorner_image_4 + · exact pairCorner_image_5 + · exact pairCorner_image_6 + · exact pairCorner_image_7 + · exact pairCorner_image_8 + · exact pairCorner_image_9 + · exact pairCorner_image_10 + · exact pairCorner_image_11 + · exact pairCorner_image_12 + · exact pairCorner_image_13 + · exact pairCorner_image_14 + · exact pairCorner_image_15 + · exact pairCorner_image_16 + · exact pairCorner_image_17 + · exact pairCorner_image_18 + · exact pairCorner_image_19 + · exact pairCorner_image_20 + · exact pairCorner_image_21 + · exact pairCorner_image_22 + · exact pairCorner_image_23 + · exact pairCorner_image_24 + · exact pairCorner_image_25 + · exact pairCorner_image_26 + · exact pairCorner_image_27 + · exact pairCorner_image_28 + · exact pairCorner_image_29 + · exact pairCorner_image_30 + · exact pairCorner_image_31 + · exact pairCorner_image_32 +theorem pairCorner_inj (e : Fin 33) : Function.Injective (pairCorner e) := by + intro a b h + have h1 := pairFace_injective e (congrArg Prod.fst h) + rcases a with ⟨a,c⟩; rcases b with ⟨b,d⟩ + dsimp at h1; subst b + have h2 := congrArg Prod.snd h + have hn : slotLeft (faceSlot e a)≠slotRight (faceSlot e a) := by + have hn : ∀ k : Fin 3,slotLeft k≠slotRight k := by decide + exact hn _ + have : c=d := by fin_cases c <;> fin_cases d <;> simp_all [pairCorner] + subst d; rfl + +theorem pairCorners_product (e : Fin 33) (f : ActCorner → ℝ) : + (∏ k∈pairCorners e,f k)=∏ b : Fin 2, + f (pairFace e b,slotLeft (faceSlot e b))*f (pairFace e b,slotRight (faceSlot e b)) := by + rw [←pairCorner_image,Finset.prod_image (fun _ _ _ _ h => pairCorner_inj e h),Fintype.prod_prod_type] + apply Finset.prod_congr rfl; intro b _ + simp [Fin.prod_univ_two,pairCorner] +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Classical +open scoped BigOperators +section +variable {I L A : Type*} [Fintype I] [DecidableEq I] [Fintype L] [Fintype A] +lemma FiniteLaw.mean_expansion_product (p : I → FiniteLaw A) (f : L → I → A → ℝ) + (g : (I → A) → ℝ) (c : L → ℝ) (hg : ∀ z,g z=∑ l,∏ i,f l i (z i)) + (hc : ∀ l,(∏ i,(p i).mean (f l i))=c l) : + (FiniteLaw.independent p).mean g=∑ l,c l := by + calc + _ = (FiniteLaw.independent p).mean (fun z => ∑ l,∏ i,f l i (z i)) := FiniteLaw.mean_congr _ hg + _ = ∑ l,(FiniteLaw.independent p).mean (fun z => ∏ i,f l i (z i)) := FiniteLaw.mean_sum _ _ + _ = _ := Finset.sum_congr rfl (fun l _ => (FiniteLaw.independent_mean_product p (f l)).trans (hc l)) +lemma uniformMean_double_product (a b : I → ℝ) : + uniformMean (fun η : I → Bool => ∏ i,(1+boolSign (η i)*a i)*(1+boolSign (η i)*b i))= + ∏ i,(1+a i*b i) := by + rw [uniformMean_pi_product (fun i η => (1+boolSign η*a i)*(1+boolSign η*b i))] + simp_rw [bool_double_mean] +end +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Classical +open scoped BigOperators +variable {K : Type*} [Fintype K] [DecidableEq K] +lemma activationMoment_product (p : ActCorner → FiniteLaw (Activation K)) (α : Fin 33 → Finset K) : + (∏ k,(p k).mean (fun z => activationPhi (α (cornerPairL k)) z*activationPhi (α (cornerPairR k)) z))= + labelProduct (fun k => activationMoment (p k)) α := by rfl +lemma mean_activation_expansion (p : ActCorner → FiniteLaw (Activation K)) (g : (ActCorner → Activation K) → ℝ) + (hg : ∀z,g z=∑ α : Fin 33 → Finset K,∏ k,activationPhi (α (cornerPairL k)) (z k)*activationPhi (α (cornerPairR k)) (z k)) : + (FiniteLaw.independent p).mean g=∑ α : Fin 33 → Finset K,labelProduct (fun k => activationMoment (p k)) α := by + exact FiniteLaw.mean_expansion_product (I := ActCorner) (L := Fin 33 → Finset K) (A := Activation K) p + (fun α k z => activationPhi (α (cornerPairL k)) z*activationPhi (α (cornerPairR k)) z) + g (labelProduct (fun k => activationMoment (p k))) hg (activationMoment_product p) +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Classical +open scoped BigOperators +section Expansion +variable {K : Type*} [Fintype K] [DecidableEq K] + +omit [Fintype K] in +lemma labels_incidence_product (α : Fin 33 → Finset K) (z : ActCorner → Activation K) : + (∏ e,∏ κ∈α e,∏ k∈pairCorners e,activationEntry (z k) κ)= + ∏ k,activationPhi (α (cornerPairL k)) (z k)*activationPhi (α (cornerPairR k)) (z k) := by + have he (e : Fin 33) : (∏ κ∈α e,∏ k∈pairCorners e,activationEntry (z k) κ)= + ∏ k∈pairCorners e,activationPhi (α e) (z k) := by + rw [Finset.prod_comm]; simp_rw [activationPhi_product] + simp_rw [he,pairCorners,Finset.prod_filter] + rw [Finset.prod_comm] + apply Finset.prod_congr rfl; intro k _ + have hi (e : Fin 33) : (cornerPairL k=e ∨ cornerPairR k=e) ↔ e∈({cornerPairL k,cornerPairR k} : Finset (Fin 33)) := by + simp only [Finset.mem_insert,Finset.mem_singleton]; tauto + simp_rw [hi] + rw [Finset.prod_ite_mem,Finset.univ_inter,Finset.prod_pair (cornerPair_ne k)] + +noncomputable def expandedModel (z : ActCorner → Activation K) : ℝ := + ∏ κ,∏ e,(1+∏ k∈pairCorners e,activationEntry (z k) κ) + +lemma expandedModel_expansion (z : ActCorner → Activation K) : + expandedModel z=∑ α : Fin 33 → Finset K, + ∏ k,activationPhi (α (cornerPairL k)) (z k)*activationPhi (α (cornerPairR k)) (z k) := by + unfold expandedModel + rw [Finset.prod_comm,product_one_add_expansion] + apply Finset.sum_congr rfl; intro α _ + exact labels_incidence_product α z + +lemma expandedModel_mean (p : ActCorner → FiniteLaw (Activation K)) + (hp : ∀ k α,α≠∅ → (p k).mean (activationPhi α)=0) : + (FiniteLaw.independent p).mean expandedModel=1+activeCoefficient (fun k => activationMoment (p k)) := by + have he : (FiniteLaw.independent p).mean expandedModel= + ∑ α : Fin 33 → Finset K,labelProduct (fun k => activationMoment (p k)) α := by + apply mean_activation_expansion p expandedModel + intro z + exact expandedModel_expansion z + rw [he,allCoefficient_eq p hp] + +noncomputable def coordinateActive (z : ActCorner → Activation K) (κ : K) (j : Fin 22) : Finset (Fin 3) := + Finset.univ.filter (fun k => κ∈(z (j,k)).1) +def coordinateSigns (z : ActCorner → Activation K) (κ : K) (j : Fin 22) (k : Fin 3) : ℤ := + if (z (j,k)).2 κ then 1 else -1 +omit [Fintype K] [DecidableEq K] in +lemma coordinateSigns_good (z : ActCorner → Activation K) (κ : K) : + ∀ j k,coordinateSigns z κ j k=1 ∨ coordinateSigns z κ j k= -1 := by + intro j k; unfold coordinateSigns; split <;> tauto +omit [Fintype K] [DecidableEq K] in +lemma coordinateSigns_real (z : ActCorner → Activation K) (κ : K) (j : Fin 22) (k : Fin 3) : + (coordinateSigns z κ j k : ℝ)=boolSign ((z (j,k)).2 κ) := by + unfold coordinateSigns boolSign; split <;> simp + +omit [Fintype K] in +lemma coordinate_factor (z : ActCorner → Activation K) (κ : K) (j : Fin 22) (k : Fin 3) (η : Fin 33 → Bool) : + (if slotLeft k∈coordinateActive z κ j ∧ slotRight k∈coordinateActive z κ j then + 1+(1:ℝ)*boolSign (η (facePair j k))*(coordinateSigns z κ j (slotLeft k):ℝ)* + (coordinateSigns z κ j (slotRight k):ℝ) else 1)= + 1+boolSign (η (facePair j k))*(activationEntry (z (j,slotLeft k)) κ*activationEntry (z (j,slotRight k)) κ) := by + simp only [coordinateActive,Finset.mem_filter,Finset.mem_univ,true_and,coordinateSigns_real,one_mul,activationEntry] + by_cases hl : κ∈(z (j,slotLeft k)).1 <;> by_cases hr : κ∈(z (j,slotRight k)).1 <;> + simp [hl,hr,mul_assoc] + +omit [Fintype K] in +lemma coordinate_boolean_product (z : ActCorner → Activation K) (κ : K) (η : Fin 33 → Bool) : + boolConfiguration 1 (coordinateActive z κ) (coordinateSigns z κ) η= + ∏ e,∏ b : Fin 2,(1+boolSign (η e)* + (activationEntry (z (pairFace e b,slotLeft (faceSlot e b))) κ* + activationEntry (z (pairFace e b,slotRight (faceSlot e b))) κ)) := by + unfold boolConfiguration boolFacePolynomial + simp_rw [coordinate_factor] + let f (a : Fin 22 × Fin 3) := 1+boolSign (η (facePair a.1 a.2))* + (activationEntry (z (a.1,slotLeft a.2)) κ*activationEntry (z (a.1,slotRight a.2)) κ) + let g (a : Fin 33 × Fin 2) := 1+boolSign (η a.1)* + (activationEntry (z (pairFace a.1 a.2,slotLeft (faceSlot a.1 a.2))) κ* + activationEntry (z (pairFace a.1 a.2,slotRight (faceSlot a.1 a.2))) κ) + change (∏ j,∏ k,f (j,k))=∏ e,∏ b,g (e,b) + rw [←Fintype.prod_prod_type f,←Fintype.prod_prod_type g] + exact Fintype.prod_equiv occurrencePairEquiv f g (fun a => by + change f a=g (facePair a.1 a.2,faceSide a.1 a.2) + simp only [f,g,faceSide_correct,faceSlot_side]) + +omit [Fintype K] in +lemma coordinateModel_eq (z : ActCorner → Activation K) (κ : K) : + uniformMean (boolConfiguration 1 (coordinateActive z κ) (coordinateSigns z κ))= + ∏ e,(1+∏ k∈pairCorners e,activationEntry (z k) κ) := by + let a (e : Fin 33) := activationEntry (z (pairFace e 0,slotLeft (faceSlot e 0))) κ* + activationEntry (z (pairFace e 0,slotRight (faceSlot e 0))) κ + let b (e : Fin 33) := activationEntry (z (pairFace e 1,slotLeft (faceSlot e 1))) κ* + activationEntry (z (pairFace e 1,slotRight (faceSlot e 1))) κ + calc + _ = uniformMean (fun η : Fin 33 → Bool => ∏ e,(1+boolSign (η e)*a e)*(1+boolSign (η e)*b e)) := by + apply uniformMean_congr; intro η + rw [coordinate_boolean_product] + simp only [Fin.prod_univ_two,a,b] + _ = ∏ e,(1+a e*b e) := uniformMean_double_product a b + _ = _ := by + apply Finset.prod_congr rfl; intro e _ + rw [pairCorners_product] + simp only [Fin.prod_univ_two,a,b] + +lemma coordinateModels_product (z : ActCorner → Activation K) : + (∏ κ,uniformMean (boolConfiguration 1 (coordinateActive z κ) (coordinateSigns z κ)))=expandedModel z := by + simp_rw [coordinateModel_eq]; rfl +end Expansion +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Classical +open scoped BigOperators +section Fubini +variable {I J K A B : Type*} [Fintype I] [Fintype J] [Fintype K] [Fintype A] [Fintype B] [DecidableEq I] [DecidableEq J] [DecidableEq K] + +noncomputable def coordinateArrayEquiv : ((I → K → A) × (J → K → B)) ≃ (K → (I → A) × (J → B)) where + toFun x k := (fun i => x.1 i k,fun j => x.2 j k) + invFun x := (fun i k => (x k).1 i,fun j k => (x k).2 j) + left_inv _x := rfl + right_inv _x := rfl + +lemma uniformMean_coordinate_factor (f : K → (I → A) → (J → B) → ℝ) : + uniformMean (fun x : (I → K → A) × (J → K → B) => + ∏ k,f k (fun i => x.1 i k) (fun j => x.2 j k))= + ∏ k,uniformMean (fun x : (I → A) × (J → B) => f k x.1 x.2) := by + have h := uniformMean_equiv (coordinateArrayEquiv (I := I) (J := J) (K := K) (A := A) (B := B)) + (fun x => ∏ k,f k (x k).1 (x k).2) + exact h.trans (uniformMean_pi_product (fun k (x : (I → A) × (J → B)) => f k x.1 x.2)) + +lemma uniformMean_law_swap (p : FiniteLaw A) (f : A → B → ℝ) : + uniformMean (fun b => p.mean (fun a => f a b))=p.mean (fun a => uniformMean (f a)) := by + unfold uniformMean FiniteLaw.mean + rw [Finset.sum_comm,Finset.sum_div] + simp_rw [←Finset.mul_sum] + apply Finset.sum_congr rfl; intro a _; ring + +lemma independent_mean_equiv {C : Type*} [Fintype C] + (e : I ≃ J) (p : J → FiniteLaw C) (f : (J → C) → ℝ) : + (FiniteLaw.independent (fun i => p (e i))).mean (fun x => f (fun j => x (e.symm j)))= + (FiniteLaw.independent p).mean f := by + unfold FiniteLaw.mean FiniteLaw.independent + let E : (I → C) ≃ (J → C) := Equiv.arrowCongr e (Equiv.refl C) + apply Fintype.sum_equiv E + intro x + dsimp [E] + congr 1 + symm + exact Fintype.prod_equiv e.symm _ _ (fun j => by simp) + +lemma independent_mean_prod (p : I → FiniteLaw A) (q : I → FiniteLaw B) (f : (I → A × B) → ℝ) : + (FiniteLaw.independent (fun i => (p i).prod (q i))).mean f= + (FiniteLaw.independent p).mean (fun x => (FiniteLaw.independent q).mean (fun y => f (fun i => (x i,y i)))) := by + unfold FiniteLaw.mean FiniteLaw.independent FiniteLaw.prod + simp_rw [Finset.mul_sum,←mul_assoc,←Finset.prod_mul_distrib] + rw [←Fintype.sum_prod_type (fun xy : (I → A) × (I → B) => + (∏ i,(p i).weight (xy.1 i)*(q i).weight (xy.2 i))*f (fun i => (xy.1 i,xy.2 i)))] + let e : (I → A × B) ≃ ((I → A) × (I → B)) := { + toFun x := (fun i => (x i).1,fun i => (x i).2) + invFun x i := (x.1 i,x.2 i) + left_inv _ := rfl + right_inv _ := rfl } + exact Fintype.sum_equiv e _ _ (fun _ => by rfl) +end Fubini +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module Classical Filter +open scoped BigOperators + +theorem faceVertex_mem (j : Fin 22) (k : Fin 3) : faceVertex j k∈faces j := by + rw [faceVertex_correct] + fin_cases k <;> simp + +theorem faceVertex_surj (j : Fin 22) (i : Fin 13) (hi : i∈faces j) : ∃ k,faceVertex j k=i := by + rw [faceVertex_correct] at hi + simp only [Finset.mem_insert,Finset.mem_singleton] at hi + rcases hi with h|h|h + · exact ⟨0,h.symm⟩ + · exact ⟨1,h.symm⟩ + · exact ⟨2,h.symm⟩ + +theorem corners_product {M : Type*} [CommMonoid M] (B : Finset (Fin 13 × Fin 22)) + (hB : B⊆corners) (f : Fin 13 × Fin 22 → M) : + (∏ c∈B,f c)=∏ j,∏ k∈faceActive B j,f (faceVertex j k,j) := by + rw [Finset.prod_sigma' Finset.univ (faceActive B) (fun j k => f (faceVertex j k,j))] + symm + apply Finset.prod_bij (fun a _ => (faceVertex a.1 a.2,a.1)) + · intro a ha + have h := (Finset.mem_sigma.mp ha).2 + exact (Finset.mem_filter.mp h).2 + · intro a ha b hb he + have h1 : a.1=b.1 := congrArg Prod.snd he + rcases a with ⟨j,k⟩; rcases b with ⟨l,m⟩ + dsimp at h1; subst l + have h2 := faceVertex_injective j (congrArg Prod.fst he) + change k=m at h2 + subst m; rfl + · intro b hb + have hi : b.1∈faces b.2 := (Finset.mem_filter.mp (hB hb)).2 + obtain ⟨k,hk⟩ := faceVertex_surj b.2 b.1 hi + refine ⟨⟨b.2,k⟩,?_,?_⟩ + · simp only [Finset.mem_sigma,Finset.mem_univ,true_and,faceActive,Finset.mem_filter] + simpa only [hk,true_and,Prod.eta] using hb + · simp only [hk,Prod.eta] + · intros; rfl + +theorem faceSigns_good (B : Finset (Fin 13 × Fin 22)) (ξ : Fin 13 × Fin 22 → ℤ) + (hξ : ∀ c∈B,ξ c=1 ∨ ξ c= -1) : ∀ j k,faceSigns B ξ j k=1 ∨ faceSigns B ξ j k= -1 := by + intro j k + unfold faceSigns + split_ifs with h + · exact hξ _ h + · exact Or.inl rfl + +theorem layerCorrelation_configuration (r : ℕ) (q : OddPrime) + (B : Finset (Fin 13 × Fin 22)) (hB : B⊆corners) (ξ : Fin 13 × Fin 22 → ℤ) : + layerCorrelation (2*r) q B ξ=uniformMean (configurationProduct (K := ZMod q.val) r (faceActive B) (faceSigns B ξ)) := by + have hm : 2*r/2=r := by omega + unfold layerCorrelation + rw [uniformMean_prod] + apply uniformMean_congr; intro X + have he (Y : Fin 22 → SymMatrix (ZMod q.val) (2*r)) : + (∏ c∈B, rankKernel (ZMod q.val) (2*r) (2*r/2) (ξ c) (X c.1-Y c.2))= + ∏ j,∏ k∈faceActive B j,rankKernel (ZMod q.val) (2*r) r (faceSigns B ξ j k) (X (faceVertex j k)-Y j) := by + rw [corners_product B hB] + apply Finset.prod_congr rfl; intro j _ + apply Finset.prod_congr rfl; intro k hk + have hk := (Finset.mem_filter.mp hk).2 + simp only [faceSigns,hk,ite_true,hm] + simp_rw [he] + exact uniformMean_pi_product (fun j y => ∏ k ∈ faceActive B j, + rankKernel (ZMod q.val) (2*r) r (faceSigns B ξ j k) (X (faceVertex j k)-y)) + +theorem pair_sub_face_iff : ∀ (j : Fin 22) (e : Fin 33), + pairVertices e⊆faces j ↔ ∃ k,facePair j k=e := by decide + +theorem product_facePair (j : Fin 22) (f : Fin 33 → ℝ) + (hf : ∀ e,¬pairVertices e⊆faces j → f e=1) : (∏ e,f e)=∏ k,f (facePair j k) := by + let S := Finset.univ.image (facePair j) + have he : (∏ e,f e)=∏ e∈S,f e := by + symm + apply Finset.prod_subset (Finset.subset_univ _) + intro e _ he + apply hf e + rw [pair_sub_face_iff] + simpa only [S,Finset.mem_image,Finset.mem_univ,true_and] using he + rw [he] + exact Finset.prod_image (fun _ _ _ _ h => facePair_injective j h) + +theorem modelFace_polynomial (c : ℝ) (B : Finset (Fin 13 × Fin 22)) + (ξ : Fin 13 × Fin 22 → ℤ) (η : Fin 33 → Bool) (j : Fin 22) : + (∏ e : ModelPair, if e.val⊆faces j ∧ (∀ i∈e.val,(i,j)∈B) then + 1+c*boolSign (η (pairModelEquiv.symm e))*∏ i∈e.val,(ξ (i,j):ℝ) else 1)= + boolFacePolynomial c (faceActive B j) (faceSigns B ξ j) j η := by + rw [←Equiv.prod_comp pairModelEquiv] + simp only [Equiv.symm_apply_apply] + change (∏ e : Fin 33,if pairVertices e⊆faces j ∧ (∀ i∈pairVertices e,(i,j)∈B) then + 1+c*boolSign (η e)*∏ i∈pairVertices e,(ξ (i,j):ℝ) else 1)=_ + rw [product_facePair j _ (fun e he => ite_eq_right (by tauto))] + apply Finset.prod_congr rfl; intro k _ + have hf : pairVertices (facePair j k)⊆faces j := (pair_sub_face_iff j _).mpr ⟨k,rfl⟩ + have hp : pairVertices (facePair j k)={faceVertex j (slotLeft k),faceVertex j (slotRight k)} := by + rw [pair_endpoints,(facePair_endpoints j k).1,(facePair_endpoints j k).2] + have hne : faceVertex j (slotLeft k)≠faceVertex j (slotRight k) := by + rw [←(facePair_endpoints j k).1,←(facePair_endpoints j k).2] + exact pair_endpoints_ne _ + simp only [hf,true_and] + simp only [hp,Finset.mem_insert,Finset.mem_singleton,forall_eq_or_imp,forall_eq, + Finset.prod_pair hne,faceActive,Finset.mem_filter,Finset.mem_univ,true_and] + by_cases h : (faceVertex j (slotLeft k),j)∈B ∧ (faceVertex j (slotRight k),j)∈B + · simp only [faceSigns,h.1,h.2,and_self,ite_true]; ring + · simp only [h,ite_false] + +noncomputable def pairBoolEquiv : (Fin 33 → Bool) ≃ (ModelPair → Bool) where + toFun η := η ∘ pairModelEquiv.symm + invFun η := η ∘ pairModelEquiv + left_inv η := by funext e; simp + right_inv η := by funext e; simp + +theorem signModelCorrelation_configuration (r : ℕ) (q : OddPrime) + (B : Finset (Fin 13 × Fin 22)) (ξ : Fin 13 × Fin 22 → ℤ) : + signModelCorrelation (2*r) q B ξ=uniformMean + (boolConfiguration (quadraticChar (ZMod q.val) ((-1:ZMod q.val)^r)) (faceActive B) (faceSigns B ξ)) := by + unfold signModelCorrelation + simp only [show 2*r/2=r by omega] + rw [←uniformMean_equiv pairBoolEquiv] + apply uniformMean_congr; intro η + change (∏ j, ∏ e : ModelPair, if e.val⊆faces j ∧ (∀ i∈e.val,(i,j)∈B) then + 1+(quadraticChar (ZMod q.val) ((-1:ZMod q.val)^r):ℝ)*boolSign (η (pairModelEquiv.symm e))* + ∏ i∈e.val,(ξ (i,j):ℝ) else 1)=_ + apply Finset.prod_congr rfl; intro j _ + exact modelFace_polynomial _ B ξ η j +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module Classical Filter +open scoped BigOperators + +noncomputable def boolTestError (r : ℕ) (T : Fin 22 → Finset (Fin 3)) + (ξ : Fin 22 → Fin 3 → ℤ) (c : ℝ) (q : OddPrime) : ℝ := + uniformMean (fun X : Fin 13 → SymMatrix (ZMod q.val) (2*r) => boolConfiguration c T ξ (pairBool X))- + uniformMean (boolConfiguration c T ξ) + +theorem boolTestError_tendsto (r : ℕ) (hbig : 12≤2*r) (T : Fin 22 → Finset (Fin 3)) + (ξ : Fin 22 → Fin 3 → ℤ) (c : ℝ) : Tendsto + (boolTestError r T ξ c) primeInfinity (nhds 0) := by + unfold boolTestError + simpa only [sub_self] using + (pairBool_test_tendsto (2*r) (even_two_mul r) hbig (boolConfiguration c T ξ)).sub_const + (uniformMean (boolConfiguration c T ξ)) + +theorem varyingBoolTestError_tendsto (r : ℕ) (hbig : 12≤2*r) (T : Fin 22 → Finset (Fin 3)) + (ξ : Fin 22 → Fin 3 → ℤ) : Tendsto + (fun q : OddPrime => boolTestError r T ξ + (quadraticChar (ZMod q.val) ((-1:ZMod q.val)^r)) q) primeInfinity (nhds 0) := by + have ht := ((boolTestError_tendsto r hbig T ξ 1).abs).add ((boolTestError_tendsto r hbig T ξ (-1)).abs) + simp only [abs_zero,add_zero] at ht + apply squeeze_zero_norm (fun q => ?_) ht + rw [Real.norm_eq_abs] + rcases quadraticChar_dichotomy (F := ZMod q.val) (pow_ne_zero r (neg_ne_zero.mpr one_ne_zero)) with h|h + · simp only [h,Int.cast_one]; exact le_add_of_nonneg_right (abs_nonneg _) + · simp only [h,Int.cast_neg,Int.cast_one]; exact le_add_of_nonneg_left (abs_nonneg _) + +theorem rankLayerConvergence (r : ℕ) (hlarge : singularTailThreshold≤2*r) + (B : Finset (Fin 13 × Fin 22)) (hB : B⊆corners) (ξ : Fin 13 × Fin 22 → ℤ) + (hξ : ∀ c∈B,ξ c=1 ∨ ξ c= -1) : Tendsto + (fun q : OddPrime => layerCorrelation (2*r) q B ξ-signModelCorrelation (2*r) q B ξ) + primeInfinity (nhds 0) := by + have hb : 12≤2*r := by have := singularTailThreshold_large; omega + have h1 := configuration_bool_tendsto r (faceActive B) (faceSigns B ξ) (faceSigns_good B ξ hξ) hlarge + have h2 := varyingBoolTestError_tendsto r hb (faceActive B) (faceSigns B ξ) + have ht := h1.add h2 + simp only [add_zero] at ht + convert ht using 1 + funext q + rw [layerCorrelation_configuration r q B hB ξ,signModelCorrelation_configuration] + unfold boolTestError + ring + +theorem rankLayerLimit_proved : RankLayerLimit := by + refine ⟨singularTailThreshold,?_,?_⟩ + · have := singularTailThreshold_large; omega + intro D hD he B hB ξ hξ + obtain ⟨r,hr⟩ := he + have h : D=2*r := by omega + rw [h] at hD ⊢ + exact rankLayerConvergence r hD B hB ξ hξ +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Filter +instance primeInfinity_neBot : NeBot primeInfinity := by + apply Filter.comap_neBot + intro s hs + obtain ⟨N,hN⟩ := Filter.mem_atTop_sets.mp hs + obtain ⟨q,hq,hprime⟩ := Nat.exists_infinite_primes (max N 3) + refine ⟨⟨q,hprime,by omega⟩,hN q (by omega)⟩ +end SidorenkoCounterexample + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/Coercivity.lean b/lean/OAI/Combinatorics/Sidorenko/Coercivity.lean new file mode 100644 index 0000000000000000000000000000000000000000..41270b3527e8801aba0d4fa803d36e293156d615 --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/Coercivity.lean @@ -0,0 +1,1128 @@ +import OAI.Combinatorics.Sidorenko.Planted + +namespace OAI + +namespace SidorenkoCounterexample + +private theorem quadratic_ge_right (A B C x b : ℝ) + (hA : 0 ≤ A) (hxb : x ≤ b) (hderiv : 2 * A * b + B ≤ 0) : + A * b ^ 2 + B * b + C ≤ A * x ^ 2 + B * x + C := by + have h : 0 ≤ -A * (x + b) - B := by + nlinarith [mul_nonneg hA (sub_nonneg.mpr hxb)] + have := mul_nonneg (sub_nonneg.mpr hxb) h + nlinarith + +private theorem quadratic_ge_endpoints (A B C a b x k : ℝ) + (hA : A ≤ 0) (hax : a ≤ x) (hxb : x ≤ b) + (ha : k ≤ A * a ^ 2 + B * a + C) + (hb : k ≤ A * b ^ 2 + B * b + C) : + k ≤ A * x ^ 2 + B * x + C := by + by_cases hab : a = b + · have : x = a := by linarith + simpa [this] using ha + have hab' : 0 < b - a := sub_pos.mpr (lt_of_le_of_ne (hax.trans hxb) hab) + have h₁ := mul_nonneg (sub_nonneg.mpr hxb) (sub_nonneg.mpr ha) + have h₂ := mul_nonneg (sub_nonneg.mpr hax) (sub_nonneg.mpr hb) + have h₃ := mul_nonneg (mul_nonneg (neg_nonneg.mpr hA) + (mul_nonneg (sub_nonneg.mpr hax) (sub_nonneg.mpr hxb))) + (le_of_lt hab') + have hsum : 0 ≤ (b - a) * (A * x ^ 2 + B * x + C - k) := by + nlinarith only [h₁, h₂, h₃] + exact le_of_sub_nonneg ((nonneg_of_mul_nonneg_right hsum hab')) + +/-- The scalar minimization for nonnegative δ, without analytic derivatives. -/ +theorem coercivity_scalar_pos (P T δ : ℝ) (hP : 0 ≤ P) (hδ : 0 ≤ δ) + (_hT : 0 ≤ T) (hTP : T ≤ P + 3 * δ) : + (P ^ 2 + δ ^ 2) / 18 ≤ + 3 * δ ^ 2 / 4 + (2 * P - T) ^ 2 / 18 + (5 * P - T) * δ / 6 - + (min (P / 3 + δ) ((P - T + 3 * δ) / 2)) ^ 2 / 2 := by + have hPd := mul_nonneg hP hδ + by_cases ht : T ≤ P / 3 + δ + · rw [min_eq_left (by linarith)] + have hmono := quadratic_ge_right (1/18) (-2*P/9-δ/6) + (3*δ^2/4+2*P^2/9+5*P*δ/6-(P/3+δ)^2/2) + T (P/3+δ) (by norm_num) ht (by nlinarith) + nlinarith [sq_nonneg P, sq_nonneg δ] + · rw [min_eq_right (by linarith)] + have hl : P / 3 + δ ≤ T := by linarith + have hem := quadratic_ge_endpoints (-5/72) (P/36+7*δ/12) + (7*P^2/72+P*δ/12-3*δ^2/8) (P/3+δ) (P+3*δ) T + ((P^2+δ^2)/18) (by norm_num) hl hTP + (by nlinarith [sq_nonneg P, sq_nonneg δ]) + (by nlinarith [sq_nonneg P, sq_nonneg δ]) + nlinarith only [hem] + +/-- The scalar minimization used after δ = -y and P = x + 3y. -/ +theorem coercivity_scalar_neg (x T y : ℝ) (hx : 0 ≤ x) (hy : 0 ≤ y) + (_hT : 0 ≤ T) (hTx : T ≤ x) : + (x ^ 2 + y ^ 2) / 18 ≤ + y ^ 2 / 4 + (2*x-T)*y/3 + (2*x-T)^2/18 - + (min (x/3) ((x-T)/2))^2/2 := by + have hxy := mul_nonneg hx hy + by_cases ht : T ≤ x/3 + · rw [min_eq_left (by linarith)] + have hmono := quadratic_ge_right (1/18) (-2*x/9-y/3) + (y^2/4+2*x*y/3+x^2/6) T (x/3) (by norm_num) ht (by nlinarith) + nlinarith [sq_nonneg x, sq_nonneg y] + · rw [min_eq_right (by linarith)] + have hem := quadratic_ge_endpoints (-5/72) (x/36-y/3) + (y^2/4+2*x*y/3+7*x^2/72) (x/3) x T ((x^2+y^2)/18) + (by norm_num) (by linarith) hTx + (by nlinarith [sq_nonneg x, sq_nonneg y]) + (by nlinarith [sq_nonneg x, sq_nonneg y]) + nlinarith only [hem] + +/-- Scalar lower bound after controlling the v-term and applying Cauchy–Schwarz. -/ +noncomputable def scalarForm (c d P T δ : ℝ) : ℝ := + (c*(d+δ)-δ*d+2*δ^2)/4 + (2*P-T)^2/18 + δ*P - c*(P+T)/6 - + (min (P/3+δ) ((P-T+3*δ)/2))^2/2 + +theorem coercivity_scalar (c d P T δ : ℝ) (hc : |δ| ≤ c) + (hd : P + T ≤ d) (hP : 0 ≤ P) (hT : 0 ≤ T) (hTP : T ≤ P+3*δ) : + (P^2+T^2+δ^2)/342 + (c-|δ|)*(d+3*δ)/12 ≤ scalarForm c d P T δ := by + have hsplit : scalarForm |δ| d P T δ + (c-|δ|)*(d+3*δ)/12 ≤ + scalarForm c d P T δ := by + have hm := mul_nonneg (sub_nonneg.mpr hc) (sub_nonneg.mpr hd) + dsimp [scalarForm] + nlinarith only [hm] + suffices h : (P^2+T^2+δ^2)/342 ≤ scalarForm |δ| d P T δ by linarith only [h, hsplit] + by_cases hδ : 0 ≤ δ + · rw [abs_of_nonneg hδ] + have hs := coercivity_scalar_pos P T δ hP hδ hT hTP + have hsquare := mul_nonneg (sub_nonneg.mpr hTP) (show 0 ≤ P+3*δ+T by linarith) + have hsize : P^2+T^2+δ^2 ≤ 19*(P^2+δ^2) := by + nlinarith only [hsquare, sq_nonneg (P-3*δ), sq_nonneg P] + dsimp [scalarForm] + nlinarith only [hs, hsize] + · have hδ' : δ ≤ 0 := le_of_not_ge hδ + rw [abs_of_nonpos hδ'] + have hx : 0 ≤ P+3*δ := by linarith + have hs := coercivity_scalar_neg (P+3*δ) T (-δ) hx (neg_nonneg.mpr hδ') hT hTP + rw [show (P+3*δ)/3 = P/3+δ by ring, + show (P+3*δ-T)/2 = (P-T+3*δ)/2 by ring] at hs + have hsquare := mul_nonneg (sub_nonneg.mpr hTP) (show 0 ≤ P+3*δ+T by linarith) + have hsize : P^2+T^2+δ^2 ≤ 19*((P+3*δ)^2+δ^2) := by + nlinarith only [hsquare, sq_nonneg (P+6*δ), sq_nonneg (P+3*δ)] + have hdim := mul_nonneg (neg_nonneg.mpr hδ') (sub_nonneg.mpr hd) + dsimp [scalarForm] + nlinarith only [hs, hsize, hdim] + +open scoped BigOperators + +/-- Exactly the homogeneous quadratic part of equation (tail-linear-loss). -/ +noncomputable def quadraticPart (c d δ v : ℝ) (p t : Fin 3 → ℝ) : ℝ := + (c*(d+δ)-δ*d+2*δ^2)/4 + (∑ i, (2*p i-t i)^2)/6 + + δ*(∑ i, p i) - c*((∑ i, p i)+(∑ i, t i))/6 + + ((d-3*δ)/2-(∑ i, p i))*v+v^2/2 + +private theorem three_sq (z : Fin 3 → ℝ) : (∑ i, z i)^2 ≤ 3*∑ i, (z i)^2 := by + simp only [Fin.sum_univ_three] + nlinarith [sq_nonneg (z 0-z 1), sq_nonneg (z 0-z 2), sq_nonneg (z 1-z 2)] + +/-- Manuscript Lemma `lem:coercivity`, with every feasibility condition explicit. + No dimension-dependent error term or asymptotic assumption occurs here. -/ +theorem coercivity (c d δ v : ℝ) (p t : Fin 3 → ℝ) + (hc : |δ| ≤ c) (hd : (∑ i, p i)+(∑ i, t i) ≤ d) + (hp : ∀ i, 0 ≤ p i) (ht : ∀ i, 0 ≤ t i) (hv : 0 ≤ v) + (htp : ∀ i, t i ≤ p i+δ) (hvp : ∀ i, v ≤ p i+δ) + (hw : 0 ≤ (d-3*δ)/2-(∑ i, p i)+v) : + ((∑ i, p i)^2+(∑ i, t i)^2+δ^2)/342 + (c-|δ|)*(d+3*δ)/12 ≤ + quadraticPart c d δ v p t := by + let P := ∑ i, p i + let T := ∑ i, t i + have hP : 0 ≤ P := Finset.sum_nonneg fun i _ => hp i + have hT : 0 ≤ T := Finset.sum_nonneg fun i _ => ht i + have hTP : T ≤ P+3*δ := by + have hh := Finset.sum_le_sum (s := Finset.univ) (fun i _ => htp i) + simpa [Finset.sum_add_distrib, P, T] using hh + have hvP : v ≤ P/3+δ := by + have hh := Finset.sum_le_sum (s := Finset.univ) (fun i _ => hvp i) + simp only [Finset.sum_add_distrib, Finset.sum_const, Finset.card_univ, + Fintype.card_fin, nsmul_eq_mul] at hh + change (3:ℝ)*v ≤ P+3*δ at hh + linarith only [hh] + let m := min (P/3+δ) ((P-T+3*δ)/2) + let k := (d-3*δ)/2-P + have hm : 0 ≤ m := le_min (by linarith only [hv, hvP]) (by linarith only [hTP]) + have hkm : -k ≤ m := by + apply le_min + · dsimp [k] + change 0 ≤ (d-3*δ)/2-P+v at hw + linarith only [hw, hvP] + · dsimp [k] + change P+T ≤ d at hd + linarith only [hd] + have hvquad : -m^2/2 ≤ k*v+v^2/2 := by + by_cases hk : 0 ≤ k + · nlinarith only [mul_nonneg hk hv, sq_nonneg v, sq_nonneg m] + · have hh₁ : 0 ≤ m+k := by linarith only [hkm] + have hh₂ : 0 ≤ m-k := by linarith only [hm, hk] + nlinarith only [mul_nonneg hh₁ hh₂, sq_nonneg (v+k)] + have hsq := three_sq (fun i => 2*p i-t i) + have hsum : (∑ i, (2*p i-t i)) = 2*P-T := by + simp [Finset.sum_sub_distrib, Finset.mul_sum, P, T] + rw [hsum] at hsq + have hscalar := coercivity_scalar c d P T δ hc hd hP hT hTP + change (P^2+T^2+δ^2)/342 + (c-|δ|)*(d+3*δ)/12 ≤ _ + calc + _ ≤ scalarForm c d P T δ := hscalar + _ ≤ quadraticPart c d δ v p t := by + dsimp [scalarForm, quadraticPart] + change _ ≤ (c*(d+δ)-δ*d+2*δ^2)/4 + (∑ i, (2*p i-t i)^2)/6 + + δ*P-c*(P+T)/6+k*v+v^2/2 + change - (min (P/3+δ) ((P-T+3*δ)/2))^2/2 ≤ _ at hvquad + nlinarith only [hsq, hvquad] + + +noncomputable def triangular (n : ℝ) : ℝ := n*(n+1)/2 + +/-- The face baseline β=C/2-∑b(h)/6, after D=d+c and s=p+t. -/ +noncomputable def baseline (c d : ℝ) (p t : Fin 3 → ℝ) : ℝ := + ((d+c+1)*c + ∑ i, triangular (p i+t i))/2 - + (∑ i, triangular (c+p i+t i))/6 + + + +noncomputable def plantedGain (c d δ v : ℝ) (p t : Fin 3 → ℝ) : ℝ := + ((d+c)/2+c+1)*((c+δ)/2)-2*((c+δ)/2)^2 + + (∑ i, triangular (p i+t i)) - δ*(∑ i, p i) - (∑ i, (p i)^2) - + v*((d-3*δ)/2-(∑ i, p i)+v) - (∑ i, triangular (t i)) + triangular v + +/-- Equation (slack), with the actual baseline and gain, not a new bound. -/ +theorem slack_identity (c d δ v : ℝ) (p t : Fin 3 → ℝ) : + baseline c d p t - plantedGain c d δ v p t = + (c*(d+δ-1)-δ*(d+2)+2*δ^2)/4 + + (∑ i, ((2*p i-t i)*(2*p i-t i-1)/6 + δ*p i-c*(p i+t i)/6)) + + v*((d-3*δ)/2-(∑ i, p i)+v) - triangular v := by + simp only [baseline, plantedGain, triangular, Fin.sum_univ_three] + ring + +/-- Equation (tail-linear-loss). -/ +theorem slack_quadratic (c d δ v : ℝ) (p t : Fin 3 → ℝ) : + baseline c d p t - plantedGain c d δ v p t = + quadraticPart c d δ v p t - c/4 - δ/2 - + (2*(∑ i, p i)-(∑ i, t i))/6-v/2 := by + rw [slack_identity] + simp only [quadraticPart, triangular, Fin.sum_univ_three] + ring + +/-- Uniform linear loss on a face, as used in (tail-budget). -/ +theorem slack_uniform_linear (c d δ v M : ℝ) (p t : Fin 3 → ℝ) + (hc : 0 ≤ c) (hδ : δ ≤ c) (hv : v ≤ M) + (hP : (∑ i, p i) ≤ 3*(M-c)) (hT : 0 ≤ ∑ i, t i) : + quadraticPart c d δ v p t - 3*M/2 ≤ + baseline c d p t - plantedGain c d δ v p t := by + rw [slack_quadratic] + linarith only [hc, hδ, hv, hP, hT] + +/-- The leading coefficient in d is exactly (c-δ+2v)/4. -/ +theorem slack_leading_coefficient (c d δ v : ℝ) (p t : Fin 3 → ℝ) : + baseline c d p t - plantedGain c d δ v p t = + ((c-δ+2*v)/4)*d + baseline c 0 p t - plantedGain c 0 δ v p t := by + simp only [baseline, plantedGain, triangular, Fin.sum_univ_three] + ring + +/-- Equation (tail-integer-slack), after the bounded-dimension argument forces +u=c, δ=c and v=0. -/ +theorem slack_integer_regime (c d : ℝ) (p t : Fin 3 → ℝ) : + baseline c d p t - plantedGain c d c 0 p t = + (3*c^2-3*c)/4 + + (∑ i, ((2*p i-t i)^2+(c-1)*(2*p i-t i)+3*c*p i))/6 := by + simp only [baseline, plantedGain, triangular, Fin.sum_univ_three] + ring + +/-- For common dimension at least two, the eventual integer-regime slack +is strictly positive. This needs no rounding relaxation. -/ +theorem slack_pos_of_two_le (c d : ℝ) (p t : Fin 3 → ℝ) + (hc : 2 ≤ c) (hp : ∀ i, 0 ≤ p i) : + 0 < baseline c d p t - plantedGain c d c 0 p t := by + rw [slack_integer_regime] + have hi (i : Fin 3) : -(c-1)^2/4 ≤ + (2*p i-t i)^2+(c-1)*(2*p i-t i)+3*c*p i := by + have hh := mul_nonneg (show 0 ≤ c by linarith) (hp i) + nlinarith only [hh, sq_nonneg (2*p i-t i+(c-1)/2)] + have hh := Finset.sum_le_sum (s := Finset.univ) (fun i _ => hi i) + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] at hh + have hpos : 0 < (c-1)*(5*c+1) := mul_pos (by linarith) (by linarith) + nlinarith only [hh, hpos] + +/-- The zero-common-dimension local equality calculation must use integer +parameters; the corresponding assertion is false for general real tuples. -/ +theorem integer_pair_slack (p t : ℤ) (hp : 0 ≤ p) (ht : 0 ≤ t) (htp : t ≤ p) : + 0 ≤ (2*p-t)*(2*p-t-1) ∧ + ((2*p-t)*(2*p-t-1) = 0 ↔ (p=0 ∧ t=0) ∨ (p=1 ∧ t=1)) := by + have hn : 0 ≤ 2*p-t := by omega + constructor + · by_cases hz : 2*p-t = 0 + · simp [hz] + · exact mul_nonneg hn (by omega) + · rw [mul_eq_zero] + constructor + · intro h + rcases h with h | h + · left; omega + · right; omega + · rintro (⟨rfl, rfl⟩ | ⟨rfl, rfl⟩) <;> norm_num + +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open scoped BigOperators +noncomputable def faceBaseline (D c : ℝ) (s : Fin 3 → ℝ) : ℝ := + ((D+1)*c + ∑ i, triangular (s i))/2 - (∑ i, triangular (c+s i))/6 + + theorem triangular_nonneg {x : ℝ} (hx : 0 ≤ x) : 0 ≤ triangular x := by + unfold triangular; positivity + theorem triangular_pos {x : ℝ} (hx : 0 < x) : 0 < triangular x := by + unfold triangular; positivity + theorem triangular_mono {x y : ℝ} (hx : 0 ≤ x) (hxy : x ≤ y) : + triangular x ≤ triangular y := by + have h := mul_nonneg (sub_nonneg.mpr hxy) (show 0 ≤ y+x+1 by linarith) + dsimp [triangular]; nlinarith only [h] + theorem triangular_nat (n : ℕ) : ((n+1).choose 2 : ℝ) = triangular n := by + rw [Nat.cast_choose_two] + simp only [Nat.cast_add,Nat.cast_one] + unfold triangular + ring + + theorem faceBaseline_lower (D c : ℝ) (s : Fin 3 → ℝ) (k : Fin 3) + (hc : 0 ≤ c) (hs : ∀ i, 0 ≤ s i) (hD : (∑ i, s i) ≤ D-c) : + triangular (c+s k)/3 + triangular c/6 + + ((∑ i, triangular (s i))-triangular (s k))/3 ≤ faceBaseline D c s := by + have hm : s k ≤ ∑ i, s i := Finset.single_le_sum (fun i _ => hs i) (Finset.mem_univ k) + have hn := mul_nonneg hc (show 0 ≤ 3*(D-c)-(∑ i, s i)-2*s k by linarith) + have he : faceBaseline D c s - (triangular (c+s k)/3 + triangular c/6 + + ((∑ i, triangular (s i))-triangular (s k))/3) = + c*(3*(D-c)-(∑ i, s i)-2*s k)/6 := by + simp only [faceBaseline,triangular,Fin.sum_univ_three] + ring + linarith only [hn,he] + + theorem half_triangular_bounds (h : ℕ) : + 0 ≤ triangular (h:ℝ)/3-triangular (h/2:ℕ) ∧ + (h:ℝ)^2/24-(h:ℝ)/12 ≤ triangular (h:ℝ)/3-triangular (h/2:ℕ) ∧ + (triangular (h:ℝ)/3-triangular (h/2:ℕ) = 0 ↔ h=0 ∨ h=2) := by + have hd := Nat.mod_add_div h 2 + have hr := Nat.mod_lt h (by norm_num : 0<2) + have hq : 0 ≤ (h/2:ℕ) := Nat.zero_le _ + have hqr : (0:ℝ) ≤ (h/2:ℕ) := Nat.cast_nonneg _ + rcases (show h%2=0 ∨ h%2=1 by omega) with he | he + · have hh : h=2*(h/2) := by omega + have hh' : (h:ℝ)=2*(h/2:ℕ) := by exact_mod_cast hh + have hn : (h/2:ℕ)=0 ∨ (h/2:ℕ)=1 ∨ 2 ≤ h/2 := by omega + rcases hn with hn | hn | hn + · have hz : h=0 := by omega + subst h; norm_num [triangular] + · have hz : h=2 := by omega + subst h; norm_num [triangular] + · have hn' : (2:ℝ) ≤ (h/2:ℕ) := by exact_mod_cast hn + have hp : 0 < (h/2:ℕ)*( (h/2:ℕ)-1 : ℝ) := mul_pos (by linarith) (by linarith) + dsimp [triangular] + constructor + · nlinarith only [hh',hp] + constructor + · nlinarith only [hh',sq_nonneg ((h/2:ℕ):ℝ)] + constructor + · intro hz; nlinarith only [hh',hp,hz] + · intro hz; rcases hz with hz | hz <;> omega + · have hh : h=2*(h/2)+1 := by omega + have hh' : (h:ℝ)=2*(h/2:ℕ)+1 := by exact_mod_cast hh + have hp : 0 < ((h/2:ℕ):ℝ)+1 := by positivity + have hp' := mul_pos hp (show (0:ℝ) < (h/2:ℕ)+2 by positivity) + dsimp [triangular] + constructor + · nlinarith only [hh',hp',sq_nonneg ((h/2:ℕ):ℝ)] + constructor + · nlinarith only [hh',sq_nonneg ((h/2:ℕ):ℝ),hqr] + constructor + · intro hz; nlinarith only [hh',hp',hz] + · intro hz; rcases hz with hz | hz <;> omega + + theorem lower_active_slack (D c : ℕ) (s : Fin 3 → ℕ) (k : Fin 3) (g : ℝ) + (hD : (∑ i, s i) ≤ D-c) (hcD : c ≤ D) + (_hk : ∀ i, s i ≤ s k) (hg : g ≤ triangular ((c+s k)/2:ℕ)) : + 0 ≤ faceBaseline D c (fun i => s i)-g ∧ + ((c+s k:ℕ):ℝ)^2/24-((c+s k:ℕ):ℝ)/12 ≤ faceBaseline D c (fun i => s i)-g ∧ + (faceBaseline D c (fun i => s i)-g = 0 → + c=0 ∧ (∀ i, i≠k → s i=0) ∧ (s k=0 ∨ s k=2)) := by + have hD' : (∑ i, (s i:ℝ)) ≤ (D:ℝ)-c := by exact_mod_cast hD + have hb := faceBaseline_lower (D:ℝ) c (fun i => s i) k (by positivity) (fun i => by positivity) hD' + have hh := half_triangular_bounds (c+s k) + have he : 0 ≤ (∑ i, triangular (s i))-triangular (s k) := by + exact sub_nonneg.mpr (Finset.single_le_sum (fun i _ => triangular_nonneg (Nat.cast_nonneg _)) (Finset.mem_univ k)) + have hct : 0 ≤ triangular (c:ℝ) := triangular_nonneg (Nat.cast_nonneg _) + simp only [Nat.cast_add] at hh + refine ⟨by linarith [hh.1],by simp only [Nat.cast_add]; linarith [hh.2.1],?_⟩ + intro hz + have hc : c=0 := by + by_contra hc + have hp := triangular_pos (show (0:ℝ) triangular_nonneg (Nat.cast_nonneg (s j))) + simpa only [Finset.sum_pair hik] using hx + have hi0 : triangular (s i)=0 := by linarith [triangular_nonneg (Nat.cast_nonneg (s i))] + by_contra hi + have hp := triangular_pos (show (0:ℝ) a.p i) (fun i => a.t i) +noncomputable def TailTuple.energy (D : ℕ) (a : TailTuple) : ℝ := + (a.P^2+a.T^2+a.delta^2)/342 + ((a.c:ℝ)-|a.delta|)*((D:ℝ)-a.c+3*a.delta)/12 +noncomputable def tailGain (D : ℕ) (full : Bool) (a : TailTuple) : ℝ := + if full then plantedGain a.c ((D:ℝ)-a.c) a.delta a.v (fun i => a.p i) (fun i => a.t i) + else triangular (a.maxH/2:ℕ) +noncomputable def tailSlack (D : ℕ) (full : Bool) (a : TailTuple) : ℝ := + faceBaseline D a.c (fun i => a.s i)-tailGain D full a +noncomputable def tailEnergy (D : ℕ) (full : Bool) (a : TailTuple) : ℝ := + if full then a.energy D else (a.maxH:ℝ)^2/24 + +def TailFeasible (D : ℕ) (full : Bool) (a : TailTuple) : Prop := + a.c ≤ D ∧ (∑ i, a.s i) ≤ D-a.c ∧ (full=true → + a.u ≤ a.c ∧ + (∀ i, (a.t i:ℝ) ≤ a.p i+a.delta) ∧ + (∀ i, (a.v:ℝ) ≤ a.p i+a.delta) ∧ + 0 ≤ (((D:ℝ)-a.c-3*a.delta)/2)-a.P+a.v) + + theorem TailTuple.h_le_max (a : TailTuple) (i : Fin 3) : a.h i ≤ a.maxH := + Finset.le_sup (Finset.mem_univ i) + theorem TailTuple.exists_max (a : TailTuple) : ∃ i, a.maxH=a.h i := by + obtain ⟨i,_,hi⟩ := Finset.exists_mem_eq_sup Finset.univ Finset.univ_nonempty a.h + exact ⟨i,hi⟩ + theorem TailTuple.c_le_max (a : TailTuple) : a.c ≤ a.maxH := + (Nat.le_add_right a.c (a.s 0)).trans (a.h_le_max 0) + theorem TailTuple.p_le_h (a : TailTuple) (i : Fin 3) : a.p i ≤ a.h i := by + unfold TailTuple.h TailTuple.s; omega + theorem TailTuple.t_le_h (a : TailTuple) (i : Fin 3) : a.t i ≤ a.h i := by + unfold TailTuple.h TailTuple.s; omega + theorem TailTuple.s_le_h (a : TailTuple) (i : Fin 3) : a.s i ≤ a.h i := by + unfold TailTuple.h; omega + theorem TailTuple.delta_abs_le (a : TailTuple) (hu : a.u ≤ a.c) : |a.delta| ≤ (a.c:ℝ) := by + have hu' : (a.u:ℝ) ≤ a.c := by exact_mod_cast hu + rw [abs_le] + dsimp [TailTuple.delta] + constructor <;> linarith [(Nat.cast_nonneg a.u : (0:ℝ) ≤ a.u)] + theorem TailTuple.baseline (D : ℕ) (a : TailTuple) : + faceBaseline D a.c (fun i => a.s i) = + baseline a.c ((D:ℝ)-a.c) (fun i => a.p i) (fun i => a.t i) := by + simp only [faceBaseline,SidorenkoCounterexample.baseline,TailTuple.s,Nat.cast_add,sub_add_cancel,add_assoc] + + theorem TailFeasible.sum_le {D : ℕ} {full : Bool} {a : TailTuple} + (ha : TailFeasible D full a) : a.P+a.T ≤ (D:ℝ)-a.c := by + have hh : (∑ i, (a.s i:ℝ)) ≤ (D:ℝ)-a.c := by + have hc : ((D-a.c:ℕ):ℝ) = (D:ℝ)-a.c := Nat.cast_sub ha.1 + rw [←hc,←Nat.cast_sum] + exact_mod_cast ha.2.1 + simpa only [TailTuple.s,Nat.cast_add,Finset.sum_add_distrib,TailTuple.P,TailTuple.T] using hh + + theorem TailFeasible.d_delta_nonneg {D : ℕ} {a : TailTuple} + (ha : TailFeasible D true a) : 0 ≤ (D:ℝ)-a.c+3*a.delta := by + have ht := Finset.sum_le_sum (s := Finset.univ) (fun i _ => (ha.2.2 rfl).2.1 i) + simp only [Finset.sum_add_distrib,Finset.sum_const,Finset.card_univ, + Fintype.card_fin,nsmul_eq_mul] at ht + change a.T ≤ a.P+3*a.delta at ht + have hT : 0 ≤ a.T := Finset.sum_nonneg (fun i _ => Nat.cast_nonneg _) + linarith [ha.sum_le] + + theorem TailFeasible.energy_nonneg {D : ℕ} {a : TailTuple} + (ha : TailFeasible D true a) : + 0 ≤ a.energy D ∧ (a.P^2+a.T^2+a.delta^2)/342 ≤ a.energy D := by + have h := mul_nonneg (sub_nonneg.mpr (a.delta_abs_le (ha.2.2 rfl).1)) ha.d_delta_nonneg + dsimp [TailTuple.energy] + constructor + · positivity + · linarith only [h] + + theorem TailFeasible.coercivity {D : ℕ} {a : TailTuple} + (ha : TailFeasible D true a) : a.energy D ≤ a.Q D := by + apply SidorenkoCounterexample.coercivity + · exact a.delta_abs_le (ha.2.2 rfl).1 + · exact ha.sum_le + · intro i; positivity + · intro i; positivity + · positivity + · exact (ha.2.2 rfl).2.1 + · exact (ha.2.2 rfl).2.2.1 + · exact (ha.2.2 rfl).2.2.2 + + theorem TailFeasible.v_le_max {D : ℕ} {a : TailTuple} + (ha : TailFeasible D true a) : a.v ≤ a.maxH := by + have hv := (ha.2.2 rfl).2.2.1 0 + have hδ := le_abs_self a.delta |>.trans (a.delta_abs_le (ha.2.2 rfl).1) + have hp : (a.p 0:ℝ) ≤ a.h 0-a.c := by + dsimp [TailTuple.h,TailTuple.s]; push_cast; linarith [(Nat.cast_nonneg (a.t 0) : (0:ℝ) ≤ a.t 0)] + have hh : (a.h 0:ℝ) ≤ a.maxH := by exact_mod_cast a.h_le_max 0 + have hv' : (a.v:ℝ) ≤ a.maxH := by linarith + exact_mod_cast hv' + + theorem tailEnergy_nonneg {D : ℕ} {full : Bool} {a : TailTuple} + (ha : TailFeasible D full a) : 0 ≤ tailEnergy D full a := by + cases full + · simp only [tailEnergy,Bool.false_eq_true,ite_false]; positivity + · exact ha.energy_nonneg.1 + + theorem tailSlack_energy_lower {D : ℕ} {full : Bool} {a : TailTuple} (M : ℝ) + (ha : TailFeasible D full a) (hM : (a.maxH:ℝ) ≤ M) : + tailEnergy D full a-3*M/2 ≤ tailSlack D full a := by + cases full + · obtain ⟨k,hk⟩ := a.exists_max + have hsk (i : Fin 3) : a.s i ≤ a.s k := by + have hh := a.h_le_max i + rw [hk] at hh + exact Nat.le_of_add_le_add_left hh + have hh := lower_active_slack D a.c a.s k (triangular (a.maxH/2:ℕ)) ha.2.1 ha.1 hsk + (by rw [hk]; rfl) + simp only [tailSlack,tailGain,tailEnergy,Bool.false_eq_true,ite_false] + rw [hk] at hh ⊢ + have hhM : (a.c+a.s k:ℕ) ≤ M := by simpa only [hk,TailTuple.h] using hM + have hMn : 0 ≤ M := (Nat.cast_nonneg a.maxH).trans hM + change ((a.c+a.s k:ℕ):ℝ)^2/24-3*M/2 ≤ _ + linarith [hh.2.1] + · have hc : (a.c:ℝ) ≤ M := le_trans (by exact_mod_cast a.c_le_max) hM + have hv : (a.v:ℝ) ≤ M := le_trans (by exact_mod_cast ha.v_le_max) hM + have hP : a.P ≤ 3*(M-a.c) := by + have hi (i : Fin 3) : (a.p i:ℝ) ≤ M-a.c := by + have hh : (a.h i:ℝ) ≤ M := le_trans (by exact_mod_cast a.h_le_max i) hM + dsimp [TailTuple.h,TailTuple.s] at hh + push_cast at hh + linarith [(Nat.cast_nonneg (a.t i) : (0:ℝ) ≤ a.t i)] + have hh := Finset.sum_le_sum (s := Finset.univ) (fun i _ => hi i) + simpa only [TailTuple.P,Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul,Nat.cast_ofNat] using hh + have hδ : a.delta ≤ (a.c:ℝ) := (le_abs_self _).trans (a.delta_abs_le (ha.2.2 rfl).1) + have hh := slack_uniform_linear (a.c:ℝ) ((D:ℝ)-a.c) a.delta (a.v:ℝ) M + (fun i => (a.p i:ℝ)) (fun i => (a.t i:ℝ)) (by positivity) hδ hv hP + (Finset.sum_nonneg (fun i _ => Nat.cast_nonneg _)) + have hh' := sub_le_sub_right ha.coercivity (3*M/2) + simpa only [tailSlack,tailGain,tailEnergy,ite_true,a.baseline D,TailTuple.Q] using hh'.trans hh +end SidorenkoCounterexample + + +namespace SidorenkoCounterexample + +def pairVertices : Fin 33 → Finset (Fin 13) := ![{0,2}, {0,3}, {2,3}, {0,9}, {2,9}, {0,1}, {1,3}, {2,4}, {3,4}, {1,9}, {4,9}, {1,10}, {3,10}, {3,11}, {4,11}, {1,12}, {9,12}, {4,8}, {8,9}, {1,7}, {7,10}, {10,11}, {8,11}, {7,12}, {8,12}, {5,7}, {5,10}, {5,11}, {6,8}, {6,11}, {6,7}, {6,12}, {5,6}] +def facePair : Fin 22 → Fin 3 → Fin 33 := ![![5, 1, 6], ![5, 3, 9], ![0, 1, 2], ![0, 3, 4], ![6, 11, 12], ![19, 11, 20], ![19, 15, 23], ![9, 15, 16], ![2, 7, 8], ![7, 4, 10], ![8, 13, 14], ![12, 13, 21], ![17, 10, 18], ![17, 14, 22], ![32, 25, 30], ![32, 27, 29], ![25, 26, 20], ![26, 27, 21], ![30, 31, 23], ![28, 29, 22], ![28, 31, 24], ![18, 24, 16]] +def pairFace : Fin 33 → Fin 2 → Fin 22 := ![![2, 3], ![0, 2], ![2, 8], ![1, 3], ![3, 9], ![0, 1], ![0, 4], ![8, 9], ![8, 10], ![1, 7], ![9, 12], ![4, 5], ![4, 11], ![10, 11], ![10, 13], ![6, 7], ![7, 21], ![12, 13], ![12, 21], ![5, 6], ![5, 16], ![11, 17], ![13, 19], ![6, 18], ![20, 21], ![14, 16], ![16, 17], ![15, 17], ![19, 20], ![15, 19], ![14, 18], ![18, 20], ![14, 15]] +def pairParent : Fin 33 → Fin 33 := ![0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 4, 6, 6, 8, 8, 9, 9, 10, 10, 11, 11, 12, 14, 15, 16, 20, 20, 21, 22, 22, 23, 23, 25] +def pairBridge : Fin 33 → Fin 22 := ![2, 2, 2, 3, 3, 0, 0, 8, 8, 1, 9, 4, 4, 10, 10, 7, 7, 12, 12, 5, 5, 11, 13, 6, 21, 16, 16, 17, 19, 19, 18, 18, 14] +def faceBit : Fin 22 → Fin 3 → Bool := ![![false, false, false], ![false, true, false], ![false, false, true], ![true, true, false], ![false, false, true], ![false, false, false], ![true, false, false], ![true, true, false], ![true, false, true], ![true, false, false], ![true, true, true], ![true, false, true], ![true, false, true], ![false, true, true], ![false, false, false], ![true, true, false], ![false, true, false], ![true, true, true], ![false, false, true], ![false, true, false], ![false, true, true], ![true, true, true]] +def separationCount (e : Fin 33) : ℕ := (Finset.univ.filter fun b => faceBit (pairFace e 0) b ≠ faceBit (pairFace e 1) b).card + + theorem faces_card : ∀ j, (faces j).card = 3 := by decide + theorem pairVertices_card : ∀ e, (pairVertices e).card = 2 := by decide + theorem pairVertices_injective : Function.Injective pairVertices := by decide + theorem facePair_injective : ∀ j, Function.Injective (facePair j) := by decide + theorem facePair_correct : ∀ j e, pairVertices e ⊆ faces j ↔ ∃ k, facePair j k=e := by decide + theorem pairFace_correct : ∀ e j, pairVertices e ⊆ faces j ↔ ∃ k, pairFace e k=j := by decide + theorem pairFace_injective : ∀ e, Function.Injective (pairFace e) := by decide + theorem pairParent_lt : ∀ e, e≠0 → (pairParent e).val < e.val := by decide + theorem pairBridge_self : ∀ e, pairVertices e ⊆ faces (pairBridge e) := by decide + theorem pairBridge_parent : ∀ e, pairVertices (pairParent e) ⊆ faces (pairBridge e) := by decide + theorem separationCount_pos : ∀ e, 1 ≤ separationCount e := by decide + theorem separationCount_root : separationCount 0=3 := by decide + theorem separationCount_le : ∀ e, separationCount e ≤ 3 := by decide + theorem root_pair : pairVertices 0={0,2} := by rfl + +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open scoped BigOperators + theorem nonnegative_interval_sq (a b M : ℝ) (ha : 0 ≤ a) (hb : 0 ≤ b) + (haM : a ≤ M) (hbM : b ≤ M) : (a-b)^2 ≤ M^2 := by + have hM : 0 ≤ M := ha.trans haM + have hab : |a-b| ≤ M := abs_le.mpr ⟨by linarith,by linarith⟩ + have hh := (sq_le_sq₀ (abs_nonneg _) hM).2 hab + simpa only [sq_abs] using hh + + theorem tail_pair_energy {D : ℕ} {full : Bool} {a : TailTuple} + (ha : TailFeasible D full a) (i k : Fin 3) : + ((a.h i:ℝ)-a.h k)^2 ≤ 684*tailEnergy D full a := by + cases full + · have hm (j : Fin 3) : (a.h j:ℝ) ≤ a.maxH := by exact_mod_cast a.h_le_max j + have hh := nonnegative_interval_sq (a.h i) (a.h k) a.maxH (by positivity) (by positivity) (hm i) (hm k) + simp only [tailEnergy,Bool.false_eq_true,ite_false] + nlinarith [sq_nonneg (a.maxH:ℝ)] + · have hs (j : Fin 3) : (a.s j:ℝ) ≤ a.P+a.T := by + have hh : (a.s j:ℝ) ≤ ∑ k, (a.s k:ℝ) := + Finset.single_le_sum (fun k _ => Nat.cast_nonneg (a.s k)) (Finset.mem_univ j) + simpa only [TailTuple.s,Nat.cast_add,Finset.sum_add_distrib,TailTuple.P,TailTuple.T] using hh + have hh := nonnegative_interval_sq (a.s i) (a.s k) (a.P+a.T) (by positivity) (by positivity) (hs i) (hs k) + have he := ha.energy_nonneg.2 + simp only [tailEnergy,ite_true] + simp only [TailTuple.h,Nat.cast_add] + nlinarith only [hh,he,sq_nonneg (a.P-a.T),sq_nonneg a.delta] + + theorem parent_energy_bound {n : ℕ} (p : Fin (n+1) → Fin (n+1)) + (hp : ∀ i, i≠0 → (p i).val < i.val) (f : Fin (n+1) → ℝ) (K : ℝ) (hK : 0 ≤ K) + (hstep : ∀ i, (f i-f (p i))^2 ≤ K) (i : Fin (n+1)) : + (f i-f 0)^2 ≤ (4:ℝ)^i.val*K := by + have hmain : ∀ m, ∀ i : Fin (n+1), i.val=m → (f i-f 0)^2 ≤ (4:ℝ)^i.val*K := by + intro m + induction m using Nat.strong_induction_on with + | h m ih => + intro i him + by_cases hi : i=0 + · subst i; simpa using hK + · have hpm : (p i).val < m := by simpa only [him] using hp i hi + have hind := ih (p i).val hpm (p i) rfl + have hpow : (4:ℝ)^((p i).val+1) ≤ (4:ℝ)^i.val := + pow_le_pow_right₀ (by norm_num) (hp i hi) + have hone : (1:ℝ) ≤ (4:ℝ)^(p i).val := one_le_pow₀ (by norm_num) + have hc := mul_le_mul_of_nonneg_right hpow hK + have hk' := mul_le_mul_of_nonneg_right hone hK + rw [pow_succ] at hc + have hh := hstep i + nlinarith only [hind,hc,hk',hh,sq_nonneg ((f i-f (p i))-(f (p i)-f 0))] + exact hmain i.val i rfl + +noncomputable def separationExcess (h : Fin 33 → ℕ) : ℝ := + ∑ e, ((separationCount e:ℝ)-1)/6*triangular (h e) + +def GlobalTailFeasible (D : ℕ) (full : Fin 22 → Bool) (a : Fin 22 → TailTuple) + (h : Fin 33 → ℕ) : Prop := + (∀ j, TailFeasible D (full j) (a j)) ∧ ∀ j k, (a j).h k=h (facePair j k) + + theorem separationExcess_nonneg (h : Fin 33 → ℕ) : 0 ≤ separationExcess h := by + apply Finset.sum_nonneg + intro e _ + have he : (1:ℝ) ≤ separationCount e := by exact_mod_cast separationCount_pos e + exact mul_nonneg (by linarith) (triangular_nonneg (Nat.cast_nonneg _)) + + theorem separationExcess_root (h : Fin 33 → ℕ) : + (h 0:ℝ)^2/6 ≤ separationExcess h := by + have hn (e : Fin 33) : 0 ≤ ((separationCount e:ℝ)-1)/6*triangular (h e) := by + have hh : (1:ℝ) ≤ separationCount e := by exact_mod_cast separationCount_pos e + exact mul_nonneg (by linarith) (triangular_nonneg (Nat.cast_nonneg _)) + have he : ((separationCount 0:ℝ)-1)/6*triangular (h 0) ≤ separationExcess h := + Finset.single_le_sum (fun e _ => hn e) (Finset.mem_univ (0 : Fin 33)) + rw [separationCount_root] at he + norm_num only [Nat.cast_ofNat] at he + dsimp [triangular] at he + nlinarith [(Nat.cast_nonneg (h 0) : (0:ℝ) ≤ h 0)] + + theorem global_tail_budget (D : ℕ) (full : Fin 22 → Bool) (a : Fin 22 → TailTuple) + (h : Fin 33 → ℕ) (ha : GlobalTailFeasible D full a h) + (htotal : (∑ j, tailSlack D (full j) (a j))+separationExcess h ≤ 0) : + (∑ j, tailEnergy D (full j) (a j))+separationExcess h ≤ + 33*((Finset.univ.sup h:ℕ):ℝ) := by + let M : ℝ := (Finset.univ.sup h:ℕ) + have hM (j : Fin 22) : ((a j).maxH:ℝ) ≤ M := by + have hh : (a j).maxH ≤ Finset.univ.sup h := by + apply Finset.sup_le + intro k _ + rw [ha.2 j k] + exact Finset.le_sup (Finset.mem_univ _) + change ((a j).maxH:ℝ) ≤ ((Finset.univ.sup h:ℕ):ℝ) + exact_mod_cast hh + have hi := Finset.sum_le_sum (s := Finset.univ) (fun j _ => tailSlack_energy_lower M (ha.1 j) (hM j)) + simp only [Finset.sum_sub_distrib,Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul] at hi + change (∑ j, tailEnergy D (full j) (a j))-22*(3*M/2) ≤ _ at hi + change (∑ j, tailEnergy D (full j) (a j))+separationExcess h ≤ 33*M + linarith only [hi,htotal] + +/-- A deliberately coarse but absolute bound on unseparated pair dimensions. +It replaces the manuscript's unbounded-subsequence argument by a finite +energy propagation along a certified spanning tree of the exact complex. -/ +def tailPairBound : ℕ := 2*4^32*22572+396 + + theorem global_tail_pair_bound (D : ℕ) (full : Fin 22 → Bool) (a : Fin 22 → TailTuple) + (h : Fin 33 → ℕ) (ha : GlobalTailFeasible D full a h) + (htotal : (∑ j, tailSlack D (full j) (a j))+separationExcess h ≤ 0) : + ∀ e, h e ≤ tailPairBound := by + let M : ℝ := (Finset.univ.sup h:ℕ) + have hM : 0 ≤ M := Nat.cast_nonneg _ + have hb := global_tail_budget D full a h ha htotal + change (∑ j, tailEnergy D (full j) (a j))+separationExcess h ≤ 33*M at hb + have he0 : 0 ≤ separationExcess h := separationExcess_nonneg h + have hen (j : Fin 22) : 0 ≤ tailEnergy D (full j) (a j) := tailEnergy_nonneg (ha.1 j) + have hes : 0 ≤ ∑ j, tailEnergy D (full j) (a j) := Finset.sum_nonneg (fun j _ => hen j) + have he (j : Fin 22) : tailEnergy D (full j) (a j) ≤ 33*M := by + have hh := Finset.single_le_sum (fun j _ => hen j) (Finset.mem_univ j) + linarith + have hroot : (h 0:ℝ)^2 ≤ 198*M := by linarith [separationExcess_root h] + have hstep (e : Fin 33) : ((h e:ℝ)-h (pairParent e))^2 ≤ 22572*M := by + obtain ⟨i,hi⟩ := (facePair_correct (pairBridge e) e).mp (pairBridge_self e) + obtain ⟨k,hk⟩ := (facePair_correct (pairBridge e) (pairParent e)).mp (pairBridge_parent e) + have hh := tail_pair_energy (ha.1 (pairBridge e)) i k + rw [ha.2,ha.2,hi,hk] at hh + linarith [he (pairBridge e)] + obtain ⟨em,_,hem⟩ := Finset.exists_mem_eq_sup Finset.univ Finset.univ_nonempty h + have hem' : (h em:ℝ)=M := by + dsimp [M]; exact_mod_cast hem.symm + have hg := parent_energy_bound pairParent pairParent_lt (fun e => (h e:ℝ)) (22572*M) (by positivity) hstep em + have hp : (4:ℝ)^em.val ≤ (4:ℝ)^32 := pow_le_pow_right₀ (by norm_num) (by omega) + have hgp := mul_le_mul_of_nonneg_right hp (show 0 ≤ 22572*M by positivity) + have htotalM : M^2 ≤ (tailPairBound:ℝ)*M := by + rw [hem'] at hg + simp only [tailPairBound,Nat.cast_add,Nat.cast_mul,Nat.cast_pow,Nat.cast_ofNat] + nlinarith only [hg,hgp,hroot,sq_nonneg (M-2*(h 0:ℝ))] + have hMB : M ≤ (tailPairBound:ℝ) := by + by_contra hnot + have hdiff : 0 < M-(tailPairBound:ℝ) := by linarith + have hMp : 0 < M := lt_of_le_of_lt (Nat.cast_nonneg _) (lt_of_not_ge hnot) + have hp := mul_pos hMp hdiff + nlinarith only [hp,htotalM] + intro e + have heM : (h e:ℝ) ≤ M := by + dsimp [M]; exact_mod_cast (Finset.le_sup (f := h) (Finset.mem_univ e)) + exact_mod_cast heM.trans hMB +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open scoped BigOperators +structure TailBox (B : ℕ) where + c : Fin (B+1) + u : Fin (B+1) + v : Fin (B+1) + p : Fin 3 → Fin (B+1) + t : Fin 3 → Fin (B+1) + deriving Fintype + +def TailBox.tuple {B : ℕ} (b : TailBox B) : TailTuple := + ⟨b.c,b.u,b.v,fun i => b.p i,fun i => b.t i⟩ +noncomputable def tailRemainder (a : TailTuple) : ℝ := + baseline a.c 0 (fun i => a.p i) (fun i => a.t i)- + plantedGain a.c 0 a.delta a.v (fun i => a.p i) (fun i => a.t i) +noncomputable def tailLinear (a : TailTuple) : ℝ := ((a.c:ℝ)-a.u+a.v)/2 +noncomputable def tailRemainderBound (B : ℕ) : ℝ := + ∑ b : TailBox B, |tailRemainder b.tuple| + theorem tailRemainderBound_nonneg (B : ℕ) : 0 ≤ tailRemainderBound B := + Finset.sum_nonneg (fun _ _ => abs_nonneg _) + theorem tailSlack_linear (D : ℕ) (a : TailTuple) : + tailSlack D true a=tailLinear a*((D:ℝ)-a.c)+tailRemainder a := by + simp only [tailSlack,tailGain,ite_true,a.baseline D] + rw [slack_leading_coefficient] + dsimp [tailLinear,tailRemainder,TailTuple.delta] + ring + theorem tailLinear_nonneg {a : TailTuple} (hu : a.u ≤ a.c) : 0 ≤ tailLinear a := by + have hu' : (a.u:ℝ) ≤ a.c := by exact_mod_cast hu + dsimp [tailLinear] + linarith [show (0:ℝ) ≤ a.v by positivity] + theorem tailLinear_half {a : TailTuple} (hu : a.u ≤ a.c) + (hbad : ¬(a.u=a.c ∧ a.v=0)) : 1/2 ≤ tailLinear a := by + have hh : a.u+1 ≤ a.c+a.v := by omega + have hh' : (a.u:ℝ)+1 ≤ a.c+a.v := by exact_mod_cast hh + dsimp [tailLinear]; linarith + theorem tailRemainder_bounded {D B : ℕ} {a : TailTuple} + (ha : TailFeasible D true a) (hB : a.maxH ≤ B) : + |tailRemainder a| ≤ tailRemainderBound B := by + have hc : a.c ≤ B := a.c_le_max.trans hB + have hu : a.u ≤ B := (ha.2.2 rfl).1.trans hc + have hv : a.v ≤ B := ha.v_le_max.trans hB + have hp (i : Fin 3) : a.p i ≤ B := (a.p_le_h i).trans ((a.h_le_max i).trans hB) + have ht (i : Fin 3) : a.t i ≤ B := (a.t_le_h i).trans ((a.h_le_max i).trans hB) + let b : TailBox B := ⟨⟨a.c,by omega⟩,⟨a.u,by omega⟩,⟨a.v,by omega⟩, + fun i => ⟨a.p i,by have := hp i; omega⟩,fun i => ⟨a.t i,by have := ht i; omega⟩⟩ + have hb : b.tuple=a := by cases a; rfl + rw [←hb] + exact Finset.single_le_sum (f := fun x : TailBox B => |tailRemainder x.tuple|) + (fun _ _ => abs_nonneg _) (Finset.mem_univ b) + theorem tailSlack_lower_nonneg {D : ℕ} {a : TailTuple} + (ha : TailFeasible D false a) : 0 ≤ tailSlack D false a := by + obtain ⟨k,hk⟩ := a.exists_max + have hsk (i : Fin 3) : a.s i ≤ a.s k := by + have hh := a.h_le_max i + rw [hk] at hh + exact Nat.le_of_add_le_add_left hh + exact (lower_active_slack D a.c a.s k (triangular (a.maxH/2:ℕ)) ha.2.1 ha.1 hsk + (by rw [hk]; rfl)).1 + theorem global_maxH_bound {D : ℕ} {full : Fin 22 → Bool} {a : Fin 22 → TailTuple} + {h : Fin 33 → ℕ} (ha : GlobalTailFeasible D full a h) + (htotal : (∑ j, tailSlack D (full j) (a j))+separationExcess h ≤ 0) (j : Fin 22) : + (a j).maxH ≤ tailPairBound := by + have hb := global_tail_pair_bound D full a h ha htotal + apply Finset.sup_le + intro k _ + rw [ha.2] + exact hb _ + + + + + theorem eventually_integer_regime : ∃ D₀ : ℕ, ∀ D ≥ D₀, + ∀ (full : Fin 22 → Bool) (a : Fin 22 → TailTuple) (h : Fin 33 → ℕ), + GlobalTailFeasible D full a h → + (∑ j, tailSlack D (full j) (a j))+separationExcess h ≤ 0 → + ∀ j, full j=true → (a j).u=(a j).c ∧ (a j).v=0 := by + let B := tailPairBound + let R := tailRemainderBound B + have hR : 0 ≤ R := tailRemainderBound_nonneg B + obtain ⟨D₀,hD₀⟩ := exists_nat_gt ((B:ℝ)+44*R) + refine ⟨D₀,?_⟩ + intro D hD full a h ha htotal + have hD' : (B:ℝ)+44*R < D := lt_of_lt_of_le hD₀ (by exact_mod_cast hD) + have hB (j : Fin 22) : (a j).maxH ≤ B := global_maxH_bound ha htotal j + have hc (j : Fin 22) : ((a j).c:ℝ) ≤ B := by + exact_mod_cast (a j).c_le_max.trans (hB j) + have hrem (j : Fin 22) (hj : full j=true) : -R ≤ tailRemainder (a j) := by + have hh := tailRemainder_bounded (D := D) (by simpa only [hj] using ha.1 j) (hB j) + exact (abs_le.mp hh).1 + have hs (j : Fin 22) : -R ≤ tailSlack D (full j) (a j) := by + cases hj : full j with + | false => + have hh := tailSlack_lower_nonneg (by simpa only [hj] using ha.1 j) + linarith only [hR,hh] + | true => + have haj : TailFeasible D true (a j) := by simpa only [hj] using ha.1 j + rw [tailSlack_linear] + have hdn : 0 ≤ (D:ℝ)-(a j).c := sub_nonneg.mpr (by exact_mod_cast haj.1) + have hh := mul_nonneg (tailLinear_nonneg (haj.2.2 rfl).1) hdn + linarith only [hh,hrem j hj] + intro j hj + by_contra hbad + have haj : TailFeasible D true (a j) := by simpa only [hj] using ha.1 j + have hA := tailLinear_half (haj.2.2 rfl).1 hbad + have hdn : 0 ≤ (D:ℝ)-(a j).c := by + have hcD : ((a j).c:ℝ) ≤ D := by exact_mod_cast haj.1 + linarith + have hmul := mul_le_mul_of_nonneg_right hA hdn + have hsl : (D:ℝ)/2-(B:ℝ)/2-R ≤ tailSlack D (full j) (a j) := by + rw [hj,tailSlack_linear] + linarith only [hmul,hrem j hj,hc j] + have hsum : tailSlack D (full j) (a j)+R ≤ ∑ k, (tailSlack D (full k) (a k)+R) := + Finset.single_le_sum (f := fun k : Fin 22 => tailSlack D (full k) (a k)+R) + (fun k _ => by linarith only [hs k]) (Finset.mem_univ j) + simp only [Finset.sum_add_distrib,Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul,Nat.cast_ofNat] at hsum + linarith only [hsum,hsl,htotal,separationExcess_nonneg h,hD'] +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open scoped BigOperators + theorem delta_integer_regime (a : TailTuple) (hu : a.u=a.c) : a.delta=(a.c:ℝ) := by + dsimp [TailTuple.delta]; rw [hu]; ring + theorem tailSlack_integer (D : ℕ) (a : TailTuple) (hu : a.u=a.c) (hv : a.v=0) : + tailSlack D true a = baseline a.c ((D:ℝ)-a.c) (fun i => a.p i) (fun i => a.t i)- + plantedGain a.c ((D:ℝ)-a.c) a.c 0 (fun i => a.p i) (fun i => a.t i) := by + simp only [tailSlack,tailGain,ite_true,a.baseline D,delta_integer_regime a hu,hv,Nat.cast_zero] + + theorem integer_slack_classification {D : ℕ} {a : TailTuple} + (ha : TailFeasible D true a) (hu : a.u=a.c) (hv : a.v=0) : + 0 ≤ tailSlack D true a ∧ (tailSlack D true a=0 → + (a.c=0 ∧ ∀ i, (a.p i=0 ∧ a.t i=0) ∨ (a.p i=1 ∧ a.t i=1)) ∨ + (a.c=1 ∧ ∀ i, a.p i=0 ∧ a.t i=0)) := by + rw [tailSlack_integer D a hu hv] + by_cases hc0 : a.c=0 + · have he : baseline a.c ((D:ℝ)-a.c) (fun i => a.p i) (fun i => a.t i)- + plantedGain a.c ((D:ℝ)-a.c) a.c 0 (fun i => a.p i) (fun i => a.t i) = + (∑ i : Fin 3, (2*(a.p i:ℝ)-a.t i)*(2*(a.p i:ℝ)-a.t i-1))/6 := by + rw [slack_integer_regime,hc0] + simp only [Nat.cast_zero,Fin.sum_univ_three]; ring + rw [he] + have hi (i : Fin 3) : 0 ≤ (2*(a.p i:ℝ)-a.t i)*(2*(a.p i:ℝ)-a.t i-1) ∧ + ((2*(a.p i:ℝ)-a.t i)*(2*(a.p i:ℝ)-a.t i-1)=0 → + (a.p i=0 ∧ a.t i=0) ∨ (a.p i=1 ∧ a.t i=1)) := by + have ht := (ha.2.2 rfl).2.1 i + rw [delta_integer_regime a hu,hc0,Nat.cast_zero,add_zero] at ht + have ht' : (a.t i:ℤ) ≤ a.p i := by exact_mod_cast ht + have hh := integer_pair_slack (a.p i) (a.t i) (by positivity) (by positivity) ht' + refine ⟨by exact_mod_cast hh.1,?_⟩ + intro hz + have hz' : (2*(a.p i:ℤ)-a.t i)*(2*(a.p i:ℤ)-a.t i-1)=0 := by exact_mod_cast hz + have hh' := hh.2.mp hz' + exact_mod_cast hh' + have hsum : 0 ≤ ∑ i : Fin 3, (2*(a.p i:ℝ)-a.t i)*(2*(a.p i:ℝ)-a.t i-1) := + Finset.sum_nonneg (fun i _ => (hi i).1) + refine ⟨by positivity,fun hz => Or.inl ⟨hc0,?_⟩⟩ + intro i + apply (hi i).2 + have hh := Finset.single_le_sum (f := fun k : Fin 3 => + (2*(a.p k:ℝ)-a.t k)*(2*(a.p k:ℝ)-a.t k-1)) + (fun k _ => (hi k).1) (Finset.mem_univ i) + linarith only [hh,hz,(hi i).1] + · by_cases hc1 : a.c=1 + · have he : baseline a.c ((D:ℝ)-a.c) (fun i => a.p i) (fun i => a.t i)- + plantedGain a.c ((D:ℝ)-a.c) a.c 0 (fun i => a.p i) (fun i => a.t i) = + (∑ i : Fin 3, ((2*(a.p i:ℝ)-a.t i)^2+3*a.p i))/6 := by + rw [slack_integer_regime,hc1] + simp only [Nat.cast_one,Fin.sum_univ_three]; ring + rw [he] + have hi (i : Fin 3) : 0 ≤ (2*(a.p i:ℝ)-a.t i)^2+3*a.p i := by positivity + have hsum : 0 ≤ ∑ i : Fin 3, ((2*(a.p i:ℝ)-a.t i)^2+3*a.p i) := + Finset.sum_nonneg (fun i _ => hi i) + refine ⟨by positivity,fun hz => Or.inr ⟨hc1,?_⟩⟩ + intro i + have hh := Finset.single_le_sum (f := fun k : Fin 3 => + (2*(a.p k:ℝ)-a.t k)^2+3*a.p k) (fun k _ => hi k) (Finset.mem_univ i) + have hp : a.p i=0 := by + have hn : (0:ℝ) ≤ a.p i := Nat.cast_nonneg _ + have hz' : (a.p i:ℝ)=0 := by nlinarith only [hh,hz,hn,sq_nonneg (2*(a.p i:ℝ)-a.t i)] + exact_mod_cast hz' + refine ⟨hp,?_⟩ + simp only [hp,Nat.cast_zero,mul_zero,add_zero,zero_sub,neg_sq] at hh + have ht' : (a.t i:ℝ)=0 := by nlinarith only [hh,hz,sq_nonneg (a.t i:ℝ)] + exact_mod_cast ht' + · have hc : (2:ℝ) ≤ a.c := by + have hh : 2 ≤ a.c := by omega + exact_mod_cast hh + have hh := slack_pos_of_two_le a.c ((D:ℝ)-a.c) (fun i => a.p i) (fun i => a.t i) + hc (fun i => by positivity) + exact ⟨hh.le,fun hz => (ne_of_gt hh hz).elim⟩ + +def FaceResidue (a : TailTuple) : Prop := + (a.c=0 ∧ ∀ i, a.h i=0 ∨ a.h i=2) ∨ (a.c=1 ∧ ∀ i, a.h i=1) + + theorem full_zero_face_residue {D : ℕ} {a : TailTuple} (ha : TailFeasible D true a) + (hu : a.u=a.c) (hv : a.v=0) (hz : tailSlack D true a=0) : FaceResidue a := by + rcases (integer_slack_classification ha hu hv).2 hz with ⟨hc,hh⟩ | ⟨hc,hh⟩ + · left; refine ⟨hc,fun i => ?_⟩ + rcases hh i with ⟨hp,ht⟩ | ⟨hp,ht⟩ + · left; simp only [TailTuple.h,TailTuple.s,hc,hp,ht] + · right; simp only [TailTuple.h,TailTuple.s,hc,hp,ht] + · right; refine ⟨hc,fun i => ?_⟩ + simp only [TailTuple.h,TailTuple.s,hc,(hh i).1,(hh i).2] + + theorem lower_zero_face_residue {D : ℕ} {a : TailTuple} + (ha : TailFeasible D false a) (hz : tailSlack D false a=0) : FaceResidue a := by + obtain ⟨k,hk⟩ := a.exists_max + have hsk (i : Fin 3) : a.s i ≤ a.s k := by + have hh := a.h_le_max i + rw [hk] at hh + exact Nat.le_of_add_le_add_left hh + have hh := (lower_active_slack D a.c a.s k (triangular (a.maxH/2:ℕ)) ha.2.1 ha.1 hsk + (by rw [hk]; rfl)).2.2 hz + left; refine ⟨hh.1,fun i => ?_⟩ + by_cases hik : i=k + · subst i; simpa only [TailTuple.h,hh.1,zero_add] using hh.2.2 + · left; simp only [TailTuple.h,hh.1,hh.2.1 i hik,add_zero] + + theorem FaceResidue.one_iff {a : TailTuple} (ha : FaceResidue a) (i k : Fin 3) : + a.h i=1 ↔ a.h k=1 := by + rcases ha with ⟨_,hh⟩ | ⟨_,hh⟩ + · have hi := hh i; have hk := hh k + constructor <;> intro h <;> omega + · rw [hh i,hh k] +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open scoped BigOperators + theorem pair_incidence_card : ∀ e : Fin 33, + (Finset.univ.filter fun p : Fin 22 × Fin 3 => facePair p.1 p.2=e).card=2 := by decide + theorem sum_face_pairs (f : Fin 33 → ℝ) : + (∑ j : Fin 22, ∑ k : Fin 3, f (facePair j k))=2*∑ e, f e := by + rw [←Fintype.sum_prod_type (fun p : Fin 22 × Fin 3 => f (facePair p.1 p.2))] + rw [←Finset.sum_fiberwise Finset.univ (fun p : Fin 22 × Fin 3 => facePair p.1 p.2)] + have he (e : Fin 33) : (∑ p ∈ Finset.univ.filter (fun p : Fin 22 × Fin 3 => facePair p.1 p.2=e), + f (facePair p.1 p.2))=2*f e := by + calc _ = ∑ _p ∈ Finset.univ.filter (fun p : Fin 22 × Fin 3 => facePair p.1 p.2=e), f e := by + apply Finset.sum_congr rfl + intro p hp + rw [(Finset.mem_filter.mp hp).2] + _ = _ := by rw [Finset.sum_const,pair_incidence_card]; simp only [nsmul_eq_mul,Nat.cast_ofNat] + simp_rw [he] + rw [Finset.mul_sum] + + theorem residue_root_zero (h : Fin 33 → ℕ) (he : separationExcess h=0) : h 0=0 := by + have hh := separationExcess_root h + rw [he] at hh + have h0 : (h 0:ℝ)=0 := by nlinarith [sq_nonneg (h 0:ℝ)] + exact_mod_cast h0 + + theorem residue_propagation (a : Fin 22 → TailTuple) (h : Fin 33 → ℕ) + (hh : ∀ j k, (a j).h k=h (facePair j k)) (ha : ∀ j, FaceResidue (a j)) + (hroot : h 0=0) : ∀ e, h e ≠ 1 := by + have hstep (e : Fin 33) : h e=1 ↔ h (pairParent e)=1 := by + obtain ⟨i,hi⟩ := (facePair_correct (pairBridge e) e).mp (pairBridge_self e) + obtain ⟨k,hk⟩ := (facePair_correct (pairBridge e) (pairParent e)).mp (pairBridge_parent e) + have hs := (ha (pairBridge e)).one_iff i k + rw [hh,hh,hi,hk] at hs + exact hs + have hmain : ∀ m, ∀ e : Fin 33, e.val=m → h e≠1 := by + intro m + induction m using Nat.strong_induction_on with + | h m ih => + intro e hem he + by_cases he0 : e=0 + · subst e; omega + · have hp : (pairParent e).val < m := by simpa only [hem] using pairParent_lt e he0 + exact ih (pairParent e).val hp (pairParent e) rfl ((hstep e).mp he) + intro e + exact hmain e.val e rfl + +/-- The exact nonsaving residue of the singular-tail exponent calculation, +uniform over all corner activity patterns when D is large enough. -/ + theorem uniform_tail_dichotomy : ∃ D₀ : ℕ, ∀ D ≥ D₀, + ∀ (full : Fin 22 → Bool) (a : Fin 22 → TailTuple) (h : Fin 33 → ℕ), + GlobalTailFeasible D full a h → + (∑ j, tailSlack D (full j) (a j))+separationExcess h ≤ 0 → + (∀ j, (a j).c=0) ∧ (∀ e, h e=0 ∨ h e=2) ∧ + (∀ j, tailSlack D (full j) (a j)=0) ∧ separationExcess h=0 ∧ + (∑ j, tailGain D (full j) (a j))=(2/3:ℝ)*∑ e, triangular (h e) := by + obtain ⟨D₀,hD₀⟩ := eventually_integer_regime + refine ⟨D₀,?_⟩ + intro D hD full a h ha htotal + have hreg := hD₀ D hD full a h ha htotal + have hn (j : Fin 22) : 0 ≤ tailSlack D (full j) (a j) := by + cases hj : full j with + | false => exact tailSlack_lower_nonneg (by simpa only [hj] using ha.1 j) + | true => exact (integer_slack_classification (by simpa only [hj] using ha.1 j) + (hreg j hj).1 (hreg j hj).2).1 + have hsn : 0 ≤ ∑ j, tailSlack D (full j) (a j) := Finset.sum_nonneg (fun j _ => hn j) + have he : separationExcess h=0 := by linarith [separationExcess_nonneg h] + have hsz : (∑ j, tailSlack D (full j) (a j))=0 := by linarith + have hz (j : Fin 22) : tailSlack D (full j) (a j)=0 := + (Finset.sum_eq_zero_iff_of_nonneg (fun j _ => hn j)).mp hsz j (Finset.mem_univ j) + have hr (j : Fin 22) : FaceResidue (a j) := by + cases hj : full j with + | false => exact lower_zero_face_residue (by simpa only [hj] using ha.1 j) (by simpa only [hj] using hz j) + | true => + exact full_zero_face_residue (by simpa only [hj] using ha.1 j) + (hreg j hj).1 (hreg j hj).2 (by simpa only [hj] using hz j) + have hnone := residue_propagation a h ha.2 hr (residue_root_zero h he) + have hface (j : Fin 22) : (a j).c=0 ∧ ∀ k, (a j).h k=0 ∨ (a j).h k=2 := by + rcases hr j with hh | ⟨_hc,hh⟩ + · exact hh + · exact (hnone (facePair j 0) (by rw [←ha.2]; exact hh 0)).elim + refine ⟨fun j => (hface j).1,?_,hz,he,?_⟩ + · intro e + obtain ⟨k,hk⟩ := (facePair_correct (pairBridge e) e).mp (pairBridge_self e) + have hh := (hface (pairBridge e)).2 k + rwa [ha.2,hk] at hh + · have hg (j : Fin 22) : tailGain D (full j) (a j)= + (1/3:ℝ)*∑ k, triangular (h (facePair j k)) := by + have hh := sub_eq_zero.mp (hz j) + change faceBaseline D (a j).c (fun k => (a j).s k)=tailGain D (full j) (a j) at hh + rw [←hh] + have hk (k : Fin 3) : (a j).s k=h (facePair j k) := by + have hk := ha.2 j k + simpa only [TailTuple.h,(hface j).1,zero_add] using hk + simp only [faceBaseline,(hface j).1,Nat.cast_zero,mul_zero,zero_add,hk] + ring + simp_rw [hg] + rw [←Finset.mul_sum,sum_face_pairs (fun e => triangular (h e))] + ring +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open scoped BigOperators + +def plantedTailTuple (D r c : ℕ) (s : Fin 3 → ℕ) + (u : CommonParameters D r c) + (θ : BaseParameters (D-c) (r-u.val.val) (s 0) (s 1) (s 2)) : TailTuple where + c := c + u := u.val.val + v := D-c-θ.val.2.2.2.val + p := ![θ.val.1.val,θ.val.2.1.val,θ.val.2.2.1.val] + t := ![s 0-θ.val.1.val,s 1-θ.val.2.1.val,s 2-θ.val.2.2.1.val] + +theorem plantedTailTuple_s (D r c : ℕ) (s : Fin 3 → ℕ) + (u : CommonParameters D r c) + (θ : BaseParameters (D-c) (r-u.val.val) (s 0) (s 1) (s 2)) (i : Fin 3) : + (plantedTailTuple D r c s u θ).s i = s i := by + have h := θ.property + unfold BaseFeasible at h + fin_cases i <;> simp [plantedTailTuple,TailTuple.s] <;> omega + +theorem plantedTailTuple_feasible (D r c : ℕ) (hD : D=2*r) (hc : c ≤ D) + (s : Fin 3 → ℕ) (hs : (∑ i, s i) ≤ D-c) + (u : CommonParameters D r c) + (θ : BaseParameters (D-c) (r-u.val.val) (s 0) (s 1) (s 2)) : + TailFeasible D true (plantedTailTuple D r c s u θ) := by + have hu := u.property.1 + have huc : u.val.val ≤ c := Nat.le_of_lt_succ u.val.isLt + have hθ := θ.property + unfold BaseFeasible at hθ + have hn : θ.val.2.2.2.val ≤ D-c := Nat.le_of_lt_succ θ.val.2.2.2.isLt + have hdc : ((D-c:ℕ):ℝ) = (D:ℝ)-c := Nat.cast_sub hc + have hru : ((r-u.val.val:ℕ):ℝ) = (r:ℝ)-u.val.val := Nat.cast_sub hu + have hDs : (D:ℝ)=2*r := by exact_mod_cast hD + refine ⟨hc,?_,fun _ => ⟨huc,?_,?_,?_⟩⟩ + · change (∑ i, (plantedTailTuple D r c s u θ).s i) ≤ D-c + simpa only [plantedTailTuple_s] using hs + · intro i + fin_cases i + all_goals dsimp [plantedTailTuple,TailTuple.delta] + · have hh := hθ.2.2.2.2.2.2.2.2.1 + have hh' : ((s 0-θ.val.1.val:ℕ):ℝ)+2*(r-u.val.val:ℕ) ≤ (D-c:ℕ)+θ.val.1.val := by exact_mod_cast hh + rw [hdc,hru] at hh'; linarith + · have hh := hθ.2.2.2.2.2.2.2.2.2.1 + have hh' : ((s 1-θ.val.2.1.val:ℕ):ℝ)+2*(r-u.val.val:ℕ) ≤ (D-c:ℕ)+θ.val.2.1.val := by exact_mod_cast hh + rw [hdc,hru] at hh'; linarith + · have hh := hθ.2.2.2.2.2.2.2.2.2.2.1 + have hh' : ((s 2-θ.val.2.2.1.val:ℕ):ℝ)+2*(r-u.val.val:ℕ) ≤ (D-c:ℕ)+θ.val.2.2.1.val := by exact_mod_cast hh + rw [hdc,hru] at hh'; linarith + · intro i + fin_cases i + all_goals dsimp [plantedTailTuple,TailTuple.delta] + · have hh := hθ.2.2.2.2.2.2.2.2.2.2.2.1 + have hh' : ((D-c-θ.val.2.2.2.val:ℕ):ℝ)+2*(r-u.val.val:ℕ) ≤ (D-c:ℕ)+θ.val.1.val := by exact_mod_cast hh + rw [hdc,hru] at hh'; linarith + · have hh := hθ.2.2.2.2.2.2.2.2.2.2.2.2.1 + have hh' : ((D-c-θ.val.2.2.2.val:ℕ):ℝ)+2*(r-u.val.val:ℕ) ≤ (D-c:ℕ)+θ.val.2.1.val := by exact_mod_cast hh + rw [hdc,hru] at hh'; linarith + · have hh := hθ.2.2.2.2.2.2.2.2.2.2.2.2.2 + have hh' : ((D-c-θ.val.2.2.2.val:ℕ):ℝ)+2*(r-u.val.val:ℕ) ≤ (D-c:ℕ)+θ.val.2.2.1.val := by exact_mod_cast hh + rw [hdc,hru] at hh'; linarith + · have hh := hθ.2.2.2.2.1 + have hh' : (θ.val.2.2.2.val:ℝ)+(θ.val.1.val+θ.val.2.1.val+θ.val.2.2.1.val) ≤ 3*(r-u.val.val:ℕ) := by exact_mod_cast hh + rw [hru] at hh' + simp only [plantedTailTuple,TailTuple.delta,TailTuple.P,Fin.sum_univ_three, + Matrix.cons_val_zero,Matrix.cons_val_one,Matrix.cons_val_two,Matrix.head_cons,Matrix.tail_cons,Nat.cast_sub hn,hdc] + linarith + +noncomputable def fullPlantedExponent (D c r : ℕ) (s : Fin 3 → ℕ) + (u : CommonParameters D r c) + (θ : BaseParameters (D-c) (r-u.val.val) (s 0) (s 1) (s 2)) : ℝ := + ((D:ℝ)+1)*c+(∑ i, triangular (s i))+3*triangular r-4*triangular D+ + isotropicExponent D c+(u.val.val:ℝ)*(c-u.val.val:ℕ)+triangular (D-u.val.val:ℕ)+ + 3*triangular (D-c:ℕ)-3*triangular (r-u.val.val:ℕ)+ + reducedPlantedExponent (D-c) (r-u.val.val) (s 0) (s 1) (s 2) θ.val + +theorem fullPlantedExponent_eq (D c r : ℕ) (hD : D=2*r) (hc : c ≤ D) + (s : Fin 3 → ℕ) (u : CommonParameters D r c) + (θ : BaseParameters (D-c) (r-u.val.val) (s 0) (s 1) (s 2)) : + fullPlantedExponent D c r s u θ = tailGain D true (plantedTailTuple D r c s u θ) := by + have hu := u.property.1 + have huc : u.val.val ≤ c := Nat.le_of_lt_succ u.val.isLt + have huD : u.val.val ≤ D := huc.trans hc + have hθ := θ.property + unfold BaseFeasible at hθ + have hn : θ.val.2.2.2.val ≤ D-c := Nat.le_of_lt_succ θ.val.2.2.2.isLt + have hiso : (isotropicExponent D c:ℝ) + triangular (D-c:ℕ) = triangular D+(c:ℝ)*(D-c:ℕ) := by + have hh := congrArg (Nat.cast : ℕ → ℝ) (isotropicExponent_add D c hc) + simpa only [Nat.cast_add,Nat.cast_mul,triangular_nat] using hh + have hDs : (D:ℝ)=2*r := by exact_mod_cast hD + have h0 : θ.val.1.val ≤ s 0 := hθ.2.2.2.2.2.1 + have h1 : θ.val.2.1.val ≤ s 1 := hθ.2.2.2.2.2.2.1 + have h2 : θ.val.2.2.1.val ≤ s 2 := hθ.2.2.2.2.2.2.2.1 + unfold fullPlantedExponent tailGain plantedGain plantedTailTuple TailTuple.delta reducedPlantedExponent + simp only [ite_true,Fin.sum_univ_three,Matrix.cons_val_zero,Matrix.cons_val_one, + Matrix.cons_val_two,Matrix.head_cons,Matrix.tail_cons,Nat.cast_add,triangular_nat,Nat.cast_sub hn,Nat.cast_sub hc, + Nat.cast_sub hu,Nat.cast_sub huc,Nat.cast_sub huD,Nat.cast_sub h0,Nat.cast_sub h1,Nat.cast_sub h2] + rw [Nat.cast_sub hc] at hiso + dsimp [triangular] at hiso ⊢ + rw [show (isotropicExponent D c:ℝ) = _ from (eq_sub_iff_add_eq.mpr hiso)] + rw [hDs] + ring + +end SidorenkoCounterexample + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/Configurations.lean b/lean/OAI/Combinatorics/Sidorenko/Configurations.lean new file mode 100644 index 0000000000000000000000000000000000000000..c27264728b7ab2bc09d8b0c5800749a1648b6c8c --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/Configurations.lean @@ -0,0 +1,908 @@ +import OAI.Combinatorics.Sidorenko.SubspaceCounts + +namespace OAI + +namespace SidorenkoCounterexample +open Module +section PairSpaceFacts +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] + + theorem triple_pairs_disjoint (L M N : Submodule K E) (h0 : (L ⊓ M) ⊓ N = ⊥) : + Disjoint (L ⊓ M) ((L ⊓ N) ⊔ (M ⊓ N)) ∧ Disjoint (L ⊓ N) (M ⊓ N) := by + constructor + · apply disjoint_iff.mpr + apply le_antisymm _ bot_le + intro x hx + exact h0.le ⟨hx.1,(show (L ⊓ N) ⊔ (M ⊓ N) ≤ N from sup_le inf_le_right inf_le_right) hx.2⟩ + · apply disjoint_iff.mpr + apply le_antisymm _ bot_le + intro x hx + exact h0.le ⟨⟨hx.1.1,hx.2.1⟩,hx.1.2⟩ + + theorem triple_own_avoidance (L M N : Submodule K E) (h0 : (L ⊓ M) ⊓ N = ⊥) : + L ⊓ triplePairSum L M N = (L ⊓ M) ⊔ (L ⊓ N) := by + apply le_antisymm + · intro x hx + obtain ⟨u,hu,v,hv,hxuv⟩ := Submodule.mem_sup.mp hx.2 + have huL : u ∈ L := (show (L ⊓ M) ⊔ (L ⊓ N) ≤ L from sup_le inf_le_left inf_le_left) hu + have hvL : v ∈ L := by + have hh := L.sub_mem hx.1 huL + rw [←hxuv,add_sub_cancel_left] at hh + exact hh + have hz : v = 0 := by simpa only [Submodule.mem_bot] using h0.le ⟨⟨hvL,hv.1⟩,hv.2⟩ + have hxu : u = x := by simpa only [hz,add_zero] using hxuv + exact hxu ▸ hu + · exact le_inf (sup_le inf_le_left inf_le_left) le_sup_left + + theorem reduction_intersection_of_split_kernel (ω : LinearMap.BilinForm K E) + (S L M : Submodule K E) (hS : S ≤ ω.orthogonal S) (hsplit : (L ⊓ S) ⊔ (M ⊓ S) = S) : + reduceSubspace ω S L ⊓ reduceSubspace ω S M = reduceSubspace ω S (L ⊓ M) := by + apply le_antisymm + · rintro x ⟨⟨l,hl,hlx⟩,⟨m,hm,hmx⟩⟩ + have heq : (reductionKernel ω S).mkQ (l-m) = 0 := by rw [map_sub,hlx,hmx,sub_self] + have hdiff : l.val-m.val ∈ (L ⊓ S) ⊔ (M ⊓ S) := by + rw [hsplit] + exact (Submodule.Quotient.mk_eq_zero (reductionKernel ω S)).mp heq + obtain ⟨a,ha,b,hb,hab⟩ := Submodule.mem_sup.mp hdiff + have hla : l.val-a = m.val+b := by + calc + _ = (l.val-m.val)-a+m.val := by abel + _ = (a+b)-a+m.val := by rw [hab] + _ = _ := by abel + have haP : a ∈ ω.orthogonal S := hS ha.2 + exact ⟨⟨l.val-a,(ω.orthogonal S).sub_mem l.property haP⟩, + ⟨L.sub_mem hl ha.1,by change l.val-a ∈ M; rw [hla]; exact M.add_mem hm hb.1⟩,by + change (reductionKernel ω S).mkQ (l-⟨a,haP⟩) = x + have hz : (reductionKernel ω S).mkQ ⟨a,haP⟩ = 0 := + (Submodule.Quotient.mk_eq_zero (reductionKernel ω S)).mpr ha.2 + rw [map_sub,hz,sub_zero,hlx]⟩ + · rintro x ⟨y,hy,rfl⟩ + exact ⟨⟨y,hy.1,rfl⟩,⟨y,hy.2,rfl⟩⟩ +end PairSpaceFacts +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section GenericTransverseMass +variable {K E F : Type*} [Field K] + [AddCommGroup E] [Module K E] [AddCommGroup F] [Module K F] + +noncomputable def orderedTransversePairEquiv + (ω : LinearMap.BilinForm K E) (η : LinearMap.BilinForm K F) + (e : E ≃ₗ[K] F) (he : ∀ x y, η (e x) (e y) = ω x y) : + OrderedTransversePair ω ≃ OrderedTransversePair η := by + let c := symplecticLagrangianEquiv ω η e he + refine (c.prodCongr c).subtypeEquiv ?_ + intro p + change p.1.val ⊓ p.2.val = ⊥ ↔ + p.1.val.map e.toLinearMap ⊓ p.2.val.map e.toLinearMap = ⊥ + rw [←Submodule.map_inf e.toLinearMap e.injective,←Submodule.map_bot e.toLinearMap] + exact (Submodule.map_injective_of_injective e.injective).eq_iff.symm + +variable [Fintype K] [Finite E] +variable (ω : LinearMap.BilinForm K E) + + theorem symplectic_orderedTransversePair_card (h2 : (2 : K) ≠ 0) + (ha : ω.IsAlt) (hω : ω.Nondegenerate) (D : ℕ) (hD : 2*D = finrank K E) : + Nat.card (OrderedTransversePair ω) = Nat.card (SymplecticLagrangian ω) * + Fintype.card K^((D+1).choose 2) := by + obtain ⟨L,_,hL⟩ := exists_containing_lagrangian ω ha ⊥ bot_le + have hd : finrank K L = D := by + have h := self_orthogonal_twice_finrank ω L hω hL + omega + obtain ⟨e,_,he⟩ := exists_lagrangian_coordinates ω L h2 ha hω hL + have hc := Nat.card_congr (symplecticLagrangianEquiv canonicalSymplectic ω e he) + have hp := Nat.card_congr (orderedTransversePairEquiv canonicalSymplectic ω e he) + rw [←hp,orderedTransversePair_card h2,hc,hd] + + theorem symplectic_transverseTriple_card_lower [Invertible (2 : K)] + (ha : ω.IsAlt) (hω : ω.Nondegenerate) (D : ℕ) (hD : 2*D = finrank K E) + (L M N : SymplecticLagrangian ω) + (hLM : L.val ⊓ M.val = ⊥) (hLN : L.val ⊓ N.val = ⊥) (hMN : M.val ⊓ N.val = ⊥) : + Nat.card (SymplecticLagrangian ω) * (Fintype.card K^((D+1).choose 2))^2 ≤ + 4^D * Nat.card (OrderedTripleOrbit ω L.val M.val N.val) := by + have hd : finrank K L.val = D := by + have h := self_orthogonal_twice_finrank ω L.val hω L.property + omega + have hcard := fixedPairOrbit_card_lower ω L.val M.val N.val ha hω + L.property M.property N.property hLM hLN hMN + rw [hd] at hcard + obtain ⟨f,hf⟩ := orderedTripleOrbit_pair_injection ω ha hω L.val M.val N.val + L.property M.property hLM + have hi := Nat.card_le_card_of_injective f hf + rw [Nat.card_prod,symplectic_orderedTransversePair_card ω + (isUnit_of_invertible (2 : K)).ne_zero ha hω D hD] at hi + calc + _ = (Nat.card (SymplecticLagrangian ω) * Fintype.card K^((D+1).choose 2)) * + Fintype.card K^((D+1).choose 2) := by rw [pow_two]; ac_rfl + _ ≤ (Nat.card (SymplecticLagrangian ω) * Fintype.card K^((D+1).choose 2)) * + (4^D * Nat.card (FixedPairOrbit ω L.val M.val N.val)) := Nat.mul_le_mul_left _ hcard + _ = 4^D * (Nat.card (SymplecticLagrangian ω) * Fintype.card K^((D+1).choose 2) * + Nat.card (FixedPairOrbit ω L.val M.val N.val)) := by ring + _ ≤ _ := Nat.mul_le_mul_left _ hi + + theorem symplectic_transverseTriple_probability_lower [Invertible (2 : K)] + (ha : ω.IsAlt) (hω : ω.Nondegenerate) (D : ℕ) (hD : 2*D = finrank K E) + (L M N : SymplecticLagrangian ω) + (hLM : L.val ⊓ M.val = ⊥) (hLN : L.val ⊓ N.val = ⊥) (hMN : M.val ⊓ N.val = ⊥) : + (Nat.card (SymplecticLagrangian ω) : ℝ)^3 ≤ + (4^D * lagrangianConstant D^2) * Nat.card (OrderedTripleOrbit ω L.val M.val N.val) := by + have hb := (symplecticLagrangian_card_bounds ω (isUnit_of_invertible (2 : K)).ne_zero ha hω D hD).2 + have ho : (Nat.card (SymplecticLagrangian ω) : ℝ) * + ((Fintype.card K : ℝ)^((D+1).choose 2))^2 ≤ + 4^D * Nat.card (OrderedTripleOrbit ω L.val M.val N.val) := by + exact_mod_cast symplectic_transverseTriple_card_lower ω ha hω D hD L M N hLM hLN hMN + calc + _ = (Nat.card (SymplecticLagrangian ω) : ℝ) * (Nat.card (SymplecticLagrangian ω) : ℝ)^2 := by ring + _ ≤ (Nat.card (SymplecticLagrangian ω) : ℝ) * + (lagrangianConstant D * (Fintype.card K : ℝ)^((D+1).choose 2))^2 := by gcongr + _ = lagrangianConstant D^2 * ((Nat.card (SymplecticLagrangian ω) : ℝ) * + ((Fintype.card K : ℝ)^((D+1).choose 2))^2) := by ring + _ ≤ lagrangianConstant D^2 * (4^D * Nat.card (OrderedTripleOrbit ω L.val M.val N.val)) := + mul_le_mul_of_nonneg_left ho (sq_nonneg _) + _ = _ := by ring +end GenericTransverseMass +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section ResidualTransversality +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] +variable (ω : LinearMap.BilinForm K E) + + theorem reduceSubspace_eq_bot_of_le (S L : Submodule K E) (hLS : L ≤ S) : + reduceSubspace ω S L = ⊥ := by + apply (Submodule.eq_bot_iff _).mpr + rintro x ⟨y,hy,rfl⟩ + exact (Submodule.Quotient.mk_eq_zero (reductionKernel ω S)).mpr (hLS hy) + + theorem triplePairSum_split (L M N : Submodule K E) : + (L ⊓ triplePairSum L M N) ⊔ (M ⊓ triplePairSum L M N) = triplePairSum L M N := by + apply le_antisymm (sup_le inf_le_right inf_le_right) + unfold triplePairSum + apply sup_le (sup_le _ _) _ + · exact (le_inf inf_le_left (le_sup_left.trans le_sup_left)).trans le_sup_left + · exact (le_inf inf_le_left (le_sup_right.trans le_sup_left)).trans le_sup_left + · exact (le_inf inf_le_left le_sup_right).trans le_sup_right + + theorem triplePairSum_reduce_pair (L M N : Submodule K E) + (hL : ω.orthogonal L = L) (hM : ω.orthogonal M = M) (hN : ω.orthogonal N = N) : + reduceSubspace ω (triplePairSum L M N) L ⊓ + reduceSubspace ω (triplePairSum L M N) M = ⊥ := by + rw [reduction_intersection_of_split_kernel ω _ L M + (triplePairSum_isotropic ω L M N hL hM hN) (triplePairSum_split L M N)] + exact reduceSubspace_eq_bot_of_le ω _ _ (le_sup_left.trans le_sup_left) + + theorem triplePairSum_reductions_transverse (L M N : Submodule K E) + (hL : ω.orthogonal L = L) (hM : ω.orthogonal M = M) (hN : ω.orthogonal N = N) : + let S := triplePairSum L M N + reduceSubspace ω S L ⊓ reduceSubspace ω S M = ⊥ ∧ + reduceSubspace ω S L ⊓ reduceSubspace ω S N = ⊥ ∧ + reduceSubspace ω S M ⊓ reduceSubspace ω S N = ⊥ := by + dsimp only + refine ⟨triplePairSum_reduce_pair ω L M N hL hM hN,?_,?_⟩ + · have hs : triplePairSum L N M = triplePairSum L M N := by + unfold triplePairSum + rw [inf_comm N M,sup_comm (L ⊓ N) (L ⊓ M)] + have h := triplePairSum_reduce_pair ω L N M hL hN hM + rw [hs] at h + exact h + · have hs : triplePairSum M N L = triplePairSum L M N := by + unfold triplePairSum + rw [inf_comm M L,inf_comm N L] + ac_rfl + have h := triplePairSum_reduce_pair ω M N L hM hN hL + rw [hs] at h + exact h +end ResidualTransversality + +section LagrangianTripleOrbit +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] +variable (ω : LinearMap.BilinForm K E) (L M N : SymplecticLagrangian ω) + +abbrev LagTripleOrbit := {p : SymplecticLagrangian ω × SymplecticLagrangian ω × SymplecticLagrangian ω // + TripleIsometry ω ω L.val M.val N.val p.1.val p.2.1.val p.2.2.val} + + theorem orderedTripleOrbit_lagrangians (p : OrderedTripleOrbit ω L.val M.val N.val) : + ω.orthogonal p.val.1 = p.val.1 ∧ ω.orthogonal p.val.2.1 = p.val.2.1 ∧ + ω.orthogonal p.val.2.2 = p.val.2.2 := by + obtain ⟨e,he,hL,hM,hN⟩ := p.property + rw [←hL,←hM,←hN,orthogonal_map_of_isometry ω e he,orthogonal_map_of_isometry ω e he, + orthogonal_map_of_isometry ω e he,L.property,M.property,N.property] + exact ⟨rfl,rfl,rfl⟩ + +noncomputable def lagTripleOrbitEquiv : LagTripleOrbit ω L M N ≃ OrderedTripleOrbit ω L.val M.val N.val where + toFun p := ⟨(p.val.1.val,p.val.2.1.val,p.val.2.2.val),p.property⟩ + invFun p := ⟨(⟨p.val.1,(orderedTripleOrbit_lagrangians ω L M N p).1⟩, + ⟨p.val.2.1,(orderedTripleOrbit_lagrangians ω L M N p).2.1⟩, + ⟨p.val.2.2,(orderedTripleOrbit_lagrangians ω L M N p).2.2⟩),p.property⟩ + left_inv _ := rfl + right_inv _ := rfl +end LagrangianTripleOrbit + +section AvoidanceTripleCount +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] + [Fintype K] [Finite E] +variable (ω : LinearMap.BilinForm K E) (S : Submodule K E) +variable (ha : ω.IsAlt) (hω : ω.Nondegenerate) (hS : S ≤ ω.orthogonal S) + +noncomputable def avoidanceTripleReduction (A B C : Submodule K E) : + (AvoidanceSpace ω S A × AvoidanceSpace ω S B × AvoidanceSpace ω S C) → + SymplecticLagrangian (symplecticReductionForm ω S ha) × + SymplecticLagrangian (symplecticReductionForm ω S ha) × + SymplecticLagrangian (symplecticReductionForm ω S ha) := fun p => + (avoidanceReduction ω S ha hω hS A p.1, + avoidanceReduction ω S ha hω hS B p.2.1,avoidanceReduction ω S ha hω hS C p.2.2) + + theorem avoidanceTripleReduction_uniform (h2 : (2 : K) ≠ 0) + (A B C : Submodule K E) (hA : A ≤ S) (hB : B ≤ S) (hC : C ≤ S) + (p : SymplecticLagrangian (symplecticReductionForm ω S ha) × + SymplecticLagrangian (symplecticReductionForm ω S ha) × + SymplecticLagrangian (symplecticReductionForm ω S ha)) : + Nat.card {x // avoidanceTripleReduction ω S ha hω hS A B C x = p} * + Nat.card (SymplecticLagrangian (symplecticReductionForm ω S ha) × + SymplecticLagrangian (symplecticReductionForm ω S ha) × + SymplecticLagrangian (symplecticReductionForm ω S ha)) = + Nat.card (AvoidanceSpace ω S A × AvoidanceSpace ω S B × AvoidanceSpace ω S C) := by + let : Finite (ReducedSpace ω S) := Module.finite_of_finite K + exact uniform_prod_card _ _ (avoidanceReduction_uniform ω S h2 ha hω hS A hA) + (uniform_prod_card _ _ (avoidanceReduction_uniform ω S h2 ha hω hS B hB) + (avoidanceReduction_uniform ω S h2 ha hω hS C hC)) p + +abbrev AvoidanceOrbitFiber (A B C : Submodule K E) + (L M N : SymplecticLagrangian (symplecticReductionForm ω S ha)) := + {p : AvoidanceSpace ω S A × AvoidanceSpace ω S B × AvoidanceSpace ω S C // + TripleIsometry (symplecticReductionForm ω S ha) (symplecticReductionForm ω S ha) + L.val M.val N.val (reduceSubspace ω S p.1.val) + (reduceSubspace ω S p.2.1.val) (reduceSubspace ω S p.2.2.val)} + +include hω hS in + theorem avoidanceOrbitFiber_card_identity (h2 : (2 : K) ≠ 0) + (A B C : Submodule K E) (hA : A ≤ S) (hB : B ≤ S) (hC : C ≤ S) + (L M N : SymplecticLagrangian (symplecticReductionForm ω S ha)) : + Nat.card (AvoidanceOrbitFiber ω S ha A B C L M N) * + Nat.card (SymplecticLagrangian (symplecticReductionForm ω S ha))^3 = + Nat.card (OrderedTripleOrbit (symplecticReductionForm ω S ha) L.val M.val N.val) * + (Nat.card (AvoidanceSpace ω S A) * (Nat.card (AvoidanceSpace ω S B) * Nat.card (AvoidanceSpace ω S C))) := by + let : Finite (ReducedSpace ω S) := Module.finite_of_finite K + have h := uniform_preimage_card (avoidanceTripleReduction ω S ha hω hS A B C) + (avoidanceTripleReduction_uniform ω S ha hω hS h2 A B C hA hB hC) + (fun p => TripleIsometry (symplecticReductionForm ω S ha) (symplecticReductionForm ω S ha) + L.val M.val N.val p.1.val p.2.1.val p.2.2.val) + change Nat.card (AvoidanceOrbitFiber ω S ha A B C L M N) * _ = + Nat.card (LagTripleOrbit _ L M N) * _ at h + rw [Nat.card_congr (lagTripleOrbitEquiv _ L M N)] at h + simp only [Nat.card_prod] at h + convert h using 1; ring +end AvoidanceTripleCount +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section AvoidanceTripleBound +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] + [Fintype K] [Finite E] [Invertible (2 : K)] +variable (ω : LinearMap.BilinForm K E) (S : Submodule K E) + + theorem avoidanceOrbitFiber_card_lower (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (hS : S ≤ ω.orthogonal S) (z : ℕ) (hz : 2*z = finrank K (ReducedSpace ω S)) + (A B C : Submodule K E) (hA : A ≤ S) (hB : B ≤ S) (hC : C ≤ S) + (L M N : SymplecticLagrangian (symplecticReductionForm ω S ha)) + (hLM : L.val ⊓ M.val = ⊥) (hLN : L.val ⊓ N.val = ⊥) (hMN : M.val ⊓ N.val = ⊥) : + (Nat.card (AvoidanceSpace ω S A) : ℝ) * (Nat.card (AvoidanceSpace ω S B) * Nat.card (AvoidanceSpace ω S C)) ≤ + (4^z * lagrangianConstant z^2) * Nat.card (AvoidanceOrbitFiber ω S ha A B C L M N) := by + let : Finite (ReducedSpace ω S) := Module.finite_of_finite K + let Ω := symplecticReductionForm ω S ha + have hΩ := symplecticReductionForm_alt ω S ha + have hp := symplecticLagrangian_card_pos Ω hΩ + have hb := symplectic_transverseTriple_probability_lower Ω hΩ + (symplecticReductionForm_nondegenerate ω S ha hω) z hz L M N hLM hLN hMN + have hi : (Nat.card (AvoidanceOrbitFiber ω S ha A B C L M N) : ℝ) * + (Nat.card (SymplecticLagrangian Ω) : ℝ)^3 = + (Nat.card (OrderedTripleOrbit Ω L.val M.val N.val) : ℝ) * + (Nat.card (AvoidanceSpace ω S A) * (Nat.card (AvoidanceSpace ω S B) * Nat.card (AvoidanceSpace ω S C))) := by + exact_mod_cast avoidanceOrbitFiber_card_identity ω S ha hω hS + (isUnit_of_invertible (2 : K)).ne_zero A B C hA hB hC L M N + have hpos : 0 < (Nat.card (SymplecticLagrangian Ω) : ℝ)^3 := by exact pow_pos (by exact_mod_cast hp) _ + apply (mul_le_mul_iff_left₀ hpos).mp + calc + _ ≤ ((Nat.card (AvoidanceSpace ω S A) : ℝ) * + (Nat.card (AvoidanceSpace ω S B) * Nat.card (AvoidanceSpace ω S C))) * + ((4^z * lagrangianConstant z^2) * Nat.card (OrderedTripleOrbit Ω L.val M.val N.val)) := + mul_le_mul_of_nonneg_left hb (by positivity) + _ = (4^z * lagrangianConstant z^2) * + ((Nat.card (OrderedTripleOrbit Ω L.val M.val N.val) : ℝ) * + (Nat.card (AvoidanceSpace ω S A) * (Nat.card (AvoidanceSpace ω S B) * Nat.card (AvoidanceSpace ω S C)))) := by ring + _ = _ := by rw [←hi]; ring + + theorem containmentOrbitFiber_card_lower (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (hS : S ≤ ω.orthogonal S) (D : ℕ) (hD : 2*D = finrank K E) + (hq : 4 * lagrangianConstant D ≤ (Fintype.card K : ℝ)) + (A B C : Submodule K E) (hA : A ≤ S) (hB : B ≤ S) (hC : C ≤ S) + (L M N : SymplecticLagrangian (symplecticReductionForm ω S ha)) + (hLM : L.val ⊓ M.val = ⊥) (hLN : L.val ⊓ N.val = ⊥) (hMN : M.val ⊓ N.val = ⊥) : + (Nat.card {L : SymplecticLagrangian ω // A ≤ L.val} : ℝ) * + (Nat.card {L : SymplecticLagrangian ω // B ≤ L.val} * + Nat.card {L : SymplecticLagrangian ω // C ≤ L.val}) ≤ + (8 * (4^D * lagrangianConstant D^2)) * Nat.card (AvoidanceOrbitFiber ω S ha A B C L M N) := by + have h2 := (isUnit_of_invertible (2 : K)).ne_zero + have h₁ : (Nat.card {L : SymplecticLagrangian ω // A ≤ L.val} : ℝ) ≤ + 2*Nat.card (AvoidanceSpace ω S A) := by + exact_mod_cast avoidance_card_lower ω h2 ha hω D hD A S hA hS hq + have h₂ : (Nat.card {L : SymplecticLagrangian ω // B ≤ L.val} : ℝ) ≤ + 2*Nat.card (AvoidanceSpace ω S B) := by + exact_mod_cast avoidance_card_lower ω h2 ha hω D hD B S hB hS hq + have h₃ : (Nat.card {L : SymplecticLagrangian ω // C ≤ L.val} : ℝ) ≤ + 2*Nat.card (AvoidanceSpace ω S C) := by + exact_mod_cast avoidance_card_lower ω h2 ha hω D hD C S hC hS hq + have hr := reducedSpace_finrank ω S hω hS + have hs := isotropic_finrank_le_half ω hω D hD S hS + have hb := avoidanceOrbitFiber_card_lower ω S ha hω hS (D-finrank K S) (by omega) + A B C hA hB hC L M N hLM hLN hMN + have hk : (4:ℝ)^(D-finrank K S) * lagrangianConstant (D-finrank K S)^2 ≤ + 4^D * lagrangianConstant D^2 := by + gcongr + · norm_num + · exact Nat.sub_le D _ + · exact le_of_lt (lagrangianConstant_pos _) + · exact lagrangianConstant_mono (Nat.sub_le D _) + calc + _ ≤ ((2:ℝ)*Nat.card (AvoidanceSpace ω S A)) * + ((2*Nat.card (AvoidanceSpace ω S B)) * (2*Nat.card (AvoidanceSpace ω S C))) := by gcongr + _ = 8 * ((Nat.card (AvoidanceSpace ω S A) : ℝ) * + (Nat.card (AvoidanceSpace ω S B) * Nat.card (AvoidanceSpace ω S C))) := by ring + _ ≤ 8 * (((4:ℝ)^(D-finrank K S) * lagrangianConstant (D-finrank K S)^2) * + Nat.card (AvoidanceOrbitFiber ω S ha A B C L M N)) := mul_le_mul_of_nonneg_left hb (by norm_num) + _ ≤ 8 * ((4^D * lagrangianConstant D^2) * + Nat.card (AvoidanceOrbitFiber ω S ha A B C L M N)) := + mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right hk (by positivity)) (by norm_num) + _ = _ := by ring +end AvoidanceTripleBound +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section IsotropicExtension +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] + [FiniteDimensional K E] [Finite E] +variable (ω : LinearMap.BilinForm K E) + +/-- A prescribed linear isomorphism of isotropic spaces extends to an actual +symplectic automorphism, not only to a dimension-preserving correspondence. -/ + theorem exists_isotropic_isometry_extension (h2 : (2 : K) ≠ 0) (ha : ω.IsAlt) + (hω : ω.Nondegenerate) (S T : Submodule K E) + (hS : S ≤ ω.orthogonal S) (hT : T ≤ ω.orthogonal T) (g : S ≃ₗ[K] T) : + ∃ e : E ≃ₗ[K] E, (∀ x y, ω (e x) (e y) = ω x y) ∧ + ∀ x : S, e x.val = (g x).val := by + obtain ⟨L,hSL,hL⟩ := exists_containing_lagrangian ω ha S hS + obtain ⟨M,hTM,hM⟩ := exists_containing_lagrangian ω ha T hT + obtain ⟨eL,hEL,hωL⟩ := exists_lagrangian_coordinates ω L h2 ha hω hL + obtain ⟨eM,hEM,hωM⟩ := exists_lagrangian_coordinates ω M h2 ha hω hM + have hdim : finrank K L = finrank K M := by + have h1 := self_orthogonal_twice_finrank ω L hω hL + have h2 := self_orthogonal_twice_finrank ω M hω hM + omega + let U := S.comap L.subtype + let W := T.comap M.subtype + let g₀ : U ≃ₗ[K] W := (Submodule.comapSubtypeEquivOfLe hSL).trans + (g.trans (Submodule.comapSubtypeEquivOfLe hTM).symm) + obtain ⟨f,hf⟩ := exists_linearEquiv_extension U W hdim g₀ + let c : (L × Module.Dual K L) ≃ₗ[K] (M × Module.Dual K M) := f.prodCongr f.symm.dualMap + have hc (x y : L × Module.Dual K L) : + canonicalSymplectic (c x) (c y) = canonicalSymplectic x y := by + simp [c,canonicalSymplectic_apply] + let e := eL.symm.trans (c.trans eM) + have he (l : L) : e l.val = (f l).val := by + change eM (c (eL.symm l.val)) = (f l).val + rw [←hEL l,eL.symm_apply_apply] + simpa [c] using hEM (f l) + refine ⟨e,?_,?_⟩ + · intro x y + change ω (eM (c (eL.symm x))) (eM (c (eL.symm y))) = ω x y + rw [hωM,hc,←hωL,eL.apply_symm_apply,eL.apply_symm_apply] + · intro x + let u : U := ⟨⟨x.val,hSL x.property⟩,x.property⟩ + change e u.val.val = (g x).val + rw [he,hf u] + rfl +end IsotropicExtension +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section FixedPairs +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] +variable (ω : LinearMap.BilinForm K E) (L M N : SymplecticLagrangian ω) + +abbrev FixedPairTripleOrbit := {p : LagTripleOrbit ω L M N // + p.val.1.val ⊓ p.val.2.1.val = L.val ⊓ M.val ∧ + p.val.1.val ⊓ p.val.2.2.val = L.val ⊓ N.val ∧ + p.val.2.1.val ⊓ p.val.2.2.val = M.val ⊓ N.val} + + theorem triplePair_inter_own (P Q R : Submodule K E) : + (P ⊓ triplePairSum P Q R) ⊓ (Q ⊓ triplePairSum P Q R) = P ⊓ Q := by + apply le_antisymm (inf_le_inf inf_le_left inf_le_left) + intro x hx + have hs : x ∈ triplePairSum P Q R := + (show P ⊓ Q ≤ triplePairSum P Q R from le_sup_left.trans le_sup_left) hx + exact ⟨⟨hx.1,hs⟩,⟨hx.2,hs⟩⟩ + + theorem triplePairSum_split_all (P Q R : Submodule K E) : + let S := triplePairSum P Q R + ((P ⊓ S) ⊔ (Q ⊓ S) = S) ∧ ((P ⊓ S) ⊔ (R ⊓ S) = S) ∧ + ((Q ⊓ S) ⊔ (R ⊓ S) = S) := by + dsimp only + have h₁ : triplePairSum P R Q = triplePairSum P Q R := by unfold triplePairSum; ac_rfl + have h₂ : triplePairSum Q R P = triplePairSum P Q R := by unfold triplePairSum; ac_rfl + exact ⟨triplePairSum_split P Q R,by simpa only [h₁] using triplePairSum_split P R Q, + by simpa only [h₂] using triplePairSum_split Q R P⟩ + + theorem triplePair_inter_all (P Q R : Submodule K E) : + let S := triplePairSum P Q R + ((P ⊓ S) ⊓ (Q ⊓ S) = P ⊓ Q) ∧ ((P ⊓ S) ⊓ (R ⊓ S) = P ⊓ R) ∧ + ((Q ⊓ S) ⊓ (R ⊓ S) = Q ⊓ R) := by + dsimp only + have h₁ : triplePairSum P R Q = triplePairSum P Q R := by unfold triplePairSum; ac_rfl + have h₂ : triplePairSum Q R P = triplePairSum P Q R := by unfold triplePairSum; ac_rfl + exact ⟨triplePair_inter_own P Q R,by simpa only [h₁] using triplePair_inter_own P R Q, + by simpa only [h₂] using triplePair_inter_own Q R P⟩ + +variable [FiniteDimensional K E] +variable (ha : ω.IsAlt) (hω : ω.Nondegenerate) + +noncomputable def tripleResidualLagrangian (P : SymplecticLagrangian ω) : + SymplecticLagrangian (symplecticReductionForm ω (triplePairSum L.val M.val N.val) ha) := + ⟨reduceSubspace ω (triplePairSum L.val M.val N.val) P.val, + general_lagrangian_reduction ω _ ha hω + (triplePairSum_isotropic ω _ _ _ L.property M.property N.property) P.val P.property⟩ + +abbrev OwnAvoidanceOrbitFiber := + AvoidanceOrbitFiber ω (triplePairSum L.val M.val N.val) ha + (L.val ⊓ triplePairSum L.val M.val N.val) + (M.val ⊓ triplePairSum L.val M.val N.val) + (N.val ⊓ triplePairSum L.val M.val N.val) + (tripleResidualLagrangian ω L M N ha hω L) + (tripleResidualLagrangian ω L M N ha hω M) + (tripleResidualLagrangian ω L M N ha hω N) + + theorem ownAvoidanceOrbitFiber_pairs (p : OwnAvoidanceOrbitFiber ω L M N ha hω) : + p.val.1.val ⊓ p.val.2.1.val = L.val ⊓ M.val ∧ + p.val.1.val ⊓ p.val.2.2.val = L.val ⊓ N.val ∧ + p.val.2.1.val ⊓ p.val.2.2.val = M.val ⊓ N.val := by + let S := triplePairSum L.val M.val N.val + have hs := triplePairSum_split_all L.val M.val N.val + have hi := triplePair_inter_all L.val M.val N.val + have ht := triplePairSum_reductions_transverse ω L.val M.val N.val L.property M.property N.property + obtain ⟨e,he,h₁,h₂,h₃⟩ := p.property + dsimp only [tripleResidualLagrangian] at h₁ h₂ h₃ + have hp₁ : reduceSubspace ω S p.val.1.val ⊓ reduceSubspace ω S p.val.2.1.val = ⊥ := by + rw [←h₁,←h₂,←Submodule.map_inf e.toLinearMap e.injective,ht.1,Submodule.map_bot] + have hp₂ : reduceSubspace ω S p.val.1.val ⊓ reduceSubspace ω S p.val.2.2.val = ⊥ := by + rw [←h₁,←h₃,←Submodule.map_inf e.toLinearMap e.injective,ht.2.1,Submodule.map_bot] + have hp₃ : reduceSubspace ω S p.val.2.1.val ⊓ reduceSubspace ω S p.val.2.2.val = ⊥ := by + rw [←h₂,←h₃,←Submodule.map_inf e.toLinearMap e.injective,ht.2.2,Submodule.map_bot] + refine ⟨?_,?_,?_⟩ + · exact (avoidance_exact_intersection ω S _ _ _ _ p.val.1.property.1 p.val.2.1.property.1 + p.val.1.property.2 p.val.2.1.property.2 hs.1 hp₁).trans hi.1 + · exact (avoidance_exact_intersection ω S _ _ _ _ p.val.1.property.1 p.val.2.2.property.1 + p.val.1.property.2 p.val.2.2.property.2 hs.2.1 hp₂).trans hi.2.1 + · exact (avoidance_exact_intersection ω S _ _ _ _ p.val.2.1.property.1 p.val.2.2.property.1 + p.val.2.1.property.2 p.val.2.2.property.2 hs.2.2 hp₃).trans hi.2.2 + +noncomputable def ownAvoidanceOrbitFiberEmbedding (h0 : (L.val ⊓ M.val) ⊓ N.val = ⊥) : + OwnAvoidanceOrbitFiber ω L M N ha hω ↪ FixedPairTripleOrbit ω L M N where + toFun p := by + have hp := ownAvoidanceOrbitFiber_pairs ω L M N ha hω p + have hs : triplePairSum p.val.1.val p.val.2.1.val p.val.2.2.val = + triplePairSum L.val M.val N.val := by unfold triplePairSum; rw [hp.1,hp.2.1,hp.2.2] + have hp0 : (p.val.1.val ⊓ p.val.2.1.val) ⊓ p.val.2.2.val = ⊥ := by + calc + _ = (p.val.1.val ⊓ p.val.2.1.val) ⊓ (p.val.1.val ⊓ p.val.2.2.val) := by ac_rfl + _ = (L.val ⊓ M.val) ⊓ (L.val ⊓ N.val) := by rw [hp.1,hp.2.1] + _ = (L.val ⊓ M.val) ⊓ N.val := by ac_rfl + _ = ⊥ := h0 + have hr : TripleResidualIsometry ω ω ha ha L.val M.val N.val p.val.1.val p.val.2.1.val p.val.2.2.val := by + unfold TripleResidualIsometry + rw [hs] + exact p.property + have ho := triple_common_zero_classification ω ω ha ha hω hω _ _ _ _ _ _ + L.property M.property N.property p.val.1.property.1 p.val.2.1.property.1 p.val.2.2.property.1 + h0 hp0 (by rw [hp.1]) (by rw [hp.2.1]) (by rw [hp.2.2]) hr + exact ⟨⟨(⟨p.val.1.val,p.val.1.property.1⟩,⟨p.val.2.1.val,p.val.2.1.property.1⟩, + ⟨p.val.2.2.val,p.val.2.2.property.1⟩),ho⟩,hp⟩ + inj' := by + intro p q h + apply Subtype.ext + have hval := congrArg (fun x : FixedPairTripleOrbit ω L M N => + (x.val.val.1.val,x.val.val.2.1.val,x.val.val.2.2.val)) h + exact Prod.ext (Subtype.ext (congrArg Prod.fst hval)) + (Prod.ext (Subtype.ext (congrArg (fun x => x.2.1) hval)) + (Subtype.ext (congrArg (fun x => x.2.2) hval))) +end FixedPairs +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section ConfigurationOrbit +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] +variable (ω : LinearMap.BilinForm K E) + + theorem subspace_map_extension (S T U : Submodule K E) (hU : U ≤ S) + (e : E ≃ₗ[K] E) (g : S ≃ₗ[K] T) (he : ∀ x : S, e x.val = (g x).val) : + U.map e.toLinearMap = ((U.comap S.subtype).map g.toLinearMap).map T.subtype := by + ext x + constructor + · rintro ⟨y,hy,rfl⟩ + exact ⟨g ⟨y,hU hy⟩,⟨⟨y,hU hy⟩,hy,rfl⟩,(he ⟨y,hU hy⟩).symm⟩ + · rintro ⟨y,⟨z,hz,rfl⟩,rfl⟩ + exact ⟨z.val,hz,he z⟩ + + theorem subtype_map_comap_of_le (S U : Submodule K E) (hU : U ≤ S) : + (U.comap S.subtype).map S.subtype = U := by + ext x + exact ⟨fun ⟨y,hy,hyx⟩ => hyx ▸ hy,fun hx => ⟨⟨x,hU hx⟩,hx,rfl⟩⟩ + + theorem subspace_comap_sup_of_le (S U V : Submodule K E) (hU : U ≤ S) (hV : V ≤ S) : + (U ⊔ V).comap S.subtype = U.comap S.subtype ⊔ V.comap S.subtype := by + apply Submodule.map_injective_of_injective S.subtype_injective + rw [Submodule.map_sup,subtype_map_comap_of_le S U hU,subtype_map_comap_of_le S V hV, + subtype_map_comap_of_le S (U ⊔ V) (sup_le hU hV)] + +variable [FiniteDimensional K E] [Finite E] + + theorem triple_subspace_orbit_injection (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (S U V W : Submodule K E) (hS : S ≤ ω.orthogonal S) + (hU : U ≤ S) (hV : V ≤ S) (hW : W ≤ S) (hsum : U ⊔ V ⊔ W = S) : + ∃ f : IsotropicDimspace ω (finrank K S) × + TripleLinearOrbit (U.comap S.subtype) (V.comap S.subtype) (W.comap S.subtype) → + OrderedTripleOrbit ω U V W, Function.Injective f := by + classical + have ht (T : IsotropicDimspace ω (finrank K S)) := isotropic_transitivity ω h2 ha hω + S T.val hS T.property.1 T.property.2.symm + let e (T : IsotropicDimspace ω (finrank K S)) := (ht T).choose + have he (T) := (ht T).choose_spec + have hgood (T : IsotropicDimspace ω (finrank K S)) + (p : TripleLinearOrbit (U.comap S.subtype) (V.comap S.subtype) (W.comap S.subtype)) : + ∃ f : E ≃ₗ[K] E, (∀ x y, ω (f x) (f y) = ω x y) ∧ + U.map f.toLinearMap = (p.val.1.map S.subtype).map (e T).toLinearMap ∧ + V.map f.toLinearMap = (p.val.2.1.map S.subtype).map (e T).toLinearMap ∧ + W.map f.toLinearMap = (p.val.2.2.map S.subtype).map (e T).toLinearMap := by + obtain ⟨g,hgU,hgV,hgW⟩ := p.property + obtain ⟨r,hr,hrg⟩ := exists_isotropic_isometry_extension ω h2 ha hω S S hS hS g + refine ⟨r.trans (e T),?_,?_,?_,?_⟩ + · intro x y + exact ((he T).1 (r x) (r y)).trans (hr x y) + · rw [submodule_map_trans,subspace_map_extension S S U hU r g hrg,hgU] + · rw [submodule_map_trans,subspace_map_extension S S V hV r g hrg,hgV] + · rw [submodule_map_trans,subspace_map_extension S S W hW r g hrg,hgW] + let f : IsotropicDimspace ω (finrank K S) × + TripleLinearOrbit (U.comap S.subtype) (V.comap S.subtype) (W.comap S.subtype) → + OrderedTripleOrbit ω U V W := fun p => + ⟨((p.2.val.1.map S.subtype).map (e p.1).toLinearMap, + (p.2.val.2.1.map S.subtype).map (e p.1).toLinearMap, + (p.2.val.2.2.map S.subtype).map (e p.1).toLinearMap),hgood p.1 p.2⟩ + have hsum' (p : TripleLinearOrbit (U.comap S.subtype) (V.comap S.subtype) (W.comap S.subtype)) : + p.val.1 ⊔ p.val.2.1 ⊔ p.val.2.2 = ⊤ := by + obtain ⟨g,hgU,hgV,hgW⟩ := p.property + rw [←hgU,←hgV,←hgW,←Submodule.map_sup,←Submodule.map_sup, + ←subspace_comap_sup_of_le S U V hU hV, + ←subspace_comap_sup_of_le S (U ⊔ V) W (sup_le hU hV) hW,hsum] + simp + have hrecover (p) : (f p).val.1 ⊔ (f p).val.2.1 ⊔ (f p).val.2.2 = p.1.val := by + change ((p.2.val.1.map S.subtype).map (e p.1).toLinearMap) ⊔ + ((p.2.val.2.1.map S.subtype).map (e p.1).toLinearMap) ⊔ + ((p.2.val.2.2.map S.subtype).map (e p.1).toLinearMap) = _ + rw [←Submodule.map_sup,←Submodule.map_sup,←Submodule.map_sup,←Submodule.map_sup,hsum'] + simpa only [Submodule.map_top,Submodule.range_subtype] using (he p.1).2 + refine ⟨f,?_⟩ + rintro ⟨T,p⟩ ⟨T',p'⟩ h + have hT : T = T' := by + apply Subtype.ext + exact (hrecover (T,p)).symm.trans ((congrArg (fun x : OrderedTripleOrbit ω U V W => + x.val.1 ⊔ x.val.2.1 ⊔ x.val.2.2) h).trans (hrecover (T',p'))) + subst T' + have hv := congrArg Subtype.val h + have hinj := (Submodule.map_injective_of_injective (e T).injective).comp + (Submodule.map_injective_of_injective S.subtype_injective) + have hp : p = p' := Subtype.ext (Prod.ext (hinj (congrArg Prod.fst hv)) + (Prod.ext (hinj (congrArg (fun x => x.2.1) hv)) (hinj (congrArg (fun x => x.2.2) hv)))) + subst p' + rfl +end ConfigurationOrbit +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section PairOrbitAssembly +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] +variable (ω : LinearMap.BilinForm K E) (L M N : SymplecticLagrangian ω) + + theorem fullTripleOrbit_fixedPair_injection : + ∃ f : OrderedTripleOrbit ω (L.val ⊓ M.val) (L.val ⊓ N.val) (M.val ⊓ N.val) × + FixedPairTripleOrbit ω L M N → OrderedTripleOrbit ω L.val M.val N.val, + Function.Injective f := by + classical + let e (p : OrderedTripleOrbit ω (L.val ⊓ M.val) (L.val ⊓ N.val) (M.val ⊓ N.val)) := + p.property.choose + have he (p : OrderedTripleOrbit ω (L.val ⊓ M.val) (L.val ⊓ N.val) (M.val ⊓ N.val)) := p.property.choose_spec + have hgood (p : OrderedTripleOrbit ω (L.val ⊓ M.val) (L.val ⊓ N.val) (M.val ⊓ N.val)) + (q : FixedPairTripleOrbit ω L M N) : + TripleIsometry ω ω L.val M.val N.val (q.val.val.1.val.map (e p).toLinearMap) + (q.val.val.2.1.val.map (e p).toLinearMap) (q.val.val.2.2.val.map (e p).toLinearMap) := by + obtain ⟨g,hg,hgL,hgM,hgN⟩ := q.val.property + refine ⟨g.trans (e p),?_,?_,?_,?_⟩ + · intro x y + exact ((he p).1 (g x) (g y)).trans (hg x y) + · rw [submodule_map_trans,hgL] + · rw [submodule_map_trans,hgM] + · rw [submodule_map_trans,hgN] + let f : OrderedTripleOrbit ω (L.val ⊓ M.val) (L.val ⊓ N.val) (M.val ⊓ N.val) × + FixedPairTripleOrbit ω L M N → OrderedTripleOrbit ω L.val M.val N.val := fun p => + ⟨(p.2.val.val.1.val.map (e p.1).toLinearMap, + p.2.val.val.2.1.val.map (e p.1).toLinearMap, + p.2.val.val.2.2.val.map (e p.1).toLinearMap),hgood p.1 p.2⟩ + have hrec (p) : ((f p).val.1 ⊓ (f p).val.2.1, + (f p).val.1 ⊓ (f p).val.2.2,(f p).val.2.1 ⊓ (f p).val.2.2) = p.1.val := by + change ((p.2.val.val.1.val.map (e p.1).toLinearMap) ⊓ (p.2.val.val.2.1.val.map (e p.1).toLinearMap), + (p.2.val.val.1.val.map (e p.1).toLinearMap) ⊓ (p.2.val.val.2.2.val.map (e p.1).toLinearMap), + (p.2.val.val.2.1.val.map (e p.1).toLinearMap) ⊓ (p.2.val.val.2.2.val.map (e p.1).toLinearMap)) = _ + rw [←Submodule.map_inf (e p.1).toLinearMap (e p.1).injective, + ←Submodule.map_inf (e p.1).toLinearMap (e p.1).injective, + ←Submodule.map_inf (e p.1).toLinearMap (e p.1).injective, + p.2.property.1,p.2.property.2.1,p.2.property.2.2, + (he p.1).2.1,(he p.1).2.2.1,(he p.1).2.2.2] + refine ⟨f,?_⟩ + rintro ⟨p,q⟩ ⟨p',q'⟩ h + have hp : p = p' := by + apply Subtype.ext + exact (hrec (p,q)).symm.trans ((congrArg (fun x : OrderedTripleOrbit ω L.val M.val N.val => + (x.val.1 ⊓ x.val.2.1,x.val.1 ⊓ x.val.2.2,x.val.2.1 ⊓ x.val.2.2)) h).trans (hrec (p',q'))) + subst p' + have hv := congrArg Subtype.val h + have hinj := Submodule.map_injective_of_injective (e p).injective + have hq : q = q' := Subtype.ext (Subtype.ext + (Prod.ext (Subtype.ext (hinj (congrArg Prod.fst hv))) + (Prod.ext (Subtype.ext (hinj (congrArg (fun x => x.2.1) hv))) + (Subtype.ext (hinj (congrArg (fun x => x.2.2) hv)))))) + subst q' + rfl + +variable [Finite E] + theorem fullTripleOrbit_fixedPair_card_lower : + Nat.card (OrderedTripleOrbit ω (L.val ⊓ M.val) (L.val ⊓ N.val) (M.val ⊓ N.val)) * + Nat.card (FixedPairTripleOrbit ω L M N) ≤ Nat.card (OrderedTripleOrbit ω L.val M.val N.val) := by + obtain ⟨f,hf⟩ := fullTripleOrbit_fixedPair_injection ω L M N + simpa only [Nat.card_prod] using Nat.card_le_card_of_injective f hf +end PairOrbitAssembly +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section ConfigurationCount +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] + [Fintype K] [Finite E] +variable (ω : LinearMap.BilinForm K E) + + theorem triple_isotropic_orbit_card_lower (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D = finrank K E) + (S U V W : Submodule K E) (hS : S ≤ ω.orthogonal S) + (hU : U ≤ S) (hV : V ≤ S) (hW : W ≤ S) (hsum : U ⊔ V ⊔ W = S) + (hdis : Disjoint U (V ⊔ W)) (hVW : Disjoint V W) : + (Fintype.card K : ℝ)^(isotropicExponent D (finrank K S) + + 2*(finrank K U*finrank K V+finrank K U*finrank K W+finrank K V*finrank K W)) ≤ + (lagrangianConstant D * 2^D) * Nat.card (OrderedTripleOrbit ω U V W) := by + let U' := U.comap S.subtype + let V' := V.comap S.subtype + let W' := W.comap S.subtype + have hc : IsCompl U' (V' ⊔ W') := by + constructor + · apply disjoint_iff.mpr + change U.comap S.subtype ⊓ (V.comap S.subtype ⊔ W.comap S.subtype) = ⊥ + rw [←subspace_comap_sup_of_le S V W hV hW,←Submodule.comap_inf,disjoint_iff.mp hdis] + simp + · apply codisjoint_iff.mpr + change U.comap S.subtype ⊔ (V.comap S.subtype ⊔ W.comap S.subtype) = ⊤ + rw [←sup_assoc,←subspace_comap_sup_of_le S U V hU hV, + ←subspace_comap_sup_of_le S (U ⊔ V) W (sup_le hU hV) hW,hsum] + simp + have hvw : Disjoint V' W' := by + apply disjoint_iff.mpr + change V.comap S.subtype ⊓ W.comap S.subtype = ⊥ + rw [←Submodule.comap_inf,disjoint_iff.mp hVW] + simp + have hu' : finrank K U' = finrank K U := (Submodule.comapSubtypeEquivOfLe hU).finrank_eq + have hv' : finrank K V' = finrank K V := (Submodule.comapSubtypeEquivOfLe hV).finrank_eq + have hw' : finrank K W' = finrank K W := (Submodule.comapSubtypeEquivOfLe hW).finrank_eq + have hb := (tripleLinearOrbit_card_bounds U' V' W' hc hvw).1 + rw [hu',hv',hw'] at hb + have hs := isotropic_finrank_le_half ω hω D hD S hS + have hi := (isotropic_card_bounds ω h2 ha hω D hD (finrank K S) hs).1 + obtain ⟨f,hf⟩ := triple_subspace_orbit_injection ω h2 ha hω S U V W hS hU hV hW hsum + have hcard : (Nat.card (IsotropicDimspace ω (finrank K S)) : ℝ)* + Nat.card (TripleLinearOrbit U' V' W') ≤ Nat.card (OrderedTripleOrbit ω U V W) := by + have hh := Nat.card_le_card_of_injective f hf + rw [Nat.card_prod] at hh + exact_mod_cast hh + have hk : lagrangianConstant (D-finrank K S) * (2:ℝ)^(finrank K S) ≤ lagrangianConstant D * 2^D := by + exact mul_le_mul (lagrangianConstant_mono (Nat.sub_le D _)) + (pow_le_pow_right₀ (by norm_num) hs) (by positivity) + (le_of_lt (lagrangianConstant_pos D)) + calc + _ = (Fintype.card K : ℝ)^isotropicExponent D (finrank K S) * + (Fintype.card K : ℝ)^(2*(finrank K U*finrank K V+finrank K U*finrank K W+finrank K V*finrank K W)) := by rw [pow_add] + _ ≤ (lagrangianConstant (D-finrank K S)*Nat.card (IsotropicDimspace ω (finrank K S))) * + (2^(finrank K S)*Nat.card (TripleLinearOrbit U' V' W')) := + mul_le_mul hi hb (by positivity) + (mul_nonneg (le_of_lt (lagrangianConstant_pos _)) (Nat.cast_nonneg _)) + _ = (lagrangianConstant (D-finrank K S)*2^(finrank K S))* + ((Nat.card (IsotropicDimspace ω (finrank K S)) : ℝ)*Nat.card (TripleLinearOrbit U' V' W')) := by ring + _ ≤ (lagrangianConstant D*2^D)*Nat.card (OrderedTripleOrbit ω U V W) := + mul_le_mul hk hcard (by positivity) + (mul_nonneg (le_of_lt (lagrangianConstant_pos _)) (by positivity)) +end ConfigurationCount + +section FixedPairCount +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] + [Fintype K] [Finite E] [Invertible (2:K)] +variable (ω : LinearMap.BilinForm K E) + theorem fixedPairTripleOrbit_card_lower (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D = finrank K E) + (hq : 4*lagrangianConstant D ≤ (Fintype.card K : ℝ)) + (L M N : SymplecticLagrangian ω) (h0 : (L.val ⊓ M.val) ⊓ N.val = ⊥) : + let S := triplePairSum L.val M.val N.val + (Fintype.card K : ℝ)^((D-finrank K ↥(L.val ⊓ S)+1).choose 2 + + (D-finrank K ↥(M.val ⊓ S)+1).choose 2 + (D-finrank K ↥(N.val ⊓ S)+1).choose 2) ≤ + (8 * (4^D * lagrangianConstant D^2)) * Nat.card (FixedPairTripleOrbit ω L M N) := by + dsimp only + let S := triplePairSum L.val M.val N.val + have hs : S ≤ ω.orthogonal S := triplePairSum_isotropic ω _ _ _ L.property M.property N.property + have his (P : SymplecticLagrangian ω) : P.val ⊓ S ≤ ω.orthogonal (P.val ⊓ S) := by + intro x hx y hy + exact P.property.ge hx.1 y hy.1 + have h2 := (isUnit_of_invertible (2:K)).ne_zero + have h₁ := (containingLagrangian_card_bounds ω h2 ha hω D hD (L.val ⊓ S) (his L)).1 + have h₂ := (containingLagrangian_card_bounds ω h2 ha hω D hD (M.val ⊓ S) (his M)).1 + have h₃ := (containingLagrangian_card_bounds ω h2 ha hω D hD (N.val ⊓ S) (his N)).1 + have ht := triplePairSum_reductions_transverse ω L.val M.val N.val L.property M.property N.property + have hb := containmentOrbitFiber_card_lower ω S ha hω hs D hD hq + (L.val ⊓ S) (M.val ⊓ S) (N.val ⊓ S) inf_le_right inf_le_right inf_le_right + (tripleResidualLagrangian ω L M N ha hω L) + (tripleResidualLagrangian ω L M N ha hω M) (tripleResidualLagrangian ω L M N ha hω N) + ht.1 ht.2.1 ht.2.2 + have he := ownAvoidanceOrbitFiberEmbedding ω L M N ha hω h0 + have hc : (Nat.card (OwnAvoidanceOrbitFiber ω L M N ha hω) : ℝ) ≤ + Nat.card (FixedPairTripleOrbit ω L M N) := by exact_mod_cast Nat.card_le_card_of_injective he he.injective + calc + _ = (Fintype.card K : ℝ)^((D-finrank K ↥(L.val ⊓ S)+1).choose 2) * + ((Fintype.card K : ℝ)^((D-finrank K ↥(M.val ⊓ S)+1).choose 2) * + (Fintype.card K : ℝ)^((D-finrank K ↥(N.val ⊓ S)+1).choose 2)) := by simp only [pow_add]; ring + _ ≤ (Nat.card {P : SymplecticLagrangian ω // L.val ⊓ S ≤ P.val} : ℝ)* + (Nat.card {P : SymplecticLagrangian ω // M.val ⊓ S ≤ P.val} * + Nat.card {P : SymplecticLagrangian ω // N.val ⊓ S ≤ P.val}) := by gcongr + _ ≤ _ := hb + _ ≤ _ := mul_le_mul_of_nonneg_left hc (by positivity) +end FixedPairCount +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +theorem pair_cost_cancellation (D u v w : ℕ) (h : u+v+w ≤ D) : + isotropicExponent D (u+v+w) + 2*(u*v+u*w+v*w) + + ((D-(u+v)+1).choose 2 + (D-(u+w)+1).choose 2 + (D-(v+w)+1).choose 2) + + ((u+1).choose 2 + (v+1).choose 2 + (w+1).choose 2) = 3*(D+1).choose 2 := by + have hu : u+v ≤ D := by omega + have hv : u+w ≤ D := by omega + have hw : v+w ≤ D := by omega + have hi := isotropicExponent_add D (u+v+w) h + have hi' : (isotropicExponent D (u+v+w) : ℚ) = + ((D+1).choose 2 : ℚ) + (u+v+w)*(D-(u+v+w)) - ((D-(u+v+w)+1).choose 2 : ℚ) := by + have hiq := congrArg (fun x : ℕ => (x:ℚ)) hi + simp only [Nat.cast_add,Nat.cast_mul,Nat.cast_sub h] at hiq + linarith + apply @Nat.cast_injective ℚ + simp only [Nat.cast_add,Nat.cast_mul,Nat.cast_ofNat,hi',Nat.cast_choose_two,Nat.cast_one, + Nat.cast_sub hu,Nat.cast_sub hv,Nat.cast_sub hw,Nat.cast_sub h] + ring + +theorem common_cost_cancellation (D c : ℕ) (hc : c ≤ D) : + isotropicExponent D c + 3*(D-c+1).choose 2 + (D+1)*c = 3*(D+1).choose 2 := by + have hi := isotropicExponent_add D c hc + have h : 2*((D-c+1).choose 2) + (D+1)*c + c*(D-c) = 2*((D+1).choose 2) := by + apply @Nat.cast_injective ℚ + simp only [Nat.cast_add,Nat.cast_mul,Nat.cast_ofNat,Nat.cast_choose_two,Nat.cast_one,Nat.cast_sub hc] + ring + omega + +open Module +section PairMass +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] + [FiniteDimensional K E] +variable (ω : LinearMap.BilinForm K E) + + theorem finrank_sup_of_disjoint (U V : Submodule K E) (h : Disjoint U V) : + finrank K ↥(U ⊔ V) = finrank K U + finrank K V := by + have hh := U.finrank_sup_add_finrank_inf_eq V + rw [disjoint_iff.mp h,finrank_bot,add_zero] at hh + exact hh + + theorem triplePairSum_finrank (L M N : Submodule K E) (h0 : (L ⊓ M) ⊓ N = ⊥) : + finrank K ↥(triplePairSum L M N) = finrank K ↥(L ⊓ M) + finrank K ↥(L ⊓ N) + finrank K ↥(M ⊓ N) := by + have hd := triple_pairs_disjoint L M N h0 + change finrank K ↥(((L ⊓ M) ⊔ (L ⊓ N)) ⊔ (M ⊓ N)) = _ + rw [sup_assoc,finrank_sup_of_disjoint _ _ hd.1,finrank_sup_of_disjoint _ _ hd.2,add_assoc] + + theorem triplePairSum_inter_finrank (L M N : Submodule K E) (h0 : (L ⊓ M) ⊓ N = ⊥) : + finrank K ↥(L ⊓ triplePairSum L M N) = finrank K ↥(L ⊓ M) + finrank K ↥(L ⊓ N) := by + rw [triple_own_avoidance L M N h0] + exact finrank_sup_of_disjoint _ _ ((triple_pairs_disjoint L M N h0).1.mono_right le_sup_left) + +noncomputable def pairOrbitConstant (D : ℕ) : ℝ := + (lagrangianConstant D*2^D)*(8*(4^D*lagrangianConstant D^2)) + + theorem pairOrbitConstant_pos (D : ℕ) : 0 < pairOrbitConstant D := by + unfold pairOrbitConstant + have h := lagrangianConstant_pos D + positivity + +variable [Fintype K] [Finite E] [Invertible (2:K)] + + theorem commonZeroOrbit_card_lower (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D = finrank K E) + (hq : 4*lagrangianConstant D ≤ (Fintype.card K : ℝ)) + (L M N : SymplecticLagrangian ω) (h0 : (L.val ⊓ M.val) ⊓ N.val = ⊥) : + (Fintype.card K : ℝ)^(3*(D+1).choose 2) ≤ + pairOrbitConstant D * (Fintype.card K : ℝ)^((finrank K ↥(L.val ⊓ M.val)+1).choose 2 + + (finrank K ↥(L.val ⊓ N.val)+1).choose 2 + (finrank K ↥(M.val ⊓ N.val)+1).choose 2) * + Nat.card (OrderedTripleOrbit ω L.val M.val N.val) := by + let S := triplePairSum L.val M.val N.val + let u := finrank K ↥(L.val ⊓ M.val) + let v := finrank K ↥(L.val ⊓ N.val) + let w := finrank K ↥(M.val ⊓ N.val) + have hs : S ≤ ω.orthogonal S := triplePairSum_isotropic ω _ _ _ L.property M.property N.property + have hdim : finrank K S = u+v+w := triplePairSum_finrank _ _ _ h0 + have hdimL : finrank K ↥(L.val ⊓ S) = u+v := triplePairSum_inter_finrank _ _ _ h0 + have h0M : (M.val ⊓ L.val) ⊓ N.val = ⊥ := by simpa only [inf_comm] using h0 + have h0N : (N.val ⊓ L.val) ⊓ M.val = ⊥ := by simpa only [inf_assoc,inf_left_comm,inf_comm] using h0 + have hSM : triplePairSum M.val L.val N.val = S := by dsimp [S,triplePairSum]; ac_rfl + have hSN : triplePairSum N.val L.val M.val = S := by dsimp [S,triplePairSum]; ac_rfl + have hdimM : finrank K ↥(M.val ⊓ S) = u+w := by + have hh := triplePairSum_inter_finrank M.val L.val N.val h0M + rw [hSM,inf_comm M.val L.val] at hh + exact hh + have hdimN : finrank K ↥(N.val ⊓ S) = v+w := by + have hh := triplePairSum_inter_finrank N.val L.val M.val h0N + rw [hSN,inf_comm N.val L.val,inf_comm N.val M.val] at hh + exact hh + have haD : u+v+w ≤ D := hdim ▸ isotropic_finrank_le_half ω hω D hD S hs + have hd := triple_pairs_disjoint L.val M.val N.val h0 + have hc := triple_isotropic_orbit_card_lower ω (isUnit_of_invertible (2:K)).ne_zero ha hω D hD S + (L.val ⊓ M.val) (L.val ⊓ N.val) (M.val ⊓ N.val) hs + (le_sup_of_le_left le_sup_left) (le_sup_of_le_left le_sup_right) le_sup_right rfl hd.1 hd.2 + rw [hdim] at hc + have hf := fixedPairTripleOrbit_card_lower ω ha hω D hD hq L M N h0 + change (Fintype.card K : ℝ)^((D-finrank K ↥(L.val ⊓ S)+1).choose 2 + + (D-finrank K ↥(M.val ⊓ S)+1).choose 2 + (D-finrank K ↥(N.val ⊓ S)+1).choose 2) ≤ _ at hf + rw [hdimL,hdimM,hdimN] at hf + have hm : (Nat.card (OrderedTripleOrbit ω (L.val ⊓ M.val) (L.val ⊓ N.val) (M.val ⊓ N.val)) : ℝ) * + Nat.card (FixedPairTripleOrbit ω L M N) ≤ Nat.card (OrderedTripleOrbit ω L.val M.val N.val) := by + exact_mod_cast fullTripleOrbit_fixedPair_card_lower ω L M N + have hn : 0 ≤ lagrangianConstant D*2^D := mul_nonneg (le_of_lt (lagrangianConstant_pos D)) (by positivity) + have hp := mul_le_mul hc hf (by positivity) + (mul_nonneg hn (Nat.cast_nonneg _)) + have hh : (Fintype.card K : ℝ)^(isotropicExponent D (u+v+w)+2*(u*v+u*w+v*w)+ + ((D-(u+v)+1).choose 2+(D-(u+w)+1).choose 2+(D-(v+w)+1).choose 2)) ≤ + pairOrbitConstant D * Nat.card (OrderedTripleOrbit ω L.val M.val N.val) := by + calc + _ ≤ (lagrangianConstant D*2^D)*Nat.card (OrderedTripleOrbit ω (L.val ⊓ M.val) (L.val ⊓ N.val) (M.val ⊓ N.val)) * + ((8*(4^D*lagrangianConstant D^2))*Nat.card (FixedPairTripleOrbit ω L M N)) := by + simpa only [pow_add] using hp + _ = pairOrbitConstant D * ((Nat.card (OrderedTripleOrbit ω (L.val ⊓ M.val) (L.val ⊓ N.val) (M.val ⊓ N.val)) : ℝ)* + Nat.card (FixedPairTripleOrbit ω L M N)) := by unfold pairOrbitConstant; ring + _ ≤ _ := mul_le_mul_of_nonneg_left hm (le_of_lt (pairOrbitConstant_pos D)) + have hh' := mul_le_mul_of_nonneg_right hh + (show 0 ≤ (Fintype.card K : ℝ)^((u+1).choose 2+(v+1).choose 2+(w+1).choose 2) by positivity) + rw [←pow_add,pair_cost_cancellation D u v w haD] at hh' + simpa only [mul_assoc,mul_left_comm,mul_comm] using hh' +end PairMass +end SidorenkoCounterexample + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/Dilution.lean b/lean/OAI/Combinatorics/Sidorenko/Dilution.lean new file mode 100644 index 0000000000000000000000000000000000000000..77adae200fd0e865f4d4ecd2ca33bf9497db2e6f --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/Dilution.lean @@ -0,0 +1,183 @@ +import OAI.Combinatorics.Sidorenko.Types + +namespace OAI + + +section + +namespace SidorenkoCounterexample +open Classical +open scoped BigOperators +namespace FiniteLaw +variable {A I : Type*} [Fintype A] [Fintype I] [DecidableEq I] +noncomputable def diluted (p : FiniteLaw A) (ε : ℝ) (h0 : 0≤ε) (h1 : ε≤1) : FiniteLaw (Option A) where + weight x := match x with | none => 1-ε | some a => ε*p.weight a + nonneg x := by cases x with | none => exact sub_nonneg.mpr h1 | some a => exact mul_nonneg h0 (p.nonneg a) + total := by rw [Fintype.sum_option,←Finset.mul_sum,p.total]; ring +omit [Fintype A] [Fintype I] [DecidableEq I] in +lemma someFunction_injective : Function.Injective (fun a : I → A => fun i => some (a i)) := by + intro a b h + funext i; exact Option.some_injective _ (congrFun h i) +omit [Fintype A] [DecidableEq I] in +lemma exists_none_of_not_some (z : I → Option A) (hz : ∀ a : I → A,(fun i => some (a i))≠z) : ∃ i,z i=none := by + by_contra hn + push Not at hn + have hs (i : I) : ∃ a,z i=some a := by + cases hi : z i with + | none => exact False.elim (hn i hi) + | some a => exact ⟨a,rfl⟩ + exact hz (fun i => (hs i).choose) (funext (fun i => (hs i).choose_spec.symm)) +lemma diluted_independent_mean (p : FiniteLaw A) (ε : ℝ) (h0 : 0≤ε) (h1 : ε≤1) + (f : (I → Option A) → ℝ) (hf : ∀ z,(∃ i,z i=none) → f z=0) : + (independent (fun _ : I => p.diluted ε h0 h1)).mean f= + ε^Fintype.card I*(independent (fun _ : I => p)).mean (fun a => f (fun i => some (a i))) := by + unfold mean independent + rw [Finset.mul_sum] + symm + apply Fintype.sum_of_injective (fun a : I → A => fun i => some (a i)) someFunction_injective + · intro z hz + rw [hf z (exists_none_of_not_some z (fun a ha => hz ⟨a,ha⟩)),mul_zero] + · intro a + simp only [diluted,Finset.prod_mul_distrib,Finset.prod_const,Finset.card_univ] + ring +end FiniteLaw +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Classical Filter +open scoped BigOperators Topology +section Dilution +variable {A B K : Type*} [Fintype A] [Fintype B] [Fintype K] [DecidableEq K] +noncomputable def dilutedPairLaw (p : A → B → FiniteLaw (Activation K)) : Option A → B → FiniteLaw (Activation K) + | none,_ => inactiveLaw + | some a,b => p a b +omit [Fintype A] [Fintype B] in +lemma dilutedPairLaw_zero (p : A → B → FiniteLaw (Activation K)) + (hp : ∀ a b α,α≠∅ → (p a b).mean (activationPhi α)=0) : + ∀ a b α,α≠∅ → (dilutedPairLaw p a b).mean (activationPhi α)=0 := by + intro a b α hα; cases a with + | none => exact inactiveLaw_zero α hα + | some a => exact hp a b α hα +lemma coefficient_dilution_left (π : FiniteLaw A) (ν : FiniteLaw B) (p : A → B → FiniteLaw (Activation K)) + (ε : ℝ) (h0 : 0≤ε) (h1 : ε≤1) : + averagedCoefficient (π.diluted ε h0 h1) ν (dilutedPairLaw p)=ε^13*averagedCoefficient π ν p := by + unfold averagedCoefficient typeMapLaw + rw [FiniteLaw.mean_prod,FiniteLaw.mean_prod] + have hz (a : Fin 13 → Option A) (ha : ∃ i,a i=none) : + (FiniteLaw.independent (fun _ : Fin 22 => ν)).mean (fun b => typedCoefficient (dilutedPairLaw p) a b)=0 := by + obtain ⟨i,hi⟩ := ha + have he (b : Fin 22 → B) : typedCoefficient (dilutedPairLaw p) a b=0 := + typedCoefficient_inactive_left _ a b i (fun j => by rw [hi]; rfl) + simp only [he,FiniteLaw.mean_const] + rw [FiniteLaw.diluted_independent_mean π ε h0 h1 _ hz] + rfl +lemma coefficient_dilution_right (π : FiniteLaw A) (ν : FiniteLaw B) (p : A → B → FiniteLaw (Activation K)) + (ε : ℝ) (h0 : 0≤ε) (h1 : ε≤1) : + averagedCoefficient ν (π.diluted ε h0 h1) (fun b a => dilutedPairLaw p a b)= + ε^22*averagedCoefficient ν π (fun b a => p a b) := by + unfold averagedCoefficient typeMapLaw + rw [FiniteLaw.mean_prod,FiniteLaw.mean_prod] + have hd (b : Fin 13 → B) : + (FiniteLaw.independent (fun _ : Fin 22 => π.diluted ε h0 h1)).mean + (fun a => typedCoefficient (fun b a => dilutedPairLaw p a b) b a)= + ε^22*(FiniteLaw.independent (fun _ : Fin 22 => π)).mean + (fun a => typedCoefficient (fun b a => p a b) b a) := by + apply FiniteLaw.diluted_independent_mean + intro a ha + obtain ⟨j,hj⟩ := ha + exact typedCoefficient_inactive_right _ b a j (fun i => by rw [hj]; rfl) + simp only [hd,FiniteLaw.mean_mul] +end Dilution +lemma exists_dilution_gap (t0 t1 : ℝ) (hneg : t0<0) : + ∃ ε : ℝ,0<ε ∧ ε<1 ∧ (1+ε^13*t0)*(1+ε^22*t1)<1 := by + let f := fun ε : ℝ => t0+ε^9*t1+ε^22*t0*t1 + have hl : Tendsto f (nhds 0) (nhds t0) := by + have hc : ContinuousAt f 0 := by dsimp [f]; fun_prop + simpa only [f,zero_pow (by omega : 9≠0),zero_pow (by omega : 22≠0),zero_mul,add_zero] using hc.tendsto + have he : ∀ᶠ ε : ℝ in nhdsWithin 0 (Set.Ioi 0),f ε<0 := + (hl.mono_left nhdsWithin_le_nhds).eventually (gt_mem_nhds hneg) + have hlt : ∀ᶠ ε : ℝ in nhdsWithin 0 (Set.Ioi 0),ε<1 := + nhdsWithin_le_nhds (gt_mem_nhds (by norm_num : (0:ℝ)<1)) + have hpos : ∀ᶠ ε : ℝ in nhdsWithin 0 (Set.Ioi 0),0<ε := self_mem_nhdsWithin + obtain ⟨ε,hε,hε1,hε0⟩ := (he.and (hlt.and hpos)).exists + refine ⟨ε,hε0,hε1,?_⟩ + have halg : (1+ε^13*t0)*(1+ε^22*t1)=1+ε^13*f ε := by dsimp [f]; ring + rw [halg] + exact add_lt_of_neg_right 1 (mul_neg_of_pos_of_neg (pow_pos hε0 _) hε) +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Classical +open scoped BigOperators +section PinningRound +variable {I J E C : Type*} [Fintype I] [Fintype J] [Fintype E] [Fintype C] + [DecidableEq I] [DecidableEq J] [DecidableEq C] +def neighborHistogram (t : E → I) (c : E → C) (i : I) (d : C) : ℕ := + ∑ e,if t e=i ∧ c e=d then 1 else 0 +lemma histogram_weighted (t : E → I) (c : E → C) (f : I → C → ℝ) : + (∑ i,∑ d,(neighborHistogram t c i d:ℝ)*f i d)=∑ e,f (t e) (c e) := by + simp only [neighborHistogram,Nat.cast_sum,Nat.cast_ite,Nat.cast_one,Nat.cast_zero,Finset.sum_mul] + calc + _ = ∑ i,∑ e,∑ d,(if t e=i ∧ c e=d then (1:ℝ) else 0)*f i d := by + apply Finset.sum_congr rfl; intro i _; rw [Finset.sum_comm] + _ = ∑ e,∑ i,∑ d,(if t e=i ∧ c e=d then (1:ℝ) else 0)*f i d := Finset.sum_comm + _ = _ := by + apply Finset.sum_congr rfl; intro e _ + simp [ite_and,ite_mul] + +structure VertexPairScores (I J : Type*) where + left : I → ℝ + right : J → ℝ + pair : I → J → ℝ +noncomputable def VertexPairScores.score (s : VertexPairScores I J) (t : E → I) (h : E → J) + (a : I → I) (b : J → J) : ℝ := ∑ i,s.left (a i)+(∑ j,s.right (b j))+∑ e,s.pair (a (t e)) (b (h e)) +noncomputable def roundScores (t : E → I) (h : E → J) (cI : I → C) (cJ : J → C) : VertexPairScores I J where + left a := -(∑ c,(neighborHistogram t (cJ ∘ h) a c:ℝ)^2) + right b := -(∑ c,(neighborHistogram h (cI ∘ t) b c:ℝ)^2) + pair a b := 2*(neighborHistogram t (cJ ∘ h) a (cJ b):ℝ)+2*(neighborHistogram h (cI ∘ t) b (cI a):ℝ) + +lemma roundScore_formula (t : E → I) (h : E → J) (cI : I → C) (cJ : J → C) + (a : I → I) (b : J → J) (ha : ∀ i,cI (a i)=cI i) (hb : ∀ j,cJ (b j)=cJ j) : + (roundScores t h cI cJ).score t h a b= + (∑ i,∑ c,(2*(neighborHistogram t (cJ ∘ h) i c:ℝ)*(neighborHistogram t (cJ ∘ h) (a i) c:ℝ)- + (neighborHistogram t (cJ ∘ h) (a i) c:ℝ)^2))+ + (∑ j,∑ c,(2*(neighborHistogram h (cI ∘ t) j c:ℝ)*(neighborHistogram h (cI ∘ t) (b j) c:ℝ)- + (neighborHistogram h (cI ∘ t) (b j) c:ℝ)^2)) := by + have hL := histogram_weighted t (cJ ∘ h) (fun i c => 2*(neighborHistogram t (cJ ∘ h) (a i) c:ℝ)) + have hR := histogram_weighted h (cI ∘ t) (fun j c => 2*(neighborHistogram h (cI ∘ t) (b j) c:ℝ)) + simp only [Function.comp_apply] at hL hR + simp only [VertexPairScores.score,roundScores,ha,hb,Finset.sum_add_distrib,Finset.sum_neg_distrib] + rw [←hL,←hR] + simp only [Finset.sum_sub_distrib] + have hmul (x y : ℝ) : x*(2*y)=2*x*y := by ring + simp only [hmul] + ring + +lemma roundScore_loss (t : E → I) (h : E → J) (cI : I → C) (cJ : J → C) + (a : I → I) (b : J → J) (ha : ∀ i,cI (a i)=cI i) (hb : ∀ j,cJ (b j)=cJ j) : + (roundScores t h cI cJ).score t h id id-(roundScores t h cI cJ).score t h a b= + (∑ i,∑ c,((neighborHistogram t (cJ ∘ h) (a i) c:ℝ)-(neighborHistogram t (cJ ∘ h) i c:ℝ))^2)+ + (∑ j,∑ c,((neighborHistogram h (cI ∘ t) (b j) c:ℝ)-(neighborHistogram h (cI ∘ t) j c:ℝ))^2) := by + rw [roundScore_formula t h cI cJ id id (fun _ => rfl) (fun _ => rfl),roundScore_formula t h cI cJ a b ha hb] + simp only [id_eq] + have halg (x y : ℝ) : (2*x*x-x^2)-(2*x*y-y^2)=(y-x)^2 := by ring + rw [show ∀ x y z w : ℝ,x+y-(z+w)=(x-z)+(y-w) by intros; ring] + simp only [←Finset.sum_sub_distrib,halg] +end PinningRound +end SidorenkoCounterexample + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/Discriminant.lean b/lean/OAI/Combinatorics/Sidorenko/Discriminant.lean new file mode 100644 index 0000000000000000000000000000000000000000..8e7f6a20e7248177f97cd44527113f46f9b56442 --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/Discriminant.lean @@ -0,0 +1,714 @@ +import OAI.Combinatorics.Sidorenko.Tail + +namespace OAI + + +section + + + + +namespace SidorenkoCounterexample +open Module LinearMap + +section Forms +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + +/-- The bilinear form induced on the quotient by its radical. -/ +def radicalQuotientForm (B : LinearMap.BilinForm K V) (hB : B.IsSymm) : + LinearMap.BilinForm K (V ⧸ B.ker) := + LinearMap.IsRefl.liftQ₂ B B.ker hB.isRefl le_rfl + +@[simp] theorem radicalQuotientForm_mk (B : LinearMap.BilinForm K V) (hB : B.IsSymm) + (x y : V) : radicalQuotientForm B hB + (Submodule.Quotient.mk x) (Submodule.Quotient.mk y) = B x y := rfl + +/-- Passing to the radical quotient really gives a nondegenerate form. -/ +theorem radicalQuotientForm_nondegenerate [FiniteDimensional K V] + (B : LinearMap.BilinForm K V) (hB : B.IsSymm) : + (radicalQuotientForm B hB).Nondegenerate := by + apply LinearMap.BilinForm.nondegenerate_iff_ker_eq_bot.mpr + apply bot_unique + intro x hx + induction x using Submodule.Quotient.induction_on with + | H x => + apply (Submodule.Quotient.mk_eq_zero B.ker).mpr + apply LinearMap.mem_ker.mpr + ext y + have h := congrArg (fun f => f (Submodule.Quotient.mk y)) hx + exact h + +theorem radicalQuotientForm_isSymm (B : LinearMap.BilinForm K V) (hB : B.IsSymm) : + (radicalQuotientForm B hB).IsSymm := by + constructor + intro x y + induction x using Submodule.Quotient.induction_on with + | H x => + induction y using Submodule.Quotient.induction_on with + | H y => exact hB.eq x y + +theorem form_isSymm_neg (B : LinearMap.BilinForm K V) (hB : B.IsSymm) : + (-B).IsSymm := by + constructor + intro x y + change -(B x y) = -(B y x) + rw [hB.eq x y] + +def radicalNegEquiv (B : LinearMap.BilinForm K V) : + (V ⧸ (-B).ker) ≃ₗ[K] (V ⧸ B.ker) := + Submodule.quotEquivOfEq _ _ (LinearMap.ker_neg B) + +theorem radicalQuotientForm_neg (B : LinearMap.BilinForm K V) (hB : B.IsSymm) + (x y : V ⧸ (-B).ker) : + radicalQuotientForm (-B) (form_isSymm_neg B hB) x y = + -(radicalQuotientForm B hB (radicalNegEquiv B x) (radicalNegEquiv B y)) := by + induction x using Submodule.Quotient.induction_on with + | H x => + induction y using Submodule.Quotient.induction_on with + | H y => rfl + +variable [FiniteDimensional K V] [Fintype K] [DecidableEq K] + +/-- Determinant character of the nondegenerate radical quotient, including +rank zero (where the empty determinant is one). -/ +noncomputable def discriminantSign (B : LinearMap.BilinForm K V) (hB : B.IsSymm) : ℤ := + quadraticChar K ((radicalQuotientForm B hB).toMatrix + (Module.finBasis K (V ⧸ B.ker))).det + +theorem discriminantSign_ne_zero (B : LinearMap.BilinForm K V) (hB : B.IsSymm) : + discriminantSign B hB ≠ 0 := by + apply mt quadraticChar_eq_zero_iff.mp + exact (LinearMap.BilinForm.nondegenerate_iff_det_ne_zero _).mp + (radicalQuotientForm_nondegenerate B hB) + +theorem discriminantSign_sq (B : LinearMap.BilinForm K V) (hB : B.IsSymm) : + discriminantSign B hB ^ 2 = 1 := by + apply quadraticChar_sq_one + exact (LinearMap.BilinForm.nondegenerate_iff_det_ne_zero _).mp + (radicalQuotientForm_nondegenerate B hB) + +theorem discriminantSign_cases (B : LinearMap.BilinForm K V) (hB : B.IsSymm) : + discriminantSign B hB = 1 ∨ discriminantSign B hB = -1 := by + apply quadraticChar_dichotomy + exact (LinearMap.BilinForm.nondegenerate_iff_det_ne_zero _).mp + (radicalQuotientForm_nondegenerate B hB) + +omit [FiniteDimensional K V] in +/-- The determinant character is independent of a basis. -/ +theorem determinant_character_basis_independent {ι : Type*} + [Fintype ι] [DecidableEq ι] (b c : Basis ι K V) (B : LinearMap.BilinForm K V) : + quadraticChar K (B.toMatrix b).det = quadraticChar K (B.toMatrix c).det := by + have hu : (b.toMatrix c).det ≠ 0 := (b.isUnit_det c).ne_zero + rw [← B.toMatrix_mul_basis_toMatrix b c, Matrix.det_mul, Matrix.det_mul, + Matrix.det_transpose, map_mul, map_mul] + have hsq := quadraticChar_sq_one (F := K) hu + linear_combination -(quadraticChar K (B.toMatrix b).det) * hsq + +omit [FiniteDimensional K V] in +/-- Basis invariance also allows unrelated finite indexing types. -/ +theorem determinant_character_basis_independent_indices {ι κ : Type*} + [Fintype ι] [DecidableEq ι] [Fintype κ] [DecidableEq κ] + (b : Basis ι K V) (c : Basis κ K V) (B : LinearMap.BilinForm K V) : + quadraticChar K (B.toMatrix b).det = quadraticChar K (B.toMatrix c).det := by + classical + let e := b.indexEquiv c + have h : B.toMatrix (b.reindex e) = Matrix.reindex e e (B.toMatrix b) := by + ext i j + simp [LinearMap.BilinForm.toMatrix_apply, Matrix.reindex_apply] + calc + quadraticChar K (B.toMatrix b).det = + quadraticChar K (B.toMatrix (b.reindex e)).det := by + rw [h, Matrix.det_reindex_self] + _ = quadraticChar K (B.toMatrix c).det := + determinant_character_basis_independent _ _ _ + +/-- The definition can be evaluated in any basis of the radical quotient. -/ +theorem discriminantSign_eq (B : LinearMap.BilinForm K V) (hB : B.IsSymm) + {ι : Type*} [Fintype ι] [DecidableEq ι] (b : Basis ι K (V ⧸ B.ker)) : + discriminantSign B hB = quadraticChar K ((radicalQuotientForm B hB).toMatrix b).det := + determinant_character_basis_independent_indices _ _ _ + +/-- Negation changes the intrinsic sign by the character of (-1)^rank. -/ +theorem discriminantSign_neg (B : LinearMap.BilinForm K V) (hB : B.IsSymm) : + discriminantSign (-B) (form_isSymm_neg B hB) = + quadraticChar K ((-1 : K) ^ finrank K (V ⧸ B.ker)) * discriminantSign B hB := by + classical + let b := Module.finBasis K (V ⧸ B.ker) + rw [discriminantSign_eq (-B) (form_isSymm_neg B hB) + (b.map (radicalNegEquiv B).symm)] + have hm : (radicalQuotientForm (-B) (form_isSymm_neg B hB)).toMatrix + (b.map (radicalNegEquiv B).symm) = -(radicalQuotientForm B hB).toMatrix b := by + ext i j + simp only [LinearMap.BilinForm.toMatrix_apply, Basis.map_apply, Matrix.neg_apply] + rw [radicalQuotientForm_neg B hB] + simp only [LinearEquiv.apply_symm_apply] + rw [hm, Matrix.det_neg, map_mul, Fintype.card_fin] + rfl + +end Forms +section Pullback +variable {K V W : Type*} [Field K] [AddCommGroup V] [Module K V] + [AddCommGroup W] [Module K W] + + theorem pullback_isSymm (B : LinearMap.BilinForm K W) (hB : B.IsSymm) + (f : V →ₗ[K] W) : LinearMap.BilinForm.IsSymm (B.compl₁₂ f f) := by + constructor + intro x y + exact hB.eq (f x) (f y) + +theorem pullback_ker (B : LinearMap.BilinForm K W) (hB : B.Nondegenerate) + (f : V →ₗ[K] W) (hf : Function.Surjective f) : + (B.compl₁₂ f f).ker = f.ker := by + ext x + simp only [LinearMap.mem_ker] + constructor + · intro hx + apply hB.1 + intro y + obtain ⟨z, rfl⟩ := hf y + exact congrArg (fun g => g z) hx + · intro hx + ext y + simp [hx] + +noncomputable def pullbackQuotientEquiv (B : LinearMap.BilinForm K W) + (hB : B.Nondegenerate) (f : V →ₗ[K] W) (hf : Function.Surjective f) : + (V ⧸ (B.compl₁₂ f f).ker) ≃ₗ[K] W := + (Submodule.quotEquivOfEq _ _ (pullback_ker B hB f hf)).trans + (f.quotKerEquivOfSurjective hf) + +@[simp] theorem pullbackQuotientEquiv_mk (B : LinearMap.BilinForm K W) + (hB : B.Nondegenerate) (f : V →ₗ[K] W) (hf : Function.Surjective f) (x : V) : + pullbackQuotientEquiv B hB f hf (Submodule.Quotient.mk x) = f x := rfl + +theorem pullbackQuotientForm (B : LinearMap.BilinForm K W) + (hBs : B.IsSymm) (hB : B.Nondegenerate) + (f : V →ₗ[K] W) (hf : Function.Surjective f) + (x y : V ⧸ (B.compl₁₂ f f).ker) : + radicalQuotientForm (B.compl₁₂ f f) (pullback_isSymm B hBs f) x y = + B (pullbackQuotientEquiv B hB f hf x) (pullbackQuotientEquiv B hB f hf y) := by + induction x using Submodule.Quotient.induction_on with + | H x => + induction y using Submodule.Quotient.induction_on with + | H y => rfl + +variable [FiniteDimensional K V] [Fintype K] [DecidableEq K] + +/-- Pulling a nondegenerate form back along a surjection does not change +its intrinsic determinant character. This covers the rank-k matrix +representation P*R*Pᵀ used in the signed layer counts. -/ +theorem discriminantSign_pullback (B : LinearMap.BilinForm K W) + (hBs : B.IsSymm) (hB : B.Nondegenerate) + (f : V →ₗ[K] W) (hf : Function.Surjective f) + {ι : Type*} [Fintype ι] [DecidableEq ι] (b : Basis ι K W) : + discriminantSign (B.compl₁₂ f f) (pullback_isSymm B hBs f) = + quadraticChar K (B.toMatrix b).det := by + classical + let e := pullbackQuotientEquiv B hB f hf + rw [discriminantSign_eq _ _ (b.map e.symm)] + congr 2 + ext i j + simp only [LinearMap.BilinForm.toMatrix_apply, Basis.map_apply] + rw [pullbackQuotientForm B hBs hB f hf] + simp only [e, LinearEquiv.apply_symm_apply] + +end Pullback +section MatrixForms +variable {K n : Type*} [Field K] [Fintype n] [DecidableEq n] + +theorem matrix_bilin_eval (M : Matrix n n K) (x y : n → K) : + M.toBilin' x y = (M.transpose.mulVec x) ⬝ᵥ y := by + rw [Matrix.toBilin'_apply] + simp only [dotProduct, Matrix.mulVec, Matrix.transpose_apply, Finset.sum_mul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro j _ + apply Finset.sum_congr rfl + intro i _ + ring + +theorem matrix_bilin_ker (M : Matrix n n K) : + M.toBilin'.ker = M.transpose.toLin'.ker := by + ext x + simp only [LinearMap.mem_ker, LinearMap.ext_iff, LinearMap.zero_apply, + matrix_bilin_eval, Matrix.toLin'_apply] + exact dotProduct_eq_zero_iff + +/-- The rank of the intrinsic quotient is the usual matrix rank. -/ +theorem matrix_radical_quotient_rank (M : Matrix n n K) : + finrank K ((n → K) ⧸ M.toBilin'.ker) = M.rank := by + have h₁ := M.toBilin'.ker.finrank_quotient_add_finrank + have h₂ := M.transpose.toLin'.finrank_range_add_finrank_ker + rw [matrix_bilin_ker] at h₁ + have hr : finrank K M.transpose.toLin'.range = M.transpose.rank := rfl + rw [hr, Matrix.rank_transpose] at h₂ + rw [matrix_bilin_ker] + omega + +theorem matrix_rank_neg (M : Matrix n n K) : (-M).rank = M.rank := by + change finrank K (Matrix.toLin' (-M)).range = finrank K (Matrix.toLin' M).range + rw [map_neg, LinearMap.range_neg] + +end MatrixForms +end SidorenkoCounterexample + +namespace SidorenkoCounterexample + + +def MainClaim : Prop := ∃ n : ℕ, 0 < n ∧ ∃ G : SimpleGraph (Fin n), + (∃ u v, G.Adj u v) ∧ homDensity H G < (edgeDensity G) ^ 66 + + +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module + +section FiniteLayer +variable (K : Type*) [Field K] (D : ℕ) + +variable [Fintype K] [DecidableEq K] +noncomputable instance : Fintype (SymMatrix K D) := Fintype.ofFinite _ + +noncomputable def matrixSign (Z : SymMatrix K D) : ℤ := + discriminantSign Z.val.toBilin' (Matrix.isSymm_toBilin'_iff_isSymm.mpr Z.property) + +/-- A nonsingular r-form occurs as a rank-r symmetric D-matrix, with its +intrinsic sign unchanged. -/ +theorem exists_matrix_of_nonsingular {r : ℕ} (hrD : r ≤ D) + (R : Matrix (Fin r) (Fin r) K) (hRs : R.IsSymm) (hR : R.det ≠ 0) : + ∃ Z : SymMatrix K D, Z.val.rank = r ∧ + matrixSign K D Z = quadraticChar K R.det := by + classical + let f : (Fin D → K) →ₗ[K] (Fin r → K) := + LinearMap.funLeft K K (Fin.castLE hrD) + have hf : Function.Surjective f := + LinearMap.funLeft_surjective_of_injective K K _ (Fin.castLE_injective hrD) + have hbs : R.toBilin'.IsSymm := Matrix.isSymm_toBilin'_iff_isSymm.mpr hRs + have hb : R.toBilin'.Nondegenerate := + LinearMap.BilinForm.nondegenerate_toBilin'_iff_det_ne_zero.mpr hR + let B : LinearMap.BilinForm K (Fin D → K) := R.toBilin'.compl₁₂ f f + have hB : B.IsSymm := pullback_isSymm _ hbs f + let Z : SymMatrix K D := ⟨B.toMatrix', + LinearMap.BilinForm.isSymm_toMatrix'_iff_isSymm.mpr hB⟩ + have hz : Z.val.toBilin' = B := Matrix.toBilin'_toMatrix' B + refine ⟨Z, ?_, ?_⟩ + · rw [← matrix_radical_quotient_rank, hz] + calc + finrank K ((Fin D → K) ⧸ B.ker) = finrank K (Fin r → K) := + (pullbackQuotientEquiv R.toBilin' hb f hf).finrank_eq + _ = r := by simp + · unfold matrixSign + simp only [hz] + have he := discriminantSign_pullback R.toBilin' hbs hb f hf + (Pi.basisFun K (Fin r)) + convert he using 1 + exact congrArg (fun M : Matrix (Fin r) (Fin r) K => quadraticChar K M.det) + (LinearMap.BilinForm.toMatrix'_toBilin' R).symm + +/-- The two positive-rank layers used in the manuscript are nonempty. -/ +theorem exists_matrix_rank_sign {r : ℕ} (hr : 0 < r) (hrD : r ≤ D) + (hK : ringChar K ≠ 2) {ξ : ℤ} (hξ : ξ = 1 ∨ ξ = -1) : + ∃ Z : SymMatrix K D, Z.val.rank = r ∧ matrixSign K D Z = ξ := by + classical + have ha : ∃ a : K, a ≠ 0 ∧ quadraticChar K a = ξ := by + rcases hξ with rfl | rfl + · exact ⟨1, one_ne_zero, map_one _⟩ + · obtain ⟨a, ha⟩ := quadraticChar_exists_neg_one (F := K) hK + refine ⟨a, ?_, ha⟩ + intro haz + simp [haz] at ha + obtain ⟨a, ha, hax⟩ := ha + let i₀ : Fin r := ⟨0, hr⟩ + let R : Matrix (Fin r) (Fin r) K := + Matrix.diagonal fun i => if i = i₀ then a else 1 + have hdet : R.det = a := by + simp [R, Matrix.det_diagonal] + obtain ⟨Z, hz, hs⟩ := exists_matrix_of_nonsingular K D hrD R + (Matrix.isSymm_diagonal _) (hdet ▸ ha) + exact ⟨Z, hz, hs.trans (hdet ▸ hax)⟩ + +noncomputable def signedLayer (r : ℕ) (ξ : ℤ) : Finset (SymMatrix K D) := by + classical + exact Finset.univ.filter fun Z => Z.val.rank = r ∧ matrixSign K D Z = ξ + +noncomputable def layerMass (r : ℕ) (ξ : ℤ) : ℝ := + (signedLayer K D r ξ).card / (Fintype.card (SymMatrix K D) : ℝ) + +noncomputable def rankKernel (r : ℕ) (ξ : ℤ) (Z : SymMatrix K D) : ℝ := by + classical + exact if Z ∈ signedLayer K D r ξ then (layerMass K D r ξ)⁻¹ else 0 + +theorem matrixSign_neg (Z : SymMatrix K D) : + matrixSign K D (-Z) = quadraticChar K ((-1 : K) ^ Z.val.rank) * + matrixSign K D Z := by + have hs := discriminantSign_neg Z.val.toBilin' + (Matrix.isSymm_toBilin'_iff_isSymm.mpr Z.property) + simpa only [matrixSign, Submodule.coe_neg, map_neg, matrix_radical_quotient_rank] using hs + +@[simp] theorem mem_signedLayer (r : ℕ) (ξ : ℤ) (Z : SymMatrix K D) : + Z ∈ signedLayer K D r ξ ↔ Z.val.rank = r ∧ matrixSign K D Z = ξ := by + classical + simp [signedLayer] + +theorem signedLayer_nonempty {r : ℕ} (hr : 0 < r) (hrD : r ≤ D) + (hK : ringChar K ≠ 2) {ξ : ℤ} (hξ : ξ = 1 ∨ ξ = -1) : + (signedLayer K D r ξ).Nonempty := by + obtain ⟨Z, hz, hs⟩ := exists_matrix_rank_sign K D hr hrD hK hξ + exact ⟨Z, (mem_signedLayer K D r ξ Z).mpr ⟨hz, hs⟩⟩ + +theorem layerMass_pos {r : ℕ} (hr : 0 < r) (hrD : r ≤ D) + (hK : ringChar K ≠ 2) {ξ : ℤ} (hξ : ξ = 1 ∨ ξ = -1) : + 0 < layerMass K D r ξ := by + apply div_pos + · exact_mod_cast (signedLayer_nonempty K D hr hrD hK hξ).card_pos + · exact_mod_cast Fintype.card_pos (α := SymMatrix K D) + +theorem rankKernel_nonneg (r : ℕ) (ξ : ℤ) (Z : SymMatrix K D) : + 0 ≤ rankKernel K D r ξ Z := by + classical + unfold rankKernel layerMass + split_ifs <;> positivity + +theorem neg_mem_signedLayer (r : ℕ) (ξ : ℤ) (Z : SymMatrix K D) : + -Z ∈ signedLayer K D r ξ ↔ + Z ∈ signedLayer K D r (quadraticChar K ((-1 : K) ^ r) * ξ) := by + rw [mem_signedLayer, mem_signedLayer] + have hc := quadraticChar_sq_one (F := K) (pow_ne_zero r (neg_ne_zero.mpr one_ne_zero)) + simp only [Submodule.coe_neg, matrix_rank_neg, matrixSign_neg] + constructor + · rintro ⟨hz, hs⟩ + rw [hz] at hs + refine ⟨hz, ?_⟩ + linear_combination quadraticChar K ((-1 : K) ^ r) * hs - + matrixSign K D Z * hc + · rintro ⟨hz, hs⟩ + refine ⟨hz, ?_⟩ + rw [hz, hs] + linear_combination ξ * hc + +theorem signedLayer_card_neg (r : ℕ) (ξ : ℤ) : + (signedLayer K D r ξ).card = + (signedLayer K D r (quadraticChar K ((-1 : K) ^ r) * ξ)).card := by + classical + apply Finset.card_bij (fun Z _ => -Z) + · intro Z hZ + exact (neg_mem_signedLayer K D r ξ (-Z)).mp (by simpa using hZ) + · intro Z _ W _ h + exact neg_injective h + · intro Z hZ + exact ⟨-Z, (neg_mem_signedLayer K D r ξ Z).mpr hZ, neg_neg Z⟩ + +theorem rankKernel_neg (r : ℕ) (ξ : ℤ) (Z : SymMatrix K D) : + rankKernel K D r ξ (-Z) = + rankKernel K D r (quadraticChar K ((-1 : K) ^ r) * ξ) Z := by + classical + unfold rankKernel + simp only [neg_mem_signedLayer] + congr 1 + unfold layerMass + rw [signedLayer_card_neg] + +end FiniteLayer + +/-- Expectation under the uniform law on a finite type. -/ +noncomputable def uniformMean {A : Type*} [Fintype A] (f : A → ℝ) : ℝ := + (∑ a, f a) / Fintype.card A + +theorem uniformMean_rankKernel {K : Type*} [Field K] [Fintype K] [DecidableEq K] + (D r : ℕ) (hr : 0 < r) (hrD : r ≤ D) (hK : ringChar K ≠ 2) + {ξ : ℤ} (hξ : ξ = 1 ∨ ξ = -1) : + uniformMean (rankKernel K D r ξ) = 1 := by + classical + have hs := (signedLayer_nonempty K D hr hrD hK hξ).card_pos + have hc := Fintype.card_pos (α := SymMatrix K D) + unfold uniformMean rankKernel + rw [Finset.sum_ite_mem] + simp only [Finset.univ_inter, Finset.sum_const, nsmul_eq_mul] + unfold layerMass + have hs' : ((signedLayer K D r ξ).card : ℝ) ≠ 0 := by exact_mod_cast hs.ne' + have hc' : (Fintype.card (SymMatrix K D) : ℝ) ≠ 0 := by exact_mod_cast hc.ne' + field_simp + +abbrev OddPrime := {q : ℕ // q.Prime ∧ q ≠ 2} +instance (q : OddPrime) : Fact q.val.Prime := ⟨q.property.1⟩ + +def primeInfinity : Filter OddPrime := Filter.comap Subtype.val Filter.atTop + +def corners : Finset (Fin 13 × Fin 22) := + Finset.univ.filter fun c => c.1 ∈ faces c.2 + +def modelPointPairs : Finset (Finset (Fin 13)) := + Finset.univ.biUnion fun j => (faces j).powersetCard 2 + +abbrev ModelPair := {e : Finset (Fin 13) // e ∈ modelPointPairs} + +noncomputable def layerCorrelation (D : ℕ) (q : OddPrime) + (B : Finset (Fin 13 × Fin 22)) (ξ : Fin 13 × Fin 22 → ℤ) : ℝ := + uniformMean fun xy : (Fin 13 → SymMatrix (ZMod q.val) D) × + (Fin 22 → SymMatrix (ZMod q.val) D) => + ∏ c ∈ B, rankKernel (ZMod q.val) D (D / 2) (ξ c) (xy.1 c.1 - xy.2 c.2) + +noncomputable def signModelCorrelation (D : ℕ) (q : OddPrime) + (B : Finset (Fin 13 × Fin 22)) (ξ : Fin 13 × Fin 22 → ℤ) : ℝ := by + classical + let c₀ : ℝ := quadraticChar (ZMod q.val) ((-1) ^ (D / 2)) + exact uniformMean fun η : ModelPair → Bool => + ∏ j : Fin 22, ∏ e : ModelPair, + if e.val ⊆ faces j ∧ (∀ i ∈ e.val, (i,j) ∈ B) then + 1 + c₀ * (if η e then 1 else -1) * ∏ i ∈ e.val, (ξ (i,j) : ℝ) + else 1 + + + + +def RankLayerLimit : Prop := ∃ D₀ : ℕ, 0 < D₀ ∧ + ∀ D : ℕ, D₀ ≤ D → Even D → + ∀ B : Finset (Fin 13 × Fin 22), B ⊆ corners → + ∀ ξ : Fin 13 × Fin 22 → ℤ, (∀ c ∈ B, ξ c = 1 ∨ ξ c = -1) → + Filter.Tendsto (fun q : OddPrime => + layerCorrelation D q B ξ - signModelCorrelation D q B ξ) + primeInfinity (nhds 0) + +end SidorenkoCounterexample + + + + + +namespace SidorenkoCounterexample +open Module LinearMap + +private theorem range_sup_complement {K V : Type*} [Field K] [AddCommGroup V] + [Module K V] (f : V →ₗ[K] V) : + LinearMap.range f ⊔ LinearMap.range (LinearMap.id - f) = ⊤ := by + apply top_unique + intro x _ + exact Submodule.mem_sup.mpr ⟨f x, ⟨x, rfl⟩, x-f x, ⟨x, rfl⟩, by abel⟩ + +/-- Equality in the dimension subadditivity for an operator and its complement +is equivalent to idempotence. -/ +theorem complementary_rank_iff {K V : Type*} [Field K] [AddCommGroup V] + [Module K V] [FiniteDimensional K V] (f : V →ₗ[K] V) : + finrank K (LinearMap.range f) + finrank K (LinearMap.range (LinearMap.id-f)) = + finrank K V ↔ IsIdempotentElem f := by + constructor + · intro h + have hsum := Submodule.finrank_sup_add_finrank_inf_eq + (LinearMap.range f) (LinearMap.range (LinearMap.id-f)) + rw [range_sup_complement, finrank_top] at hsum + have hz : finrank K (LinearMap.range f ⊓ LinearMap.range (LinearMap.id-f) : + Submodule K V) = 0 := by omega + have hinf := Submodule.finrank_eq_zero.mp hz + change f*f = f + ext x + have hx₁ : f x-f (f x) ∈ LinearMap.range f := ⟨x-f x, map_sub f x (f x)⟩ + have hx₂ : f x-f (f x) ∈ LinearMap.range (LinearMap.id-f) := ⟨f x, rfl⟩ + have hx : f x-f (f x) ∈ (⊥ : Submodule K V) := by + rw [← hinf] + exact ⟨hx₁, hx₂⟩ + have hzero : f x-f (f x) = 0 := hx + exact (sub_eq_zero.mp hzero).symm + · intro h + rw [← h.ker_eq_range] + exact f.finrank_range_add_finrank_ker + +/-- Matrix version of complementary_rank_iff. -/ +theorem matrix_complementary_rank_iff {K n : Type*} [Field K] [Fintype n] + [DecidableEq n] (P : Matrix n n K) : + P.rank + (1-P).rank = Fintype.card n ↔ P*P=P := by + have h := complementary_rank_iff (Matrix.toLin' P) + have hdim : finrank K (n → K) = Fintype.card n := Module.finrank_fintype_fun_eq_card K + rw [← Matrix.toLin'_one, ← map_sub Matrix.toLin'] at h + change P.rank+(1-P).rank = finrank K (n → K) ↔ IsIdempotentElem (Matrix.toLin' P) at h + rw [hdim] at h + rw [h] + change (Matrix.toLin' P).comp (Matrix.toLin' P) = Matrix.toLin' P ↔ _ + rw [← Matrix.toLin'_mul, Matrix.toLin'.injective.eq_iff] + +/-- Exact complementary-images equivalence in the main proof. Nonsingularity +is determinant ≠ 0; no characteristic or symmetry hypothesis is discarded +from an application, since the equivalence holds without those restrictions. -/ +theorem half_rank_projection {K n : Type*} [Field K] [Fintype n] [DecidableEq n] + (r : ℕ) (hdim : Fintype.card n = 2*r) (A B : Matrix n n K) + (hB : B.det ≠ 0) (hA : A.rank = r) : + (B-A).rank = r ↔ A*B⁻¹*A=A := by + have hu : IsUnit B.det := isUnit_iff_ne_zero.mpr hB + have hBi : B⁻¹.det ≠ 0 := by simpa [Matrix.det_nonsing_inv] using inv_ne_zero hB + have hPr : (A*B⁻¹).rank = r := (Matrix.rank_mul_eq_left_of_det_ne_zero _ _ hBi).trans hA + have hQr : (1-A*B⁻¹).rank = (B-A).rank := by + rw [show 1-A*B⁻¹ = (B-A)*B⁻¹ by rw [sub_mul, Matrix.mul_nonsing_inv B hu]] + exact Matrix.rank_mul_eq_left_of_det_ne_zero _ _ hBi + have hmain := matrix_complementary_rank_iff (A*B⁻¹) + rw [hPr, hQr, hdim] at hmain + have hsum : r+(B-A).rank=2*r ↔ (B-A).rank=r := by omega + rw [hsum] at hmain + rw [hmain] + constructor + · intro h + have hm := congrArg (fun M => M*B) h + simpa only [Matrix.mul_assoc, Matrix.nonsing_inv_mul B hu, Matrix.mul_one] using hm + · intro h + calc + (A*B⁻¹)*(A*B⁻¹) = (A*B⁻¹*A)*B⁻¹ := by simp only [Matrix.mul_assoc] + _ = A*B⁻¹ := by rw [h] + +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section Border +variable {K : Type*} [Field K] +def borderIndex (n : ℕ) : Fin (n+1) ≃ Fin n ⊕ PUnit.{1} := + (finSuccEquiv n).trans (Equiv.optionEquivSumPUnit (Fin n)) + +def borderRaw {n : ℕ} (M : Matrix (Fin n) (Fin n) K) (z : Fin n → K) (a : K) : + Matrix (Fin n ⊕ PUnit.{1}) (Fin n ⊕ PUnit.{1}) K := + Matrix.fromBlocks M (Matrix.of fun i _ => z i) (Matrix.of fun _ j => z j) (Matrix.of fun _ _ => a) + +def symmetricBorder {n : ℕ} (M : SymMatrix K n) (z : Fin n → K) (a : K) : SymMatrix K (n+1) := + ⟨(borderRaw M.val z a).submatrix (borderIndex n) (borderIndex n), by + ext i j + change borderRaw M.val z a (borderIndex n j) (borderIndex n i) = + borderRaw M.val z a (borderIndex n i) (borderIndex n j) + cases borderIndex n i with + | inl i => cases borderIndex n j with + | inl j => exact M.property.apply i j + | inr j => rfl + | inr i => cases borderIndex n j <;> rfl⟩ + +def borderUnpack {n : ℕ} (M : SymMatrix K (n+1)) : + SymMatrix K n × (Fin n → K) × K := + (⟨M.val.submatrix (fun i => (borderIndex n).symm (.inl i)) + (fun i => (borderIndex n).symm (.inl i)), by + ext i j; exact M.property.apply _ _⟩, + fun i => M.val ((borderIndex n).symm (.inl i)) ((borderIndex n).symm (.inr PUnit.unit)), + M.val ((borderIndex n).symm (.inr PUnit.unit)) ((borderIndex n).symm (.inr PUnit.unit))) + +def symmetricBorderEquiv (n : ℕ) : + SymMatrix K (n+1) ≃ SymMatrix K n × (Fin n → K) × K where + toFun := borderUnpack + invFun x := symmetricBorder x.1 x.2.1 x.2.2 + left_inv M := by + apply Subtype.ext + ext i j + obtain ⟨i,rfl⟩ := (borderIndex n).symm.surjective i + obtain ⟨j,rfl⟩ := (borderIndex n).symm.surjective j + cases i with + | inl i => cases j with + | inl j => simp [symmetricBorder,borderUnpack,borderRaw,Matrix.fromBlocks] + | inr j => cases j; simp [symmetricBorder,borderUnpack,borderRaw,Matrix.fromBlocks] + | inr i => + cases i + cases j with + | inl j => + simpa [symmetricBorder,borderUnpack,borderRaw,Matrix.fromBlocks] using + (M.property.apply ((borderIndex n).symm (.inr PUnit.unit)) + ((borderIndex n).symm (.inl j))) + | inr j => cases j; simp [symmetricBorder,borderUnpack,borderRaw,Matrix.fromBlocks] + right_inv x := by + rcases x with ⟨M,z,a⟩ + apply Prod.ext + · apply Subtype.ext; ext i j; simp [symmetricBorder,borderUnpack,borderRaw,Matrix.fromBlocks] + · apply Prod.ext + · funext i; simp [symmetricBorder,borderUnpack,borderRaw,Matrix.fromBlocks] + · simp [symmetricBorder,borderUnpack,borderRaw,Matrix.fromBlocks] + + theorem symmetricBorder_det {n : ℕ} (M : SymMatrix K n) (z : Fin n → K) (a : K) + (hM : M.val.det ≠ 0) : + (symmetricBorder M z a).val.det = M.val.det * (a - z ⬝ᵥ (M.val⁻¹.mulVec z)) := by + classical + let := Matrix.invertibleOfIsUnitDet M.val (isUnit_iff_ne_zero.mpr hM) + rw [symmetricBorder,Matrix.det_submatrix_equiv_self] + dsimp only [borderRaw] + rw [Matrix.det_fromBlocks₁₁] + congr 1 + rw [Matrix.det_unique] + simp only [Matrix.sub_apply, Matrix.mul_apply, Matrix.of_apply, + Matrix.invOf_eq_nonsing_inv, dotProduct, Matrix.mulVec, Finset.mul_sum, Finset.sum_mul] + rw [Finset.sum_comm] + simp only [mul_assoc] + +end Border +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open scoped BigOperators +section Mean +variable {A B : Type*} [Fintype A] [Fintype B] +theorem uniformMean_congr {f g : A → ℝ} (h : ∀ a, f a = g a) : + uniformMean f = uniformMean g := by + unfold uniformMean + congr 1 + exact Finset.sum_congr rfl fun a _ => h a + +theorem uniformMean_equiv (e : A ≃ B) (f : B → ℝ) : + uniformMean (f ∘ e) = uniformMean f := by + unfold uniformMean + dsimp only [Function.comp_def] + rw [Fintype.card_congr e, Equiv.sum_comp e f] + +theorem uniformMean_prod (f : A × B → ℝ) : + uniformMean f = uniformMean fun a => uniformMean fun b => f (a,b) := by + unfold uniformMean + rw [Fintype.sum_prod_type, Fintype.card_prod, Nat.cast_mul] + simp_rw [← Finset.sum_div] + ring + +theorem uniformMean_const [Nonempty A] (c : ℝ) : uniformMean (fun _ : A => c) = c := by + simp [uniformMean, (Nat.cast_ne_zero.mpr (Fintype.card_ne_zero (α := A)) : + (Fintype.card A : ℝ) ≠ 0)] + +theorem uniformMean_add (f g : A → ℝ) : + uniformMean (fun a => f a + g a) = uniformMean f + uniformMean g := by + simp [uniformMean, Finset.sum_add_distrib, add_div] + +theorem uniformMean_sub (f g : A → ℝ) : + uniformMean (fun a => f a - g a) = uniformMean f - uniformMean g := by + simp [uniformMean, Finset.sum_sub_distrib, sub_div] + +theorem uniformMean_mul (c : ℝ) (f : A → ℝ) : + uniformMean (fun a => c * f a) = c * uniformMean f := by + simp [uniformMean, ← Finset.mul_sum, mul_div_assoc] + +theorem uniformMean_mono {f g : A → ℝ} (h : ∀ a, f a ≤ g a) : + uniformMean f ≤ uniformMean g := by + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) + exact Finset.sum_le_sum fun a _ => h a + +theorem uniformMean_nonneg {f : A → ℝ} (h : ∀ a, 0 ≤ f a) : 0 ≤ uniformMean f := + div_nonneg (Finset.sum_nonneg fun a _ => h a) (Nat.cast_nonneg _) + +theorem abs_uniformMean_le (f : A → ℝ) : + |uniformMean f| ≤ uniformMean fun a => |f a| := by + unfold uniformMean + rw [abs_div, abs_of_nonneg (show (0 : ℝ) ≤ Fintype.card A from Nat.cast_nonneg _)] + exact div_le_div_of_nonneg_right (Finset.abs_sum_le_sum_abs ..) (Nat.cast_nonneg _) + +theorem uniformMean_bound [Nonempty A] {f : A → ℝ} {c : ℝ} (h : ∀ a, f a ≤ c) : + uniformMean f ≤ c := by + simpa only [uniformMean_const] using uniformMean_mono h + +theorem uniformMean_indicator (p : A → Prop) [DecidablePred p] : + uniformMean (fun a => if p a then 1 else 0) = + (Fintype.card {a // p a} : ℝ) / Fintype.card A := by + simp [uniformMean, Fintype.card_subtype, Finset.sum_boole] +end Mean +end SidorenkoCounterexample + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/Exposure.lean b/lean/OAI/Combinatorics/Sidorenko/Exposure.lean new file mode 100644 index 0000000000000000000000000000000000000000..91000d90f9036d386ccd9666d018083533b32fcd --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/Exposure.lean @@ -0,0 +1,904 @@ +import OAI.Combinatorics.Sidorenko.PairBounds + +namespace OAI + +namespace SidorenkoCounterexample +open scoped BigOperators +section Sequential +variable {A : Type*} [Finite A] + +def SeqValid (k : ℕ) (R : (Fin k → A) → Prop) + (P : (n : ℕ) → (Fin (k+n) → A) → A → Prop) : + (n : ℕ) → (Fin (k+n) → A) → Prop + | 0,x => R x + | n+1,x => SeqValid k R P n (Fin.init x) ∧ P n (Fin.init x) (x (Fin.last (k+n))) + +abbrev ValidSeq (k : ℕ) (R : (Fin k → A) → Prop) + (P : (n : ℕ) → (Fin (k+n) → A) → A → Prop) (n : ℕ) := + {x : Fin (k+n) → A // SeqValid k R P n x} + +noncomputable def validSeqSuccEquiv (k : ℕ) (R : (Fin k → A) → Prop) + (P : (n : ℕ) → (Fin (k+n) → A) → A → Prop) (n : ℕ) : + ValidSeq k R P (n+1) ≃ Σ x : ValidSeq k R P n, {a : A // P n x.val a} where + toFun x := ⟨⟨Fin.init x.val,x.property.1⟩,⟨x.val (Fin.last (k+n)),x.property.2⟩⟩ + invFun x := ⟨Fin.snoc (α := fun _ => A) x.1.val x.2.val,by + have hs : Fin.snoc (α := fun _ => A) x.1.val x.2.val (Fin.last (k+n))=x.2.val := Fin.snoc_last (α := fun _ => A) x.2.val x.1.val + change SeqValid k R P n (Fin.init (Fin.snoc (α := fun _ => A) x.1.val x.2.val)) ∧ + P n (Fin.init (Fin.snoc (α := fun _ => A) x.1.val x.2.val)) (Fin.snoc (α := fun _ => A) x.1.val x.2.val (Fin.last (k+n))) + rw [Fin.init_snoc,hs] + exact ⟨x.1.property,x.2.property⟩⟩ + left_inv x := Subtype.ext (Fin.snoc_init_self x.val) + right_inv x := by + rcases x with ⟨⟨x,hx⟩,⟨a,ha⟩⟩ + dsimp + apply Sigma.ext + · apply Subtype.ext + exact Fin.init_snoc (α := fun _ => A) a x + · apply (Subtype.heq_iff_coe_eq + (p := fun b => P n (Fin.init (Fin.snoc (α := fun _ => A) x a)) b) + (q := fun b => P n x b) (fun b => by rw [Fin.init_snoc])).mpr + exact Fin.snoc_last (α := fun _ => A) a x + + theorem validSeq_card_bound (k : ℕ) (R : (Fin k → A) → Prop) + (P : (n : ℕ) → (Fin (k+n) → A) → A → Prop) (B : ℕ → ℝ) + (hB : ∀ n, 0≤B n) (hb : ∀ n (x : ValidSeq k R P n), (Nat.card {a : A // P n x.val a}:ℝ) ≤ B n) + (n : ℕ) : (Nat.card (ValidSeq k R P n):ℝ) ≤ + Nat.card {x : Fin k → A // R x} * ∏ i : Fin n, B i.val := by + classical + induction n with + | zero => simp only [Fin.prod_univ_zero,mul_one]; exact le_rfl + | succ n ih => + let := Fintype.ofFinite (ValidSeq k R P n) + rw [Nat.card_congr (validSeqSuccEquiv k R P n),Nat.card_sigma,Nat.cast_sum] + calc + _ ≤ ∑ _x : ValidSeq k R P n, B n := Finset.sum_le_sum (fun x _ => hb n x) + _ = (Nat.card (ValidSeq k R P n):ℝ)*B n := by simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,Nat.card_eq_fintype_card] + _ ≤ (Nat.card {x : Fin k → A // R x} * ∏ i : Fin n, B i.val)*B n := mul_le_mul_of_nonneg_right ih (hB n) + _ = _ := by rw [Fin.prod_univ_castSucc]; simp only [Fin.val_castSucc,Fin.val_last]; ring +end Sequential +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open scoped BigOperators +def faceVertex : Fin 22 → Fin 3 → Fin 13 := ![![0, 1, 3], ![0, 1, 9], ![0, 2, 3], ![0, 2, 9], ![1, 3, 10], ![1, 7, 10], ![1, 7, 12], ![1, 9, 12], ![2, 3, 4], ![2, 4, 9], ![3, 4, 11], ![3, 10, 11], ![4, 8, 9], ![4, 8, 11], ![5, 6, 7], ![5, 6, 11], ![5, 7, 10], ![5, 10, 11], ![6, 7, 12], ![6, 8, 11], ![6, 8, 12], ![8, 9, 12]] +def classFace : Fin 6 → Fin 11 → Fin 22 := ![![0, 1, 2, 4, 5, 16, 14, 18, 20, 19, 13], ![3, 9, 8, 10, 11, 17, 15, 12, 21, 7, 6], ![0, 2, 8, 9, 12, 4, 11, 5, 6, 18, 14], ![1, 3, 7, 21, 20, 19, 13, 10, 15, 17, 16], ![0, 1, 3, 9, 7, 6, 5, 16, 14, 15, 19], ![2, 8, 10, 11, 4, 17, 13, 12, 21, 20, 18]] +def classPoint : Fin 6 → Fin 13 → Fin 13 := ![![0, 1, 3, 9, 2, 10, 7, 5, 6, 12, 8, 11, 4], ![0, 2, 9, 4, 3, 11, 10, 5, 6, 8, 12, 1, 7], ![0, 1, 3, 2, 4, 9, 8, 10, 11, 7, 12, 6, 5], ![0, 1, 9, 2, 12, 8, 6, 11, 4, 3, 5, 10, 7], ![0, 1, 3, 9, 2, 4, 12, 7, 10, 5, 6, 11, 8], ![0, 2, 3, 4, 11, 10, 1, 5, 8, 9, 12, 6, 7]] +def classOldZero : Fin 6 → Fin 10 → Fin 13 := ![![0, 0, 1, 1, 6, 7, 8, 8, 8, 10], ![1, 1, 4, 4, 6, 7, 3, 9, 2, 11], ![0, 3, 3, 4, 1, 2, 1, 1, 9, 11], ![0, 1, 2, 5, 6, 5, 8, 6, 10, 10], ![0, 0, 4, 1, 1, 1, 7, 9, 9, 10], ![1, 2, 2, 2, 5, 3, 3, 8, 8, 11]] +def classOldOne : Fin 6 → Fin 10 → Fin 13 := ![![1, 2, 2, 5, 5, 6, 6, 9, 10, 11], ![2, 3, 3, 5, 5, 5, 2, 2, 10, 10], ![2, 2, 4, 5, 2, 7, 7, 9, 10, 9], ![2, 2, 4, 4, 5, 7, 7, 7, 7, 11], ![1, 3, 3, 3, 6, 7, 8, 7, 10, 11], ![2, 3, 4, 5, 4, 4, 8, 9, 10, 10]] +def classOldPair : Fin 6 → Fin 10 → Fin 33 := ![![5, 1, 6, 11, 20, 25, 30, 31, 28, 22], ![4, 7, 8, 13, 21, 27, 10, 18, 16, 15], ![1, 2, 7, 10, 6, 12, 11, 19, 23, 30], ![3, 9, 16, 24, 28, 22, 14, 29, 27, 26], ![5, 3, 4, 9, 15, 19, 20, 25, 32, 29], ![2, 8, 13, 12, 21, 14, 17, 18, 24, 31]] +def classNewPairZero : Fin 6 → Fin 10 → Fin 33 := ![![3, 0, 11, 19, 25, 32, 31, 28, 29, 17], ![7, 2, 13, 12, 26, 32, 17, 24, 9, 19], ![0, 7, 4, 17, 11, 13, 19, 15, 30, 32], ![0, 15, 18, 28, 29, 17, 8, 32, 26, 25], ![3, 0, 7, 15, 19, 11, 25, 32, 27, 28], ![7, 13, 12, 6, 26, 17, 10, 24, 28, 30]] +def classNewPairOne : Fin 6 → Fin 10 → Fin 33 := ![![9, 2, 12, 20, 26, 30, 23, 24, 22, 14], ![10, 8, 14, 21, 27, 29, 18, 16, 15, 23], ![2, 8, 10, 18, 12, 21, 20, 23, 31, 25], ![4, 16, 24, 31, 22, 14, 13, 27, 21, 20], ![9, 4, 10, 16, 23, 20, 26, 30, 29, 22], ![8, 14, 21, 11, 27, 22, 18, 16, 31, 23]] +def classParent : Fin 6 → Fin 10 → Fin 11 := ![![0, 0, 0, 3, 4, 5, 6, 7, 8, 9], ![0, 1, 2, 3, 4, 5, 1, 7, 8, 9], ![0, 1, 2, 3, 0, 5, 5, 7, 8, 9], ![0, 0, 2, 3, 4, 5, 6, 5, 8, 9], ![0, 1, 2, 1, 4, 5, 6, 7, 8, 9], ![0, 1, 2, 3, 3, 2, 6, 7, 8, 9]] + + theorem faceVertex_correct : ∀ j, faces j={faceVertex j 0,faceVertex j 1,faceVertex j 2} := by decide + theorem classPoint_bijective : ∀ c, Function.Bijective (classPoint c) := by decide + theorem classFace_injective : ∀ c, Function.Injective (classFace c) := by decide + theorem classOldZero_lt : ∀ c n, (classOldZero c n).val<3+n.val := by decide + theorem classOldOne_lt : ∀ c n, (classOldOne c n).val<3+n.val := by decide + theorem classRoot_correct : ∀ c, faces (classFace c 0)={classPoint c 0,classPoint c 1,classPoint c 2} := by decide + theorem classStep_correct : ∀ c n, faces (classFace c n.succ)= + {classPoint c (classOldZero c n),classPoint c (classOldOne c n),classPoint c ⟨3+n.val,by omega⟩} := by decide + theorem classOldPair_correct : ∀ c n, pairVertices (classOldPair c n)= + {classPoint c (classOldZero c n),classPoint c (classOldOne c n)} := by decide + theorem classNewPairZero_correct : ∀ c n, pairVertices (classNewPairZero c n)= + {classPoint c (classOldZero c n),classPoint c ⟨3+n.val,by omega⟩} := by decide + theorem classNewPairOne_correct : ∀ c n, pairVertices (classNewPairOne c n)= + {classPoint c (classOldOne c n),classPoint c ⟨3+n.val,by omega⟩} := by decide + theorem classParent_lt : ∀ c n, (classParent c n).val classFace cn.1 cn.2=j).card=3 := by decide + theorem classInternal_occurs : ∀ e, (Finset.univ.filter fun c => classInternal c e).card=3-separationCount e := by decide + theorem classOldPair_internal : ∀ c n, classInternal c (classOldPair c n) := by decide + theorem classStep_pairs : ∀ c n, Finset.image (facePair (classFace c n.succ)) Finset.univ = + {classOldPair c n,classNewPairZero c n,classNewPairOne c n} := by decide + theorem classStep_pairs_distinct : ∀ c n, classOldPair c n≠classNewPairZero c n ∧ + classOldPair c n≠classNewPairOne c n ∧ classNewPairZero c n≠classNewPairOne c n := by decide + + theorem faceVertex_injective : ∀ j, Function.Injective (faceVertex j) := by decide + theorem faceVertex_pairs : ∀ j k, pairVertices (facePair j k)= + (![ {faceVertex j 0,faceVertex j 1}, {faceVertex j 0,faceVertex j 2}, {faceVertex j 1,faceVertex j 2}] : Fin 3 → Finset (Fin 13)) k := by decide + theorem classRootPairZero : ∀ c, pairVertices (facePair (classFace c 0) 0)={classPoint c 0,classPoint c 1} := by decide + theorem classRootPairOne : ∀ c, pairVertices (facePair (classFace c 0) 1)={classPoint c 0,classPoint c 2} := by decide + theorem classRootPairTwo : ∀ c, pairVertices (facePair (classFace c 0) 2)={classPoint c 1,classPoint c 2} := by decide + theorem classTree_occurs : ∀ e, (Finset.univ.filter fun cn : Fin 6 × Fin 10 => classOldPair cn.1 cn.2=e).card=3-separationCount e := by decide +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open Module + theorem inverse_power_inequality (q C L N : ℝ) (a : ℕ) (hq : 0 rfl + right_inv _ := rfl + +def faceNaturalCost (D : ℕ) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) (j : Fin 22) : ℕ := + (D+1)*c j+∑ k : Fin 3, (h (facePair j k)-c j+1).choose 2 + theorem root_natural_cost (D : ℕ) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) (j : Fin 22) : + naturalProfileCost D (c j) (h (facePair j 0)) (h (facePair j 1)) (h (facePair j 2))=faceNaturalCost D c h j := by + simp only [naturalProfileCost,faceNaturalCost,Fin.sum_univ_three] + theorem step_natural_cost (D : ℕ) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) (κ : Fin 6) (n : Fin 10) : + naturalProfileCost D (c (classFace κ n.succ)) (h (classOldPair κ n)) + (h (classNewPairZero κ n)) (h (classNewPairOne κ n))=faceNaturalCost D c h (classFace κ n.succ) := by + let f (e : Fin 33) := (h e-c (classFace κ n.succ)+1).choose 2 + have hs : (∑ e ∈ Finset.univ.image (facePair (classFace κ n.succ)), f e)= + ∑ k : Fin 3, f (facePair (classFace κ n.succ) k) := + Finset.sum_image (fun a _ b _ hab => facePair_injective _ hab) + rw [classStep_pairs] at hs + obtain ⟨h01,h02,h12⟩ := classStep_pairs_distinct κ n + simp only [Finset.sum_insert,Finset.mem_insert,Finset.mem_singleton,h01,h02,h12, + or_self,not_false_eq_true,Finset.sum_singleton] at hs + unfold naturalProfileCost faceNaturalCost + change _ = (D+1)*c (classFace κ n.succ)+∑ k, f (facePair (classFace κ n.succ) k) + rw [←hs] + simp only [f] + omega +section ExposureProfile +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] +variable (ω : LinearMap.BilinForm K E) +def PointProfile (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) (L : Fin 13 → SymplecticLagrangian ω) : Prop := + (∀ j, finrank K ↥((faces j).inf fun i => (L i).val : Submodule K E)=c j) ∧ + (∀ e, finrank K ↥((pairVertices e).inf fun i => (L i).val : Submodule K E)=h e) +def LocalProfile (c u v w : ℕ) (L M N : SymplecticLagrangian ω) : Prop := + finrank K ↥((L.val ⊓ M.val) ⊓ N.val)=c ∧ finrank K ↥(L.val ⊓ M.val)=u ∧ + finrank K ↥(L.val ⊓ N.val)=v ∧ finrank K ↥(M.val ⊓ N.val)=w + theorem PointProfile.local {c : Fin 22 → ℕ} {h : Fin 33 → ℕ} {L : Fin 13 → SymplecticLagrangian ω} + (hL : PointProfile ω c h L) (j : Fin 22) (i k l : Fin 13) (e f g : Fin 33) + (hj : faces j={i,k,l}) (he : pairVertices e={i,k}) (hf : pairVertices f={i,l}) + (hg : pairVertices g={k,l}) : LocalProfile ω (c j) (h e) (h f) (h g) (L i) (L k) (L l) := by + classical + unfold PointProfile at hL + refine ⟨?_,?_,?_,?_⟩ + · have hh := hL.1 j + rw [hj,Finset.inf_insert,Finset.inf_insert,Finset.inf_singleton,←inf_assoc] at hh + exact hh + · have hh := hL.2 e + rw [he,Finset.inf_insert,Finset.inf_singleton] at hh + exact hh + · have hh := hL.2 f + rw [hf,Finset.inf_insert,Finset.inf_singleton] at hh + exact hh + · have hh := hL.2 g + rw [hg,Finset.inf_insert,Finset.inf_singleton] at hh + exact hh + +def classRootConstraint (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) (κ : Fin 6) (x : Fin 3 → SymplecticLagrangian ω) : Prop := + LocalProfile ω (c (classFace κ 0)) (h (facePair (classFace κ 0) 0)) + (h (facePair (classFace κ 0) 1)) (h (facePair (classFace κ 0) 2)) (x 0) (x 1) (x 2) + +def classStepConstraint (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) (κ : Fin 6) + (n : ℕ) (x : Fin (3+n) → SymplecticLagrangian ω) (Y : SymplecticLagrangian ω) : Prop := + if hn : n<10 then + LocalProfile ω (c (classFace κ ⟨n+1,by omega⟩)) (h (classOldPair κ ⟨n,hn⟩)) + (h (classNewPairZero κ ⟨n,hn⟩)) (h (classNewPairOne κ ⟨n,hn⟩)) + (x ⟨(classOldZero κ ⟨n,hn⟩).val,classOldZero_lt κ ⟨n,hn⟩⟩) + (x ⟨(classOldOne κ ⟨n,hn⟩).val,classOldOne_lt κ ⟨n,hn⟩⟩) Y + else False +noncomputable def rootConstraintEquiv (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) (κ : Fin 6) : + {x : Fin 3 → SymplecticLagrangian ω // classRootConstraint ω c h κ x} ≃ + TripleDimProfile ω (c (classFace κ 0)) (h (facePair (classFace κ 0) 0)) + (h (facePair (classFace κ 0) 1)) (h (facePair (classFace κ 0) 2)) := + tupleThreeEquiv.subtypeEquiv (fun _ => Iff.rfl) + +variable [Fintype K] [Finite E] +noncomputable def classStepBound (D : ℕ) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) (κ : Fin 6) (n : ℕ) : ℝ := + if hn : n<10 then fullProfileConstant D*(Nat.card (SymplecticLagrangian ω):ℝ)* + (Fintype.card K:ℝ)^(((h (classOldPair κ ⟨n,hn⟩)+1).choose 2:ℝ)-(faceNaturalCost D c h (classFace κ ⟨n+1,by omega⟩):ℝ)) + else 0 + omit [Finite E] in + theorem classStepBound_nonneg (D : ℕ) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) (κ : Fin 6) (n : ℕ) : + 0≤classStepBound ω D c h κ n := by + unfold classStepBound + split_ifs + · exact mul_nonneg (mul_nonneg (fullProfileConstant_pos D).le (by positivity)) (Real.rpow_nonneg (by positivity) _) + · exact le_rfl + theorem classStep_card_bound (h2 : (2:K)≠0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D=finrank K E) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) (hc : ∀ j, c j≤D) + (κ : Fin 6) (n : ℕ) (x : Fin (3+n) → SymplecticLagrangian ω) : + (Nat.card {Y : SymplecticLagrangian ω // classStepConstraint ω c h κ n x Y}:ℝ) ≤ classStepBound ω D c h κ n := by + classical + by_cases hn : n<10 + · let L := x ⟨(classOldZero κ ⟨n,hn⟩).val,classOldZero_lt κ ⟨n,hn⟩⟩ + let M := x ⟨(classOldOne κ ⟨n,hn⟩).val,classOldOne_lt κ ⟨n,hn⟩⟩ + let j : Fin 22 := classFace κ ⟨n+1,by omega⟩ + let e := classOldPair κ ⟨n,hn⟩ + let f := classNewPairZero κ ⟨n,hn⟩ + let g := classNewPairOne κ ⟨n,hn⟩ + have hp : ∀ Y, classStepConstraint ω c h κ n x Y ↔ LocalProfile ω (c j) (h e) (h f) (h g) L M Y := by + intro Y; simp only [classStepConstraint,dite_eq_left hn]; rfl + by_cases hh : finrank K ↥(L.val ⊓ M.val)=h e + · have heq : Nat.card {Y // classStepConstraint ω c h κ n x Y}=Nat.card (PairCompletion ω L M (c j) (h f) (h g)) := by + apply Nat.card_congr + exact Equiv.subtypeEquivRight (fun Y => by rw [hp]; exact ⟨fun hY => ⟨hY.1,hY.2.2⟩,fun hY => ⟨hY.1,hh,hY.2⟩⟩) + rw [heq] + have hb := conditionalProfile_card_raw ω h2 ha hω D hD L M (c j) (h f) (h g) (hc j) + rw [hh] at hb + have hcost := step_natural_cost D c h κ ⟨n,hn⟩ + change naturalProfileCost D (c j) (h e) (h f) (h g)=faceNaturalCost D c h j at hcost + rw [hcost] at hb + simpa only [classStepBound,dite_eq_left hn, e,j] using hb + · have hem : IsEmpty {Y // classStepConstraint ω c h κ n x Y} := ⟨fun Y => hh ((hp Y.val).mp Y.property).2.1⟩ + have hz := Nat.card_eq_zero.mpr (Or.inl hem) + rw [hz,Nat.cast_zero] + exact classStepBound_nonneg ω D c h κ n + · have hem : IsEmpty {Y // classStepConstraint ω c h κ n x Y} := + ⟨fun Y => by simpa only [classStepConstraint,dite_eq_right hn] using Y.property⟩ + rw [Nat.card_eq_zero.mpr (Or.inl hem),Nat.cast_zero,classStepBound,dite_eq_right hn] + +noncomputable def classPrefix (κ : Fin 6) (L : Fin 13 → SymplecticLagrangian ω) + (n : ℕ) (hn : n≤10) : Fin (3+n) → SymplecticLagrangian ω := + fun i => L (classPoint κ ⟨i.val,by omega⟩) + omit [Fintype K] [Finite E] in + theorem classPrefix_valid {c : Fin 22 → ℕ} {h : Fin 33 → ℕ} + {L : Fin 13 → SymplecticLagrangian ω} (hL : PointProfile ω c h L) + (κ : Fin 6) (n : ℕ) (hn : n≤10) : + SeqValid 3 (classRootConstraint ω c h κ) (classStepConstraint ω c h κ) n (classPrefix ω κ L n hn) := by + induction n with + | zero => + exact PointProfile.local ω hL _ _ _ _ _ _ _ (classRoot_correct κ) + (classRootPairZero κ) (classRootPairOne κ) (classRootPairTwo κ) + | succ n ih => + have hn' : n<10 := by omega + refine ⟨?_,?_⟩ + · exact ih (by omega) + · simp only [classStepConstraint,dite_eq_left hn'] + exact PointProfile.local ω hL _ _ _ _ _ _ _ (classStep_correct κ ⟨n,hn'⟩) + (classOldPair_correct κ ⟨n,hn'⟩) (classNewPairZero_correct κ ⟨n,hn'⟩) + (classNewPairOne_correct κ ⟨n,hn'⟩) +noncomputable def pointProfile_class_injection (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) (κ : Fin 6) : + {L : Fin 13 → SymplecticLagrangian ω // PointProfile ω c h L} ↪ + ValidSeq 3 (classRootConstraint ω c h κ) (classStepConstraint ω c h κ) 10 where + toFun L := ⟨classPrefix ω κ L.val 10 le_rfl,classPrefix_valid ω L.property κ 10 le_rfl⟩ + inj' := by + intro L M hm + apply Subtype.ext + funext i + obtain ⟨j,hj⟩ := (classPoint_bijective κ).2 i + have hh := congrFun (congrArg Subtype.val hm) j + change L.val (classPoint κ j)=M.val (classPoint κ j) at hh + simpa only [hj] using hh + theorem classRoot_card_bound (h2 : (2:K)≠0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D=finrank K E) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) (hc : ∀ j, c j≤D) + (κ : Fin 6) : (Nat.card {x : Fin 3 → SymplecticLagrangian ω // classRootConstraint ω c h κ x}:ℝ) ≤ + fullProfileConstant D*(Nat.card (SymplecticLagrangian ω):ℝ)^3* + (Fintype.card K:ℝ)^(-(faceNaturalCost D c h (classFace κ 0):ℝ)) := by + rw [Nat.card_congr (rootConstraintEquiv ω c h κ)] + have hb := tripleProfile_card_raw ω h2 ha hω D hD (c (classFace κ 0)) + (h (facePair (classFace κ 0) 0)) (h (facePair (classFace κ 0) 1)) + (h (facePair (classFace κ 0) 2)) (hc _) + simpa only [root_natural_cost] using hb + + +noncomputable def classExponent (D : ℕ) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) (κ : Fin 6) : ℝ := + -(∑ i : Fin 11, (faceNaturalCost D c h (classFace κ i):ℝ))+ + ∑ i : Fin 10, ((h (classOldPair κ i)+1).choose 2:ℝ) + omit [Finite E] in + theorem classStepBound_product (D : ℕ) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) (κ : Fin 6) : + (∏ n : Fin 10, classStepBound ω D c h κ n.val)= + (fullProfileConstant D*(Nat.card (SymplecticLagrangian ω):ℝ))^10* + (Fintype.card K:ℝ)^(∑ n : Fin 10, + (((h (classOldPair κ n)+1).choose 2:ℝ)-(faceNaturalCost D c h (classFace κ n.succ):ℝ))) := by + have hq : 0<(Fintype.card K:ℝ) := by exact_mod_cast Fintype.card_pos (α:=K) + simp only [classStepBound,dite_eq_left (Fin.isLt _),Fin.eta,Finset.prod_mul_distrib, + Finset.prod_const,Finset.card_univ,Fintype.card_fin] + rw [Real.rpow_sum_of_pos hq,mul_pow] + rfl + theorem pointProfile_class_card_bound (h2 : (2:K)≠0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D=finrank K E) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) (hc : ∀ j, c j≤D) + (κ : Fin 6) : (Nat.card {L : Fin 13 → SymplecticLagrangian ω // PointProfile ω c h L}:ℝ) ≤ + (fullProfileConstant D)^11*(Nat.card (SymplecticLagrangian ω):ℝ)^13* + (Fintype.card K:ℝ)^(classExponent D c h κ) := by + have hq : 0<(Fintype.card K:ℝ) := by exact_mod_cast Fintype.card_pos (α:=K) + have hs := validSeq_card_bound 3 (classRootConstraint ω c h κ) (classStepConstraint ω c h κ) + (classStepBound ω D c h κ) (classStepBound_nonneg ω D c h κ) + (fun n x => classStep_card_bound ω h2 ha hω D hD c h hc κ n x.val) 10 + have hr := classRoot_card_bound ω h2 ha hω D hD c h hc κ + have hi : (Nat.card {L : Fin 13 → SymplecticLagrangian ω // PointProfile ω c h L}:ℝ) ≤ + Nat.card (ValidSeq 3 (classRootConstraint ω c h κ) (classStepConstraint ω c h κ) 10) := by + exact_mod_cast Nat.card_le_card_of_injective _ (pointProfile_class_injection ω c h κ).injective + calc + _ ≤ _ := hi.trans hs + _ ≤ (fullProfileConstant D*(Nat.card (SymplecticLagrangian ω):ℝ)^3* + (Fintype.card K:ℝ)^(-(faceNaturalCost D c h (classFace κ 0):ℝ)))* + ∏ n : Fin 10,classStepBound ω D c h κ n.val := + mul_le_mul_of_nonneg_right hr (Finset.prod_nonneg fun n _ => classStepBound_nonneg ω D c h κ n.val) + _ = _ := by + rw [classStepBound_product] + have he : -(faceNaturalCost D c h (classFace κ 0):ℝ)+ + (∑ n : Fin 10, (((h (classOldPair κ n)+1).choose 2:ℝ)- + (faceNaturalCost D c h (classFace κ n.succ):ℝ)))=classExponent D c h κ := by + unfold classExponent + rw [Fin.sum_univ_succ (fun i : Fin 11 => (faceNaturalCost D c h (classFace κ i):ℝ)),Finset.sum_sub_distrib] + ring + rw [←he,Real.rpow_add hq] + ring +end ExposureProfile + + theorem sum_class_faces (f : Fin 22 → ℝ) : + (∑ κ : Fin 6, ∑ n : Fin 11, f (classFace κ n))=3*∑ j, f j := by + rw [←Fintype.sum_prod_type (fun p : Fin 6 × Fin 11 => f (classFace p.1 p.2))] + rw [←Finset.sum_fiberwise Finset.univ (fun p : Fin 6 × Fin 11 => classFace p.1 p.2)] + have he (j : Fin 22) : (∑ p ∈ Finset.univ.filter (fun p : Fin 6 × Fin 11 => classFace p.1 p.2=j), + f (classFace p.1 p.2))=3*f j := by + calc _ = ∑ _p ∈ Finset.univ.filter (fun p : Fin 6 × Fin 11 => classFace p.1 p.2=j), f j := by + apply Finset.sum_congr rfl + intro p hp + rw [(Finset.mem_filter.mp hp).2] + _ = _ := by rw [Finset.sum_const,classFace_occurs]; simp only [nsmul_eq_mul,Nat.cast_ofNat] + simp_rw [he] + rw [Finset.mul_sum] + theorem sum_class_old_pairs (f : Fin 33 → ℝ) : + (∑ κ : Fin 6, ∑ n : Fin 10, f (classOldPair κ n))=∑ e, (3-(separationCount e:ℝ))*f e := by + rw [←Fintype.sum_prod_type (fun p : Fin 6 × Fin 10 => f (classOldPair p.1 p.2))] + rw [←Finset.sum_fiberwise Finset.univ (fun p : Fin 6 × Fin 10 => classOldPair p.1 p.2)] + apply Finset.sum_congr rfl + intro e _ + calc _ = ∑ _p ∈ Finset.univ.filter (fun p : Fin 6 × Fin 10 => classOldPair p.1 p.2=e), f e := by + apply Finset.sum_congr rfl + intro p hp + rw [(Finset.mem_filter.mp hp).2] + _ = _ := by rw [Finset.sum_const,classTree_occurs]; simp only [nsmul_eq_mul,Nat.cast_sub (separationCount_le e),Nat.cast_ofNat] +noncomputable def profileCost (D : ℕ) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) : ℝ := + (∑ j, (faceNaturalCost D c h j:ℝ))/2-(∑ e, (3-(separationCount e:ℝ))*triangular (h e))/6 + theorem sum_class_exponent (D : ℕ) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) : + (∑ κ, classExponent D c h κ)= -6*profileCost D c h := by + simp only [classExponent,Finset.sum_add_distrib,Finset.sum_neg_distrib,triangular_nat] + rw [sum_class_faces (fun j => (faceNaturalCost D c h j:ℝ)),sum_class_old_pairs (fun e => triangular (h e))] + unfold profileCost + ring + +section GlobalExposure +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] [Fintype K] [Finite E] +variable (ω : LinearMap.BilinForm K E) + theorem pointProfile_card_bound (h2 : (2:K)≠0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D=finrank K E) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) (hc : ∀ j, c j≤D) : + (Nat.card {L : Fin 13 → SymplecticLagrangian ω // PointProfile ω c h L}:ℝ) ≤ + (fullProfileConstant D)^11*(Nat.card (SymplecticLagrangian ω):ℝ)^13* + (Fintype.card K:ℝ)^(-profileCost D c h) := by + have hq : 0<(Fintype.card K:ℝ) := by exact_mod_cast Fintype.card_pos (α:=K) + have hb := Finset.prod_le_prod₀ (s:=Finset.univ) (f:=fun _κ : Fin 6 => + (Nat.card {L : Fin 13 → SymplecticLagrangian ω // PointProfile ω c h L}:ℝ)) + (fun _κ _ => Nat.cast_nonneg _) (fun κ _ => pointProfile_class_card_bound ω h2 ha hω D hD c h hc κ) + simp only [Finset.prod_mul_distrib,Finset.prod_const,Finset.card_univ,Fintype.card_fin] at hb + rw [←Real.rpow_sum_of_pos hq,sum_class_exponent] at hb + have he : -6*profileCost D c h=(-profileCost D c h)*(6:ℕ) := by norm_num; ring + rw [he,Real.rpow_mul_natCast hq.le] at hb + have hC := fullProfileConstant_pos D + apply (pow_le_pow_iff_left₀ (Nat.cast_nonneg _) (by positivity) (by norm_num : (6:ℕ)≠0)).mp + simpa only [mul_pow] using hb +end GlobalExposure +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open scoped BigOperators +section ZeroSequential +variable {A : Type*} [Finite A] +def ZeroSeqValid (P : (n : ℕ) → (Fin n → A) → A → Prop) : + (n : ℕ) → (Fin n → A) → Prop + | 0,_ => True + | n+1,x => ZeroSeqValid P n (Fin.init x) ∧ P n (Fin.init x) (x (Fin.last n)) +abbrev ZeroValidSeq (P : (n : ℕ) → (Fin n → A) → A → Prop) (n : ℕ) := + {x : Fin n → A // ZeroSeqValid P n x} +noncomputable def zeroValidSeqSuccEquiv + (P : (n : ℕ) → (Fin n → A) → A → Prop) (n : ℕ) : + ZeroValidSeq P (n+1) ≃ Σ x : ZeroValidSeq P n, {a : A // P n x.val a} where + toFun x := ⟨⟨Fin.init x.val,x.property.1⟩,⟨x.val (Fin.last n),x.property.2⟩⟩ + invFun x := ⟨Fin.snoc (α := fun _ => A) x.1.val x.2.val,by + have hs : Fin.snoc (α := fun _ => A) x.1.val x.2.val (Fin.last n)=x.2.val := Fin.snoc_last (α := fun _ => A) x.2.val x.1.val + change ZeroSeqValid P n (Fin.init (Fin.snoc (α := fun _ => A) x.1.val x.2.val)) ∧ + P n (Fin.init (Fin.snoc (α := fun _ => A) x.1.val x.2.val)) (Fin.snoc (α := fun _ => A) x.1.val x.2.val (Fin.last n)) + rw [Fin.init_snoc,hs] + exact ⟨x.1.property,x.2.property⟩⟩ + left_inv x := Subtype.ext (Fin.snoc_init_self x.val) + right_inv x := by + rcases x with ⟨⟨x,hx⟩,⟨a,ha⟩⟩ + dsimp + apply Sigma.ext + · apply Subtype.ext + exact Fin.init_snoc (α := fun _ => A) a x + · apply (Subtype.heq_iff_coe_eq + (p := fun b => P n (Fin.init (Fin.snoc (α := fun _ => A) x a)) b) + (q := fun b => P n x b) (fun b => by rw [Fin.init_snoc])).mpr + exact Fin.snoc_last (α := fun _ => A) a x + + theorem zeroValidSeq_card_bound + (P : (n : ℕ) → (Fin n → A) → A → Prop) (B : ℕ → ℝ) + (hB : ∀ n, 0≤B n) (hb : ∀ n (x : ZeroValidSeq P n), (Nat.card {a : A // P n x.val a}:ℝ) ≤ B n) + (n : ℕ) : (Nat.card (ZeroValidSeq P n):ℝ) ≤ + ∏ i : Fin n, B i.val := by + classical + induction n with + | zero => + rw [Fin.prod_univ_zero] + norm_num [ZeroValidSeq,ZeroSeqValid,Nat.card_eq_fintype_card,Fintype.card_subtype] + | succ n ih => + let := Fintype.ofFinite (ZeroValidSeq P n) + rw [Nat.card_congr (zeroValidSeqSuccEquiv P n),Nat.card_sigma,Nat.cast_sum] + calc + _ ≤ ∑ _x : ZeroValidSeq P n, B n := Finset.sum_le_sum (fun x _ => hb n x) + _ = (Nat.card (ZeroValidSeq P n):ℝ)*B n := by simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,Nat.card_eq_fintype_card] + _ ≤ (∏ i : Fin n, B i.val)*B n := mul_le_mul_of_nonneg_right ih (hB n) + _ = _ := by rw [Fin.prod_univ_castSucc]; simp only [Fin.val_castSucc,Fin.val_last] +end ZeroSequential +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section OrthogonalTuple +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] +variable (ω : LinearMap.BilinForm K E) + +def OrthogonalStep (R : ℕ → ℕ → Prop) (n : ℕ) (x : Fin n → E) (y : E) : Prop := + LinearIndependent K (Fin.snoc (α := fun _ => E) x y) ∧ ∀ i : Fin n, R i.val n → ω (x i) y=0 +abbrev OrthogonalTuple (R : ℕ → ℕ → Prop) (n : ℕ) := + {x : Fin n → E // LinearIndependent K x ∧ ∀ i j : Fin n, i.val + exact linearIndependent_empty_type + | succ n => + have hx := x.property.2.1 + rwa [Fin.snoc_init_self] at hx + theorem orthogonalTuple_valid (R : ℕ → ℕ → Prop) (n : ℕ) (x : OrthogonalTuple ω R n) : + ZeroSeqValid (OrthogonalStep ω R) n x.val := by + induction n with + | zero => trivial + | succ n ih => + have hli : LinearIndependent K (Fin.init x.val) := x.property.1.comp Fin.castSucc (Fin.castSucc_injective n) + have hrel : ∀ i j : Fin n, i.val z.val) h +noncomputable def priorConstraintCount (R : ℕ → ℕ → Prop) (n : ℕ) : ℕ := + Nat.card {i : Fin n // R i.val n} +variable [Fintype K] [Finite E] + theorem independent_orthogonal_card (hω : ω.Nondegenerate) {n : ℕ} (x : Fin n → E) + (hx : LinearIndependent K x) (s : Finset (Fin n)) : + Nat.card {y : E // ∀ i∈s, ω (x i) y=0}=(Fintype.card K)^(finrank K E-s.card) := by + classical + let z : s → E := fun i => x i.val + let S : Submodule K E := Submodule.span K (Set.range z) + have hli : LinearIndependent K z := hx.comp (fun i : s => i.val) Subtype.val_injective + have hdim : finrank K S=s.card := by rw [finrank_span_eq_card hli,Fintype.card_coe] + have he : {y : E // ∀ i∈s, ω (x i) y=0} ≃ ω.orthogonal S := + Equiv.subtypeEquivRight (fun y => by + constructor + · intro hy + rw [LinearMap.BilinForm.mem_orthogonal_iff] + have hh : S ≤ LinearMap.ker (ω.flip y) := by + apply Submodule.span_le.mpr + rintro _ ⟨i,rfl⟩ + exact hy i.val i.property + intro v hv + exact hh hv + · intro hy i hi + exact hy (x i) (Submodule.subset_span ⟨⟨i,hi⟩,rfl⟩)) + rw [Nat.card_congr he,Module.natCard_eq_pow_finrank (K := K),Nat.card_eq_fintype_card, + ω.finrank_orthogonal hω S,hdim] + theorem orthogonalStep_card_bound (hω : ω.Nondegenerate) (R : ℕ → ℕ → Prop) + (n : ℕ) (x : ZeroValidSeq (OrthogonalStep ω R) n) : + (Nat.card {y : E // OrthogonalStep ω R n x.val y}:ℝ) ≤ + (Fintype.card K:ℝ)^(finrank K E-priorConstraintCount R n) := by + classical + let s : Finset (Fin n) := Finset.univ.filter fun i => R i.val n + have he : s.card=priorConstraintCount R n := by + rw [priorConstraintCount,Nat.card_eq_fintype_card,Fintype.card_subtype] + have hi : Nat.card {y : E // OrthogonalStep ω R n x.val y} ≤ Nat.card {y : E // ∀ i∈s, ω (x.val i) y=0} := + Nat.card_le_card_of_injective (fun y => ⟨y.val,fun i hi => y.property.2 i (Finset.mem_filter.mp hi).2⟩) + (by + intro a b h + apply Subtype.ext + exact congrArg (fun z : {y : E // ∀ i∈s, ω (x.val i) y=0} => z.val) h) + rw [independent_orthogonal_card ω hω x.val (orthogonalSeq_independent ω R n x),he] at hi + exact_mod_cast hi + theorem orthogonalTuple_card_bound (hω : ω.Nondegenerate) (R : ℕ → ℕ → Prop) (n : ℕ) : + (Nat.card (OrthogonalTuple ω R n):ℝ) ≤ + (Fintype.card K:ℝ)^(∑ i : Fin n, (finrank K E-priorConstraintCount R i.val)) := by + classical + have hs := zeroValidSeq_card_bound (OrthogonalStep ω R) + (fun i => (Fintype.card K:ℝ)^(finrank K E-priorConstraintCount R i)) + (fun _ => by positivity) (orthogonalStep_card_bound ω hω R) n + rw [Finset.prod_pow_eq_pow_sum] at hs + have hh : (Nat.card (OrthogonalTuple ω R n):ℝ) ≤ Nat.card (ZeroValidSeq (OrthogonalStep ω R) n) := by + exact_mod_cast Nat.card_le_card_of_injective _ (orthogonalTupleToSeq ω R n).injective + exact hh.trans hs +end OrthogonalTuple +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +noncomputable def constraintPairCount (R : ℕ → ℕ → Prop) (n : ℕ) : ℕ := by + classical + exact ∑ j : Fin n, ∑ i : Fin n, if i.val ⟨⟨i.val.val,lt_trans (by simpa only [Nat.zero_add] using i.val.isLt) j.isLt⟩,by simpa only [Nat.zero_add] using i.val.isLt,i.property⟩ + invFun := fun i => ⟨⟨i.val.val,by simpa only [Nat.zero_add] using i.property.1⟩,i.property.2⟩ + left_inv := fun _ => rfl + right_inv := fun _ => rfl } + rw [priorConstraintCount,Nat.card_congr e,Nat.card_eq_fintype_card,Fintype.card_subtype] + simp only [Finset.sum_boole,Nat.cast_id] +section TupleRpow +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] [Fintype K] [Finite E] +variable (ω : LinearMap.BilinForm K E) + theorem orthogonalTuple_card_rpow (hω : ω.Nondegenerate) (R : ℕ → ℕ → Prop) (n : ℕ) + (hn : n≤finrank K E) : + (Nat.card {x : Fin n → E // LinearIndependent K x ∧ + ∀ i j : Fin n, i.val by subst j; exact (lt_irrefl _ h) + simp [hne,h,not_lt.mpr h.le] + · have hij : i=j := Fin.ext h + simp [hij] + · have hne : i≠j := fun hh => by subst j; exact (lt_irrefl _ h) + simp [hne,h,not_lt.mpr h.le,←hr] + simp_rw [he,Finset.sum_add_distrib] + rw [Finset.sum_comm (f:=fun i j : Fin n => if i.val ∃ (hi : i ⟨fun i=>x.val (e i),x.property.1.comp e e.injective,by + intro i j _ hij + obtain ⟨hi,hj,h⟩ := hij + exact x.property.2 _ _ h⟩ + have hf : Function.Injective f := by + intro x y h + apply Subtype.ext + funext a + have hh := congrArg (fun z => z.val (e.symm a)) h + simpa only [f,Equiv.apply_symm_apply] using hh + have hc := Nat.card_le_card_of_injective f hf + have he : {p : Fin (Fintype.card A) × Fin (Fintype.card A) // p.1≠p.2 ∧ Q p.1.val p.2.val} ≃ + {p : A×A // p.1≠p.2 ∧ R p.1 p.2} := + (e.prodCongr e).subtypeEquiv (by + intro p + change (p.1≠p.2 ∧ enumeratedRelation R e p.1.val p.2.val) ↔ (e p.1≠e p.2 ∧ R (e p.1) (e p.2)) + simp only [e.injective.ne_iff,enumeratedRelation] + constructor + · rintro ⟨hne,hi,hj,h⟩ + exact ⟨hne,h⟩ + · rintro ⟨hne,h⟩ + exact ⟨hne,p.1.isLt,p.2.isLt,h⟩) + have hd := double_constraintPairCount Q (Fintype.card A) (enumeratedRelation_symm R hR e) + rw [Nat.card_congr he] at hd + have hd' : (constraintPairCount Q (Fintype.card A):ℝ)= + (Nat.card {p : A×A // p.1≠p.2 ∧ R p.1 p.2}:ℝ)/2 := by + have hdc : (2:ℝ)*constraintPairCount Q (Fintype.card A)=(Nat.card {p : A×A // p.1≠p.2 ∧ R p.1 p.2}:ℝ) := by exact_mod_cast hd + linarith + rw [hd'] at hb + exact (by exact_mod_cast hc : (Nat.card (ConstrainedTuple ω R):ℝ)≤_).trans hb +end AbstractTuple +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section ResidualCount +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] [Fintype K] [Finite E] + theorem independentTuples_card_lower (k : ℕ) (hE : finrank K E=k) : + (Fintype.card K:ℝ)^(k*k) ≤ 2^k*(Nat.card (IndependentTuple K E k):ℝ) := by + classical + have hq : (2:ℝ)≤Fintype.card K := by exact_mod_cast (Fintype.one_lt_card (α:=K)) + have hq0 : (0:ℝ) fun _ => pow_nonneg hq0.le k) + (fun i _ => hp i) + rw [IndependentTuple,card_linearIndependent (by omega),hE,Nat.cast_prod] + simp only [Nat.cast_sub (hle _),Nat.cast_pow] + simpa only [Finset.prod_const,Finset.card_univ,Fintype.card_fin,←pow_mul,Finset.prod_mul_distrib] using h + +variable (ω : LinearMap.BilinForm K E) + theorem containingLagrangian_card_rpow (h2 : (2:K)≠0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D=finrank K E) (S : Submodule K E) : + (Nat.card {L : SymplecticLagrangian ω // S≤L.val}:ℝ) ≤ + lagrangianConstant D * (Nat.card (SymplecticLagrangian ω):ℝ) * + (Fintype.card K:ℝ)^(-(D:ℝ)*finrank K S+(finrank K S:ℝ)*(finrank K S-1)/2) := by + classical + have hq : 0<(Fintype.card K:ℝ) := by exact_mod_cast Fintype.card_pos (α:=K) + by_cases his : S≤ω.orthogonal S + · have hs := isotropic_finrank_le_half ω hω D hD S his + have h := (containingLagrangian_card_bounds ω h2 ha hω D hD S his).2 + have hl := (symplecticLagrangian_card_bounds ω h2 ha hω D hD).1 + have hC := lagrangianConstant_mono (Nat.sub_le D (finrank K S)) + have he : (((D-finrank K S+1).choose 2:ℕ):ℝ) = + ((D+1).choose 2:ℕ) + (-(D:ℝ)*finrank K S+(finrank K S:ℝ)*(finrank K S-1)/2) := by + rw [Nat.cast_choose_two,Nat.cast_choose_two] + simp only [Nat.cast_add,Nat.cast_one,Nat.cast_sub hs] + ring + rw [←Real.rpow_natCast,he,Real.rpow_add hq] at h + calc + _ ≤ _ := h + _ ≤ _ := by + rw [Real.rpow_natCast,←mul_assoc] + exact mul_le_mul_of_nonneg_right (mul_le_mul hC hl (by positivity) (lagrangianConstant_pos D).le) (Real.rpow_nonneg hq.le _) + · have hz : Nat.card {L : SymplecticLagrangian ω // S≤L.val}=0 := by + let : IsEmpty {L : SymplecticLagrangian ω // S≤L.val} := ⟨fun L => his (by + calc + S ≤ L.val.val := L.property + _ = ω.orthogonal L.val.val := L.val.property.symm + _ ≤ ω.orthogonal S := ω.orthogonal_le L.property)⟩ + exact Nat.card_eq_zero.mpr (Or.inl inferInstance) + rw [hz,Nat.cast_zero] + exact mul_nonneg (mul_nonneg (lagrangianConstant_pos D).le (Nat.cast_nonneg _)) (Real.rpow_nonneg hq.le _) +end ResidualCount +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section FamilySpan +variable {K E I : Type*} [Field K] [AddCommGroup E] [Module K E] [Fintype I] +variable [Finite E] +abbrev FamilySpanStratum (h : I → ℕ) (k : ℕ) := + {A : (i : I) → DimSubspace K E (h i) // finrank K ↥(⨆ i, (A i).val)=k} +noncomputable def familySpanCoding (h : I → ℕ) (k : ℕ) (A : FamilySpanStratum (K:=K) (E:=E) h k) : + Σ W : DimSubspace K E k, (i : I) → DimSubspace K W.val (h i) := + ⟨⟨⨆ i, (A.val i).val,A.property⟩,fun i => restrictDimSubspace (⨆ i, (A.val i).val) + (A.val i) (le_iSup (fun i => (A.val i).val) i)⟩ +omit [Fintype I] [Finite E] in + theorem familySpanCoding_injective (h : I → ℕ) (k : ℕ) : + Function.Injective (familySpanCoding (K:=K) (E:=E) h k) := by + let recover : (Σ W : DimSubspace K E k, (i : I) → DimSubspace K W.val (h i)) → (I → Submodule K E) := + fun x i => (x.2 i).val.map x.1.val.subtype + have he (A : FamilySpanStratum (K:=K) (E:=E) h k) : recover (familySpanCoding h k A)=fun i => (A.val i).val := by + funext i + change ((A.val i).val.comap (⨆ j, (A.val j).val).subtype).map (⨆ j, (A.val j).val).subtype = _ + rw [Submodule.map_comap_subtype] + exact inf_eq_right.mpr (le_iSup (fun j => (A.val j).val) i) + intro A B hAB + have hh := congrArg recover hAB + rw [he,he] at hh + apply Subtype.ext + funext i + exact Subtype.ext (congrFun hh i) +variable [Fintype K] + theorem familySpan_card_upper (h : I → ℕ) (k : ℕ) (hk : k≤finrank K E) (hh : ∀ i, h i≤k) : + (Nat.card (FamilySpanStratum (K:=K) (E:=E) h k):ℝ) ≤ + 2^(k+∑ i, h i)*(Fintype.card K:ℝ)^(k*(finrank K E-k)+∑ i, h i*(k-h i)) := by + classical + let := Fintype.ofFinite (DimSubspace K E k) + have hf (W : DimSubspace K E k) : + (Nat.card ((i : I) → DimSubspace K W.val (h i)):ℝ) ≤ + (2:ℝ)^(∑ i, h i)*(Fintype.card K:ℝ)^(∑ i, h i*(k-h i)) := by + rw [Nat.card_pi,Nat.cast_prod] + have hh' (i : I) := subspace_count_upper (K:=K) (V:=W.val) (h i) (by rw [W.property];exact hh i) + simp only [W.property] at hh' + have hp := Finset.prod_le_prod₀ (s:=Finset.univ) (fun i _ => Nat.cast_nonneg (Nat.card (DimSubspace K W.val (h i)))) (fun i _ => hh' i) + simpa only [Finset.prod_mul_distrib,Finset.prod_pow_eq_pow_sum] using hp + have hs := real_card_sigma_le (B:=DimSubspace K E k) _ hf + have hi : (Nat.card (FamilySpanStratum (K:=K) (E:=E) h k):ℝ) ≤ + Nat.card (Σ W : DimSubspace K E k, (i : I) → DimSubspace K W.val (h i)) := by + exact_mod_cast Nat.card_le_card_of_injective _ (familySpanCoding_injective (K:=K) (E:=E) h k) + calc + _ ≤ _ := hi.trans hs + _ ≤ (2^k*(Fintype.card K:ℝ)^(k*(finrank K E-k))) * + (2^(∑ i, h i)*(Fintype.card K:ℝ)^(∑ i, h i*(k-h i))) := + mul_le_mul_of_nonneg_right (subspace_count_upper k hk) (by positivity) + _ = _ := by rw [pow_add,pow_add];ring +end FamilySpan +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section DirectFamilies +variable {K E I : Type*} [Field K] [AddCommGroup E] [Module K E] [Fintype I] +variable [Finite E] +variable (ω : LinearMap.BilinForm K E) +abbrev DirectFamily (h : I → ℕ) (R : I → I → Prop) := + {A : (i : I) → DimSubspace K E (h i) // iSupIndep (fun i => (A i).val) ∧ + ∀ i j, R i j → ∀ x∈(A i).val, ∀ y∈(A j).val, ω x y=0} +abbrev FamilyBases {h : I → ℕ} {R : I → I → Prop} (A : DirectFamily ω h R) := + (i : I) → IndependentTuple K (A.val i).val (h i) +omit [Fintype I] in + theorem directFamilyBases_independent {h : I → ℕ} {R : I → I → Prop} + (A : DirectFamily ω h R) (b : FamilyBases ω A) : + LinearIndependent K (fun x : Σ i, Fin (h i) => (((b x.1).val x.2 : (A.val x.1).val):E)) := by + classical + apply linearIndependent_iUnion_finite (f := fun (i : I) (a : Fin (h i)) => ((b i).val a:E)) + · intro i + exact (b i).property.map' (A.val i).val.subtype (Submodule.ker_subtype _) + · intro i t _ hi + have he (j : I) : Submodule.span K (Set.range (fun a => (((b j).val a : (A.val j).val):E)))=(A.val j).val := + tuple_spans (h j) (A.val j) (b j) + simp_rw [he] + exact A.property.1.disjoint_biSup hi +noncomputable def directBasisForget (h : I → ℕ) (R : I → I → Prop) + (x : Σ A : DirectFamily ω h R, FamilyBases ω A) : + ConstrainedTuple ω (fun a b : Σ i, Fin (h i) => R a.1 b.1) := + ⟨fun a => ((x.2 a.1).val a.2:E),directFamilyBases_independent ω x.1 x.2, + fun a b hr => x.1.property.2 a.1 b.1 hr _ ((x.2 a.1).val a.2).property _ ((x.2 b.1).val b.2).property⟩ +omit [Fintype I] in + theorem directBasisForget_injective (h : I → ℕ) (R : I → I → Prop) : + Function.Injective (directBasisForget ω h R) := by + rintro ⟨A,s⟩ ⟨B,t⟩ hh + have hv (i : I) (a : Fin (h i)) : ((s i).val a:E)=((t i).val a:E) := + congrArg (fun x : ConstrainedTuple ω (fun a b : Σ i, Fin (h i) => R a.1 b.1) => x.val ⟨i,a⟩) hh + have hAB : A=B := by + apply Subtype.ext + funext i + apply Subtype.ext + rw [←tuple_spans (h i) (A.val i) (s i),←tuple_spans (h i) (B.val i) (t i)] + congr 2 + exact funext (hv i) + subst B + congr 1 + funext i + apply Subtype.ext + funext a + exact Subtype.ext (hv i a) +variable [Fintype K] + theorem familyBases_card_lower {h : I → ℕ} {R : I → I → Prop} (A : DirectFamily ω h R) : + (Fintype.card K:ℝ)^(∑ i, h i*h i) ≤ 2^(∑ i, h i)*(Nat.card (FamilyBases ω A):ℝ) := by + classical + have hp := Finset.prod_le_prod₀ (s:=Finset.univ) + (fun i _ => pow_nonneg (Nat.cast_nonneg (Fintype.card K)) (h i*h i)) + (fun i _ => independentTuples_card_lower (E:=(A.val i).val) (h i) (A.val i).property) + rw [FamilyBases,Nat.card_pi,Nat.cast_prod] + simpa only [Finset.prod_mul_distrib,Finset.prod_pow_eq_pow_sum] using hp + theorem directFamily_card_bound (hω : ω.Nondegenerate) (h : I → ℕ) (R : I → I → Prop) + (hR : ∀ i j, R i j → R j i) (hn : (∑ i, h i)≤finrank K E) : + (Nat.card (DirectFamily ω h R):ℝ) ≤ 2^(∑ i,h i)* + (Fintype.card K:ℝ)^((finrank K E:ℝ)*(∑ i, h i)- + (Nat.card {p : (Σ i, Fin (h i))×(Σ i, Fin (h i)) // p.1≠p.2 ∧ R p.1.1 p.2.1}:ℝ)/2- + ∑ i, (h i:ℝ)^2) := by + classical + let := Fintype.ofFinite (DirectFamily ω h R) + have hq : 0<(Fintype.card K:ℝ) := by exact_mod_cast Fintype.card_pos (α:=K) + have hb := constrainedTuple_card_rpow ω hω (fun a b : Σ i, Fin (h i) => R a.1 b.1) + (fun a b hr => hR _ _ hr) (by simpa only [Fintype.card_sigma,Fintype.card_fin] using hn) + have hf : (Nat.card (Σ A : DirectFamily ω h R, FamilyBases ω A):ℝ) ≤ + Nat.card (ConstrainedTuple ω (fun a b : Σ i, Fin (h i) => R a.1 b.1)) := by + exact_mod_cast Nat.card_le_card_of_injective _ (directBasisForget_injective ω h R) + have hl : (Nat.card (DirectFamily ω h R):ℝ)*(Fintype.card K:ℝ)^(∑ i, h i*h i) ≤ + 2^(∑ i, h i)*(Nat.card (Σ A : DirectFamily ω h R, FamilyBases ω A):ℝ) := by + rw [Nat.card_sigma,Nat.cast_sum,Finset.mul_sum] + calc + _ = ∑ _A : DirectFamily ω h R, (Fintype.card K:ℝ)^(∑ i, h i*h i) := by + simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,Nat.card_eq_fintype_card] + _ ≤ _ := Finset.sum_le_sum (fun A _ => familyBases_card_lower ω A) + have hm := hl.trans (mul_le_mul_of_nonneg_left (hf.trans hb) (by positivity : (0:ℝ)≤2^(∑ i,h i))) + have he : ((∑ i, h i*h i:ℕ):ℝ)=∑ i, (h i:ℝ)^2 := by simp only [Nat.cast_sum,Nat.cast_mul,pow_two] + rw [←Real.rpow_natCast,he] at hm + have hsum : (Fintype.card (Σ i, Fin (h i)):ℝ)=∑ i, (h i:ℝ) := by simp only [Fintype.card_sigma,Fintype.card_fin,Nat.cast_sum] + rw [hsum] at hm + apply (le_div_iff₀ (Real.rpow_pos_of_pos hq _)).mpr at hm + rw [mul_div_assoc,←Real.rpow_sub hq] at hm + simpa only [Nat.cast_sum,mul_comm (∑ i, (h i:ℝ)) (finrank K E:ℝ)] using hm +end DirectFamilies +end SidorenkoCounterexample + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/FormGluing.lean b/lean/OAI/Combinatorics/Sidorenko/FormGluing.lean new file mode 100644 index 0000000000000000000000000000000000000000..094905f2ebee2045a52c56c2057ada5d7e7e0287 --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/FormGluing.lean @@ -0,0 +1,727 @@ +import OAI.Combinatorics.Sidorenko.Lagrangian + +namespace OAI + +namespace SidorenkoCounterexample +open scoped BigOperators +open Module +section UniformMaps +variable {K U W : Type*} [Field K] [AddCommGroup U] [Module K U] + [AddCommGroup W] [Module K W] [Finite U] [Finite W] + +noncomputable def preimageFiberEquiv (f : U →ₗ[K] W) (P : W → Prop) : + {x : U // P (f x)} ≃ Σ y : {y : W // P y}, {x : U // f x = y.val} where + toFun x := ⟨⟨f x.val,x.property⟩,⟨x.val,rfl⟩⟩ + invFun y := ⟨y.2.val, by simpa only [y.2.property] using y.1.property⟩ + left_inv _ := rfl + right_inv y := by + rcases y with ⟨⟨y,hy⟩,⟨x,hx⟩⟩ + cases hx + rfl + + theorem surjective_linear_preimage_card (f : U →ₗ[K] W) + (hf : Function.Surjective f) (P : W → Prop) : + Nat.card {x : U // P (f x)} = Nat.card {y : W // P y} * Nat.card f.ker := by + classical + let : Fintype U := Fintype.ofFinite _ + let : Fintype W := Fintype.ofFinite _ + have hcard (y : W) : Nat.card {x : U // f x = y} = Nat.card f.ker := by + rw [Nat.card_eq_fintype_card, Nat.card_eq_fintype_card] + simpa [Fintype.card_subtype, LinearMap.mem_ker] using + AddMonoidHom.card_fiber_eq_of_mem_range f (hf y) (hf 0) + rw [Nat.card_congr (preimageFiberEquiv f P), Nat.card_sigma] + simp only [hcard, Finset.sum_const, nsmul_eq_mul, Finset.card_univ, Nat.card_eq_fintype_card, Nat.cast_id] + + theorem surjective_linear_card (f : U →ₗ[K] W) (hf : Function.Surjective f) : + Nat.card U = Nat.card W * Nat.card f.ker := by + have h := surjective_linear_preimage_card f hf (fun _ => True) + simpa using h + + theorem surjective_linear_probability (f : U →ₗ[K] W) + (hf : Function.Surjective f) (P : W → Prop) : + (Nat.card {x : U // P (f x)} : ℝ) / Nat.card U = + (Nat.card {y : W // P y} : ℝ) / Nat.card W := by + rw [surjective_linear_preimage_card f hf P, surjective_linear_card f hf] + have hk : (Nat.card f.ker : ℝ) ≠ 0 := by exact_mod_cast (Nat.card_pos (α := f.ker)).ne' + push_cast + exact mul_div_mul_right _ _ hk + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +noncomputable def weightedCombination (t : ι → K) : (ι → W) →ₗ[K] W := + ∑ i, t i • LinearMap.proj i + +omit [Finite W] in + theorem weightedCombination_surjective (t : ι → K) (ht : t ≠ 0) : + Function.Surjective (weightedCombination (W := W) t) := by + classical + obtain ⟨i,hi⟩ : ∃ i, t i ≠ 0 := by simpa [funext_iff] using ht + intro w + refine ⟨Pi.single i ((t i)⁻¹ • w), ?_⟩ + simp [weightedCombination, Pi.single_apply, hi] + +end UniformMaps + + +section FiniteUnion +variable {T Ω : Type*} [Fintype T] [Finite Ω] [Nonempty Ω] + +omit [Nonempty Ω] in + theorem finite_union_card_bound (A : T → Ω → Prop) : + Nat.card {x : Ω // ∃ t, A t x} ≤ ∑ t, Nat.card {x : Ω // A t x} := by + let f : (Σ t : T, {x : Ω // A t x}) → {x : Ω // ∃ t, A t x} := + fun x => ⟨x.2.val,⟨x.1,x.2.property⟩⟩ + have hf : Function.Surjective f := by + rintro ⟨x,t,ht⟩ + exact ⟨⟨t,⟨x,ht⟩⟩,rfl⟩ + exact (Nat.card_le_card_of_surjective f hf).trans_eq Nat.card_sigma + + theorem finite_union_probability_bound (A : T → Ω → Prop) (C : ℝ) + (hA : ∀ t, (Nat.card {x : Ω // A t x} : ℝ) / Nat.card Ω ≤ C) : + (Nat.card {x : Ω // ∃ t, A t x} : ℝ) / Nat.card Ω ≤ (Fintype.card T : ℝ)*C := by + have hc : (0:ℝ) < Nat.card Ω := by exact_mod_cast Nat.card_pos (α := Ω) + calc + _ ≤ (∑ t, (Nat.card {x : Ω // A t x} : ℝ)) / Nat.card Ω := by + apply div_le_div_of_nonneg_right _ hc.le + exact_mod_cast finite_union_card_bound A + _ = ∑ t, (Nat.card {x : Ω // A t x} : ℝ) / Nat.card Ω := Finset.sum_div .. + _ ≤ ∑ _t : T, C := Finset.sum_le_sum (fun t _ => hA t) + _ = _ := by simp + +end FiniteUnion + +section GoodMinors +variable {K V : Type*} [Field K] [Fintype K] [AddCommGroup V] [Module K V] [Finite V] + +def symmetricFormSubmodule : Submodule K (LinearMap.BilinForm K V) where + carrier := {B | B.IsSymm} + zero_mem' := ⟨fun _ _ => rfl⟩ + add_mem' := fun hB hC => hB.add hC + smul_mem' := fun a _ hB => hB.smul a + +noncomputable instance : AddCommGroup (SymForm K V) := by + change AddCommGroup (symmetricFormSubmodule (K := K) (V := V)) + exact Submodule.addCommGroup (R := K) (M := LinearMap.BilinForm K V) (symmetricFormSubmodule (K := K) (V := V)) +noncomputable instance : Module K (SymForm K V) := by + change Module K (symmetricFormSubmodule (K := K) (V := V)) + exact Submodule.module (symmetricFormSubmodule (K := K) (V := V)) + +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + + theorem symmetric_combination_nullity_bound (t : ι → K) (ht : t ≠ 0) + (u : ℕ) (hu : u ≤ finrank K V) : + (Nat.card {Q : ι → SymForm K V // + u ≤ finrank K (weightedCombination t Q).val.ker} : ℝ) / + Nat.card (ι → SymForm K V) ≤ 2^u / (Fintype.card K : ℝ)^((u+1).choose 2) := by + rw [surjective_linear_probability (weightedCombination t) + (weightedCombination_surjective t ht) (fun B : SymForm K V => u ≤ finrank K B.val.ker)] + exact symmetric_nullity_probability_bound u hu + + +/-- The simultaneous bad-combination event, before invertibility +conditioning. The union is over every nonzero frequency, not only a fixed +one; its cardinal cost is explicitly q^s. -/ + theorem symmetric_bad_span_bound (u : ℕ) (hu : u ≤ finrank K V) : + (Nat.card {Q : ι → SymForm K V // ∃ t : ι → K, t ≠ 0 ∧ + u ≤ finrank K (weightedCombination t Q).val.ker} : ℝ) / + Nat.card (ι → SymForm K V) ≤ + (Fintype.card K : ℝ)^(Fintype.card ι) * + (2^u / (Fintype.card K : ℝ)^((u+1).choose 2)) := by + classical + let T := {t : ι → K // t ≠ 0} + have heq : {Q : ι → SymForm K V // ∃ t : ι → K, t ≠ 0 ∧ + u ≤ finrank K (weightedCombination t Q).val.ker} ≃ + {Q : ι → SymForm K V // ∃ t : T, + u ≤ finrank K (weightedCombination t.val Q).val.ker} := + Equiv.subtypeEquiv (Equiv.refl _) (fun Q => by + constructor + · rintro ⟨t,ht,h⟩ + exact ⟨⟨t,ht⟩,h⟩ + · rintro ⟨t,h⟩ + exact ⟨t.val,t.property,h⟩) + rw [Nat.card_congr heq] + refine (finite_union_probability_bound + (fun t : T => fun Q : ι → SymForm K V => + u ≤ finrank K (weightedCombination t.val Q).val.ker) + _ (fun t => symmetric_combination_nullity_bound t.val t.property u hu)).trans ?_ + apply mul_le_mul_of_nonneg_right _ (by positivity) + have hcard : Fintype.card T ≤ Fintype.card (ι → K) := Fintype.card_subtype_le _ + rw [Fintype.card_fun] at hcard + exact_mod_cast hcard + + theorem symmetric_low_rank_span_bound (s : ℕ) (hs : s ≤ finrank K V) : + (Nat.card {Q : ι → SymForm K V // ∃ t : ι → K, t ≠ 0 ∧ + finrank K (weightedCombination t Q).val.range ≤ s} : ℝ) / + Nat.card (ι → SymForm K V) ≤ + (Fintype.card K : ℝ)^(Fintype.card ι) * + (2^(finrank K V-s) / (Fintype.card K : ℝ)^((finrank K V-s+1).choose 2)) := by + have heq : {Q : ι → SymForm K V // ∃ t : ι → K, t ≠ 0 ∧ + finrank K (weightedCombination t Q).val.range ≤ s} ≃ + {Q : ι → SymForm K V // ∃ t : ι → K, t ≠ 0 ∧ + finrank K V-s ≤ finrank K (weightedCombination t Q).val.ker} := + Equiv.subtypeEquiv (Equiv.refl _) (fun Q => by + apply exists_congr + intro t + change (t ≠ 0 ∧ finrank K (weightedCombination t Q).val.range ≤ s) ↔ + (t ≠ 0 ∧ finrank K V-s ≤ finrank K (weightedCombination t Q).val.ker) + have h : finrank K (weightedCombination t Q).val.range + + finrank K (weightedCombination t Q).val.ker = finrank K V := + (weightedCombination t Q).val.finrank_range_add_finrank_ker + apply and_congr_right + intro ht + constructor + · intro hr + omega + · intro hk + omega) + rw [Nat.card_congr heq] + exact symmetric_bad_span_bound (finrank K V-s) (Nat.sub_le _ _) + +end GoodMinors +end SidorenkoCounterexample + + +namespace SidorenkoCounterexample +section FormGluing +variable {K E V : Type*} [Field K] [AddCommGroup E] [Module K E] + [AddCommGroup V] [Module K V] + +/-- Symmetric forms descend through a linear map precisely when its kernel +is in the radical; the result is extended to the ambient codomain. -/ + theorem symmetric_form_descend (f : E →ₗ[K] V) (B : LinearMap.BilinForm K E) + (hB : B.IsSymm) (hk : f.ker ≤ B.ker) : + ∃ C : LinearMap.BilinForm K V, C.IsSymm ∧ C.compl₁₂ f f = B := by + obtain ⟨p,hp⟩ := f.range.subtype.exists_leftInverse_of_injective (LinearMap.ker_eq_bot.mpr f.range.subtype_injective) + let e := f.quotKerEquivRange + let Q := LinearMap.IsRefl.liftQ₂ B f.ker hB.isRefl hk + let g : V →ₗ[K] (E ⧸ f.ker) := e.symm.toLinearMap.comp p + have hg (x : E) : g (f x) = f.ker.mkQ x := by + apply e.injective + change e (e.symm (p (f x))) = e (f.ker.mkQ x) + rw [e.apply_symm_apply] + have hp' := LinearMap.congr_fun hp (f.rangeRestrict x) + exact hp' + refine ⟨Q.compl₁₂ g g, ?_, ?_⟩ + · constructor + intro x y + change Q (g x) (g y) = Q (g y) (g x) + generalize g x = a, g y = b + induction a using Submodule.Quotient.induction_on with + | H a => + induction b using Submodule.Quotient.induction_on with + | H b => exact hB.eq a b + · apply LinearMap.ext + intro x + apply LinearMap.ext + intro y + change Q (g (f x)) (g (f y)) = B x y + rw [hg,hg] + rfl + + theorem symmetric_form_extend (U : Submodule K V) (B : LinearMap.BilinForm K U) + (hB : B.IsSymm) : + ∃ C : LinearMap.BilinForm K V, C.IsSymm ∧ C.compl₁₂ U.subtype U.subtype = B := by + apply symmetric_form_descend U.subtype B hB + rw [Submodule.ker_subtype] + exact bot_le + +/-- The cross block implementing gluing of forms on two subspaces. Its +restrictions to the common subspace agree with the prescribed forms. -/ +def glueCross (U W : Submodule K V) (B : LinearMap.BilinForm K U) + (C : LinearMap.BilinForm K W) + (p : U →ₗ[K] ↥(U ⊓ W)) (q : W →ₗ[K] ↥(U ⊓ W)) : + U →ₗ[K] W →ₗ[K] K := + B.compl₂ ((Submodule.inclusion inf_le_left).comp q) + + LinearMap.comp C ((Submodule.inclusion inf_le_right).comp p) - + (B.compl₁₂ (Submodule.inclusion inf_le_left) (Submodule.inclusion inf_le_left)).compl₁₂ p q + +variable (U W : Submodule K V) (B : LinearMap.BilinForm K U) (C : LinearMap.BilinForm K W) +variable (p : U →ₗ[K] ↥(U ⊓ W)) (q : W →ₗ[K] ↥(U ⊓ W)) + + theorem glueCross_left (hp : p.comp (Submodule.inclusion inf_le_left) = LinearMap.id) + (s : ↥(U ⊓ W)) (w : W) : + glueCross U W B C p q (Submodule.inclusion inf_le_left s) w = + C (Submodule.inclusion inf_le_right s) w := by + have hps := LinearMap.congr_fun hp s + change p (Submodule.inclusion inf_le_left s) = s at hps + change B (Submodule.inclusion inf_le_left s) (Submodule.inclusion inf_le_left (q w)) + + C (Submodule.inclusion inf_le_right (p (Submodule.inclusion inf_le_left s))) w - + B (Submodule.inclusion inf_le_left (p (Submodule.inclusion inf_le_left s))) + (Submodule.inclusion inf_le_left (q w)) = _ + rw [hps] + ring + + theorem glueCross_right (hq : q.comp (Submodule.inclusion inf_le_right) = LinearMap.id) + (hBC : B.compl₁₂ (Submodule.inclusion inf_le_left) (Submodule.inclusion inf_le_left) = + C.compl₁₂ (Submodule.inclusion inf_le_right) (Submodule.inclusion inf_le_right)) + (u : U) (s : ↥(U ⊓ W)) : + glueCross U W B C p q u (Submodule.inclusion inf_le_right s) = + B u (Submodule.inclusion inf_le_left s) := by + have hqs := LinearMap.congr_fun hq s + change q (Submodule.inclusion inf_le_right s) = s at hqs + have hc := LinearMap.congr_fun (LinearMap.congr_fun hBC (p u)) s + change B (Submodule.inclusion inf_le_left (p u)) (Submodule.inclusion inf_le_left s) = + C (Submodule.inclusion inf_le_right (p u)) (Submodule.inclusion inf_le_right s) at hc + change B u (Submodule.inclusion inf_le_left (q (Submodule.inclusion inf_le_right s))) + + C (Submodule.inclusion inf_le_right (p u)) (Submodule.inclusion inf_le_right s) - + B (Submodule.inclusion inf_le_left (p u)) + (Submodule.inclusion inf_le_left (q (Submodule.inclusion inf_le_right s))) = _ + rw [hqs] + rw [hc] + ring + + + + theorem symmetric_form_glue (hB : B.IsSymm) (hC : C.IsSymm) + (hBC : B.compl₁₂ (Submodule.inclusion inf_le_left) (Submodule.inclusion inf_le_left) = + C.compl₁₂ (Submodule.inclusion inf_le_right) (Submodule.inclusion inf_le_right)) : + ∃ F : LinearMap.BilinForm K V, F.IsSymm ∧ + F.compl₁₂ U.subtype U.subtype = B ∧ F.compl₁₂ W.subtype W.subtype = C := by + let i : ↥(U ⊓ W) →ₗ[K] U := Submodule.inclusion inf_le_left + let j : ↥(U ⊓ W) →ₗ[K] W := Submodule.inclusion inf_le_right + have hi : Function.Injective i := by + intro x y h + exact Subtype.ext (congrArg (fun u : U => u.val) h) + have hj : Function.Injective j := by + intro x y h + exact Subtype.ext (congrArg (fun w : W => w.val) h) + obtain ⟨p,hp⟩ := i.exists_leftInverse_of_injective (LinearMap.ker_eq_bot.mpr hi) + obtain ⟨q,hq⟩ := j.exists_leftInverse_of_injective (LinearMap.ker_eq_bot.mpr hj) + let A := glueCross U W B C p q + let fst := LinearMap.fst K U W + let snd := LinearMap.snd K U W + let D : LinearMap.BilinForm K (U × W) := + B.compl₁₂ fst fst + C.compl₁₂ snd snd + + A.compl₁₂ fst snd + A.flip.compl₁₂ snd fst + have hD (x y : U × W) : D x y = B x.1 y.1 + C x.2 y.2 + A x.1 y.2 + A y.1 x.2 := rfl + have hDs : D.IsSymm := by + constructor + intro x y + rw [hD,hD,hB.eq x.1 y.1,hC.eq x.2 y.2] + ring + let f : U × W →ₗ[K] V := U.subtype.comp fst + W.subtype.comp snd + have hf (x : U × W) : f x = x.1.val + x.2.val := rfl + have hk : f.ker ≤ D.ker := by + intro x hx + have hsum : x.1.val + x.2.val = 0 := hx + have hxW : x.1.val ∈ W := by + have hh : x.1.val = -x.2.val := eq_neg_of_add_eq_zero_left hsum + rw [hh] + exact W.neg_mem x.2.property + let s : ↥(U ⊓ W) := ⟨x.1.val, x.1.property, hxW⟩ + have hxs : x = (i s, -j s) := by + apply Prod.ext + · rfl + · apply Subtype.ext + exact (eq_neg_of_add_eq_zero_right hsum) + apply LinearMap.mem_ker.mpr + apply LinearMap.ext + intro y + change D x y = 0 + rw [hxs,hD] + change B (i s) y.1 + C (-j s) y.2 + A (i s) y.2 + A y.1 (-j s) = 0 + simp only [map_neg, LinearMap.neg_apply] + rw [glueCross_left U W B C p q hp, + glueCross_right U W B C p q hq hBC, hB.eq] + ring + obtain ⟨F,hFs,hDF⟩ := symmetric_form_descend f D hDs hk + refine ⟨F,hFs,?_,?_⟩ + · apply LinearMap.ext + intro u + apply LinearMap.ext + intro v + have h := LinearMap.congr_fun (LinearMap.congr_fun hDF (u,0)) (v,0) + change F (f (u,0)) (f (v,0)) = D (u,0) (v,0) at h + simpa [hf,hD] using h + · apply LinearMap.ext + intro u + apply LinearMap.ext + intro v + have h := LinearMap.congr_fun (LinearMap.congr_fun hDF (0,u)) (0,v) + change F (f (0,u)) (f (0,v)) = D (0,u) (0,v) at h + simpa [hf,hD] using h + +/-- Pointwise form of simultaneous extension, avoiding any implicit identification +of the two copies of the common subspace. -/ +theorem symmetric_form_glue_pointwise (hB : B.IsSymm) (hC : C.IsSymm) + (hc : ∀ (x y : V) (hxU : x ∈ U) (hxW : x ∈ W) (hyU : y ∈ U) (hyW : y ∈ W), + B ⟨x,hxU⟩ ⟨y,hyU⟩ = C ⟨x,hxW⟩ ⟨y,hyW⟩) : + ∃ F : LinearMap.BilinForm K V, F.IsSymm ∧ + F.compl₁₂ U.subtype U.subtype = B ∧ F.compl₁₂ W.subtype W.subtype = C := by + apply symmetric_form_glue U W B C hB hC + ext x y + exact hc x y x.property.1 x.property.2 y.property.1 y.property.2 + +end FormGluing +section CyclicDifference +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + + + + +theorem cyclic_difference_exists (A₀ A₁ A₂ : Submodule K V) + (D₀ : LinearMap.BilinForm K ↥(A₁ ⊓ A₂)) + (D₁ : LinearMap.BilinForm K ↥(A₂ ⊓ A₀)) + (D₂ : LinearMap.BilinForm K ↥(A₀ ⊓ A₁)) + (hD₀ : D₀.IsSymm) (hD₁ : D₁.IsSymm) (hD₂ : D₂.IsSymm) + (hc : ∀ (x y : V) (hx₀ : x ∈ A₀) (hx₁ : x ∈ A₁) (hx₂ : x ∈ A₂) + (hy₀ : y ∈ A₀) (hy₁ : y ∈ A₁) (hy₂ : y ∈ A₂), + D₀ ⟨x,hx₁,hx₂⟩ ⟨y,hy₁,hy₂⟩ + D₁ ⟨x,hx₂,hx₀⟩ ⟨y,hy₂,hy₀⟩ + + D₂ ⟨x,hx₀,hx₁⟩ ⟨y,hy₀,hy₁⟩ = 0) : + ∃ F G : LinearMap.BilinForm K V, F.IsSymm ∧ G.IsSymm ∧ + (F-G).compl₁₂ (A₁ ⊓ A₂).subtype (A₁ ⊓ A₂).subtype = D₀ ∧ + G.compl₁₂ (A₂ ⊓ A₀).subtype (A₂ ⊓ A₀).subtype = D₁ ∧ + (-F).compl₁₂ (A₀ ⊓ A₁).subtype (A₀ ⊓ A₁).subtype = D₂ := by + let S := (A₁ ⊓ A₂) ⊓ (A₀ ⊓ A₁) + let i : S →ₗ[K] ↥(A₁ ⊓ A₂) := Submodule.inclusion inf_le_left + let j : S →ₗ[K] ↥(A₀ ⊓ A₁) := Submodule.inclusion inf_le_right + let T : LinearMap.BilinForm K S := (-D₂).compl₁₂ j j + have hT : T.IsSymm := by + constructor + intro x y + change -(D₂ (j x) (j y)) = -(D₂ (j y) (j x)) + rw [hD₂.eq] + have hi : i.ker = ⊥ := LinearMap.ker_eq_bot.mpr (by + intro x y h + exact Subtype.ext (congrArg (fun u : ↥(A₁ ⊓ A₂) => u.val) h)) + obtain ⟨H,hHs,hH⟩ := symmetric_form_descend i T hT (by rw [hi]; exact bot_le) + have hHval (x y : V) (hx₀ : x ∈ A₀) (hx₁ : x ∈ A₁) (hx₂ : x ∈ A₂) + (hy₀ : y ∈ A₀) (hy₁ : y ∈ A₁) (hy₂ : y ∈ A₂) : + H ⟨x,hx₁,hx₂⟩ ⟨y,hy₁,hy₂⟩ = -D₂ ⟨x,hx₀,hx₁⟩ ⟨y,hy₀,hy₁⟩ := + LinearMap.congr_fun (LinearMap.congr_fun hH ⟨x,⟨hx₁,hx₂⟩,hx₀,hx₁⟩) + ⟨y,⟨hy₁,hy₂⟩,hy₀,hy₁⟩ + have hneg : (-D₂).IsSymm := by + constructor + intro x y + change -(D₂ x y) = -(D₂ y x) + rw [hD₂.eq] + obtain ⟨F,hFs,hF₀,hF₂⟩ := symmetric_form_glue_pointwise + (A₁ ⊓ A₂) (A₀ ⊓ A₁) H (-D₂) hHs hneg (by + intro x y hx hy hx' hy' + exact hHval x y hy.1 hx.1 hx.2 hy'.1 hx'.1 hx'.2) + have hsub : (H-D₀).IsSymm := by + constructor + intro x y + change H x y - D₀ x y = H y x - D₀ y x + rw [hHs.eq,hD₀.eq] + obtain ⟨G,hGs,hG₀,hG₁⟩ := symmetric_form_glue_pointwise + (A₁ ⊓ A₂) (A₂ ⊓ A₀) (H-D₀) D₁ hsub hD₁ (by + intro x y hx hy hx' hy' + change H ⟨x,hx⟩ ⟨y,hx'⟩ - D₀ ⟨x,hx⟩ ⟨y,hx'⟩ = D₁ ⟨x,hy⟩ ⟨y,hy'⟩ + rw [hHval x y hy.2 hx.1 hx.2 hy'.2 hx'.1 hx'.2] + have h := hc x y hy.2 hx.1 hx.2 hy'.2 hx'.1 hx'.2 + linear_combination -h) + refine ⟨F,G,hFs,hGs,?_,hG₁,?_⟩ + · ext x y + have hf := LinearMap.congr_fun (LinearMap.congr_fun hF₀ x) y + have hg := LinearMap.congr_fun (LinearMap.congr_fun hG₀ x) y + change F x y = H x y at hf + change G x y = H x y - D₀ x y at hg + change F x y - G x y = D₀ x y + rw [hf,hg] + ring + · ext x y + have hf := LinearMap.congr_fun (LinearMap.congr_fun hF₂ x) y + change F x y = -D₂ x y at hf + change -(F x y) = D₂ x y + rw [hf,neg_neg] + +end CyclicDifference +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section PlantedDifference +variable {K V W : Type*} [Field K] [AddCommGroup V] [Module K V] + [AddCommGroup W] [Module K W] + +noncomputable def symFormPull (f : V →ₗ[K] W) : SymForm K W →ₗ[K] SymForm K V where + toFun B := ⟨B.val.compl₁₂ f f, by constructor; intro x y; exact B.property.eq (f x) (f y)⟩ + map_add' _ _ := rfl + map_smul' _ _ := rfl + +theorem symFormPull_surjective (f : V →ₗ[K] W) (hf : Function.Injective f) : + Function.Surjective (symFormPull f) := by + intro B + obtain ⟨C,hCs,hC⟩ := symmetric_form_descend f B.val B.property + (by rw [LinearMap.ker_eq_bot.mpr hf]; exact bot_le) + exact ⟨⟨C,hCs⟩,Subtype.ext hC⟩ + +variable (A₀ A₁ A₂ : Submodule K V) +abbrev DifferenceTargets := SymForm K ↥(A₁ ⊓ A₂) × + (SymForm K ↥(A₂ ⊓ A₀) × SymForm K ↥(A₀ ⊓ A₁)) +abbrev CommonSpace := ↥((A₀ ⊓ A₁) ⊓ A₂) + +def commonInclusion₀ : CommonSpace A₀ A₁ A₂ →ₗ[K] ↥(A₁ ⊓ A₂) := + Submodule.inclusion (le_inf (inf_le_left.trans inf_le_right) inf_le_right) +def commonInclusion₁ : CommonSpace A₀ A₁ A₂ →ₗ[K] ↥(A₂ ⊓ A₀) := + Submodule.inclusion (le_inf inf_le_right (inf_le_left.trans inf_le_left)) +def commonInclusion₂ : CommonSpace A₀ A₁ A₂ →ₗ[K] ↥(A₀ ⊓ A₁) := + Submodule.inclusion inf_le_left + +noncomputable def cyclicDifferenceMap : (Fin 3 → SymForm K V) →ₗ[K] + DifferenceTargets A₀ A₁ A₂ := + let p (i : Fin 3) : (Fin 3 → SymForm K V) →ₗ[K] SymForm K V := LinearMap.proj i + ((symFormPull (A₁ ⊓ A₂).subtype).comp (p 1 - p 2)).prod + (((symFormPull (A₂ ⊓ A₀).subtype).comp (p 2 - p 0)).prod + ((symFormPull (A₀ ⊓ A₁).subtype).comp (p 0 - p 1))) + +noncomputable def differenceConstraint : DifferenceTargets A₀ A₁ A₂ →ₗ[K] + SymForm K (CommonSpace A₀ A₁ A₂) := + (symFormPull (commonInclusion₀ A₀ A₁ A₂)).comp (LinearMap.fst K _ _) + + (symFormPull (commonInclusion₁ A₀ A₁ A₂)).comp + ((LinearMap.fst K _ _).comp (LinearMap.snd K _ _)) + + (symFormPull (commonInclusion₂ A₀ A₁ A₂)).comp + ((LinearMap.snd K _ _).comp (LinearMap.snd K _ _)) + +theorem differenceConstraint_surjective : + Function.Surjective (differenceConstraint A₀ A₁ A₂) := by + intro B + have hi : Function.Injective (commonInclusion₀ A₀ A₁ A₂) := by + intro x y h + exact Subtype.ext (congrArg (fun z : ↥(A₁ ⊓ A₂) => z.val) h) + obtain ⟨C,hC⟩ := symFormPull_surjective (commonInclusion₀ A₀ A₁ A₂) hi B + refine ⟨(C,0,0), ?_⟩ + change symFormPull (commonInclusion₀ A₀ A₁ A₂) C + + symFormPull (commonInclusion₁ A₀ A₁ A₂) 0 + + symFormPull (commonInclusion₂ A₀ A₁ A₂) 0 = B + simp [hC] + +/-- The exact image, with all common-space constraints retained. -/ +theorem cyclicDifference_range : + (cyclicDifferenceMap A₀ A₁ A₂).range = (differenceConstraint A₀ A₁ A₂).ker := by + apply le_antisymm + · rintro D ⟨F,rfl⟩ + apply LinearMap.mem_ker.mpr + apply Subtype.ext + ext x y + change (F 1).val x y - (F 2).val x y + + ((F 2).val x y - (F 0).val x y) + + ((F 0).val x y - (F 1).val x y) = 0 + ring + · intro D hD + have hcon := LinearMap.mem_ker.mp hD + obtain ⟨F,G,hFs,hGs,hFG,hG,hF⟩ := cyclic_difference_exists A₀ A₁ A₂ + D.1.val D.2.1.val D.2.2.val D.1.property D.2.1.property D.2.2.property (by + intro x y hx₀ hx₁ hx₂ hy₀ hy₁ hy₂ + exact congrArg (fun B : SymForm K (CommonSpace A₀ A₁ A₂) => + B.val ⟨x,⟨hx₀,hx₁⟩,hx₂⟩ ⟨y,⟨hy₀,hy₁⟩,hy₂⟩) hcon) + refine ⟨![0,⟨F,hFs⟩,⟨G,hGs⟩], ?_⟩ + apply Prod.ext + · apply Subtype.ext + exact hFG + · apply Prod.ext + · apply Subtype.ext + ext x y + change G x y - 0 = D.2.1.val x y + rw [sub_zero] + exact LinearMap.congr_fun (LinearMap.congr_fun hG x) y + · apply Subtype.ext + ext x y + change 0 - F x y = D.2.2.val x y + rw [zero_sub] + exact LinearMap.congr_fun (LinearMap.congr_fun hF x) y + +end PlantedDifference +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +section ConstraintDensity +variable {K U W X : Type*} [Field K] [AddCommGroup U] [Module K U] + [AddCommGroup W] [Module K W] [AddCommGroup X] [Module K X] + [Finite U] [Finite W] [Finite X] + +/-- Conditioning a uniform vector on a surjective linear constraint costs at +most the cardinality of the constraint space. This is a counting inequality, +not an independence assumption about the constrained entries. -/ +theorem linear_constraint_probability_bound (f : U →ₗ[K] W) (c : W →ₗ[K] X) + (hc : Function.Surjective c) (hfc : f.range = c.ker) (P : W → Prop) : + (Nat.card {u : U // P (f u)} : ℝ) / Nat.card U ≤ + (Nat.card X : ℝ) * (Nat.card {w : W // P w} : ℝ) / Nat.card W := by + have hprob := surjective_linear_probability f.rangeRestrict (by rintro ⟨w,u,rfl⟩; exact ⟨u,rfl⟩) + (fun w : f.range => P w.val) + have hinj : Function.Injective (fun w : {w : f.range // P w.val} => + (⟨w.val.val,w.property⟩ : {w : W // P w})) := by + intro a b h + apply Subtype.ext + apply Subtype.ext + exact congrArg (fun z : {w : W // P w} => z.val) h + have hcard := Nat.card_le_card_of_injective _ hinj + have htotal := surjective_linear_card c hc + have hx : (Nat.card X : ℝ) ≠ 0 := by exact_mod_cast (Nat.card_pos (α := X)).ne' + have hk : (Nat.card c.ker : ℝ) ≠ 0 := by exact_mod_cast (Nat.card_pos (α := c.ker)).ne' + calc + (Nat.card {u : U // P (f u)} : ℝ) / Nat.card U = + (Nat.card {w : f.range // P w.val} : ℝ) / Nat.card f.range := hprob + _ ≤ (Nat.card {w : W // P w} : ℝ) / Nat.card f.range := + div_le_div_of_nonneg_right (by exact_mod_cast hcard) (Nat.cast_nonneg _) + _ = (Nat.card X : ℝ) * (Nat.card {w : W // P w} : ℝ) / Nat.card W := by + rw [hfc,htotal] + push_cast + field_simp + +end ConstraintDensity +section ProductDensity +variable {U W X : Type*} [Finite U] [Finite W] [Finite X] + +def triplePredicateEquiv (P : U → Prop) (Q : W → Prop) (R : X → Prop) : + {z : U × (W × X) // P z.1 ∧ Q z.2.1 ∧ R z.2.2} ≃ + {u : U // P u} × ({w : W // Q w} × {x : X // R x}) where + toFun z := (⟨z.val.1,z.property.1⟩,⟨z.val.2.1,z.property.2.1⟩,⟨z.val.2.2,z.property.2.2⟩) + invFun z := ⟨(z.1.val,z.2.1.val,z.2.2.val),z.1.property,z.2.1.property,z.2.2.property⟩ + left_inv _ := rfl + right_inv _ := rfl + +omit [Finite U] [Finite W] [Finite X] in +theorem triple_predicate_probability (P : U → Prop) (Q : W → Prop) (R : X → Prop) : + (Nat.card {z : U × (W × X) // P z.1 ∧ Q z.2.1 ∧ R z.2.2} : ℝ) / + Nat.card (U × (W × X)) = + ((Nat.card {u : U // P u} : ℝ) / Nat.card U) * + ((Nat.card {w : W // Q w} : ℝ) / Nat.card W) * + ((Nat.card {x : X // R x} : ℝ) / Nat.card X) := by + rw [Nat.card_congr (triplePredicateEquiv P Q R)] + simp only [Nat.card_prod, Nat.cast_mul] + ring + +end ProductDensity +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section OriginalDifferences +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] +variable (A₀ A₁ A₂ : Submodule K V) +abbrev OriginalForms := SymForm K A₀ × (SymForm K A₁ × SymForm K A₂) + +noncomputable def ambientRestrictions : (Fin 3 → SymForm K V) →ₗ[K] + OriginalForms A₀ A₁ A₂ := + let p (i : Fin 3) : (Fin 3 → SymForm K V) →ₗ[K] SymForm K V := LinearMap.proj i + ((symFormPull A₀.subtype).comp (p 0)).prod + (((symFormPull A₁.subtype).comp (p 1)).prod ((symFormPull A₂.subtype).comp (p 2))) + +noncomputable def originalCyclicDifference : OriginalForms A₀ A₁ A₂ →ₗ[K] + DifferenceTargets A₀ A₁ A₂ := + let p₀ : OriginalForms A₀ A₁ A₂ →ₗ[K] SymForm K A₀ := LinearMap.fst K _ _ + let p₁ : OriginalForms A₀ A₁ A₂ →ₗ[K] SymForm K A₁ := + (LinearMap.fst K _ _).comp (LinearMap.snd K _ _) + let p₂ : OriginalForms A₀ A₁ A₂ →ₗ[K] SymForm K A₂ := + (LinearMap.snd K _ _).comp (LinearMap.snd K _ _) + ((symFormPull (Submodule.inclusion inf_le_left : ↥(A₁ ⊓ A₂) →ₗ[K] A₁)).comp p₁ - + (symFormPull (Submodule.inclusion inf_le_right : ↥(A₁ ⊓ A₂) →ₗ[K] A₂)).comp p₂).prod + (((symFormPull (Submodule.inclusion inf_le_left : ↥(A₂ ⊓ A₀) →ₗ[K] A₂)).comp p₂ - + (symFormPull (Submodule.inclusion inf_le_right : ↥(A₂ ⊓ A₀) →ₗ[K] A₀)).comp p₀).prod + ((symFormPull (Submodule.inclusion inf_le_left : ↥(A₀ ⊓ A₁) →ₗ[K] A₀)).comp p₀ - + (symFormPull (Submodule.inclusion inf_le_right : ↥(A₀ ⊓ A₁) →ₗ[K] A₁)).comp p₁)) + +theorem ambientRestrictions_surjective : Function.Surjective (ambientRestrictions A₀ A₁ A₂) := by + intro B + obtain ⟨F₀,h₀⟩ := symFormPull_surjective A₀.subtype A₀.subtype_injective B.1 + obtain ⟨F₁,h₁⟩ := symFormPull_surjective A₁.subtype A₁.subtype_injective B.2.1 + obtain ⟨F₂,h₂⟩ := symFormPull_surjective A₂.subtype A₂.subtype_injective B.2.2 + refine ⟨![F₀,F₁,F₂], ?_⟩ + change (symFormPull A₀.subtype F₀,symFormPull A₁.subtype F₁,symFormPull A₂.subtype F₂) = B + rw [h₀,h₁,h₂] + +theorem originalDifference_comp_restriction : + (originalCyclicDifference A₀ A₁ A₂).comp (ambientRestrictions A₀ A₁ A₂) = + cyclicDifferenceMap A₀ A₁ A₂ := by + apply LinearMap.ext + intro F + apply Prod.ext + · apply Subtype.ext + ext x y + rfl + · apply Prod.ext + · apply Subtype.ext + ext x y + rfl + · apply Subtype.ext + ext x y + rfl + +/-- The image statement for exactly the independent form spaces appearing in +the planted lift, NOT an assumption of independent difference matrices. -/ +theorem originalCyclicDifference_range : + (originalCyclicDifference A₀ A₁ A₂).range = (differenceConstraint A₀ A₁ A₂).ker := by + have h : (cyclicDifferenceMap A₀ A₁ A₂).range = + (originalCyclicDifference A₀ A₁ A₂).range := by + rw [← originalDifference_comp_restriction, LinearMap.range_comp, + LinearMap.range_eq_top.mpr (ambientRestrictions_surjective A₀ A₁ A₂), Submodule.map_top] + exact h.symm.trans (cyclicDifference_range A₀ A₁ A₂) + + + +theorem planted_nullity_probability_bound [Fintype K] [Finite V] + (t₀ t₁ t₂ : ℕ) (h₀ : t₀ ≤ finrank K ↥(A₁ ⊓ A₂)) + (h₁ : t₁ ≤ finrank K ↥(A₂ ⊓ A₀)) (h₂ : t₂ ≤ finrank K ↥(A₀ ⊓ A₁)) : + (Nat.card {F : OriginalForms A₀ A₁ A₂ // + t₀ ≤ finrank K (originalCyclicDifference A₀ A₁ A₂ F).1.val.ker ∧ + t₁ ≤ finrank K (originalCyclicDifference A₀ A₁ A₂ F).2.1.val.ker ∧ + t₂ ≤ finrank K (originalCyclicDifference A₀ A₁ A₂ F).2.2.val.ker} : ℝ) / + Nat.card (OriginalForms A₀ A₁ A₂) ≤ + (Fintype.card K : ℝ)^((finrank K (CommonSpace A₀ A₁ A₂)+1).choose 2) * + ((2^t₀ / (Fintype.card K : ℝ)^((t₀+1).choose 2)) * + (2^t₁ / (Fintype.card K : ℝ)^((t₁+1).choose 2)) * + (2^t₂ / (Fintype.card K : ℝ)^((t₂+1).choose 2))) := by + have hc := linear_constraint_probability_bound + (originalCyclicDifference A₀ A₁ A₂) (differenceConstraint A₀ A₁ A₂) + (differenceConstraint_surjective A₀ A₁ A₂) (originalCyclicDifference_range A₀ A₁ A₂) + (fun D => t₀ ≤ finrank K D.1.val.ker ∧ t₁ ≤ finrank K D.2.1.val.ker ∧ + t₂ ≤ finrank K D.2.2.val.ker) + have hp := triple_predicate_probability + (fun B : SymForm K ↥(A₁ ⊓ A₂) => t₀ ≤ finrank K B.val.ker) + (fun B : SymForm K ↥(A₂ ⊓ A₀) => t₁ ≤ finrank K B.val.ker) + (fun B : SymForm K ↥(A₀ ⊓ A₁) => t₂ ≤ finrank K B.val.ker) + rw [mul_div_assoc, hp, symForm_card, Nat.cast_pow] at hc + refine hc.trans ?_ + have hb₀ := symmetric_nullity_probability_bound (K := K) (V := ↥(A₁ ⊓ A₂)) t₀ h₀ + have hb₁ := symmetric_nullity_probability_bound (K := K) (V := ↥(A₂ ⊓ A₀)) t₁ h₁ + have hb₂ := symmetric_nullity_probability_bound (K := K) (V := ↥(A₀ ⊓ A₁)) t₂ h₂ + apply mul_le_mul_of_nonneg_left _ (by positivity) + exact mul_le_mul (mul_le_mul hb₀ hb₁ (by positivity) (by positivity)) hb₂ + (by positivity) (by positivity) + +end OriginalDifferences +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open Module +section ActualLiftCost +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [Fintype K] [Finite V] +variable (A₀ A₁ A₂ : Submodule K V) + theorem lift_pair_profile_probability_bound (t₀ t₁ t₂ : ℕ) + (h₀ : t₀ ≤ finrank K ↥(A₁ ⊓ A₂)) (h₁ : t₁ ≤ finrank K ↥(A₂ ⊓ A₀)) + (h₂ : t₂ ≤ finrank K ↥(A₀ ⊓ A₁)) : + (Nat.card {F : OriginalForms A₀ A₁ A₂ // + finrank K ↥(A₁.dualAnnihilator ⊓ A₂.dualAnnihilator) + t₀ ≤ + finrank K ↥((graphLagrangian A₁ F.2.1).val ⊓ (graphLagrangian A₂ F.2.2).val) ∧ + finrank K ↥(A₂.dualAnnihilator ⊓ A₀.dualAnnihilator) + t₁ ≤ + finrank K ↥((graphLagrangian A₂ F.2.2).val ⊓ (graphLagrangian A₀ F.1).val) ∧ + finrank K ↥(A₀.dualAnnihilator ⊓ A₁.dualAnnihilator) + t₂ ≤ + finrank K ↥((graphLagrangian A₀ F.1).val ⊓ (graphLagrangian A₁ F.2.1).val)} : ℝ) / + Nat.card (OriginalForms A₀ A₁ A₂) ≤ + (Fintype.card K : ℝ)^((finrank K (CommonSpace A₀ A₁ A₂)+1).choose 2) * + ((2^t₀ / (Fintype.card K : ℝ)^((t₀+1).choose 2)) * + (2^t₁ / (Fintype.card K : ℝ)^((t₁+1).choose 2)) * + (2^t₂ / (Fintype.card K : ℝ)^((t₂+1).choose 2))) := by + have he (F : OriginalForms A₀ A₁ A₂) : + (finrank K ↥(A₁.dualAnnihilator ⊓ A₂.dualAnnihilator) + t₀ ≤ + finrank K ↥((graphLagrangian A₁ F.2.1).val ⊓ (graphLagrangian A₂ F.2.2).val) ∧ + finrank K ↥(A₂.dualAnnihilator ⊓ A₀.dualAnnihilator) + t₁ ≤ + finrank K ↥((graphLagrangian A₂ F.2.2).val ⊓ (graphLagrangian A₀ F.1).val) ∧ + finrank K ↥(A₀.dualAnnihilator ⊓ A₁.dualAnnihilator) + t₂ ≤ + finrank K ↥((graphLagrangian A₀ F.1).val ⊓ (graphLagrangian A₁ F.2.1).val)) ↔ + (t₀ ≤ finrank K (originalCyclicDifference A₀ A₁ A₂ F).1.val.ker ∧ + t₁ ≤ finrank K (originalCyclicDifference A₀ A₁ A₂ F).2.1.val.ker ∧ + t₂ ≤ finrank K (originalCyclicDifference A₀ A₁ A₂ F).2.2.val.ker) := by + change (_ ≤ finrank K ↥(formGraph A₁ F.2.1.val ⊓ formGraph A₂ F.2.2.val) ∧ + _ ≤ finrank K ↥(formGraph A₂ F.2.2.val ⊓ formGraph A₀ F.1.val) ∧ + _ ≤ finrank K ↥(formGraph A₀ F.1.val ⊓ formGraph A₁ F.2.1.val)) ↔ _ + rw [graph_pair_intersection_finrank,graph_pair_intersection_finrank,graph_pair_intersection_finrank] + simp only [Nat.add_le_add_iff_left] + rfl + rw [Nat.card_congr (Equiv.subtypeEquivRight he)] + exact planted_nullity_probability_bound A₀ A₁ A₂ t₀ t₁ t₂ h₀ h₁ h₂ +end ActualLiftCost +end SidorenkoCounterexample + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/GlobalMoments.lean b/lean/OAI/Combinatorics/Sidorenko/GlobalMoments.lean new file mode 100644 index 0000000000000000000000000000000000000000..226592dd76d2d448e6519221ff0c5f24da569c0f --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/GlobalMoments.lean @@ -0,0 +1,700 @@ +import OAI.Combinatorics.Sidorenko.Charts + +namespace OAI + + +section + +namespace SidorenkoCounterexample +open Module Classical Filter +open scoped BigOperators +def slotLeft : Fin 3 → Fin 3 := ![0,0,1] +def slotRight : Fin 3 → Fin 3 := ![1,2,2] +theorem facePair_endpoints : ∀ j k, + pairLeft (facePair j k)=faceVertex j (slotLeft k) ∧ + pairRight (facePair j k)=faceVertex j (slotRight k) := by decide + +theorem modelPair_mem (e : Fin 33) : pairVertices e∈modelPointPairs := by + have h : ∀ e,∃ j,pairVertices e⊆faces j := by decide + obtain ⟨j,hj⟩ := h e + exact Finset.mem_biUnion.mpr ⟨j,Finset.mem_univ _,Finset.mem_powersetCard.mpr ⟨hj,pairVertices_card e⟩⟩ +theorem face_pairs_image : ∀ j, (faces j).powersetCard 2 = + Finset.univ.image (fun k => pairVertices (facePair j k)) := by decide +theorem modelPair_all (e : Finset (Fin 13)) (he : e∈modelPointPairs) : ∃ k,pairVertices k=e := by + obtain ⟨j,_,hj⟩ := Finset.mem_biUnion.mp he + rw [face_pairs_image] at hj + obtain ⟨k,_,hk⟩ := Finset.mem_image.mp hj + exact ⟨facePair j k,hk⟩ +noncomputable def pairModelEquiv : Fin 33 ≃ ModelPair := + Equiv.ofBijective (fun e => ⟨pairVertices e,modelPair_mem e⟩) ⟨ + fun _ _ h => pairVertices_injective (congrArg Subtype.val h), + fun e => by obtain ⟨k,hk⟩ := modelPair_all e.val e.property; exact ⟨k,Subtype.ext hk⟩⟩ + +def faceActive (B : Finset (Fin 13 × Fin 22)) (j : Fin 22) : Finset (Fin 3) := + Finset.univ.filter fun k => (faceVertex j k,j)∈B +noncomputable def faceSigns (B : Finset (Fin 13 × Fin 22)) (ξ : Fin 13 × Fin 22 → ℤ) + (j : Fin 22) (k : Fin 3) : ℤ := if (faceVertex j k,j)∈B then ξ (faceVertex j k,j) else 1 + +theorem fullTransverse_face {K : Type*} [Field K] {r : ℕ} (X : Fin 13 → SymMatrix K (2*r)) + (hX : fullTransverse X) (j : Fin 22) : faceTransverse r (X ∘ faceVertex j) := by + have h (k : Fin 3) := hX (facePair j k) + simp only [(facePair_endpoints j _).1,(facePair_endpoints j _).2] at h + exact ⟨h 0,h 1,h 2⟩ + +noncomputable def boolFacePolynomial (c : ℝ) (T : Finset (Fin 3)) (ξ : Fin 3 → ℤ) + (j : Fin 22) (η : Fin 33 → Bool) : ℝ := + ∏ k : Fin 3, if slotLeft k∈T ∧ slotRight k∈T then + 1+c*boolSign (η (facePair j k))*(ξ (slotLeft k) : ℝ)*(ξ (slotRight k) : ℝ) else 1 + +section FaceGraph +variable {K : Type*} [Field K] [Fintype K] [DecidableEq K] +theorem pairBool_eq_sign {D : ℕ} (X : Fin 13 → SymMatrix K D) (hX : fullTransverse X) (e : Fin 33) : + boolSign (pairBool X e)=pairSign X e := by + have h := pairBool_error X e + rw [pairSingular,ite_eq_right (hX e)] at h + exact sub_eq_zero.mp (abs_nonpos_iff.mp h) + +theorem facePolynomial_bool (r : ℕ) (T : Finset (Fin 3)) (ξ : Fin 3 → ℤ) + (X : Fin 13 → SymMatrix K (2*r)) (hX : fullTransverse X) (j : Fin 22) : + facePolynomial r T ξ (X ∘ faceVertex j)= + boolFacePolynomial (quadraticChar K ((-1 : K)^r)) T ξ j (pairBool X) := by + unfold boolFacePolynomial + simp_rw [pairBool_eq_sign X hX,pairSign,(facePair_endpoints j _).1,(facePair_endpoints j _).2] + simp only [Fin.prod_univ_three,slotLeft,slotRight,Matrix.cons_val_zero,Matrix.cons_val_one, + Matrix.cons_val_two,facePolynomial,pairPolynomial,Function.comp_def] + rfl +end FaceGraph +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module Classical Filter +open scoped BigOperators +section Global +variable {K : Type*} [Field K] [Fintype K] [DecidableEq K] +noncomputable def configurationProduct (r : ℕ) (T : Fin 22 → Finset (Fin 3)) + (ξ : Fin 22 → Fin 3 → ℤ) (X : Fin 13 → SymMatrix K (2*r)) : ℝ := + ∏ j,faceLocal r (T j) (ξ j) (X ∘ faceVertex j) +theorem configurationProduct_nonneg (r : ℕ) (T : Fin 22 → Finset (Fin 3)) + (ξ : Fin 22 → Fin 3 → ℤ) (X : Fin 13 → SymMatrix K (2*r)) : + 0≤configurationProduct r T ξ X := Finset.prod_nonneg (fun _ _ => faceLocal_nonneg ..) +noncomputable def matrixSingularTail (r : ℕ) (T : Fin 22 → Finset (Fin 3)) + (ξ : Fin 22 → Fin 3 → ℤ) : ℝ := + uniformMean fun X : Fin 13 → SymMatrix K (2*r) => + if fullTransverse X then 0 else configurationProduct r T ξ X + +def canonicalSingular (D : ℕ) (L : Fin 13 → CanonicalLag (K := K) D) : Prop := + ∃ e, finrank K ↥((pairVertices e).inf fun i => (L i).val)≠0 + +omit [Fintype K] [DecidableEq K] in +theorem canonicalSingular_chart (r : ℕ) (X : Fin 13 → SymMatrix K (2*r)) : + canonicalSingular (2*r) (matrixLagrangian ∘ X) ↔ ¬fullTransverse X := by + unfold canonicalSingular fullTransverse + rw [not_forall] + apply exists_congr + intro e + rw [pair_endpoints,Finset.inf_insert,Finset.inf_singleton] + exact not_congr (matrixLagrangian_pair_zero (2*r) (X (pairLeft e)) (X (pairRight e))) + +noncomputable def canonicalConfiguration (r : ℕ) (T : Fin 22 → Finset (Fin 3)) + (L : Fin 13 → CanonicalLag (K := K) (2*r)) : ℝ := + ∏ j,activeFaceDensity (canonicalSymplectic (K := K) (V := Fin (2*r) → K)) r + (verticalLagrangian (K := K) (V := Fin (2*r) → K)) (L ∘ faceVertex j) (T j) + +omit [Fintype K] [DecidableEq K] in +theorem canonicalConfiguration_nonneg (r : ℕ) (T : Fin 22 → Finset (Fin 3)) + (L : Fin 13 → CanonicalLag (K := K) (2*r)) : 0≤canonicalConfiguration r T L := + Finset.prod_nonneg (fun _ _ => activeFaceDensity_nonneg ..) + +theorem configuration_chart_bound (r : ℕ) (T : Fin 22 → Finset (Fin 3)) + (ξ : Fin 22 → Fin 3 → ℤ) (X : Fin 13 → SymMatrix K (2*r)) {C : ℝ} (hC : 1≤C) + (hξ : ∀ j i, canonicalStratumMass (K := K) (2*r) r / layerMass K (2*r) r (ξ j i)≤C) : + configurationProduct r T ξ X ≤ (C^3*lagrangianConstant (2*r))^22 * + canonicalConfiguration r T (matrixLagrangian ∘ X) := by + calc + _ ≤ ∏ j : Fin 22, (C^3*lagrangianConstant (2*r))* + activeFaceDensity (canonicalSymplectic (K := K) (V := Fin (2*r) → K)) r + (verticalLagrangian (K := K) (V := Fin (2*r) → K)) + (matrixLagrangian ∘ (X ∘ faceVertex j)) (T j) := + Finset.prod_le_prod₀ (fun _ _ => faceLocal_nonneg ..) + (fun j _ => faceLocal_chart_bound r (T j) (ξ j) _ hC (fun i _ => hξ j i)) + _ = _ := by rw [Finset.prod_mul_distrib,Finset.prod_const,Finset.card_univ,Fintype.card_fin]; rfl + +omit [DecidableEq K] in +theorem actualSingularTail_uniform (r : ℕ) (T : Fin 22 → Finset (Fin 3)) + [Fintype (CanonicalLag (K := K) (2*r))] : + actualSingularTail (canonicalSymplectic (K := K) (V := Fin (2*r) → K)) r + (verticalLagrangian (K := K) (V := Fin (2*r) → K)) T = + uniformMean (fun L : Fin 13 → CanonicalLag (K := K) (2*r) => + if canonicalSingular (2*r) L then canonicalConfiguration r T L else 0) := by + have hi : Fintype.ofFinite (Fin 13 → CanonicalLag (K := K) (2*r)) = + (inferInstance : Fintype (Fin 13 → CanonicalLag (K := K) (2*r))) := Subsingleton.elim _ _ + unfold actualSingularTail uniformMean + rw [hi] + simp only [Fintype.card_fun,Fintype.card_fin,Nat.cast_pow,Nat.card_eq_fintype_card] + congr 1 + apply Finset.sum_congr rfl + intro L _ + unfold canonicalSingular canonicalConfiguration + split_ifs <;> rfl + +theorem matrixSingularTail_bound (r : ℕ) (T : Fin 22 → Finset (Fin 3)) + (ξ : Fin 22 → Fin 3 → ℤ) {C : ℝ} (hC : 1≤C) + (hξ : ∀ j i, canonicalStratumMass (K := K) (2*r) r / layerMass K (2*r) r (ξ j i)≤C) : + matrixSingularTail (K := K) r T ξ ≤ + ((C^3*lagrangianConstant (2*r))^22*lagrangianConstant (2*r)^13)* + actualSingularTail (canonicalSymplectic (K := K) (V := Fin (2*r) → K)) r + (verticalLagrangian (K := K) (V := Fin (2*r) → K)) T := by + let := Fintype.ofFinite (CanonicalLag (K := K) (2*r)) + let : Nonempty (CanonicalLag (K := K) (2*r)) := ⟨verticalLagrangian⟩ + let f (L : Fin 13 → CanonicalLag (K := K) (2*r)) := + if canonicalSingular (2*r) L then canonicalConfiguration r T L else 0 + have hf (L) : 0≤f L := by dsimp only [f]; split <;> simp only [canonicalConfiguration_nonneg,le_refl] + have hj : Function.Injective (fun X : Fin 13 → SymMatrix K (2*r) => matrixLagrangian ∘ X) := by + intro X Y h; funext i; exact matrixLagrangian_injective (2*r) (congrFun h i) + have hi := uniformMean_injection (fun X : Fin 13 → SymMatrix K (2*r) => matrixLagrangian ∘ X) hj f hf + have he : ((Fintype.card (Fin 13 → CanonicalLag (K := K) (2*r)) : ℝ)/ + Fintype.card (Fin 13 → SymMatrix K (2*r)))=(chartRatio (K := K) (2*r))^13 := by + simp only [Fintype.card_fun,Fintype.card_fin,Nat.cast_pow,chartRatio,Nat.card_eq_fintype_card,div_pow] + rw [he] at hi + have hp (X : Fin 13 → SymMatrix K (2*r)) : + (if fullTransverse X then 0 else configurationProduct r T ξ X)≤ + (C^3*lagrangianConstant (2*r))^22*f (matrixLagrangian ∘ X) := by + dsimp only [f] + rw [canonicalSingular_chart] + by_cases hx : fullTransverse X + · simp only [hx,ite_true,not_true_eq_false,ite_false,mul_zero,le_refl] + · simp only [hx,ite_false,not_false_eq_true,ite_true] + exact configuration_chart_bound r T ξ X hC hξ + have hC0 : 0≤(C^3*lagrangianConstant (2*r))^22 := by positivity + calc + _ ≤ (C^3*lagrangianConstant (2*r))^22*uniformMean (fun X => f (matrixLagrangian ∘ X)) := by + rw [←uniformMean_mul]; exact uniformMean_mono hp + _ ≤ (C^3*lagrangianConstant (2*r))^22*(chartRatio (K := K) (2*r)^13*uniformMean f) := + mul_le_mul_of_nonneg_left hi hC0 + _ ≤ (C^3*lagrangianConstant (2*r))^22*(lagrangianConstant (2*r)^13*uniformMean f) := by + exact mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right + (pow_le_pow_left₀ (chartRatio_nonneg (2*r)) (chartRatio_bound (2*r)) _) (uniformMean_nonneg hf)) hC0 + _ = _ := by rw [actualSingularTail_uniform,mul_assoc] +end Global + +theorem canonicalTail_tendsto (r : ℕ) (T : Fin 22 → Finset (Fin 3)) + (hlarge : singularTailThreshold≤2*r) : Tendsto + (fun q : OddPrime => actualSingularTail (canonicalSymplectic (K := ZMod q.val) (V := Fin (2*r) → ZMod q.val)) r + (verticalLagrangian (K := ZMod q.val) (V := Fin (2*r) → ZMod q.val)) T) + primeInfinity (nhds 0) := by + have ht := (integratedTailMajorant_tendsto_zero (2*r) r (fun j => decide (T j=Finset.univ)) + (singularTailThreshold_large.trans hlarge)).comp primeInfinity_real_tendsto + apply squeeze_zero' (Eventually.of_forall (fun q => actualSingularTail_nonneg _ r _ T)) _ ht + filter_upwards [primeInfinity_real_tendsto.eventually (eventually_ge_atTop (4*lagrangianConstant (2*r)))] with q hq + have h2 : (2 : ZMod q.val)≠0 := Ring.two_ne_zero (by simpa only [ZMod.ringChar_zmod_n] using q.property.2) + let : Invertible (2 : ZMod q.val) := invertibleOfNonzero h2 + have hD : 2*(2*r)=finrank (ZMod q.val) + ((Fin (2*r) → ZMod q.val) × Module.Dual (ZMod q.val) (Fin (2*r) → ZMod q.val)) := by + rw [Module.finrank_prod,Subspace.dual_finrank_eq,Module.finrank_pi,Fintype.card_fin]; omega + have h := actualSingularTail_bound + (canonicalSymplectic (K := ZMod q.val) (V := Fin (2*r) → ZMod q.val)) + canonicalSymplectic_nondegenerate (2*r) hD h2 canonicalSymplectic_alt r rfl hlarge + (by simpa only [ZMod.card] using hq) verticalLagrangian T + simpa only [Function.comp_def,ZMod.card] using h + +theorem matrixSingularTail_tendsto (r : ℕ) (T : Fin 22 → Finset (Fin 3)) + (ξ : Fin 22 → Fin 3 → ℤ) (hξ : ∀ j i, ξ j i=1 ∨ ξ j i= -1) + (hlarge : singularTailThreshold≤2*r) : Tendsto + (fun q : OddPrime => matrixSingularTail (K := ZMod q.val) r T ξ) primeInfinity (nhds 0) := by + have hr : 0 le_trans (by norm_num : (0:ℝ)≤1) (faceBound_one (K := K) r (ξ j))) + unfold globalBound; linarith + +theorem faceBound_le_global (r : ℕ) (ξ : Fin 22 → Fin 3 → ℤ) (j : Fin 22) : + faceBound (K := K) r (ξ j)≤globalBound (K := K) r ξ := by + have h := Finset.single_le_sum (s := (Finset.univ : Finset (Fin 22))) + (fun k _ => le_trans (by norm_num : (0:ℝ)≤1) (faceBound_one (K := K) r (ξ k))) (Finset.mem_univ j) + unfold globalBound; linarith + +theorem configuration_difference_bound (hK : ringChar K≠2) (r : ℕ) (hr : 0 faceLocal r (T j) (ξ j) (X ∘ faceVertex j)) + (fun j => facePolynomial r (T j) (ξ j) (X ∘ faceVertex j)) (by linarith : 1≤globalBound (K := K) r ξ) + (fun j _ => by + rw [abs_of_nonneg (faceLocal_nonneg ..)] + exact (faceLocal_bound hK r hr (T j) (ξ j) (hξ j) _ (fullTransverse_face X hX j)).trans (faceBound_le_global r ξ j)) + (fun j _ => (facePolynomial_abs_le r (T j) (ξ j) (hξ j) _).trans hC) + simp only [Finset.card_univ,Fintype.card_fin] at h + exact h.trans (mul_le_mul_of_nonneg_left (Finset.sum_le_sum (fun j _ => + faceLocal_error hK r hr (T j) (ξ j) (hξ j) _ (fullTransverse_face X hX j))) (by positivity)) + +noncomputable def transverseDifference (r : ℕ) (T : Fin 22 → Finset (Fin 3)) + (ξ : Fin 22 → Fin 3 → ℤ) : ℝ := + uniformMean fun X : Fin 13 → SymMatrix K (2*r) => + if fullTransverse X then configurationProduct r T ξ X-configurationPolynomial r T ξ X else 0 + +theorem transverseDifference_bound (hK : ringChar K≠2) (r : ℕ) (hr : 0 faceError r (ξ j) (X ∘ faceVertex j)) := by + calc + _ ≤ uniformMean (fun X : Fin 13 → SymMatrix K (2*r) => + |if fullTransverse X then configurationProduct r T ξ X-configurationPolynomial r T ξ X else 0|) := abs_uniformMean_le _ + _ ≤ uniformMean (fun X : Fin 13 → SymMatrix K (2*r) => + globalBound (K := K) r ξ^22*∑ j,faceError r (ξ j) (X ∘ faceVertex j)) := by + apply uniformMean_mono; intro X + split_ifs with hX + · exact configuration_difference_bound hK r hr T ξ hξ X hX + · rw [abs_zero]; exact mul_nonneg (by positivity) (Finset.sum_nonneg (fun j _ => faceError_nonneg ..)) + _ = _ := by rw [uniformMean_mul,uniformMean_sum] +end GlobalProduct + +theorem globalBound_tendsto (r : ℕ) (hr : 0 globalBound (K := ZMod q.val) r ξ) primeInfinity (nhds 646) := by + have hs := (tendsto_finsetSum Finset.univ (fun j _ => faceBound_tendsto r hr (ξ j) (hξ j))).const_add 8 + norm_num only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul] at hs + exact hs + +theorem transverseDifference_tendsto (r : ℕ) (hr : 1 transverseDifference (K := ZMod q.val) r T ξ) primeInfinity (nhds 0) := by + have he := tendsto_finsetSum Finset.univ (fun j _ => + faceError_mean_tendsto r hr (ξ j) (hξ j) (faceVertex j) (faceVertex_injective j)) + simp only [Finset.sum_const_zero] at he + have ht := ((globalBound_tendsto r (by omega) ξ hξ).pow 22).mul he + simp only [mul_zero] at ht + apply squeeze_zero_norm (fun q => ?_) ht + rw [Real.norm_eq_abs] + exact transverseDifference_bound (by simpa only [ZMod.ringChar_zmod_n] using q.property.2) r (by omega) T ξ hξ +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module Classical Filter +open scoped BigOperators +noncomputable def boolConfiguration (c : ℝ) (T : Fin 22 → Finset (Fin 3)) + (ξ : Fin 22 → Fin 3 → ℤ) (η : Fin 33 → Bool) : ℝ := + ∏ j,boolFacePolynomial c (T j) (ξ j) j η + +theorem boolFacePolynomial_abs_le (c : ℝ) (hc : |c|≤1) (T : Finset (Fin 3)) + (ξ : Fin 3 → ℤ) (hξ : ∀ i,ξ i=1 ∨ ξ i= -1) (j : Fin 22) (η : Fin 33 → Bool) : + |boolFacePolynomial c T ξ j η|≤8 := by + have hs (i) : |(ξ i : ℝ)|=1 := by rcases hξ i with h|h <;> simp [h] + have h := abs_prod_le_pow Finset.univ + (fun k : Fin 3 => if slotLeft k∈T ∧ slotRight k∈T then + 1+c*boolSign (η (facePair j k))*(ξ (slotLeft k) : ℝ)*(ξ (slotRight k) : ℝ) else 1) + (by norm_num : (0:ℝ)≤2) (fun k _ => by + split_ifs + · calc + _ ≤ |(1:ℝ)|+|c*boolSign (η (facePair j k))*(ξ (slotLeft k) : ℝ)*(ξ (slotRight k) : ℝ)| := abs_add_le _ _ + _ ≤ 2 := by simp only [abs_one,abs_mul,boolSign_abs,hs,mul_one]; linarith + · norm_num) + norm_num only [Finset.card_univ,Fintype.card_fin,show (2:ℝ)^3=8 by norm_num] at h + exact h + +theorem boolConfiguration_abs_le (c : ℝ) (hc : |c|≤1) (T : Fin 22 → Finset (Fin 3)) + (ξ : Fin 22 → Fin 3 → ℤ) (hξ : ∀ j i,ξ j i=1 ∨ ξ j i= -1) (η : Fin 33 → Bool) : + |boolConfiguration c T ξ η|≤8^22 := by + simpa only [boolConfiguration,Finset.card_univ,Fintype.card_fin] using + abs_prod_le_pow Finset.univ (fun j => boolFacePolynomial c (T j) (ξ j) j η) + (by norm_num : (0:ℝ)≤8) (fun j _ => boolFacePolynomial_abs_le c hc (T j) (ξ j) (hξ j) j η) + +section GlobalBool +variable {K : Type*} [Field K] [Fintype K] [DecidableEq K] + +theorem configurationPolynomial_bool (r : ℕ) (T : Fin 22 → Finset (Fin 3)) + (ξ : Fin 22 → Fin 3 → ℤ) (X : Fin 13 → SymMatrix K (2*r)) (hX : fullTransverse X) : + configurationPolynomial r T ξ X= + boolConfiguration (quadraticChar K ((-1:K)^r)) T ξ (pairBool X) := by + apply Finset.prod_congr rfl + intro j _ + exact facePolynomial_bool r (T j) (ξ j) X hX j + +noncomputable def boolSingular (r : ℕ) (T : Fin 22 → Finset (Fin 3)) + (ξ : Fin 22 → Fin 3 → ℤ) : ℝ := + uniformMean fun X : Fin 13 → SymMatrix K (2*r) => if fullTransverse X then 0 else + boolConfiguration (quadraticChar K ((-1:K)^r)) T ξ (pairBool X) + +theorem boolSingular_bound (r : ℕ) (T : Fin 22 → Finset (Fin 3)) + (ξ : Fin 22 → Fin 3 → ℤ) (hξ : ∀ j i,ξ j i=1 ∨ ξ j i= -1) : + |boolSingular (K := K) r T ξ|≤8^22*(33*((2*r : ℕ):ℝ)/Fintype.card K) := by + have hc : |(quadraticChar K ((-1:K)^r) : ℝ)|≤1 := by + rcases quadraticChar_dichotomy (F := K) (pow_ne_zero r (neg_ne_zero.mpr one_ne_zero)) with h|h <;> simp [h] + calc + _ ≤ uniformMean (fun X : Fin 13 → SymMatrix K (2*r) => + |if fullTransverse X then 0 else boolConfiguration (quadraticChar K ((-1:K)^r)) T ξ (pairBool X)|) := abs_uniformMean_le _ + _ ≤ uniformMean (fun X : Fin 13 → SymMatrix K (2*r) => + 8^22*(if fullTransverse X then 0 else 1)) := by + apply uniformMean_mono; intro X; split_ifs + · norm_num + · simpa only [mul_one] using boolConfiguration_abs_le _ hc T ξ hξ (pairBool X) + _ = 8^22*uniformMean (fun X : Fin 13 → SymMatrix K (2*r) => if fullTransverse X then 0 else 1) := uniformMean_mul _ _ + _ ≤ _ := by + have h := mul_le_mul_of_nonneg_left (nonTransverse_mean (K := K) (D := 2*r)) (by positivity : (0:ℝ)≤8^22) + simpa only [mul_div_assoc] using h + +theorem configuration_mean_identity (r : ℕ) (T : Fin 22 → Finset (Fin 3)) + (ξ : Fin 22 → Fin 3 → ℤ) : + uniformMean (configurationProduct (K := K) r T ξ)-uniformMean + (fun X : Fin 13 → SymMatrix K (2*r) => boolConfiguration (quadraticChar K ((-1:K)^r)) T ξ (pairBool X)) = + transverseDifference (K := K) r T ξ+matrixSingularTail (K := K) r T ξ-boolSingular (K := K) r T ξ := by + rw [←uniformMean_sub] + unfold transverseDifference matrixSingularTail boolSingular + rw [←uniformMean_add,←uniformMean_sub] + apply uniformMean_congr + intro X + by_cases hx : fullTransverse X + · simp only [hx,ite_true,add_zero,sub_zero,configurationPolynomial_bool r T ξ X hx] + · simp only [hx,ite_false,zero_add] +end GlobalBool + +theorem boolSingular_tendsto (r : ℕ) (T : Fin 22 → Finset (Fin 3)) + (ξ : Fin 22 → Fin 3 → ℤ) (hξ : ∀ j i,ξ j i=1 ∨ ξ j i= -1) : Tendsto + (fun q : OddPrime => boolSingular (K := ZMod q.val) r T ξ) primeInfinity (nhds 0) := by + have hd : Tendsto (fun q : OddPrime => (33*((2*r : ℕ):ℝ))/(q.val:ℝ)) primeInfinity (nhds 0) := + tendsto_const_nhds.div_atTop primeInfinity_real_tendsto + have ht := hd.const_mul (8^22 : ℝ) + simp only [mul_zero] at ht + apply squeeze_zero_norm (fun q => ?_) ht + rw [Real.norm_eq_abs] + simpa only [ZMod.card] using boolSingular_bound (K := ZMod q.val) r T ξ hξ + +theorem configuration_bool_tendsto (r : ℕ) (T : Fin 22 → Finset (Fin 3)) + (ξ : Fin 22 → Fin 3 → ℤ) (hξ : ∀ j i,ξ j i=1 ∨ ξ j i= -1) + (hlarge : singularTailThreshold≤2*r) : Tendsto + (fun q : OddPrime => uniformMean (configurationProduct (K := ZMod q.val) r T ξ)-uniformMean + (fun X : Fin 13 → SymMatrix (ZMod q.val) (2*r) => + boolConfiguration (quadraticChar (ZMod q.val) ((-1:ZMod q.val)^r)) T ξ (pairBool X))) primeInfinity (nhds 0) := by + have hr : 1 congrArg (p.weight a*·) (h a) +@[simp] theorem mean_const (p : FiniteLaw A) (c : ℝ) : p.mean (fun _ => c)=c := by + rw [mean,←Finset.sum_mul,p.total,one_mul] +theorem mean_add (p : FiniteLaw A) (f g : A → ℝ) : + p.mean (fun a => f a+g a)=p.mean f+p.mean g := by simp only [mean,mul_add,Finset.sum_add_distrib] +theorem mean_sub (p : FiniteLaw A) (f g : A → ℝ) : + p.mean (fun a => f a-g a)=p.mean f-p.mean g := by simp only [mean,mul_sub,Finset.sum_sub_distrib] +theorem mean_mul (p : FiniteLaw A) (c : ℝ) (f : A → ℝ) : + p.mean (fun a => c*f a)=c*p.mean f := by unfold mean; rw [Finset.mul_sum]; congr 1; funext a; ring +theorem mean_mul_right (p : FiniteLaw A) (f : A → ℝ) (c : ℝ) : + p.mean (fun a => f a*c)=p.mean f*c := by unfold mean; rw [Finset.sum_mul]; congr 1; funext a; ring +omit [DecidableEq I] in +theorem mean_sum (p : FiniteLaw A) (f : I → A → ℝ) : + p.mean (fun a => ∑ i,f i a)=∑ i,p.mean (f i) := by unfold mean; simp_rw [Finset.mul_sum]; rw [Finset.sum_comm] +omit [Fintype I] [DecidableEq I] in +theorem mean_finset_sum (p : FiniteLaw A) (s : Finset I) (f : I → A → ℝ) : + p.mean (fun a => ∑ i∈s,f i a)=∑ i∈s,p.mean (f i) := by unfold mean; simp_rw [Finset.mul_sum]; rw [Finset.sum_comm] +theorem mean_nonneg (p : FiniteLaw A) {f : A → ℝ} (hf : ∀ a,0≤f a) : 0≤p.mean f := + Finset.sum_nonneg (fun a _ => mul_nonneg (p.nonneg a) (hf a)) +theorem mean_mono (p : FiniteLaw A) {f g : A → ℝ} (h : ∀ a,f a≤g a) : p.mean f≤p.mean g := + Finset.sum_le_sum (fun a _ => mul_le_mul_of_nonneg_left (h a) (p.nonneg a)) +theorem mean_bound (p : FiniteLaw A) {f : A → ℝ} {c : ℝ} (h : ∀ a,f a≤c) : p.mean f≤c := by + simpa only [mean_const] using p.mean_mono h +theorem abs_mean_le (p : FiniteLaw A) (f : A → ℝ) : |p.mean f|≤p.mean (fun a => |f a|) := by + calc + _ ≤ ∑ a,|p.weight a*f a| := Finset.abs_sum_le_sum_abs .. + _ = _ := by simp only [mean,abs_mul,abs_of_nonneg (p.nonneg _)] + +noncomputable def dirac (a : A) : FiniteLaw A where + weight b := if b=a then 1 else 0 + nonneg b := by split <;> norm_num + total := by simp +@[simp] theorem mean_dirac (a : A) (f : A → ℝ) : (dirac a).mean f=f a := by simp [mean,dirac] + +noncomputable def uniform [Nonempty A] : FiniteLaw A where + weight _ := (Fintype.card A : ℝ)⁻¹ + nonneg _ := by positivity + total := by simp [nsmul_eq_mul,ne_of_gt (Fintype.card_pos (α := A))] +theorem mean_uniform [Nonempty A] (f : A → ℝ) : uniform.mean f=uniformMean f := by + simp only [mean,uniform,uniformMean,div_eq_mul_inv,Finset.sum_mul,mul_comm] + +noncomputable def prod (p : FiniteLaw A) (q : FiniteLaw B) : FiniteLaw (A × B) where + weight x := p.weight x.1*q.weight x.2 + nonneg _ := mul_nonneg (p.nonneg _) (q.nonneg _) + total := by rw [Fintype.sum_prod_type]; simp_rw [←Finset.mul_sum,q.total,mul_one]; exact p.total +@[simp] theorem mean_prod (p : FiniteLaw A) (q : FiniteLaw B) (f : A × B → ℝ) : + (p.prod q).mean f=p.mean (fun a => q.mean (fun b => f (a,b))) := by + unfold mean prod; rw [Fintype.sum_prod_type]; simp_rw [Finset.mul_sum,mul_assoc] + +theorem mean_swap (p : FiniteLaw A) (q : FiniteLaw B) (f : A → B → ℝ) : + p.mean (fun a => q.mean (f a))=q.mean (fun b => p.mean (fun a => f a b)) := by + simp only [mean,Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl; intro b _ + apply Finset.sum_congr rfl; intro a _; ring + +noncomputable def independent (p : I → FiniteLaw A) : FiniteLaw (I → A) where + weight x := ∏ i,(p i).weight (x i) + nonneg x := Finset.prod_nonneg (fun i _ => (p i).nonneg (x i)) + total := by rw [←Fintype.prod_sum]; simp only [(p _).total,Finset.prod_const_one] + +theorem independent_mean_product (p : I → FiniteLaw A) (f : I → A → ℝ) : + (independent p).mean (fun x => ∏ i,f i (x i))=∏ i,(p i).mean (f i) := by + simp only [mean,independent,←Finset.prod_mul_distrib] + exact (Fintype.prod_sum (fun i a => (p i).weight a*f i a)).symm + +theorem mean_map_product (p : I → FiniteLaw A) (f : I → A → ℝ) : + (∏ i,(p i).mean (f i))=∑ x : I → A,∏ i,(p i).weight (x i)*f i (x i) := by + simp only [mean,Fintype.prod_sum] + +noncomputable def mixture (p q : FiniteLaw A) (t : ℝ) (ht : 0≤t) (ht1 : t≤1) : FiniteLaw A where + weight a := t*p.weight a+(1-t)*q.weight a + nonneg a := add_nonneg (mul_nonneg ht (p.nonneg a)) (mul_nonneg (by linarith) (q.nonneg a)) + total := by rw [Finset.sum_add_distrib,←Finset.mul_sum,←Finset.mul_sum,p.total,q.total]; ring + +theorem mean_mixture (p q : FiniteLaw A) (t : ℝ) (ht : 0≤t) (ht1 : t≤1) (f : A → ℝ) : + (mixture p q t ht ht1).mean f=t*p.mean f+(1-t)*q.mean f := by + unfold mean mixture; simp only [add_mul,mul_assoc,Finset.sum_add_distrib,Finset.mul_sum] + +noncomputable def map (p : FiniteLaw A) (f : A → B) : FiniteLaw B where + weight b := ∑ a,if f a=b then p.weight a else 0 + nonneg b := Finset.sum_nonneg (fun a _ => by split <;> simp only [p.nonneg,le_refl]) + total := by rw [Finset.sum_comm]; simpa using p.total + +theorem mean_map (p : FiniteLaw A) (f : A → B) (g : B → ℝ) : + (p.map f).mean g=p.mean (g ∘ f) := by + simp only [mean,map,Finset.sum_mul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl; intro a _ + simp + +theorem mean_tendsto {Q : Type*} {l : Filter Q} (p : FiniteLaw A) (f : Q → A → ℝ) + (g : A → ℝ) (h : ∀ a,Filter.Tendsto (fun q => f q a) l (nhds (g a))) : + Filter.Tendsto (fun q => p.mean (f q)) l (nhds (p.mean g)) := by + exact tendsto_finsetSum Finset.univ (fun a _ => (h a).const_mul (p.weight a)) +end FiniteLaw +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Classical +open scoped BigOperators symmDiff +section BooleanMoments +variable {K : Type*} [Fintype K] [DecidableEq K] + +theorem boolMonomial_asprod (s : Finset K) (η : K → Bool) : + boolMonomial s η=∏ k,if k∈s then boolSign (η k) else 1 := by + simp [boolMonomial,Finset.prod_ite_mem] + +omit [Fintype K] [DecidableEq K] in +theorem boolMonomial_abs (s : Finset K) (η : K → Bool) : |boolMonomial s η|=1 := by + simp [boolMonomial,Finset.abs_prod] + +theorem boolMonomial_mul (s t : Finset K) (η : K → Bool) : + boolMonomial s η*boolMonomial t η=boolMonomial (s ∆ t) η := by + simp_rw [boolMonomial_asprod] + rw [←Finset.prod_mul_distrib] + apply Finset.prod_congr rfl; intro k _ + by_cases hs : k∈s <;> by_cases ht : k∈t <;> + simp only [Finset.mem_symmDiff,hs,ht,not_true_eq_false,not_false_eq_true, + and_self,and_false,false_and,or_self,true_or,or_true,ite_true,ite_false,one_mul,mul_one] + exact (pow_two (boolSign (η k))).symm.trans (boolSign_sq (η k)) + +theorem boolSign_mean : uniformMean boolSign=0 := by + norm_num [uniformMean,Fintype.sum_bool,boolSign] + +theorem boolMonomial_mean (s : Finset K) : uniformMean (boolMonomial s)=if s=∅ then 1 else 0 := by + rw [uniformMean_congr (boolMonomial_asprod s)] + rw [uniformMean_pi_product (fun k b => if k∈s then boolSign b else 1)] + by_cases hs : s=∅ + · simp [hs,uniformMean_const] + · rw [ite_eq_right hs] + obtain ⟨k,hk⟩ := Finset.nonempty_iff_ne_empty.mpr hs + apply Finset.prod_eq_zero (Finset.mem_univ k) + simp only [hk,ite_true,boolSign_mean] + +theorem boolMonomial_orthog (s t : Finset K) : + uniformMean (fun η => boolMonomial s η*boolMonomial t η)=if s=t then 1 else 0 := by + simp_rw [boolMonomial_mul,boolMonomial_mean,Finset.symmDiff_eq_empty] + +noncomputable def tiltLaw (s : Finset K) (hs : s≠∅) (a : ℝ) (ha : |a|≤1) : FiniteLaw (K → Bool) where + weight η := (Fintype.card (K → Bool):ℝ)⁻¹*(1+a*boolMonomial s η) + nonneg η := by + apply mul_nonneg (by positivity) + have hab : |a*boolMonomial s η|≤1 := by simpa only [abs_mul,boolMonomial_abs,mul_one] using ha + have := neg_abs_le (a*boolMonomial s η); linarith + total := by + simp only [←div_eq_inv_mul] + rw [←Finset.sum_div] + change uniformMean (fun η : K → Bool => 1+a*boolMonomial s η)=1 + rw [uniformMean_add,uniformMean_const,uniformMean_mul,boolMonomial_mean,ite_eq_right hs]; ring + +theorem tiltLaw_mean (s : Finset K) (hs : s≠∅) (a : ℝ) (ha : |a|≤1) (f : (K → Bool) → ℝ) : + (tiltLaw s hs a ha).mean f=uniformMean (fun η => (1+a*boolMonomial s η)*f η) := by + unfold FiniteLaw.mean tiltLaw uniformMean + rw [Finset.sum_div] + apply Finset.sum_congr rfl; intro η _; ring + +theorem tiltLaw_monomial (s t : Finset K) (hs : s≠∅) (a : ℝ) (ha : |a|≤1) : + (tiltLaw s hs a ha).mean (boolMonomial t)=(if t=∅ then 1 else 0)+a*(if t=s then 1 else 0) := by + rw [tiltLaw_mean] + simp_rw [add_mul,one_mul,mul_assoc] + rw [uniformMean_add,uniformMean_mul,boolMonomial_mean,boolMonomial_orthog] + simp only [eq_comm (a := s) (b := t)] + +abbrev Activation (K : Type*) := Finset K × (K → Bool) +noncomputable def activationPhi (α : Finset K) (z : Activation K) : ℝ := + if α⊆z.1 then boolMonomial α z.2 else 0 + +omit [Fintype K] in +@[simp] theorem activationPhi_empty (z : Activation K) : activationPhi ∅ z=1 := by + simp [activationPhi] + +theorem activationPhi_mul (α β : Finset K) (z : Activation K) : + activationPhi α z*activationPhi β z= + if α∪β⊆z.1 then boolMonomial (α ∆ β) z.2 else 0 := by + unfold activationPhi + simp only [Finset.union_subset_iff] + by_cases hα : α⊆z.1 <;> by_cases hβ : β⊆z.1 <;> simp [hα,hβ,boolMonomial_mul] + +theorem activationPhi_disjoint (α β : Finset K) (h : Disjoint α β) (z : Activation K) : + activationPhi α z*activationPhi β z=activationPhi (α∪β) z := by + rw [activationPhi_mul,Finset.symmDiff_eq_union h] + rfl + +noncomputable def branchLaw (S Γ : Finset K) (hΓ : Γ≠∅) (a : ℝ) (ha : |a|≤1) : FiniteLaw (Activation K) := + (FiniteLaw.dirac S).prod (tiltLaw Γ hΓ a ha) + +theorem branchLaw_phi (S Γ α : Finset K) (hΓ : Γ≠∅) (a : ℝ) (ha : |a|≤1) : + (branchLaw S Γ hΓ a ha).mean (activationPhi α)= + if α⊆S then (if α=∅ then 1 else 0)+a*(if α=Γ then 1 else 0) else 0 := by + unfold branchLaw + rw [FiniteLaw.mean_prod,FiniteLaw.mean_dirac] + by_cases hα : α⊆S + · simp only [activationPhi,hα,ite_true]; exact tiltLaw_monomial Γ α hΓ a ha + · simp only [activationPhi,hα,ite_false,FiniteLaw.mean_const] + +theorem branchLaw_second (S Γ α β : Finset K) (hΓ : Γ≠∅) (a : ℝ) (ha : |a|≤1) : + (branchLaw S Γ hΓ a ha).mean (fun z => activationPhi α z*activationPhi β z)= + if α∪β⊆S then (if α=β then 1 else 0)+a*(if α ∆ β=Γ then 1 else 0) else 0 := by + unfold branchLaw + rw [FiniteLaw.mean_prod,FiniteLaw.mean_dirac] + simp_rw [activationPhi_mul] + by_cases h : α∪β⊆S + · simp only [h,ite_true] + rw [tiltLaw_monomial] + simp only [Finset.symmDiff_eq_empty] + · simp only [h,ite_false,FiniteLaw.mean_const] + +noncomputable def baseActivation (M Γ : Finset K) (hΓ : Γ≠∅) (a : ℝ) (ha : |a|≤1) : FiniteLaw (Activation K) := + FiniteLaw.mixture (branchLaw M Γ hΓ a ha) (branchLaw Γ Γ hΓ (-a) (by simpa using ha)) + (1/2) (by norm_num) (by norm_num) + +theorem baseActivation_zero (M Γ α : Finset K) (hΓ : Γ≠∅) (hΓM : Γ⊆M) + (a : ℝ) (ha : |a|≤1) (hα : α≠∅) : (baseActivation M Γ hΓ a ha).mean (activationPhi α)=0 := by + unfold baseActivation + rw [FiniteLaw.mean_mixture,branchLaw_phi,branchLaw_phi] + by_cases h : α=Γ + · subst α; simp [hΓ,hΓM]; ring + · simp [h,hα] + +noncomputable def activationMoment (p : FiniteLaw (Activation K)) (α β : Finset K) : ℝ := + p.mean (fun z => activationPhi α z*activationPhi β z) + +@[simp] theorem activationMoment_empty (p : FiniteLaw (Activation K)) : activationMoment p ∅ ∅=1 := by + simp [activationMoment] + +theorem activationMoment_disjoint (p : FiniteLaw (Activation K)) + (hp : ∀ α,α≠∅ → p.mean (activationPhi α)=0) (α β : Finset K) + (hd : Disjoint α β) (hn : α∪β≠∅) : activationMoment p α β=0 := by + unfold activationMoment + simp_rw [activationPhi_disjoint α β hd] + exact hp _ hn + +theorem baseActivation_moment (M Γ α β : Finset K) (hΓ : Γ≠∅) + (a : ℝ) (ha : |a|≤1) : activationMoment (baseActivation M Γ hΓ a ha) α β= + (1/2)*(if α∪β⊆M then (if α=β then 1 else 0)+a*(if α ∆ β=Γ then 1 else 0) else 0)+ + (1/2)*(if α∪β⊆Γ then (if α=β then 1 else 0)-a*(if α ∆ β=Γ then 1 else 0) else 0) := by + unfold activationMoment baseActivation + rw [FiniteLaw.mean_mixture,branchLaw_second,branchLaw_second] + norm_num only [show (1:ℝ)-1/2=1/2 by norm_num,neg_mul,←sub_eq_add_neg] +end BooleanMoments +end SidorenkoCounterexample + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/Grassmann.lean b/lean/OAI/Combinatorics/Sidorenko/Grassmann.lean new file mode 100644 index 0000000000000000000000000000000000000000..e61b7e74e07490174c5c411b6a843085157e9258 --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/Grassmann.lean @@ -0,0 +1,309 @@ +import OAI.Combinatorics.Sidorenko.Basic + +namespace OAI + +namespace SidorenkoCounterexample +open scoped BigOperators +open Module +section SubspaceCount +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [Fintype K] [Finite V] + +abbrev DimSubspace (K V : Type*) [Field K] [AddCommGroup V] [Module K V] (k : ℕ) := + {U : Submodule K V // finrank K U = k} + +abbrev IndependentTuple (K V : Type*) [Field K] [AddCommGroup V] [Module K V] (k : ℕ) := + {s : Fin k → V // LinearIndependent K s} + +omit [Fintype K] in + theorem tuple_spans (k : ℕ) (U : DimSubspace K V k) + (s : IndependentTuple K U.val k) : + Submodule.span K (Set.range (fun i => (s.val i : V))) = U.val := by + have hs : Submodule.span K (Set.range s.val) = ⊤ := by + apply Submodule.eq_top_of_finrank_eq + rw [finrank_span_eq_card s.property, Fintype.card_fin, U.property] + have h := congrArg (Submodule.map U.val.subtype) hs + simpa only [Submodule.map_span, Submodule.map_top, Submodule.range_subtype, + ← Set.range_comp, Function.comp_def, Submodule.subtype_apply] using h + +noncomputable def tupleForget {k : ℕ} + (s : Σ U : DimSubspace K V k, IndependentTuple K U.val k) : + IndependentTuple K V k := + ⟨fun i => (s.2.val i : V), s.2.property.map' s.1.val.subtype + (Submodule.ker_subtype _)⟩ + +omit [Fintype K] in + theorem tupleForget_bijective (k : ℕ) : + Function.Bijective (tupleForget (K := K) (V := V) (k := k)) := by + constructor + · rintro ⟨U,s⟩ ⟨W,t⟩ heq + have hval : (fun i => (s.val i : V)) = (fun i => (t.val i : V)) := + congrArg Subtype.val heq + have hUW : U = W := by + apply Subtype.ext + rw [← tuple_spans k U s, ← tuple_spans k W t, hval] + subst W + congr 1 + apply Subtype.ext + funext i + exact Subtype.ext (congrFun hval i) + · intro s + let U : DimSubspace K V k := ⟨Submodule.span K (Set.range s.val), by + rw [finrank_span_eq_card s.property, Fintype.card_fin]⟩ + let t : Fin k → U.val := fun i => ⟨s.val i, Submodule.subset_span ⟨i,rfl⟩⟩ + have ht : LinearIndependent K t := LinearIndependent.of_comp U.val.subtype s.property + refine ⟨⟨U,⟨t,ht⟩⟩, ?_⟩ + rfl + +/-- Counting independent tuples by their span gives the exact Grassmann +counting identity, with no division and including k=0. -/ + theorem subspace_count_identity (k : ℕ) (hk : k ≤ finrank K V) : + Nat.card (DimSubspace K V k) * + (∏ i : Fin k, (Fintype.card K ^ k - Fintype.card K ^ i.val)) = + ∏ i : Fin k, (Fintype.card K ^ finrank K V - Fintype.card K ^ i.val) := by + classical + let : Fintype (DimSubspace K V k) := Fintype.ofFinite _ + have h := Nat.card_congr (Equiv.ofBijective _ (tupleForget_bijective (K := K) (V := V) k)) + rw [Nat.card_sigma] at h + have hcard (U : DimSubspace K V k) : Nat.card (IndependentTuple K U.val k) = + ∏ i : Fin k, (Fintype.card K ^ k - Fintype.card K ^ i.val) := by + rw [IndependentTuple, card_linearIndependent (by rw [U.property]), U.property] + simp only [hcard, Finset.sum_const, nsmul_eq_mul, Finset.card_univ, Nat.cast_id] at h + rw [Nat.card_eq_fintype_card, h] + exact card_linearIndependent hk + + theorem independent_tuple_count_pos (k : ℕ) : + 0 < ∏ i : Fin k, (Fintype.card K ^ k - Fintype.card K ^ i.val) := by + apply Finset.prod_pos + intro i _ + apply Nat.sub_pos_of_lt + exact Nat.pow_lt_pow_right Fintype.one_lt_card i.isLt + +/-- The exact Gaussian binomial formula stated in the manuscript. -/ + theorem subspace_count_real (k : ℕ) (hk : k ≤ finrank K V) : + (Nat.card (DimSubspace K V k) : ℝ) = + ∏ i : Fin k, ((Fintype.card K : ℝ) ^ finrank K V - (Fintype.card K : ℝ)^i.val) / + ((Fintype.card K : ℝ)^k - (Fintype.card K : ℝ)^i.val) := by + have h := subspace_count_identity (K := K) (V := V) k hk + have hp := independent_tuple_count_pos (K := K) k + have hle (i : Fin k) : Fintype.card K ^ i.val ≤ Fintype.card K ^ k := + Nat.pow_le_pow_right (by exact Fintype.card_pos) i.isLt.le + have hle' (i : Fin k) : Fintype.card K ^ i.val ≤ Fintype.card K ^ finrank K V := + Nat.pow_le_pow_right (by exact Fintype.card_pos) (i.isLt.le.trans hk) + have hr : (Nat.card (DimSubspace K V k) : ℝ) * + (∏ i : Fin k, ((Fintype.card K : ℝ)^k - (Fintype.card K : ℝ)^i.val)) = + ∏ i : Fin k, ((Fintype.card K : ℝ)^finrank K V - (Fintype.card K : ℝ)^i.val) := by + have hc := congrArg (fun n : ℕ => (n : ℝ)) h + simpa only [Nat.cast_mul, Nat.cast_prod, Nat.cast_sub (hle _), + Nat.cast_sub (hle' _), Nat.cast_pow] using hc + have hpr : (0 : ℝ) < ∏ i : Fin k, ((Fintype.card K : ℝ)^k - + (Fintype.card K : ℝ)^i.val) := by + have hpc : (0 : ℝ) < ((∏ i : Fin k, (Fintype.card K ^ k - + Fintype.card K ^ i.val)) : ℕ) := by exact_mod_cast hp + simpa only [Nat.cast_prod, Nat.cast_sub (hle _), Nat.cast_pow] using hpc + rw [Finset.prod_div_distrib] + exact (eq_div_iff hpr.ne').mpr hr + +/-- A dimension-uniform explicit Grassmann bound, sufficient for all nullity +union bounds; the constant 2^k is independent of the finite field. -/ + theorem subspace_count_upper (k : ℕ) (hk : k ≤ finrank K V) : + (Nat.card (DimSubspace K V k) : ℝ) ≤ + 2^k * (Fintype.card K : ℝ)^(k * (finrank K V - k)) := by + rw [subspace_count_real k hk] + let q : ℝ := Fintype.card K + have hq : 2 ≤ q := by + have hcard : 2 ≤ Fintype.card K := Fintype.one_lt_card + change (2 : ℝ) ≤ (Fintype.card K : ℝ) + exact_mod_cast hcard + have hq0 : 0 < q := by linarith + have hpow (i : Fin k) : 2 * q^i.val ≤ q^k := by + calc + 2 * q^i.val ≤ q * q^i.val := mul_le_mul_of_nonneg_right hq (pow_nonneg hq0.le _) + _ = q^(i.val+1) := by rw [pow_succ]; ring + _ ≤ q^k := pow_le_pow_right₀ (by linarith) i.isLt + have hfac (i : Fin k) : (q^finrank K V - q^i.val)/(q^k-q^i.val) ≤ + 2 * q^(finrank K V - k) := by + have hid : q^finrank K V = q^(finrank K V - k) * q^k := by + rw [← pow_add, Nat.sub_add_cancel hk] + have hp : 0 < q^i.val := pow_pos hq0 _ + have hd : 0 < q^k-q^i.val := by linarith [hpow i] + apply (div_le_iff₀ hd).mpr + have hm := mul_le_mul_of_nonneg_left (hpow i) (pow_nonneg hq0.le (finrank K V-k)) + rw [hid] + nlinarith + calc + (∏ i : Fin k, (q^finrank K V - q^i.val)/(q^k-q^i.val)) ≤ + ∏ _i : Fin k, 2 * q^(finrank K V-k) := by + apply Finset.prod_le_prod₀ + · intro i _ + apply div_nonneg + · exact sub_nonneg.mpr (pow_le_pow_right₀ (by linarith) (i.isLt.le.trans hk)) + · linarith [hpow i, pow_nonneg hq0.le i.val] + · intro i _ + exact hfac i + _ = 2^k * q^(k * (finrank K V-k)) := by + rw [Finset.prod_const, Finset.card_univ, Fintype.card_fin, mul_pow, ← pow_mul, + Nat.mul_comm (finrank K V-k) k] + +end SubspaceCount +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section FormCount +variable (K : Type*) [Field K] + +def symmetricSubmodule (D : ℕ) : Submodule K (Matrix (Fin D) (Fin D) K) where + carrier := {M | M.IsSymm} + zero_mem' := Matrix.isSymm_zero + add_mem' := fun hM hN => hM.add hN + smul_mem' := fun a _ hM => hM.smul a + +abbrev SymMatrix (D : ℕ) := symmetricSubmodule K D + +/-- A symmetric matrix is exactly a function on unordered pairs with repetition. -/ +def symMatrixCoordinates (D : ℕ) : SymMatrix K D ≃ (Sym2 (Fin D) → K) := + (Equiv.subtypeEquiv (Equiv.refl (Matrix (Fin D) (Fin D) K)) (fun M => by + change M.IsSymm ↔ ∀ i j, M i j = M j i + constructor + · intro h i j + exact (h.apply i j).symm + · intro h + ext i j + exact h j i)).trans Sym2.lift + + theorem symMatrix_card [Fintype K] (D : ℕ) : + Nat.card (SymMatrix K D) = Fintype.card K ^ ((D+1).choose 2) := by + rw [Nat.card_congr (symMatrixCoordinates K D), Nat.card_fun, + Nat.card_eq_fintype_card, Nat.card_eq_fintype_card, Sym2.card, Fintype.card_fin] + +variable (V : Type*) [AddCommGroup V] [Module K V] + +abbrev SymForm := {B : LinearMap.BilinForm K V // B.IsSymm} + +noncomputable def symFormMatrix [FiniteDimensional K V] : + SymForm K V ≃ SymMatrix K (finrank K V) := + Equiv.subtypeEquiv (LinearMap.BilinForm.toMatrix (Module.finBasis K V)).toEquiv + (fun B => (B.isSymm_toMatrix_iff_isSymm (Module.finBasis K V)).symm) + +instance symForm_finite [Finite K] [FiniteDimensional K V] : Finite (SymForm K V) := + Finite.of_equiv (SymMatrix K (finrank K V)) (symFormMatrix K V).symm + + theorem symForm_card [Fintype K] [FiniteDimensional K V] : + Nat.card (SymForm K V) = Fintype.card K ^ ((finrank K V + 1).choose 2) := by + rw [Nat.card_congr (symFormMatrix K V), symMatrix_card] + +variable {K V} + +/-- Symmetric forms whose radical contains a prescribed subspace descend +bijectively to the quotient. This keeps the actual radical condition. -/ +def formRadicalEquiv (U : Submodule K V) : + {B : SymForm K V // U ≤ B.val.ker} ≃ SymForm K (V ⧸ U) where + toFun B := ⟨LinearMap.IsRefl.liftQ₂ B.val.val U B.val.property.isRefl B.property, by + constructor + intro x y + induction x using Submodule.Quotient.induction_on with + | H x => + induction y using Submodule.Quotient.induction_on with + | H y => exact B.val.property.eq x y⟩ + invFun C := ⟨⟨C.val.compl₁₂ U.mkQ U.mkQ, by + constructor + intro x y + exact C.property.eq _ _⟩, by + intro x hx + apply LinearMap.mem_ker.mpr + ext y + change C.val (U.mkQ x) (U.mkQ y) = 0 + simp [(Submodule.Quotient.mk_eq_zero U).mpr hx]⟩ + left_inv B := by + apply Subtype.ext + apply Subtype.ext + ext x y + rfl + right_inv C := by + apply Subtype.ext + ext x y + rfl + + + + theorem radical_containment_card [Fintype K] [FiniteDimensional K V] + (U : Submodule K V) : + Nat.card {B : SymForm K V // U ≤ B.val.ker} = + Fintype.card K ^ ((finrank K V - finrank K U + 1).choose 2) := by + rw [Nat.card_congr (formRadicalEquiv U), symForm_card] + congr 2 + have h := U.finrank_quotient_add_finrank + omega + +/-- Union bound over genuine subspaces of the radical, not a rank heuristic. -/ + theorem nullity_count_bound [Fintype K] [Finite V] (u : ℕ) : + Nat.card {B : SymForm K V // u ≤ finrank K B.val.ker} ≤ + Nat.card (DimSubspace K V u) * + Fintype.card K ^ ((finrank K V - u + 1).choose 2) := by + classical + let : Fintype (DimSubspace K V u) := Fintype.ofFinite _ + let f : (Σ U : DimSubspace K V u, {B : SymForm K V // U.val ≤ B.val.ker}) → + {B : SymForm K V // u ≤ finrank K B.val.ker} := fun x => + ⟨x.2.val, by simpa only [x.1.property] using Submodule.finrank_mono x.2.property⟩ + have hf : Function.Surjective f := by + intro B + obtain ⟨v, hv⟩ := exists_linearIndependent_of_le_finrank B.property + let w : Fin u → V := fun i => (v i : V) + have hw : LinearIndependent K w := hv.map' B.val.val.ker.subtype + (Submodule.ker_subtype _) + let U : DimSubspace K V u := ⟨Submodule.span K (Set.range w), by + rw [finrank_span_eq_card hw, Fintype.card_fin]⟩ + have hU : U.val ≤ B.val.val.ker := by + apply Submodule.span_le.mpr + rintro _ ⟨i,rfl⟩ + exact (v i).property + exact ⟨⟨U,⟨B.val,hU⟩⟩, rfl⟩ + calc + Nat.card {B : SymForm K V // u ≤ finrank K B.val.ker} ≤ + Nat.card (Σ U : DimSubspace K V u, {B : SymForm K V // U.val ≤ B.val.ker}) := + Nat.card_le_card_of_surjective f hf + _ = _ := by + rw [Nat.card_sigma] + have hdim (U : DimSubspace K V u) : finrank K U.val = u := U.property + simp only [radical_containment_card, hdim, Finset.sum_const, + nsmul_eq_mul, Finset.card_univ, Nat.card_eq_fintype_card, Nat.cast_id] + + theorem symmetric_nullity_exponent (n u : ℕ) (hu : u ≤ n) : + u*(n-u) + (n-u+1).choose 2 + (u+1).choose 2 = (n+1).choose 2 := by + have h : ((u*(n-u) + (n-u+1).choose 2 + (u+1).choose 2 : ℕ) : ℚ) = + ((n+1).choose 2 : ℚ) := by + simp only [Nat.cast_add, Nat.cast_mul, Nat.cast_choose_two, Nat.cast_one, + Nat.cast_sub hu] + ring + exact_mod_cast h + +/-- An explicit finite-field nullity tail bound. In the manuscript this is +O(q^(-b(u))); here the constant is the concrete field-independent 2^u. -/ + theorem symmetric_nullity_probability_bound [Fintype K] [Finite V] + (u : ℕ) (hu : u ≤ finrank K V) : + (Nat.card {B : SymForm K V // u ≤ finrank K B.val.ker} : ℝ) / + Nat.card (SymForm K V) ≤ 2^u / (Fintype.card K : ℝ)^((u+1).choose 2) := by + have hcount : (Nat.card {B : SymForm K V // u ≤ finrank K B.val.ker} : ℝ) ≤ + (Nat.card (DimSubspace K V u) : ℝ) * + (Fintype.card K : ℝ)^((finrank K V-u+1).choose 2) := by + exact_mod_cast nullity_count_bound (K := K) (V := V) u + have hspace := subspace_count_upper (K := K) (V := V) u hu + have hq : (0 : ℝ) < Fintype.card K := by exact_mod_cast Fintype.card_pos (α := K) + rw [symForm_card, Nat.cast_pow] + apply (div_le_iff₀ (pow_pos hq _)).mpr + calc + (Nat.card {B : SymForm K V // u ≤ finrank K B.val.ker} : ℝ) ≤ + 2^u * (Fintype.card K : ℝ)^(u*(finrank K V-u)) * + (Fintype.card K : ℝ)^((finrank K V-u+1).choose 2) := + hcount.trans (mul_le_mul_of_nonneg_right hspace (pow_nonneg hq.le _)) + _ = 2^u / (Fintype.card K : ℝ)^((u+1).choose 2) * + (Fintype.card K : ℝ)^((finrank K V+1).choose 2) := by + rw [← symmetric_nullity_exponent (finrank K V) u hu] + rw [pow_add, pow_add] + field_simp + +end FormCount +end SidorenkoCounterexample + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/Lagrangian.lean b/lean/OAI/Combinatorics/Sidorenko/Lagrangian.lean new file mode 100644 index 0000000000000000000000000000000000000000..20a5b9aca4f0c963e0208c7bdfd6a5a20921e476 --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/Lagrangian.lean @@ -0,0 +1,743 @@ +import OAI.Combinatorics.Sidorenko.Grassmann + +namespace OAI + +namespace SidorenkoCounterexample +open Module +section LagrangianCharts +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + + +def canonicalSymplectic : LinearMap.BilinForm K (V × Module.Dual K V) where + toFun p := { + toFun := fun q => q.2 p.1 - p.2 q.1 + map_add' := by intros; simp; ring + map_smul' := by intros; simp; ring } + map_add' := by + intro p q + apply LinearMap.ext + intro z + change z.2 (p.1+q.1) - (p.2+q.2) z.1 = + (z.2 p.1 - p.2 z.1) + (z.2 q.1 - q.2 z.1) + simp + ring + map_smul' := by + intro a p + apply LinearMap.ext + intro z + change z.2 (a • p.1) - (a • p.2) z.1 = a * (z.2 p.1-p.2 z.1) + simp + ring + +@[simp] theorem canonicalSymplectic_apply (p q : V × Module.Dual K V) : + canonicalSymplectic p q = q.2 p.1 - p.2 q.1 := rfl + + theorem canonicalSymplectic_alt : (canonicalSymplectic (K := K) (V := V)).IsAlt := by + intro p + simp + + theorem canonicalSymplectic_nondegenerate : + (canonicalSymplectic (K := K) (V := V)).Nondegenerate := by + have hleft : ∀ p : V × Module.Dual K V, + (∀ q, canonicalSymplectic p q = 0) → p = 0 := by + rintro ⟨x,f⟩ hp + have hx : x = 0 := (Module.forall_dual_apply_eq_zero_iff K x).mp (fun g => by + simpa using hp (0,g)) + have hf : f = 0 := by + ext y + simpa using hp (y,0) + simp [hx,hf] + refine ⟨hleft, ?_⟩ + intros p hp + apply hleft + intro q + exact canonicalSymplectic_alt.isRefl _ _ (hp q) + +variable [FiniteDimensional K V] + +/-- Lagrangians are self-orthogonal subspaces, equivalently isotropic +subspaces of half the ambient dimension. -/ +abbrev Lagrangian := {L : Submodule K (V × Module.Dual K V) // + canonicalSymplectic.orthogonal L = L} + + theorem lagrangian_finrank (L : Lagrangian (K := K) (V := V)) : + finrank K L.val = finrank K V := by + have h := LinearMap.BilinForm.finrank_orthogonal canonicalSymplectic_nondegenerate L.val + rw [L.property, Module.finrank_prod, Subspace.dual_finrank_eq] at h + have hle := Submodule.finrank_le L.val + rw [Module.finrank_prod, Subspace.dual_finrank_eq] at hle + omega + +/-- The graph over a subspace, with its free vertical annihilator retained. -/ +def formGraph (U : Submodule K V) (B : LinearMap.BilinForm K U) : + Submodule K (V × Module.Dual K V) where + carrier := {p | ∃ u : U, u.val = p.1 ∧ p.2.comp U.subtype = B u} + zero_mem' := ⟨0, rfl, by simp⟩ + add_mem' := by + rintro p q ⟨u,hu,hf⟩ ⟨v,hv,hg⟩ + refine ⟨u+v, by simp [hu,hv], ?_⟩ + change (p.2+q.2).comp U.subtype = B (u+v) + ext w + simp only [LinearMap.add_comp, LinearMap.add_apply, map_add] + exact congrArg (fun l : Module.Dual K U => l w) (congrArg₂ (·+·) hf hg) + smul_mem' := by + rintro a p ⟨u,hu,hf⟩ + refine ⟨a • u, by simp [hu], ?_⟩ + change (a • p.2).comp U.subtype = B (a • u) + rw [map_smul, LinearMap.smul_comp, hf] + +omit [FiniteDimensional K V] in + theorem formGraph_fst_range (U : Submodule K V) (B : LinearMap.BilinForm K U) : + (formGraph U B).map (LinearMap.fst K V (Module.Dual K V)) = U := by + ext x + constructor + · rintro ⟨p,⟨u,hu,_⟩,hp⟩ + have hp' : p.1 = x := hp + rw [← hp', ← hu] + exact u.property + · intro hx + obtain ⟨f,hf⟩ := (Subspace.dualRestrict_surjective (W := U)) (B ⟨x,hx⟩) + exact ⟨(x,f),⟨⟨x,hx⟩,rfl,hf⟩,rfl⟩ + +omit [FiniteDimensional K V] in + theorem formGraph_isotropic (U : Submodule K V) (B : SymForm K U) : + formGraph U B.val ≤ canonicalSymplectic.orthogonal (formGraph U B.val) := by + rintro p ⟨u,hu,hf⟩ q ⟨v,hv,hg⟩ + change p.2 q.1 - q.2 p.1 = 0 + rw [← hu, ← hv] + have hf' := congrArg (fun l : Module.Dual K U => l v) hf + have hg' := congrArg (fun l : Module.Dual K U => l u) hg + exact sub_eq_zero.mpr (hf'.trans ((B.property.eq u v).trans hg'.symm)) + +def formGraphProjection (U : Submodule K V) (B : LinearMap.BilinForm K U) : + formGraph U B →ₗ[K] U where + toFun p := ⟨p.val.1, by obtain ⟨u,hu,_⟩ := p.property; exact hu ▸ u.property⟩ + map_add' _ _ := rfl + map_smul' _ _ := rfl + +omit [FiniteDimensional K V] in + theorem formGraphProjection_surj (U : Submodule K V) (B : LinearMap.BilinForm K U) : + Function.Surjective (formGraphProjection U B) := by + intro u + obtain ⟨f,hf⟩ := Subspace.dualRestrict_surjective (W := U) (B u) + exact ⟨⟨(u.val,f),u,rfl,hf⟩,rfl⟩ + +noncomputable def graphVerticalEquiv (U : Submodule K V) (B : LinearMap.BilinForm K U) : + U.dualAnnihilator ≃ₗ[K] (formGraphProjection U B).ker where + toFun f := ⟨⟨(0,f.val),0,rfl, by + ext u + simpa using ((Submodule.mem_dualAnnihilator (W := U) f.val).mp f.property) u u.property⟩, rfl⟩ + invFun p := ⟨p.val.val.2, by + obtain ⟨u,hu,hf⟩ := p.val.property + have hx : p.val.val.1 = 0 := congrArg Subtype.val p.property + have hu0 : u = 0 := Subtype.ext (hu.trans hx) + apply (Submodule.mem_dualAnnihilator (W := U) p.val.val.2).mpr + intro x hxU + have hf' := congrArg (fun l : Module.Dual K U => l ⟨x,hxU⟩) hf + simpa [hu0] using hf'⟩ + left_inv _ := rfl + right_inv p := by + apply Subtype.ext + apply Subtype.ext + apply Prod.ext + · exact (congrArg Subtype.val p.property).symm + · rfl + map_add' f g := by + apply Subtype.ext + apply Subtype.ext + simp + map_smul' a f := by + apply Subtype.ext + apply Subtype.ext + simp + + theorem surjective_finrank_eq {E F : Type*} [AddCommGroup E] [Module K E] + [AddCommGroup F] [Module K F] [FiniteDimensional K E] + (p : E →ₗ[K] F) (hp : Function.Surjective p) : + finrank K E = finrank K F + finrank K p.ker := by + have h := LinearMap.finrank_range_add_finrank_ker p + rw [LinearMap.range_eq_top.mpr hp, finrank_top] at h + exact h.symm + + theorem formGraph_finrank (U : Submodule K V) (B : LinearMap.BilinForm K U) : + finrank K (formGraph U B) = finrank K V := by + have h := surjective_finrank_eq (K := K) (E := formGraph U B) (F := U) + (formGraphProjection U B) (formGraphProjection_surj U B) + rw [← (graphVerticalEquiv U B).finrank_eq] at h + exact h.trans (Subspace.finrank_add_finrank_dualAnnihilator_eq U) + +noncomputable def graphLagrangian (U : Submodule K V) (B : SymForm K U) : + Lagrangian (K := K) (V := V) := + ⟨formGraph U B.val, by + apply (Submodule.eq_of_le_of_finrank_eq (formGraph_isotropic U B) _).symm + rw [formGraph_finrank, LinearMap.BilinForm.finrank_orthogonal canonicalSymplectic_nondegenerate, + Module.finrank_prod, Subspace.dual_finrank_eq, formGraph_finrank, Nat.add_sub_cancel_left]⟩ + + theorem graphLagrangian_form_injective (U : Submodule K V) : + Function.Injective (graphLagrangian (K := K) U) := by + intro B C h + apply Subtype.ext + apply LinearMap.ext + intro u + obtain ⟨f,hf⟩ := Subspace.dualRestrict_surjective (W := U) (B.val u) + have hp : (u.val,f) ∈ formGraph U B.val := ⟨u,rfl,hf⟩ + have he : formGraph U B.val = formGraph U C.val := congrArg Subtype.val h + rw [he] at hp + obtain ⟨v,hv,hg⟩ := hp + have hv' : v = u := Subtype.ext hv + exact hf.symm.trans (hv' ▸ hg) + +omit [FiniteDimensional K V] in + theorem lagrangian_pairing_zero (L : Lagrangian (K := K) (V := V)) + {p q : V × Module.Dual K V} (hp : p ∈ L.val) (hq : q ∈ L.val) : + canonicalSymplectic p q = 0 := by + have hq' : q ∈ canonicalSymplectic.orthogonal L.val := L.property.symm ▸ hq + exact hq' p hp + +/-- Every Lagrangian is the graph of a unique symmetric form over its +first-coordinate projection. This includes nontransverse charts. -/ + theorem graphLagrangian_surjective : + Function.Surjective (fun S : Σ U : Submodule K V, SymForm K U => graphLagrangian S.1 S.2) := by + intro L + let U := L.val.map (LinearMap.fst K V (Module.Dual K V)) + let p : L.val →ₗ[K] U := { + toFun := fun x => ⟨x.val.1, ⟨x.val,x.property,rfl⟩⟩ + map_add' := fun _ _ => rfl + map_smul' := fun _ _ => rfl } + have hp : Function.Surjective p := by + rintro ⟨x,y,hy,hyx⟩ + exact ⟨⟨y,hy⟩,Subtype.ext hyx⟩ + obtain ⟨s,hs⟩ := p.exists_rightInverse_of_surjective (LinearMap.range_eq_top.mpr hp) + have hsfst (u : U) : (s u).val.1 = u.val := congrArg Subtype.val (LinearMap.congr_fun hs u) + let C : LinearMap.BilinForm K U := + (((LinearMap.snd K V (Module.Dual K V)).comp L.val.subtype).comp s).compl₂ U.subtype + have hC : C.IsSymm := by + constructor + intro u v + change (s u).val.2 v.val = (s v).val.2 u.val + have h := lagrangian_pairing_zero L (s u).property (s v).property + change (s v).val.2 (s u).val.1 - (s u).val.2 (s v).val.1 = 0 at h + rw [hsfst, hsfst] at h + exact (sub_eq_zero.mp h).symm + refine ⟨⟨U,⟨C,hC⟩⟩, ?_⟩ + apply Subtype.ext + symm + apply Submodule.eq_of_le_of_finrank_eq + · intro x hx + let u : U := ⟨x.1,⟨x,hx,rfl⟩⟩ + refine ⟨u,rfl,?_⟩ + apply LinearMap.ext + intro y + have h := lagrangian_pairing_zero L hx (s y).property + change (s y).val.2 x.1 - x.2 (s y).val.1 = 0 at h + rw [hsfst] at h + change x.2 y.val = (s u).val.2 y.val + exact (sub_eq_zero.mp h).symm.trans (hC.eq y u) + · exact (lagrangian_finrank L).trans (formGraph_finrank U C).symm + +noncomputable def lagrangianGraphEquiv : + (Σ U : Submodule K V, SymForm K U) ≃ Lagrangian (K := K) (V := V) := + Equiv.ofBijective (fun S => graphLagrangian S.1 S.2) ⟨by + rintro ⟨U,B⟩ ⟨W,C⟩ he + have h : U = W := by + rw [← formGraph_fst_range U B.val, ← formGraph_fst_range W C.val] + exact congrArg (fun L : Lagrangian (K := K) (V := V) => + L.val.map (LinearMap.fst K V (Module.Dual K V))) he + cases h + congr 1 + exact graphLagrangian_form_injective U he, + graphLagrangian_surjective⟩ + +/-- Exact chart decomposition count: the vertical-annihilator stratum is +retained rather than discarded as a negligible exceptional event. -/ + theorem lagrangian_card_sum [Fintype K] [Finite V] : + letI := Fintype.ofFinite (Submodule K V) + Nat.card (Lagrangian (K := K) (V := V)) = + ∑ U : Submodule K V, (Fintype.card K)^((finrank K U+1).choose 2) := by + classical + let := Fintype.ofFinite (Submodule K V) + rw [← Nat.card_congr (lagrangianGraphEquiv (K := K) (V := V)), Nat.card_sigma] + simp only [symForm_card] + +end LagrangianCharts +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section NormalCoordinates +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] [FiniteDimensional K E] +variable (ω : LinearMap.BilinForm K E) (L : Submodule K E) + +def symplecticProjection : E →ₗ[K] Module.Dual K L := ω.flip.compl₂ L.subtype + +omit [FiniteDimensional K E] in +@[simp] theorem symplecticProjection_apply (x : E) (l : L) : + symplecticProjection ω L x l = ω l.val x := rfl + + theorem symplecticProjection_surjective (hω : ω.Nondegenerate) : + Function.Surjective (symplecticProjection ω L) := by + intro f + obtain ⟨g,hg⟩ := Subspace.dualRestrict_surjective (W := L) f + let e := ω.flip.toDual (LinearMap.BilinForm.nondegenerate_flip_iff.mpr hω) + refine ⟨e.symm g, ?_⟩ + apply LinearMap.ext + intro l + change ω.flip (e.symm g) l.val = f l + have he : ω.flip (e.symm g) l.val = g l.val := by + exact congrArg (fun f : Module.Dual K E => f l.val) (e.apply_symm_apply g) + exact he.trans (LinearMap.congr_fun hg l) + +omit [FiniteDimensional K E] in + theorem symplecticProjection_ker (hL : ω.orthogonal L = L) : + (symplecticProjection ω L).ker = L := by + ext x + rw [LinearMap.mem_ker] + constructor + · intro h + rw [← hL] + intro l hl + exact LinearMap.congr_fun h ⟨l,hl⟩ + · intro hx + apply LinearMap.ext + intro l + have hx' : x ∈ ω.orthogonal L := hL.symm ▸ hx + exact hx' l.val l.property + +/-- A section of the projection can be corrected by half its alternating +Gram form, retaining its projection and making its image isotropic. -/ + theorem exists_isotropic_section (h2 : (2 : K) ≠ 0) (ha : ω.IsAlt) + (hω : ω.Nondegenerate) (hL : ω.orthogonal L = L) : + ∃ s : Module.Dual K L →ₗ[K] E, + (symplecticProjection ω L).comp s = LinearMap.id ∧ + ∀ f g, ω (s f) (s g) = 0 := by + obtain ⟨s,hs⟩ := (symplecticProjection ω L).exists_rightInverse_of_surjective + (LinearMap.range_eq_top.mpr (symplecticProjection_surjective ω L hω)) + let A : LinearMap.BilinForm K (Module.Dual K L) := ω.compl₁₂ s s + let t : Module.Dual K L →ₗ[K] L := + (-(2 : K)⁻¹) • ((Module.evalEquiv K L).symm.toLinearMap.comp A) + have ht (f g : Module.Dual K L) : g (t f) = -(2 : K)⁻¹ * ω (s f) (s g) := by + simp [t,A] + have hproj (f : Module.Dual K L) (l : L) : ω l.val (s f) = f l := by + exact LinearMap.congr_fun (LinearMap.congr_fun hs f) l + have hLL (l m : L) : ω l.val m.val = 0 := by + have hm : m.val ∈ ω.orthogonal L := hL.symm ▸ m.property + exact hm l.val l.property + refine ⟨s + L.subtype.comp t, ?_, ?_⟩ + · apply LinearMap.ext + intro f + apply LinearMap.ext + intro l + change ω l.val (s f + (t f).val) = f l + rw [map_add, hproj, hLL, add_zero] + · intro f g + change ω (s f + (t f).val) (s g + (t g).val) = 0 + simp only [map_add, LinearMap.add_apply] + rw [hproj, hLL, ← ha.neg_eq (t g).val (s f), hproj, ht, ht, + ← ha.neg_eq (s f) (s g)] + field_simp + ring + +/-- Relative Darboux coordinates for any fixed Lagrangian. No transitivity +or symplectic basis theorem is assumed. -/ + theorem exists_lagrangian_coordinates (h2 : (2 : K) ≠ 0) (ha : ω.IsAlt) + (hω : ω.Nondegenerate) (hL : ω.orthogonal L = L) : + ∃ e : (L × Module.Dual K L) ≃ₗ[K] E, + (∀ l : L, e (l,0) = l.val) ∧ + ∀ x y, ω (e x) (e y) = canonicalSymplectic x y := by + obtain ⟨s,hs,hiso⟩ := exists_isotropic_section ω L h2 ha hω hL + let e : (L × Module.Dual K L) →ₗ[K] E := + L.subtype.comp (LinearMap.fst K L (Module.Dual K L)) + + s.comp (LinearMap.snd K L (Module.Dual K L)) + have hp (l : L) : symplecticProjection ω L l.val = 0 := by + exact (symplecticProjection_ker ω L hL).ge l.property + have heproj (x : L × Module.Dual K L) : symplecticProjection ω L (e x) = x.2 := by + change symplecticProjection ω L (x.1.val + s x.2) = x.2 + rw [map_add, hp, zero_add] + exact LinearMap.congr_fun hs x.2 + have hinj : Function.Injective e := by + apply (LinearMap.ker_eq_bot).mp + apply (Submodule.eq_bot_iff _).mpr + intro x hx + have hx0 : e x = 0 := hx + have hf : x.2 = 0 := by rw [← heproj x, hx0, map_zero] + apply Prod.ext + · apply Subtype.ext + simpa [e,hf] using hx0 + · exact hf + have hsurj : Function.Surjective e := by + intro x + let f := symplecticProjection ω L x + have hz : x - s f ∈ L := by + apply (symplecticProjection_ker ω L hL).le + rw [LinearMap.mem_ker, map_sub] + exact sub_eq_zero.mpr (LinearMap.congr_fun hs f).symm + refine ⟨(⟨x-s f,hz⟩,f), ?_⟩ + change x - s f + s f = x + exact sub_add_cancel x (s f) + refine ⟨LinearEquiv.ofBijective e ⟨hinj,hsurj⟩, ?_, ?_⟩ + · intro l + change l.val + s 0 = l.val + simp + · rintro ⟨l,f⟩ ⟨m,g⟩ + change ω (l.val + s f) (m.val + s g) = g l - f m + have hLL : ω l.val m.val = 0 := by + have hm : m.val ∈ ω.orthogonal L := hL.symm ▸ m.property + exact hm l.val l.property + have hfg (f : Module.Dual K L) (l : L) : ω l.val (s f) = f l := + LinearMap.congr_fun (LinearMap.congr_fun hs f) l + simp only [map_add, LinearMap.add_apply] + rw [hLL, hfg, + ← ha.neg_eq m.val (s f), hfg, hiso] + ring + + + theorem self_orthogonal_twice_finrank (hω : ω.Nondegenerate) + (hL : ω.orthogonal L = L) : 2 * finrank K L = finrank K E := by + have h := LinearMap.BilinForm.finrank_orthogonal hω L + rw [hL] at h + have hle := Submodule.finrank_le L + omega + +/-- Isometries act transitively on Lagrangians, proved by the corrected +sections above. This is needed to use uniform pair laws in the planted model. -/ + theorem lagrangian_transitivity (h2 : (2 : K) ≠ 0) (ha : ω.IsAlt) + (hω : ω.Nondegenerate) (hL : ω.orthogonal L = L) + (M : Submodule K E) (hM : ω.orthogonal M = M) : + ∃ e : E ≃ₗ[K] E, (∀ x y, ω (e x) (e y) = ω x y) ∧ L.map e.toLinearMap = M := by + obtain ⟨eL,hEL,hωL⟩ := exists_lagrangian_coordinates ω L h2 ha hω hL + obtain ⟨eM,hEM,hωM⟩ := exists_lagrangian_coordinates ω M h2 ha hω hM + have hdim : finrank K L = finrank K M := by + have h1 := self_orthogonal_twice_finrank ω L hω hL + have h2 := self_orthogonal_twice_finrank ω M hω hM + omega + let f : L ≃ₗ[K] M := LinearEquiv.ofFinrankEq L M hdim + let c : (L × Module.Dual K L) ≃ₗ[K] (M × Module.Dual K M) := + f.prodCongr f.symm.dualMap + have hc (x y : L × Module.Dual K L) : + canonicalSymplectic (c x) (c y) = canonicalSymplectic x y := by + simp [c,canonicalSymplectic_apply] + let e := eL.symm.trans (c.trans eM) + have he (l : L) : e l.val = (f l).val := by + change eM (c (eL.symm l.val)) = (f l).val + rw [← hEL l, eL.symm_apply_apply] + simpa [c] using hEM (f l) + refine ⟨e, ?_, ?_⟩ + · intro x y + change ω (eM (c (eL.symm x))) (eM (c (eL.symm y))) = ω x y + rw [hωM, hc, ← hωL, eL.apply_symm_apply, eL.apply_symm_apply] + · ext x + constructor + · rintro ⟨y,hy,rfl⟩ + change e y ∈ M + rw [he ⟨y,hy⟩] + exact (f ⟨y,hy⟩).property + · intro hx + let l := f.symm ⟨x,hx⟩ + refine ⟨l.val,l.property, ?_⟩ + change e l.val = x + rw [he] + exact congrArg Subtype.val (f.apply_symm_apply ⟨x,hx⟩) + +omit [FiniteDimensional K E] in +/-- Orthogonal complement commutes with any form-preserving equivalence. -/ + theorem orthogonal_map_of_isometry (e : E ≃ₗ[K] E) + (he : ∀ x y, ω (e x) (e y) = ω x y) (U : Submodule K E) : + ω.orthogonal (U.map e.toLinearMap) = (ω.orthogonal U).map e.toLinearMap := by + ext x + constructor + · intro hx + refine ⟨e.symm x, ?_, e.apply_symm_apply x⟩ + intro u hu + rw [← he, e.apply_symm_apply] + exact hx (e u) ⟨u,hu,rfl⟩ + · rintro ⟨y,hy,rfl⟩ _ ⟨u,hu,rfl⟩ + change ω (e u) (e y) = 0 + rw [he] + exact hy u hu + +noncomputable def lagrangianIsometryEquiv (e : E ≃ₗ[K] E) + (he : ∀ x y, ω (e x) (e y) = ω x y) : + {U : Submodule K E // ω.orthogonal U = U} ≃ + {U : Submodule K E // ω.orthogonal U = U} := + (Submodule.orderIsoMapComap e).toEquiv.subtypeEquiv (by + intro U + change ω.orthogonal U = U ↔ ω.orthogonal (U.map e.toLinearMap) = U.map e.toLinearMap + rw [orthogonal_map_of_isometry ω e he] + exact (Submodule.orderIsoMapComap e).injective.eq_iff.symm) + +end NormalCoordinates +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section PairCounts +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] + +def verticalSpace : Submodule K (V × Module.Dual K V) := + (LinearMap.fst K V (Module.Dual K V)).ker + +omit [FiniteDimensional K V] in +@[simp] theorem mem_verticalSpace (p : V × Module.Dual K V) : + p ∈ verticalSpace (K := K) ↔ p.1 = 0 := Iff.rfl + +omit [FiniteDimensional K V] in + theorem verticalSpace_graph : verticalSpace (K := K) (V := V) = formGraph ⊥ 0 := by + ext p + constructor + · intro hp + refine ⟨0,hp.symm,?_⟩ + ext u + change p.2 u.val = 0 + have hu : u.val = 0 := u.property + rw [hu,map_zero] + · rintro ⟨u,hu,_⟩ + change p.1 = 0 + exact hu.symm.trans u.property + +noncomputable def verticalLagrangian : Lagrangian (K := K) (V := V) := + ⟨verticalSpace, by + rw [verticalSpace_graph] + exact (graphLagrangian ⊥ ⟨0, LinearMap.BilinForm.isSymm_zero⟩).property⟩ + +noncomputable def graphVerticalIntersectionEquiv (U : Submodule K V) + (B : LinearMap.BilinForm K U) : + U.dualAnnihilator ≃ₗ[K] ↥(formGraph U B ⊓ verticalSpace (K := K) (V := V)) where + toFun f := ⟨(0,f.val),⟨⟨0,rfl, by + ext u + simpa using ((Submodule.mem_dualAnnihilator (W := U) f.val).mp f.property) u u.property⟩,rfl⟩⟩ + invFun p := ⟨p.val.2, by + obtain ⟨u,hu,hf⟩ := p.property.1 + have hu0 : u = 0 := Subtype.ext (hu.trans p.property.2) + apply (Submodule.mem_dualAnnihilator (W := U) p.val.2).mpr + intro x hxU + have hf' := congrArg (fun l : Module.Dual K U => l ⟨x,hxU⟩) hf + simpa [hu0] using hf'⟩ + left_inv _ := rfl + right_inv p := by + apply Subtype.ext + exact Prod.ext p.property.2.symm rfl + map_add' f g := by apply Subtype.ext; simp + map_smul' a f := by apply Subtype.ext; simp + + theorem graph_vertical_intersection_finrank (U : Submodule K V) + (B : LinearMap.BilinForm K U) : + finrank K ↥(formGraph U B ⊓ verticalSpace (K := K) (V := V)) = finrank K V - finrank K U := by + rw [← (graphVerticalIntersectionEquiv U B).finrank_eq] + have h := Subspace.finrank_add_finrank_dualAnnihilator_eq U + omega + +/-- The exact stratum bijection for the intersection with a coordinate +Lagrangian: dimension h is neither approximated nor dropped. -/ +noncomputable def pairStratumEquiv (h : ℕ) (hh : h ≤ finrank K V) : + (Σ U : {U : Submodule K V // finrank K U = finrank K V-h}, SymForm K U.val) ≃ + {L : Lagrangian (K := K) (V := V) // finrank K ↥(L.val ⊓ verticalSpace (K := K) (V := V)) = h} := by + classical + let e : (Σ U : {U : Submodule K V // finrank K U = finrank K V-h}, SymForm K U.val) → + Lagrangian (K := K) (V := V) := fun S => graphLagrangian S.1.val S.2 + have he (S) : finrank K ↥((e S).val ⊓ verticalSpace (K := K) (V := V)) = h := by + exact (graph_vertical_intersection_finrank S.1.val S.2.val).trans (by + rw [S.1.property, Nat.sub_sub_self hh]) + refine Equiv.ofBijective (fun S => ⟨e S,he S⟩) ⟨?_, ?_⟩ + · rintro ⟨⟨U,hU⟩,B⟩ ⟨⟨W,hW⟩,C⟩ hEq + have h : graphLagrangian U B = graphLagrangian W C := congrArg Subtype.val hEq + have hUW : U = W := by + have hs : (⟨U,B⟩ : Σ U : Submodule K V, SymForm K U) = ⟨W,C⟩ := + (lagrangianGraphEquiv (K := K) (V := V)).injective h + exact congrArg Sigma.fst hs + cases hUW + have hBC := graphLagrangian_form_injective U h + cases hBC + rfl + · rintro ⟨L,hL⟩ + obtain ⟨⟨U,B⟩,hUB⟩ := graphLagrangian_surjective (K := K) (V := V) L + have hU : finrank K U = finrank K V-h := by + have hdim : finrank K V-finrank K U = h := by + rw [← graph_vertical_intersection_finrank U B.val] + have heq := congrArg (fun L : Lagrangian (K := K) (V := V) => + finrank K ↥(L.val ⊓ verticalSpace (K := K) (V := V))) hUB + exact heq.trans hL + have hle := Submodule.finrank_le U + omega + refine ⟨⟨⟨U,hU⟩,B⟩, Subtype.ext hUB⟩ + + theorem vertical_pair_count [Fintype K] [Finite V] (h : ℕ) (hh : h ≤ finrank K V) : + Nat.card {L : Lagrangian (K := K) (V := V) // finrank K ↥(L.val ⊓ verticalSpace (K := K) (V := V)) = h} = + Nat.card {U : Submodule K V // finrank K U = finrank K V-h} * + (Fintype.card K)^((finrank K V-h+1).choose 2) := by + classical + let := Fintype.ofFinite {U : Submodule K V // finrank K U = finrank K V-h} + rw [← Nat.card_congr (pairStratumEquiv (K := K) (V := V) h hh), Nat.card_sigma] + simp only [symForm_card] + have hd (U : {U : Submodule K V // finrank K U = finrank K V-h}) : + finrank K U.val = finrank K V-h := U.property + simp_rw [hd] + simp [Nat.card_eq_fintype_card] + + +omit [FiniteDimensional K V] in + theorem pair_stratum_card_congr (A B : Lagrangian (K := K) (V := V)) + (e : (V × Module.Dual K V) ≃ₗ[K] (V × Module.Dual K V)) + (he : ∀ x y, canonicalSymplectic (e x) (e y) = canonicalSymplectic x y) + (hAB : A.val.map e.toLinearMap = B.val) (h : ℕ) : + Nat.card {L : Lagrangian (K := K) (V := V) // finrank K ↥(L.val ⊓ A.val) = h} = + Nat.card {L : Lagrangian (K := K) (V := V) // finrank K ↥(L.val ⊓ B.val) = h} := by + let f := lagrangianIsometryEquiv canonicalSymplectic e he + apply Nat.card_congr (f.subtypeEquiv _) + intro L + have hdim : finrank K ↥((f L).val ⊓ B.val) = finrank K ↥(L.val ⊓ A.val) := by + change finrank K ↥(L.val.map e.toLinearMap ⊓ B.val) = _ + rw [← hAB, ← Submodule.map_inf e.toLinearMap e.injective] + exact (Submodule.equivMapOfInjective e.toLinearMap e.injective (L.val ⊓ A.val)).finrank_eq.symm + rw [hdim] + + + + theorem lagrangian_pair_count [Fintype K] [Finite V] (h2 : (2 : K) ≠ 0) + (A : Lagrangian (K := K) (V := V)) (h : ℕ) (hh : h ≤ finrank K V) : + Nat.card {L : Lagrangian (K := K) (V := V) // finrank K ↥(L.val ⊓ A.val) = h} = + Nat.card {U : Submodule K V // finrank K U = finrank K V-h} * + (Fintype.card K)^((finrank K V-h+1).choose 2) := by + obtain ⟨e,he,hAe⟩ := lagrangian_transitivity canonicalSymplectic A.val h2 + canonicalSymplectic_alt canonicalSymplectic_nondegenerate A.property + verticalLagrangian.val verticalLagrangian.property + exact (pair_stratum_card_congr A verticalLagrangian e he hAe h).trans + (vertical_pair_count (K := K) (V := V) h hh) + +end PairCounts +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section LinearGlue +variable {K E V : Type*} [Field K] [AddCommGroup E] [Module K E] + [AddCommGroup V] [Module K V] + theorem linear_functional_descend (f : E →ₗ[K] V) (g : E →ₗ[K] K) + (hk : f.ker ≤ g.ker) : ∃ h : V →ₗ[K] K, h.comp f = g := by + obtain ⟨p,hp⟩ := f.range.subtype.exists_leftInverse_of_injective + (LinearMap.ker_eq_bot.mpr f.range.subtype_injective) + let e := f.quotKerEquivRange + let a : V →ₗ[K] E ⧸ f.ker := e.symm.toLinearMap.comp p + have he (x : E) : a (f x) = f.ker.mkQ x := by + apply e.injective + change e (e.symm (p (f x))) = e (f.ker.mkQ x) + rw [e.apply_symm_apply] + exact LinearMap.congr_fun hp (f.rangeRestrict x) + refine ⟨(f.ker.liftQ g hk).comp a, ?_⟩ + ext x + change f.ker.liftQ g hk (a (f x)) = g x + rw [he] + rfl + + theorem linear_functional_glue (U W : Submodule K V) (f : U →ₗ[K] K) (g : W →ₗ[K] K) + (hfg : ∀ x : ↥(U ⊓ W), f (Submodule.inclusion inf_le_left x) = + g (Submodule.inclusion inf_le_right x)) : + ∃ h : V →ₗ[K] K, h.comp U.subtype = f ∧ h.comp W.subtype = g := by + let a : U × W →ₗ[K] V := U.subtype.comp (LinearMap.fst K U W) + + W.subtype.comp (LinearMap.snd K U W) + let b : U × W →ₗ[K] K := f.comp (LinearMap.fst K U W) + g.comp (LinearMap.snd K U W) + have hab : a.ker ≤ b.ker := by + rintro x hx + have hh : x.1.val + x.2.val = 0 := hx + have he : x.1.val = -x.2.val := eq_neg_of_add_eq_zero_left hh + let s : ↥(U ⊓ W) := ⟨x.1.val,x.1.property,he ▸ W.neg_mem x.2.property⟩ + have h₁ : Submodule.inclusion (show U ⊓ W ≤ U from inf_le_left) s = x.1 := rfl + have h₂ : Submodule.inclusion (show U ⊓ W ≤ W from inf_le_right) s = -x.2 := Subtype.ext he + have hf := hfg s + rw [h₁,h₂,map_neg] at hf + change f x.1 + g x.2 = 0 + rw [hf,neg_add_cancel] + obtain ⟨h,hh⟩ := linear_functional_descend a b hab + refine ⟨h,?_,?_⟩ <;> ext x + · have he := LinearMap.congr_fun hh (x,0) + simpa [a,b] using he + · have he := LinearMap.congr_fun hh (0,x) + simpa [a,b] using he +end LinearGlue + +section PairLift +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] +variable (U W : Submodule K V) (B : LinearMap.BilinForm K U) (C : LinearMap.BilinForm K W) +def graphDifference : LinearMap.BilinForm K ↥(U ⊓ W) := + B.compl₁₂ (Submodule.inclusion inf_le_left) (Submodule.inclusion inf_le_left) - + C.compl₁₂ (Submodule.inclusion inf_le_right) (Submodule.inclusion inf_le_right) + +def graphPairProjection : ↥(formGraph U B ⊓ formGraph W C) →ₗ[K] ↥(graphDifference U W B C).ker where + toFun p := ⟨⟨p.val.1,by + obtain ⟨u,hu,_⟩ := p.property.1 + obtain ⟨w,hw,_⟩ := p.property.2 + exact ⟨hu ▸ u.property,hw ▸ w.property⟩⟩,by + apply LinearMap.mem_ker.mpr + ext z + obtain ⟨u,hu,hf⟩ := p.property.1 + obtain ⟨w,hw,hg⟩ := p.property.2 + have e₁ : (Submodule.inclusion inf_le_left : ↥(U ⊓ W) →ₗ[K] U) ⟨p.val.1,by + exact ⟨hu ▸ u.property,hw ▸ w.property⟩⟩ = u := Subtype.ext hu.symm + have e₂ : (Submodule.inclusion inf_le_right : ↥(U ⊓ W) →ₗ[K] W) ⟨p.val.1,by + exact ⟨hu ▸ u.property,hw ▸ w.property⟩⟩ = w := Subtype.ext hw.symm + change B _ _ - C _ _ = 0 + rw [e₁,e₂] + have h₁ := LinearMap.congr_fun hf (Submodule.inclusion inf_le_left z) + have h₂ := LinearMap.congr_fun hg (Submodule.inclusion inf_le_right z) + exact sub_eq_zero.mpr (h₁.symm.trans h₂)⟩ + map_add' _ _ := rfl + map_smul' _ _ := rfl + + theorem graphPairProjection_surjective : Function.Surjective (graphPairProjection U W B C) := by + rintro ⟨x,hx⟩ + have hc (z : ↥(U ⊓ W)) : B (Submodule.inclusion inf_le_left x) (Submodule.inclusion inf_le_left z) = + C (Submodule.inclusion inf_le_right x) (Submodule.inclusion inf_le_right z) := by + have h := LinearMap.congr_fun (LinearMap.mem_ker.mp hx) z + exact sub_eq_zero.mp h + obtain ⟨f,hf,hg⟩ := linear_functional_glue U W (B (Submodule.inclusion inf_le_left x)) + (C (Submodule.inclusion inf_le_right x)) hc + refine ⟨⟨(x.val,f),⟨⟨Submodule.inclusion inf_le_left x,rfl,hf⟩, + ⟨Submodule.inclusion inf_le_right x,rfl,hg⟩⟩⟩,rfl⟩ + +noncomputable def graphPairKernelEquiv : (U ⊔ W).dualAnnihilator ≃ₗ[K] + (graphPairProjection U W B C).ker where + toFun f := ⟨⟨(0,f.val),⟨⟨0,rfl,by + ext x + change f.val x.val = B 0 x + rw [map_zero,LinearMap.zero_apply] + exact (Submodule.mem_dualAnnihilator (W := U ⊔ W) f.val).mp f.property x.val ((show U ≤ U ⊔ W from le_sup_left) x.property)⟩, + ⟨0,rfl,by + ext x + change f.val x.val = C 0 x + rw [map_zero,LinearMap.zero_apply] + exact (Submodule.mem_dualAnnihilator (W := U ⊔ W) f.val).mp f.property x.val ((show W ≤ U ⊔ W from le_sup_right) x.property)⟩⟩⟩,rfl⟩ + invFun p := ⟨p.val.val.2, by + apply (Submodule.mem_dualAnnihilator (W := U ⊔ W) p.val.val.2).mpr + have hzero : p.val.val.1 = 0 := congrArg (fun z : (graphDifference U W B C).ker => z.val.val) p.property + obtain ⟨u,hu,hf⟩ := p.val.property.1 + obtain ⟨w,hw,hg⟩ := p.val.property.2 + have hu0 : u = 0 := Subtype.ext (hu.trans hzero) + have hw0 : w = 0 := Subtype.ext (hw.trans hzero) + intro x hx + obtain ⟨y,hy,z,hz,rfl⟩ := Submodule.mem_sup.mp hx + rw [map_add] + have h₁ := LinearMap.congr_fun hf ⟨y,hy⟩ + have h₂ := LinearMap.congr_fun hg ⟨z,hz⟩ + simp only [hu0,hw0,map_zero,LinearMap.zero_apply,LinearMap.comp_apply,Submodule.subtype_apply] at h₁ h₂ + rw [h₁,h₂,add_zero]⟩ + left_inv _ := rfl + right_inv p := by + apply Subtype.ext + apply Subtype.ext + exact Prod.ext (congrArg (fun z : (graphDifference U W B C).ker => z.val.val) p.property).symm rfl + map_add' _ _ := by apply Subtype.ext; apply Subtype.ext; simp + map_smul' _ _ := by apply Subtype.ext; apply Subtype.ext; simp + + theorem graph_pair_intersection_finrank [FiniteDimensional K V] : + finrank K ↥(formGraph U B ⊓ formGraph W C) = + finrank K ↥(U.dualAnnihilator ⊓ W.dualAnnihilator) + finrank K (graphDifference U W B C).ker := by + have h := LinearMap.finrank_range_add_finrank_ker (K := K) + (V := ↥(formGraph U B ⊓ formGraph W C)) (V₂ := ↥(graphDifference U W B C).ker) + (graphPairProjection U W B C) + rw [LinearMap.range_eq_top.mpr (graphPairProjection_surjective U W B C),finrank_top] at h + rw [←(graphPairKernelEquiv U W B C).finrank_eq] at h + rw [Submodule.dualAnnihilator_sup_eq] at h + omega +end PairLift +end SidorenkoCounterexample + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/LocalMoments.lean b/lean/OAI/Combinatorics/Sidorenko/LocalMoments.lean new file mode 100644 index 0000000000000000000000000000000000000000..f30442f0b5452439abe2936c8e0e6e36f1deedd2 --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/LocalMoments.lean @@ -0,0 +1,818 @@ +import OAI.Combinatorics.Sidorenko.Normalization + +namespace OAI + + +section + +namespace SidorenkoCounterexample +open Module LinearMap +open scoped Matrix BigOperators +section Count +variable {I K V : Type*} [Fintype I] [Field K] [Fintype K] [DecidableEq K] + [AddCommGroup V] [Module K V] [FiniteDimensional K V] + +theorem uniformMean_mul_card (f : I → ℝ) : + (Fintype.card I : ℝ)*uniformMean f=∑ i, f i := by + by_cases h : Fintype.card I=0 + · have := Fintype.card_eq_zero_iff.mp h + simp [uniformMean] + · unfold uniformMean + field_simp + +theorem restrictionSign_count (U : I → Submodule K V) (Q : SymForm K V) (ξ : ℤ) : + (Nat.card {i : I // (Q.val.restrict (U i)).Nondegenerate ∧ + discriminantSign (Q.val.restrict (U i)) (Q.property.restrict (U i))=ξ} : ℝ) = + (Fintype.card I : ℝ)*uniformMean (fun i => formSignIndicator ξ (symFormPull (U i).subtype Q)) := by + classical + rw [uniformMean_mul_card,Nat.card_eq_fintype_card,Fintype.card_subtype,←Finset.sum_boole] + apply Finset.sum_congr rfl + intro i _ + change (if (Q.val.restrict (U i)).Nondegenerate ∧ + discriminantSign (Q.val.restrict (U i)) (Q.property.restrict (U i))=ξ then 1 else 0 : ℝ) = + if (Q.val.restrict (U i)).Nondegenerate then + if discriminantSign (Q.val.restrict (U i)) (Q.property.restrict (U i))=ξ then 1 else 0 else 0 + split_ifs <;> simp_all +end Count +section Identities +variable {K : Type*} [Field K] [Fintype K] [DecidableEq K] {D r : ℕ} + +noncomputable def signedProjectorIsotropicEquiv (Q : Matrix (Fin D) (Fin D) K) + (hQ : Q.IsSymm) (hdet : Q.det≠0) (r : ℕ) (ξ : ℤ) + (L : LinearMap.BilinForm K (Fin D → K)) : + {A : SignedProjector Q r ξ // L.restrict A.val.val.toLin'.range=0} ≃ + {U : {U : DimSubspace K (Fin D → K) r // L.restrict U.val=0} // + (Q.toBilin'.restrict U.val.val).Nondegenerate ∧ + discriminantSign (Q.toBilin'.restrict U.val.val) + ((Matrix.isSymm_toBilin'_iff_isSymm.mpr hQ).restrict U.val.val)=ξ} where + toFun A := + let U := signedProjectorSubspaceEquiv Q hQ hdet r ξ A.val + ⟨⟨U.val,by + change L.restrict (centerSubspaceEquiv Q hQ hdet A.val.val).val=0 + rw [centerSubspaceEquiv_val]; exact A.property⟩,U.property⟩ + invFun U := + let A := (signedProjectorSubspaceEquiv Q hQ hdet r ξ).symm ⟨U.val.val,U.property⟩ + ⟨A,by + rw [←centerSubspaceEquiv_val Q hQ hdet] + change L.restrict ((signedProjectorSubspaceEquiv Q hQ hdet r ξ) A).val.val=0 + rw [show (signedProjectorSubspaceEquiv Q hQ hdet r ξ) A=⟨U.val.val,U.property⟩ from + Equiv.apply_symm_apply _ _] + exact U.val.property⟩ + left_inv A := by + apply Subtype.ext + exact (signedProjectorSubspaceEquiv Q hQ hdet r ξ).symm_apply_apply A.val + right_inv U := by + apply Subtype.ext + apply Subtype.ext + change ((signedProjectorSubspaceEquiv Q hQ hdet r ξ) + ((signedProjectorSubspaceEquiv Q hQ hdet r ξ).symm ⟨U.val.val,U.property⟩)).val=U.val.val + rw [Equiv.apply_symm_apply] + +noncomputable def pairRestrictionFraction (Q : SymMatrix K D) (r : ℕ) (ξ : ℤ) : ℝ := by + classical + let := Fintype.ofFinite (DimSubspace K (Fin D → K) r) + exact uniformMean (fun U : DimSubspace K (Fin D → K) r => + formSignIndicator ξ (symFormPull U.val.subtype (matrixFormEquiv D Q))) + +noncomputable def isotropicRestrictionFraction (Q : SymMatrix K D) + (L : LinearMap.BilinForm K (Fin D → K)) (r : ℕ) (ξ : ℤ) : ℝ := by + classical + let := Fintype.ofFinite {U : DimSubspace K (Fin D → K) r // L.restrict U.val=0} + exact uniformMean (fun U : {U : DimSubspace K (Fin D → K) r // L.restrict U.val=0} => + formSignIndicator ξ (symFormPull U.val.val.subtype (matrixFormEquiv D Q))) + +theorem pairCenter_card (hd : D=2*r) (B : SymMatrix K D) (hB : B.val.det≠0) + (ξ ζ : ℤ) (hm : quadraticChar K B.val.det=quadraticChar K ((-1 : K)^r)*ξ*ζ) : + (Nat.card {A : SymMatrix K D // A ∈ signedLayer K D r ξ ∧ A-B ∈ signedLayer K D r ζ} : ℝ) = + (Nat.card (DimSubspace K (Fin D → K) r) : ℝ) * + pairRestrictionFraction (⟨B.val⁻¹,B.property.inv⟩ : SymMatrix K D) r ξ := by + classical + let := Fintype.ofFinite (DimSubspace K (Fin D → K) r) + have hn : B.val⁻¹.det≠0 := by simpa [Matrix.det_nonsing_inv] using inv_ne_zero hB + rw [Nat.card_congr ((pairSignedCenterEquiv hd B hB ξ ζ hm).trans + (signedProjectorSubspaceEquiv B.val⁻¹ B.property.inv hn r ξ))] + exact (restrictionSign_count (fun U : DimSubspace K (Fin D → K) r => U.val) + (matrixFormEquiv D ⟨B.val⁻¹,B.property.inv⟩) ξ).trans (by + rw [Nat.card_eq_fintype_card]; rfl) + +theorem tripleCenter_card (hd : D=2*r) (B C : SymMatrix K D) + (hB : B.val.det≠0) (hC : C.val.det≠0) (ξ ζ θ : ℤ) + (hmB : quadraticChar K B.val.det=quadraticChar K ((-1 : K)^r)*ξ*ζ) + (hmC : quadraticChar K C.val.det=quadraticChar K ((-1 : K)^r)*ξ*θ) : + (Nat.card {A : SymMatrix K D // A ∈ signedLayer K D r ξ ∧ A-B ∈ signedLayer K D r ζ ∧ + A-C ∈ signedLayer K D r θ} : ℝ) = + (Nat.card {U : DimSubspace K (Fin D → K) r // + (B.val⁻¹-C.val⁻¹).toBilin'.restrict U.val=0} : ℝ) * + isotropicRestrictionFraction (⟨B.val⁻¹,B.property.inv⟩ : SymMatrix K D) + (B.val⁻¹-C.val⁻¹).toBilin' r ξ := by + classical + let := Fintype.ofFinite {U : DimSubspace K (Fin D → K) r // + (B.val⁻¹-C.val⁻¹).toBilin'.restrict U.val=0} + have hn : B.val⁻¹.det≠0 := by simpa [Matrix.det_nonsing_inv] using inv_ne_zero hB + rw [Nat.card_congr ((tripleSignedCenterEquiv hd B C hB hC ξ ζ θ hmB hmC).trans + (signedProjectorIsotropicEquiv B.val⁻¹ B.property.inv hn r ξ _))] + exact (restrictionSign_count (fun U : {U : DimSubspace K (Fin D → K) r // + (B.val⁻¹-C.val⁻¹).toBilin'.restrict U.val=0} => U.val.val) + (matrixFormEquiv D ⟨B.val⁻¹,B.property.inv⟩) ξ).trans (by + rw [Nat.card_eq_fintype_card]; rfl) +end Identities +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module Filter +open scoped BigOperators +section Coeff +variable {K : Type*} [Field K] [Fintype K] [DecidableEq K] +noncomputable def pairCoefficient (r : ℕ) (ξ ζ : ℤ) : ℝ := + (Nat.card (DimSubspace K (Fin (2*r) → K) r) : ℝ) / + (Fintype.card (SymMatrix K (2*r)) : ℝ) / + (layerMass K (2*r) r ξ * layerMass K (2*r) r ζ) +noncomputable def tripleCoefficient (r : ℕ) (ξ ζ θ : ℤ) : ℝ := + (Nat.card (MaxOrthogonal (K := K) (V := Fin r → K)) : ℝ) / + (Fintype.card (SymMatrix K (2*r)) : ℝ) / + (layerMass K (2*r) r ξ * layerMass K (2*r) r ζ * layerMass K (2*r) r θ) + +theorem pair_exponent_cancel (r : ℕ) : + r*r+2*((r+1).choose 2)=(2*r+1).choose 2 := by + have h := triangular_nat_add r r + have he : r+r+1=2*r+1 := by omega + rw [he] at h + omega + +theorem triple_exponent_cancel (r : ℕ) : + r.choose 2+3*((r+1).choose 2)=(2*r+1).choose 2 := by + have h : (r.choose 2 : ℚ)+3*((r+1).choose 2 : ℚ)=((2*r+1).choose 2 : ℚ) := by + simp only [Nat.cast_choose_two,Nat.cast_add,Nat.cast_mul,Nat.cast_one,Nat.cast_ofNat] + ring + exact_mod_cast h + +theorem pairCoefficient_normalized (r : ℕ) (ξ ζ : ℤ) : + pairCoefficient (K := K) r ξ ζ = + grassmannFactor (2*r) r (Fintype.card K) / + ((layerMass K (2*r) r ξ * (Fintype.card K : ℝ)^((r+1).choose 2)) * + (layerMass K (2*r) r ζ * (Fintype.card K : ℝ)^((r+1).choose 2))) := by + unfold pairCoefficient + rw [subspace_count_normalized r (by simp; omega),←Nat.card_eq_fintype_card (α := SymMatrix K (2*r)),symMatrix_card] + simp only [Module.finrank_fin_fun,show 2*r-r=r by omega,Nat.cast_pow] + rw [←pair_exponent_cancel,pow_add,pow_mul] + have hq : (Fintype.card K : ℝ)≠0 := Nat.cast_ne_zero.mpr Fintype.card_ne_zero + field_simp + ring + +theorem tripleCoefficient_normalized (hK : ringChar K≠2) (r : ℕ) (ξ ζ θ : ℤ) : + tripleCoefficient (K := K) r ξ ζ θ = + orthogonalFactor r (Fintype.card K) / + ((layerMass K (2*r) r ξ * (Fintype.card K : ℝ)^((r+1).choose 2)) * + (layerMass K (2*r) r ζ * (Fintype.card K : ℝ)^((r+1).choose 2)) * + (layerMass K (2*r) r θ * (Fintype.card K : ℝ)^((r+1).choose 2))) := by + have he := maxOrthogonal_normalized (K := K) hK r + unfold tripleCoefficient + rw [←he,←Nat.card_eq_fintype_card (α := SymMatrix K (2*r)),symMatrix_card,Nat.cast_pow, + ←triple_exponent_cancel,pow_add,pow_mul] + have hq : (Fintype.card K : ℝ)≠0 := Nat.cast_ne_zero.mpr Fintype.card_ne_zero + field_simp + ring + +theorem pairCoefficient_nonneg (r : ℕ) (ξ ζ : ℤ) : 0≤pairCoefficient (K := K) r ξ ζ := by + unfold pairCoefficient layerMass + positivity + +theorem tripleCoefficient_nonneg (r : ℕ) (ξ ζ θ : ℤ) : 0≤tripleCoefficient (K := K) r ξ ζ θ := by + unfold tripleCoefficient layerMass + positivity +end Coeff + +theorem pairCoefficient_tendsto (r : ℕ) (hr : 0 pairCoefficient (K := ZMod q.val) r ξ ζ) + primeInfinity (nhds 4) := by + have hx := layerMass_tendsto (2*r) r hr (by omega) hξ + have hz := layerMass_tendsto (2*r) r hr (by omega) hζ + have hf := (grassmannFactor_tendsto (2*r) r (by omega)).comp primeInfinity_real_tendsto + have h := hf.div (hx.mul hz) (by norm_num) + simp only [show 2*r-r=r by omega,Function.comp_def] at h + norm_num only at h + simp_rw [pairCoefficient_normalized,ZMod.card] + convert h using 1 + +theorem tripleCoefficient_tendsto (r : ℕ) (hr : 0 tripleCoefficient (K := ZMod q.val) r ξ ζ θ) + primeInfinity (nhds 16) := by + have hx := layerMass_tendsto (2*r) r hr (by omega) hξ + have hz := layerMass_tendsto (2*r) r hr (by omega) hζ + have ht := layerMass_tendsto (2*r) r hr (by omega) hθ + have hf := (orthogonalFactor_tendsto r hr).comp primeInfinity_real_tendsto + have h := hf.div ((hx.mul hz).mul ht) (by norm_num) + simp only [show 2*r-r=r by omega,Function.comp_def] at h + norm_num only at h + have he (q : OddPrime) := tripleCoefficient_normalized (K := ZMod q.val) + (by simpa only [ZMod.ringChar_zmod_n] using q.property.2) r ξ ζ θ + simp only [ZMod.card] at he + simp_rw [he] + exact h +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section Sizes +variable {K : Type*} [Field K] [Fintype K] [DecidableEq K] + +omit [DecidableEq K] in +theorem maxOrthogonal_card_lower (r : ℕ) : + Fintype.card K ^ r.choose 2 ≤ Nat.card (MaxOrthogonal (K := K) (V := Fin r → K)) := by + classical + let : Finite (Module.Dual K (Fin r → K)) := Module.finite_of_finite K + have h := Nat.card_le_card_of_injective (f := graphMaxOrthogonal (K := K) (⊤ : Submodule K (Fin r → K))) (graphMaxOrthogonal_form_injective + (K := K) (⊤ : Submodule K (Fin r → K))) + simpa only [altForm_card,finrank_top,Module.finrank_fin_fun] using h + +theorem halfIsotropic_card (r : ℕ) (L : LinearMap.BilinForm K (Fin (2*r) → K)) + (hs : L.IsSymm) (hL : L.Nondegenerate) (hK : ringChar K≠2) + (hc : discriminantSign L hs=quadraticChar K ((-1 : K)^r)) : + Nat.card {U : DimSubspace K (Fin (2*r) → K) r // L.restrict U.val=0} = + Nat.card (MaxOrthogonal (K := K) (V := Fin r → K)) := by + rw [Nat.card_congr (halfIsotropicEquiv L hL r (by simp))] + exact split_form_card L hs hL hK r (by simp) hc + +omit [DecidableEq K] in +theorem pairFamily_card_ge (r : ℕ) (hr : 0 + |uniformMean (fun i => formSignIndicator ξ (symFormPull (U i).subtype (matrixFormEquiv D Q)))-1/2|) ≤ + Real.sqrt (((r : ℝ)+1)/(Fintype.card K : ℝ)) := by + have hq : (0 : ℝ) |uniformMean (fun i => formSignIndicator ξ (symFormPull (U i).subtype Q))-1/2|) + dsimp only [Function.comp_def] at he + rw [he] + have h := restriction_family_L1_sq U hinj r hd hK hξ + have hiq : 1/(Fintype.card I : ℝ)≤1/(Fintype.card K : ℝ) := one_div_le_one_div_of_le hq hc + have ht : (r : ℝ)/(Fintype.card K : ℝ)+1/(Fintype.card I : ℝ) ≤ + ((r : ℝ)+1)/(Fintype.card K : ℝ) := by rw [add_div]; linarith + exact (Real.le_sqrt (uniformMean_nonneg (fun _ => abs_nonneg _)) (by positivity)).mpr (h.trans ht) + +theorem pairRestrictionFraction_L1 (r : ℕ) (hr : 0 |pairRestrictionFraction Q r ξ-1/2|) ≤ + Real.sqrt (((r : ℝ)+1)/(Fintype.card K : ℝ)) := by + classical + let := Fintype.ofFinite (DimSubspace K (Fin (2*r) → K) r) + exact matrix_restriction_family_L1 (fun U : DimSubspace K (Fin (2*r) → K) r => U.val) + Subtype.val_injective (fun U => U.property) + (by simpa only [Nat.card_eq_fintype_card] using pairFamily_card_ge (K := K) r hr) hK hξ + +theorem isotropicRestrictionFraction_L1 (r : ℕ) (hr : 1 |isotropicRestrictionFraction Q L r ξ-1/2|) ≤ + Real.sqrt (((r : ℝ)+1)/(Fintype.card K : ℝ)) := by + classical + let := Fintype.ofFinite {U : DimSubspace K (Fin (2*r) → K) r // L.restrict U.val=0} + exact matrix_restriction_family_L1 (fun U : {U : DimSubspace K (Fin (2*r) → K) r // L.restrict U.val=0} => U.val.val) + (Subtype.val_injective.comp Subtype.val_injective) (fun U => U.val.property) + (by simpa only [Nat.card_eq_fintype_card] using isotropicFamily_card_ge r hr L hs hL hK hc) hK hξ +end Bounds +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open scoped BigOperators +section Mean +variable {I A B : Type*} [Fintype I] [DecidableEq I] [Fintype A] [Fintype B] + +omit [DecidableEq I] in +theorem uniformMean_sum (f : I → A → ℝ) : + uniformMean (fun a => ∑ i, f i a)=∑ i, uniformMean (f i) := by + unfold uniformMean + rw [Finset.sum_comm,Finset.sum_div] + +theorem uniformMean_coordinate [Nonempty A] (i : I) (f : A → ℝ) : + uniformMean (fun x : I → A => f (x i))=uniformMean f := by + classical + rw [←uniformMean_equiv (Equiv.piSplitAt i (fun _ : I => A)).symm,uniformMean_prod] + simp only [Function.comp_def,Equiv.piSplitAt,Equiv.coe_fn_symm_mk] + simp [uniformMean_const] + +theorem uniformMean_update [Nonempty A] (i : I) (f : (I → A) → ℝ) : + uniformMean f=uniformMean (fun x : I → A => uniformMean (fun a : A => f (Function.update x i a))) := by + classical + let e := Equiv.funSplitAt i A + have he (x : A × ({j : I // j≠i} → A)) (a : A) : + Function.update (e.symm x) i a=e.symm (a,x.2) := by + ext j + by_cases hj : j=i + · subst j; simp [e,Equiv.funSplitAt,Equiv.piSplitAt] + · simp [e,Equiv.funSplitAt,Equiv.piSplitAt,hj] + rw [←uniformMean_equiv e.symm,uniformMean_prod] + conv_rhs => rw [←uniformMean_equiv e.symm,uniformMean_prod] + simp only [Function.comp_def,he] + rw [uniformMean_const] + exact uniformMean_swap _ + +theorem uniformMean_mul_right (f : A → ℝ) (c : ℝ) : + uniformMean (fun a => f a*c)=uniformMean f*c := by + simpa only [mul_comm] using uniformMean_mul c f + +theorem uniformMean_ite_le [Nonempty A] (P : A → Prop) [DecidablePred P] + (f : A → ℝ) (b : ℝ) (hf : ∀ a, P a → f a≤b) (hb : 0≤b) : + uniformMean (fun a => if P a then f a else 0)≤b := by + apply uniformMean_bound + intro a + split_ifs with h + · exact hf a h + · exact hb +end Mean +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open scoped BigOperators +open Module +section Inverting +variable {K : Type*} [Field K] [Fintype K] + +/-- Extend inversion by fixing singular forms. Unlike the total matrix inverse, +this is a permutation of the entire symmetric-matrix probability space. -/ +noncomputable def symmetricInverse (D : ℕ) (M : SymMatrix K D) : SymMatrix K D := + by + classical + exact if M.val.det = 0 then M else ⟨M.val⁻¹, M.property.inv⟩ + +omit [Fintype K] in + theorem symmetricInverse_involutive (D : ℕ) : Function.Involutive (symmetricInverse (K := K) D) := by + classical + intro M + by_cases h : M.val.det = 0 + · have he : symmetricInverse D M = M := by simp only [symmetricInverse, h, ↓reduceIte] + rw [he, he] + · let M' : SymMatrix K D := ⟨M.val⁻¹, M.property.inv⟩ + have he : symmetricInverse D M = M' := by simp only [symmetricInverse, h, ↓reduceIte, M'] + have hn : M'.val.det ≠ 0 := (M.val.isUnit_nonsing_inv_det (isUnit_iff_ne_zero.mpr h)).ne_zero + have he' : symmetricInverse D M' = ⟨M'.val⁻¹, M'.property.inv⟩ := by + simp only [symmetricInverse, hn, ↓reduceIte] + rw [he, he'] + exact Subtype.ext (M.val.nonsing_inv_nonsing_inv (isUnit_iff_ne_zero.mpr h)) + +noncomputable def symmetricInverseEquiv (D : ℕ) : SymMatrix K D ≃ SymMatrix K D := + (symmetricInverse_involutive D).toPerm + +end Inverting +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module Classical +open scoped Matrix BigOperators +section Center +variable {K : Type*} [Field K] [Fintype K] [DecidableEq K] +noncomputable def pairLocal (r : ℕ) (ξ ζ : ℤ) (B : SymMatrix K (2*r)) : ℝ := + uniformMean (fun A => rankKernel K (2*r) r ξ A * rankKernel K (2*r) r ζ (A-B)) +noncomputable def tripleLocal (r : ℕ) (ξ ζ θ : ℤ) (B C : SymMatrix K (2*r)) : ℝ := + uniformMean (fun A => rankKernel K (2*r) r ξ A * rankKernel K (2*r) r ζ (A-B) * + rankKernel K (2*r) r θ (A-C)) + +def pairMatch (r : ℕ) (ξ ζ : ℤ) (B : SymMatrix K (2*r)) : Prop := + quadraticChar K B.val.det=quadraticChar K ((-1 : K)^r)*ξ*ζ + +def tripleMatch (r : ℕ) (ξ ζ θ : ℤ) (B C : SymMatrix K (2*r)) : Prop := + pairMatch r ξ ζ B ∧ pairMatch r ξ θ C ∧ pairMatch r ζ θ (C-B) + +theorem pairLocal_card (r : ℕ) (ξ ζ : ℤ) (B : SymMatrix K (2*r)) : + pairLocal r ξ ζ B = + (Nat.card {A : SymMatrix K (2*r) // A ∈ signedLayer K (2*r) r ξ ∧ + A-B ∈ signedLayer K (2*r) r ζ} : ℝ) / + (Fintype.card (SymMatrix K (2*r)) : ℝ) / + (layerMass K (2*r) r ξ * layerMass K (2*r) r ζ) := by + have he (A : SymMatrix K (2*r)) : + rankKernel K (2*r) r ξ A * rankKernel K (2*r) r ζ (A-B) = + (if A ∈ signedLayer K (2*r) r ξ ∧ A-B ∈ signedLayer K (2*r) r ζ then (1 : ℝ) else 0) * + (layerMass K (2*r) r ξ * layerMass K (2*r) r ζ)⁻¹ := by + unfold rankKernel + split_ifs <;> simp_all [mul_comm] + unfold pairLocal + simp_rw [he] + rw [uniformMean_mul_right,uniformMean_indicator,Nat.card_eq_fintype_card] + rfl + +theorem tripleLocal_card (r : ℕ) (ξ ζ θ : ℤ) (B C : SymMatrix K (2*r)) : + tripleLocal r ξ ζ θ B C = + (Nat.card {A : SymMatrix K (2*r) // A ∈ signedLayer K (2*r) r ξ ∧ + A-B ∈ signedLayer K (2*r) r ζ ∧ A-C ∈ signedLayer K (2*r) r θ} : ℝ) / + (Fintype.card (SymMatrix K (2*r)) : ℝ) / + (layerMass K (2*r) r ξ * layerMass K (2*r) r ζ * layerMass K (2*r) r θ) := by + have he (A : SymMatrix K (2*r)) : + rankKernel K (2*r) r ξ A * rankKernel K (2*r) r ζ (A-B) * rankKernel K (2*r) r θ (A-C) = + (if A ∈ signedLayer K (2*r) r ξ ∧ A-B ∈ signedLayer K (2*r) r ζ ∧ + A-C ∈ signedLayer K (2*r) r θ then (1 : ℝ) else 0) * + (layerMass K (2*r) r ξ * layerMass K (2*r) r ζ * layerMass K (2*r) r θ)⁻¹ := by + unfold rankKernel + split_ifs <;> simp_all [mul_comm,mul_assoc] + unfold tripleLocal + simp_rw [he] + rw [uniformMean_mul_right,uniformMean_indicator,Nat.card_eq_fintype_card] + rfl + +theorem pairLocal_match (r : ℕ) (ξ ζ : ℤ) (B : SymMatrix K (2*r)) + (hB : B.val.det≠0) (hm : pairMatch r ξ ζ B) : + pairLocal r ξ ζ B = pairCoefficient (K := K) r ξ ζ * + pairRestrictionFraction (symmetricInverse (2*r) B) r ξ := by + rw [pairLocal_card,pairCenter_card rfl B hB ξ ζ hm] + simp only [symmetricInverse,hB,ite_false] + unfold pairCoefficient + ring + +theorem pairLocal_mismatch (r : ℕ) (ξ ζ : ℤ) (B : SymMatrix K (2*r)) + (hB : B.val.det≠0) (hm : ¬pairMatch r ξ ζ B) : pairLocal r ξ ζ B=0 := by + unfold pairLocal + have he (A : SymMatrix K (2*r)) : + rankKernel K (2*r) r ξ A * rankKernel K (2*r) r ζ (A-B)=0 := by + unfold rankKernel + split_ifs with hx hz + · obtain ⟨ha,hs⟩ := (mem_signedLayer ..).mp hx + obtain ⟨hb,ht⟩ := (mem_signedLayer ..).mp hz + have h := signed_pair_compatibility rfl A B hB ha hb + rw [hs,ht] at h + exact (hm h).elim + all_goals simp + simp_rw [he] + exact uniformMean_const 0 + +theorem tripleLocal_mismatch (r : ℕ) (ξ ζ θ : ℤ) (B C : SymMatrix K (2*r)) + (hB : B.val.det≠0) (hC : C.val.det≠0) (hBC : (C-B).val.det≠0) + (hm : ¬tripleMatch r ξ ζ θ B C) : tripleLocal r ξ ζ θ B C=0 := by + unfold tripleLocal + have he (A : SymMatrix K (2*r)) : + rankKernel K (2*r) r ξ A * rankKernel K (2*r) r ζ (A-B) * rankKernel K (2*r) r θ (A-C)=0 := by + unfold rankKernel + split_ifs with hx hz ht + · obtain ⟨ha,hs⟩ := (mem_signedLayer ..).mp hx + obtain ⟨hb,hz⟩ := (mem_signedLayer ..).mp hz + obtain ⟨hc,ht⟩ := (mem_signedLayer ..).mp ht + have h1 := signed_pair_compatibility rfl A B hB ha hb + have h2 := signed_pair_compatibility rfl A C hC ha hc + have h3 := signed_pair_compatibility rfl (A-B) (C-B) hBC hb (by simpa using hc) + simp only [sub_sub_sub_cancel_right] at h3 + rw [hs,hz] at h1 + rw [hs,ht] at h2 + rw [hz,ht] at h3 + exact (hm ⟨h1,h2,h3⟩).elim + all_goals simp + simp_rw [he] + exact uniformMean_const 0 +omit [Fintype K] [DecidableEq K] in +theorem inverse_difference_det (D : ℕ) (B C : SymMatrix K D) + (hB : B.val.det≠0) (hC : C.val.det≠0) : + (B.val⁻¹-C.val⁻¹).det = B.val.det⁻¹ * (C-B).val.det * C.val.det⁻¹ := by + rw [Matrix.inv_sub_inv (by + exact iff_of_true ((Matrix.isUnit_iff_isUnit_det _).mpr (isUnit_iff_ne_zero.mpr hB)) + ((Matrix.isUnit_iff_isUnit_det _).mpr (isUnit_iff_ne_zero.mpr hC)))] + simp only [Matrix.det_mul,Matrix.det_nonsing_inv,Ring.inverse_eq_inv,Submodule.coe_sub] + +omit [Fintype K] [DecidableEq K] in +theorem inverse_difference_nondegenerate (D : ℕ) (B C : SymMatrix K D) + (hB : B.val.det≠0) (hC : C.val.det≠0) (hBC : (C-B).val.det≠0) : + (B.val⁻¹-C.val⁻¹).toBilin'.Nondegenerate := by + apply Matrix.nondegenerate_toBilin'_iff.mpr + apply Matrix.nondegenerate_iff_det_ne_zero.mpr + rw [inverse_difference_det D B C hB hC] + exact mul_ne_zero (mul_ne_zero (inv_ne_zero hB) hBC) (inv_ne_zero hC) + +theorem matching_inverse_difference_split (r : ℕ) (B C : SymMatrix K (2*r)) + (hB : B.val.det≠0) (hC : C.val.det≠0) (hBC : (C-B).val.det≠0) + {ξ ζ θ : ℤ} (hξ : ξ=1 ∨ ξ= -1) (hζ : ζ=1 ∨ ζ= -1) (hθ : θ=1 ∨ θ= -1) + (hm : tripleMatch r ξ ζ θ B C) : + discriminantSign (B.val⁻¹-C.val⁻¹).toBilin' + (Matrix.isSymm_toBilin'_iff_isSymm.mpr (B.property.inv.sub C.property.inv)) = + quadraticChar K ((-1 : K)^r) := by + rw [discriminantSign_nondegenerate _ _ (inverse_difference_nondegenerate (2*r) B C hB hC hBC) + (Pi.basisFun K (Fin (2*r)))] + change quadraticChar K ((B.val⁻¹-C.val⁻¹).toBilin'.toMatrix').det = _ + rw [LinearMap.BilinForm.toMatrix'_toBilin',inverse_difference_det (2*r) B C hB hC, + map_mul,map_mul,quadraticChar_inverse hB,quadraticChar_inverse hC] + rw [hm.1,hm.2.1,hm.2.2] + have hc := quadraticChar_sq_one (F := K) (pow_ne_zero r (neg_ne_zero.mpr one_ne_zero)) + have hx : ξ^2=1 := by rcases hξ with rfl | rfl <;> norm_num + have hz : ζ^2=1 := by rcases hζ with rfl | rfl <;> norm_num + have ht : θ^2=1 := by rcases hθ with rfl | rfl <;> norm_num + calc + _ = quadraticChar K ((-1 : K)^r) * (quadraticChar K ((-1 : K)^r))^2 * ξ^2 * ζ^2 * θ^2 := by ring + _ = _ := by rw [hc,hx,hz,ht]; ring + +theorem tripleLocal_match (hK : ringChar K≠2) (r : ℕ) (B C : SymMatrix K (2*r)) + (hB : B.val.det≠0) (hC : C.val.det≠0) (hBC : (C-B).val.det≠0) + {ξ ζ θ : ℤ} (hξ : ξ=1 ∨ ξ= -1) (hζ : ζ=1 ∨ ζ= -1) (hθ : θ=1 ∨ θ= -1) + (hm : tripleMatch r ξ ζ θ B C) : + tripleLocal r ξ ζ θ B C = tripleCoefficient (K := K) r ξ ζ θ * + isotropicRestrictionFraction (symmetricInverse (2*r) B) (B.val⁻¹-C.val⁻¹).toBilin' r ξ := by + rw [tripleLocal_card,tripleCenter_card rfl B C hB hC ξ ζ θ hm.1 hm.2.1, + halfIsotropic_card r _ (Matrix.isSymm_toBilin'_iff_isSymm.mpr (B.property.inv.sub C.property.inv)) + (inverse_difference_nondegenerate (2*r) B C hB hC hBC) hK + (matching_inverse_difference_split r B C hB hC hBC hξ hζ hθ hm)] + simp only [symmetricInverse,hB,ite_false] + unfold tripleCoefficient + ring +end Center +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module Classical +open scoped BigOperators +section Means +variable {A B : Type*} [Fintype A] [Fintype B] +theorem uniformMean_le_one {f : A → ℝ} (hf : ∀ a, f a ≤ 1) : uniformMean f ≤ 1 := by + cases isEmpty_or_nonempty A + · simp [uniformMean] + · exact uniformMean_bound hf +variable [AddCommGroup A] +theorem uniformMean_subLeft (a : A) (f : A → ℝ) : + uniformMean (fun x => f (a-x))=uniformMean f := + uniformMean_equiv (Equiv.subLeft a) f +end Means +section Range +variable {K : Type*} [Field K] [Fintype K] [DecidableEq K] {D : ℕ} +theorem pairRestrictionFraction_range (Q : SymMatrix K D) (r : ℕ) (ξ : ℤ) : + 0 ≤ pairRestrictionFraction Q r ξ ∧ pairRestrictionFraction Q r ξ ≤ 1 := by + let := Fintype.ofFinite (DimSubspace K (Fin D → K) r) + unfold pairRestrictionFraction + exact ⟨uniformMean_nonneg (fun _ => formSignIndicator_nonneg _ _), + uniformMean_le_one (fun _ => formSignIndicator_le_one _ _)⟩ +theorem isotropicRestrictionFraction_range (Q : SymMatrix K D) + (L : LinearMap.BilinForm K (Fin D → K)) (r : ℕ) (ξ : ℤ) : + 0 ≤ isotropicRestrictionFraction Q L r ξ ∧ isotropicRestrictionFraction Q L r ξ ≤ 1 := by + let := Fintype.ofFinite {U : DimSubspace K (Fin D → K) r // L.restrict U.val=0} + unfold isotropicRestrictionFraction + exact ⟨uniformMean_nonneg (fun _ => formSignIndicator_nonneg _ _), + uniformMean_le_one (fun _ => formSignIndicator_le_one _ _)⟩ +omit [DecidableEq K] in +theorem uniformMean_inverse (f : SymMatrix K D → ℝ) : + uniformMean (fun B => f (symmetricInverse D B))=uniformMean f := + uniformMean_equiv (symmetricInverseEquiv D) f + +omit [DecidableEq K] in +theorem uniformMean_inverse_difference (f : SymMatrix K D → SymMatrix K D → ℝ) : + uniformMean (fun B => uniformMean fun C => + f (symmetricInverse D B) (symmetricInverse D B-symmetricInverse D C)) = + uniformMean (fun L => uniformMean fun Q => f Q L) := by + calc + _ = uniformMean (fun B => uniformMean fun T => f (symmetricInverse D B) (symmetricInverse D B-T)) := by + apply uniformMean_congr + intro B + exact uniformMean_inverse (fun T => f (symmetricInverse D B) (symmetricInverse D B-T)) + _ = uniformMean (fun B => uniformMean fun L => f (symmetricInverse D B) L) := by + apply uniformMean_congr + intro B + exact uniformMean_subLeft (symmetricInverse D B) (f (symmetricInverse D B)) + _ = uniformMean (fun Q => uniformMean fun L => f Q L) := + uniformMean_inverse (fun Q => uniformMean fun L => f Q L) + _ = _ := uniformMean_swap _ +end Range +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module Classical Filter +open scoped BigOperators + +theorem scalar_fraction_error (c f m : ℝ) (hc : 0 ≤ c) : + |c*f-m| ≤ |c/2-m|+c*|f-1/2| := by + calc + _ = |(c/2-m)+c*(f-1/2)| := by congr 1; ring + _ ≤ |c/2-m|+|c*(f-1/2)| := abs_add_le _ _ + _ = _ := by rw [abs_mul,abs_of_nonneg hc] +section Error +variable {K : Type*} [Field K] [Fintype K] [DecidableEq K] + +def matrixSplit (r : ℕ) (L : SymMatrix K (2*r)) : Prop := + L.val.det≠0 ∧ discriminantSign L.val.toBilin' + (Matrix.isSymm_toBilin'_iff_isSymm.mpr L.property)=quadraticChar K ((-1 : K)^r) + +noncomputable def pairError (r : ℕ) (ξ ζ : ℤ) (B : SymMatrix K (2*r)) : ℝ := + if B.val.det≠0 then |pairLocal r ξ ζ B-(if pairMatch r ξ ζ B then 2 else 0)| else 0 +noncomputable def tripleError (r : ℕ) (ξ ζ θ : ℤ) (B C : SymMatrix K (2*r)) : ℝ := + if B.val.det≠0 ∧ C.val.det≠0 ∧ (C-B).val.det≠0 then + |tripleLocal r ξ ζ θ B C-(if tripleMatch r ξ ζ θ B C then 8 else 0)| else 0 + +noncomputable def splitFractionError (r : ℕ) (ξ : ℤ) (Q L : SymMatrix K (2*r)) : ℝ := + if matrixSplit r L then |isotropicRestrictionFraction Q L.val.toBilin' r ξ-1/2| else 0 + +theorem splitFractionError_nonneg (r : ℕ) (ξ : ℤ) (Q L : SymMatrix K (2*r)) : + 0 ≤ splitFractionError r ξ Q L := by unfold splitFractionError; split <;> positivity + +theorem pairError_pointwise (r : ℕ) (ξ ζ : ℤ) (B : SymMatrix K (2*r)) : + pairError r ξ ζ B ≤ |pairCoefficient (K := K) r ξ ζ/2-2|+ + pairCoefficient (K := K) r ξ ζ*|pairRestrictionFraction (symmetricInverse (2*r) B) r ξ-1/2| := by + have hc := pairCoefficient_nonneg (K := K) r ξ ζ + unfold pairError + split_ifs with hB hm + · rw [pairLocal_match r ξ ζ B hB hm] + exact scalar_fraction_error _ _ _ hc + · rw [pairLocal_mismatch r ξ ζ B hB hm] + simp only [sub_zero,abs_zero] + positivity + · positivity + +theorem tripleError_pointwise (hK : ringChar K≠2) (r : ℕ) {ξ ζ θ : ℤ} + (hξ : ξ=1 ∨ ξ= -1) (hζ : ζ=1 ∨ ζ= -1) (hθ : θ=1 ∨ θ= -1) + (B C : SymMatrix K (2*r)) : + tripleError r ξ ζ θ B C ≤ |tripleCoefficient (K := K) r ξ ζ θ/2-8|+ + tripleCoefficient (K := K) r ξ ζ θ * splitFractionError r ξ + (symmetricInverse (2*r) B) (symmetricInverse (2*r) B-symmetricInverse (2*r) C) := by + have hc := tripleCoefficient_nonneg (K := K) r ξ ζ θ + have hf := splitFractionError_nonneg r ξ (symmetricInverse (2*r) B) + (symmetricInverse (2*r) B-symmetricInverse (2*r) C) + unfold tripleError + split_ifs with ht hm + · obtain ⟨hB,hC,hBC⟩ := ht + have hs : matrixSplit r (symmetricInverse (2*r) B-symmetricInverse (2*r) C) := by + simp only [matrixSplit,symmetricInverse,hB,hC,ite_false,Submodule.coe_sub] + exact ⟨Matrix.nondegenerate_iff_det_ne_zero.mp + (Matrix.nondegenerate_toBilin'_iff.mp (inverse_difference_nondegenerate (2*r) B C hB hC hBC)), + matching_inverse_difference_split r B C hB hC hBC hξ hζ hθ hm⟩ + rw [tripleLocal_match hK r B C hB hC hBC hξ hζ hθ hm,splitFractionError,ite_eq_left hs] + simp only [symmetricInverse,hB,hC,ite_false,Submodule.coe_sub] + exact scalar_fraction_error _ _ _ hc + · rw [tripleLocal_mismatch r ξ ζ θ B C ht.1 ht.2.1 ht.2.2 hm] + simp only [sub_zero,abs_zero] + positivity + · positivity + +theorem splitFractionError_mean (hK : ringChar K≠2) (r : ℕ) (hr : 1 splitFractionError r ξ Q L) ≤ + Real.sqrt (((r : ℝ)+1)/(Fintype.card K : ℝ)) := by + by_cases h : matrixSplit r L + · simp only [splitFractionError,h,ite_true] + exact isotropicRestrictionFraction_L1 r hr _ + (Matrix.isSymm_toBilin'_iff_isSymm.mpr L.property) + (Matrix.nondegenerate_toBilin'_iff.mpr (Matrix.nondegenerate_iff_det_ne_zero.mpr h.1)) + hK h.2 hξ + · simp only [splitFractionError,h,ite_false,uniformMean_const] + positivity + +theorem pairError_mean (hK : ringChar K≠2) (r : ℕ) (hr : 0 |pairRestrictionFraction Q r ξ-1/2|)] + exact add_le_add le_rfl (mul_le_mul_of_nonneg_left (pairRestrictionFraction_L1 r hr hK hξ) + (pairCoefficient_nonneg (K := K) r ξ ζ)) + +theorem tripleError_mean (hK : ringChar K≠2) (r : ℕ) (hr : 1 uniformMean (fun C => tripleError (K := K) r ξ ζ θ B C)) ≤ + |tripleCoefficient (K := K) r ξ ζ θ/2-8|+ + tripleCoefficient (K := K) r ξ ζ θ * Real.sqrt (((r : ℝ)+1)/(Fintype.card K : ℝ)) := by + apply (uniformMean_mono (fun B => uniformMean_mono (tripleError_pointwise hK r hξ hζ hθ B))).trans + simp_rw [uniformMean_add,uniformMean_const,uniformMean_mul] + rw [uniformMean_inverse_difference] + exact add_le_add le_rfl (mul_le_mul_of_nonneg_left + (uniformMean_bound (splitFractionError_mean hK r hr hξ)) (tripleCoefficient_nonneg (K := K) r ξ ζ θ)) +end Error +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module Classical Filter +open scoped BigOperators +section Bounds +variable {K : Type*} [Field K] [Fintype K] [DecidableEq K] +theorem pairLocal_nonneg (r : ℕ) (ξ ζ : ℤ) (B : SymMatrix K (2*r)) : 0≤pairLocal r ξ ζ B := + uniformMean_nonneg fun _ => mul_nonneg (rankKernel_nonneg ..) (rankKernel_nonneg ..) +theorem tripleLocal_nonneg (r : ℕ) (ξ ζ θ : ℤ) (B C : SymMatrix K (2*r)) : + 0≤tripleLocal r ξ ζ θ B C := + uniformMean_nonneg fun _ => mul_nonneg + (mul_nonneg (rankKernel_nonneg ..) (rankKernel_nonneg ..)) (rankKernel_nonneg ..) +theorem pairError_nonneg (r : ℕ) (ξ ζ : ℤ) (B : SymMatrix K (2*r)) : 0≤pairError r ξ ζ B := by + unfold pairError; split <;> positivity +theorem tripleError_nonneg (r : ℕ) (ξ ζ θ : ℤ) (B C : SymMatrix K (2*r)) : + 0≤tripleError r ξ ζ θ B C := by unfold tripleError; split <;> positivity + +theorem pairLocal_bound (r : ℕ) (ξ ζ : ℤ) (B : SymMatrix K (2*r)) (hB : B.val.det≠0) : + pairLocal r ξ ζ B ≤ pairCoefficient (K := K) r ξ ζ := by + by_cases hm : pairMatch r ξ ζ B + · rw [pairLocal_match r ξ ζ B hB hm] + exact mul_le_of_le_one_right (pairCoefficient_nonneg ..) (pairRestrictionFraction_range _ _ _).2 + · rw [pairLocal_mismatch r ξ ζ B hB hm] + exact pairCoefficient_nonneg .. + +theorem tripleLocal_bound (hK : ringChar K≠2) (r : ℕ) {ξ ζ θ : ℤ} + (hξ : ξ=1 ∨ ξ= -1) (hζ : ζ=1 ∨ ζ= -1) (hθ : θ=1 ∨ θ= -1) + (B C : SymMatrix K (2*r)) (hB : B.val.det≠0) (hC : C.val.det≠0) (hBC : (C-B).val.det≠0) : + tripleLocal r ξ ζ θ B C ≤ tripleCoefficient (K := K) r ξ ζ θ := by + by_cases hm : tripleMatch r ξ ζ θ B C + · rw [tripleLocal_match hK r B C hB hC hBC hξ hζ hθ hm] + exact mul_le_of_le_one_right (tripleCoefficient_nonneg ..) (isotropicRestrictionFraction_range _ _ _ _).2 + · rw [tripleLocal_mismatch r ξ ζ θ B C hB hC hBC hm] + exact tripleCoefficient_nonneg .. +end Bounds + +theorem localFraction_error_tendsto (r : ℕ) : + Tendsto (fun q : OddPrime => Real.sqrt (((r : ℝ)+1)/(q.val : ℝ))) primeInfinity (nhds 0) := by + have h := ((tendsto_inv_atTop_zero (𝕜 := ℝ)).comp primeInfinity_real_tendsto).const_mul ((r : ℝ)+1) + have hs := Real.continuous_sqrt.continuousAt.tendsto.comp h + simpa only [mul_zero,Real.sqrt_zero,Function.comp_def,←div_eq_mul_inv] using hs + +theorem pairError_tendsto (r : ℕ) (hr : 0 uniformMean (pairError (K := ZMod q.val) r ξ ζ)) primeInfinity (nhds 0) := by + have hc := pairCoefficient_tendsto r hr hξ hζ + have ha := ((hc.div_const 2).sub_const 2).abs + have hb := hc.mul (localFraction_error_tendsto r) + have h := ha.add hb + norm_num only at h + apply squeeze_zero (fun q => uniformMean_nonneg (pairError_nonneg r ξ ζ)) (fun q => ?_) h + simpa only [ZMod.card] using pairError_mean (K := ZMod q.val) + (by simpa only [ZMod.ringChar_zmod_n] using q.property.2) r hr hξ + +theorem tripleError_tendsto (r : ℕ) (hr : 1 uniformMean (fun B => uniformMean + (fun C => tripleError (K := ZMod q.val) r ξ ζ θ B C))) primeInfinity (nhds 0) := by + have hc := tripleCoefficient_tendsto r (by omega) hξ hζ hθ + have ha := ((hc.div_const 2).sub_const 8).abs + have hb := hc.mul (localFraction_error_tendsto r) + have h := ha.add hb + norm_num only at h + apply squeeze_zero (fun q => uniformMean_nonneg fun B => uniformMean_nonneg (tripleError_nonneg r ξ ζ θ B)) + (fun q => ?_) h + simpa only [ZMod.card] using tripleError_mean (K := ZMod q.val) + (by simpa only [ZMod.ringChar_zmod_n] using q.property.2) r hr hξ hζ hθ +end SidorenkoCounterexample + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/Monomials.lean b/lean/OAI/Combinatorics/Sidorenko/Monomials.lean new file mode 100644 index 0000000000000000000000000000000000000000..543f18369a61390b0d52116cd74fe41ff0047c18 --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/Monomials.lean @@ -0,0 +1,539 @@ +import OAI.Combinatorics.Sidorenko.SignMoments + +namespace OAI + + +section + +namespace SidorenkoCounterexample +open Module Classical +open scoped BigOperators +section StarMoment +variable {K I J : Type*} [Field K] [Fintype K] [DecidableEq K] + [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] [Nonempty J] {N : ℕ} + +noncomputable def starSign (v : I) (k : J → I) (W : I → SymMatrix K N) + (z : I → (Fin N → K)) (a : I → K) : ℝ := + ∏ j, (quadraticChar K (symmetricBorder (W v-W (k j)) (z v-z (k j)) (a v-a (k j))).val.det : ℝ) + +omit [Fintype I] [DecidableEq I] [DecidableEq J] [Nonempty J] in +theorem starSign_abs_le (v : I) (k : J → I) (W : I → SymMatrix K N) + (z : I → (Fin N → K)) (a : I → K) : |starSign v k W z a| ≤ 1 := + characterProduct_abs_le _ + +omit [Fintype I] in +theorem starSign_update_bound (hK : ringChar K≠2) (v : I) (k : J → I) + (hv : ∀ j, k j≠v) (W : I → SymMatrix K N) (z : I → (Fin N → K)) (a : I → K) + (hW : goodMinors (fun j => W v-W (k j))) : + |uniformMean (fun z' => starSign v k W (Function.update z v z') a)| ≤ + Real.sqrt (1/(Fintype.card K : ℝ)) := by + have he (z' : Fin N → K) : starSign v k W (Function.update z v z') a = + ∏ j, (quadraticChar K (symmetricBorder (W v-W (k j)) (z'-z (k j)) (a v-a (k j))).val.det : ℝ) := by + simp only [starSign,Function.update_self,Function.update_of_ne (hv _)] + simp_rw [he] + apply (Real.le_sqrt (abs_nonneg _) (by positivity)).mpr + rw [sq_abs] + exact schur_sign_moment hK (fun j => W v-W (k j)) hW.1 (fun j => z (k j)) + (fun j => a v-a (k j)) hW.2 + +omit [Fintype I] in +theorem testedStar_update_bound (hK : ringChar K≠2) (v : I) (k : J → I) + (hv : ∀ j, k j≠v) (W : I → SymMatrix K N) (z : I → (Fin N → K)) (a : I → K) + (R : (I → (Fin N → K)) → ℝ) (hR : ∀ z, |R z| ≤ 1) + (hRi : ∀ z', R (Function.update z v z')=R z) : + |uniformMean (fun z' => R (Function.update z v z') * starSign v k W (Function.update z v z') a)| ≤ + Real.sqrt (1/(Fintype.card K : ℝ)) + + (if goodMinors (fun j => W v-W (k j)) then 0 else 1) := by + simp_rw [hRi] + rw [uniformMean_mul,abs_mul] + by_cases hW : goodMinors (fun j => W v-W (k j)) + · rw [ite_eq_left hW,add_zero] + exact (mul_le_of_le_one_left (abs_nonneg _) (hR z)).trans (starSign_update_bound hK v k hv W z a hW) + · rw [ite_eq_right hW] + apply le_trans _ (le_add_of_nonneg_left (Real.sqrt_nonneg _)) + apply (mul_le_of_le_one_left (abs_nonneg _) (hR z)).trans + exact (abs_uniformMean_le _).trans (uniformMean_bound fun z' => starSign_abs_le v k W _ a) + +theorem testedStar_mean_bound (hK : ringChar K≠2) (v : I) (k : J → I) + (hk : Function.Injective k) (hv : ∀ j, k j≠v) (hN : Fintype.card J ≤ N) + (R : (I → SymMatrix K N) → (I → (Fin N → K)) → (I → K) → ℝ) + (hR : ∀ W z a, |R W z a| ≤ 1) + (hRi : ∀ W z a z', R W (Function.update z v z') a=R W z a) : + |uniformMean (fun W => uniformMean fun a => uniformMean fun z => R W z a * starSign v k W z a)| ≤ + Real.sqrt (1/(Fintype.card K : ℝ)) + minorBadBound N (Fintype.card J) (Fintype.card K) := by + have hpoint (W : I → SymMatrix K N) (a : I → K) : + |uniformMean (fun z => R W z a * starSign v k W z a)| ≤ + Real.sqrt (1/(Fintype.card K : ℝ)) + + (if goodMinors (fun j => W v-W (k j)) then 0 else 1) := by + rw [uniformMean_update v] + apply (abs_uniformMean_le _).trans + exact uniformMean_bound (fun z => testedStar_update_bound hK v k hv W z a (fun z => R W z a) + (fun z => hR W z a) (hRi W z a)) + apply (abs_uniformMean_le _).trans + calc + _ ≤ uniformMean (fun W : I → SymMatrix K N => Real.sqrt (1/(Fintype.card K : ℝ)) + + (if goodMinors (fun j => W v-W (k j)) then 0 else 1)) := by + apply uniformMean_mono + intro W + exact (abs_uniformMean_le _).trans (uniformMean_bound (hpoint W)) + _ = Real.sqrt (1/(Fintype.card K : ℝ)) + + uniformMean (fun M : J → SymMatrix K N => if goodMinors M then 0 else 1) := by + rw [uniformMean_add,uniformMean_const] + congr 1 + exact uniformMean_starDifference (K := K) v k hk hv + (fun M : J → SymMatrix K N => if goodMinors M then 0 else 1) + _ ≤ _ := add_le_add le_rfl (badMinors_bound (K := K) hN) +end StarMoment +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module Classical +open scoped BigOperators + +def pairLeft : Fin 33 → Fin 13 := ![0,0,2,0,2,0,1,2,3,1,4,1,3,3,4,1,9,4,8,1,7,10,8,7,8,5,5,5,6,6,6,6,5] +def pairRight : Fin 33 → Fin 13 := ![2,3,3,9,9,1,3,4,4,9,9,10,10,11,11,12,12,8,9,7,10,11,11,12,12,7,10,11,8,11,7,12,6] +theorem pair_endpoints : ∀ e, pairVertices e={pairLeft e,pairRight e} := by decide +theorem pair_endpoints_ne : ∀ e, pairLeft e≠pairRight e := by decide + +def pairOther (v : Fin 13) (e : Fin 33) : Fin 13 := if pairLeft e=v then pairRight e else pairLeft e + +theorem pairOther_ne (v : Fin 13) (e : Fin 33) (_hv : v∈pairVertices e) : pairOther v e≠v := by + unfold pairOther + split_ifs with h + · simpa only [h] using (pair_endpoints_ne e).symm + · exact h + +theorem pair_vertices_other (v : Fin 13) (e : Fin 33) (hv : v∈pairVertices e) : + pairVertices e={v,pairOther v e} := by + rw [pair_endpoints] at hv ⊢ + simp only [Finset.mem_insert,Finset.mem_singleton] at hv + unfold pairOther + split_ifs with h + · rw [h] + · rcases hv with h' | h' + · exact (h h'.symm).elim + · rw [h']; exact Finset.pair_comm _ _ + +def selectedIncident (F : Finset (Fin 33)) (v : Fin 13) : Finset (Fin 33) := + F.filter (fun e => v∈pairVertices e) + +theorem selectedIncident_card (F : Finset (Fin 33)) (v : Fin 13) : (selectedIncident F v).card ≤ 6 := by + apply le_trans (Finset.card_le_card ?_) (incidentPairs_card_le v) + intro e he + exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,(Finset.mem_filter.mp he).2⟩ + +theorem pairOther_injective (F : Finset (Fin 33)) (v : Fin 13) : + Function.Injective (fun e : selectedIncident F v => pairOther v e.val) := by + intro e f h + dsimp only at h + apply Subtype.ext + apply pairVertices_injective + rw [pair_vertices_other v e.val (Finset.mem_filter.mp e.property).2, + pair_vertices_other v f.val (Finset.mem_filter.mp f.property).2,h] + +section Signs +variable {K : Type*} [Field K] [Fintype K] [DecidableEq K] {D : ℕ} +noncomputable def pairSign (X : Fin 13 → SymMatrix K D) (e : Fin 33) : ℝ := + quadraticChar K (X (pairLeft e)-X (pairRight e)).val.det + +theorem pairSign_abs_le (X : Fin 13 → SymMatrix K D) (e : Fin 33) : |pairSign X e| ≤ 1 := by + unfold pairSign + by_cases h : (X (pairLeft e)-X (pairRight e)).val.det=0 + · rw [h]; norm_num + · rcases quadraticChar_dichotomy (F := K) h with h | h <;> rw [h] <;> norm_num + +omit [Fintype K] [DecidableEq K] in +theorem determinant_difference_even (hD : Even D) (A B : SymMatrix K D) : + (A-B).val.det=(B-A).val.det := by + have he : A-B= -(B-A) := by abel + rw [he,Submodule.coe_neg,Matrix.det_neg,Fintype.card_fin,hD.neg_pow,one_pow,one_mul] + +theorem pairSign_other (hD : Even D) (X : Fin 13 → SymMatrix K D) + (v : Fin 13) (e : Fin 33) (hv : v∈pairVertices e) : + pairSign X e=quadraticChar K (X v-X (pairOther v e)).val.det := by + rw [pair_endpoints] at hv + simp only [Finset.mem_insert,Finset.mem_singleton] at hv + unfold pairSign pairOther + split_ifs with h + · rw [h] + · rcases hv with h' | h' + · exact (h h'.symm).elim + · rw [h',determinant_difference_even hD] + +theorem pairSign_product_abs_le (F : Finset (Fin 33)) (X : Fin 13 → SymMatrix K D) : + |∏ e∈F, pairSign X e| ≤ 1 := by + rw [Finset.abs_prod] + exact Finset.prod_le_one₀ (fun e _ => abs_nonneg _) (fun e _ => pairSign_abs_le X e) +end Signs +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module Classical Filter +open scoped BigOperators +section Moment +variable {K : Type*} [Field K] [Fintype K] [DecidableEq K] {N : ℕ} + +noncomputable def nonincidentProduct (F : Finset (Fin 33)) (v : Fin 13) + (W : Fin 13 → SymMatrix K N) (z : Fin 13 → (Fin N → K)) (a : Fin 13 → K) : ℝ := + ∏ e∈F\selectedIncident F v, pairSign (fun i => symmetricBorder (W i) (z i) (a i)) e + +theorem nonincidentProduct_abs_le (F : Finset (Fin 33)) (v : Fin 13) + (W : Fin 13 → SymMatrix K N) (z : Fin 13 → (Fin N → K)) (a : Fin 13 → K) : + |nonincidentProduct F v W z a| ≤ 1 := pairSign_product_abs_le _ _ + +theorem nonincidentProduct_update (F : Finset (Fin 33)) (v : Fin 13) + (W : Fin 13 → SymMatrix K N) (z : Fin 13 → (Fin N → K)) (a : Fin 13 → K) + (z' : Fin N → K) : nonincidentProduct F v W (Function.update z v z') a= + nonincidentProduct F v W z a := by + apply Finset.prod_congr rfl + intro e he + obtain ⟨heF,heN⟩ := Finset.mem_sdiff.mp he + have hv : v∉pairVertices e := by + intro h + exact heN (Finset.mem_filter.mpr ⟨heF,h⟩) + have hl : pairLeft e≠v := by + intro h; apply hv; rw [pair_endpoints, h]; simp + have hr : pairRight e≠v := by + intro h; apply hv; rw [pair_endpoints, h]; simp + simp only [pairSign,Function.update_of_ne hl,Function.update_of_ne hr] + +theorem pairSign_product_split (hN : Even (N+1)) (F : Finset (Fin 33)) (v : Fin 13) + (W : Fin 13 → SymMatrix K N) (z : Fin 13 → (Fin N → K)) (a : Fin 13 → K) : + (∏ e∈F, pairSign (fun i => symmetricBorder (W i) (z i) (a i)) e)= + nonincidentProduct F v W z a * starSign v + (fun e : selectedIncident F v => pairOther v e.val) W z a := by + have he : starSign v (fun e : selectedIncident F v => pairOther v e.val) W z a= + ∏ e∈selectedIncident F v, pairSign (fun i => symmetricBorder (W i) (z i) (a i)) e := by + rw [←Finset.prod_coe_sort] + apply Finset.prod_congr rfl + intro e _ + rw [pairSign_other hN _ v e.val (Finset.mem_filter.mp e.property).2] + rw [symmetricBorder_sub] + rw [he] + exact (Finset.prod_sdiff (Finset.filter_subset _ _)).symm + +theorem pairSign_moment_bound (hK : ringChar K≠2) (hN : Even (N+1)) + (F : Finset (Fin 33)) (v : Fin 13) (hne : (selectedIncident F v).Nonempty) + (hc : (selectedIncident F v).card ≤ N) : + |uniformMean (fun X : Fin 13 → SymMatrix K (N+1) => ∏ e∈F, pairSign X e)| ≤ + Real.sqrt (1/(Fintype.card K : ℝ)) + + minorBadBound N (selectedIncident F v).card (Fintype.card K) := by + let : Nonempty (selectedIncident F v) := ⟨⟨hne.choose,hne.choose_spec⟩⟩ + rw [uniformMean_bordered] + simp_rw [pairSign_product_split hN F v] + have he (W : Fin 13 → SymMatrix K N) := uniformMean_swap + (fun z a => nonincidentProduct F v W z a * starSign v + (fun e : selectedIncident F v => pairOther v e.val) W z a) + simp_rw [he] + simpa only [Fintype.card_coe] using testedStar_mean_bound hK v _ (pairOther_injective F v) + (fun e => pairOther_ne v e.val (Finset.mem_filter.mp e.property).2) + (by simpa using hc) (nonincidentProduct F v) + (nonincidentProduct_abs_le F v) (nonincidentProduct_update F v) +end Moment + + theorem minorBadBound_tendsto (N s : ℕ) (h : s<(N-s+1).choose 2) : + Tendsto (minorBadBound N s) atTop (nhds 0) := by + have ha : Tendsto (fun q : ℝ => (s : ℝ)*N/q) atTop (nhds 0) := by + simpa only [mul_zero,div_eq_mul_inv] using + (tendsto_inv_atTop_zero (𝕜 := ℝ)).const_mul ((s : ℝ)*N) + have hb : Tendsto (fun q : ℝ => q^s*(2^(N-s)/q^((N-s+1).choose 2))) atTop (nhds 0) := by + have ht := (inverse_power_tendsto_zero ((N-s+1).choose 2-s) (by omega)).const_mul ((2 : ℝ)^(N-s)) + simp only [mul_zero] at ht + apply ht.congr' (eventually_atTop.mpr ⟨1,fun q hq => ?_⟩) + have hq0 : q≠0 := by linarith + have hn : (N-s+1).choose 2=s+((N-s+1).choose 2-s) := by omega + rw [hn,pow_add] + field_simp + congr 1; omega + change Tendsto (fun q : ℝ => (s : ℝ)*N/q + q^s*(2^(N-s)/q^((N-s+1).choose 2))) atTop (nhds 0) + simpa only [add_zero] using ha.add hb + + theorem sign_moment_dimension (N s : ℕ) (hN : 11≤N) (hs : s≤6) : + s≤N ∧ s<(N-s+1).choose 2 := by + have hd : 6≤N-s+1 := by omega + have hc := Nat.choose_le_choose 2 hd + rw [show (6:ℕ).choose 2=15 by decide] at hc + omega + +theorem pairSign_moment_tendsto (D : ℕ) (hD : Even D) (hbig : 12≤D) + (F : Finset (Fin 33)) (hF : F.Nonempty) : + Tendsto (fun q : OddPrime => uniformMean (fun X : Fin 13 → SymMatrix (ZMod q.val) D => + ∏ e∈F, pairSign X e)) primeInfinity (nhds 0) := by + obtain ⟨e,he⟩ := hF + let v := pairLeft e + have hi : (selectedIncident F v).Nonempty := by + refine ⟨e,Finset.mem_filter.mpr ⟨he,?_⟩⟩ + rw [pair_endpoints]; exact Finset.mem_insert_self _ _ + have hn : D=D-1+1 := by omega + have hn' : Even (D-1+1) := hn ▸ hD + have hc := sign_moment_dimension (D-1) (selectedIncident F v).card (by omega) (selectedIncident_card F v) + have ht : Tendsto (fun q : OddPrime => Real.sqrt (1/(q.val : ℝ)) + + minorBadBound (D-1) (selectedIncident F v).card q.val) primeInfinity (nhds 0) := by + have ha := Real.continuous_sqrt.continuousAt.tendsto.comp + ((inverse_power_tendsto_zero 1 (by omega)).comp primeInfinity_real_tendsto) + simpa only [pow_one,Real.sqrt_zero,add_zero,Function.comp_def] using ha.add + ((minorBadBound_tendsto (D-1) _ hc.2).comp primeInfinity_real_tendsto) + apply squeeze_zero_norm (fun q => ?_) ht + rw [Real.norm_eq_abs] + conv_lhs => rw [hn] + simpa only [ZMod.card] using pairSign_moment_bound + (K := ZMod q.val) (by simpa only [ZMod.ringChar_zmod_n] using q.property.2) hn' F v hi hc.1 +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Classical Filter +open scoped BigOperators +section Product +variable {I : Type*} [DecidableEq I] +omit [DecidableEq I] in +theorem abs_prod_le_pow (s : Finset I) (f : I → ℝ) {C : ℝ} (_hC : 0≤C) + (hf : ∀ i∈s, |f i|≤C) : |∏ i∈s, f i|≤C^s.card := by + rw [Finset.abs_prod,←Finset.prod_const] + exact Finset.prod_le_prod₀ (fun _ _ => abs_nonneg _) hf + +theorem product_difference_bound (s : Finset I) (f g : I → ℝ) {C : ℝ} (hC : 1≤C) + (hf : ∀ i∈s, |f i|≤C) (hg : ∀ i∈s, |g i|≤C) : + |(∏ i∈s, f i)-(∏ i∈s, g i)| ≤ C^s.card * ∑ i∈s, |f i-g i| := by + induction s using Finset.induction_on with + | empty => simp + | @insert a s ha ih => + have hC0 : 0≤C := le_trans (by norm_num) hC + have hf' := fun i hi => hf i (Finset.mem_insert_of_mem hi) + have hg' := fun i hi => hg i (Finset.mem_insert_of_mem hi) + specialize ih hf' hg' + rw [Finset.prod_insert ha,Finset.prod_insert ha,Finset.card_insert_of_notMem ha, + Finset.sum_insert ha,pow_succ] + calc + _ = |f a*((∏ i∈s, f i)-(∏ i∈s, g i)) + (f a-g a)*(∏ i∈s, g i)| := by congr 1; ring + _ ≤ |f a*((∏ i∈s, f i)-(∏ i∈s, g i))| + |(f a-g a)*(∏ i∈s, g i)| := abs_add_le _ _ + _ = |f a| * |(∏ i∈s, f i)-(∏ i∈s, g i)| + |f a-g a| * |∏ i∈s, g i| := by simp only [abs_mul] + _ ≤ C*(C^s.card*∑ i∈s, |f i-g i|) + |f a-g a| * C^s.card := + add_le_add (mul_le_mul (hf a (Finset.mem_insert_self ..)) ih (abs_nonneg _) hC0) + (mul_le_mul_of_nonneg_left (abs_prod_le_pow s g hC0 hg') (abs_nonneg _)) + _ ≤ _ := by + have h : |f a-g a| * C^s.card ≤ C*(|f a-g a| * C^s.card) := + le_mul_of_one_le_left (mul_nonneg (abs_nonneg _) (pow_nonneg hC0 _)) hC + nlinarith + +theorem product_difference_unit (s : Finset I) (f g : I → ℝ) + (hf : ∀ i∈s, |f i|≤1) (hg : ∀ i∈s, |g i|≤1) : + |(∏ i∈s, f i)-(∏ i∈s, g i)| ≤ ∑ i∈s, |f i-g i| := by + simpa only [one_pow,one_mul] using product_difference_bound s f g (le_refl 1) hf hg +end Product +section Mean +variable {I A : Type*} [Fintype I] [DecidableEq I] [Fintype A] +omit [Fintype I] [DecidableEq I] in +theorem uniformMean_finset_sum (s : Finset I) (f : I → A → ℝ) : + uniformMean (fun a => ∑ i∈s, f i a)=∑ i∈s, uniformMean (f i) := by + unfold uniformMean + rw [Finset.sum_comm,Finset.sum_div] + +theorem uniformMean_pi_product (f : I → A → ℝ) : + uniformMean (fun x : I → A => ∏ i, f i (x i))=∏ i, uniformMean (f i) := by + unfold uniformMean + rw [←Fintype.prod_sum,Finset.prod_div_distrib,Finset.prod_const,Finset.card_univ, + Fintype.card_fun,Nat.cast_pow] +end Mean +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module Classical Filter +open scoped BigOperators +section Difference +variable {K I W : Type*} [Field K] [Fintype I] [DecidableEq I] + [AddCommGroup W] [Module K W] [Fintype W] +include K in +theorem uniformMean_point_difference (i k : I) (hik : i≠k) (f : W → ℝ) : + uniformMean (fun X : I → W => f (X i-X k))=uniformMean f := by + let L : (I → W) →ₗ[K] W := + { toFun := fun X => X i-X k + map_add' := by intros; simp only [Pi.add_apply]; abel + map_smul' := by intros; simp only [Pi.smul_apply,smul_sub,RingHom.id_apply] } + have hL : Function.Surjective L := by + intro w + refine ⟨Function.update 0 i w,?_⟩ + change (Function.update (0 : I → W) i w) i-(Function.update (0 : I → W) i w) k=w + simp [Function.update_of_ne hik.symm] + exact uniformMean_surjective_linear L hL f +end Difference +section Pair +variable {K : Type*} [Field K] [Fintype K] [DecidableEq K] {D : ℕ} +noncomputable def pairSingular (X : Fin 13 → SymMatrix K D) (e : Fin 33) : ℝ := + if (X (pairLeft e)-X (pairRight e)).val.det=0 then 1 else 0 + +omit [Fintype K] in +theorem pairSingular_nonneg (X : Fin 13 → SymMatrix K D) (e : Fin 33) : 0≤pairSingular X e := by + unfold pairSingular; split <;> norm_num + +theorem pairSingular_mean (e : Fin 33) : + uniformMean (fun X : Fin 13 → SymMatrix K D => pairSingular X e)≤(D : ℝ)/Fintype.card K := by + unfold pairSingular + rw [uniformMean_point_difference (K := K) _ _ (pair_endpoints_ne e) + (fun B : SymMatrix K D => if B.val.det=0 then 1 else 0)] + exact symmetricSingularProb_bound D + +def fullTransverse (X : Fin 13 → SymMatrix K D) : Prop := + ∀ e : Fin 33, (X (pairLeft e)-X (pairRight e)).val.det≠0 + +omit [Fintype K] in +theorem nonTransverse_pointwise (X : Fin 13 → SymMatrix K D) : + (if fullTransverse X then 0 else 1 : ℝ) ≤ ∑ e, pairSingular X e := by + by_cases h : fullTransverse X + · rw [ite_eq_left h]; exact Finset.sum_nonneg fun e _ => pairSingular_nonneg X e + · rw [ite_eq_right h] + obtain ⟨e,he⟩ := not_forall.mp h + have he := not_not.mp he + calc + (1 : ℝ) = pairSingular X e := by rw [pairSingular,ite_eq_left he] + _ ≤ _ := Finset.single_le_sum (fun e _ => pairSingular_nonneg X e) (Finset.mem_univ e) + +theorem nonTransverse_mean : + uniformMean (fun X : Fin 13 → SymMatrix K D => if fullTransverse X then 0 else 1) ≤ + 33*((D : ℝ)/Fintype.card K) := by + apply (uniformMean_mono nonTransverse_pointwise).trans + rw [uniformMean_sum] + calc + _ ≤ ∑ _e : Fin 33, (D : ℝ)/Fintype.card K := Finset.sum_le_sum fun e _ => pairSingular_mean e + _ = _ := by simp + +noncomputable def pairBool (X : Fin 13 → SymMatrix K D) (e : Fin 33) : Bool := + decide (pairSign X e=1) + +def boolSign (b : Bool) : ℝ := if b then 1 else -1 +@[simp] theorem boolSign_abs (b : Bool) : |boolSign b|=1 := by cases b <;> norm_num [boolSign] +@[simp] theorem boolSign_sq (b : Bool) : boolSign b^2=1 := by cases b <;> norm_num [boolSign] + +theorem pairBool_error (X : Fin 13 → SymMatrix K D) (e : Fin 33) : + |boolSign (pairBool X e)-pairSign X e| ≤ pairSingular X e := by + by_cases hz : (X (pairLeft e)-X (pairRight e)).val.det=0 + · have he : pairSign X e=0 := by unfold pairSign; rw [hz]; norm_num + rw [pairSingular,ite_eq_left hz,he] + simp + · have he : pairSign X e=1 ∨ pairSign X e= -1 := by + unfold pairSign + rcases quadraticChar_dichotomy (F := K) hz with h | h <;> rw [h] <;> norm_num + rw [pairSingular,ite_eq_right hz] + rcases he with he | he <;> norm_num [pairBool,he,boolSign] + +theorem pairBool_moment_error (F : Finset (Fin 33)) : + |uniformMean (fun X : Fin 13 → SymMatrix K D => ∏ e∈F, boolSign (pairBool X e))- + uniformMean (fun X : Fin 13 → SymMatrix K D => ∏ e∈F, pairSign X e)| ≤ + (F.card : ℝ)*((D : ℝ)/Fintype.card K) := by + rw [←uniformMean_sub] + apply (abs_uniformMean_le _).trans + calc + _ ≤ uniformMean (fun X : Fin 13 → SymMatrix K D => ∑ e∈F, pairSingular X e) := by + apply uniformMean_mono + intro X + exact (product_difference_unit F _ _ (by simp) (fun e _ => pairSign_abs_le X e)).trans + (Finset.sum_le_sum fun e _ => pairBool_error X e) + _ = ∑ e∈F, uniformMean (fun X : Fin 13 → SymMatrix K D => pairSingular X e) := uniformMean_finset_sum _ _ + _ ≤ ∑ _e∈F, (D : ℝ)/Fintype.card K := Finset.sum_le_sum fun e _ => pairSingular_mean e + _ = _ := by simp +end Pair + +theorem pairBool_moment_tendsto (D : ℕ) (hD : Even D) (hbig : 12≤D) + (F : Finset (Fin 33)) (hF : F.Nonempty) : + Tendsto (fun q : OddPrime => uniformMean (fun X : Fin 13 → SymMatrix (ZMod q.val) D => + ∏ e∈F, boolSign (pairBool X e))) primeInfinity (nhds 0) := by + have hm := pairSign_moment_tendsto D hD hbig F hF + have hb : Tendsto (fun q : OddPrime => (F.card : ℝ)*((D : ℝ)/(q.val : ℝ))) primeInfinity (nhds 0) := by + simpa only [mul_zero,Function.comp_def,div_eq_mul_inv] using + (((tendsto_inv_atTop_zero (𝕜 := ℝ)).comp primeInfinity_real_tendsto).const_mul (D : ℝ)).const_mul (F.card : ℝ) + have he : Tendsto (fun q : OddPrime => + uniformMean (fun X : Fin 13 → SymMatrix (ZMod q.val) D => ∏ e∈F, boolSign (pairBool X e))- + uniformMean (fun X : Fin 13 → SymMatrix (ZMod q.val) D => ∏ e∈F, pairSign X e)) primeInfinity (nhds 0) := by + apply squeeze_zero_norm (fun q => ?_) hb + simpa only [Real.norm_eq_abs,ZMod.card] using pairBool_moment_error (K := ZMod q.val) (D := D) F + simpa only [sub_add_cancel,add_zero] using he.add hm +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module Classical +open scoped BigOperators +section Graph +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] +noncomputable def fullGraphIntersection (B C : LinearMap.BilinForm K V) : + (B-C).ker ≃ₗ[K] ↥(B.graph⊓C.graph) where + toFun x := ⟨(x.val,B x.val),by + constructor + · rfl + · apply (C.mem_graph_iff _).mpr + exact sub_eq_zero.mp (show B x.val-C x.val=0 from x.property)⟩ + invFun x := ⟨x.val.1,by + have hb := (B.mem_graph_iff _).mp x.property.1 + have hc := (C.mem_graph_iff _).mp x.property.2 + change B x.val.1-C x.val.1=0 + rw [←hb,←hc,sub_self]⟩ + left_inv x := rfl + right_inv x := by + apply Subtype.ext + exact Prod.ext rfl ((B.mem_graph_iff _).mp x.property.1).symm + map_add' x y := by apply Subtype.ext; simp + map_smul' c x := by apply Subtype.ext; simp + +noncomputable def matrixLagrangian {D : ℕ} (M : SymMatrix K D) : + SymplecticLagrangian (canonicalSymplectic (K := K) (V := Fin D → K)) := + ⟨M.val.toBilin'.graph, fullGraph_selforthogonal _ (Matrix.isSymm_toBilin'_iff_isSymm.mpr M.property)⟩ + +theorem matrixLagrangian_injective (D : ℕ) : Function.Injective (matrixLagrangian (K := K) (D := D)) := by + intro A B h + apply Subtype.ext + apply Matrix.toBilin'.injective + exact fullGraph_injective (congrArg Subtype.val h) + +theorem matrixLagrangian_pair_rank (D : ℕ) (A B : SymMatrix K D) : + finrank K ↥((matrixLagrangian A).val⊓(matrixLagrangian B).val)+(A-B).val.rank=D := by + have h := ((A-B).val.toBilin').ker.finrank_quotient_add_finrank + rw [matrix_radical_quotient_rank] at h + have he := (fullGraphIntersection A.val.toBilin' B.val.toBilin').finrank_eq + have hf : (A-B).val.toBilin'=A.val.toBilin'-B.val.toBilin' := by rw [Submodule.coe_sub,map_sub] + rw [hf] at h + simp only [Module.finrank_pi,Fintype.card_fin] at h + change finrank K ↥(A.val.toBilin'.graph⊓B.val.toBilin'.graph)+(A-B).val.rank=D + omega + +theorem matrixLagrangian_pair_zero (D : ℕ) (A B : SymMatrix K D) : + finrank K ↥((matrixLagrangian A).val⊓(matrixLagrangian B).val)=0 ↔ (A-B).val.det≠0 := by + change finrank K ↥(A.val.toBilin'.graph⊓B.val.toBilin'.graph)=0 ↔ (A-B).val.det≠0 + rw [← (fullGraphIntersection A.val.toBilin' B.val.toBilin').finrank_eq] + have hf : (A-B).val.toBilin'=A.val.toBilin'-B.val.toBilin' := by rw [Submodule.coe_sub,map_sub] + rw [←hf,Submodule.finrank_eq_zero] + exact LinearMap.BilinForm.nondegenerate_iff_ker_eq_bot.symm.trans + (Matrix.nondegenerate_toBilin'_iff.trans Matrix.nondegenerate_iff_det_ne_zero) +end Graph +end SidorenkoCounterexample + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/Normalization.lean b/lean/OAI/Combinatorics/Sidorenko/Normalization.lean new file mode 100644 index 0000000000000000000000000000000000000000..7734c673150fb85793d8988d511b3240c2de8d7a --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/Normalization.lean @@ -0,0 +1,422 @@ +import OAI.Combinatorics.Sidorenko.Restrictions + +namespace OAI + + +section + +namespace SidorenkoCounterexample +open scoped BigOperators +open Module Filter + +noncomputable def grassmannFactor (D k : ℕ) (q : ℝ) : ℝ := + ∏ i : Fin k, (1 - 1 / q^(D-i.val)) / (1 - 1 / q^(k-i.val)) + +theorem grassmann_single_factor (D k i : ℕ) (hik : i ≤ k) (hkD : k ≤ D) + (q : ℝ) (hq : q ≠ 0) : + (q^D - q^i)/(q^k-q^i) = q^(D-k) * + ((1 - 1/q^(D-i)) / (1 - 1/q^(k-i))) := by + have hf (n : ℕ) (hi : i ≤ n) : q^n-q^i=q^n*(1-1/q^(n-i)) := by + rw [mul_sub, mul_one, mul_one_div, div_eq_mul_inv, + ← pow_sub₀ q hq (Nat.sub_le n i), Nat.sub_sub_self hi] + rw [hf D (hik.trans hkD), hf k hik, mul_div_mul_comm, + div_eq_mul_inv (q^D), ← pow_sub₀ q hq hkD] + +theorem subspace_count_normalized {K V : Type*} [Field K] [AddCommGroup V] + [Module K V] [Fintype K] [Finite V] (k : ℕ) (hk : k ≤ finrank K V) : + (Nat.card (DimSubspace K V k) : ℝ) = + (Fintype.card K : ℝ)^(k*(finrank K V-k)) * + grassmannFactor (finrank K V) k (Fintype.card K) := by + rw [subspace_count_real k hk] + have hf (i : Fin k) := grassmann_single_factor (finrank K V) k i.val i.isLt.le hk + (Fintype.card K : ℝ) (Nat.cast_ne_zero.mpr Fintype.card_ne_zero) + simp_rw [hf] + rw [Finset.prod_mul_distrib, Finset.prod_const, Finset.card_univ, + Fintype.card_fin, ← pow_mul, Nat.mul_comm (finrank K V-k) k] + rfl + +theorem inverse_power_tendsto_zero (n : ℕ) (hn : 0 1/q^n) atTop (nhds 0) := by + simpa only [one_div, inv_pow, zero_pow (Nat.ne_zero_of_lt hn)] using + (tendsto_inv_atTop_zero (𝕜 := ℝ)).pow n + +theorem grassmannFactor_tendsto (D k : ℕ) (hk : k ≤ D) : + Tendsto (grassmannFactor D k) atTop (nhds 1) := by + unfold grassmannFactor + have h (i : Fin k) : Tendsto (fun q : ℝ => + (1 - 1/q^(D-i.val))/(1-1/q^(k-i.val))) atTop (nhds 1) := by + have hD := inverse_power_tendsto_zero (D-i.val) (by omega) + have hk' := inverse_power_tendsto_zero (k-i.val) (by omega) + have ha : Tendsto (fun q : ℝ => 1-1/q^(D-i.val)) atTop (nhds (1-0:ℝ)) := + tendsto_const_nhds.sub hD + have hb : Tendsto (fun q : ℝ => 1-1/q^(k-i.val)) atTop (nhds (1-0:ℝ)) := + tendsto_const_nhds.sub hk' + have hc : Tendsto (fun q : ℝ => + (1-1/q^(D-i.val))/(1-1/q^(k-i.val))) atTop (nhds ((1-0:ℝ)/(1-0))) := + (ha.div hb (by norm_num)).congr (fun _ => rfl) + simpa only [sub_zero, div_self (one_ne_zero : (1:ℝ) ≠ 0)] using hc + simpa using tendsto_finsetProd Finset.univ (fun i _ => h i) + +theorem triangular_nat_add (r k : ℕ) : + (r+k+1).choose 2 = (r+1).choose 2 + (k+1).choose 2 + r*k := by + have h : (((r+k+1).choose 2 : ℕ) : ℚ) = + ((r+1).choose 2 : ℚ) + ((k+1).choose 2 : ℚ) + (r:ℚ)*k := by + simp only [Nat.cast_choose_two, Nat.cast_add, Nat.cast_one] + ring + exact_mod_cast h + +theorem layerMass_normalized {K : Type*} [Field K] [Fintype K] [DecidableEq K] + (D r : ℕ) (hrD : r ≤ D) {ξ : ℤ} (hξ : ξ = 1 ∨ ξ = -1) : + layerMass K D r ξ * (Fintype.card K : ℝ)^((D-r+1).choose 2) = + grassmannFactor D (D-r) (Fintype.card K) * symmetricSignProb (K := K) r ξ := by + rw [layerMass_exact D r hrD hξ, subspace_count_normalized _ (by simp)] + simp only [Module.finrank_pi, Fintype.card_fin, Nat.sub_sub_self hrD] + have he : (D+1).choose 2 = (r+1).choose 2 + (D-r+1).choose 2 + (D-r)*r := by + simpa only [Nat.add_sub_of_le hrD, Nat.mul_comm r (D-r)] using triangular_nat_add r (D-r) + rw [he, pow_add, pow_add] + have hq : (Fintype.card K : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr Fintype.card_ne_zero + field_simp + +theorem primeInfinity_real_tendsto : + Tendsto (fun q : OddPrime => (q.val : ℝ)) primeInfinity atTop := + tendsto_natCast_atTop_atTop.comp Filter.tendsto_comap + +theorem symmetricSignProb_tendsto (r : ℕ) (hr : 0 symmetricSignProb (K := ZMod q.val) r ξ) + primeInfinity (nhds (1/2)) := by + rw [tendsto_iff_norm_sub_tendsto_zero] + have hlim : Tendsto (fun q : OddPrime => (r:ℝ)/q.val) primeInfinity (nhds 0) := by + simpa only [div_eq_mul_inv,mul_zero, Function.comp_def] using + ((tendsto_inv_atTop_zero (𝕜 := ℝ)).comp primeInfinity_real_tendsto).const_mul (r:ℝ) + apply squeeze_zero (fun _ => norm_nonneg _) _ hlim + intro q + simpa only [Real.norm_eq_abs,ZMod.card] using + symmetricSignProb_error (K := ZMod q.val) r hr + (by simpa only [ZMod.ringChar_zmod_n] using q.property.2) hξ + +theorem layerMass_tendsto (D r : ℕ) (hr : 0 layerMass (ZMod q.val) D r ξ * + (q.val:ℝ)^((D-r+1).choose 2)) primeInfinity (nhds (1/2)) := by + have he (q : OddPrime) := layerMass_normalized (K := ZMod q.val) D r hrD hξ + simp only [ZMod.card] at he + simp_rw [he] + simpa only [one_mul, Function.comp_def] using + ((grassmannFactor_tendsto D (D-r) (Nat.sub_le ..)).comp + primeInfinity_real_tendsto).mul (symmetricSignProb_tendsto r hr hξ) + +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module Filter Topology +open scoped BigOperators +section CountDimension +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] [Fintype K] [Finite V] +theorem maxOrthogonal_card_by_dimension (hK : ringChar K ≠ 2) : + Nat.card (MaxOrthogonal (K := K) (V := V)) = + ∑ k : Fin (finrank K V+1), Nat.card (DimSubspace K V k.val) * + Fintype.card K ^ k.val.choose 2 := by + classical + let := Fintype.ofFinite (Submodule K V) + let d : Submodule K V → Fin (finrank K V+1) := + fun U => ⟨finrank K U,Nat.lt_succ_of_le (Submodule.finrank_le U)⟩ + rw [maxOrthogonal_card_sum hK,← Fintype.sum_fiberwise d] + apply Finset.sum_congr rfl + intro k _ + have hc : Nat.card {U : Submodule K V // d U = k} = Nat.card (DimSubspace K V k.val) := + Nat.card_congr (Equiv.subtypeEquivRight (fun U => by + change (⟨finrank K U,_⟩ : Fin _)=k ↔ finrank K U=k.val + exact Fin.ext_iff)) + have he (U : {U : Submodule K V // d U = k}) : finrank K U.val = k.val := + congrArg Fin.val U.property + simp only [he,Finset.sum_const,Finset.card_univ,nsmul_eq_mul,←Nat.card_eq_fintype_card,hc,Nat.cast_id] +end CountDimension + +noncomputable def orthogonalFactor (r : ℕ) (q : ℝ) : ℝ := + ∑ k : Fin (r+1), grassmannFactor r k.val q / q^((r-k.val).choose 2) + +theorem choose_two_add (a b : ℕ) : (a+b).choose 2 = a.choose 2+b.choose 2+a*b := by + have h : (((a+b).choose 2 : ℕ) : ℚ) = (a.choose 2 : ℚ)+(b.choose 2 : ℚ)+(a:ℚ)*b := by + simp only [Nat.cast_choose_two, Nat.cast_add] + ring + exact_mod_cast h + +theorem maxOrthogonal_normalized {K : Type*} [Field K] [Fintype K] + (hK : ringChar K ≠ 2) (r : ℕ) : + (Nat.card (MaxOrthogonal (K := K) (V := Fin r → K)) : ℝ) / + (Fintype.card K : ℝ)^r.choose 2 = orthogonalFactor r (Fintype.card K) := by + classical + rw [maxOrthogonal_card_by_dimension hK,Module.finrank_fin_fun] + simp only [Nat.cast_sum,Nat.cast_mul,Nat.cast_pow] + rw [Finset.sum_div] + unfold orthogonalFactor + apply Finset.sum_congr rfl + intro k _ + rw [subspace_count_normalized k.val (by simp; omega)] + simp only [Module.finrank_fin_fun] + have hr : (k.val+(r-k.val)).choose 2 = r.choose 2 := by rw [Nat.add_sub_of_le (by omega)] + have he : r.choose 2 = k.val.choose 2 + (r-k.val).choose 2 + k.val*(r-k.val) := by + rw [←hr,choose_two_add] + rw [he,pow_add,pow_add] + have hq : (Fintype.card K : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr Fintype.card_ne_zero + field_simp + +theorem orthogonalFactor_tendsto (r : ℕ) (hr : 0 + grassmannFactor (n+1) k.val q / q^((n+1-k.val).choose 2)) atTop (nhds 0) := by + have hp : 0 < (n+1-k.val).choose 2 := Nat.choose_pos (by omega) + have h := (grassmannFactor_tendsto (n+1) k.val (by omega)).mul + (inverse_power_tendsto_zero _ hp) + simpa only [one_mul,div_eq_mul_inv,one_div] using h + have hsum := tendsto_finsetSum Finset.univ (fun k (_ : k ∈ Finset.univ) => hrest k) + have hn : Tendsto (fun q : ℝ => grassmannFactor (n+1) n q / + q^((n+1-n).choose 2)) atTop (nhds 1) := by + simpa using grassmannFactor_tendsto (n+1) n (Nat.le_succ n) + have hn1 : Tendsto (fun q : ℝ => grassmannFactor (n+1) (n+1) q / + q^((n+1-(n+1)).choose 2)) atTop (nhds 1) := by + simpa using grassmannFactor_tendsto (n+1) (n+1) le_rfl + have h := (hsum.add hn).add hn1 + simp only [Finset.sum_const_zero,zero_add] at h + norm_num only [one_add_one_eq_two] at h + convert h using 1 + funext q + unfold orthogonalFactor + rw [Fin.sum_univ_castSucc,Fin.sum_univ_castSucc] + rfl + + theorem split_form_normalized {K E : Type*} [Field K] [Fintype K] [DecidableEq K] + [AddCommGroup E] [Module K E] [FiniteDimensional K E] + (B : LinearMap.BilinForm K E) (hs : B.IsSymm) (hB : B.Nondegenerate) + (hK : ringChar K ≠ 2) (r : ℕ) (hd : finrank K E=2*r) + (hc : discriminantSign B hs = quadraticChar K ((-1 : K)^r)) : + (Nat.card (SymplecticLagrangian B) : ℝ)/(Fintype.card K : ℝ)^r.choose 2 = + orthogonalFactor r (Fintype.card K) := by + rw [split_form_card B hs hB hK r hd hc] + exact maxOrthogonal_normalized hK r +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module LinearMap +open scoped Matrix BigOperators +section PairSigns +variable {K : Type*} [Field K] [Fintype K] [DecidableEq K] {D r : ℕ} + +theorem signed_pair_compatibility (hd : D=2*r) (A B : SymMatrix K D) + (hB : B.val.det≠0) (ha : A.val.rank=r) (hb : (A-B).val.rank=r) : + quadraticChar K B.val.det = quadraticChar K ((-1 : K)^r) * + matrixSign K D A * matrixSign K D (A-B) := by + have hba : (B.val-A.val).rank=r := by + have he : B.val-A.val= -(A-B).val := by simp + rw [he,matrix_rank_neg,hb] + have hi := (half_rank_projection r (by simpa using hd) A.val B.val hB ha).mp hba + have hs := center_complement_sign B.val A.val B.property hB A.property hi + have he : (⟨B.val-A.val,B.property.sub A.property⟩ : SymMatrix K D)= -(A-B) := by + apply Subtype.ext; simp + change quadraticChar K B.val.det = matrixSign K D A * + matrixSign K D ⟨B.val-A.val,B.property.sub A.property⟩ at hs + rw [he,matrixSign_neg,hb] at hs + rw [hs]; ring + +theorem signed_second_iff (hd : D=2*r) (A B : SymMatrix K D) + (hB : B.val.det≠0) (ha : A.val.rank=r) {ξ ζ : ℤ} (hx : matrixSign K D A=ξ) + (hm : quadraticChar K B.val.det=quadraticChar K ((-1 : K)^r)*ξ*ζ) : + ((A-B).val.rank=r ∧ matrixSign K D (A-B)=ζ) ↔ A.val*B.val⁻¹*A.val=A.val := by + have hr : (A-B).val.rank=r ↔ A.val*B.val⁻¹*A.val=A.val := by + rw [←half_rank_projection r (by simpa using hd) A.val B.val hB ha] + have he : (A-B).val= -(B.val-A.val) := by simp + rw [he,matrix_rank_neg] + constructor + · exact fun h => hr.mp h.1 + · intro hi + have hb := hr.mpr hi + refine ⟨hb,?_⟩ + have hp := signed_pair_compatibility hd A B hB ha hb + rw [hx,hm] at hp + have hc : quadraticChar K ((-1 : K)^r)≠0 := by + exact mt quadraticChar_eq_zero_iff.mp (pow_ne_zero r (neg_ne_zero.mpr (one_ne_zero : (1 : K)≠0))) + have hn : ξ≠0 := by rw [←hx]; exact discriminantSign_ne_zero _ _ + exact mul_left_cancel₀ (mul_ne_zero hc hn) hp.symm +end PairSigns +section Equiv +variable {K n : Type*} [Field K] [Fintype K] [DecidableEq K] [Fintype n] [DecidableEq n] + +omit [Fintype K] [DecidableEq K] in +theorem centerSubspaceEquiv_rank (Q : Matrix n n K) (hQ : Q.IsSymm) (hdet : Q.det≠0) + (A : CenterProjection Q) : finrank K (centerSubspaceEquiv Q hQ hdet A).val = A.val.rank := by + rw [centerSubspaceEquiv_val] + rfl + +theorem centerSubspaceEquiv_sign (Q : Matrix n n K) (hQ : Q.IsSymm) (hdet : Q.det≠0) + (A : CenterProjection Q) : + discriminantSign A.val.toBilin' (Matrix.isSymm_toBilin'_iff_isSymm.mpr A.property.1) = + discriminantSign (Q.toBilin'.restrict (centerSubspaceEquiv Q hQ hdet A).val) + ((Matrix.isSymm_toBilin'_iff_isSymm.mpr hQ).restrict _) := by + rw [centerSubspaceEquiv_val] + exact center_discriminant Q A.val hQ hdet A.property.1 A.property.2 + +noncomputable def centerPredicateEquiv (Q : Matrix n n K) (hQ : Q.IsSymm) (hdet : Q.det≠0) + (P : Submodule K (n → K) → Prop) : + {A : CenterProjection Q // P A.val.toLin'.range} ≃ + {U : Submodule K (n → K) // (Q.toBilin'.restrict U).Nondegenerate ∧ P U} := + ((centerSubspaceEquiv Q hQ hdet).subtypeEquiv (fun A => by + rw [centerSubspaceEquiv_val])).trans + (Equiv.subtypeSubtypeEquivSubtypeInter _ _) +end Equiv +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module LinearMap +open scoped Matrix BigOperators +section SignedProjector +variable {K : Type*} [Field K] [Fintype K] [DecidableEq K] {D r : ℕ} + +def SignedProjector (Q : Matrix (Fin D) (Fin D) K) (r : ℕ) (ξ : ℤ) := + {A : CenterProjection Q // A.val.rank=r ∧ + discriminantSign A.val.toBilin' (Matrix.isSymm_toBilin'_iff_isSymm.mpr A.property.1)=ξ} + +noncomputable def pairSignedCenterEquiv (hd : D=2*r) (B : SymMatrix K D) + (hB : B.val.det≠0) (ξ ζ : ℤ) + (hm : quadraticChar K B.val.det=quadraticChar K ((-1 : K)^r)*ξ*ζ) : + {A : SymMatrix K D // A ∈ signedLayer K D r ξ ∧ A-B ∈ signedLayer K D r ζ} ≃ + SignedProjector B.val⁻¹ r ξ where + toFun A := + ⟨⟨A.val.val,A.val.property, + (signed_second_iff hd A.val B hB ((mem_signedLayer ..).mp A.property.1).1 + ((mem_signedLayer ..).mp A.property.1).2 hm).mp + ((mem_signedLayer ..).mp A.property.2)⟩, + ((mem_signedLayer ..).mp A.property.1).1,((mem_signedLayer ..).mp A.property.1).2⟩ + invFun A := + ⟨⟨A.val.val,A.val.property.1⟩, + (mem_signedLayer ..).mpr A.property, + (mem_signedLayer ..).mpr ((signed_second_iff hd ⟨A.val.val,A.val.property.1⟩ B hB + A.property.1 A.property.2 hm).mpr A.val.property.2)⟩ + left_inv A := by apply Subtype.ext; rfl + right_inv A := by apply Subtype.ext; rfl + +noncomputable def signedProjectorSubspaceEquiv (Q : Matrix (Fin D) (Fin D) K) + (hQ : Q.IsSymm) (hdet : Q.det≠0) (r : ℕ) (ξ : ℤ) : + SignedProjector Q r ξ ≃ + {U : DimSubspace K (Fin D → K) r // (Q.toBilin'.restrict U.val).Nondegenerate ∧ + discriminantSign (Q.toBilin'.restrict U.val) + ((Matrix.isSymm_toBilin'_iff_isSymm.mpr hQ).restrict U.val)=ξ} where + toFun A := + ⟨⟨(centerSubspaceEquiv Q hQ hdet A.val).val, + (centerSubspaceEquiv_rank Q hQ hdet A.val).trans A.property.1⟩, + (centerSubspaceEquiv Q hQ hdet A.val).property, + (centerSubspaceEquiv_sign Q hQ hdet A.val).symm.trans A.property.2⟩ + invFun U := + ⟨(centerSubspaceEquiv Q hQ hdet).symm ⟨U.val.val,U.property.1⟩,by + constructor + · rw [←centerSubspaceEquiv_rank Q hQ hdet,Equiv.apply_symm_apply]; exact U.val.property + · rw [centerSubspaceEquiv_sign Q hQ hdet,Equiv.apply_symm_apply]; exact U.property.2⟩ + left_inv A := by + apply Subtype.ext + exact (centerSubspaceEquiv Q hQ hdet).symm_apply_apply A.val + right_inv U := by + apply Subtype.ext + apply Subtype.ext + change ((centerSubspaceEquiv Q hQ hdet) + ((centerSubspaceEquiv Q hQ hdet).symm ⟨U.val.val,U.property.1⟩)).val=U.val.val + rw [Equiv.apply_symm_apply] +end SignedProjector +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module LinearMap +open scoped Matrix BigOperators +section Isotropic +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + +theorem restrict_eq_zero_iff_isotropic (L : LinearMap.BilinForm K V) (U : Submodule K V) : + L.restrict U=0 ↔ U ≤ L.orthogonal U := by + constructor + · intro h x hx y hy + have he := congrArg (fun B : LinearMap.BilinForm K U => B ⟨y,hy⟩ ⟨x,hx⟩) h + exact he + · intro h + apply LinearMap.ext + intro x + apply LinearMap.ext + intro y + exact h y.property x.val x.property + +variable [FiniteDimensional K V] +theorem half_isotropic_iff_self (L : LinearMap.BilinForm K V) (hL : L.Nondegenerate) + (r : ℕ) (hd : finrank K V=2*r) (U : Submodule K V) (hu : finrank K U=r) : + L.restrict U=0 ↔ L.orthogonal U=U := by + rw [restrict_eq_zero_iff_isotropic] + constructor + · intro h + symm + apply Submodule.eq_of_le_of_finrank_eq h + have hr := L.finrank_orthogonal hL U + omega + · intro h; rw [h] + +noncomputable def halfIsotropicEquiv (L : LinearMap.BilinForm K V) (hL : L.Nondegenerate) + (r : ℕ) (hd : finrank K V=2*r) : + {U : DimSubspace K V r // L.restrict U.val=0} ≃ SymplecticLagrangian L where + toFun U := ⟨U.val.val,(half_isotropic_iff_self L hL r hd U.val.val U.val.property).mp U.property⟩ + invFun U := ⟨⟨U.val,by + have h := self_orthogonal_twice_finrank L U.val hL U.property + omega⟩,(restrict_eq_zero_iff_isotropic L U.val).mpr (by rw [U.property])⟩ + left_inv U := by apply Subtype.ext; rfl + right_inv U := rfl +end Isotropic +section Triple +variable {K : Type*} [Field K] [Fintype K] [DecidableEq K] {D r : ℕ} + +noncomputable def tripleSignedCenterEquiv (hd : D=2*r) (B C : SymMatrix K D) + (hB : B.val.det≠0) (hC : C.val.det≠0) (ξ ζ θ : ℤ) + (hmB : quadraticChar K B.val.det=quadraticChar K ((-1 : K)^r)*ξ*ζ) + (hmC : quadraticChar K C.val.det=quadraticChar K ((-1 : K)^r)*ξ*θ) : + {A : SymMatrix K D // A ∈ signedLayer K D r ξ ∧ A-B ∈ signedLayer K D r ζ ∧ + A-C ∈ signedLayer K D r θ} ≃ + {A : SignedProjector B.val⁻¹ r ξ // (B.val⁻¹-C.val⁻¹).toBilin'.restrict A.val.val.toLin'.range=0} where + toFun A := ⟨pairSignedCenterEquiv hd B hB ξ ζ hmB ⟨A.val,A.property.1,A.property.2.1⟩,by + apply (center_second_equation B.val⁻¹ C.val⁻¹ A.val.val A.val.property + ((pairSignedCenterEquiv hd B hB ξ ζ hmB ⟨A.val,A.property.1,A.property.2.1⟩).val.property.2)).mp + exact (signed_second_iff hd A.val C hC ((mem_signedLayer ..).mp A.property.1).1 + ((mem_signedLayer ..).mp A.property.1).2 hmC).mp ((mem_signedLayer ..).mp A.property.2.2)⟩ + invFun A := + let a := (pairSignedCenterEquiv hd B hB ξ ζ hmB).symm A.val + ⟨a.val,a.property.1,a.property.2,(mem_signedLayer ..).mpr + ((signed_second_iff hd a.val C hC ((mem_signedLayer ..).mp a.property.1).1 + ((mem_signedLayer ..).mp a.property.1).2 hmC).mpr + ((center_second_equation B.val⁻¹ C.val⁻¹ A.val.val.val A.val.val.property.1 + A.val.val.property.2).mpr A.property))⟩ + left_inv A := by apply Subtype.ext; rfl + right_inv A := by apply Subtype.ext; rfl +end Triple +end SidorenkoCounterexample + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/Nullity.lean b/lean/OAI/Combinatorics/Sidorenko/Nullity.lean new file mode 100644 index 0000000000000000000000000000000000000000..f0c2f755ddb468e3e11a9e482ee6400a0da300d8 --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/Nullity.lean @@ -0,0 +1,996 @@ +import OAI.Combinatorics.Sidorenko.FormGluing + +namespace OAI + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section Bounds +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [Fintype K] [Finite V] +/-- The elementary matching lower Grassmann bound. -/ +theorem subspace_count_lower (k : ℕ) (hk : k ≤ finrank K V) : + (Fintype.card K : ℝ)^(k*(finrank K V-k)) ≤ Nat.card (DimSubspace K V k) := by + rw [subspace_count_real k hk] + let q : ℝ := Fintype.card K + have hq : 1 < q := by + dsimp [q] + exact_mod_cast (Fintype.one_lt_card (α := K)) + have hq0 : 0 < q := by linarith + have hfac (i : Fin k) : q^(finrank K V-k) ≤ + (q^finrank K V-q^i.val)/(q^k-q^i.val) := by + have hd : 0 < q^k-q^i.val := sub_pos.mpr (pow_lt_pow_right₀ hq i.isLt) + have hid : q^finrank K V = q^(finrank K V-k)*q^k := by + rw [←pow_add,Nat.sub_add_cancel hk] + apply (le_div_iff₀ hd).mpr + rw [hid] + have hp : 1 ≤ q^(finrank K V-k) := one_le_pow₀ hq.le + have hm := mul_le_mul_of_nonneg_right hp (pow_nonneg hq0.le i.val) + nlinarith + calc + q^(k*(finrank K V-k)) = ∏ _i : Fin k, q^(finrank K V-k) := by + simp only [Finset.prod_const,Finset.card_univ,Fintype.card_fin,←pow_mul] + rw [Nat.mul_comm] + _ ≤ _ := Finset.prod_le_prod₀ (fun _ _ => pow_nonneg hq0.le _) (fun i _ => hfac i) + +end Bounds +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open Module +section ContainingSubspaces +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] + theorem containment_quotient_finrank (S U : Submodule K V) (hS : S ≤ U) : + finrank K (U.map S.mkQ) + finrank K S = finrank K U := by + have h := LinearMap.finrank_range_add_finrank_ker (S.mkQ.comp U.subtype) + rw [LinearMap.range_comp,Submodule.range_subtype,LinearMap.ker_comp,Submodule.ker_mkQ] at h + rw [(Submodule.comapSubtypeEquivOfLe hS).finrank_eq] at h + exact h + +noncomputable def containingSubspaceEquiv (S : Submodule K V) (r : ℕ) (hr : finrank K S ≤ r) : + {U : DimSubspace K V r // S ≤ U.val} ≃ DimSubspace K (V ⧸ S) (r-finrank K S) where + toFun U := ⟨U.val.val.map S.mkQ,by + have h := containment_quotient_finrank S U.val.val U.property + rw [U.val.property] at h + omega⟩ + invFun Q := ⟨⟨Q.val.comap S.mkQ,by + have h := containment_quotient_finrank S (Q.val.comap S.mkQ) (Submodule.le_comap_mkQ _ _) + rw [Submodule.map_comap_eq_self (by simp),Q.property] at h + omega⟩,Submodule.le_comap_mkQ _ _⟩ + left_inv U := by + apply Subtype.ext + apply Subtype.ext + change (U.val.val.map S.mkQ).comap S.mkQ = U.val.val + simp only [Submodule.comap_map_mkQ, sup_eq_right.mpr U.property] + right_inv Q := by + apply Subtype.ext + exact (S.comapMkQRelIso).symm_apply_apply Q.val + +variable [Fintype K] [Finite V] + omit [Finite V] in + theorem containingSubspace_card_bounds (S : Submodule K V) (r : ℕ) + (hr : finrank K S ≤ r) (hrD : r ≤ finrank K V) : + (Fintype.card K : ℝ)^((r-finrank K S)*(finrank K V-r)) ≤ + Nat.card {U : DimSubspace K V r // S ≤ U.val} ∧ + (Nat.card {U : DimSubspace K V r // S ≤ U.val} : ℝ) ≤ + 2^r*(Fintype.card K : ℝ)^((r-finrank K S)*(finrank K V-r)) := by + let : Finite (V ⧸ S) := Module.finite_of_finite K + have hD := S.finrank_quotient_add_finrank + have hle : r-finrank K S ≤ finrank K (V ⧸ S) := by omega + have he : finrank K (V ⧸ S)-(r-finrank K S) = finrank K V-r := by omega + rw [Nat.card_congr (containingSubspaceEquiv S r hr)] + constructor + · simpa only [he] using (subspace_count_lower (K := K) (V := V ⧸ S) (r-finrank K S) hle) + · have h := subspace_count_upper (K := K) (V := V ⧸ S) (r-finrank K S) hle + rw [he] at h + exact h.trans (mul_le_mul_of_nonneg_right (pow_le_pow_right₀ (by norm_num) (Nat.sub_le r _)) (by positivity)) +end ContainingSubspaces +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section TripleSubspaces +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + +abbrev SubspaceTripleProfile (r p₀ p₁ p₂ : ℕ) := + {R : DimSubspace K V r × DimSubspace K V r × DimSubspace K V r // + (R.1.val ⊓ R.2.1.val) ⊓ R.2.2.val = ⊥ ∧ + finrank K ↥(R.1.val ⊓ R.2.1.val) = p₀ ∧ + finrank K ↥(R.1.val ⊓ R.2.2.val) = p₁ ∧ + finrank K ↥(R.2.1.val ⊓ R.2.2.val) = p₂} +abbrev PairSubspaceConfig (p₀ p₁ p₂ : ℕ) := + {P : DimSubspace K V p₀ × DimSubspace K V p₁ × DimSubspace K V p₂ // + Disjoint P.1.val P.2.1.val ∧ Disjoint P.1.val P.2.2.val ∧ Disjoint P.2.1.val P.2.2.val} +abbrev SubspaceTripleCompletion {p₀ p₁ p₂ : ℕ} (r : ℕ) (P : PairSubspaceConfig (K := K) (V := V) p₀ p₁ p₂) := + {R : DimSubspace K V r // P.val.1.val ⊔ P.val.2.1.val ≤ R.val} × + {R : DimSubspace K V r // P.val.1.val ⊔ P.val.2.2.val ≤ R.val} × + {R : DimSubspace K V r // P.val.2.1.val ⊔ P.val.2.2.val ≤ R.val} + + theorem triple_pairwise_disjoint (L M N : Submodule K V) (hc : (L ⊓ M) ⊓ N = ⊥) : + Disjoint (L ⊓ M) (L ⊓ N) ∧ Disjoint (L ⊓ M) (M ⊓ N) ∧ Disjoint (L ⊓ N) (M ⊓ N) := by + refine ⟨disjoint_iff.mpr (le_antisymm ?_ bot_le),disjoint_iff.mpr (le_antisymm ?_ bot_le), + disjoint_iff.mpr (le_antisymm ?_ bot_le)⟩ + · intro x hx + exact hc.le ⟨hx.1,hx.2.2⟩ + · intro x hx + exact hc.le ⟨hx.1,hx.2.2⟩ + · intro x hx + exact hc.le ⟨⟨hx.1.1,hx.2.1⟩,hx.1.2⟩ + +noncomputable def subspaceProfile_to_config {r p₀ p₁ p₂ : ℕ} + (R : SubspaceTripleProfile (K := K) (V := V) r p₀ p₁ p₂) : + Σ P : PairSubspaceConfig (K := K) (V := V) p₀ p₁ p₂, SubspaceTripleCompletion r P := + ⟨⟨(⟨R.val.1.val ⊓ R.val.2.1.val,R.property.2.1⟩, + ⟨R.val.1.val ⊓ R.val.2.2.val,R.property.2.2.1⟩, + ⟨R.val.2.1.val ⊓ R.val.2.2.val,R.property.2.2.2⟩), + triple_pairwise_disjoint _ _ _ R.property.1⟩, + ⟨R.val.1,sup_le inf_le_left inf_le_left⟩, + ⟨R.val.2.1,sup_le inf_le_right inf_le_left⟩, + ⟨R.val.2.2,sup_le inf_le_right inf_le_right⟩⟩ + theorem subspaceProfile_to_config_injective (r p₀ p₁ p₂ : ℕ) : + Function.Injective (subspaceProfile_to_config (K := K) (V := V) (r := r) (p₀ := p₀) (p₁ := p₁) (p₂ := p₂)) := by + intro R S h + let f : (Σ P : PairSubspaceConfig (K := K) (V := V) p₀ p₁ p₂, SubspaceTripleCompletion r P) → + DimSubspace K V r × DimSubspace K V r × DimSubspace K V r := fun p => (p.2.1.val,p.2.2.1.val,p.2.2.2.val) + exact Subtype.ext (congrArg f h) + +variable [FiniteDimensional K V] + theorem disjoint_sup_finrank (U W : Submodule K V) (h : Disjoint U W) : + finrank K ↥(U ⊔ W) = finrank K U + finrank K W := by + have hh := Submodule.finrank_sup_add_finrank_inf_eq U W + rw [h.eq_bot,finrank_bot,add_zero] at hh + exact hh + +variable [Fintype K] + theorem pairSubspaceConfig_card_upper (p₀ p₁ p₂ : ℕ) + (h₀ : p₀ ≤ finrank K V) (h₁ : p₁ ≤ finrank K V) (h₂ : p₂ ≤ finrank K V) : + (Nat.card (PairSubspaceConfig (K := K) (V := V) p₀ p₁ p₂) : ℝ) ≤ + 2^(p₀+p₁+p₂)*(Fintype.card K : ℝ)^(p₀*(finrank K V-p₀)+p₁*(finrank K V-p₁)+p₂*(finrank K V-p₂)) := by + let : Finite V := Module.finite_of_finite K + have hc : Nat.card (PairSubspaceConfig (K := K) (V := V) p₀ p₁ p₂) ≤ + Nat.card (DimSubspace K V p₀ × DimSubspace K V p₁ × DimSubspace K V p₂) := + Nat.card_le_card_of_injective Subtype.val Subtype.val_injective + have hh : (Nat.card (PairSubspaceConfig (K := K) (V := V) p₀ p₁ p₂) : ℝ) ≤ + (Nat.card (DimSubspace K V p₀) : ℝ) * Nat.card (DimSubspace K V p₁) * Nat.card (DimSubspace K V p₂) := by + rw [Nat.card_prod, Nat.card_prod] at hc + exact_mod_cast (hc.trans_eq (Nat.mul_assoc _ _ _).symm) + calc + _ ≤ _ := hh + _ ≤ (2^p₀*(Fintype.card K : ℝ)^(p₀*(finrank K V-p₀))) * + (2^p₁*(Fintype.card K : ℝ)^(p₁*(finrank K V-p₁))) * + (2^p₂*(Fintype.card K : ℝ)^(p₂*(finrank K V-p₂))) := by + exact mul_le_mul (mul_le_mul (subspace_count_upper p₀ h₀) (subspace_count_upper p₁ h₁) + (by positivity) (by positivity)) (subspace_count_upper p₂ h₂) (by positivity) (by positivity) + _ = _ := by simp only [pow_add]; ring + + theorem subspaceTripleCompletion_card_upper {p₀ p₁ p₂ : ℕ} (r : ℕ) + (P : PairSubspaceConfig (K := K) (V := V) p₀ p₁ p₂) + (hr : r ≤ finrank K V) (h₀ : p₀+p₁ ≤ r) (h₁ : p₀+p₂ ≤ r) (h₂ : p₁+p₂ ≤ r) : + (Nat.card (SubspaceTripleCompletion r P) : ℝ) ≤ + 2^(3*r)*(Fintype.card K : ℝ)^((r-(p₀+p₁))*(finrank K V-r)+ + (r-(p₀+p₂))*(finrank K V-r)+(r-(p₁+p₂))*(finrank K V-r)) := by + let : Finite V := Module.finite_of_finite K + have d₀ : finrank K ↥(P.val.1.val ⊔ P.val.2.1.val) = p₀+p₁ := by + rw [disjoint_sup_finrank _ _ P.property.1,P.val.1.property,P.val.2.1.property] + have d₁ : finrank K ↥(P.val.1.val ⊔ P.val.2.2.val) = p₀+p₂ := by + rw [disjoint_sup_finrank _ _ P.property.2.1,P.val.1.property,P.val.2.2.property] + have d₂ : finrank K ↥(P.val.2.1.val ⊔ P.val.2.2.val) = p₁+p₂ := by + rw [disjoint_sup_finrank _ _ P.property.2.2,P.val.2.1.property,P.val.2.2.property] + have a₀ := (containingSubspace_card_bounds (P.val.1.val ⊔ P.val.2.1.val) r (by omega) hr).2 + have a₁ := (containingSubspace_card_bounds (P.val.1.val ⊔ P.val.2.2.val) r (by omega) hr).2 + have a₂ := (containingSubspace_card_bounds (P.val.2.1.val ⊔ P.val.2.2.val) r (by omega) hr).2 + rw [d₀] at a₀ + rw [d₁] at a₁ + rw [d₂] at a₂ + have h := mul_le_mul (mul_le_mul a₀ a₁ (by positivity) (by positivity)) a₂ (by positivity) (by positivity) + simpa only [SubspaceTripleCompletion,Nat.card_prod,Nat.cast_mul,pow_add,pow_mul,show 3*r=r+r+r by omega, + mul_assoc,mul_left_comm,mul_comm] using h + +noncomputable def subspaceTripleExponent (n r p₀ p₁ p₂ : ℕ) : ℕ := + p₀*(n-p₀)+p₁*(n-p₁)+p₂*(n-p₂) + + ((r-(p₀+p₁))*(n-r)+(r-(p₀+p₂))*(n-r)+(r-(p₁+p₂))*(n-r)) + + theorem subspaceTripleProfile_card_upper (r p₀ p₁ p₂ : ℕ) + (hr : r ≤ finrank K V) (h₀ : p₀+p₁ ≤ r) (h₁ : p₀+p₂ ≤ r) (h₂ : p₁+p₂ ≤ r) : + (Nat.card (SubspaceTripleProfile (K := K) (V := V) r p₀ p₁ p₂) : ℝ) ≤ + 2^(p₀+p₁+p₂+3*r)*(Fintype.card K : ℝ)^(subspaceTripleExponent (finrank K V) r p₀ p₁ p₂) := by + classical + let : Finite V := Module.finite_of_finite K + let := Fintype.ofFinite (PairSubspaceConfig (K := K) (V := V) p₀ p₁ p₂) + have hc : (Nat.card (SubspaceTripleProfile (K := K) (V := V) r p₀ p₁ p₂) : ℝ) ≤ + Nat.card (Σ P : PairSubspaceConfig (K := K) (V := V) p₀ p₁ p₂, SubspaceTripleCompletion r P) := by + exact_mod_cast Nat.card_le_card_of_injective _ (subspaceProfile_to_config_injective (K := K) (V := V) r p₀ p₁ p₂) + let e := (r-(p₀+p₁))*(finrank K V-r)+(r-(p₀+p₂))*(finrank K V-r)+(r-(p₁+p₂))*(finrank K V-r) + calc + _ ≤ _ := hc + _ = ∑ P : PairSubspaceConfig (K := K) (V := V) p₀ p₁ p₂, (Nat.card (SubspaceTripleCompletion r P) : ℝ) := by + rw [Nat.card_sigma,Nat.cast_sum] + _ ≤ ∑ _P : PairSubspaceConfig (K := K) (V := V) p₀ p₁ p₂, 2^(3*r)*(Fintype.card K : ℝ)^e := + Finset.sum_le_sum (fun P _ => subspaceTripleCompletion_card_upper r P hr h₀ h₁ h₂) + _ = (Nat.card (PairSubspaceConfig (K := K) (V := V) p₀ p₁ p₂) : ℝ)*(2^(3*r)*(Fintype.card K : ℝ)^e) := by + simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,Nat.card_eq_fintype_card] + _ ≤ (2^(p₀+p₁+p₂)*(Fintype.card K : ℝ)^(p₀*(finrank K V-p₀)+p₁*(finrank K V-p₁)+p₂*(finrank K V-p₂))) * + (2^(3*r)*(Fintype.card K : ℝ)^e) := mul_le_mul_of_nonneg_right + (pairSubspaceConfig_card_upper p₀ p₁ p₂ (by omega) (by omega) (by omega)) (by positivity) + _ = _ := by dsimp [e,subspaceTripleExponent]; simp only [pow_add]; ring +end TripleSubspaces +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section SpanCount +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] + +noncomputable def restrictDimSubspace (Z : Submodule K V) {r : ℕ} (R : DimSubspace K V r) (h : R.val ≤ Z) : + DimSubspace K Z r := + ⟨R.val.comap Z.subtype, (Submodule.comapSubtypeEquivOfLe h).finrank_eq.trans R.property⟩ + +noncomputable def restrictTripleProfile (Z : Submodule K V) {r p₀ p₁ p₂ : ℕ} + (R : SubspaceTripleProfile (K := K) (V := V) r p₀ p₁ p₂) + (h : R.val.1.val ⊔ R.val.2.1.val ⊔ R.val.2.2.val ≤ Z) : + SubspaceTripleProfile (K := K) (V := Z) r p₀ p₁ p₂ := by + have h₀ : R.val.1.val ≤ Z := le_trans (le_trans le_sup_left le_sup_left) h + have h₁ : R.val.2.1.val ≤ Z := le_trans (le_trans le_sup_right le_sup_left) h + have h₂ : R.val.2.2.val ≤ Z := le_trans le_sup_right h + refine ⟨(restrictDimSubspace Z R.val.1 h₀, restrictDimSubspace Z R.val.2.1 h₁, + restrictDimSubspace Z R.val.2.2 h₂), ?_, ?_, ?_, ?_⟩ + · change (R.val.1.val.comap Z.subtype ⊓ R.val.2.1.val.comap Z.subtype) ⊓ R.val.2.2.val.comap Z.subtype = ⊥ + rw [←Submodule.comap_inf,←Submodule.comap_inf,R.property.1,Submodule.comap_bot] + exact LinearMap.ker_eq_bot.mpr Z.injective_subtype + · change finrank K ↥(R.val.1.val.comap Z.subtype ⊓ R.val.2.1.val.comap Z.subtype) = p₀ + rw [←Submodule.comap_inf,(Submodule.comapSubtypeEquivOfLe (inf_le_left.trans h₀) : + (R.val.1.val ⊓ R.val.2.1.val).comap Z.subtype ≃ₗ[K] ↥(R.val.1.val ⊓ R.val.2.1.val)).finrank_eq] + exact R.property.2.1 + · change finrank K ↥(R.val.1.val.comap Z.subtype ⊓ R.val.2.2.val.comap Z.subtype) = p₁ + rw [←Submodule.comap_inf,(Submodule.comapSubtypeEquivOfLe (inf_le_left.trans h₀) : + (R.val.1.val ⊓ R.val.2.2.val).comap Z.subtype ≃ₗ[K] ↥(R.val.1.val ⊓ R.val.2.2.val)).finrank_eq] + exact R.property.2.2.1 + · change finrank K ↥(R.val.2.1.val.comap Z.subtype ⊓ R.val.2.2.val.comap Z.subtype) = p₂ + rw [←Submodule.comap_inf,(Submodule.comapSubtypeEquivOfLe (inf_le_left.trans h₁) : + (R.val.2.1.val ⊓ R.val.2.2.val).comap Z.subtype ≃ₗ[K] ↥(R.val.2.1.val ⊓ R.val.2.2.val)).finrank_eq] + exact R.property.2.2.2 + +abbrev SubspaceTripleSpanProfile (r p₀ p₁ p₂ n : ℕ) := + {R : SubspaceTripleProfile (K := K) (V := V) r p₀ p₁ p₂ // + finrank K ↥(R.val.1.val ⊔ R.val.2.1.val ⊔ R.val.2.2.val) = n} + +noncomputable def spanProfileInjection (r p₀ p₁ p₂ n : ℕ) + (R : SubspaceTripleSpanProfile (K := K) (V := V) r p₀ p₁ p₂ n) : + Σ Z : DimSubspace K V n, SubspaceTripleProfile (K := K) (V := Z.val) r p₀ p₁ p₂ := + ⟨⟨R.val.val.1.val ⊔ R.val.val.2.1.val ⊔ R.val.val.2.2.val,R.property⟩, + restrictTripleProfile _ R.val le_rfl⟩ + + omit [FiniteDimensional K V] in + theorem spanProfileInjection_injective (r p₀ p₁ p₂ n : ℕ) : + Function.Injective (spanProfileInjection (K := K) (V := V) r p₀ p₁ p₂ n) := by + intro R S h + let recover : (Σ Z : DimSubspace K V n, SubspaceTripleProfile (K := K) (V := Z.val) r p₀ p₁ p₂) → + Submodule K V × Submodule K V × Submodule K V := fun ZR => + (ZR.2.val.1.val.map ZR.1.val.subtype,ZR.2.val.2.1.val.map ZR.1.val.subtype, + ZR.2.val.2.2.val.map ZR.1.val.subtype) + have he (T : SubspaceTripleSpanProfile (K := K) (V := V) r p₀ p₁ p₂ n) : + recover (spanProfileInjection r p₀ p₁ p₂ n T) = + (T.val.val.1.val,T.val.val.2.1.val,T.val.val.2.2.val) := by + let Z := T.val.val.1.val ⊔ T.val.val.2.1.val ⊔ T.val.val.2.2.val + change ((T.val.val.1.val.comap Z.subtype).map Z.subtype, + (T.val.val.2.1.val.comap Z.subtype).map Z.subtype, + (T.val.val.2.2.val.comap Z.subtype).map Z.subtype) = _ + rw [Submodule.map_comap_subtype,Submodule.map_comap_subtype,Submodule.map_comap_subtype] + rw [inf_eq_right.mpr (le_trans le_sup_left le_sup_left), + inf_eq_right.mpr (le_trans le_sup_right le_sup_left),inf_eq_right.mpr le_sup_right] + have hh := congrArg recover h + rw [he,he] at hh + apply Subtype.ext + apply Subtype.ext + exact Prod.ext (Subtype.ext (congrArg Prod.fst hh)) + (Prod.ext (Subtype.ext (congrArg (fun z => z.2.1) hh)) (Subtype.ext (congrArg (fun z => z.2.2) hh))) + +variable [Fintype K] + theorem subspaceTripleSpanProfile_card_upper (r p₀ p₁ p₂ n : ℕ) + (hn : n ≤ finrank K V) (hr : r ≤ n) + (h₀ : p₀+p₁ ≤ r) (h₁ : p₀+p₂ ≤ r) (h₂ : p₁+p₂ ≤ r) : + (Nat.card (SubspaceTripleSpanProfile (K := K) (V := V) r p₀ p₁ p₂ n) : ℝ) ≤ + 2^(n+p₀+p₁+p₂+3*r)*(Fintype.card K : ℝ)^ + (n*(finrank K V-n)+subspaceTripleExponent n r p₀ p₁ p₂) := by + classical + let : Finite V := Module.finite_of_finite K + let := Fintype.ofFinite (DimSubspace K V n) + have hc : (Nat.card (SubspaceTripleSpanProfile (K := K) (V := V) r p₀ p₁ p₂ n) : ℝ) ≤ + Nat.card (Σ Z : DimSubspace K V n, SubspaceTripleProfile (K := K) (V := Z.val) r p₀ p₁ p₂) := by + exact_mod_cast Nat.card_le_card_of_injective _ (spanProfileInjection_injective (K := K) (V := V) r p₀ p₁ p₂ n) + calc + _ ≤ _ := hc + _ = ∑ Z : DimSubspace K V n, (Nat.card (SubspaceTripleProfile (K := K) (V := Z.val) r p₀ p₁ p₂) : ℝ) := by + rw [Nat.card_sigma,Nat.cast_sum] + _ ≤ ∑ _Z : DimSubspace K V n, 2^(p₀+p₁+p₂+3*r)*(Fintype.card K : ℝ)^(subspaceTripleExponent n r p₀ p₁ p₂) := by + apply Finset.sum_le_sum + intro Z _ + simpa only [Z.property] using subspaceTripleProfile_card_upper (K := K) (V := Z.val) r p₀ p₁ p₂ + (by simpa only [Z.property] using hr) h₀ h₁ h₂ + _ = (Nat.card (DimSubspace K V n) : ℝ) * + (2^(p₀+p₁+p₂+3*r)*(Fintype.card K : ℝ)^(subspaceTripleExponent n r p₀ p₁ p₂)) := by + simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,Nat.card_eq_fintype_card] + _ ≤ (2^n*(Fintype.card K : ℝ)^(n*(finrank K V-n))) * + (2^(p₀+p₁+p₂+3*r)*(Fintype.card K : ℝ)^(subspaceTripleExponent n r p₀ p₁ p₂)) := + mul_le_mul_of_nonneg_right (subspace_count_upper n hn) (by positivity) + _ = _ := by simp only [pow_add]; ring +end SpanCount +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section PlantedSubspaceExponent +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] [Fintype K] + + theorem subspace_span_cost_identity (d n r p₀ p₁ p₂ : ℕ) + (hn : n ≤ d) (hr : r ≤ n) + (h₀ : p₀+p₁ ≤ r) (h₁ : p₀+p₂ ≤ r) (h₂ : p₁+p₂ ≤ r) : + ((n*(d-n)+subspaceTripleExponent n r p₀ p₁ p₂ : ℕ) : ℝ) - (3*r*(d-r) : ℕ) = + -((d:ℝ)-2*r)*(p₀+p₁+p₂) - ((p₀:ℝ)^2+p₁^2+p₂^2) - ((d:ℝ)-n)*(3*r-n-(p₀+p₁+p₂)) := by + have hp₀ : p₀ ≤ n := (Nat.le_add_right p₀ p₁).trans (h₀.trans hr) + have hp₁ : p₁ ≤ n := (Nat.le_add_left p₁ p₀).trans (h₀.trans hr) + have hp₂ : p₂ ≤ n := (Nat.le_add_left p₂ p₀).trans (h₁.trans hr) + simp only [subspaceTripleExponent,Nat.cast_add,Nat.cast_mul,Nat.cast_ofNat, + Nat.cast_sub hn,Nat.cast_sub hr,Nat.cast_sub (hr.trans hn), + Nat.cast_sub hp₀,Nat.cast_sub hp₁,Nat.cast_sub hp₂,Nat.cast_sub h₀,Nat.cast_sub h₁,Nat.cast_sub h₂] + ring + + + + theorem subspace_span_probability_bound (r p₀ p₁ p₂ n : ℕ) + (hn : n ≤ finrank K V) (hr : r ≤ n) + (h₀ : p₀+p₁ ≤ r) (h₁ : p₀+p₂ ≤ r) (h₂ : p₁+p₂ ≤ r) : + (Nat.card (SubspaceTripleSpanProfile (K := K) (V := V) r p₀ p₁ p₂ n) : ℝ) / + (Nat.card (DimSubspace K V r) : ℝ)^3 ≤ + 2^(n+p₀+p₁+p₂+3*r)*(Fintype.card K : ℝ)^( + -((finrank K V:ℝ)-2*r)*(p₀+p₁+p₂) - ((p₀:ℝ)^2+p₁^2+p₂^2) - + ((finrank K V:ℝ)-n)*(3*r-n-(p₀+p₁+p₂))) := by + let : Finite V := Module.finite_of_finite K + let q : ℝ := Fintype.card K + have hq : 0 < q := by dsimp [q]; exact_mod_cast Fintype.card_pos (α := K) + have hcount := subspaceTripleSpanProfile_card_upper (K := K) (V := V) r p₀ p₁ p₂ n hn hr h₀ h₁ h₂ + have hden : q^(3*r*(finrank K V-r)) ≤ (Nat.card (DimSubspace K V r) : ℝ)^3 := by + have hu := subspace_count_lower (K := K) (V := V) r (hr.trans hn) + have hh := pow_le_pow_left₀ (pow_nonneg hq.le _) hu 3 + simpa only [←pow_mul,Nat.mul_comm 3 r,Nat.mul_assoc,Nat.mul_left_comm,Nat.mul_comm] using hh + have hp : 0 < (Nat.card (DimSubspace K V r) : ℝ)^3 := lt_of_lt_of_le (pow_pos hq _) hden + have hdiv : (Nat.card (SubspaceTripleSpanProfile (K := K) (V := V) r p₀ p₁ p₂ n) : ℝ) / + (Nat.card (DimSubspace K V r) : ℝ)^3 ≤ + (2^(n+p₀+p₁+p₂+3*r)*q^(n*(finrank K V-n)+subspaceTripleExponent n r p₀ p₁ p₂)) / + q^(3*r*(finrank K V-r)) := by + exact div_le_div₀ (by positivity) hcount (pow_pos hq _) hden + refine hdiv.trans_eq ?_ + rw [mul_div_assoc,←Real.rpow_natCast q (n*(finrank K V-n)+subspaceTripleExponent n r p₀ p₁ p₂), + ←Real.rpow_natCast q (3*r*(finrank K V-r)),←Real.rpow_sub hq, + subspace_span_cost_identity (finrank K V) n r p₀ p₁ p₂ hn hr h₀ h₁ h₂] +end PlantedSubspaceExponent +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section DualPlantedBases +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] + + theorem coannihilator_finrank (R : Submodule K (Module.Dual K V)) : + finrank K R.dualCoannihilator + finrank K R = finrank K V := by + have h := Subspace.finrank_add_finrank_dualAnnihilator_eq R.dualCoannihilator + rwa [Subspace.dualCoannihilator_dualAnnihilator_eq] at h + +noncomputable def dualDimSubspaceEquiv (r : ℕ) (hr : r ≤ finrank K V) : + DimSubspace K V (finrank K V-r) ≃ DimSubspace K (Module.Dual K V) r where + toFun U := ⟨U.val.dualAnnihilator, by + have h := Subspace.finrank_add_finrank_dualAnnihilator_eq U.val + rw [U.property] at h + omega⟩ + invFun R := ⟨R.val.dualCoannihilator, by + have h := coannihilator_finrank R.val + rw [R.property] at h + omega⟩ + left_inv U := Subtype.ext Subspace.dualAnnihilator_dualCoannihilator_eq + right_inv R := Subtype.ext Subspace.dualCoannihilator_dualAnnihilator_eq + + theorem coannihilator_common_finrank (R₀ R₁ R₂ : Submodule K (Module.Dual K V)) : + finrank K ↥((R₀.dualCoannihilator ⊓ R₁.dualCoannihilator) ⊓ R₂.dualCoannihilator) = + finrank K V - finrank K ↥((R₀ ⊔ R₁) ⊔ R₂) := by + rw [←Submodule.dualCoannihilator_sup_eq,←Submodule.dualCoannihilator_sup_eq] + have h := coannihilator_finrank ((R₀ ⊔ R₁) ⊔ R₂) + omega + +noncomputable def dualGraph (R : Submodule K (Module.Dual K V)) + (B : SymForm K R.dualCoannihilator) : Lagrangian (K := K) (V := V) := + graphLagrangian R.dualCoannihilator B + + theorem dualGraph_vertical_dim (R : Submodule K (Module.Dual K V)) + (B : SymForm K R.dualCoannihilator) : + finrank K ↥((dualGraph R B).val ⊓ verticalSpace (K := K) (V := V)) = finrank K R := by + change finrank K ↥(formGraph R.dualCoannihilator B.val ⊓ verticalSpace (K := K) (V := V)) = _ + rw [graph_vertical_intersection_finrank] + have h := coannihilator_finrank R + omega + + theorem dualGraph_vertical_subspace (R : Submodule K (Module.Dual K V)) + (B : SymForm K R.dualCoannihilator) (f : Module.Dual K V) : + ((0,f) : V × Module.Dual K V) ∈ (dualGraph R B).val ↔ f ∈ R := by + change (∃ u : R.dualCoannihilator, u.val = 0 ∧ _ = B.val u) ↔ _ + constructor + · rintro ⟨u,hu,hf⟩ + have hu0 : u = 0 := Subtype.ext hu + have hf0 : f ∈ R.dualCoannihilator.dualAnnihilator := by + apply (Submodule.mem_dualAnnihilator (W := R.dualCoannihilator) f).mpr + intro x hx + have h := congrArg (fun l : Module.Dual K R.dualCoannihilator => l ⟨x,hx⟩) hf + simpa [hu0] using h + simpa only [Subspace.dualCoannihilator_dualAnnihilator_eq] using hf0 + · intro hf + refine ⟨0,rfl,?_⟩ + ext x + change f x.val = B.val 0 x + rw [map_zero,LinearMap.zero_apply] + have hx := (Submodule.mem_dualCoannihilator (Φ := R) x.val).mp x.property + exact hx f hf + + theorem dualGraph_common_zero (R₀ R₁ R₂ : Submodule K (Module.Dual K V)) + (F : OriginalForms R₀.dualCoannihilator R₁.dualCoannihilator R₂.dualCoannihilator) + (h : ((dualGraph R₀ F.1).val ⊓ (dualGraph R₁ F.2.1).val) ⊓ (dualGraph R₂ F.2.2).val = ⊥) : + (R₀ ⊓ R₁) ⊓ R₂ = ⊥ := by + apply le_antisymm _ bot_le + intro f hf + have hm : ((0,f) : V × Module.Dual K V) ∈ + ((dualGraph R₀ F.1).val ⊓ (dualGraph R₁ F.2.1).val) ⊓ (dualGraph R₂ F.2.2).val := + ⟨⟨(dualGraph_vertical_subspace R₀ F.1 f).mpr hf.1.1, + (dualGraph_vertical_subspace R₁ F.2.1 f).mpr hf.1.2⟩, + (dualGraph_vertical_subspace R₂ F.2.2 f).mpr hf.2⟩ + have hz := h.le hm + exact congrArg Prod.snd hz + +end DualPlantedBases +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section NullityAll +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [Fintype K] [Finite V] + theorem symmetric_nullity_probability_bound_all (t : ℕ) : + (Nat.card {B : SymForm K V // t ≤ finrank K B.val.ker} : ℝ) / Nat.card (SymForm K V) ≤ + 2^t / (Fintype.card K : ℝ)^((t+1).choose 2) := by + by_cases ht : t ≤ finrank K V + · exact symmetric_nullity_probability_bound t ht + · have : IsEmpty {B : SymForm K V // t ≤ finrank K B.val.ker} := + ⟨fun B => ht (B.property.trans (Submodule.finrank_le B.val.val.ker))⟩ + rw [Nat.card_of_isEmpty,Nat.cast_zero,zero_div] + positivity +end NullityAll +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section NullityAllLift +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [Fintype K] [Finite V] +variable (A₀ A₁ A₂ : Submodule K V) + + +theorem planted_nullity_probability_bound_all + (t₀ t₁ t₂ : ℕ) : + (Nat.card {F : OriginalForms A₀ A₁ A₂ // + t₀ ≤ finrank K (originalCyclicDifference A₀ A₁ A₂ F).1.val.ker ∧ + t₁ ≤ finrank K (originalCyclicDifference A₀ A₁ A₂ F).2.1.val.ker ∧ + t₂ ≤ finrank K (originalCyclicDifference A₀ A₁ A₂ F).2.2.val.ker} : ℝ) / + Nat.card (OriginalForms A₀ A₁ A₂) ≤ + (Fintype.card K : ℝ)^((finrank K (CommonSpace A₀ A₁ A₂)+1).choose 2) * + ((2^t₀ / (Fintype.card K : ℝ)^((t₀+1).choose 2)) * + (2^t₁ / (Fintype.card K : ℝ)^((t₁+1).choose 2)) * + (2^t₂ / (Fintype.card K : ℝ)^((t₂+1).choose 2))) := by + have hc := linear_constraint_probability_bound + (originalCyclicDifference A₀ A₁ A₂) (differenceConstraint A₀ A₁ A₂) + (differenceConstraint_surjective A₀ A₁ A₂) (originalCyclicDifference_range A₀ A₁ A₂) + (fun D => t₀ ≤ finrank K D.1.val.ker ∧ t₁ ≤ finrank K D.2.1.val.ker ∧ + t₂ ≤ finrank K D.2.2.val.ker) + have hp := triple_predicate_probability + (fun B : SymForm K ↥(A₁ ⊓ A₂) => t₀ ≤ finrank K B.val.ker) + (fun B : SymForm K ↥(A₂ ⊓ A₀) => t₁ ≤ finrank K B.val.ker) + (fun B : SymForm K ↥(A₀ ⊓ A₁) => t₂ ≤ finrank K B.val.ker) + rw [mul_div_assoc, hp, symForm_card, Nat.cast_pow] at hc + refine hc.trans ?_ + have hb₀ := symmetric_nullity_probability_bound_all (K := K) (V := ↥(A₁ ⊓ A₂)) t₀ + have hb₁ := symmetric_nullity_probability_bound_all (K := K) (V := ↥(A₂ ⊓ A₀)) t₁ + have hb₂ := symmetric_nullity_probability_bound_all (K := K) (V := ↥(A₀ ⊓ A₁)) t₂ + apply mul_le_mul_of_nonneg_left _ (by positivity) + exact mul_le_mul (mul_le_mul hb₀ hb₁ (by positivity) (by positivity)) hb₂ + (by positivity) (by positivity) + + + theorem lift_pair_profile_probability_bound_all (t₀ t₁ t₂ : ℕ) + : + (Nat.card {F : OriginalForms A₀ A₁ A₂ // + finrank K ↥(A₁.dualAnnihilator ⊓ A₂.dualAnnihilator) + t₀ ≤ + finrank K ↥((graphLagrangian A₁ F.2.1).val ⊓ (graphLagrangian A₂ F.2.2).val) ∧ + finrank K ↥(A₂.dualAnnihilator ⊓ A₀.dualAnnihilator) + t₁ ≤ + finrank K ↥((graphLagrangian A₂ F.2.2).val ⊓ (graphLagrangian A₀ F.1).val) ∧ + finrank K ↥(A₀.dualAnnihilator ⊓ A₁.dualAnnihilator) + t₂ ≤ + finrank K ↥((graphLagrangian A₀ F.1).val ⊓ (graphLagrangian A₁ F.2.1).val)} : ℝ) / + Nat.card (OriginalForms A₀ A₁ A₂) ≤ + (Fintype.card K : ℝ)^((finrank K (CommonSpace A₀ A₁ A₂)+1).choose 2) * + ((2^t₀ / (Fintype.card K : ℝ)^((t₀+1).choose 2)) * + (2^t₁ / (Fintype.card K : ℝ)^((t₁+1).choose 2)) * + (2^t₂ / (Fintype.card K : ℝ)^((t₂+1).choose 2))) := by + have he (F : OriginalForms A₀ A₁ A₂) : + (finrank K ↥(A₁.dualAnnihilator ⊓ A₂.dualAnnihilator) + t₀ ≤ + finrank K ↥((graphLagrangian A₁ F.2.1).val ⊓ (graphLagrangian A₂ F.2.2).val) ∧ + finrank K ↥(A₂.dualAnnihilator ⊓ A₀.dualAnnihilator) + t₁ ≤ + finrank K ↥((graphLagrangian A₂ F.2.2).val ⊓ (graphLagrangian A₀ F.1).val) ∧ + finrank K ↥(A₀.dualAnnihilator ⊓ A₁.dualAnnihilator) + t₂ ≤ + finrank K ↥((graphLagrangian A₀ F.1).val ⊓ (graphLagrangian A₁ F.2.1).val)) ↔ + (t₀ ≤ finrank K (originalCyclicDifference A₀ A₁ A₂ F).1.val.ker ∧ + t₁ ≤ finrank K (originalCyclicDifference A₀ A₁ A₂ F).2.1.val.ker ∧ + t₂ ≤ finrank K (originalCyclicDifference A₀ A₁ A₂ F).2.2.val.ker) := by + change (_ ≤ finrank K ↥(formGraph A₁ F.2.1.val ⊓ formGraph A₂ F.2.2.val) ∧ + _ ≤ finrank K ↥(formGraph A₂ F.2.2.val ⊓ formGraph A₀ F.1.val) ∧ + _ ≤ finrank K ↥(formGraph A₀ F.1.val ⊓ formGraph A₁ F.2.1.val)) ↔ _ + rw [graph_pair_intersection_finrank,graph_pair_intersection_finrank,graph_pair_intersection_finrank] + simp only [Nat.add_le_add_iff_left] + rfl + rw [Nat.card_congr (Equiv.subtypeEquivRight he)] + exact planted_nullity_probability_bound_all A₀ A₁ A₂ t₀ t₁ t₂ + +end NullityAllLift +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section DualProfileLift +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] +variable {r p₀ p₁ p₂ n : ℕ} +abbrev DualProfileForms (R : SubspaceTripleSpanProfile (K := K) (V := Module.Dual K V) r p₀ p₁ p₂ n) := + OriginalForms R.val.val.1.val.dualCoannihilator R.val.val.2.1.val.dualCoannihilator + R.val.val.2.2.val.dualCoannihilator +abbrev DualLiftEvent (R : SubspaceTripleSpanProfile (K := K) (V := Module.Dual K V) r p₀ p₁ p₂ n) + (t₀ t₁ t₂ : ℕ) := + {F : DualProfileForms R // + p₂+t₂ ≤ finrank K ↥((dualGraph R.val.val.2.1.val F.2.1).val ⊓ (dualGraph R.val.val.2.2.val F.2.2).val) ∧ + p₁+t₁ ≤ finrank K ↥((dualGraph R.val.val.2.2.val F.2.2).val ⊓ (dualGraph R.val.val.1.val F.1).val) ∧ + p₀+t₀ ≤ finrank K ↥((dualGraph R.val.val.1.val F.1).val ⊓ (dualGraph R.val.val.2.1.val F.2.1).val)} + + theorem dualProfileForms_card [Fintype K] [Finite V] + (R : SubspaceTripleSpanProfile (K := K) (V := Module.Dual K V) r p₀ p₁ p₂ n) : + Nat.card (DualProfileForms R) = (Fintype.card K)^(3*((finrank K V-r+1).choose 2)) := by + have hdim (S : DimSubspace K (Module.Dual K V) r) : finrank K S.val.dualCoannihilator = finrank K V-r := by + have h := coannihilator_finrank S.val + rw [S.property] at h + omega + simp only [DualProfileForms,OriginalForms,Nat.card_prod,symForm_card,hdim,←pow_add] + congr 1 + omega + + theorem dual_lift_probability_bound [Fintype K] [Finite V] + (R : SubspaceTripleSpanProfile (K := K) (V := Module.Dual K V) r p₀ p₁ p₂ n) + (t₀ t₁ t₂ : ℕ) : + (Nat.card (DualLiftEvent R t₀ t₁ t₂) : ℝ) / Nat.card (DualProfileForms R) ≤ + 2^(t₀+t₁+t₂) * (Fintype.card K : ℝ)^((finrank K V-n+1).choose 2) / + (Fintype.card K : ℝ)^((t₀+1).choose 2+(t₁+1).choose 2+(t₂+1).choose 2) := by + let A₀ := R.val.val.1.val.dualCoannihilator + let A₁ := R.val.val.2.1.val.dualCoannihilator + let A₂ := R.val.val.2.2.val.dualCoannihilator + have h₀ : finrank K ↥(A₁.dualAnnihilator ⊓ A₂.dualAnnihilator) = p₂ := by + dsimp only [A₁,A₂] + rw [Subspace.dualCoannihilator_dualAnnihilator_eq,Subspace.dualCoannihilator_dualAnnihilator_eq] + exact R.val.property.2.2.2 + have h₁ : finrank K ↥(A₂.dualAnnihilator ⊓ A₀.dualAnnihilator) = p₁ := by + dsimp only [A₂,A₀] + rw [Subspace.dualCoannihilator_dualAnnihilator_eq,Subspace.dualCoannihilator_dualAnnihilator_eq,inf_comm] + exact R.val.property.2.2.1 + have h₂ : finrank K ↥(A₀.dualAnnihilator ⊓ A₁.dualAnnihilator) = p₀ := by + dsimp only [A₀,A₁] + rw [Subspace.dualCoannihilator_dualAnnihilator_eq,Subspace.dualCoannihilator_dualAnnihilator_eq] + exact R.val.property.2.1 + have hv : finrank K (CommonSpace A₀ A₁ A₂) = finrank K V-n := by + exact (coannihilator_common_finrank _ _ _).trans (by rw [R.property]) + have hb := lift_pair_profile_probability_bound_all A₀ A₁ A₂ t₂ t₁ t₀ + rw [h₀,h₁,h₂,hv] at hb + refine hb.trans_eq ?_ + simp only [pow_add] + ring + +end DualProfileLift +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section ProfileConstraints +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] + theorem subspace_profile_constraints {r p₀ p₁ p₂ n : ℕ} + (R : SubspaceTripleSpanProfile (K := K) (V := V) r p₀ p₁ p₂ n) : + n ≤ finrank K V ∧ r ≤ n ∧ p₀+p₁ ≤ r ∧ p₀+p₂ ≤ r ∧ p₁+p₂ ≤ r ∧ + n+(p₀+p₁+p₂) ≤ 3*r := by + let A := R.val.val.1.val + let B := R.val.val.2.1.val + let C := R.val.val.2.2.val + have hdis := triple_pairwise_disjoint A B C R.val.property.1 + have hdA : finrank K A = r := R.val.val.1.property + have hdB : finrank K B = r := R.val.val.2.1.property + have hdC : finrank K C = r := R.val.val.2.2.property + have hp₀ : finrank K ↥(A ⊓ B) = p₀ := R.val.property.2.1 + have hp₁ : finrank K ↥(A ⊓ C) = p₁ := R.val.property.2.2.1 + have hp₂ : finrank K ↥(B ⊓ C) = p₂ := R.val.property.2.2.2 + have hn : finrank K ↥((A ⊔ B) ⊔ C) = n := R.property + have ha : p₀+p₁ ≤ r := by + have h := Submodule.finrank_mono (show (A ⊓ B) ⊔ (A ⊓ C) ≤ A from sup_le inf_le_left inf_le_left) + rwa [disjoint_sup_finrank _ _ hdis.1,hp₀,hp₁,hdA] at h + have hb : p₀+p₂ ≤ r := by + have h := Submodule.finrank_mono (show (A ⊓ B) ⊔ (B ⊓ C) ≤ B from sup_le inf_le_right inf_le_left) + rwa [disjoint_sup_finrank _ _ hdis.2.1,hp₀,hp₂,hdB] at h + have hc : p₁+p₂ ≤ r := by + have h := Submodule.finrank_mono (show (A ⊓ C) ⊔ (B ⊓ C) ≤ C from sup_le inf_le_right inf_le_right) + rwa [disjoint_sup_finrank _ _ hdis.2.2,hp₁,hp₂,hdC] at h + refine ⟨hn ▸ Submodule.finrank_le _,?_,ha,hb,hc,?_⟩ + · have h := Submodule.finrank_mono (show A ≤ (A ⊔ B) ⊔ C from le_trans le_sup_left le_sup_left) + rwa [hdA,hn] at h + · have h₁ := Submodule.finrank_sup_add_finrank_inf_eq A B + have h₂ := Submodule.finrank_sup_add_finrank_inf_eq (A ⊔ B) C + have h₃ := Submodule.finrank_mono (show (A ⊓ C) ⊔ (B ⊓ C) ≤ (A ⊔ B) ⊓ C from + sup_le (inf_le_inf le_sup_left le_rfl) (inf_le_inf le_sup_right le_rfl)) + rw [disjoint_sup_finrank _ _ hdis.2.2,hp₁,hp₂] at h₃ + rw [hdA,hdB,hp₀] at h₁ + rw [hn,hdC] at h₂ + omega +end ProfileConstraints + +section DualLiftSum +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] + [Fintype K] [Finite V] + + theorem center_stratum_cube (r : ℕ) (hr : r ≤ finrank K V) : + (Nat.card {L : Lagrangian (K := K) (V := V) // + finrank K ↥(L.val ⊓ verticalSpace (K := K) (V := V)) = r} : ℝ)^3 = + (Nat.card (DimSubspace K (Module.Dual K V) r) : ℝ)^3 * + (Fintype.card K : ℝ)^(3*((finrank K V-r+1).choose 2)) := by + rw [vertical_pair_count r hr,Nat.cast_mul,Nat.cast_pow,mul_pow, + Nat.card_congr (dualDimSubspaceEquiv (K := K) (V := V) r hr),←pow_mul,Nat.mul_comm _ 3] + + theorem dual_lift_sum_probability_bound (r p₀ p₁ p₂ n t₀ t₁ t₂ : ℕ) (hr : r ≤ finrank K V) : + (Nat.card (Σ R : SubspaceTripleSpanProfile (K := K) (V := Module.Dual K V) r p₀ p₁ p₂ n, + DualLiftEvent R t₀ t₁ t₂) : ℝ) / + (Nat.card {L : Lagrangian (K := K) (V := V) // + finrank K ↥(L.val ⊓ verticalSpace (K := K) (V := V)) = r} : ℝ)^3 ≤ + ((Nat.card (SubspaceTripleSpanProfile (K := K) (V := Module.Dual K V) r p₀ p₁ p₂ n) : ℝ) / + (Nat.card (DimSubspace K (Module.Dual K V) r) : ℝ)^3) * + (2^(t₀+t₁+t₂) * (Fintype.card K : ℝ)^((finrank K V-n+1).choose 2) / + (Fintype.card K : ℝ)^((t₀+1).choose 2+(t₁+1).choose 2+(t₂+1).choose 2)) := by + classical + let : Finite (Module.Dual K V) := Module.finite_of_finite K + let RType := SubspaceTripleSpanProfile (K := K) (V := Module.Dual K V) r p₀ p₁ p₂ n + let : Fintype RType := Fintype.ofFinite _ + let q : ℝ := Fintype.card K + let f := 3*((finrank K V-r+1).choose 2) + let b : ℝ := 2^(t₀+t₁+t₂)*q^((finrank K V-n+1).choose 2)/ + q^((t₀+1).choose 2+(t₁+1).choose 2+(t₂+1).choose 2) + have hq : 0 < q := by dsimp [q]; exact_mod_cast Fintype.card_pos (α := K) + have hF : 0 < q^f := pow_pos hq _ + have hb (R : RType) : (Nat.card (DualLiftEvent R t₀ t₁ t₂) : ℝ) ≤ b*q^f := by + have h := dual_lift_probability_bound R t₀ t₁ t₂ + rw [dualProfileForms_card,Nat.cast_pow] at h + exact (div_le_iff₀ hF).mp h + have hc : (Nat.card (Σ R : RType, DualLiftEvent R t₀ t₁ t₂) : ℝ) ≤ + (Nat.card RType : ℝ)*b*q^f := by + rw [Nat.card_sigma,Nat.cast_sum] + calc + _ ≤ ∑ _R : RType, b*q^f := Finset.sum_le_sum (fun R _ => hb R) + _ = _ := by simp only [Finset.sum_const,nsmul_eq_mul,Finset.card_univ,Nat.card_eq_fintype_card]; ring + rw [center_stratum_cube r hr] + refine (div_le_div_of_nonneg_right hc (by positivity)).trans_eq ?_ + change (Nat.card RType : ℝ)*b*q^f / ((Nat.card (DimSubspace K (Module.Dual K V) r) : ℝ)^3*q^f) = _ + rw [mul_div_mul_right _ _ hF.ne'] + ring + +end DualLiftSum +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section CanonicalCoding +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] +abbrev CenterStratum (r : ℕ) := {L : Lagrangian (K := K) (V := V) // + finrank K ↥(L.val ⊓ verticalSpace (K := K) (V := V)) = r} + +noncomputable def dualPairStratumEquiv (r : ℕ) (hr : r ≤ finrank K V) : + (Σ R : DimSubspace K (Module.Dual K V) r, SymForm K R.val.dualCoannihilator) ≃ + CenterStratum (K := K) (V := V) r := + (Equiv.sigmaCongrLeft (β := fun U : DimSubspace K V (finrank K V-r) => SymForm K U.val) + (dualDimSubspaceEquiv (K := K) (V := V) r hr).symm).trans (pairStratumEquiv r hr) + + theorem dualPairStratumEquiv_apply (r : ℕ) (hr : r ≤ finrank K V) + (R : DimSubspace K (Module.Dual K V) r) (F : SymForm K R.val.dualCoannihilator) : + (dualPairStratumEquiv r hr ⟨R,F⟩).val = dualGraph R.val F := rfl + +abbrev DualBaseTriple (r : ℕ) := DimSubspace K (Module.Dual K V) r × + DimSubspace K (Module.Dual K V) r × DimSubspace K (Module.Dual K V) r +abbrev DualBaseForms {r : ℕ} (R : DualBaseTriple (K := K) (V := V) r) := + OriginalForms R.1.val.dualCoannihilator R.2.1.val.dualCoannihilator R.2.2.val.dualCoannihilator +noncomputable def dualBaseTripleGraph {r : ℕ} (R : DualBaseTriple (K := K) (V := V) r) + (F : DualBaseForms R) : Lagrangian (K := K) (V := V) × Lagrangian (K := K) (V := V) × Lagrangian (K := K) (V := V) := + (dualGraph R.1.val F.1,dualGraph R.2.1.val F.2.1,dualGraph R.2.2.val F.2.2) + +noncomputable def dualTripleStratumEquiv (r : ℕ) (hr : r ≤ finrank K V) : + (Σ R : DualBaseTriple (K := K) (V := V) r, DualBaseForms R) ≃ + CenterStratum (K := K) (V := V) r × CenterStratum (K := K) (V := V) r × CenterStratum (K := K) (V := V) r := + let e : (Σ R : DualBaseTriple (K := K) (V := V) r, DualBaseForms R) ≃ + (Σ R : DimSubspace K (Module.Dual K V) r, SymForm K R.val.dualCoannihilator) × + (Σ R : DimSubspace K (Module.Dual K V) r, SymForm K R.val.dualCoannihilator) × + (Σ R : DimSubspace K (Module.Dual K V) r, SymForm K R.val.dualCoannihilator) := + { toFun := fun RF => (⟨RF.1.1,RF.2.1⟩,⟨RF.1.2.1,RF.2.2.1⟩,⟨RF.1.2.2,RF.2.2.2⟩) + invFun := fun p => ⟨(p.1.1,p.2.1.1,p.2.2.1),(p.1.2,p.2.1.2,p.2.2.2)⟩ + left_inv := fun _ => rfl + right_inv := fun _ => rfl } + e.trans ((dualPairStratumEquiv r hr).prodCongr ((dualPairStratumEquiv r hr).prodCongr (dualPairStratumEquiv r hr))) + + theorem dualTripleStratumEquiv_graph (r : ℕ) (hr : r ≤ finrank K V) + (RF : Σ R : DualBaseTriple (K := K) (V := V) r, DualBaseForms R) : + ((dualTripleStratumEquiv r hr RF).1.val,(dualTripleStratumEquiv r hr RF).2.1.val, + (dualTripleStratumEquiv r hr RF).2.2.val) = dualBaseTripleGraph RF.1 RF.2 := rfl + + theorem dualGraph_pair_finrank_ge (R S : Submodule K (Module.Dual K V)) + (F : SymForm K R.dualCoannihilator) (G : SymForm K S.dualCoannihilator) : + finrank K ↥(R ⊓ S) ≤ finrank K ↥((dualGraph R F).val ⊓ (dualGraph S G).val) := by + change _ ≤ finrank K ↥(formGraph R.dualCoannihilator F.val ⊓ formGraph S.dualCoannihilator G.val) + rw [graph_pair_intersection_finrank, + Subspace.dualCoannihilator_dualAnnihilator_eq,Subspace.dualCoannihilator_dualAnnihilator_eq] + exact Nat.le_add_right _ _ + +abbrev CanonicalLiftProfile (r s₀ s₁ s₂ : ℕ) := + {RF : Σ R : DualBaseTriple (K := K) (V := V) r, DualBaseForms R // + let L := dualBaseTripleGraph RF.1 RF.2 + (L.1.val ⊓ L.2.1.val) ⊓ L.2.2.val = ⊥ ∧ + finrank K ↥(L.1.val ⊓ L.2.1.val) = s₀ ∧ + finrank K ↥(L.1.val ⊓ L.2.2.val) = s₁ ∧ + finrank K ↥(L.2.1.val ⊓ L.2.2.val) = s₂} + +end CanonicalCoding +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section ExtraFeasibility +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] + + theorem coannihilator_pair_finrank (R S : Submodule K (Module.Dual K V)) : + finrank K ↥(R.dualCoannihilator ⊓ S.dualCoannihilator) + finrank K R + finrank K S = + finrank K V + finrank K ↥(R ⊓ S) := by + rw [←Submodule.dualCoannihilator_sup_eq] + have h := coannihilator_finrank (R ⊔ S) + have hg := Submodule.finrank_sup_add_finrank_inf_eq R S + omega + + theorem dualGraph_pair_finrank_le (R S : Submodule K (Module.Dual K V)) + (F : SymForm K R.dualCoannihilator) (G : SymForm K S.dualCoannihilator) : + finrank K ↥((dualGraph R F).val ⊓ (dualGraph S G).val) ≤ + finrank K ↥(R ⊓ S)+finrank K ↥(R.dualCoannihilator ⊓ S.dualCoannihilator) := by + change finrank K ↥(formGraph R.dualCoannihilator F.val ⊓ formGraph S.dualCoannihilator G.val) ≤ _ + rw [graph_pair_intersection_finrank, + Subspace.dualCoannihilator_dualAnnihilator_eq,Subspace.dualCoannihilator_dualAnnihilator_eq] + exact Nat.add_le_add_left (Submodule.finrank_le _) _ + + theorem dualGraph_pair_extra_feasible {r s : ℕ} (R S : DimSubspace K (Module.Dual K V) r) + (F : SymForm K R.val.dualCoannihilator) (G : SymForm K S.val.dualCoannihilator) + (hs : finrank K ↥((dualGraph R.val F).val ⊓ (dualGraph S.val G).val) = s) : + (s-finrank K ↥(R.val ⊓ S.val))+2*r ≤ finrank K V+finrank K ↥(R.val ⊓ S.val) := by + have h₁ := dualGraph_pair_finrank_ge R.val S.val F G + have h₂ := dualGraph_pair_finrank_le R.val S.val F G + have h₃ := coannihilator_pair_finrank R.val S.val + rw [hs] at h₁ h₂ + rw [R.property,S.property] at h₃ + omega + + theorem dual_common_pair_extra_feasible {r p₀ p₁ p₂ n : ℕ} + (R : SubspaceTripleSpanProfile (K := K) (V := Module.Dual K V) r p₀ p₁ p₂ n) : + (finrank K V-n)+2*r ≤ finrank K V+p₀ ∧ + (finrank K V-n)+2*r ≤ finrank K V+p₁ ∧ + (finrank K V-n)+2*r ≤ finrank K V+p₂ := by + let A := R.val.val.1.val + let B := R.val.val.2.1.val + let C := R.val.val.2.2.val + have hdA : finrank K A = r := R.val.val.1.property + have hdB : finrank K B = r := R.val.val.2.1.property + have hdC : finrank K C = r := R.val.val.2.2.property + have hp₀ : finrank K ↥(A ⊓ B) = p₀ := R.val.property.2.1 + have hp₁ : finrank K ↥(A ⊓ C) = p₁ := R.val.property.2.2.1 + have hp₂ : finrank K ↥(B ⊓ C) = p₂ := R.val.property.2.2.2 + have hn : finrank K ↥((A ⊔ B) ⊔ C) = n := R.property + have hv := coannihilator_common_finrank A B C + rw [hn] at hv + have h₀ := Submodule.finrank_mono (show (A.dualCoannihilator ⊓ B.dualCoannihilator) ⊓ C.dualCoannihilator ≤ + A.dualCoannihilator ⊓ B.dualCoannihilator from inf_le_left) + have h₁ := Submodule.finrank_mono (show (A.dualCoannihilator ⊓ B.dualCoannihilator) ⊓ C.dualCoannihilator ≤ + A.dualCoannihilator ⊓ C.dualCoannihilator from inf_le_inf inf_le_left le_rfl) + have h₂ := Submodule.finrank_mono (show (A.dualCoannihilator ⊓ B.dualCoannihilator) ⊓ C.dualCoannihilator ≤ + B.dualCoannihilator ⊓ C.dualCoannihilator from inf_le_inf inf_le_right le_rfl) + rw [hv] at h₀ h₁ h₂ + have hc₀ := coannihilator_pair_finrank A B + have hc₁ := coannihilator_pair_finrank A C + have hc₂ := coannihilator_pair_finrank B C + rw [hdA,hdB,hp₀] at hc₀ + rw [hdA,hdC,hp₁] at hc₁ + rw [hdB,hdC,hp₂] at hc₂ + omega + +end ExtraFeasibility +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section CanonicalParameterCount +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] + +abbrev FourDims (d : ℕ) := Fin (d+1) × Fin (d+1) × Fin (d+1) × Fin (d+1) +def BaseFeasible (r s₀ s₁ s₂ : ℕ) {d : ℕ} (θ : FourDims d) : Prop := + r ≤ θ.2.2.2.val ∧ θ.1.val+θ.2.1.val ≤ r ∧ θ.1.val+θ.2.2.1.val ≤ r ∧ + θ.2.1.val+θ.2.2.1.val ≤ r ∧ θ.2.2.2.val+(θ.1.val+θ.2.1.val+θ.2.2.1.val) ≤ 3*r ∧ + θ.1.val ≤ s₀ ∧ θ.2.1.val ≤ s₁ ∧ θ.2.2.1.val ≤ s₂ ∧ + (s₀-θ.1.val)+2*r ≤ d+θ.1.val ∧ (s₁-θ.2.1.val)+2*r ≤ d+θ.2.1.val ∧ + (s₂-θ.2.2.1.val)+2*r ≤ d+θ.2.2.1.val ∧ + (d-θ.2.2.2.val)+2*r ≤ d+θ.1.val ∧ (d-θ.2.2.2.val)+2*r ≤ d+θ.2.1.val ∧ + (d-θ.2.2.2.val)+2*r ≤ d+θ.2.2.1.val +abbrev BaseParameters (d r s₀ s₁ s₂ : ℕ) := {θ : FourDims d // BaseFeasible r s₀ s₁ s₂ θ} + +noncomputable def canonicalLiftFourDims {r s₀ s₁ s₂ : ℕ} + (P : CanonicalLiftProfile (K := K) (V := V) r s₀ s₁ s₂) : FourDims (finrank K V) := + let bound (R : Submodule K (Module.Dual K V)) : finrank K R < finrank K V+1 := by + have h := Submodule.finrank_le R + rw [Subspace.dual_finrank_eq] at h + omega + (⟨finrank K ↥(P.val.1.1.val ⊓ P.val.1.2.1.val),bound _⟩, + ⟨finrank K ↥(P.val.1.1.val ⊓ P.val.1.2.2.val),bound _⟩, + ⟨finrank K ↥(P.val.1.2.1.val ⊓ P.val.1.2.2.val),bound _⟩, + ⟨finrank K ↥((P.val.1.1.val ⊔ P.val.1.2.1.val) ⊔ P.val.1.2.2.val),bound _⟩) + +noncomputable def canonicalLiftSubspaces {r s₀ s₁ s₂ : ℕ} + (P : CanonicalLiftProfile (K := K) (V := V) r s₀ s₁ s₂) : + SubspaceTripleSpanProfile (K := K) (V := Module.Dual K V) r + (canonicalLiftFourDims P).1.val (canonicalLiftFourDims P).2.1.val + (canonicalLiftFourDims P).2.2.1.val (canonicalLiftFourDims P).2.2.2.val := + ⟨⟨P.val.1,dualGraph_common_zero _ _ _ P.val.2 P.property.1,rfl,rfl,rfl⟩,rfl⟩ + + theorem canonicalLift_feasible {r s₀ s₁ s₂ : ℕ} + (P : CanonicalLiftProfile (K := K) (V := V) r s₀ s₁ s₂) : + BaseFeasible r s₀ s₁ s₂ (canonicalLiftFourDims P) := by + have hc := subspace_profile_constraints (canonicalLiftSubspaces P) + refine ⟨hc.2.1,hc.2.2.1,hc.2.2.2.1,hc.2.2.2.2.1,hc.2.2.2.2.2,?_,?_,?_,?_,?_,?_,?_⟩ + · exact (dualGraph_pair_finrank_ge _ _ P.val.2.1 P.val.2.2.1).trans_eq P.property.2.1 + · exact (dualGraph_pair_finrank_ge _ _ P.val.2.1 P.val.2.2.2).trans_eq P.property.2.2.1 + · exact (dualGraph_pair_finrank_ge _ _ P.val.2.2.1 P.val.2.2.2).trans_eq P.property.2.2.2 + · exact dualGraph_pair_extra_feasible P.val.1.1 P.val.1.2.1 P.val.2.1 P.val.2.2.1 P.property.2.1 + · exact dualGraph_pair_extra_feasible P.val.1.1 P.val.1.2.2 P.val.2.1 P.val.2.2.2 P.property.2.2.1 + · exact dualGraph_pair_extra_feasible P.val.1.2.1 P.val.1.2.2 P.val.2.2.1 P.val.2.2.2 P.property.2.2.2 + · exact dual_common_pair_extra_feasible (canonicalLiftSubspaces P) + + theorem dualGraph_pair_gap_bound (R S : Submodule K (Module.Dual K V)) + (F : SymForm K R.dualCoannihilator) (G : SymForm K S.dualCoannihilator) + {p s : ℕ} (hp : finrank K ↥(R ⊓ S) = p) + (hs : finrank K ↥((dualGraph R F).val ⊓ (dualGraph S G).val) = s) : + p+(s-p) ≤ finrank K ↥((dualGraph R F).val ⊓ (dualGraph S G).val) := by + have h := dualGraph_pair_finrank_ge R S F G + rw [hp,hs] at h + rw [hs] + omega + +noncomputable def dualLift_of_exactDims {r p₀ p₁ p₂ n s₀ s₁ s₂ : ℕ} + (R : SubspaceTripleSpanProfile (K := K) (V := Module.Dual K V) r p₀ p₁ p₂ n) + (F : DualProfileForms R) + (hs₀ : finrank K ↥((dualGraph R.val.val.1.val F.1).val ⊓ (dualGraph R.val.val.2.1.val F.2.1).val) = s₀) + (hs₁ : finrank K ↥((dualGraph R.val.val.1.val F.1).val ⊓ (dualGraph R.val.val.2.2.val F.2.2).val) = s₁) + (hs₂ : finrank K ↥((dualGraph R.val.val.2.1.val F.2.1).val ⊓ (dualGraph R.val.val.2.2.val F.2.2).val) = s₂) : + DualLiftEvent R (s₀-p₀) (s₁-p₁) (s₂-p₂) := + ⟨F,dualGraph_pair_gap_bound _ _ F.2.1 F.2.2 R.val.property.2.2.2 hs₂, + by + have h := dualGraph_pair_gap_bound _ _ F.1 F.2.2 R.val.property.2.2.1 hs₁ + rwa [inf_comm] at h, + dualGraph_pair_gap_bound _ _ F.1 F.2.1 R.val.property.2.1 hs₀⟩ + +noncomputable def canonicalLiftCoding {r s₀ s₁ s₂ : ℕ} + (P : CanonicalLiftProfile (K := K) (V := V) r s₀ s₁ s₂) : + Σ θ : BaseParameters (finrank K V) r s₀ s₁ s₂, + Σ R : SubspaceTripleSpanProfile (K := K) (V := Module.Dual K V) + r θ.val.1.val θ.val.2.1.val θ.val.2.2.1.val θ.val.2.2.2.val, + DualLiftEvent R (s₀-θ.val.1.val) (s₁-θ.val.2.1.val) (s₂-θ.val.2.2.1.val) := + ⟨⟨canonicalLiftFourDims P,canonicalLift_feasible P⟩,canonicalLiftSubspaces P, + dualLift_of_exactDims (canonicalLiftSubspaces P) P.val.2 P.property.2.1 P.property.2.2.1 P.property.2.2.2⟩ + + theorem canonicalLiftCoding_injective (r s₀ s₁ s₂ : ℕ) : + Function.Injective (canonicalLiftCoding (K := K) (V := V) (r := r) (s₀ := s₀) (s₁ := s₁) (s₂ := s₂)) := by + let recover : (Σ θ : BaseParameters (finrank K V) r s₀ s₁ s₂, + Σ R : SubspaceTripleSpanProfile (K := K) (V := Module.Dual K V) + r θ.val.1.val θ.val.2.1.val θ.val.2.2.1.val θ.val.2.2.2.val, + DualLiftEvent R (s₀-θ.val.1.val) (s₁-θ.val.2.1.val) (s₂-θ.val.2.2.1.val)) → + Σ R : DualBaseTriple (K := K) (V := V) r, DualBaseForms R := + fun T => ⟨T.2.1.val.val,T.2.2.val⟩ + intro P Q h + exact Subtype.ext (congrArg recover h) + +abbrev CenterTripleProfile (r s₀ s₁ s₂ : ℕ) := + {L : CenterStratum (K := K) (V := V) r × CenterStratum (K := K) (V := V) r × CenterStratum (K := K) (V := V) r // + (L.1.val.val ⊓ L.2.1.val.val) ⊓ L.2.2.val.val = ⊥ ∧ + finrank K ↥(L.1.val.val ⊓ L.2.1.val.val) = s₀ ∧ + finrank K ↥(L.1.val.val ⊓ L.2.2.val.val) = s₁ ∧ + finrank K ↥(L.2.1.val.val ⊓ L.2.2.val.val) = s₂} + +noncomputable def canonicalCenterProfileEquiv (r s₀ s₁ s₂ : ℕ) (hr : r ≤ finrank K V) : + CanonicalLiftProfile (K := K) (V := V) r s₀ s₁ s₂ ≃ CenterTripleProfile (K := K) (V := V) r s₀ s₁ s₂ := + Equiv.subtypeEquiv (dualTripleStratumEquiv r hr) (fun _ => Iff.rfl) + +end CanonicalParameterCount +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators + +noncomputable instance baseParametersFintype (d r s₀ s₁ s₂ : ℕ) : Fintype (BaseParameters d r s₀ s₁ s₂) := Fintype.ofFinite _ + +def reducedPlantedExponent (d r s₀ s₁ s₂ : ℕ) (θ : FourDims d) : ℝ := + -((d:ℝ)-2*r)*(θ.1.val+θ.2.1.val+θ.2.2.1.val) - + ((θ.1.val:ℝ)^2+θ.2.1.val^2+θ.2.2.1.val^2) - + ((d:ℝ)-θ.2.2.2.val)*(3*r-θ.2.2.2.val-(θ.1.val+θ.2.1.val+θ.2.2.1.val)) + + ((d-θ.2.2.2.val+1).choose 2 : ℕ) - + (((s₀-θ.1.val+1).choose 2+(s₁-θ.2.1.val+1).choose 2+(s₂-θ.2.2.1.val+1).choose 2 : ℕ) : ℝ) + +def reducedPlantedConstant (r s₀ s₁ s₂ : ℕ) {d : ℕ} (θ : FourDims d) : ℝ := + 2^(θ.2.2.2.val+θ.1.val+θ.2.1.val+θ.2.2.1.val+3*r+(s₀-θ.1.val)+(s₁-θ.2.1.val)+(s₂-θ.2.2.1.val)) + +section CanonicalNumericalBound +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] [Fintype K] [Finite V] + + theorem reducedPlanted_bound_one (r s₀ s₁ s₂ : ℕ) + (θ : BaseParameters (finrank K V) r s₀ s₁ s₂) : + (Nat.card (Σ R : SubspaceTripleSpanProfile (K := K) (V := Module.Dual K V) + r θ.val.1.val θ.val.2.1.val θ.val.2.2.1.val θ.val.2.2.2.val, + DualLiftEvent R (s₀-θ.val.1.val) (s₁-θ.val.2.1.val) (s₂-θ.val.2.2.1.val)) : ℝ) / + (Nat.card (CenterStratum (K := K) (V := V) r) : ℝ)^3 ≤ + reducedPlantedConstant r s₀ s₁ s₂ θ.val * + (Fintype.card K : ℝ)^(reducedPlantedExponent (finrank K V) r s₀ s₁ s₂ θ.val) := by + let p₀ := θ.val.1.val + let p₁ := θ.val.2.1.val + let p₂ := θ.val.2.2.1.val + let n := θ.val.2.2.2.val + let t₀ := s₀-p₀ + let t₁ := s₁-p₁ + let t₂ := s₂-p₂ + have hn : n ≤ finrank K V := Nat.le_of_lt_succ θ.val.2.2.2.isLt + have hcon := θ.property + have hr : r ≤ n := hcon.1 + have hh := dual_lift_sum_probability_bound (K := K) (V := V) r p₀ p₁ p₂ n t₀ t₁ t₂ (hr.trans hn) + have hp := subspace_span_probability_bound (K := K) (V := Module.Dual K V) r p₀ p₁ p₂ n + (by rwa [Subspace.dual_finrank_eq]) hr hcon.2.1 hcon.2.2.1 hcon.2.2.2.1 + rw [Subspace.dual_finrank_eq] at hp + refine hh.trans ((mul_le_mul_of_nonneg_right hp (by positivity)).trans_eq ?_) + let q : ℝ := Fintype.card K + have hq : 0 < q := by dsimp [q]; exact_mod_cast Fintype.card_pos (α := K) + let e : ℝ := -((finrank K V:ℝ)-2*r)*(p₀+p₁+p₂) - ((p₀:ℝ)^2+p₁^2+p₂^2) - + ((finrank K V:ℝ)-n)*(3*r-n-(p₀+p₁+p₂)) + change (2^(n+p₀+p₁+p₂+3*r) * q^e) * + (2^(t₀+t₁+t₂)*q^((finrank K V-n+1).choose 2)/q^((t₀+1).choose 2+(t₁+1).choose 2+(t₂+1).choose 2)) = _ + have he : reducedPlantedExponent (finrank K V) r s₀ s₁ s₂ θ.val = + e+((finrank K V-n+1).choose 2 : ℕ)-(((t₀+1).choose 2+(t₁+1).choose 2+(t₂+1).choose 2 : ℕ) : ℝ) := rfl + rw [he,Real.rpow_sub hq (e+((finrank K V-n+1).choose 2 : ℕ)) + (((t₀+1).choose 2+(t₁+1).choose 2+(t₂+1).choose 2 : ℕ) : ℝ), + Real.rpow_add hq e ((finrank K V-n+1).choose 2 : ℕ),Real.rpow_natCast,Real.rpow_natCast] + simp only [reducedPlantedConstant, pow_add] + change _ = 2^n*2^p₀*2^p₁*2^p₂*2^(3*r)*2^t₀*2^t₁*2^t₂ * _ + ring + + theorem canonical_center_profile_probability_bound (r s₀ s₁ s₂ : ℕ) (hr : r ≤ finrank K V) : + (Nat.card (CenterTripleProfile (K := K) (V := V) r s₀ s₁ s₂) : ℝ) / + (Nat.card (CenterStratum (K := K) (V := V) r) : ℝ)^3 ≤ + ∑ θ : BaseParameters (finrank K V) r s₀ s₁ s₂, + reducedPlantedConstant r s₀ s₁ s₂ θ.val * + (Fintype.card K : ℝ)^(reducedPlantedExponent (finrank K V) r s₀ s₁ s₂ θ.val) := by + classical + let : Finite (Module.Dual K V) := Module.finite_of_finite K + have hi := Nat.card_le_card_of_injective _ (canonicalLiftCoding_injective (K := K) (V := V) r s₀ s₁ s₂) + rw [Nat.card_congr (canonicalCenterProfileEquiv r s₀ s₁ s₂ hr),Nat.card_sigma] at hi + have hi' := (Nat.cast_le (α := ℝ)).mpr hi + rw [Nat.cast_sum] at hi' + refine (div_le_div_of_nonneg_right hi' (by positivity)).trans ?_ + rw [Finset.sum_div] + exact Finset.sum_le_sum (fun θ _ => reducedPlanted_bound_one r s₀ s₁ s₂ θ) + +end CanonicalNumericalBound +end SidorenkoCounterexample + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/OrbitBounds.lean b/lean/OAI/Combinatorics/Sidorenko/OrbitBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..5354e1d81b10272db0d52574e7f50f56c428c1ed --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/OrbitBounds.lean @@ -0,0 +1,959 @@ +import OAI.Combinatorics.Sidorenko.Configurations + +namespace OAI + +namespace SidorenkoCounterexample +open Module +section CommonOrbitGeometry +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] + [FiniteDimensional K E] +variable (ω : LinearMap.BilinForm K E) + + theorem reduceSubspace_finrank_containing (S A : Submodule K E) + (hSA : S ≤ A) (hAP : A ≤ ω.orthogonal S) : + finrank K (reduceSubspace ω S A) + finrank K S = finrank K A := by + let f : A →ₗ[K] ReducedSpace ω S := (reductionKernel ω S).mkQ.comp (Submodule.inclusion hAP) + have hk : LinearMap.ker f = S.comap A.subtype := by + ext x + exact Submodule.Quotient.mk_eq_zero (reductionKernel ω S) + have hr : LinearMap.range f = reduceSubspace ω S A := by + ext y + constructor + · rintro ⟨x,rfl⟩ + exact ⟨⟨x.val,hAP x.property⟩,x.property,rfl⟩ + · rintro ⟨x,hx,rfl⟩ + exact ⟨⟨x.val,hx⟩,rfl⟩ + have hh := f.finrank_range_add_finrank_ker + rw [hk,hr,(Submodule.comapSubtypeEquivOfLe hSA).finrank_eq] at hh + exact hh + +noncomputable def commonReductionLagrangian (S : Submodule K E) (ha : ω.IsAlt) + (hS : S ≤ ω.orthogonal S) (L : SymplecticLagrangian ω) (hSL : S ≤ L.val) : + SymplecticLagrangian (symplecticReductionForm ω S ha) := + ⟨reduceSubspace ω S L.val,reduce_lagrangian ω S ha hS L.val L.property hSL⟩ + + theorem commonOrbit_injection [Finite E] (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (L M N : SymplecticLagrangian ω) : + let S := (L.val ⊓ M.val) ⊓ N.val + ∃ f : IsotropicDimspace ω (finrank K S) × + OrderedTripleOrbit (symplecticReductionForm ω S ha) + (reduceSubspace ω S L.val) (reduceSubspace ω S M.val) (reduceSubspace ω S N.val) → + OrderedTripleOrbit ω L.val M.val N.val, Function.Injective f := by + dsimp only + classical + let S := (L.val ⊓ M.val) ⊓ N.val + have hSL : S ≤ L.val := inf_le_left.trans inf_le_left + have hSM : S ≤ M.val := inf_le_left.trans inf_le_right + have hSN : S ≤ N.val := inf_le_right + have hS : S ≤ ω.orthogonal S := by + intro x hx y hy + exact L.property.ge (hSL hx) y (hSL hy) + let η := symplecticReductionForm ω S ha + let L' := commonReductionLagrangian ω S ha hS L hSL + let M' := commonReductionLagrangian ω S ha hS M hSM + let N' := commonReductionLagrangian ω S ha hS N hSN + have hzero : (L'.val ⊓ M'.val) ⊓ N'.val = ⊥ := by + change (reduceSubspace ω S L.val ⊓ reduceSubspace ω S M.val) ⊓ reduceSubspace ω S N.val = ⊥ + rw [←reduceSubspace_inf ω S L.val M.val hSL, + ←reduceSubspace_inf ω S (L.val ⊓ M.val) N.val inf_le_left] + exact reduceSubspace_self ω S + have ht (T : IsotropicDimspace ω (finrank K S)) := isotropic_transitivity ω h2 ha hω + S T.val hS T.property.1 T.property.2.symm + let e (T : IsotropicDimspace ω (finrank K S)) := (ht T).choose + have he (T : IsotropicDimspace ω (finrank K S)) := (ht T).choose_spec + let Orb := OrderedTripleOrbit η L'.val M'.val N'.val + have hpLag (p : Orb) := orderedTripleOrbit_lagrangians η L' M' N' p + have hpzero (p : Orb) : (p.val.1 ⊓ p.val.2.1) ⊓ p.val.2.2 = ⊥ := by + obtain ⟨g,_,hgL,hgM,hgN⟩ := p.property + rw [←hgL,←hgM,←hgN,←Submodule.map_inf g.toLinearMap g.injective, + ←Submodule.map_inf g.toLinearMap g.injective,hzero,Submodule.map_bot] + have hgood (p : Orb) : TripleIsometry ω ω L.val M.val N.val + (liftReduction ω S p.val.1) (liftReduction ω S p.val.2.1) (liftReduction ω S p.val.2.2) := by + apply triple_containing_isometry_lift ω S ha hω hS L.val M.val N.val + (liftReduction ω S p.val.1) (liftReduction ω S p.val.2.1) (liftReduction ω S p.val.2.2) + L.property M.property N.property + (liftReduction_lagrangian ω S ha hS _ (hpLag p).1) + (liftReduction_lagrangian ω S ha hS _ (hpLag p).2.1) + (liftReduction_lagrangian ω S ha hS _ (hpLag p).2.2) + hSL hSM hSN (le_liftReduction ω S hS _) (le_liftReduction ω S hS _) (le_liftReduction ω S hS _) + rw [reduce_lift,reduce_lift,reduce_lift] + exact p.property + have hgood' (T : IsotropicDimspace ω (finrank K S)) (p : Orb) : TripleIsometry ω ω L.val M.val N.val + ((liftReduction ω S p.val.1).map (e T).toLinearMap) + ((liftReduction ω S p.val.2.1).map (e T).toLinearMap) + ((liftReduction ω S p.val.2.2).map (e T).toLinearMap) := by + obtain ⟨g,hg,hgL,hgM,hgN⟩ := hgood p + refine ⟨g.trans (e T),?_,?_,?_,?_⟩ + · intro x y + exact ((he T).1 (g x) (g y)).trans (hg x y) + · rw [submodule_map_trans,hgL] + · rw [submodule_map_trans,hgM] + · rw [submodule_map_trans,hgN] + let f : IsotropicDimspace ω (finrank K S) × Orb → OrderedTripleOrbit ω L.val M.val N.val := fun p => + ⟨((liftReduction ω S p.2.val.1).map (e p.1).toLinearMap, + (liftReduction ω S p.2.val.2.1).map (e p.1).toLinearMap, + (liftReduction ω S p.2.val.2.2).map (e p.1).toLinearMap),hgood' p.1 p.2⟩ + have hrec (p) : ((f p).val.1 ⊓ (f p).val.2.1) ⊓ (f p).val.2.2 = p.1.val := by + change (((liftReduction ω S p.2.val.1).map (e p.1).toLinearMap) ⊓ + ((liftReduction ω S p.2.val.2.1).map (e p.1).toLinearMap)) ⊓ + ((liftReduction ω S p.2.val.2.2).map (e p.1).toLinearMap) = _ + rw [←Submodule.map_inf (e p.1).toLinearMap (e p.1).injective, + ←Submodule.map_inf (e p.1).toLinearMap (e p.1).injective, + ←liftReduction_inf,←liftReduction_inf,hpzero, liftReduction_bot ω S hS] + exact (he p.1).2 + refine ⟨f,?_⟩ + rintro ⟨T,p⟩ ⟨T',p'⟩ h + have hT : T = T' := by + apply Subtype.ext + exact (hrec (T,p)).symm.trans ((congrArg (fun x : OrderedTripleOrbit ω L.val M.val N.val => + (x.val.1 ⊓ x.val.2.1) ⊓ x.val.2.2) h).trans (hrec (T',p'))) + subst T' + have hv := congrArg Subtype.val h + have hinj := (Submodule.map_injective_of_injective (e T).injective).comp (liftReduction_injective ω S) + have hp : p = p' := Subtype.ext (Prod.ext (hinj (congrArg Prod.fst hv)) + (Prod.ext (hinj (congrArg (fun x => x.2.1) hv)) (hinj (congrArg (fun x => x.2.2) hv)))) + subst p' + rfl + +variable [Finite E] + theorem commonOrbit_card_lower (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (L M N : SymplecticLagrangian ω) : + let S := (L.val ⊓ M.val) ⊓ N.val + Nat.card (IsotropicDimspace ω (finrank K S)) * + Nat.card (OrderedTripleOrbit (symplecticReductionForm ω S ha) + (reduceSubspace ω S L.val) (reduceSubspace ω S M.val) (reduceSubspace ω S N.val)) ≤ + Nat.card (OrderedTripleOrbit ω L.val M.val N.val) := by + obtain ⟨f,hf⟩ := commonOrbit_injection ω h2 ha hω L M N + simpa only [Nat.card_prod] using Nat.card_le_card_of_injective f hf +end CommonOrbitGeometry +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open Module +section AllOrbitMass +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] + [Fintype K] [Finite E] [Invertible (2:K)] +variable (ω : LinearMap.BilinForm K E) + +noncomputable def tripleDefect (D : ℕ) (L M N : Submodule K E) : ℕ := + let c := finrank K ↥((L ⊓ M) ⊓ N) + (D+1)*c + ((finrank K ↥(L ⊓ M)-c+1).choose 2 + + (finrank K ↥(L ⊓ N)-c+1).choose 2 + (finrank K ↥(M ⊓ N)-c+1).choose 2) + + theorem pairOrbitConstant_mono : Monotone pairOrbitConstant := by + intro m n h + unfold pairOrbitConstant + have hm := lagrangianConstant_pos m + have hn := lagrangianConstant_pos n + have hc := lagrangianConstant_mono h + gcongr <;> norm_num + +noncomputable def orbitMassConstant (D : ℕ) : ℝ := lagrangianConstant D*pairOrbitConstant D + + theorem orbitMassConstant_pos (D : ℕ) : 0 < orbitMassConstant D := + mul_pos (lagrangianConstant_pos D) (pairOrbitConstant_pos D) + + theorem tripleOrbit_card_lower (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D = finrank K E) + (hq : 4*lagrangianConstant D ≤ (Fintype.card K : ℝ)) + (L M N : SymplecticLagrangian ω) : + (Fintype.card K : ℝ)^(3*(D+1).choose 2) ≤ + orbitMassConstant D * (Fintype.card K : ℝ)^(tripleDefect D L.val M.val N.val) * + Nat.card (OrderedTripleOrbit ω L.val M.val N.val) := by + let S := (L.val ⊓ M.val) ⊓ N.val + have hSL : S ≤ L.val := inf_le_left.trans inf_le_left + have hSM : S ≤ M.val := inf_le_left.trans inf_le_right + have hSN : S ≤ N.val := inf_le_right + have hS : S ≤ ω.orthogonal S := by + intro x hx y hy + exact L.property.ge (hSL hx) y (hSL hy) + let c := finrank K S + have hc : c ≤ D := isotropic_finrank_le_half ω hω D hD S hS + let η := symplecticReductionForm ω S ha + let L' := commonReductionLagrangian ω S ha hS L hSL + let M' := commonReductionLagrangian ω S ha hS M hSM + let N' := commonReductionLagrangian ω S ha hS N hSN + let : Finite (ReducedSpace ω S) := Module.finite_of_finite K + have hzero : (L'.val ⊓ M'.val) ⊓ N'.val = ⊥ := by + change (reduceSubspace ω S L.val ⊓ reduceSubspace ω S M.val) ⊓ reduceSubspace ω S N.val = ⊥ + rw [←reduceSubspace_inf ω S L.val M.val hSL, + ←reduceSubspace_inf ω S (L.val ⊓ M.val) N.val inf_le_left] + exact reduceSubspace_self ω S + have hdim : 2*(D-c) = finrank K (ReducedSpace ω S) := by + have hh := reducedSpace_finrank ω S hω hS + change _ + 2*c = _ at hh + omega + have hq' : 4*lagrangianConstant (D-c) ≤ (Fintype.card K : ℝ) := + (mul_le_mul_of_nonneg_left (lagrangianConstant_mono (Nat.sub_le D c)) (by norm_num)).trans hq + have hp := commonZeroOrbit_card_lower η (symplecticReductionForm_alt ω S ha) + (symplecticReductionForm_nondegenerate ω S ha hω) (D-c) hdim hq' L' M' N' hzero + have hpair (P Q : SymplecticLagrangian ω) (hSP : S ≤ P.val) (hSQ : S ≤ Q.val) : + finrank K ↥(reduceSubspace ω S P.val ⊓ reduceSubspace ω S Q.val) = + finrank K ↥(P.val ⊓ Q.val)-c := by + rw [←reduceSubspace_inf ω S P.val Q.val hSP] + have hh := reduceSubspace_finrank_containing ω S (P.val ⊓ Q.val) (le_inf hSP hSQ) + (inf_le_left.trans (lagrangian_le_orthogonal ω S P.val P.property hSP)) + change _ + c = _ at hh + omega + change (Fintype.card K : ℝ)^(3*(D-c+1).choose 2) ≤ pairOrbitConstant (D-c) * + (Fintype.card K : ℝ)^((finrank K ↥(reduceSubspace ω S L.val ⊓ reduceSubspace ω S M.val)+1).choose 2 + + (finrank K ↥(reduceSubspace ω S L.val ⊓ reduceSubspace ω S N.val)+1).choose 2 + + (finrank K ↥(reduceSubspace ω S M.val ⊓ reduceSubspace ω S N.val)+1).choose 2) * _ at hp + rw [hpair L M hSL hSM,hpair L N hSL hSN,hpair M N hSM hSN] at hp + have h2 := (isUnit_of_invertible (2:K)).ne_zero + have hi := (isotropic_card_bounds ω h2 ha hω D hD c hc).1 + have hm : (Nat.card (IsotropicDimspace ω c) : ℝ) * + Nat.card (OrderedTripleOrbit η L'.val M'.val N'.val) ≤ + Nat.card (OrderedTripleOrbit ω L.val M.val N.val) := by + exact_mod_cast commonOrbit_card_lower ω h2 ha hω L M N + let δ := (finrank K ↥(L.val ⊓ M.val)-c+1).choose 2 + + (finrank K ↥(L.val ⊓ N.val)-c+1).choose 2 + (finrank K ↥(M.val ⊓ N.val)-c+1).choose 2 + have hconst : lagrangianConstant (D-c)*pairOrbitConstant (D-c) ≤ orbitMassConstant D := + mul_le_mul (lagrangianConstant_mono (Nat.sub_le D c)) (pairOrbitConstant_mono (Nat.sub_le D c)) + (le_of_lt (pairOrbitConstant_pos _)) (le_of_lt (lagrangianConstant_pos _)) + have hm' := mul_le_mul hconst hm (by positivity) (le_of_lt (orbitMassConstant_pos D)) + have hbase : (Fintype.card K : ℝ)^(isotropicExponent D c+3*(D-c+1).choose 2) ≤ + orbitMassConstant D * (Fintype.card K : ℝ)^δ * Nat.card (OrderedTripleOrbit ω L.val M.val N.val) := by + calc + _ ≤ (lagrangianConstant (D-c)*Nat.card (IsotropicDimspace ω c)) * + (pairOrbitConstant (D-c)*(Fintype.card K : ℝ)^δ * Nat.card (OrderedTripleOrbit η L'.val M'.val N'.val)) := by + rw [pow_add] + exact mul_le_mul hi hp (by positivity) (mul_nonneg (le_of_lt (lagrangianConstant_pos _)) (Nat.cast_nonneg _)) + _ = ((lagrangianConstant (D-c)*pairOrbitConstant (D-c))* + ((Nat.card (IsotropicDimspace ω c) : ℝ)*Nat.card (OrderedTripleOrbit η L'.val M'.val N'.val)))* + (Fintype.card K : ℝ)^δ := by ring + _ ≤ (orbitMassConstant D*Nat.card (OrderedTripleOrbit ω L.val M.val N.val))* + (Fintype.card K : ℝ)^δ := mul_le_mul_of_nonneg_right hm' (by positivity) + _ = _ := by ring + have hh := mul_le_mul_of_nonneg_right hbase (show 0 ≤ (Fintype.card K : ℝ)^((D+1)*c) by positivity) + rw [←pow_add,common_cost_cancellation D c hc] at hh + change _ ≤ orbitMassConstant D * (Fintype.card K : ℝ)^((D+1)*c+δ) * _ + rw [pow_add] + calc + _ ≤ (orbitMassConstant D*(Fintype.card K : ℝ)^δ*Nat.card (OrderedTripleOrbit ω L.val M.val N.val))* + (Fintype.card K : ℝ)^((D+1)*c) := hh + _ = _ := by ring +end AllOrbitMass +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section ConfigurationUpper +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] [Finite E] +variable (ω : LinearMap.BilinForm K E) + theorem triple_subspace_orbit_surjection (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (S U V W : Submodule K E) (hS : S ≤ ω.orthogonal S) + (hU : U ≤ S) (hV : V ≤ S) (hW : W ≤ S) (_hsum : U ⊔ V ⊔ W = S) : + ∃ f : IsotropicDimspace ω (finrank K S) × + TripleLinearOrbit (U.comap S.subtype) (V.comap S.subtype) (W.comap S.subtype) → + OrderedTripleOrbit ω U V W, Function.Surjective f := by + classical + have ht (T : IsotropicDimspace ω (finrank K S)) := isotropic_transitivity ω h2 ha hω + S T.val hS T.property.1 T.property.2.symm + let e (T : IsotropicDimspace ω (finrank K S)) := (ht T).choose + have he (T) := (ht T).choose_spec + have hgood (T : IsotropicDimspace ω (finrank K S)) + (p : TripleLinearOrbit (U.comap S.subtype) (V.comap S.subtype) (W.comap S.subtype)) : + ∃ f : E ≃ₗ[K] E, (∀ x y, ω (f x) (f y) = ω x y) ∧ + U.map f.toLinearMap = (p.val.1.map S.subtype).map (e T).toLinearMap ∧ + V.map f.toLinearMap = (p.val.2.1.map S.subtype).map (e T).toLinearMap ∧ + W.map f.toLinearMap = (p.val.2.2.map S.subtype).map (e T).toLinearMap := by + obtain ⟨g,hgU,hgV,hgW⟩ := p.property + obtain ⟨r,hr,hrg⟩ := exists_isotropic_isometry_extension ω h2 ha hω S S hS hS g + refine ⟨r.trans (e T),?_,?_,?_,?_⟩ + · intro x y + exact ((he T).1 (r x) (r y)).trans (hr x y) + · rw [submodule_map_trans,subspace_map_extension S S U hU r g hrg,hgU] + · rw [submodule_map_trans,subspace_map_extension S S V hV r g hrg,hgV] + · rw [submodule_map_trans,subspace_map_extension S S W hW r g hrg,hgW] + let f : IsotropicDimspace ω (finrank K S) × + TripleLinearOrbit (U.comap S.subtype) (V.comap S.subtype) (W.comap S.subtype) → + OrderedTripleOrbit ω U V W := fun p => + ⟨((p.2.val.1.map S.subtype).map (e p.1).toLinearMap, + (p.2.val.2.1.map S.subtype).map (e p.1).toLinearMap, + (p.2.val.2.2.map S.subtype).map (e p.1).toLinearMap),hgood p.1 p.2⟩ + refine ⟨f,?_⟩ + intro p + obtain ⟨g,hg,hgU,hgV,hgW⟩ := p.property + have hT : S.map g.toLinearMap ≤ ω.orthogonal (S.map g.toLinearMap) := by + rw [orthogonal_map_of_isometry ω g hg] + exact Submodule.map_mono hS + let T : IsotropicDimspace ω (finrank K S) := + ⟨S.map g.toLinearMap,hT,g.finrank_map_eq S⟩ + let r := g.trans (e T).symm + have hrS : S.map r.toLinearMap = S := by + rw [submodule_map_trans] + change T.val.map (e T).symm.toLinearMap = S + rw [←(he T).2,submodule_map_symm_cancel] + let rS : S ≃ₗ[K] S := r.ofSubmodules S S hrS + let q := tripleLinearOrbitMap (U.comap S.subtype) (V.comap S.subtype) (W.comap S.subtype) rS + have heq : r.trans (e T) = g := by + ext x + simp only [r,LinearEquiv.trans_apply,LinearEquiv.apply_symm_apply] + have hmap (A : Submodule K E) (hA : A ≤ S) : + ((((A.comap S.subtype).map rS.toLinearMap).map S.subtype).map (e T).toLinearMap) = A.map g.toLinearMap := by + rw [←subspace_map_extension S S A hA r rS (fun _ => rfl),←submodule_map_trans,heq] + refine ⟨(T,q),Subtype.ext ?_⟩ + change (((((U.comap S.subtype).map rS.toLinearMap).map S.subtype).map (e T).toLinearMap), + ((((V.comap S.subtype).map rS.toLinearMap).map S.subtype).map (e T).toLinearMap), + ((((W.comap S.subtype).map rS.toLinearMap).map S.subtype).map (e T).toLinearMap)) = p.val + rw [hmap U hU,hmap V hV,hmap W hW,hgU,hgV,hgW] + + theorem triple_subspace_orbit_card_identity (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (S U V W : Submodule K E) (hS : S ≤ ω.orthogonal S) + (hU : U ≤ S) (hV : V ≤ S) (hW : W ≤ S) (hsum : U ⊔ V ⊔ W = S) : + Nat.card (OrderedTripleOrbit ω U V W) = Nat.card (IsotropicDimspace ω (finrank K S)) * + Nat.card (TripleLinearOrbit (U.comap S.subtype) (V.comap S.subtype) (W.comap S.subtype)) := by + apply le_antisymm + · obtain ⟨f,hf⟩ := triple_subspace_orbit_surjection ω h2 ha hω S U V W hS hU hV hW hsum + simpa only [Nat.card_prod] using Nat.card_le_card_of_surjective f hf + · obtain ⟨f,hf⟩ := triple_subspace_orbit_injection ω h2 ha hω S U V W hS hU hV hW hsum + simpa only [Nat.card_prod] using Nat.card_le_card_of_injective f hf +end ConfigurationUpper +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open Module +section DecompositionTransitivity +variable {K E F : Type*} [Field K] [AddCommGroup E] [Module K E] [AddCommGroup F] [Module K F] + + theorem subspace_map_eq_of_restriction_equiv (U : Submodule K E) (V : Submodule K F) + (e : E ≃ₗ[K] F) (g : U ≃ₗ[K] V) (h : ∀ x : U, e x.val = (g x).val) : + U.map e.toLinearMap = V := by + ext y + constructor + · rintro ⟨x,hx,rfl⟩ + change e (⟨x,hx⟩ : U).val ∈ V + rw [h ⟨x,hx⟩] + exact (g ⟨x,hx⟩).property + · intro hy + obtain ⟨x,hx⟩ := g.surjective ⟨y,hy⟩ + exact ⟨x.val,x.property,(h x).trans (congrArg Subtype.val hx)⟩ + +variable [FiniteDimensional K E] [FiniteDimensional K F] + theorem triple_decomposition_equiv (U V W : Submodule K E) (U' V' W' : Submodule K F) + (hU : IsCompl U (V ⊔ W)) (hVW : Disjoint V W) + (hU' : IsCompl U' (V' ⊔ W')) (hVW' : Disjoint V' W') + (hu : finrank K U = finrank K U') (hv : finrank K V = finrank K V') (hw : finrank K W = finrank K W') : + ∃ e : E ≃ₗ[K] F, U.map e.toLinearMap = U' ∧ V.map e.toLinearMap = V' ∧ W.map e.toLinearMap = W' := by + let gu := LinearEquiv.ofFinrankEq U U' hu + let gv := LinearEquiv.ofFinrankEq V V' hv + let gw := LinearEquiv.ofFinrankEq W W' hw + let a := tripleSumEquiv U V W hU hVW + let b := tripleSumEquiv U' V' W' hU' hVW' + let e := a.symm.trans ((gu.prodCongr (gv.prodCongr gw)).trans b) + have heU (x : U) : e x.val = (gu x).val := by + have hax : a (x,(0,0)) = x.val := by simp [a] + rw [←hax] + simp [e,b] + have heV (x : V) : e x.val = (gv x).val := by + have hax : a (0,(x,0)) = x.val := by simp [a] + rw [←hax] + simp [e,b] + have heW (x : W) : e x.val = (gw x).val := by + have hax : a (0,(0,x)) = x.val := by simp [a] + rw [←hax] + simp [e,b] + exact ⟨e,subspace_map_eq_of_restriction_equiv U U' e gu heU, + subspace_map_eq_of_restriction_equiv V V' e gv heV,subspace_map_eq_of_restriction_equiv W W' e gw heW⟩ +end DecompositionTransitivity + +section ConfigTransitivity +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] [Finite E] +variable (ω : LinearMap.BilinForm K E) + + omit [Finite E] in + theorem triple_comap_isCompl (S U V W : Submodule K E) + (hU : U ≤ S) (hV : V ≤ S) (hW : W ≤ S) + (hsum : U ⊔ V ⊔ W = S) (hdis : Disjoint U (V ⊔ W)) : + IsCompl (U.comap S.subtype) (V.comap S.subtype ⊔ W.comap S.subtype) := by + constructor + · apply disjoint_iff.mpr + rw [←subspace_comap_sup_of_le S V W hV hW,←Submodule.comap_inf,disjoint_iff.mp hdis] + simp + · apply codisjoint_iff.mpr + rw [←sup_assoc,←subspace_comap_sup_of_le S U V hU hV, + ←subspace_comap_sup_of_le S (U ⊔ V) W (sup_le hU hV) hW,hsum] + simp + + theorem triple_isotropic_config_transitivity (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (U V W U' V' W' : Submodule K E) + (hS : U ⊔ V ⊔ W ≤ ω.orthogonal (U ⊔ V ⊔ W)) + (hS' : U' ⊔ V' ⊔ W' ≤ ω.orthogonal (U' ⊔ V' ⊔ W')) + (hdis : Disjoint U (V ⊔ W)) (hVW : Disjoint V W) + (hdis' : Disjoint U' (V' ⊔ W')) (hVW' : Disjoint V' W') + (hu : finrank K U = finrank K U') (hv : finrank K V = finrank K V') (hw : finrank K W = finrank K W') : + TripleIsometry ω ω U V W U' V' W' := by + let S := U ⊔ V ⊔ W + let T := U' ⊔ V' ⊔ W' + have hU : U ≤ S := le_sup_of_le_left le_sup_left + have hV : V ≤ S := le_sup_of_le_left le_sup_right + have hW : W ≤ S := le_sup_right + have hU' : U' ≤ T := le_sup_of_le_left le_sup_left + have hV' : V' ≤ T := le_sup_of_le_left le_sup_right + have hW' : W' ≤ T := le_sup_right + have hd : Disjoint (V.comap S.subtype) (W.comap S.subtype) := by + apply disjoint_iff.mpr + rw [←Submodule.comap_inf,hVW.eq_bot] + simp + have hd' : Disjoint (V'.comap T.subtype) (W'.comap T.subtype) := by + apply disjoint_iff.mpr + rw [←Submodule.comap_inf,hVW'.eq_bot] + simp + obtain ⟨g,hgU,hgV,hgW⟩ := triple_decomposition_equiv + (U.comap S.subtype) (V.comap S.subtype) (W.comap S.subtype) + (U'.comap T.subtype) (V'.comap T.subtype) (W'.comap T.subtype) + (triple_comap_isCompl S U V W hU hV hW rfl hdis) hd + (triple_comap_isCompl T U' V' W' hU' hV' hW' rfl hdis') hd' + (by rw [(Submodule.comapSubtypeEquivOfLe hU).finrank_eq,(Submodule.comapSubtypeEquivOfLe hU').finrank_eq]; exact hu) + (by rw [(Submodule.comapSubtypeEquivOfLe hV).finrank_eq,(Submodule.comapSubtypeEquivOfLe hV').finrank_eq]; exact hv) + (by rw [(Submodule.comapSubtypeEquivOfLe hW).finrank_eq,(Submodule.comapSubtypeEquivOfLe hW').finrank_eq]; exact hw) + obtain ⟨e,he,heg⟩ := exists_isotropic_isometry_extension ω h2 ha hω S T hS hS' g + refine ⟨e,he,?_,?_,?_⟩ + · rw [subspace_map_extension S T U hU e g heg,hgU,subtype_map_comap_of_le T U' hU'] + · rw [subspace_map_extension S T V hV e g heg,hgV,subtype_map_comap_of_le T V' hV'] + · rw [subspace_map_extension S T W hW e g heg,hgW,subtype_map_comap_of_le T W' hW'] +end ConfigTransitivity +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open Module +section ConfigurationBound +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] [Fintype K] [Finite E] +variable (ω : LinearMap.BilinForm K E) + theorem triple_isotropic_orbit_card_upper (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D = finrank K E) + (S U V W : Submodule K E) (hS : S ≤ ω.orthogonal S) + (hU : U ≤ S) (hV : V ≤ S) (hW : W ≤ S) (hsum : U ⊔ V ⊔ W = S) + (hdis : Disjoint U (V ⊔ W)) (hVW : Disjoint V W) : + (Nat.card (OrderedTripleOrbit ω U V W) : ℝ) ≤ + (lagrangianConstant D * 4^D) * (Fintype.card K : ℝ)^(isotropicExponent D (finrank K S) + + 2*(finrank K U*finrank K V+finrank K U*finrank K W+finrank K V*finrank K W)) := by + have hconst := lagrangianConstant_pos D + let U' := U.comap S.subtype + let V' := V.comap S.subtype + let W' := W.comap S.subtype + have hc : IsCompl U' (V' ⊔ W') := triple_comap_isCompl S U V W hU hV hW hsum hdis + have hvw : Disjoint V' W' := by + apply disjoint_iff.mpr + change V.comap S.subtype ⊓ W.comap S.subtype = ⊥ + rw [←Submodule.comap_inf,disjoint_iff.mp hVW] + simp + have hu' : finrank K U' = finrank K U := (Submodule.comapSubtypeEquivOfLe hU).finrank_eq + have hv' : finrank K V' = finrank K V := (Submodule.comapSubtypeEquivOfLe hV).finrank_eq + have hw' : finrank K W' = finrank K W := (Submodule.comapSubtypeEquivOfLe hW).finrank_eq + have hb := (tripleLinearOrbit_card_bounds U' V' W' hc hvw).2 + rw [hu',hv',hw'] at hb + have hs := isotropic_finrank_le_half ω hω D hD S hS + have hi := (isotropic_card_bounds ω h2 ha hω D hD (finrank K S) hs).2 + have hk : (2:ℝ)^(finrank K S) * 2^(finrank K S) ≤ 4^D := by + calc + _ = (4:ℝ)^(finrank K S) := by rw [←mul_pow]; norm_num + _ ≤ _ := pow_le_pow_right₀ (by norm_num) hs + rw [triple_subspace_orbit_card_identity ω h2 ha hω S U V W hS hU hV hW hsum,Nat.cast_mul] + calc + _ ≤ ((lagrangianConstant D*2^(finrank K S))*(Fintype.card K : ℝ)^isotropicExponent D (finrank K S)) * + (2^(finrank K S)*(Fintype.card K : ℝ)^(2*(finrank K U*finrank K V+finrank K U*finrank K W+finrank K V*finrank K W))) := + mul_le_mul hi hb (Nat.cast_nonneg _) (by positivity) + _ = (lagrangianConstant D*(2^(finrank K S)*2^(finrank K S))) * (Fintype.card K : ℝ)^(isotropicExponent D (finrank K S) + + 2*(finrank K U*finrank K V+finrank K U*finrank K W+finrank K V*finrank K W)) := by rw [pow_add]; ring + _ ≤ _ := by gcongr +end ConfigurationBound + +section CommonZeroProfiles +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] [FiniteDimensional K E] +variable (ω : LinearMap.BilinForm K E) +abbrev CommonZeroDimProfile (L M N : SymplecticLagrangian ω) := + {p : SymplecticLagrangian ω × SymplecticLagrangian ω × SymplecticLagrangian ω // + (p.1.val ⊓ p.2.1.val) ⊓ p.2.2.val = ⊥ ∧ + finrank K ↥(p.1.val ⊓ p.2.1.val) = finrank K ↥(L.val ⊓ M.val) ∧ + finrank K ↥(p.1.val ⊓ p.2.2.val) = finrank K ↥(L.val ⊓ N.val) ∧ + finrank K ↥(p.2.1.val ⊓ p.2.2.val) = finrank K ↥(M.val ⊓ N.val)} +variable [Finite E] + omit [FiniteDimensional K E] in + theorem commonZeroProfile_injection (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (L M N : SymplecticLagrangian ω) (h0 : (L.val ⊓ M.val) ⊓ N.val = ⊥) : + ∃ f : CommonZeroDimProfile ω L M N → + OrderedTripleOrbit ω (L.val ⊓ M.val) (L.val ⊓ N.val) (M.val ⊓ N.val) × + {P : SymplecticLagrangian ω // (L.val ⊓ M.val) ⊔ (L.val ⊓ N.val) ≤ P.val} × + {P : SymplecticLagrangian ω // (L.val ⊓ M.val) ⊔ (M.val ⊓ N.val) ≤ P.val} × + {P : SymplecticLagrangian ω // (L.val ⊓ N.val) ⊔ (M.val ⊓ N.val) ≤ P.val}, + Function.Injective f := by + classical + let O := OrderedTripleOrbit ω (L.val ⊓ M.val) (L.val ⊓ N.val) (M.val ⊓ N.val) + have ht (p : CommonZeroDimProfile ω L M N) : + TripleIsometry ω ω (L.val ⊓ M.val) (L.val ⊓ N.val) (M.val ⊓ N.val) + (p.val.1.val ⊓ p.val.2.1.val) (p.val.1.val ⊓ p.val.2.2.val) (p.val.2.1.val ⊓ p.val.2.2.val) := by + have hd := triple_pairs_disjoint L.val M.val N.val h0 + have hd' := triple_pairs_disjoint p.val.1.val p.val.2.1.val p.val.2.2.val p.property.1 + exact triple_isotropic_config_transitivity ω h2 ha hω _ _ _ _ _ _ + (triplePairSum_isotropic ω _ _ _ L.property M.property N.property) + (triplePairSum_isotropic ω _ _ _ p.val.1.property p.val.2.1.property p.val.2.2.property) + hd.1 hd.2 hd'.1 hd'.2 p.property.2.1.symm p.property.2.2.1.symm p.property.2.2.2.symm + let orb (p : CommonZeroDimProfile ω L M N) : O := + ⟨(p.val.1.val ⊓ p.val.2.1.val,p.val.1.val ⊓ p.val.2.2.val,p.val.2.1.val ⊓ p.val.2.2.val),ht p⟩ + let e (o : O) := o.property.choose + have he (o : O) := o.property.choose_spec + have hes (o : O) (x y : E) : ω ((e o).symm x) ((e o).symm y) = ω x y := by + simpa only [e,LinearEquiv.apply_symm_apply] using ((he o).1 ((e o).symm x) ((e o).symm y)).symm + let g (o : O) := lagrangianIsometryEquiv ω (e o).symm (hes o) + have hg (o : O) (P : SymplecticLagrangian ω) : (g o P).val = P.val.map (e o).symm.toLinearMap := rfl + have hpL (p : CommonZeroDimProfile ω L M N) : + (L.val ⊓ M.val) ⊔ (L.val ⊓ N.val) ≤ (g (orb p) p.val.1).val := by + rw [hg,←Submodule.orderIsoMapComap_symm_apply'] + apply (Submodule.orderIsoMapComap (e (orb p))).le_symm_apply.mpr + change ((L.val ⊓ M.val) ⊔ (L.val ⊓ N.val)).map (e (orb p)).toLinearMap ≤ p.val.1.val + rw [Submodule.map_sup,(he (orb p)).2.1,(he (orb p)).2.2.1] + exact sup_le inf_le_left inf_le_left + have hpM (p : CommonZeroDimProfile ω L M N) : + (L.val ⊓ M.val) ⊔ (M.val ⊓ N.val) ≤ (g (orb p) p.val.2.1).val := by + rw [hg,←Submodule.orderIsoMapComap_symm_apply'] + apply (Submodule.orderIsoMapComap (e (orb p))).le_symm_apply.mpr + change ((L.val ⊓ M.val) ⊔ (M.val ⊓ N.val)).map (e (orb p)).toLinearMap ≤ p.val.2.1.val + rw [Submodule.map_sup,(he (orb p)).2.1,(he (orb p)).2.2.2] + exact sup_le inf_le_right inf_le_left + have hpN (p : CommonZeroDimProfile ω L M N) : + (L.val ⊓ N.val) ⊔ (M.val ⊓ N.val) ≤ (g (orb p) p.val.2.2).val := by + rw [hg,←Submodule.orderIsoMapComap_symm_apply'] + apply (Submodule.orderIsoMapComap (e (orb p))).le_symm_apply.mpr + change ((L.val ⊓ N.val) ⊔ (M.val ⊓ N.val)).map (e (orb p)).toLinearMap ≤ p.val.2.2.val + rw [Submodule.map_sup,(he (orb p)).2.2.1,(he (orb p)).2.2.2] + exact sup_le inf_le_right inf_le_right + let f (p : CommonZeroDimProfile ω L M N) := + (orb p,(⟨g (orb p) p.val.1,hpL p⟩ : {P : SymplecticLagrangian ω // (L.val ⊓ M.val) ⊔ (L.val ⊓ N.val) ≤ P.val}), + (⟨g (orb p) p.val.2.1,hpM p⟩ : {P : SymplecticLagrangian ω // (L.val ⊓ M.val) ⊔ (M.val ⊓ N.val) ≤ P.val}), + (⟨g (orb p) p.val.2.2,hpN p⟩ : {P : SymplecticLagrangian ω // (L.val ⊓ N.val) ⊔ (M.val ⊓ N.val) ≤ P.val})) + refine ⟨f,?_⟩ + intro p q hpq + have ho : orb p = orb q := congrArg Prod.fst hpq + have hL : g (orb p) p.val.1 = g (orb p) q.val.1 := by + simpa only [f,ho] using congrArg (fun r => r.2.1.val) hpq + have hM : g (orb p) p.val.2.1 = g (orb p) q.val.2.1 := by + simpa only [f,ho] using congrArg (fun r => r.2.2.1.val) hpq + have hN : g (orb p) p.val.2.2 = g (orb p) q.val.2.2 := by + simpa only [f,ho] using congrArg (fun r => r.2.2.2.val) hpq + exact Subtype.ext (Prod.ext ((g (orb p)).injective hL) + (Prod.ext ((g (orb p)).injective hM) ((g (orb p)).injective hN))) +end CommonZeroProfiles +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open Module +noncomputable def profileMassConstant (D : ℕ) : ℝ := lagrangianConstant D^4 * 4^D + theorem profileMassConstant_pos (D : ℕ) : 0 < profileMassConstant D := by + unfold profileMassConstant + have := lagrangianConstant_pos D + positivity + theorem profileMassConstant_mono : Monotone profileMassConstant := by + intro a b hab + unfold profileMassConstant + exact mul_le_mul (pow_le_pow_left₀ (le_of_lt (lagrangianConstant_pos a)) (lagrangianConstant_mono hab) 4) + (pow_le_pow_right₀ (by norm_num) hab) (by positivity) (by positivity) +section CommonZeroMass +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] [Fintype K] [Finite E] +variable (ω : LinearMap.BilinForm K E) + theorem commonZeroProfile_card_upper (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D = finrank K E) + (L M N : SymplecticLagrangian ω) (h0 : (L.val ⊓ M.val) ⊓ N.val = ⊥) : + (Fintype.card K : ℝ)^((finrank K ↥(L.val ⊓ M.val)+1).choose 2 + + (finrank K ↥(L.val ⊓ N.val)+1).choose 2 + (finrank K ↥(M.val ⊓ N.val)+1).choose 2) * + Nat.card (CommonZeroDimProfile ω L M N) ≤ profileMassConstant D * (Fintype.card K : ℝ)^(3*(D+1).choose 2) := by + have hconst := lagrangianConstant_pos D + let u := finrank K ↥(L.val ⊓ M.val) + let v := finrank K ↥(L.val ⊓ N.val) + let w := finrank K ↥(M.val ⊓ N.val) + let S := triplePairSum L.val M.val N.val + let A := (L.val ⊓ M.val) ⊔ (L.val ⊓ N.val) + let B := (L.val ⊓ M.val) ⊔ (M.val ⊓ N.val) + let C := (L.val ⊓ N.val) ⊔ (M.val ⊓ N.val) + have hA : A ≤ L.val := sup_le inf_le_left inf_le_left + have hB : B ≤ M.val := sup_le inf_le_right inf_le_left + have hC : C ≤ N.val := sup_le inf_le_right inf_le_right + have his (P : SymplecticLagrangian ω) (T : Submodule K E) (hT : T ≤ P.val) : T ≤ ω.orthogonal T := by + intro x hx y hy + exact P.property.ge (hT hx) y (hT hy) + have hd := triple_pairs_disjoint L.val M.val N.val h0 + have hdimA : finrank K A = u+v := finrank_sup_of_disjoint _ _ (hd.1.mono_right le_sup_left) + have hdimB : finrank K B = u+w := finrank_sup_of_disjoint _ _ (hd.1.mono_right le_sup_right) + have hdimC : finrank K C = v+w := finrank_sup_of_disjoint _ _ hd.2 + have hdim : finrank K S = u+v+w := triplePairSum_finrank L.val M.val N.val h0 + have hs : S ≤ ω.orthogonal S := triplePairSum_isotropic ω _ _ _ L.property M.property N.property + have haD : u+v+w ≤ D := hdim ▸ isotropic_finrank_le_half ω hω D hD S hs + have hc := triple_isotropic_orbit_card_upper ω h2 ha hω D hD S + (L.val ⊓ M.val) (L.val ⊓ N.val) (M.val ⊓ N.val) hs + (le_sup_of_le_left le_sup_left) (le_sup_of_le_left le_sup_right) le_sup_right rfl hd.1 hd.2 + rw [hdim] at hc + have hcont (P : SymplecticLagrangian ω) (T : Submodule K E) (hT : T ≤ P.val) : + (Nat.card {Q : SymplecticLagrangian ω // T ≤ Q.val} : ℝ) ≤ + lagrangianConstant D * (Fintype.card K : ℝ)^((D-finrank K T+1).choose 2) := + ((containingLagrangian_card_bounds ω h2 ha hω D hD T (his P T hT)).2).trans + (mul_le_mul_of_nonneg_right (lagrangianConstant_mono (Nat.sub_le _ _)) (by positivity)) + have h₁ := hcont L A hA + have h₂ := hcont M B hB + have h₃ := hcont N C hC + rw [hdimA] at h₁ + rw [hdimB] at h₂ + rw [hdimC] at h₃ + obtain ⟨f,hf⟩ := commonZeroProfile_injection ω h2 ha hω L M N h0 + have hcard : (Nat.card (CommonZeroDimProfile ω L M N) : ℝ) ≤ + Nat.card (OrderedTripleOrbit ω (L.val ⊓ M.val) (L.val ⊓ N.val) (M.val ⊓ N.val)) * + ((Nat.card {Q : SymplecticLagrangian ω // A ≤ Q.val} : ℝ) * + (Nat.card {Q : SymplecticLagrangian ω // B ≤ Q.val} * Nat.card {Q : SymplecticLagrangian ω // C ≤ Q.val})) := by + have hh := Nat.card_le_card_of_injective f hf + rw [Nat.card_prod,Nat.card_prod,Nat.card_prod] at hh + exact_mod_cast hh + have hb : (Nat.card (CommonZeroDimProfile ω L M N) : ℝ) ≤ + profileMassConstant D * (Fintype.card K : ℝ)^(isotropicExponent D (u+v+w)+2*(u*v+u*w+v*w)+ + ((D-(u+v)+1).choose 2+(D-(u+w)+1).choose 2+(D-(v+w)+1).choose 2)) := by + calc + _ ≤ _ := hcard + _ ≤ ((lagrangianConstant D*4^D)*(Fintype.card K : ℝ)^(isotropicExponent D (u+v+w)+2*(u*v+u*w+v*w))) * + ((lagrangianConstant D*(Fintype.card K : ℝ)^((D-(u+v)+1).choose 2))* + ((lagrangianConstant D*(Fintype.card K : ℝ)^((D-(u+w)+1).choose 2))* + (lagrangianConstant D*(Fintype.card K : ℝ)^((D-(v+w)+1).choose 2)))) := by + gcongr + _ = _ := by unfold profileMassConstant; simp only [pow_add]; ring + have hh := mul_le_mul_of_nonneg_right hb + (show 0 ≤ (Fintype.card K : ℝ)^((u+1).choose 2+(v+1).choose 2+(w+1).choose 2) by positivity) + rw [mul_assoc,←pow_add,pair_cost_cancellation D u v w haD] at hh + simpa only [mul_comm] using hh +end CommonZeroMass +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open Module +section ProfileQuotient +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] [FiniteDimensional K E] +variable (ω : LinearMap.BilinForm K E) +abbrev TripleDimProfile (c u v w : ℕ) := + {p : SymplecticLagrangian ω × SymplecticLagrangian ω × SymplecticLagrangian ω // + finrank K ↥((p.1.val ⊓ p.2.1.val) ⊓ p.2.2.val) = c ∧ + finrank K ↥(p.1.val ⊓ p.2.1.val) = u ∧ + finrank K ↥(p.1.val ⊓ p.2.2.val) = v ∧ + finrank K ↥(p.2.1.val ⊓ p.2.2.val) = w} +noncomputable def tripleProfileCommon {c u v w : ℕ} (p : TripleDimProfile ω c u v w) : IsotropicDimspace ω c := + ⟨(p.val.1.val ⊓ p.val.2.1.val) ⊓ p.val.2.2.val, + (by intro x hx y hy; exact p.val.1.property.ge hx.1.1 y hy.1.1),p.property.1⟩ + + theorem reducePair_finrank (S : Submodule K E) (P Q : SymplecticLagrangian ω) + (hSP : S ≤ P.val) (hSQ : S ≤ Q.val) : + finrank K ↥(reduceSubspace ω S P.val ⊓ reduceSubspace ω S Q.val) = + finrank K ↥(P.val ⊓ Q.val)-finrank K S := by + rw [←reduceSubspace_inf ω S P.val Q.val hSP] + have hh := reduceSubspace_finrank_containing ω S (P.val ⊓ Q.val) (le_inf hSP hSQ) + (inf_le_left.trans (lagrangian_le_orthogonal ω S P.val P.property hSP)) + omega + + omit [FiniteDimensional K E] in + theorem reduceLagrangian_injective (S : Submodule K E) : + Function.Injective (fun P : {P : SymplecticLagrangian ω // S ≤ P.val} => reduceSubspace ω S P.val.val) := by + intro P Q h + apply Subtype.ext + apply Subtype.ext + have hh := congrArg (liftReduction ω S) h + simpa only [lift_reduce ω S P.val.val P.property (lagrangian_le_orthogonal ω S P.val.val P.val.property P.property), + lift_reduce ω S Q.val.val Q.property (lagrangian_le_orthogonal ω S Q.val.val Q.val.property Q.property)] using hh + + theorem fixedCommonProfile_injection (ha : ω.IsAlt) {c u v w : ℕ} + (S : IsotropicDimspace ω c) + (p₀ : {p : TripleDimProfile ω c u v w // tripleProfileCommon ω p = S}) : + ∃ L M N : SymplecticLagrangian (symplecticReductionForm ω S.val ha), + (L.val ⊓ M.val) ⊓ N.val = ⊥ ∧ + finrank K ↥(L.val ⊓ M.val) = u-c ∧ + finrank K ↥(L.val ⊓ N.val) = v-c ∧ + finrank K ↥(M.val ⊓ N.val) = w-c ∧ + ∃ f : {p : TripleDimProfile ω c u v w // tripleProfileCommon ω p = S} → + CommonZeroDimProfile (symplecticReductionForm ω S.val ha) L M N, Function.Injective f := by + let F := {p : TripleDimProfile ω c u v w // tripleProfileCommon ω p = S} + have heq (p : F) : (p.val.val.1.val ⊓ p.val.val.2.1.val) ⊓ p.val.val.2.2.val = S.val := + congrArg Subtype.val p.property + have hL (p : F) : S.val ≤ p.val.val.1.val := (heq p).symm ▸ inf_le_left.trans inf_le_left + have hM (p : F) : S.val ≤ p.val.val.2.1.val := (heq p).symm ▸ inf_le_left.trans inf_le_right + have hN (p : F) : S.val ≤ p.val.val.2.2.val := (heq p).symm ▸ inf_le_right + let L (p : F) := commonReductionLagrangian ω S.val ha S.property.1 p.val.val.1 (hL p) + let M (p : F) := commonReductionLagrangian ω S.val ha S.property.1 p.val.val.2.1 (hM p) + let N (p : F) := commonReductionLagrangian ω S.val ha S.property.1 p.val.val.2.2 (hN p) + have hzero (p : F) : ((L p).val ⊓ (M p).val) ⊓ (N p).val = ⊥ := by + change (reduceSubspace ω S.val p.val.val.1.val ⊓ reduceSubspace ω S.val p.val.val.2.1.val) ⊓ + reduceSubspace ω S.val p.val.val.2.2.val = ⊥ + rw [←reduceSubspace_inf ω S.val _ _ (hL p),←reduceSubspace_inf ω S.val _ _ (le_inf (hL p) (hM p)),heq p] + exact reduceSubspace_self ω S.val + have hu (p : F) : finrank K ↥((L p).val ⊓ (M p).val) = u-c := by + change finrank K ↥(reduceSubspace ω S.val p.val.val.1.val ⊓ reduceSubspace ω S.val p.val.val.2.1.val) = _ + rw [reducePair_finrank ω S.val _ _ (hL p) (hM p),p.val.property.2.1,S.property.2] + have hv (p : F) : finrank K ↥((L p).val ⊓ (N p).val) = v-c := by + change finrank K ↥(reduceSubspace ω S.val p.val.val.1.val ⊓ reduceSubspace ω S.val p.val.val.2.2.val) = _ + rw [reducePair_finrank ω S.val _ _ (hL p) (hN p),p.val.property.2.2.1,S.property.2] + have hw (p : F) : finrank K ↥((M p).val ⊓ (N p).val) = w-c := by + change finrank K ↥(reduceSubspace ω S.val p.val.val.2.1.val ⊓ reduceSubspace ω S.val p.val.val.2.2.val) = _ + rw [reducePair_finrank ω S.val _ _ (hM p) (hN p),p.val.property.2.2.2,S.property.2] + let f (p : F) : CommonZeroDimProfile (symplecticReductionForm ω S.val ha) (L p₀) (M p₀) (N p₀) := + ⟨(L p,M p,N p),hzero p,(hu p).trans (hu p₀).symm,(hv p).trans (hv p₀).symm,(hw p).trans (hw p₀).symm⟩ + refine ⟨L p₀,M p₀,N p₀,hzero p₀,hu p₀,hv p₀,hw p₀,f,?_⟩ + intro p q hpq + have heL : (L p).val = (L q).val := congrArg (fun r => r.val.1.val) hpq + have heM : (M p).val = (M q).val := congrArg (fun r => r.val.2.1.val) hpq + have heN : (N p).val = (N q).val := congrArg (fun r => r.val.2.2.val) hpq + have hpL : p.val.val.1 = q.val.val.1 := congrArg Subtype.val + (reduceLagrangian_injective ω S.val (a₁ := ⟨p.val.val.1,hL p⟩) (a₂ := ⟨q.val.val.1,hL q⟩) heL) + have hpM : p.val.val.2.1 = q.val.val.2.1 := congrArg Subtype.val + (reduceLagrangian_injective ω S.val (a₁ := ⟨p.val.val.2.1,hM p⟩) (a₂ := ⟨q.val.val.2.1,hM q⟩) heM) + have hpN : p.val.val.2.2 = q.val.val.2.2 := congrArg Subtype.val + (reduceLagrangian_injective ω S.val (a₁ := ⟨p.val.val.2.2,hN p⟩) (a₂ := ⟨q.val.val.2.2,hN q⟩) heN) + exact Subtype.ext (Subtype.ext (Prod.ext hpL (Prod.ext hpM hpN))) +end ProfileQuotient +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section AllProfileMass +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] [Fintype K] [Finite E] +variable (ω : LinearMap.BilinForm K E) + theorem fixedCommonProfile_card_upper (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D = finrank K E) {c u v w : ℕ} (S : IsotropicDimspace ω c) : + (Fintype.card K : ℝ)^((u-c+1).choose 2+(v-c+1).choose 2+(w-c+1).choose 2) * + Nat.card {p : TripleDimProfile ω c u v w // tripleProfileCommon ω p = S} ≤ + profileMassConstant (D-c) * (Fintype.card K : ℝ)^(3*(D-c+1).choose 2) := by + classical + let F := {p : TripleDimProfile ω c u v w // tripleProfileCommon ω p = S} + by_cases hF : Nonempty F + · obtain ⟨p₀⟩ := hF + obtain ⟨L,M,N,hzero,hu,hv,hw,f,hf⟩ := fixedCommonProfile_injection ω ha S p₀ + let : Finite (ReducedSpace ω S.val) := Module.finite_of_finite K + have hc : c ≤ D := S.property.2 ▸ isotropic_finrank_le_half ω hω D hD S.val S.property.1 + have hdim : 2*(D-c) = finrank K (ReducedSpace ω S.val) := by + have hh := reducedSpace_finrank ω S.val hω S.property.1 + rw [S.property.2,←hD] at hh + omega + have hp := commonZeroProfile_card_upper (symplecticReductionForm ω S.val ha) h2 + (symplecticReductionForm_alt ω S.val ha) (symplecticReductionForm_nondegenerate ω S.val ha hω) + (D-c) hdim L M N hzero + rw [hu,hv,hw] at hp + have hc : (Nat.card F : ℝ) ≤ Nat.card (CommonZeroDimProfile (symplecticReductionForm ω S.val ha) L M N) := by + exact_mod_cast Nat.card_le_card_of_injective f hf + exact (mul_le_mul_of_nonneg_left hc (by positivity)).trans hp + · have h_empty : IsEmpty F := not_nonempty_iff.mp hF + have hc : Nat.card F = 0 := Nat.card_eq_zero.mpr (Or.inl h_empty) + change _ * (Nat.card F : ℝ) ≤ _ + rw [hc,Nat.cast_zero,mul_zero] + exact mul_nonneg (le_of_lt (profileMassConstant_pos _)) (by positivity) + +noncomputable def fullProfileConstant (D : ℕ) : ℝ := lagrangianConstant D * 2^D * profileMassConstant D + theorem fullProfileConstant_pos (D : ℕ) : 0 < fullProfileConstant D := + mul_pos (mul_pos (lagrangianConstant_pos _) (by positivity)) (profileMassConstant_pos _) + + theorem tripleProfile_card_upper (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D = finrank K E) (c u v w : ℕ) (hc : c ≤ D) : + (Fintype.card K : ℝ)^((D+1)*c + ((u-c+1).choose 2+(v-c+1).choose 2+(w-c+1).choose 2)) * + Nat.card (TripleDimProfile ω c u v w) ≤ fullProfileConstant D * (Fintype.card K : ℝ)^(3*(D+1).choose 2) := by + classical + let := Fintype.ofFinite (IsotropicDimspace ω c) + let δ := (u-c+1).choose 2+(v-c+1).choose 2+(w-c+1).choose 2 + let q : ℝ := Fintype.card K + have hi := (isotropic_card_bounds ω h2 ha hω D hD c hc).2 + have hsum : (Nat.card (TripleDimProfile ω c u v w) : ℝ) = + ∑ S : IsotropicDimspace ω c, (Nat.card {p : TripleDimProfile ω c u v w // tripleProfileCommon ω p = S} : ℝ) := by + have hh := (Nat.card_congr (Equiv.sigmaFiberEquiv (tripleProfileCommon ω (c := c) (u := u) (v := v) (w := w)))).symm + rw [Nat.card_sigma] at hh + exact_mod_cast hh + have hbase : q^δ * Nat.card (TripleDimProfile ω c u v w) ≤ + (Nat.card (IsotropicDimspace ω c) : ℝ) * (profileMassConstant (D-c)*q^(3*(D-c+1).choose 2)) := by + rw [hsum,Finset.mul_sum] + calc + _ ≤ ∑ _S : IsotropicDimspace ω c, profileMassConstant (D-c)*q^(3*(D-c+1).choose 2) := + Finset.sum_le_sum (fun S _ => fixedCommonProfile_card_upper ω h2 ha hω D hD S) + _ = _ := by simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,Nat.card_eq_fintype_card] + have hk : (lagrangianConstant D*2^c)*profileMassConstant (D-c) ≤ fullProfileConstant D := by + exact mul_le_mul + (mul_le_mul_of_nonneg_left (pow_le_pow_right₀ (by norm_num) hc) (le_of_lt (lagrangianConstant_pos _))) + (profileMassConstant_mono (Nat.sub_le D c)) (le_of_lt (profileMassConstant_pos _)) + (mul_nonneg (le_of_lt (lagrangianConstant_pos _)) (by positivity)) + have hconst := fullProfileConstant_pos D + calc + _ = q^((D+1)*c) * (q^δ * Nat.card (TripleDimProfile ω c u v w)) := by rw [pow_add,mul_assoc] + _ ≤ q^((D+1)*c) * ((Nat.card (IsotropicDimspace ω c) : ℝ)*(profileMassConstant (D-c)*q^(3*(D-c+1).choose 2))) := + mul_le_mul_of_nonneg_left hbase (by positivity) + _ ≤ q^((D+1)*c) * (((lagrangianConstant D*2^c)*q^isotropicExponent D c)*(profileMassConstant (D-c)*q^(3*(D-c+1).choose 2))) := by + gcongr + exact mul_nonneg (le_of_lt (profileMassConstant_pos _)) (by positivity) + _ = ((lagrangianConstant D*2^c)*profileMassConstant (D-c))*q^(isotropicExponent D c+3*(D-c+1).choose 2+(D+1)*c) := by + simp only [pow_add]; ring + _ = ((lagrangianConstant D*2^c)*profileMassConstant (D-c))*q^(3*(D+1).choose 2) := by + rw [common_cost_cancellation D c hc] + _ ≤ _ := mul_le_mul_of_nonneg_right hk (by positivity) +end AllProfileMass +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section GeneralPairCounts +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] [Fintype K] [Finite E] +variable (ω : LinearMap.BilinForm K E) + theorem symplectic_pair_count (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (A : SymplecticLagrangian ω) (h : ℕ) (hh : h ≤ finrank K A.val) : + Nat.card {L : SymplecticLagrangian ω // finrank K ↥(L.val ⊓ A.val) = h} = + Nat.card (DimSubspace K A.val (finrank K A.val-h)) * (Fintype.card K)^((finrank K A.val-h+1).choose 2) := by + classical + obtain ⟨e,_,he⟩ := exists_lagrangian_coordinates ω A.val h2 ha hω A.property + let f := symplecticLagrangianEquiv canonicalSymplectic ω e he + let A₀ := f.symm A + have hm : A₀.val.map e.toLinearMap = A.val := congrArg Subtype.val (f.apply_symm_apply A) + have hd (L : Lagrangian (K := K) (V := A.val)) : + finrank K ↥((f L).val ⊓ A.val) = finrank K ↥(L.val ⊓ A₀.val) := by + change finrank K ↥(L.val.map e.toLinearMap ⊓ A.val) = _ + calc + _ = finrank K ↥(L.val.map e.toLinearMap ⊓ A₀.val.map e.toLinearMap) := + congrArg (fun S : Submodule K E => finrank K ↥(L.val.map e.toLinearMap ⊓ S)) hm.symm + _ = _ := by rw [←Submodule.map_inf e.toLinearMap e.injective]; exact e.finrank_map_eq _ + have hc : Nat.card {L : Lagrangian (K := K) (V := A.val) // finrank K ↥(L.val ⊓ A₀.val) = h} = + Nat.card {L : SymplecticLagrangian ω // finrank K ↥(L.val ⊓ A.val) = h} := + Nat.card_congr (f.subtypeEquiv (fun L => by rw [hd])) + rw [←hc] + exact lagrangian_pair_count h2 A₀ h hh + + theorem symplectic_pair_card_bounds (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D = finrank K E) (A : SymplecticLagrangian ω) (h : ℕ) (hh : h ≤ D) : + (Fintype.card K : ℝ)^((D+1).choose 2) ≤ (Fintype.card K : ℝ)^((h+1).choose 2) * + Nat.card {L : SymplecticLagrangian ω // finrank K ↥(L.val ⊓ A.val) = h} ∧ + (Fintype.card K : ℝ)^((h+1).choose 2) * + Nat.card {L : SymplecticLagrangian ω // finrank K ↥(L.val ⊓ A.val) = h} ≤ + 2^D*(Fintype.card K : ℝ)^((D+1).choose 2) := by + have hd : finrank K A.val = D := by + have h := self_orthogonal_twice_finrank ω A.val hω A.property + omega + have hhA : h ≤ finrank K A.val := by omega + have hcount := symplectic_pair_count ω h2 ha hω A h hhA + rw [hd] at hcount + rw [hcount,Nat.cast_mul,Nat.cast_pow] + have hl := subspace_count_lower (K := K) (V := A.val) (D-h) (by omega) + have hu := subspace_count_upper (K := K) (V := A.val) (D-h) (by omega) + rw [hd,Nat.sub_sub_self hh] at hl hu + have he : (Fintype.card K : ℝ)^((h+1).choose 2) * + ((Fintype.card K : ℝ)^((D-h)*h)*(Fintype.card K : ℝ)^((D-h+1).choose 2)) = + (Fintype.card K : ℝ)^((D+1).choose 2) := by + rw [←pow_add,←pow_add] + congr 1 + have hexp := symmetric_nullity_exponent D h hh + rw [Nat.mul_comm h (D-h)] at hexp + omega + constructor + · rw [←he] + gcongr + · calc + _ ≤ (Fintype.card K : ℝ)^((h+1).choose 2) * + ((2^(D-h)*(Fintype.card K : ℝ)^((D-h)*h))*(Fintype.card K : ℝ)^((D-h+1).choose 2)) := by gcongr + _ = 2^(D-h)*(Fintype.card K : ℝ)^((D+1).choose 2) := by rw [←he]; ring + _ ≤ _ := mul_le_mul_of_nonneg_right + (pow_le_pow_right₀ (by norm_num) (Nat.sub_le D h)) (by positivity) + +abbrev OrderedPairDim (h : ℕ) := {p : SymplecticLagrangian ω × SymplecticLagrangian ω // + finrank K ↥(p.1.val ⊓ p.2.val) = h} +noncomputable def orderedPairDimEquiv (h : ℕ) : OrderedPairDim ω h ≃ + Σ A : SymplecticLagrangian ω, {L : SymplecticLagrangian ω // finrank K ↥(L.val ⊓ A.val) = h} where + toFun p := ⟨p.val.1,⟨p.val.2,by rw [inf_comm]; exact p.property⟩⟩ + invFun p := ⟨(p.1,p.2.val),by rw [inf_comm]; exact p.2.property⟩ + left_inv _ := rfl + right_inv _ := rfl + + theorem orderedPairDim_card_lower (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D = finrank K E) (h : ℕ) (hh : h ≤ D) : + (Fintype.card K : ℝ)^(2*(D+1).choose 2) ≤ (Fintype.card K : ℝ)^((h+1).choose 2) * Nat.card (OrderedPairDim ω h) := by + classical + let := Fintype.ofFinite (SymplecticLagrangian ω) + have hc : (Nat.card (OrderedPairDim ω h) : ℝ) = + ∑ A : SymplecticLagrangian ω, (Nat.card {L : SymplecticLagrangian ω // finrank K ↥(L.val ⊓ A.val) = h} : ℝ) := by + rw [Nat.card_congr (orderedPairDimEquiv ω h),Nat.card_sigma,Nat.cast_sum] + rw [hc,Finset.mul_sum] + have he : 2*(D+1).choose 2 = (D+1).choose 2+(D+1).choose 2 := by omega + rw [he,pow_add] + calc + _ ≤ (Nat.card (SymplecticLagrangian ω) : ℝ)*(Fintype.card K : ℝ)^((D+1).choose 2) := + mul_le_mul_of_nonneg_right (symplecticLagrangian_card_bounds ω h2 ha hω D hD).1 (by positivity) + _ = ∑ _A : SymplecticLagrangian ω, (Fintype.card K : ℝ)^((D+1).choose 2) := by + simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,Nat.card_eq_fintype_card] + _ ≤ _ := Finset.sum_le_sum (fun A _ => (symplectic_pair_card_bounds ω h2 ha hω D hD A h hh).1) +end GeneralPairCounts +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open Module +section ConditionalProfile +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] [FiniteDimensional K E] +variable (ω : LinearMap.BilinForm K E) +abbrev PairCompletion (L M : SymplecticLagrangian ω) (c v w : ℕ) := + {N : SymplecticLagrangian ω // finrank K ↥((L.val ⊓ M.val) ⊓ N.val) = c ∧ + finrank K ↥(L.val ⊓ N.val) = v ∧ finrank K ↥(M.val ⊓ N.val) = w} + + omit [FiniteDimensional K E] in + theorem pairCompletion_card_congr (L M L' M' : SymplecticLagrangian ω) + (e : E ≃ₗ[K] E) (he : ∀ x y, ω (e x) (e y) = ω x y) + (hL : L.val.map e.toLinearMap = L'.val) (hM : M.val.map e.toLinearMap = M'.val) (c v w : ℕ) : + Nat.card (PairCompletion ω L M c v w) = Nat.card (PairCompletion ω L' M' c v w) := by + let f := lagrangianIsometryEquiv ω e he + have hp (A B : Submodule K E) : finrank K ↥(A.map e.toLinearMap ⊓ B.map e.toLinearMap) = finrank K ↥(A ⊓ B) := by + rw [←Submodule.map_inf e.toLinearMap e.injective] + exact e.finrank_map_eq _ + have hc (P : SymplecticLagrangian ω) : finrank K ↥((L'.val ⊓ M'.val) ⊓ (f P).val) = + finrank K ↥((L.val ⊓ M.val) ⊓ P.val) := by + change finrank K ↥((L'.val ⊓ M'.val) ⊓ P.val.map e.toLinearMap) = _ + rw [←hL,←hM,←Submodule.map_inf e.toLinearMap e.injective,hp] + have hv (P : SymplecticLagrangian ω) : finrank K ↥(L'.val ⊓ (f P).val) = finrank K ↥(L.val ⊓ P.val) := by + change finrank K ↥(L'.val ⊓ P.val.map e.toLinearMap) = _ + rw [←hL,hp] + have hw (P : SymplecticLagrangian ω) : finrank K ↥(M'.val ⊓ (f P).val) = finrank K ↥(M.val ⊓ P.val) := by + change finrank K ↥(M'.val ⊓ P.val.map e.toLinearMap) = _ + rw [←hM,hp] + exact Nat.card_congr (f.subtypeEquiv (fun P => by rw [hc,hv,hw])) + +noncomputable def profilePairCompletionEquiv (c u v w : ℕ) : TripleDimProfile ω c u v w ≃ + Σ p : OrderedPairDim ω u, PairCompletion ω p.val.1 p.val.2 c v w where + toFun p := ⟨⟨(p.val.1,p.val.2.1),p.property.2.1⟩,⟨p.val.2.2,p.property.1,p.property.2.2⟩⟩ + invFun p := ⟨(p.1.val.1,p.1.val.2,p.2.val),p.2.property.1,p.1.property,p.2.property.2⟩ + left_inv _ := rfl + right_inv _ := rfl + +variable [Finite E] + theorem tripleProfile_completion_card (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (L M : SymplecticLagrangian ω) (c v w : ℕ) : + Nat.card (TripleDimProfile ω c (finrank K ↥(L.val ⊓ M.val)) v w) = + Nat.card (OrderedPairDim ω (finrank K ↥(L.val ⊓ M.val))) * Nat.card (PairCompletion ω L M c v w) := by + classical + let := Fintype.ofFinite (OrderedPairDim ω (finrank K ↥(L.val ⊓ M.val))) + rw [Nat.card_congr (profilePairCompletionEquiv ω c (finrank K ↥(L.val ⊓ M.val)) v w),Nat.card_sigma] + have hc (p : OrderedPairDim ω (finrank K ↥(L.val ⊓ M.val))) : + Nat.card (PairCompletion ω p.val.1 p.val.2 c v w) = Nat.card (PairCompletion ω L M c v w) := by + obtain ⟨e,he,hL,hM⟩ := ordered_pair_transitivity ω h2 ha hω + p.val.1.val p.val.2.val L.val M.val p.val.1.property p.val.2.property L.property M.property p.property + exact pairCompletion_card_congr ω p.val.1 p.val.2 L M e he hL hM c v w + simp only [hc,Finset.sum_const,Finset.card_univ,nsmul_eq_mul,Nat.card_eq_fintype_card] + simp only [Nat.cast_id] + +variable [Fintype K] + theorem conditionalProfile_card_upper (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D = finrank K E) (L M : SymplecticLagrangian ω) (c v w : ℕ) (hc : c ≤ D) : + (Fintype.card K : ℝ)^((D+1)*c + ((finrank K ↥(L.val ⊓ M.val)-c+1).choose 2+ + (v-c+1).choose 2+(w-c+1).choose 2)) * Nat.card (PairCompletion ω L M c v w) ≤ + fullProfileConstant D * (Fintype.card K : ℝ)^((finrank K ↥(L.val ⊓ M.val)+1).choose 2+(D+1).choose 2) := by + let u := finrank K ↥(L.val ⊓ M.val) + let δ := (D+1)*c + ((u-c+1).choose 2+(v-c+1).choose 2+(w-c+1).choose 2) + let q : ℝ := Fintype.card K + have hq : 0 < q := by dsimp [q]; exact_mod_cast Fintype.card_pos (α := K) + have hu : u ≤ D := by + have h := self_orthogonal_twice_finrank ω L.val hω L.property + have hle := Submodule.finrank_mono (show L.val ⊓ M.val ≤ L.val from inf_le_left) + dsimp [u] + omega + have hp := orderedPairDim_card_lower ω h2 ha hω D hD u hu + have ht := tripleProfile_card_upper ω h2 ha hω D hD c u v w hc + have hi : (Nat.card (TripleDimProfile ω c u v w) : ℝ) = + (Nat.card (OrderedPairDim ω u) : ℝ)*Nat.card (PairCompletion ω L M c v w) := by + exact_mod_cast tripleProfile_completion_card ω h2 ha hω L M c v w + apply (mul_le_mul_iff_right₀ (pow_pos hq (2*(D+1).choose 2))).mp + calc + _ = q^δ*(q^(2*(D+1).choose 2)*Nat.card (PairCompletion ω L M c v w)) := by ring + _ ≤ q^δ*((q^((u+1).choose 2)*Nat.card (OrderedPairDim ω u))*Nat.card (PairCompletion ω L M c v w)) := by gcongr + _ = q^((u+1).choose 2)*(q^δ*Nat.card (TripleDimProfile ω c u v w)) := by rw [hi]; ring + _ ≤ q^((u+1).choose 2)*(fullProfileConstant D*q^(3*(D+1).choose 2)) := + mul_le_mul_of_nonneg_left ht (by positivity) + _ = q^(2*(D+1).choose 2)*(fullProfileConstant D*q^((u+1).choose 2+(D+1).choose 2)) := by + have he : 3*(D+1).choose 2 = 2*(D+1).choose 2+(D+1).choose 2 := by omega + rw [he,pow_add,pow_add] + ring +end ConditionalProfile +end SidorenkoCounterexample + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/Orbits.lean b/lean/OAI/Combinatorics/Sidorenko/Orbits.lean new file mode 100644 index 0000000000000000000000000000000000000000..8e137edd5cb17ad4e188ff8ecaacb170e7ba0006 --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/Orbits.lean @@ -0,0 +1,863 @@ +import OAI.Combinatorics.Sidorenko.TripleRanks + +namespace OAI + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators + +/-- Counting a finite set by uniformly bounded fibers. -/ +theorem card_le_card_mul_of_fibers {A B : Type*} [Finite A] [Finite B] + (f : A → B) (m : ℕ) (h : ∀ b, Nat.card {a : A // f a = b} ≤ m) : + Nat.card A ≤ Nat.card B * m := by + classical + let := Fintype.ofFinite A + let := Fintype.ofFinite B + calc + Nat.card A = Nat.card (Σ b : B, {a : A // f a = b}) := + (Nat.card_congr (Equiv.sigmaFiberEquiv f)).symm + _ = ∑ b : B, Nat.card {a : A // f a = b} := by + simp only [Nat.card_eq_fintype_card,Fintype.card_sigma] + _ ≤ ∑ _b : B, m := Finset.sum_le_sum (fun b _ => h b) + _ = Nat.card B * m := by simp [Nat.card_eq_fintype_card] + +section NormSphere +variable {K E : Type*} [Field K] [Fintype K] [AddCommGroup E] [Module K E] + [FiniteDimensional K E] [Finite E] + +/-- A quadratic equation with no linear term has at most two roots. -/ +theorem square_fiber_card (a : K) : Nat.card {x : K // x^2 = a} ≤ 2 := by + classical + by_cases h : ∃ x : K, x^2 = a + · obtain ⟨x,hx⟩ := h + let f : {z : K // z^2 = a} → (↑({x,-x} : Finset K)) := fun z => + ⟨z.val,by + have hh : z.val = x ∨ z.val = -x := sq_eq_sq_iff_eq_or_eq_neg.mp (z.property.trans hx.symm) + simpa only [Finset.mem_insert,Finset.mem_singleton] using hh⟩ + have hf : Function.Injective f := by + intro z w he + apply Subtype.ext + exact congrArg (fun t : ↑({x,-x} : Finset K) => (t : K)) he + calc + _ ≤ Nat.card (↑({x,-x} : Finset K)) := Nat.card_le_card_of_injective f hf + _ = ({x,-x} : Finset K).card := by + rw [Nat.card_eq_fintype_card] + exact Fintype.card_coe _ + _ ≤ 2 := Finset.card_le_two + · have he : IsEmpty {x : K // x^2 = a} := ⟨fun x => h ⟨x.val,x.property⟩⟩ + let := he + simp + +omit [FiniteDimensional K E] in +/-- Split along any vector of nonzero norm; this bounds a norm sphere by +exactly two choices over every point of the orthogonal complement. -/ +theorem norm_sphere_count (B : LinearMap.BilinForm K E) (hs : B.IsSymm) + (x : E) (hx : B x x ≠ 0) (a : K) : + Nat.card {v : E // B v v = a} ≤ + 2 * Nat.card (B.orthogonal (K ∙ x)) := by + classical + have hx0 : x ≠ 0 := by intro hh; subst x; simp at hx + let P := B.orthogonal (K ∙ x) + let c : ((K ∙ x) × P) ≃ₗ[K] E := + (K ∙ x).prodEquivOfIsCompl P (B.isCompl_span_singleton_orthogonal hx) + let e : (K × P) ≃ₗ[K] E := + ((LinearEquiv.toSpanNonzeroSingleton K E x hx0).prodCongr (LinearEquiv.refl K P)).trans c + have he (z : K × P) : e z = z.1 • x + z.2.val := rfl + have hnorm (z : K × P) : B (e z) (e z) = z.1^2 * B x x + B z.2.val z.2.val := by + have h1 : B x z.2.val = 0 := z.2.property x (Submodule.mem_span_singleton_self x) + have h2 : B z.2.val x = 0 := hs.eq _ _ ▸ h1 + rw [he] + simp only [map_add,map_smul,LinearMap.add_apply,LinearMap.smul_apply, + smul_eq_mul,h1,h2,mul_zero,add_zero,zero_add] + ring + let f : {v : E // B v v = a} → P := fun v => (e.symm v.val).2 + have hf (p : P) : Nat.card {v : {v : E // B v v = a} // f v = p} ≤ 2 := by + let g : {v : {v : E // B v v = a} // f v = p} → + {t : K // t^2 = (a - B p.val p.val) / B x x} := fun v => + ⟨(e.symm v.val.val).1,by + have hh := hnorm (e.symm v.val.val) + have hv : (e.symm v.val.val).2 = p := v.property + rw [e.apply_symm_apply,v.val.property,hv] at hh + apply (eq_div_iff hx).mpr + linear_combination -hh⟩ + have hg : Function.Injective g := by + intro v w h + apply Subtype.ext + apply Subtype.ext + apply e.symm.injective + apply Prod.ext + · exact congrArg Subtype.val h + · exact v.property.trans w.property.symm + exact (Nat.card_le_card_of_injective g hg).trans (square_fiber_card _) + exact (card_le_card_mul_of_fibers f 2 hf).trans_eq (Nat.mul_comm _ _) + + + +theorem norm_sphere_count_pow (B : LinearMap.BilinForm K E) (hs : B.IsSymm) + (x : E) (hx : B x x ≠ 0) (a : K) : + Nat.card {v : E // B v v = a} ≤ 2 * Fintype.card K ^ (finrank K E - 1) := by + have hx0 : x ≠ 0 := by intro hh; subst x; simp at hx + have hd := Submodule.finrank_add_eq_of_isCompl (B.isCompl_span_singleton_orthogonal hx) + rw [finrank_span_singleton hx0] at hd + have hp : finrank K (B.orthogonal (K ∙ x)) = finrank K E - 1 := by omega + have hc : Nat.card (B.orthogonal (K ∙ x)) = Fintype.card K ^ (finrank K E - 1) := by + rw [Module.natCard_eq_pow_finrank (K := K), hp, Nat.card_eq_fintype_card] + exact (norm_sphere_count B hs x hx a).trans_eq (congrArg (2 * ·) hc) + +end NormSphere +section Isometries +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] + [FiniteDimensional K E] + +/-- Linear automorphisms preserving a specified bilinear form. -/ +def BilinAut (B : LinearMap.BilinForm K E) := + {e : E ≃ₗ[K] E // ∀ x y, B (e x) (e y) = B x y} + +instance (B : LinearMap.BilinForm K E) [Finite E] : Finite (BilinAut B) := by + apply Finite.of_injective (fun e : BilinAut B => (e.val : E → E)) + intro e f h + apply Subtype.ext + exact LinearEquiv.ext (congrFun h) + +noncomputable def restrictBilinAut (B : LinearMap.BilinForm K E) + (x : E) (e : BilinAut B) (hfix : e.val x = x) : + BilinAut (B.restrict (B.orthogonal (K ∙ x))) := by + let P := B.orthogonal (K ∙ x) + have hp : ∀ z ∈ P, e.val z ∈ P := by + intro z hz a ha + obtain ⟨t,rfl⟩ := Submodule.mem_span_singleton.mp ha + have hh : B x (e.val z) = 0 := by + calc + _ = B (e.val x) (e.val z) := by rw [hfix] + _ = B x z := e.property x z + _ = 0 := hz x (Submodule.mem_span_singleton_self x) + simp [hh] + let g : P →ₗ[K] P := e.val.toLinearMap.restrict hp + have hg : Function.Injective g := by + intro z w h + apply Subtype.ext + exact e.val.injective (congrArg Subtype.val h) + let f : P ≃ₗ[K] P := LinearEquiv.ofBijective g + ⟨hg,LinearMap.injective_iff_surjective.mp hg⟩ + refine ⟨f,?_⟩ + intro z w + exact e.property z.val w.val + +@[simp] theorem restrictBilinAut_apply (B : LinearMap.BilinForm K E) + (x : E) (e : BilinAut B) (hfix : e.val x = x) + (z : B.orthogonal (K ∙ x)) : + ((restrictBilinAut B x e hfix).val z).val = e.val z.val := rfl + +/-- An isometry fixing a nonzero-norm vector is determined by its action +on the orthogonal complement. -/ +theorem restrictBilinAut_injective (B : LinearMap.BilinForm K E) + (x : E) (hx : B x x ≠ 0) : + Function.Injective (fun e : {e : BilinAut B // e.val x = x} => + restrictBilinAut B x e.val e.property) := by + intro e f h + apply Subtype.ext + apply Subtype.ext + apply LinearEquiv.ext + intro z + have hz : z ∈ (K ∙ x) ⊔ B.orthogonal (K ∙ x) := by + rw [(B.isCompl_span_singleton_orthogonal hx).sup_eq_top] + trivial + obtain ⟨a,ha,p,hp,rfl⟩ := Submodule.mem_sup.mp hz + obtain ⟨t,rfl⟩ := Submodule.mem_span_singleton.mp ha + have hh := congrArg (fun g : BilinAut (B.restrict (B.orthogonal (K ∙ x))) => + (g.val (⟨p,hp⟩ : B.orthogonal (K ∙ x))).val) h + change e.val.val p = f.val.val p at hh + simp only [map_add,map_smul,e.property,f.property,hh] + +noncomputable def relativeBilinAut (B : LinearMap.BilinForm K E) + (e f : BilinAut B) : BilinAut B := + ⟨e.val.trans f.val.symm,by + intro x y + have hf := f.property (f.val.symm (e.val x)) (f.val.symm (e.val y)) + simp only [LinearEquiv.apply_symm_apply] at hf + exact hf.symm.trans (e.property x y)⟩ + +omit [FiniteDimensional K E] in +theorem relativeBilinAut_injective (B : LinearMap.BilinForm K E) (f : BilinAut B) : + Function.Injective (fun e => relativeBilinAut B e f) := by + intro e g h + apply Subtype.ext + apply LinearEquiv.ext + intro x + have hh := congrArg (fun a : BilinAut B => f.val (a.val x)) h + simpa only [relativeBilinAut,LinearEquiv.trans_apply,LinearEquiv.apply_symm_apply] using hh + +variable [Finite E] + +/-- The fibers of evaluation at x inject into the stabilizer of x by +translation by any chosen member of the fiber. -/ +theorem bilinAut_eval_fiber_bound (B : LinearMap.BilinForm K E) (x y : E) + (hx : B x x ≠ 0) : + Nat.card {e : BilinAut B // e.val x = y} ≤ + Nat.card (BilinAut (B.restrict (B.orthogonal (K ∙ x)))) := by + classical + by_cases hn : Nonempty {e : BilinAut B // e.val x = y} + · let e0 := hn.some + let f : {e : BilinAut B // e.val x = y} → {e : BilinAut B // e.val x = x} := fun e => + ⟨relativeBilinAut B e.val e0.val,by + change e0.val.val.symm (e.val.val x) = x + exact (congrArg e0.val.val.symm (e.property.trans e0.property.symm)).trans + (e0.val.val.symm_apply_apply x)⟩ + have hf : Function.Injective f := by + intro e g h + apply Subtype.ext + apply relativeBilinAut_injective B e0.val + exact congrArg Subtype.val h + exact (Nat.card_le_card_of_injective f hf).trans + (Nat.card_le_card_of_injective _ (restrictBilinAut_injective B x hx)) + · have : IsEmpty {e : BilinAut B // e.val x = y} := not_nonempty_iff.mp hn + let := this + simp + +/-- A nonzero-norm vector splits the cardinality estimate into its norm +sphere and the isometries of the smaller orthogonal complement. -/ +theorem bilinAut_step (B : LinearMap.BilinForm K E) (x : E) (hx : B x x ≠ 0) : + Nat.card (BilinAut B) ≤ Nat.card {y : E // B y y = B x x} * + Nat.card (BilinAut (B.restrict (B.orthogonal (K ∙ x)))) := by + let s : BilinAut B → {y : E // B y y = B x x} := fun e => ⟨e.val x,e.property x x⟩ + apply card_le_card_mul_of_fibers s + intro y + let f : {e : BilinAut B // s e = y} → {e : BilinAut B // e.val x = y.val} := + fun e => ⟨e.val,congrArg Subtype.val e.property⟩ + have hf : Function.Injective f := by + intro e g h + apply Subtype.ext + exact congrArg (fun t : {e : BilinAut B // e.val x = y.val} => t.val) h + exact (Nat.card_le_card_of_injective f hf).trans (bilinAut_eval_fiber_bound B x y.val hx) + +variable [Fintype K] [Invertible (2 : K)] + + + + +theorem bilinAut_card_bound (B : LinearMap.BilinForm K E) (hs : B.IsSymm) + (hB : B.Nondegenerate) : + Nat.card (BilinAut B) ≤ 2 ^ finrank K E * Fintype.card K ^ (finrank K E).choose 2 := by + suffices ∀ d, finrank K E = d → + Nat.card (BilinAut B) ≤ 2 ^ d * Fintype.card K ^ d.choose 2 by exact this _ rfl + intro d hd + induction d generalizing E with + | zero => + have : Subsingleton E := Module.finrank_zero_iff.mp hd + have : Subsingleton (BilinAut B) := by + refine ⟨fun e f => ?_⟩ + apply Subtype.ext + apply LinearEquiv.ext + intro x + exact Subsingleton.elim _ _ + simpa using Nat.card_le_card_of_injective (fun _ : BilinAut B => ()) + (fun _ _ _ => Subsingleton.elim _ _) + | succ d ih => + have hB0 : B ≠ 0 := by + intro hh + have hz : ∀ x : E, x = 0 := by + intro x + apply hB.1 + intro y + rw [hh] + rfl + have hh0 : finrank K E = 0 := (finrank_zero_iff_forall_zero).mpr hz + omega + obtain ⟨x,hx⟩ := LinearMap.BilinForm.exists_bilinForm_self_ne_zero hB0 (LinearMap.BilinForm.isSymm_iff.mp hs) + have hx0 : x ≠ 0 := by intro hh; subst x; simp at hx + let P := B.orthogonal (K ∙ x) + have hP : finrank K P = d := by + change finrank K (B.orthogonal (K ∙ x)) = d + have hh := Submodule.finrank_add_eq_of_isCompl (B.isCompl_span_singleton_orthogonal hx) + rw [finrank_span_singleton hx0,hd] at hh + omega + have hp := ih (B.restrict P) (by constructor; intro x y; exact hs.eq x.val y.val) + (B.restrict_nondegenerate_orthogonal_spanSingleton hB hs.isRefl hx) hP + have hn := norm_sphere_count_pow B hs x hx (B x x) + rw [hd,Nat.add_sub_cancel] at hn + calc + _ ≤ Nat.card {y : E // B y y = B x x} * Nat.card (BilinAut (B.restrict P)) := + bilinAut_step B x hx + _ ≤ (2 * Fintype.card K ^ d) * (2^d * Fintype.card K ^ d.choose 2) := + Nat.mul_le_mul hn hp + _ = 2 ^ (d+1) * Fintype.card K ^ (d+1).choose 2 := by + rw [Nat.choose_succ_succ,Nat.choose_one_right,pow_add,pow_succ] + ring + +end Isometries +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section FormOrbits +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] + [FiniteDimensional K E] + +/-- Evaluate a linear automorphism on a fixed basis. -/ +noncomputable def linearAutTuple : (E ≃ₗ[K] E) → + {v : Fin (finrank K E) → E // LinearIndependent K v} := fun e => + ⟨fun i => e (finBasis K E i), (finBasis K E).linearIndependent.map' e.toLinearMap + (LinearMap.ker_eq_bot.mpr e.injective)⟩ + +theorem linearAutTuple_bijective : Function.Bijective (linearAutTuple (K := K) (E := E)) := by + constructor + · intro e f h + apply LinearEquiv.toLinearMap_injective + apply (finBasis K E).ext + intro i + exact congrFun (congrArg Subtype.val h) i + · intro v + have hspan : Submodule.span K (Set.range v.val) = ⊤ := by + apply Submodule.eq_top_of_finrank_eq + rw [finrank_span_eq_card v.property,Fintype.card_fin] + let b : Basis (Fin (finrank K E)) K E := Basis.mk v.property (by rw [hspan]) + refine ⟨(finBasis K E).equiv b (Equiv.refl _),?_⟩ + apply Subtype.ext + funext i + simp [linearAutTuple,b] + +variable [Fintype K] [Finite E] + +/-- General linear group order, obtained directly by counting ordered bases. -/ +theorem linearAut_card : Nat.card (E ≃ₗ[K] E) = + ∏ i : Fin (finrank K E), (Fintype.card K ^ finrank K E - Fintype.card K ^ i.val) := by + rw [Nat.card_congr (Equiv.ofBijective _ (linearAutTuple_bijective (K := K) (E := E)))] + exact card_linearIndependent le_rfl + +/-- The congruence orbit of the literal form, not merely its rank stratum. -/ +abbrev FormOrbit (B : LinearMap.BilinForm K E) := + {C : LinearMap.BilinForm K E // ∃ e : E ≃ₗ[K] E, C = B.comp e.toLinearMap e.toLinearMap} + +instance linearAut_finite : Finite (E ≃ₗ[K] E) := + Finite.of_injective (fun e : E ≃ₗ[K] E => (e : E → E)) + (fun _ _ h => LinearEquiv.ext (congrFun h)) + +instance formOrbit_finite (B : LinearMap.BilinForm K E) : Finite (FormOrbit B) := + Finite.of_injective (fun C : FormOrbit B => fun x y => C.val x y) (by + intro C D h + apply Subtype.ext + ext x y + exact congrFun (congrFun h x) y) + +def formOrbitMap (B : LinearMap.BilinForm K E) (e : E ≃ₗ[K] E) : FormOrbit B := + ⟨B.comp e.toLinearMap e.toLinearMap,⟨e,rfl⟩⟩ + +omit [FiniteDimensional K E] [Fintype K] in +/-- Every orbit-map fiber embeds into the isometry group; this is the +inequality direction of orbit--stabilizer, without assuming a form classification. -/ +theorem formOrbit_fiber_bound (B : LinearMap.BilinForm K E) (C : FormOrbit B) : + Nat.card {e : E ≃ₗ[K] E // formOrbitMap B e = C} ≤ Nat.card (BilinAut B) := by + classical + obtain ⟨e0,he0⟩ := C.property + let f : {e : E ≃ₗ[K] E // formOrbitMap B e = C} → BilinAut B := fun e => + ⟨e0.symm.trans e.val,by + intro x y + have hh := congrArg (fun D : FormOrbit B => D.val (e0.symm x) (e0.symm y)) e.property + change B (e.val (e0.symm x)) (e.val (e0.symm y)) = C.val (e0.symm x) (e0.symm y) at hh + rw [he0] at hh + simpa only [LinearMap.BilinForm.comp_apply,LinearEquiv.coe_coe, + LinearEquiv.apply_symm_apply,LinearEquiv.trans_apply] using hh⟩ + apply Nat.card_le_card_of_injective f + intro e g h + apply Subtype.ext + apply LinearEquiv.ext + intro x + have hh := congrArg (fun a : BilinAut B => a.val (e0 x)) h + simpa only [f,LinearEquiv.trans_apply,LinearEquiv.symm_apply_apply] using hh + +omit [FiniteDimensional K E] in +theorem formOrbit_card_mul_bound (B : LinearMap.BilinForm K E) : + Nat.card (E ≃ₗ[K] E) ≤ Nat.card (FormOrbit B) * Nat.card (BilinAut B) := + card_le_card_mul_of_fibers (formOrbitMap B) _ (formOrbit_fiber_bound B) + + + +theorem linearAut_card_lower : Fintype.card K ^ (finrank K E * finrank K E) ≤ + 2 ^ finrank K E * Nat.card (E ≃ₗ[K] E) := by + rw [linearAut_card] + have hq : 2 ≤ Fintype.card K := Fintype.one_lt_card + have hfac (i : Fin (finrank K E)) : Fintype.card K ^ finrank K E ≤ + 2 * (Fintype.card K ^ finrank K E - Fintype.card K ^ i.val) := by + have hle : Fintype.card K ^ (i.val+1) ≤ Fintype.card K ^ finrank K E := + Nat.pow_le_pow_right (by omega) i.isLt + have hh : 2 * Fintype.card K ^ i.val ≤ Fintype.card K ^ finrank K E := by + calc + _ ≤ Fintype.card K * Fintype.card K ^ i.val := Nat.mul_le_mul_right _ hq + _ = Fintype.card K ^ (i.val+1) := by rw [pow_succ]; ring + _ ≤ _ := hle + omega + calc + _ = ∏ _i : Fin (finrank K E), Fintype.card K ^ finrank K E := by + simp only [Finset.prod_const,Finset.card_univ,Fintype.card_fin,←pow_mul] + _ ≤ ∏ i : Fin (finrank K E), 2 * (Fintype.card K ^ finrank K E - Fintype.card K ^ i.val) := + Finset.prod_le_prod (fun i _ => hfac i) + _ = _ := by rw [Finset.prod_mul_distrib]; simp + +variable [Invertible (2 : K)] + +/-- Every nonsingular symmetric form class occupies a fixed positive +proportion of the full symmetric-form space, uniformly in the finite field. +The deliberately coarse constant 4⁻ᵈ is enough for the manuscript's tail bound. -/ +theorem formOrbit_card_lower (B : LinearMap.BilinForm K E) (hs : B.IsSymm) + (hB : B.Nondegenerate) : + Fintype.card K ^ (finrank K E+1).choose 2 ≤ + 4 ^ finrank K E * Nat.card (FormOrbit B) := by + let d := finrank K E + let q := Fintype.card K + have h1 := (linearAut_card_lower (K := K) (E := E)).trans + (Nat.mul_le_mul_left (2^d) (formOrbit_card_mul_bound B)) + have h2 := Nat.mul_le_mul_left (2^d * Nat.card (FormOrbit B)) (bilinAut_card_bound B hs hB) + have hh : q^(d*d) ≤ (4^d * Nat.card (FormOrbit B)) * q^d.choose 2 := by + calc + _ ≤ 2^d * (Nat.card (FormOrbit B) * Nat.card (BilinAut B)) := h1 + _ = (2^d * Nat.card (FormOrbit B)) * Nat.card (BilinAut B) := by ring + _ ≤ (2^d * Nat.card (FormOrbit B)) * (2^d * q^d.choose 2) := h2 + _ = _ := by rw [show (4 : ℕ) = 2*2 from rfl,mul_pow]; ring + have hd : d*d = (d+1).choose 2 + d.choose 2 := by + have hc : ∀ n : ℕ, n*n = n + 2*n.choose 2 := by + intro n + induction n with + | zero => simp + | succ n ih => + rw [Nat.choose_succ_succ,Nat.choose_one_right] + nlinarith + rw [Nat.choose_succ_succ,Nat.choose_one_right] + linear_combination hc d + rw [hd,pow_add] at hh + exact Nat.le_of_mul_le_mul_right hh (pow_pos Fintype.card_pos _) + +end FormOrbits +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section TransverseForms +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + +/-- Graph coordinates for a transverse Lagrangian, with the full symmetric +form retained rather than only its dimension or square class. -/ +theorem fullGraph_selforthogonal (B : LinearMap.BilinForm K V) (hs : B.IsSymm) : + canonicalSymplectic.orthogonal B.graph = B.graph := by + ext x + constructor + · intro hx + apply (B.mem_graph_iff x).mpr + ext y + have hh := hx (y,B y) (by rfl) + change x.2 y - B y x.1 = 0 at hh + exact (sub_eq_zero.mp hh).trans (hs.eq y x.1) + · intro hx y hy + have hx' := (B.mem_graph_iff x).mp hx + have hy' := (B.mem_graph_iff y).mp hy + change x.2 y.1 - y.2 x.1 = 0 + rw [hx',hy',hs.eq] + exact sub_self _ + +theorem fullGraph_injective : Function.Injective + (fun B : LinearMap.BilinForm K V => B.graph) := by + intro B C h + change B.graph = C.graph at h + apply LinearMap.ext + intro x + have hx : (x,B x) ∈ C.graph := by rw [← h]; rfl + exact (C.mem_graph_iff _).mp hx + +/-- The coordinate action corresponding to a change of basis of a form. -/ +def formCoordinateEquiv (g : V ≃ₗ[K] V) : + (V × Module.Dual K V) ≃ₗ[K] (V × Module.Dual K V) := + g.symm.prodCongr g.dualMap + +theorem formCoordinateEquiv_isometry (g : V ≃ₗ[K] V) (x y : V × Module.Dual K V) : + canonicalSymplectic (formCoordinateEquiv g x) (formCoordinateEquiv g y) = + canonicalSymplectic x y := by + simp [formCoordinateEquiv,canonicalSymplectic_apply] + +theorem fullGraph_congruence (B : LinearMap.BilinForm K V) (g : V ≃ₗ[K] V) : + B.graph.map (formCoordinateEquiv g).toLinearMap = (B.comp g.toLinearMap g.toLinearMap).graph := by + apply subspace_map_eq_of_mem_iff + intro x + change g.dualMap x.2 = (B.comp g.toLinearMap g.toLinearMap) (g.symm x.1) ↔ x.2 = B x.1 + constructor + · intro h + ext y + have hh := LinearMap.congr_fun h (g.symm y) + simpa [LinearEquiv.dualMap_apply,LinearMap.BilinForm.comp_apply] using hh + · intro h + ext y + simp [LinearEquiv.dualMap_apply,LinearMap.BilinForm.comp_apply,h] + +end TransverseForms +section TransverseTripleCoordinates +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] + [FiniteDimensional K E] +variable (ω : LinearMap.BilinForm K E) + +/-- Three pairwise transverse Lagrangians admit literal symmetric-form +coordinates; transversality to both axes is exactly nonsingularity. -/ +theorem exists_transverse_triple_form (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (L M N : Submodule K E) (hL : ω.orthogonal L = L) + (hM : ω.orthogonal M = M) (hN : ω.orthogonal N = N) + (hLM : L ⊓ M = ⊥) (hLN : L ⊓ N = ⊥) (hMN : M ⊓ N = ⊥) : + ∃ (e : (L × Module.Dual K L) ≃ₗ[K] E) (B : LinearMap.BilinForm K L), + B.IsSymm ∧ B.Nondegenerate ∧ + (∀ x, e x ∈ L ↔ x.2 = 0) ∧ (∀ x, e x ∈ M ↔ x.1 = 0) ∧ + (∀ x, e x ∈ N ↔ x.2 = B x.1) ∧ + (∀ x y, ω (e x) (e y) = canonicalSymplectic x y) := by + obtain ⟨e,heL,heM,heform⟩ := exists_transverse_pair_coordinates ω ha hω L M hL hM hLM + let p : N →ₗ[K] L := (LinearMap.fst K L (Module.Dual K L)).comp + (e.symm.toLinearMap.comp N.subtype) + have hp : Function.Injective p := by + apply (LinearMap.ker_eq_bot).mp + apply (Submodule.eq_bot_iff _).mpr + intro n hn + have hm : n.val ∈ M := by + have hh : e (e.symm n.val) ∈ M := (heM _).mpr hn + simpa only [e.apply_symm_apply] using hh + have hz : n.val ∈ M ⊓ N := ⟨hm,n.property⟩ + apply Subtype.ext + change n.val = 0 + simpa only [hMN,Submodule.mem_bot] using hz + have hd : finrank K N = finrank K L := by + have h1 := self_orthogonal_twice_finrank ω N hω hN + have h2 := self_orthogonal_twice_finrank ω L hω hL + omega + let a : N ≃ₗ[K] L := LinearEquiv.ofBijective p + ⟨hp,(LinearMap.injective_iff_surjective_of_finrank_eq_finrank hd).mp hp⟩ + let B : LinearMap.BilinForm K L := (LinearMap.snd K L (Module.Dual K L)).comp + (e.symm.toLinearMap.comp (N.subtype.comp a.symm.toLinearMap)) + have hcoord (x : L) : e.symm (a.symm x).val = (x,B x) := by + apply Prod.ext + · exact a.apply_symm_apply x + · rfl + have hNgraph (x : L × Module.Dual K L) : e x ∈ N ↔ x.2 = B x.1 := by + constructor + · intro hx + let n : N := ⟨e x,hx⟩ + have haN : a n = x.1 := by + change (e.symm (e x)).1 = x.1 + rw [e.symm_apply_apply] + have hh := hcoord (a n) + rw [a.symm_apply_apply,haN] at hh + have hh' := congrArg Prod.snd hh + change (e.symm (e x)).2 = B x.1 at hh' + simpa only [e.symm_apply_apply] using hh' + · intro hx + have hh := congrArg e (hcoord x.1) + rw [e.apply_symm_apply,← hx] at hh + exact hh ▸ (a.symm x.1).property + have hs : B.IsSymm := by + constructor + intro x y + have hh := hN.ge ((a.symm y).property) (a.symm x).val ((a.symm x).property) + rw [← e.apply_symm_apply (a.symm x).val,← e.apply_symm_apply (a.symm y).val, + heform,hcoord,hcoord] at hh + change B y x - B x y = 0 at hh + exact (sub_eq_zero.mp hh).symm + have hleft (x : L) (hx : ∀ y, B x y = 0) : x = 0 := by + have hxB : B x = 0 := by ext y; exact hx y + have hxL : (a.symm x).val ∈ L := by + have hh := (heL (x,B x)).mpr hxB + have hc := congrArg e (hcoord x) + rw [e.apply_symm_apply] at hc + exact hc.symm ▸ hh + have hz : (a.symm x).val ∈ L ⊓ N := ⟨hxL,(a.symm x).property⟩ + have hn0 : a.symm x = 0 := Subtype.ext (by + change (a.symm x).val = 0 + simpa only [hLN,Submodule.mem_bot] using hz) + have hh := congrArg a hn0 + simpa only [a.apply_symm_apply,map_zero] using hh + refine ⟨e,B,hs,⟨hleft,?_⟩,heL,heM,hNgraph,heform⟩ + intro x hx + exact hleft x (fun y => (hs.eq x y).trans (hx y)) + +end TransverseTripleCoordinates +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section FixedPairOrbit +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] +variable (ω : LinearMap.BilinForm K E) (L M N : Submodule K E) + +/-- Third members reachable while fixing both members of the ordered pair. -/ +abbrev FixedPairOrbit := {N' : Submodule K E // + ∃ e : E ≃ₗ[K] E, (∀ x y, ω (e x) (e y) = ω x y) ∧ + L.map e.toLinearMap = L ∧ M.map e.toLinearMap = M ∧ N.map e.toLinearMap = N'} + +theorem fixedPairOrbit_selforthogonal (hN : ω.orthogonal N = N) + (N' : FixedPairOrbit ω L M N) : ω.orthogonal N'.val = N'.val := by + obtain ⟨e,he,_,_,hne⟩ := N'.property + rw [←hne,orthogonal_map_of_isometry ω e he,hN] + +variable [FiniteDimensional K E] + +/-- Congruence classes inject into the actual third-member fiber of the +ordered symplectic orbit. No classification of forms is used. -/ +theorem fixedPairOrbit_form_injection (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (hL : ω.orthogonal L = L) (hM : ω.orthogonal M = M) (hN : ω.orthogonal N = N) + (hLM : L ⊓ M = ⊥) (hLN : L ⊓ N = ⊥) (hMN : M ⊓ N = ⊥) : + ∃ B : LinearMap.BilinForm K L, B.IsSymm ∧ B.Nondegenerate ∧ + ∃ f : FormOrbit B → FixedPairOrbit ω L M N, Function.Injective f := by + classical + obtain ⟨e,B,hs,hB,heL,heM,heN,heform⟩ := + exists_transverse_triple_form ω ha hω L M N hL hM hN hLM hLN hMN + have hgood (C : FormOrbit B) : + ∃ f : E ≃ₗ[K] E, (∀ x y, ω (f x) (f y) = ω x y) ∧ + L.map f.toLinearMap = L ∧ M.map f.toLinearMap = M ∧ + N.map f.toLinearMap = C.val.graph.map e.toLinearMap := by + obtain ⟨g,hg⟩ := C.property + let f := e.symm.trans ((formCoordinateEquiv g).trans e) + refine ⟨f,?_,?_,?_,?_⟩ + · intro x y + change ω (e (formCoordinateEquiv g (e.symm x))) + (e (formCoordinateEquiv g (e.symm y)))=ω x y + rw [heform,formCoordinateEquiv_isometry,←heform,e.apply_symm_apply,e.apply_symm_apply] + · apply subspace_map_eq_of_mem_iff f + intro x + change e (formCoordinateEquiv g (e.symm x)) ∈ L ↔ x ∈ L + rw [heL] + change g.dualMap (e.symm x).2 = 0 ↔ x ∈ L + rw [LinearEquiv.map_eq_zero_iff] + simpa only [e.apply_symm_apply] using (heL (e.symm x)).symm + · apply subspace_map_eq_of_mem_iff f + intro x + change e (formCoordinateEquiv g (e.symm x)) ∈ M ↔ x ∈ M + rw [heM] + change g.symm (e.symm x).1 = 0 ↔ x ∈ M + rw [LinearEquiv.map_eq_zero_iff] + simpa only [e.apply_symm_apply] using (heM (e.symm x)).symm + · apply subspace_map_eq_of_mem_iff f + intro x + rw [Submodule.mem_map_equiv] + change e.symm (e (formCoordinateEquiv g (e.symm x))) ∈ C.val.graph ↔ x ∈ N + rw [e.symm_apply_apply,hg,←fullGraph_congruence,Submodule.mem_map_equiv] + rw [LinearEquiv.symm_apply_apply,LinearMap.mem_graph_iff] + simpa only [e.apply_symm_apply] using (heN (e.symm x)).symm + let f : FormOrbit B → FixedPairOrbit ω L M N := + fun C => ⟨C.val.graph.map e.toLinearMap,hgood C⟩ + refine ⟨B,hs,hB,f,?_⟩ + intro C D h + apply Subtype.ext + apply fullGraph_injective + exact Submodule.map_injective_of_injective e.injective (congrArg Subtype.val h) + +variable [Fintype K] [Finite E] [Invertible (2 : K)] + +/-- The essential residual orbit lower bound, with a concrete uniform +fixed-dimension constant, for each individual target ordered triple. -/ +theorem fixedPairOrbit_card_lower (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (hL : ω.orthogonal L = L) (hM : ω.orthogonal M = M) (hN : ω.orthogonal N = N) + (hLM : L ⊓ M = ⊥) (hLN : L ⊓ N = ⊥) (hMN : M ⊓ N = ⊥) : + Fintype.card K ^ (finrank K L+1).choose 2 ≤ + 4 ^ finrank K L * Nat.card (FixedPairOrbit ω L M N) := by + obtain ⟨B,hs,hB,f,hf⟩ := fixedPairOrbit_form_injection ω L M N ha hω hL hM hN hLM hLN hMN + exact (formOrbit_card_lower B hs hB).trans + (Nat.mul_le_mul_left _ (Nat.card_le_card_of_injective f hf)) + +end FixedPairOrbit +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section UniformCountingBounds +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [Fintype K] [Finite V] + +/-- Reindexing the exact graph-chart count by projection dimension. -/ +theorem lagrangian_card_by_dimension : + Nat.card (Lagrangian (K := K) (V := V)) = + ∑ k : Fin (finrank K V+1), Nat.card (DimSubspace K V k.val) * + Fintype.card K ^ (k.val+1).choose 2 := by + classical + let := Fintype.ofFinite (Submodule K V) + let d : Submodule K V → Fin (finrank K V+1) := + fun U => ⟨finrank K U,Nat.lt_succ_of_le (Submodule.finrank_le U)⟩ + rw [lagrangian_card_sum,← Fintype.sum_fiberwise d] + apply Finset.sum_congr rfl + intro k _ + have hc : Nat.card {U : Submodule K V // d U = k} = Nat.card (DimSubspace K V k.val) := + Nat.card_congr (Equiv.subtypeEquivRight (fun U => by + change (⟨finrank K U,_⟩ : Fin _)=k ↔ finrank K U=k.val + exact Fin.ext_iff)) + have he (U : {U : Submodule K V // d U = k}) : finrank K U.val = k.val := + congrArg Fin.val U.property + simp only [he,Finset.sum_const,Finset.card_univ,nsmul_eq_mul,←Nat.card_eq_fintype_card,hc,Nat.cast_id] + +/-- A field-independent fixed-dimension upper normalization constant. -/ +noncomputable def lagrangianConstant (n : ℕ) : ℝ := (n+1) * 2^n + +theorem lagrangianConstant_pos (n : ℕ) : 0 < lagrangianConstant n := by + unfold lagrangianConstant + positivity + +theorem lagrangian_card_upper : + (Nat.card (Lagrangian (K := K) (V := V)) : ℝ) ≤ + lagrangianConstant (finrank K V) * (Fintype.card K : ℝ)^((finrank K V+1).choose 2) := by + rw [lagrangian_card_by_dimension,Nat.cast_sum] + let n := finrank K V + let q : ℝ := Fintype.card K + have hq : 1 ≤ q := by + dsimp [q] + exact_mod_cast (Nat.succ_le_iff.mpr (Fintype.card_pos (α := K))) + have hterm (k : Fin (n+1)) : + (Nat.card (DimSubspace K V k.val) : ℝ) * q^(k.val+1).choose 2 ≤ + 2^n*q^(n+1).choose 2 := by + have hk : k.val ≤ n := Nat.le_of_lt_succ k.isLt + have he : k.val*(n-k.val)+(k.val+1).choose 2 ≤ (n+1).choose 2 := by + have hh := symmetric_nullity_exponent n (n-k.val) (Nat.sub_le n k.val) + rw [Nat.sub_sub_self hk] at hh + nlinarith + calc + _ ≤ (2^k.val*q^(k.val*(n-k.val)))*q^(k.val+1).choose 2 := + mul_le_mul_of_nonneg_right (subspace_count_upper k.val hk) (by positivity) + _ = 2^k.val*q^(k.val*(n-k.val)+(k.val+1).choose 2) := by rw [pow_add]; ring + _ ≤ 2^n*q^(n+1).choose 2 := mul_le_mul + (pow_le_pow_right₀ (by norm_num) hk) (pow_le_pow_right₀ hq he) (by positivity) (by positivity) + calc + _ ≤ ∑ _k : Fin (n+1), 2^n*q^(n+1).choose 2 := by + apply Finset.sum_le_sum + intro k _ + simpa only [Nat.cast_mul,Nat.cast_pow] using hterm k + _ = _ := by simp [lagrangianConstant,n,q]; ring + +theorem lagrangian_card_lower : + (Fintype.card K : ℝ)^((finrank K V+1).choose 2) ≤ + Nat.card (Lagrangian (K := K) (V := V)) := by + let : Finite (Module.Dual K V) := Module.finite_of_finite K + have h := Nat.card_le_card_of_injective (graphLagrangian (K := K) (V := V) (⊤ : Submodule K V)) + (graphLagrangian_form_injective (⊤ : Submodule K V)) + rw [symForm_card] at h + simpa only [finrank_top,Nat.cast_pow] using (show + ((Fintype.card K^((finrank K ↥(⊤ : Submodule K V)+1).choose 2) : ℕ) : ℝ) ≤ + (Nat.card (Lagrangian (K := K) (V := V)) : ℝ) from by exact_mod_cast h) + +end UniformCountingBounds +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section FullTripleOrbit +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] +variable (ω : LinearMap.BilinForm K E) +abbrev SymplecticLagrangian := {L : Submodule K E // ω.orthogonal L = L} +abbrev OrderedTransversePair := {p : SymplecticLagrangian ω × SymplecticLagrangian ω // + p.1.val ⊓ p.2.val = ⊥} +abbrev OrderedTripleOrbit (L M N : Submodule K E) := + {p : Submodule K E × Submodule K E × Submodule K E // + ∃ e : E ≃ₗ[K] E, (∀ x y, ω (e x) (e y) = ω x y) ∧ + L.map e.toLinearMap = p.1 ∧ M.map e.toLinearMap = p.2.1 ∧ + N.map e.toLinearMap = p.2.2} + +variable [FiniteDimensional K E] +theorem orderedTripleOrbit_pair_injection (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (L M N : Submodule K E) (hL : ω.orthogonal L = L) (hM : ω.orthogonal M = M) + (hLM : L ⊓ M = ⊥) : + ∃ f : OrderedTransversePair ω × FixedPairOrbit ω L M N → OrderedTripleOrbit ω L M N, + Function.Injective f := by + classical + have ht (p : OrderedTransversePair ω) := transverse_pair_transitivity ω ha hω + L M p.val.1.val p.val.2.val hL hM p.val.1.property p.val.2.property hLM p.property + let e (p : OrderedTransversePair ω) := (ht p).choose + have he (p) := (ht p).choose_spec + have hgood (p : OrderedTransversePair ω) (N' : FixedPairOrbit ω L M N) : + ∃ f : E ≃ₗ[K] E, (∀ x y, ω (f x) (f y) = ω x y) ∧ + L.map f.toLinearMap = p.val.1.val ∧ M.map f.toLinearMap = p.val.2.val ∧ + N.map f.toLinearMap = N'.val.map (e p).toLinearMap := by + obtain ⟨g,hg,hgL,hgM,hgN⟩ := N'.property + refine ⟨g.trans (e p),?_,?_,?_,?_⟩ + · intro x y + exact ((he p).1 (g x) (g y)).trans (hg x y) + · change L.map ((e p).toLinearMap.comp g.toLinearMap) = _ + rw [Submodule.map_comp,hgL] + exact (he p).2.1 + · change M.map ((e p).toLinearMap.comp g.toLinearMap) = _ + rw [Submodule.map_comp,hgM] + exact (he p).2.2 + · change N.map ((e p).toLinearMap.comp g.toLinearMap) = _ + rw [Submodule.map_comp,hgN] + let f : OrderedTransversePair ω × FixedPairOrbit ω L M N → OrderedTripleOrbit ω L M N := + fun x => ⟨(x.1.val.1.val,x.1.val.2.val,x.2.val.map (e x.1).toLinearMap),hgood x.1 x.2⟩ + refine ⟨f,?_⟩ + rintro ⟨p,A⟩ ⟨q,B⟩ h + have hv := congrArg Subtype.val h + have hp : p = q := by + apply Subtype.ext + apply Prod.ext + · exact Subtype.ext (congrArg Prod.fst hv) + · exact Subtype.ext (congrArg (fun x => x.2.1) hv) + subst q + have hab : A = B := by + apply Subtype.ext + exact Submodule.map_injective_of_injective (e p).injective + (congrArg (fun x => x.2.2) hv) + subst B + rfl +end FullTripleOrbit + +section CanonicalTripleMass +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [Fintype K] [Finite V] +local notation "ω" => (canonicalSymplectic (K := K) (V := V)) + + theorem transverse_to_card (h2 : (2 : K) ≠ 0) (A : Lagrangian (K := K) (V := V)) : + Nat.card {B : Lagrangian (K := K) (V := V) // A.val ⊓ B.val = ⊥} = + Fintype.card K^((finrank K V+1).choose 2) := by + have h := lagrangian_pair_count h2 A 0 (Nat.zero_le _) + have hc : Nat.card {U : Submodule K V // finrank K U = finrank K V} = 1 := by + let : Unique {U : Submodule K V // finrank K U = finrank K V} := + ⟨⟨⊤,finrank_top K V⟩,fun U => Subtype.ext (Submodule.eq_top_of_finrank_eq U.property)⟩ + exact Nat.card_unique + have he : {B : Lagrangian (K := K) (V := V) // A.val ⊓ B.val = ⊥} ≃ + {B : Lagrangian (K := K) (V := V) // finrank K ↥(B.val ⊓ A.val) = 0} := + Equiv.subtypeEquiv (Equiv.refl _) (by + intro B + change A.val ⊓ B.val = ⊥ ↔ finrank K ↥(B.val ⊓ A.val) = 0 + rw [Submodule.finrank_eq_zero,inf_comm]) + rw [Nat.card_congr he,h] + simp only [Nat.sub_zero,hc,one_mul] + + theorem orderedTransversePair_card (h2 : (2 : K) ≠ 0) : + Nat.card (OrderedTransversePair ω) = Nat.card (Lagrangian (K := K) (V := V)) * + Fintype.card K^((finrank K V+1).choose 2) := by + classical + let : Finite (Module.Dual K V) := Module.finite_of_finite K + let := Fintype.ofFinite (Lagrangian (K := K) (V := V)) + let e : OrderedTransversePair ω ≃ + Σ A : Lagrangian (K := K) (V := V), {B : Lagrangian (K := K) (V := V) // A.val ⊓ B.val = ⊥} := + { toFun := fun p => ⟨p.val.1,⟨p.val.2,p.property⟩⟩ + invFun := fun p => ⟨(p.1,p.2.val),p.2.property⟩ + left_inv := fun p => rfl + right_inv := fun p => rfl } + rw [Nat.card_congr e,Nat.card_sigma] + simp only [transverse_to_card h2,Finset.sum_const,Finset.card_univ,smul_eq_mul, + Nat.card_eq_fintype_card] + + theorem orderedTransverseTriple_card_lower [Invertible (2 : K)] + (L M N : Lagrangian (K := K) (V := V)) + (hLM : L.val ⊓ M.val = ⊥) (hLN : L.val ⊓ N.val = ⊥) (hMN : M.val ⊓ N.val = ⊥) : + Nat.card (Lagrangian (K := K) (V := V)) * + (Fintype.card K^((finrank K V+1).choose 2)) ^ 2 ≤ + 4^finrank K V * Nat.card (OrderedTripleOrbit ω L.val M.val N.val) := by + let : Finite (Module.Dual K V) := Module.finite_of_finite K + have hcard := fixedPairOrbit_card_lower ω L.val M.val N.val + canonicalSymplectic_alt canonicalSymplectic_nondegenerate + L.property M.property N.property hLM hLN hMN + rw [lagrangian_finrank L] at hcard + obtain ⟨f,hf⟩ := orderedTripleOrbit_pair_injection ω canonicalSymplectic_alt + canonicalSymplectic_nondegenerate L.val M.val N.val L.property M.property hLM + have hi := Nat.card_le_card_of_injective f hf + rw [Nat.card_prod,orderedTransversePair_card (isUnit_of_invertible (2 : K)).ne_zero] at hi + calc + _ = (Nat.card (Lagrangian (K := K) (V := V)) * Fintype.card K^((finrank K V+1).choose 2)) * + Fintype.card K^((finrank K V+1).choose 2) := by rw [pow_two]; ac_rfl + _ ≤ (Nat.card (Lagrangian (K := K) (V := V)) * Fintype.card K^((finrank K V+1).choose 2)) * + (4^finrank K V * Nat.card (FixedPairOrbit ω L.val M.val N.val)) := Nat.mul_le_mul_left _ hcard + _ = 4^finrank K V * (Nat.card (Lagrangian (K := K) (V := V)) * + Fintype.card K^((finrank K V+1).choose 2) * Nat.card (FixedPairOrbit ω L.val M.val N.val)) := by ring + _ ≤ _ := Nat.mul_le_mul_left _ hi +end CanonicalTripleMass +end SidorenkoCounterexample + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/PairBounds.lean b/lean/OAI/Combinatorics/Sidorenko/PairBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..1965b53d5e0de7f0a179669f0aaaa05a88084397 --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/PairBounds.lean @@ -0,0 +1,501 @@ +import OAI.Combinatorics.Sidorenko.Coercivity + +namespace OAI + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators + + theorem real_card_sigma_le {B : Type*} [Finite B] {C : B → Type*} [∀ b, Finite (C b)] + (m : ℝ) (h : ∀ b, (Nat.card (C b) : ℝ) ≤ m) : + (Nat.card (Σ b, C b) : ℝ) ≤ Nat.card B*m := by + classical + let := Fintype.ofFinite B + let _ (b : B) := Fintype.ofFinite (C b) + simp only [Nat.card_eq_fintype_card,Fintype.card_sigma,Nat.cast_sum] + calc + (∑ b, (Fintype.card (C b):ℝ)) ≤ ∑ _b : B, m := Finset.sum_le_sum (fun b _ => by simpa only [Nat.card_eq_fintype_card] using h b) + _ = (Fintype.card B:ℝ)*m := by simp + +section PairDifference +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] +variable (A B : Submodule K V) +noncomputable def pairFormDifference : (SymForm K A × SymForm K B) →ₗ[K] SymForm K ↥(A ⊓ B) := + (symFormPull (Submodule.inclusion inf_le_left : ↥(A ⊓ B) →ₗ[K] A)).comp (LinearMap.fst K _ _) - + (symFormPull (Submodule.inclusion inf_le_right : ↥(A ⊓ B) →ₗ[K] B)).comp (LinearMap.snd K _ _) + theorem pairFormDifference_surjective : Function.Surjective (pairFormDifference A B) := by + intro F + obtain ⟨G,hG⟩ := symFormPull_surjective + (Submodule.inclusion inf_le_left : ↥(A ⊓ B) →ₗ[K] A) (Submodule.inclusion_injective _) F + refine ⟨(G,0),?_⟩ + change symFormPull _ G-symFormPull _ 0=F + rw [map_zero,sub_zero,hG] + theorem pairFormDifference_graph (F : SymForm K A) (G : SymForm K B) : + (pairFormDifference A B (F,G)).val = graphDifference A B F.val G.val := rfl + + theorem pairFormDifference_nullity_bound [Fintype K] [Finite V] (t : ℕ) + (ht : t ≤ finrank K ↥(A ⊓ B)) : + (Nat.card {FG : SymForm K A × SymForm K B // + t ≤ finrank K (graphDifference A B FG.1.val FG.2.val).ker} : ℝ) / + Nat.card (SymForm K A × SymForm K B) ≤ + 2^t/(Fintype.card K : ℝ)^((t+1).choose 2) := by + change (Nat.card {FG : SymForm K A × SymForm K B // + t ≤ finrank K (pairFormDifference A B FG).val.ker} : ℝ) / _ ≤ _ + rw [surjective_linear_probability (pairFormDifference A B) (pairFormDifference_surjective A B) (fun F => t ≤ finrank K F.val.ker)] + exact symmetric_nullity_probability_bound t ht +end PairDifference + +section PairBaseCounts +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] +abbrev SubspacePairProfile (r p : ℕ) := + {R : DimSubspace K V r × DimSubspace K V r // finrank K ↥(R.1.val ⊓ R.2.val) = p} +abbrev PairBaseCode (r p : ℕ) := + Σ R : DimSubspace K V r, Σ P : DimSubspace K R.val p, + {S : DimSubspace K V r // P.val.map R.val.subtype ≤ S.val} + +noncomputable def pairBaseCode {r p : ℕ} (RS : SubspacePairProfile (K := K) (V := V) r p) : + PairBaseCode (K := K) (V := V) r p := by + let R := RS.val.1 + let S := RS.val.2 + let P := (R.val ⊓ S.val).comap R.val.subtype + have hP : finrank K P = p := by + rw [(Submodule.comapSubtypeEquivOfLe (inf_le_left : R.val ⊓ S.val ≤ R.val)).finrank_eq] + exact RS.property + refine ⟨R,⟨P,hP⟩,S,?_⟩ + intro x hx + obtain ⟨y,hy,rfl⟩ := hx + exact hy.2 + theorem pairBaseCode_injective (r p : ℕ) : + Function.Injective (pairBaseCode (K := K) (V := V) (r := r) (p := p)) := by + intro a b h + apply Subtype.ext + exact congrArg (fun c : PairBaseCode (K := K) (V := V) r p => (c.1,c.2.2.val)) h + +variable [Fintype K] [Finite V] + theorem subspacePairProfile_card_upper (r p : ℕ) (hr : r ≤ finrank K V) (hp : p ≤ r) : + (Nat.card (SubspacePairProfile (K := K) (V := V) r p) : ℝ) ≤ + (2^r*(Fintype.card K : ℝ)^(r*(finrank K V-r))) * + ((2^p*(Fintype.card K : ℝ)^(p*(r-p))) * + (2^r*(Fintype.card K : ℝ)^((r-p)*(finrank K V-r)))) := by + have hq : (0:ℝ) ≤ Fintype.card K := by positivity + have hP (R : DimSubspace K V r) (P : DimSubspace K R.val p) : + (Nat.card {S : DimSubspace K V r // P.val.map R.val.subtype ≤ S.val} : ℝ) ≤ + 2^r*(Fintype.card K : ℝ)^((r-p)*(finrank K V-r)) := by + have hd : finrank K (P.val.map R.val.subtype) = p := + (Submodule.finrank_map_subtype_eq R.val P.val).trans P.property + have hh := (containingSubspace_card_bounds (P.val.map R.val.subtype) r (by rwa [hd]) hr).2 + rwa [hd] at hh + have hR (R : DimSubspace K V r) : + (Nat.card (Σ P : DimSubspace K R.val p, + {S : DimSubspace K V r // P.val.map R.val.subtype ≤ S.val}) : ℝ) ≤ + (2^p*(Fintype.card K : ℝ)^(p*(r-p))) * + (2^r*(Fintype.card K : ℝ)^((r-p)*(finrank K V-r))) := by + refine (real_card_sigma_le _ (hP R)).trans ?_ + have hc := subspace_count_upper (K := K) (V := R.val) p (by rwa [R.property]) + rw [R.property] at hc + exact mul_le_mul_of_nonneg_right hc (by positivity) + have hc : (Nat.card (SubspacePairProfile (K := K) (V := V) r p) : ℝ) ≤ + Nat.card (PairBaseCode (K := K) (V := V) r p) := by + exact_mod_cast Nat.card_le_card_of_injective _ (pairBaseCode_injective (K := K) (V := V) r p) + refine (hc.trans (real_card_sigma_le _ hR)).trans ?_ + exact mul_le_mul_of_nonneg_right (subspace_count_upper r hr) (by positivity) + + theorem subspacePairProfile_probability_bound (r p : ℕ) (hD : finrank K V = 2*r) (hp : p ≤ r) : + (Fintype.card K : ℝ)^(p*p) * Nat.card (SubspacePairProfile (K := K) (V := V) r p) ≤ + 2^(2*r+p)*(Nat.card (DimSubspace K V r):ℝ)^2 := by + have hr : r ≤ finrank K V := by omega + have hc := subspacePairProfile_card_upper (K := K) (V := V) r p hr hp + rw [hD,show 2*r-r=r by omega] at hc + have hl := subspace_count_lower (K := K) (V := V) r hr + rw [hD,show 2*r-r=r by omega] at hl + have hexp : p*p+r*r+(p*(r-p)+(r-p)*r)=2*(r*r) := by + have hs := Nat.sub_add_cancel hp + nlinarith + have htwo : r+(p+r)=2*r+p := by omega + let q : ℝ := Fintype.card K + calc + q^(p*p)*Nat.card (SubspacePairProfile (K := K) (V := V) r p) ≤ + q^(p*p)*((2^r*q^(r*r))*((2^p*q^(p*(r-p)))*(2^r*q^((r-p)*r)))) := + mul_le_mul_of_nonneg_left hc (by positivity) + _ = 2^(2*r+p)*(q^(r*r))^2 := by + rw [show q^(p*p)*((2^r*q^(r*r))*((2^p*q^(p*(r-p)))*(2^r*q^((r-p)*r)))) = + (2^r*(2^p*2^r))*(q^(p*p)*q^(r*r)*(q^(p*(r-p))*q^((r-p)*r))) by ring] + rw [←pow_add,←pow_add,htwo,←pow_add,←pow_add,←pow_add,hexp,pow_mul] + rw [pow_mul]; ring + _ ≤ _ := mul_le_mul_of_nonneg_left (pow_le_pow_left₀ (by positivity) hl 2) (by positivity) +end PairBaseCounts +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +abbrev PairParameters (r h : ℕ) := {p : Fin (r+1) // p.val ≤ h ∧ h-p.val ≤ p.val} +noncomputable instance pairParametersFintype (r h : ℕ) : Fintype (PairParameters r h) := Fintype.ofFinite _ +section PairLiftCounts +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] +abbrev DualPairBase (r : ℕ) := DimSubspace K (Module.Dual K V) r × DimSubspace K (Module.Dual K V) r +abbrev DualPairForms {r : ℕ} (R : DualPairBase (K := K) (V := V) r) := + SymForm K R.1.val.dualCoannihilator × SymForm K R.2.val.dualCoannihilator +abbrev CanonicalPairProfile (r h : ℕ) := + {RF : Σ R : DualPairBase (K := K) (V := V) r, DualPairForms R // + finrank K ↥((dualGraph RF.1.1.val RF.2.1).val ⊓ (dualGraph RF.1.2.val RF.2.2).val) = h} +abbrev DualPairLiftEvent {r p : ℕ} (R : SubspacePairProfile (K := K) (V := Module.Dual K V) r p) (t : ℕ) := + {F : DualPairForms R.val // t ≤ finrank K (graphDifference _ _ F.1.val F.2.val).ker} +abbrev CenterPairProfile (r h : ℕ) := + {L : CenterStratum (K := K) (V := V) r × CenterStratum (K := K) (V := V) r // + finrank K ↥(L.1.val.val ⊓ L.2.val.val) = h} +noncomputable def dualPairProductEquiv (r : ℕ) (hr : r ≤ finrank K V) : + (Σ R : DualPairBase (K := K) (V := V) r, DualPairForms R) ≃ + CenterStratum (K := K) (V := V) r × CenterStratum (K := K) (V := V) r := + ( { toFun := fun RF => (⟨RF.1.1,RF.2.1⟩,⟨RF.1.2,RF.2.2⟩) + invFun := fun P => ⟨(P.1.1,P.2.1),(P.1.2,P.2.2)⟩ + left_inv := fun _ => rfl + right_inv := fun _ => rfl } : + (Σ R : DualPairBase (K := K) (V := V) r, DualPairForms R) ≃ + (Σ R : DimSubspace K (Module.Dual K V) r, SymForm K R.val.dualCoannihilator) × + (Σ R : DimSubspace K (Module.Dual K V) r, SymForm K R.val.dualCoannihilator)).trans + ((dualPairStratumEquiv r hr).prodCongr (dualPairStratumEquiv r hr)) +noncomputable def canonicalPairProfileEquiv (r h : ℕ) (hr : r ≤ finrank K V) : + CanonicalPairProfile (K := K) (V := V) r h ≃ CenterPairProfile (K := K) (V := V) r h := + (dualPairProductEquiv r hr).subtypeEquiv (fun _ => Iff.rfl) + +noncomputable def canonicalPairParameter {r h : ℕ} (hD : finrank K V=2*r) + (P : CanonicalPairProfile (K := K) (V := V) r h) : PairParameters r h := by + let p := finrank K ↥(P.val.1.1.val ⊓ P.val.1.2.val) + have hpr : p ≤ r := (Submodule.finrank_mono inf_le_left).trans_eq P.val.1.1.property + have hph : p ≤ h := by + simpa only [P.property] using dualGraph_pair_finrank_ge P.val.1.1.val P.val.1.2.val P.val.2.1 P.val.2.2 + have ht := dualGraph_pair_extra_feasible P.val.1.1 P.val.1.2 P.val.2.1 P.val.2.2 P.property + refine ⟨⟨p,by omega⟩,hph,?_⟩ + dsimp [p] at * + omega + + theorem dualGraph_pair_kernel_exact (R S : Submodule K (Module.Dual K V)) + (F : SymForm K R.dualCoannihilator) (G : SymForm K S.dualCoannihilator) : + finrank K ↥((dualGraph R F).val ⊓ (dualGraph S G).val) = + finrank K ↥(R ⊓ S)+finrank K (graphDifference _ _ F.val G.val).ker := by + have hh := graph_pair_intersection_finrank R.dualCoannihilator S.dualCoannihilator F.val G.val + rw [Subspace.dualCoannihilator_dualAnnihilator_eq (W := R), + Subspace.dualCoannihilator_dualAnnihilator_eq (W := S)] at hh + exact hh + + theorem dualGraph_pair_kernel_ge (R S : Submodule K (Module.Dual K V)) + (F : SymForm K R.dualCoannihilator) (G : SymForm K S.dualCoannihilator) (h : ℕ) + (hh : finrank K ↥((dualGraph R F).val ⊓ (dualGraph S G).val) = h) : + h-finrank K ↥(R ⊓ S) ≤ finrank K (graphDifference _ _ F.val G.val).ker := by + rw [dualGraph_pair_kernel_exact] at hh + omega +noncomputable def canonicalPairCoding {r h : ℕ} (hD : finrank K V=2*r) + (P : CanonicalPairProfile (K := K) (V := V) r h) : + Σ p : PairParameters r h, Σ R : SubspacePairProfile (K := K) (V := Module.Dual K V) r p.val.val, + DualPairLiftEvent R (h-p.val.val) := + ⟨canonicalPairParameter hD P,⟨P.val.1,rfl⟩,P.val.2, + dualGraph_pair_kernel_ge _ _ _ _ h P.property⟩ + + theorem canonicalPairCoding_injective {r h : ℕ} (hD : finrank K V=2*r) : + Function.Injective (canonicalPairCoding (K := K) (V := V) (h := h) hD) := by + let recover : (Σ p : PairParameters r h, Σ R : SubspacePairProfile (K := K) (V := Module.Dual K V) r p.val.val, + DualPairLiftEvent R (h-p.val.val)) → Σ R : DualPairBase (K := K) (V := V) r, DualPairForms R := + fun T => ⟨T.2.1.val,T.2.2.val⟩ + intro P Q hh + exact Subtype.ext (congrArg recover hh) + +variable [Fintype K] [Finite V] +omit [Finite V] in + theorem dualPairForms_card {r : ℕ} (R : DualPairBase (K := K) (V := V) r) : + Nat.card (DualPairForms R) = Fintype.card K ^ (2*((finrank K V-r+1).choose 2)) := by + have h₁ := coannihilator_finrank R.1.val + have h₂ := coannihilator_finrank R.2.val + rw [R.1.property] at h₁ + rw [R.2.property] at h₂ + have hd₁ : finrank K R.1.val.dualCoannihilator=finrank K V-r := by omega + have hd₂ : finrank K R.2.val.dualCoannihilator=finrank K V-r := by omega + simp only [DualPairForms,Nat.card_prod,symForm_card,hd₁,hd₂,←pow_add,two_mul] + theorem center_stratum_square (r : ℕ) (hr : r ≤ finrank K V) : + (Nat.card (CenterStratum (K := K) (V := V) r):ℝ)^2 = + (Nat.card (DimSubspace K (Module.Dual K V) r):ℝ)^2 * + (Fintype.card K:ℝ)^(2*((finrank K V-r+1).choose 2)) := by + rw [vertical_pair_count r hr,Nat.cast_mul,Nat.cast_pow,mul_pow, + Nat.card_congr (dualDimSubspaceEquiv (K := K) (V := V) r hr),←pow_mul,Nat.mul_comm _ 2] + + theorem dualPairLift_probability_bound {r p : ℕ} (hD : finrank K V=2*r) + (R : SubspacePairProfile (K := K) (V := Module.Dual K V) r p) (t : ℕ) (ht : t ≤ p) : + (Nat.card (DualPairLiftEvent R t):ℝ)/Nat.card (DualPairForms R.val) ≤ + 2^t/(Fintype.card K:ℝ)^((t+1).choose 2) := by + have hd := coannihilator_pair_finrank R.val.1.val R.val.2.val + rw [R.val.1.property,R.val.2.property,R.property,hD] at hd + exact pairFormDifference_nullity_bound _ _ t (by omega) + + theorem pairPlanted_bound_one (r h : ℕ) (hD : finrank K V=2*r) (p : PairParameters r h) : + (Nat.card (Σ R : SubspacePairProfile (K := K) (V := Module.Dual K V) r p.val.val, + DualPairLiftEvent R (h-p.val.val)):ℝ) / + (Nat.card (CenterStratum (K := K) (V := V) r):ℝ)^2 ≤ + 2^(2*r+p.val.val+(h-p.val.val)) / + (Fintype.card K:ℝ)^(p.val.val*p.val.val+(h-p.val.val+1).choose 2) := by + classical + let := Module.finite_of_finite K (M := Module.Dual K V) + let RType := SubspacePairProfile (K := K) (V := Module.Dual K V) r p.val.val + let q : ℝ := Fintype.card K + let f := 2*((finrank K V-r+1).choose 2) + let b : ℝ := 2^(h-p.val.val)/q^((h-p.val.val+1).choose 2) + have hq : 0 < q := by dsimp [q]; exact_mod_cast Fintype.card_pos (α := K) + have hforms (R : RType) : (Nat.card (DualPairLiftEvent R (h-p.val.val)):ℝ) ≤ b*q^f := by + have hh := dualPairLift_probability_bound hD R (h-p.val.val) p.property.2 + rw [dualPairForms_card,Nat.cast_pow] at hh + exact (div_le_iff₀ (pow_pos hq _)).mp hh + have hc := real_card_sigma_le _ hforms + have hr : r ≤ finrank K V := by omega + have hg : 0 < (Nat.card (DimSubspace K (Module.Dual K V) r):ℝ) := by + have hh := subspace_count_lower (K := K) (V := Module.Dual K V) r (by rw [Subspace.dual_finrank_eq]; exact hr) + exact lt_of_lt_of_le (by positivity) hh + have hp := subspacePairProfile_probability_bound (K := K) (V := Module.Dual K V) r p.val.val + (by rwa [Subspace.dual_finrank_eq]) (by omega) + rw [center_stratum_square r hr] + calc + _ ≤ (Nat.card RType:ℝ)*(b*q^f)/((Nat.card (DimSubspace K (Module.Dual K V) r):ℝ)^2*q^f) := + div_le_div_of_nonneg_right hc (by positivity) + _ = ((Nat.card RType:ℝ)/(Nat.card (DimSubspace K (Module.Dual K V) r):ℝ)^2)*b := by + field_simp + _ ≤ (2^(2*r+p.val.val)/q^(p.val.val*p.val.val))*b := by + apply mul_le_mul_of_nonneg_right _ (by dsimp [b]; positivity) + apply (div_le_div_iff₀ (sq_pos_of_pos hg) (pow_pos hq _)).mpr + simpa only [mul_comm] using hp + _ = _ := by dsimp [b]; rw [div_mul_div_comm,←pow_add,←pow_add] +end PairLiftCounts +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open scoped BigOperators + theorem two_active_gain_bound (h p : ℕ) (hph : p ≤ h) (htp : h-p ≤ p) : + ((h+1).choose 2 : ℝ) ≤ p*p+((h-p+1).choose 2 : ℕ)+((h/2+1).choose 2 : ℕ) := by + rw [triangular_nat,triangular_nat,triangular_nat] + have he : ((h-p : ℕ):ℝ)=(h:ℝ)-p := Nat.cast_sub hph + rw [he] + unfold triangular + have hh : h=2*(h/2) ∨ h=2*(h/2)+1 := by omega + have ha : (0:ℝ) ≤ h/2 := by positivity + rcases hh with hh|hh + · have hh' : (h:ℝ)=2*(h/2 : ℕ) := by exact_mod_cast hh + have hpa : h/2 ≤ p := by omega + by_cases hp : p=h/2 + · have hp' : (p:ℝ)=(h/2 : ℕ) := by exact_mod_cast hp + nlinarith + · have hp' : (h/2 : ℕ)+1 ≤ (p:ℝ) := by exact_mod_cast (show h/2+1 ≤ p by omega) + have hm := mul_nonneg (sub_nonneg.mpr (show ((h/2 : ℕ):ℝ) ≤ p by linarith)) + (sub_nonneg.mpr (show (1:ℝ) ≤ p-(h/2 : ℕ) by linarith)) + have hm' := mul_nonneg (show (0:ℝ) ≤ (h/2 : ℕ) by positivity) + (sub_nonneg.mpr (show ((h/2 : ℕ):ℝ) ≤ p by linarith)) + nlinarith + · have hh' : (h:ℝ)=2*(h/2 : ℕ)+1 := by exact_mod_cast hh + have hp' : (h/2 : ℕ)+1 ≤ (p:ℝ) := by exact_mod_cast (show h/2+1 ≤ p by omega) + have hm := mul_nonneg (show (0:ℝ) ≤ (h/2 : ℕ) by positivity) + (sub_nonneg.mpr (show (h/2 : ℕ)+1 ≤ (p:ℝ) from hp')) + nlinarith [sq_nonneg ((p:ℝ)-(h/2 : ℕ)-1)] + +section PairFinal +open Module +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [Fintype K] [Finite V] + theorem canonical_center_pair_probability_bound (r h : ℕ) (hD : finrank K V=2*r) : + (Nat.card (CenterPairProfile (K := K) (V := V) r h):ℝ) / + (Nat.card (CenterStratum (K := K) (V := V) r):ℝ)^2 ≤ + ∑ p : PairParameters r h, 2^(2*r+p.val.val+(h-p.val.val)) / + (Fintype.card K:ℝ)^(p.val.val*p.val.val+(h-p.val.val+1).choose 2) := by + classical + let := Module.finite_of_finite K (M := Module.Dual K V) + have hr : r ≤ finrank K V := by omega + rw [←Nat.card_congr (canonicalPairProfileEquiv r h hr)] + have hc := Nat.card_le_card_of_injective _ (canonicalPairCoding_injective (K := K) (V := V) (h := h) hD) + have hh : (Nat.card (CanonicalPairProfile (K := K) (V := V) r h):ℝ) ≤ + Nat.card (Σ p : PairParameters r h, Σ R : SubspacePairProfile (K := K) (V := Module.Dual K V) r p.val.val, + DualPairLiftEvent R (h-p.val.val)) := by exact_mod_cast hc + refine (div_le_div_of_nonneg_right hh (by positivity)).trans ?_ + rw [Nat.card_sigma,Nat.cast_sum,Finset.sum_div] + exact Finset.sum_le_sum (fun p _ => pairPlanted_bound_one r h hD p) + + theorem canonical_center_pair_gain_bound (r h : ℕ) (hD : finrank K V=2*r) : + (Fintype.card K:ℝ)^((h+1).choose 2) * + ((Nat.card (CenterPairProfile (K := K) (V := V) r h):ℝ) / + (Nat.card (CenterStratum (K := K) (V := V) r):ℝ)^2) ≤ + (Nat.card (PairParameters r h):ℝ)*2^(2*r+h)*(Fintype.card K:ℝ)^((h/2+1).choose 2) := by + have hq : (1:ℝ) ≤ Fintype.card K := by exact_mod_cast Fintype.card_pos (α := K) + have hqpos : (0:ℝ) < Fintype.card K := by positivity + have hh := canonical_center_pair_probability_bound (K := K) (V := V) r h hD + refine (mul_le_mul_of_nonneg_left hh (by positivity)).trans ?_ + rw [Finset.mul_sum] + calc + _ ≤ ∑ _p : PairParameters r h, 2^(2*r+h)*(Fintype.card K:ℝ)^((h/2+1).choose 2) := by + apply Finset.sum_le_sum + intro p _ + have hs : p.val.val+(h-p.val.val)=h := Nat.add_sub_of_le p.property.1 + have hg : (h+1).choose 2 ≤ p.val.val*p.val.val+(h-p.val.val+1).choose 2+(h/2+1).choose 2 := by + have hb := two_active_gain_bound h p.val.val p.property.1 p.property.2 + exact_mod_cast hb + rw [show 2*r+p.val.val+(h-p.val.val)=2*r+h by omega] + rw [←mul_div_assoc] + apply (div_le_iff₀ (pow_pos hqpos _)).mpr + calc + _ ≤ 2^(2*r+h)*(Fintype.card K:ℝ)^(p.val.val*p.val.val+(h-p.val.val+1).choose 2+(h/2+1).choose 2) := by + rw [mul_comm]; exact mul_le_mul_of_nonneg_left (pow_le_pow_right₀ hq hg) (by positivity) + _ = _ := by rw [pow_add]; ring + _ = _ := by simp only [Finset.sum_const,Finset.card_univ,Nat.card_eq_fintype_card]; ring +end PairFinal +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section SymplecticPairPlanted +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] +variable (ω : LinearMap.BilinForm K E) +abbrev PairCenterSet (r : ℕ) (L M : Submodule K E) := + {Y : SymplecticLagrangian ω // finrank K ↥(L ⊓ Y.val)=r ∧ finrank K ↥(M ⊓ Y.val)=r} +abbrev SymplecticCenterPairProfile (Y : SymplecticLagrangian ω) (r h : ℕ) := + {L : SymplecticCenterStratum ω Y r × SymplecticCenterStratum ω Y r // + finrank K ↥(L.1.val.val ⊓ L.2.val.val)=h} +noncomputable def symplecticCenterPairProfileEquiv {V : Type*} [AddCommGroup V] [Module K V] + (Y : SymplecticLagrangian ω) (e : (V × Module.Dual K V) ≃ₗ[K] E) + (he : ∀ x y, ω (e x) (e y)=canonicalSymplectic x y) + (hY : (verticalSpace (K := K) (V := V)).map e.toLinearMap=Y.val) (r h : ℕ) : + CenterPairProfile (K := K) (V := V) r h ≃ SymplecticCenterPairProfile ω Y r h := + let f := symplecticCenterStratumEquiv ω Y e he hY r + (f.prodCongr f).subtypeEquiv (by + intro L + change _ ↔ finrank K ↥(L.1.val.val.map e.toLinearMap ⊓ L.2.val.val.map e.toLinearMap)=h + rw [map_pair_finrank]) +noncomputable def pairCenterIsometryEquiv (r : ℕ) (L M : Submodule K E) + (e : E ≃ₗ[K] E) (he : ∀ x y, ω (e x) (e y)=ω x y) : + PairCenterSet ω r L M ≃ PairCenterSet ω r (L.map e.toLinearMap) (M.map e.toLinearMap) := + (lagrangianIsometryEquiv ω e he).subtypeEquiv (by + intro Y + change (_ ∧ _) ↔ (finrank K ↥(L.map e.toLinearMap ⊓ Y.val.map e.toLinearMap)=r ∧ + finrank K ↥(M.map e.toLinearMap ⊓ Y.val.map e.toLinearMap)=r) + rw [map_pair_finrank,map_pair_finrank]) +noncomputable def pairCenterProfileEquiv (r h : ℕ) : + (Σ p : OrderedPairDim ω h, PairCenterSet ω r p.val.1.val p.val.2.val) ≃ + Σ Y : SymplecticLagrangian ω, SymplecticCenterPairProfile ω Y r h where + toFun P := ⟨P.2.val,⟨(⟨P.1.val.1,P.2.property.1⟩,⟨P.1.val.2,P.2.property.2⟩),P.1.property⟩⟩ + invFun P := ⟨⟨(P.2.val.1.val,P.2.val.2.val),P.2.property⟩, + ⟨P.1,P.2.val.1.property,P.2.val.2.property⟩⟩ + left_inv _ := rfl + right_inv _ := rfl +variable [Fintype K] [Finite E] + omit [Fintype K] in + theorem pairCenter_profile_card (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (r : ℕ) (L M : SymplecticLagrangian ω) : + Nat.card (Σ Y : SymplecticLagrangian ω, + SymplecticCenterPairProfile ω Y r (finrank K ↥(L.val ⊓ M.val))) = + Nat.card (OrderedPairDim ω (finrank K ↥(L.val ⊓ M.val))) * Nat.card (PairCenterSet ω r L.val M.val) := by + classical + let := Fintype.ofFinite (OrderedPairDim ω (finrank K ↥(L.val ⊓ M.val))) + rw [←Nat.card_congr (pairCenterProfileEquiv ω r (finrank K ↥(L.val ⊓ M.val))),Nat.card_sigma] + have hc (p : OrderedPairDim ω (finrank K ↥(L.val ⊓ M.val))) : + Nat.card (PairCenterSet ω r p.val.1.val p.val.2.val)=Nat.card (PairCenterSet ω r L.val M.val) := by + obtain ⟨e,he,hL,hM⟩ := ordered_pair_transitivity ω h2 ha hω + p.val.1.val p.val.2.val L.val M.val p.val.1.property p.val.2.property L.property M.property p.property + have hh := Nat.card_congr (pairCenterIsometryEquiv ω r p.val.1.val p.val.2.val e he) + rwa [hL,hM] at hh + simp only [hc,Finset.sum_const,Finset.card_univ,nsmul_eq_mul,Nat.card_eq_fintype_card,Nat.cast_id] + omit [Fintype K] in + theorem symplectic_center_stratum_card_eq (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (A B : SymplecticLagrangian ω) (r : ℕ) : + Nat.card (SymplecticCenterStratum ω A r)=Nat.card (SymplecticCenterStratum ω B r) := by + obtain ⟨e,he,hA⟩ := lagrangian_transitivity ω A.val h2 ha hω A.property B.val B.property + exact Nat.card_congr ((lagrangianIsometryEquiv ω e he).subtypeEquiv (by + intro L + change _ ↔ finrank K ↥(L.val.map e.toLinearMap ⊓ B.val)=r + rw [←hA,map_pair_finrank])) + theorem symplectic_center_pair_gain_bound (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (r : ℕ) (hD : finrank K E=2*(2*r)) (Y : SymplecticLagrangian ω) (h : ℕ) : + (Fintype.card K:ℝ)^((h+1).choose 2)* + ((Nat.card (SymplecticCenterPairProfile ω Y r h):ℝ)/ + (Nat.card (SymplecticCenterStratum ω Y r):ℝ)^2) ≤ + (Nat.card (PairParameters r h):ℝ)*2^(2*r+h)*(Fintype.card K:ℝ)^((h/2+1).choose 2) := by + obtain ⟨e,he,hY⟩ := exists_center_coordinates ω h2 ha hω Y + rw [←Nat.card_congr (symplecticCenterPairProfileEquiv ω Y e he hY r h), + ←Nat.card_congr (symplecticCenterStratumEquiv ω Y e he hY r)] + have hd := self_orthogonal_twice_finrank ω Y.val hω Y.property + exact canonical_center_pair_gain_bound r h (by omega) +noncomputable def pairFaceDensity (r : ℕ) (A L M : SymplecticLagrangian ω) : ℝ := + (Nat.card (PairCenterSet ω r L.val M.val):ℝ)*(Nat.card (SymplecticLagrangian ω):ℝ) / + (Nat.card (SymplecticCenterStratum ω A r):ℝ)^2 + omit [Fintype K] [Finite E] in + theorem pairFaceDensity_nonneg (r : ℕ) (A L M : SymplecticLagrangian ω) : + 0 ≤ pairFaceDensity ω r A L M := by unfold pairFaceDensity; positivity +end SymplecticPairPlanted + + theorem normalized_pair_gain (L A O Z T C B : ℝ) (hL : 0.trans_eq (mul_comm _ _) + have hGain : q^((h+1).choose 2)*(Nat.card (OrderedPairDim ω h):ℝ)*Nat.card (PairCenterSet ω r L.val M.val) ≤ + (Nat.card (SymplecticLagrangian ω):ℝ)*a^2*b := by + rw [mul_assoc,←Nat.cast_mul,←pairCenter_profile_card ω h2 ha hω r L M,Nat.card_sigma,Nat.cast_sum,Finset.mul_sum] + calc + _ ≤ ∑ _Y : SymplecticLagrangian ω, a^2*b := Finset.sum_le_sum (fun Y _ => hg Y) + _ = _ := by simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,Nat.card_eq_fintype_card]; ring + exact normalized_pair_gain _ _ _ _ _ _ _ hL ha0 (by positivity) (by positivity) hMass hGain +end PairPointwise +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open Module +section ActualProfile +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] [Fintype K] [Finite E] +variable (ω : LinearMap.BilinForm K E) + theorem actual_profile_pair_sum_le (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D c u v w : ℕ) (hD : 2*D=finrank K E) (p : TripleDimProfile ω c u v w) : + (u-c)+(v-c)+(w-c) ≤ D-c := by + let S := tripleProfileCommon ω p + obtain ⟨L,M,N,hzero,hu,hv,hw,_⟩ := fixedCommonProfile_injection ω ha S ⟨p,rfl⟩ + let : Finite (ReducedSpace ω S.val) := Module.finite_of_finite K + have hc : c≤D := S.property.2 ▸ isotropic_finrank_le_half ω hω D hD S.val S.property.1 + have hd : 2*(D-c)=finrank K (ReducedSpace ω S.val) := by + have hh := reducedSpace_finrank ω S.val hω S.property.1 + rw [S.property.2,←hD] at hh + omega + simpa only [hu,hv,hw] using symplectic_profile_pair_sum_le + (symplecticReductionForm ω S.val ha) (symplecticReductionForm_nondegenerate ω S.val ha hω) (D-c) hd L M N hzero +end ActualProfile +end SidorenkoCounterexample + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/Pinning.lean b/lean/OAI/Combinatorics/Sidorenko/Pinning.lean new file mode 100644 index 0000000000000000000000000000000000000000..58474b3d16f665f6771c28ca6e9ab8fee2b49e03 --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/Pinning.lean @@ -0,0 +1,319 @@ +import OAI.Combinatorics.Sidorenko.Refinement + +namespace OAI + + +section + +namespace SidorenkoCounterexample +open Classical Filter +open scoped BigOperators Topology +section Mix +variable {A : Type*} [Fintype A] +lemma exists_positive_perturbation (f g : A → ℝ) (hf : ∀ a,0≤f a) + (hg : ∀ a,f a=0 → 0≤g a) : + ∃ ε : ℝ,0<ε ∧ ∀ a,0≤f a+ε*g a ∧ (f a+ε*g a=0 ↔ f a=0 ∧ g a=0) := by + have hv : ∀ᶠ ε : ℝ in nhds 0,∀ a,f a≠0 → 0 (hn h).elim) + · have hpos : 0 f a+ε*g a) (nhds 0) (nhds (f a)) := by + simpa using (tendsto_const_nhds : Tendsto (fun _ : ℝ => f a) (nhds 0) (nhds (f a))).add ((tendsto_id : Tendsto (fun ε : ℝ => ε) (nhds 0) (nhds 0)).mul_const (g a)) + exact (ht.eventually (lt_mem_nhds hpos)).mono (fun _ h _ => h) + have hw : ∀ᶠ ε : ℝ in nhdsWithin 0 (Set.Ioi 0),0<ε ∧ ∀ a,f a≠0 → 0 ?_⟩ + by_cases ha : f a=0 + · have hga := hg a ha + rw [ha,zero_add] + refine ⟨mul_nonneg hε.le hga,?_⟩ + simp only [true_and] + exact mul_eq_zero.trans (or_iff_right (ne_of_gt hε)) + · have hp := he a ha + exact ⟨hp.le,iff_of_false (ne_of_gt hp) (fun h => ha h.1)⟩ +end Mix +section Pin +variable {I J E C : Type*} [Fintype I] [Fintype J] [Fintype E] [Fintype C] + [DecidableEq I] [DecidableEq J] [DecidableEq C] +omit [DecidableEq I] [DecidableEq C] in +lemma sum_hist_sq_nonneg (f g : I → C → ℕ) : + 0≤∑ i,∑ c,((f i c:ℝ)-(g i c:ℝ))^2 := + Finset.sum_nonneg (fun _ _ => Finset.sum_nonneg (fun _ _ => sq_nonneg _)) +omit [DecidableEq I] [DecidableEq C] in +lemma sum_hist_sq_eq_zero (f g : I → C → ℕ) : + (∑ i,∑ c,((f i c:ℝ)-(g i c:ℝ))^2)=0 ↔ f=g := by + rw [Finset.sum_eq_zero_iff_of_nonneg (fun _ _ => Finset.sum_nonneg (fun _ _ => sq_nonneg _))] + simp only [Finset.mem_univ,forall_true_left] + simp only [Finset.sum_eq_zero_iff_of_nonneg (fun _ _ => sq_nonneg _),Finset.mem_univ,forall_true_left, + sq_eq_zero_iff,sub_eq_zero,Nat.cast_inj] + exact ⟨fun h => funext (fun i => funext (h i)),fun h => by rw [h]; simp⟩ +lemma roundScore_loss_properties (t : E → I) (h : E → J) (cI : I → C) (cJ : J → C) + (a : I → I) (b : J → J) (ha : ∀ i,cI (a i)=cI i) (hb : ∀ j,cJ (b j)=cJ j) : + let loss := (roundScores t h cI cJ).score t h id id-(roundScores t h cI cJ).score t h a b + 0≤loss ∧ (loss=0 ↔ + (∀ i,neighborHistogram t (cJ ∘ h) (a i)=neighborHistogram t (cJ ∘ h) i) ∧ + (∀ j,neighborHistogram h (cI ∘ t) (b j)=neighborHistogram h (cI ∘ t) j)) := by + dsimp only + rw [roundScore_loss t h cI cJ a b ha hb] + have hL := sum_hist_sq_nonneg (fun i => neighborHistogram t (cJ ∘ h) (a i)) (neighborHistogram t (cJ ∘ h)) + have hR := sum_hist_sq_nonneg (fun j => neighborHistogram h (cI ∘ t) (b j)) (neighborHistogram h (cI ∘ t)) + refine ⟨add_nonneg hL hR,?_⟩ + rw [add_eq_zero_iff_of_nonneg hL hR,sum_hist_sq_eq_zero,sum_hist_sq_eq_zero] + simp only [funext_iff] + +noncomputable def VertexPairScores.mix (s r : VertexPairScores I J) (ε : ℝ) : VertexPairScores I J where + left i := s.left i+ε*r.left i + right j := s.right j+ε*r.right j + pair i j := s.pair i j+ε*r.pair i j +omit [DecidableEq I] [DecidableEq J] in +lemma VertexPairScores.score_mix (s r : VertexPairScores I J) (ε : ℝ) + (t : E → I) (h : E → J) (a : I → I) (b : J → J) : + (s.mix r ε).score t h a b=s.score t h a b+ε*r.score t h a b := by + simp only [score,mix,Finset.sum_add_distrib,←Finset.mul_sum]; ring + +def PreservesColors (cI : I → C) (cJ : J → C) (m : (I → I) × (J → J)) : Prop := + (∀ i,cI (m.1 i)=cI i) ∧ ∀ j,cJ (m.2 j)=cJ j +lemma pinning_step (t : E → I) (h : E → J) (cI dI : I → C) (cJ dJ : J → C) + (hI : ∀ v w,dI v=dI w ↔ cI v=cI w ∧ neighborHistogram t (cJ ∘ h) v=neighborHistogram t (cJ ∘ h) w) + (hJ : ∀ v w,dJ v=dJ w ↔ cJ v=cJ w ∧ neighborHistogram h (cI ∘ t) v=neighborHistogram h (cI ∘ t) w) + (s : VertexPairScores I J) + (hs : ∀ m : (I → I) × (J → J),0≤ s.score t h id id-s.score t h m.1 m.2 ∧ + (s.score t h id id-s.score t h m.1 m.2=0 ↔ PreservesColors cI cJ m)) : + ∃ snew : VertexPairScores I J,∀ m : (I → I) × (J → J),0≤ snew.score t h id id-snew.score t h m.1 m.2 ∧ + (snew.score t h id id-snew.score t h m.1 m.2=0 ↔ PreservesColors dI dJ m) := by + let r := roundScores t h cI cJ + let f (m : (I → I) × (J → J)) := s.score t h id id-s.score t h m.1 m.2 + let g (m : (I → I) × (J → J)) := r.score t h id id-r.score t h m.1 m.2 + have hg (m) (hm : f m=0) := (hs m).2.mp hm + have hp (m) (hm : f m=0) := roundScore_loss_properties t h cI cJ m.1 m.2 (hg m hm).1 (hg m hm).2 + obtain ⟨ε,hε,he⟩ := exists_positive_perturbation f g (fun m => (hs m).1) (fun m hm => (hp m hm).1) + refine ⟨s.mix r ε,fun m => ?_⟩ + have halg : (s.mix r ε).score t h id id-(s.mix r ε).score t h m.1 m.2=f m+ε*g m := by + simp only [VertexPairScores.score_mix,f,g]; ring + rw [halg] + refine ⟨(he m).1,(he m).2.trans ?_⟩ + constructor + · rintro ⟨hf,hg0⟩ + obtain ⟨hL,hR⟩ := (hp m hf).2.mp hg0 + exact ⟨fun i => (hI _ _).mpr ⟨(hg m hf).1 i,hL i⟩,fun j => (hJ _ _).mpr ⟨(hg m hf).2 j,hR j⟩⟩ + · intro hm + have hc : PreservesColors cI cJ m := ⟨fun i => ((hI _ _).mp (hm.1 i)).1,fun j => ((hJ _ _).mp (hm.2 j)).1⟩ + have hf := (hs m).2.mpr hc + exact ⟨hf,(hp m hf).2.mpr ⟨fun i => ((hI _ _).mp (hm.1 i)).2,fun j => ((hJ _ _).mp (hm.2 j)).2⟩⟩ +end Pin +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Classical +open scoped BigOperators +lemma pinning_complex : ∃ s : VertexPairScores (Fin 13) (Fin 22), + ∀ a b,(a,b)≠(id,id) → s.score cornerPoint (fun k : ActCorner => k.1) a b < s.score cornerPoint (fun k : ActCorner => k.1) id id := by + let t := cornerPoint + let h := fun k : ActCorner => k.1 + let s0 : VertexPairScores (Fin 13) (Fin 22) := ⟨fun _ => 0,fun _ => 0,fun _ _ => 0⟩ + have hcI : ∀ i,refineLeft0 i=0 := by decide + have hcJ : ∀ j,refineRight0 j=1 := by decide + have hs0 (m : (Fin 13 → Fin 13) × (Fin 22 → Fin 22)) : + 0 ≤ s0.score t h id id-s0.score t h m.1 m.2 ∧ + (s0.score t h id id-s0.score t h m.1 m.2=0 ↔ PreservesColors refineLeft0 refineRight0 m) := by + simp only [VertexPairScores.score,s0,Finset.sum_const_zero,add_zero,sub_self,le_refl,true_and] + exact iff_of_true trivial ⟨fun i => (hcI _).trans (hcI i).symm,fun j => (hcJ _).trans (hcJ j).symm⟩ + have hL0 : neighborHistogram t (refineRight0 ∘ h)=histLeft0 := funext (fun i => funext (histLeft0_correct i)) + have hR0 : neighborHistogram h (refineLeft0 ∘ t)=histRight0 := funext (fun j => funext (histRight0_correct j)) + have hI0 : ∀ v w,refineLeft1 v=refineLeft1 w ↔ refineLeft0 v=refineLeft0 w ∧ + neighborHistogram t (refineRight0 ∘ h) v=neighborHistogram t (refineRight0 ∘ h) w := by + simpa only [hL0] using refineLeft0_iff + have hJ0 : ∀ v w,refineRight1 v=refineRight1 w ↔ refineRight0 v=refineRight0 w ∧ + neighborHistogram h (refineLeft0 ∘ t) v=neighborHistogram h (refineLeft0 ∘ t) w := by + simpa only [hR0] using refineRight0_iff + obtain ⟨s1,hs1⟩ := pinning_step t h refineLeft0 refineLeft1 refineRight0 refineRight1 hI0 hJ0 s0 hs0 + have hL1 : neighborHistogram t (refineRight1 ∘ h)=histLeft1 := funext (fun i => funext (histLeft1_correct i)) + have hR1 : neighborHistogram h (refineLeft1 ∘ t)=histRight1 := funext (fun j => funext (histRight1_correct j)) + have hI1 : ∀ v w,refineLeft2 v=refineLeft2 w ↔ refineLeft1 v=refineLeft1 w ∧ + neighborHistogram t (refineRight1 ∘ h) v=neighborHistogram t (refineRight1 ∘ h) w := by + simpa only [hL1] using refineLeft1_iff + have hJ1 : ∀ v w,refineRight2 v=refineRight2 w ↔ refineRight1 v=refineRight1 w ∧ + neighborHistogram h (refineLeft1 ∘ t) v=neighborHistogram h (refineLeft1 ∘ t) w := by + simpa only [hR1] using refineRight1_iff + obtain ⟨s2,hs2⟩ := pinning_step t h refineLeft1 refineLeft2 refineRight1 refineRight2 hI1 hJ1 s1 hs1 + have hL2 : neighborHistogram t (refineRight2 ∘ h)=histLeft2 := funext (fun i => funext (histLeft2_correct i)) + have hR2 : neighborHistogram h (refineLeft2 ∘ t)=histRight2 := funext (fun j => funext (histRight2_correct j)) + have hI2 : ∀ v w,refineLeft3 v=refineLeft3 w ↔ refineLeft2 v=refineLeft2 w ∧ + neighborHistogram t (refineRight2 ∘ h) v=neighborHistogram t (refineRight2 ∘ h) w := by + simpa only [hL2] using refineLeft2_iff + have hJ2 : ∀ v w,refineRight3 v=refineRight3 w ↔ refineRight2 v=refineRight2 w ∧ + neighborHistogram h (refineLeft2 ∘ t) v=neighborHistogram h (refineLeft2 ∘ t) w := by + simpa only [hR2] using refineRight2_iff + obtain ⟨s3,hs3⟩ := pinning_step t h refineLeft2 refineLeft3 refineRight2 refineRight3 hI2 hJ2 s2 hs2 + have hL3 : neighborHistogram t (refineRight3 ∘ h)=histLeft3 := funext (fun i => funext (histLeft3_correct i)) + have hR3 : neighborHistogram h (refineLeft3 ∘ t)=histRight3 := funext (fun j => funext (histRight3_correct j)) + have hI3 : ∀ v w,refineLeft4 v=refineLeft4 w ↔ refineLeft3 v=refineLeft3 w ∧ + neighborHistogram t (refineRight3 ∘ h) v=neighborHistogram t (refineRight3 ∘ h) w := by + simpa only [hL3] using refineLeft3_iff + have hJ3 : ∀ v w,refineRight4 v=refineRight4 w ↔ refineRight3 v=refineRight3 w ∧ + neighborHistogram h (refineLeft3 ∘ t) v=neighborHistogram h (refineLeft3 ∘ t) w := by + simpa only [hR3] using refineRight3_iff + obtain ⟨s4,hs4⟩ := pinning_step t h refineLeft3 refineLeft4 refineRight3 refineRight4 hI3 hJ3 s3 hs3 + refine ⟨s4,fun a b hne => ?_⟩ + have hp := hs4 (a,b) + have hn : s4.score t h id id-s4.score t h a b≠0 := by + intro hz + have hc := hp.2.mp hz + apply hne + exact Prod.ext (funext (fun i => refineLeft_final (hc.1 i))) (funext (fun j => refineRight_final (hc.2 j))) + exact sub_pos.mp (lt_of_le_of_ne hp.1 (Ne.symm hn)) +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Classical Filter +open scoped BigOperators Topology +section Weights +variable {A I : Type*} [Fintype A] [Nonempty A] [Fintype I] +noncomputable def exponentialNormalizer (s : A → ℝ) (ρ : ℝ) : ℝ := ∑ a,Real.exp (ρ*s a) +lemma exponentialNormalizer_pos (s : A → ℝ) (ρ : ℝ) : 0 Real.exp_pos _) Finset.univ_nonempty +noncomputable def exponentialPrior (s : A → ℝ) (ρ : ℝ) : FiniteLaw A where + weight a := Real.exp (ρ*s a)/exponentialNormalizer s ρ + nonneg _ := div_nonneg (Real.exp_pos _).le (exponentialNormalizer_pos s ρ).le + total := by rw [←Finset.sum_div]; exact div_self (ne_of_gt (exponentialNormalizer_pos s ρ)) +lemma prod_exp_weight (ρ : ℝ) (s : I → ℝ) : + (∏ i,Real.exp (ρ*s i))=Real.exp (ρ*∑ i,s i) := by + rw [Finset.mul_sum,Real.exp_sum] +lemma exponentialPrior_product (s : A → ℝ) (ρ : ℝ) (a : I → A) : + (∏ i,(exponentialPrior s ρ).weight (a i))= + Real.exp (ρ*∑ i,s (a i))/(exponentialNormalizer s ρ)^Fintype.card I := by + simp only [exponentialPrior,Finset.prod_div_distrib,Finset.prod_const,Finset.card_univ,prod_exp_weight] +omit [Nonempty A] in +lemma exponential_dominant_limit (s c : A → ℝ) (a₀ : A) (hs : ∀ a,a≠a₀ → s a ∑ a,c a*Real.exp (ρ*(s a-s a₀))) atTop (nhds (c a₀)) := by + have h (a : A) : Tendsto (fun ρ : ℝ => c a*Real.exp (ρ*(s a-s a₀))) atTop + (nhds (if a=a₀ then c a₀ else 0)) := by + by_cases ha : a=a₀ + · subst a; simp + · have hd : s a-s a₀<0 := sub_neg.mpr (hs a ha) + have ht := Real.tendsto_exp_atBot.comp (Tendsto.const_mul_atTop_of_neg hd (tendsto_id : Tendsto (fun ρ : ℝ => ρ) atTop atTop)) + simpa only [ha,ite_false,mul_comm,mul_zero,Function.comp_def,id_eq] using ht.const_mul (c a) + simpa only [Finset.sum_ite_eq',Finset.mem_univ,ite_true] using tendsto_finsetSum Finset.univ (fun a _ => h a) +omit [Nonempty A] in +lemma exponential_dominant_negative (s c : A → ℝ) (a₀ : A) (hs : ∀ a,a≠a₀ → s a thinnedLaw (basePairLaw a b) (gibbsThinning s ρ M a b) (h0 a b) (h1 a b))= + gibbsPrefactor s ρ M 66*(∑ m : (Fin 13 → Fin 13) × (Fin 22 → Fin 22), + typedCoefficient basePairLaw m.1 m.2*Real.exp (ρ*s.score cornerPoint (fun k : ActCorner => k.1) m.1 m.2)) := by + unfold averagedCoefficient FiniteLaw.mean + rw [Finset.mul_sum] + apply Finset.sum_congr rfl; intro m _ + dsimp only + rw [typedCoefficient_thinned] + change ((∏ i,(exponentialPrior s.left ρ).weight (m.1 i))*(∏ j,(exponentialPrior s.right ρ).weight (m.2 j)))* + ((∏ k : ActCorner,gibbsThinning s ρ M (m.1 (cornerPoint k)) (m.2 k.1))*typedCoefficient basePairLaw m.1 m.2)=_ + rw [←mul_assoc,gibbs_weight_formula] + have hc : Fintype.card ActCorner=66 := by decide + rw [hc]; ring +lemma exists_negative_coefficient : ∃ (π : FiniteLaw (Fin 13)) (ν : FiniteLaw (Fin 22)) + (p : Fin 13 → Fin 22 → FiniteLaw (Activation ActCorner)), + (∀ a b α,α≠∅ → (p a b).mean (activationPhi α)=0) ∧ averagedCoefficient π ν p<0 := by + obtain ⟨s,hs⟩ := pinning_complex + let Q := fun m : (Fin 13 → Fin 13) × (Fin 22 → Fin 22) => s.score cornerPoint (fun k : ActCorner => k.1) m.1 m.2 + let C := fun m : (Fin 13 → Fin 13) × (Fin 22 → Fin 22) => typedCoefficient basePairLaw m.1 m.2 + have hc : C (id,id)<0 := by + change activeCoefficient (fun k => activationMoment (basePairLaw (cornerPoint k) k.1))<0 + rw [basePairLaw_identity]; exact neg_neg_of_pos (pow_pos (by norm_num) _) + obtain ⟨ρ,hρ,hneg⟩ := exponential_dominant_negative Q C (id,id) (fun m hm => hs m.1 m.2 hm) hc + let M : ℝ := Finset.univ.sup' Finset.univ_nonempty (fun ab : Fin 13 × Fin 22 => s.pair ab.1 ab.2) + have hM (a : Fin 13) (b : Fin 22) : s.pair a b≤M := Finset.le_sup' (fun ab : Fin 13 × Fin 22 => s.pair ab.1 ab.2) (Finset.mem_univ (a,b)) + have h0 (a : Fin 13) (b : Fin 22) : 0≤gibbsThinning s ρ M a b := (gibbsThinning_pos s ρ M a b).le + have h1 (a : Fin 13) (b : Fin 22) : gibbsThinning s ρ M a b≤1 := gibbsThinning_le_one s ρ M hρ.le hM a b + refine ⟨exponentialPrior s.left ρ,exponentialPrior s.right ρ, + (fun a b => thinnedLaw (basePairLaw a b) (gibbsThinning s ρ M a b) (h0 a b) (h1 a b)),?_,?_⟩ + · intro a b α hα + exact thinnedLaw_zero _ (basePairLaw_zero a b) _ _ _ α hα + · rw [averagedCoefficient_gibbs] + exact mul_neg_of_pos_of_neg (gibbsPrefactor_pos s ρ M 66) hneg +end SidorenkoCounterexample + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/Planted.lean b/lean/OAI/Combinatorics/Sidorenko/Planted.lean new file mode 100644 index 0000000000000000000000000000000000000000..65f0215769972e1cb70cc17cd4652ec9548e1db3 --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/Planted.lean @@ -0,0 +1,760 @@ +import OAI.Combinatorics.Sidorenko.OrbitBounds + +namespace OAI + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section PlantedQuotient +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] [FiniteDimensional K E] +variable (ω : LinearMap.BilinForm K E) (S : Submodule K E) + + theorem reduceSubspace_finrank_general (A : Submodule K E) (hAP : A ≤ ω.orthogonal S) : + finrank K (reduceSubspace ω S A) + finrank K ↥(S ⊓ A) = finrank K A := by + let f : A →ₗ[K] ReducedSpace ω S := (reductionKernel ω S).mkQ.comp (Submodule.inclusion hAP) + have hk : LinearMap.ker f = (S ⊓ A).comap A.subtype := by + ext x + constructor + · intro hx + exact ⟨(Submodule.Quotient.mk_eq_zero (reductionKernel ω S)).mp hx,x.property⟩ + · intro hx + exact (Submodule.Quotient.mk_eq_zero (reductionKernel ω S)).mpr hx.1 + have hr : LinearMap.range f = reduceSubspace ω S A := by + ext y + constructor + · rintro ⟨x,rfl⟩ + exact ⟨⟨x.val,hAP x.property⟩,x.property,rfl⟩ + · rintro ⟨x,hx,rfl⟩ + exact ⟨⟨x.val,hx⟩,rfl⟩ + have hh := f.finrank_range_add_finrank_ker + rw [hk,hr,(Submodule.comapSubtypeEquivOfLe (inf_le_right : S ⊓ A ≤ A)).finrank_eq] at hh + exact hh + + + + theorem reduce_center_intersection_finrank (L Y : Submodule K E) + (hSL : S ≤ L) (hLP : L ≤ ω.orthogonal S) : + finrank K ↥(reduceSubspace ω S L ⊓ reduceSubspace ω S Y) + finrank K ↥(S ⊓ Y) = + finrank K ↥(L ⊓ Y) := by + rw [←reduceSubspace_inf ω S L Y hSL] + have hh := reduceSubspace_finrank_general ω S (L ⊓ Y) (inf_le_left.trans hLP) + have he : S ⊓ (L ⊓ Y) = S ⊓ Y := by rw [←inf_assoc,inf_eq_left.mpr hSL] + rwa [he] at hh +end PlantedQuotient + +section CenterDisintegration +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] +variable (ω : LinearMap.BilinForm K E) + +abbrev TripleCenterSet (r : ℕ) (L M N : Submodule K E) := + {Y : SymplecticLagrangian ω // finrank K ↥(L ⊓ Y.val) = r ∧ + finrank K ↥(M ⊓ Y.val) = r ∧ finrank K ↥(N ⊓ Y.val) = r} + +noncomputable def tripleCenterIsometryEquiv (r : ℕ) (L M N : Submodule K E) + (e : E ≃ₗ[K] E) (he : ∀ x y, ω (e x) (e y) = ω x y) : + TripleCenterSet ω r L M N ≃ + TripleCenterSet ω r (L.map e.toLinearMap) (M.map e.toLinearMap) (N.map e.toLinearMap) := by + let f := lagrangianIsometryEquiv ω e he + refine f.subtypeEquiv ?_ + intro Y + change (_ ∧ _ ∧ _) ↔ (finrank K ↥(L.map e.toLinearMap ⊓ Y.val.map e.toLinearMap) = r ∧ + finrank K ↥(M.map e.toLinearMap ⊓ Y.val.map e.toLinearMap) = r ∧ + finrank K ↥(N.map e.toLinearMap ⊓ Y.val.map e.toLinearMap) = r) + rw [←Submodule.map_inf e.toLinearMap e.injective,←Submodule.map_inf e.toLinearMap e.injective, + ←Submodule.map_inf e.toLinearMap e.injective,e.finrank_map_eq,e.finrank_map_eq,e.finrank_map_eq] + + theorem tripleCenter_orbit_card (r : ℕ) (L M N : Submodule K E) + (P : OrderedTripleOrbit ω L M N) : + Nat.card (TripleCenterSet ω r P.val.1 P.val.2.1 P.val.2.2) = + Nat.card (TripleCenterSet ω r L M N) := by + obtain ⟨e,he,hL,hM,hN⟩ := P.property + rw [←hL,←hM,←hN] + exact (Nat.card_congr (tripleCenterIsometryEquiv ω r L M N e he)).symm + +/-- A literal finite disintegration over an ACTUAL ordered orbit, the exact +density-ratio identity behind the local planted bound. -/ + theorem tripleCenterOrbit_card [Finite E] (r : ℕ) (L M N : Submodule K E) : + Nat.card (Σ P : OrderedTripleOrbit ω L M N, TripleCenterSet ω r P.val.1 P.val.2.1 P.val.2.2) = + Nat.card (OrderedTripleOrbit ω L M N) * Nat.card (TripleCenterSet ω r L M N) := by + classical + let := Fintype.ofFinite (OrderedTripleOrbit ω L M N) + rw [Nat.card_sigma] + simp_rw [tripleCenter_orbit_card ω r L M N] + simp only [Finset.sum_const,Finset.card_univ,smul_eq_mul,Nat.card_eq_fintype_card] + +end CenterDisintegration +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section GenericReducedCount +variable {K E V : Type*} [Field K] [AddCommGroup E] [Module K E] + [AddCommGroup V] [Module K V] +variable (ω : LinearMap.BilinForm K E) + +abbrev SymplecticCenterStratum (Y : SymplecticLagrangian ω) (r : ℕ) := + {L : SymplecticLagrangian ω // finrank K ↥(L.val ⊓ Y.val) = r} +abbrev SymplecticCenterProfile (Y : SymplecticLagrangian ω) (r s₀ s₁ s₂ : ℕ) := + {L : SymplecticCenterStratum ω Y r × SymplecticCenterStratum ω Y r × SymplecticCenterStratum ω Y r // + (L.1.val.val ⊓ L.2.1.val.val) ⊓ L.2.2.val.val = ⊥ ∧ + finrank K ↥(L.1.val.val ⊓ L.2.1.val.val) = s₀ ∧ + finrank K ↥(L.1.val.val ⊓ L.2.2.val.val) = s₁ ∧ + finrank K ↥(L.2.1.val.val ⊓ L.2.2.val.val) = s₂} + + theorem exists_center_coordinates [FiniteDimensional K E] (h2 : (2:K) ≠ 0) + (ha : ω.IsAlt) (hω : ω.Nondegenerate) (Y : SymplecticLagrangian ω) : + ∃ e : (Y.val × Module.Dual K Y.val) ≃ₗ[K] E, + (∀ x y, ω (e x) (e y) = canonicalSymplectic x y) ∧ + (verticalSpace (K := K) (V := Y.val)).map e.toLinearMap = Y.val := by + obtain ⟨e,_,he⟩ := exists_lagrangian_coordinates ω Y.val h2 ha hω Y.property + let f := symplecticLagrangianEquiv canonicalSymplectic ω e he + let A := f.symm Y + have hm : A.val.map e.toLinearMap = Y.val := congrArg Subtype.val (f.apply_symm_apply Y) + obtain ⟨a,ha,hA⟩ := lagrangian_transitivity canonicalSymplectic verticalLagrangian.val h2 + canonicalSymplectic_alt canonicalSymplectic_nondegenerate verticalLagrangian.property A.val A.property + refine ⟨a.trans e,?_,?_⟩ + · intro x y + change ω (e (a x)) (e (a y)) = _ + rw [he,ha] + · change verticalSpace.map (e.toLinearMap.comp a.toLinearMap) = _ + rw [Submodule.map_comp] + change (verticalLagrangian.val.map a.toLinearMap).map e.toLinearMap = _ + rw [hA,hm] + + theorem map_pair_finrank (e : V ≃ₗ[K] E) (A B : Submodule K V) : + finrank K ↥(A.map e.toLinearMap ⊓ B.map e.toLinearMap) = finrank K ↥(A ⊓ B) := by + rw [←Submodule.map_inf e.toLinearMap e.injective] + exact e.finrank_map_eq _ + + theorem map_common_zero_iff (e : V ≃ₗ[K] E) (A B C : Submodule K V) : + (A.map e.toLinearMap ⊓ B.map e.toLinearMap) ⊓ C.map e.toLinearMap = ⊥ ↔ (A ⊓ B) ⊓ C = ⊥ := by + rw [←Submodule.map_inf e.toLinearMap e.injective,←Submodule.map_inf e.toLinearMap e.injective] + constructor + · intro h + apply (Submodule.orderIsoMapComap e).injective + simpa only [Submodule.orderIsoMapComap_apply,Submodule.map_bot] using h + · intro h + rw [h,Submodule.map_bot] + +noncomputable def symplecticCenterStratumEquiv (Y : SymplecticLagrangian ω) + (e : (V × Module.Dual K V) ≃ₗ[K] E) + (he : ∀ x y, ω (e x) (e y) = canonicalSymplectic x y) + (hY : (verticalSpace (K := K) (V := V)).map e.toLinearMap = Y.val) (r : ℕ) : + CenterStratum (K := K) (V := V) r ≃ SymplecticCenterStratum ω Y r := + (symplecticLagrangianEquiv canonicalSymplectic ω e he).subtypeEquiv (by + intro L + change finrank K ↥(L.val ⊓ verticalSpace) = r ↔ finrank K ↥(L.val.map e.toLinearMap ⊓ Y.val) = r + rw [←hY,map_pair_finrank]) + +noncomputable def symplecticCenterProfileEquiv (Y : SymplecticLagrangian ω) + (e : (V × Module.Dual K V) ≃ₗ[K] E) + (he : ∀ x y, ω (e x) (e y) = canonicalSymplectic x y) + (hY : (verticalSpace (K := K) (V := V)).map e.toLinearMap = Y.val) (r s₀ s₁ s₂ : ℕ) : + CenterTripleProfile (K := K) (V := V) r s₀ s₁ s₂ ≃ SymplecticCenterProfile ω Y r s₀ s₁ s₂ := + let f := symplecticCenterStratumEquiv ω Y e he hY r + (f.prodCongr (f.prodCongr f)).subtypeEquiv (by + intro L + change (_ ∧ _ ∧ _ ∧ _) ↔ + ((L.1.val.val.map e.toLinearMap ⊓ L.2.1.val.val.map e.toLinearMap) ⊓ L.2.2.val.val.map e.toLinearMap = ⊥ ∧ + finrank K ↥(L.1.val.val.map e.toLinearMap ⊓ L.2.1.val.val.map e.toLinearMap) = s₀ ∧ + finrank K ↥(L.1.val.val.map e.toLinearMap ⊓ L.2.2.val.val.map e.toLinearMap) = s₁ ∧ + finrank K ↥(L.2.1.val.val.map e.toLinearMap ⊓ L.2.2.val.val.map e.toLinearMap) = s₂) + rw [map_common_zero_iff,map_pair_finrank,map_pair_finrank,map_pair_finrank]) + + theorem symplectic_center_profile_probability_bound [Fintype K] [Finite E] + (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (Y : SymplecticLagrangian ω) (r s₀ s₁ s₂ : ℕ) (hr : r ≤ finrank K Y.val) : + (Nat.card (SymplecticCenterProfile ω Y r s₀ s₁ s₂) : ℝ) / + (Nat.card (SymplecticCenterStratum ω Y r) : ℝ)^3 ≤ + ∑ θ : BaseParameters (finrank K Y.val) r s₀ s₁ s₂, + reducedPlantedConstant r s₀ s₁ s₂ θ.val * + (Fintype.card K : ℝ)^(reducedPlantedExponent (finrank K Y.val) r s₀ s₁ s₂ θ.val) := by + obtain ⟨e,he,hY⟩ := exists_center_coordinates ω h2 ha hω Y + rw [←Nat.card_congr (symplecticCenterProfileEquiv ω Y e he hY r s₀ s₁ s₂), + ←Nat.card_congr (symplecticCenterStratumEquiv ω Y e he hY r)] + exact canonical_center_profile_probability_bound r s₀ s₁ s₂ hr + + theorem symplectic_profile_pair_sum_le [Fintype K] [Finite E] + (hω : ω.Nondegenerate) (D : ℕ) (hD : 2*D = finrank K E) + (L M N : SymplecticLagrangian ω) (h0 : (L.val ⊓ M.val) ⊓ N.val = ⊥) : + finrank K ↥(L.val ⊓ M.val)+finrank K ↥(L.val ⊓ N.val)+finrank K ↥(M.val ⊓ N.val) ≤ D := by + rw [←triplePairSum_finrank _ _ _ h0] + exact isotropic_finrank_le_half ω hω D hD _ (triplePairSum_isotropic ω _ _ _ L.property M.property N.property) + +end GenericReducedCount +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section CommonCenterCounts +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] [Fintype K] [Finite E] +variable (ω : LinearMap.BilinForm K E) +abbrev CommonCenterSet (S : Submodule K E) (u : ℕ) := + {Y : SymplecticLagrangian ω // finrank K ↥(S ⊓ Y.val) = u} + + theorem commonCenter_card_upper (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D = finrank K E) (S : Submodule K E) + (hS : S ≤ ω.orthogonal S) (u : ℕ) (hu : u ≤ finrank K S) : + (Nat.card (CommonCenterSet ω S u) : ℝ) ≤ + 2^u * lagrangianConstant (D-u) * + (Fintype.card K : ℝ)^(u*(finrank K S-u)+(D-u+1).choose 2) := by + classical + let B := CommonCenterSet ω S u + let Inc := Σ U : DimSubspace K S u, {Y : SymplecticLagrangian ω // U.val.map S.subtype ≤ Y.val} + let f (Y : B) : Inc := + ⟨⟨(S ⊓ Y.val.val).comap S.subtype, + (Submodule.comapSubtypeEquivOfLe (inf_le_left : S ⊓ Y.val.val ≤ S)).finrank_eq.trans Y.property⟩, + ⟨Y.val,by rintro x ⟨y,hy,rfl⟩; exact hy.2⟩⟩ + have hf : Function.Injective f := by + intro Y Z h + exact Subtype.ext (congrArg (fun i : Inc => i.2.val) h) + have hb (U : DimSubspace K S u) : + (Nat.card {Y : SymplecticLagrangian ω // U.val.map S.subtype ≤ Y.val} : ℝ) ≤ + lagrangianConstant (D-u)*(Fintype.card K : ℝ)^((D-u+1).choose 2) := by + have hle : U.val.map S.subtype ≤ S := by rintro x ⟨y,_,rfl⟩; exact y.property + have his : U.val.map S.subtype ≤ ω.orthogonal (U.val.map S.subtype) := + hle.trans (hS.trans (ω.orthogonal_le hle)) + have hd : finrank K (U.val.map S.subtype) = u := + (Submodule.equivMapOfInjective S.subtype S.subtype_injective U.val).finrank_eq.symm.trans U.property + simpa only [hd] using (containingLagrangian_card_bounds ω h2 ha hω D hD _ his).2 + let := Fintype.ofFinite (DimSubspace K S u) + have hi : (Nat.card Inc : ℝ) ≤ (Nat.card (DimSubspace K S u) : ℝ)* + (lagrangianConstant (D-u)*(Fintype.card K : ℝ)^((D-u+1).choose 2)) := by + rw [Nat.card_sigma,Nat.cast_sum] + calc + _ ≤ ∑ U : DimSubspace K S u, lagrangianConstant (D-u)*(Fintype.card K : ℝ)^((D-u+1).choose 2) := + Finset.sum_le_sum (fun U _ => hb U) + _ = _ := by simp [Nat.card_eq_fintype_card] + calc + _ ≤ (Nat.card Inc : ℝ) := Nat.cast_le.mpr (Nat.card_le_card_of_injective f hf) + _ ≤ _ := hi + _ ≤ (2^u*(Fintype.card K : ℝ)^(u*(finrank K S-u))) * + (lagrangianConstant (D-u)*(Fintype.card K : ℝ)^((D-u+1).choose 2)) := + mul_le_mul_of_nonneg_right (subspace_count_upper u hu) + (mul_nonneg (lagrangianConstant_pos (D-u)).le (by positivity)) + _ = _ := by rw [pow_add]; ring + + theorem commonCenter_cost_bound (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D = finrank K E) (S : Submodule K E) + (hS : S ≤ ω.orthogonal S) (u : ℕ) (hu : u ≤ finrank K S) : + (Fintype.card K : ℝ)^(u*(D-finrank K S)+(u+1).choose 2) * + (Nat.card (CommonCenterSet ω S u) : ℝ) ≤ + 2^D * lagrangianConstant D * (Fintype.card K : ℝ)^((D+1).choose 2) := by + have hc := isotropic_finrank_le_half ω hω D hD S hS + have hud : u ≤ D := hu.trans hc + have he : u*(D-finrank K S)+(u+1).choose 2+ + (u*(finrank K S-u)+(D-u+1).choose 2) = (D+1).choose 2 := by + have hh := symmetric_nullity_exponent D u hud + have hmul : u*(D-finrank K S)+u*(finrank K S-u) = u*(D-u) := by + rw [←Nat.mul_add]; congr 1; omega + omega + have hh := mul_le_mul_of_nonneg_left (commonCenter_card_upper ω h2 ha hω D hD S hS u hu) + (show 0 ≤ (Fintype.card K : ℝ)^(u*(D-finrank K S)+(u+1).choose 2) by positivity) + calc + _ ≤ _ := hh + _ = (2^u*lagrangianConstant (D-u))*(Fintype.card K : ℝ)^((D+1).choose 2) := by + rw [←he,pow_add]; ring + _ ≤ _ := mul_le_mul_of_nonneg_right + (mul_le_mul (pow_le_pow_right₀ (show (1:ℝ) ≤ 2 by norm_num) hud) + (lagrangianConstant_mono (Nat.sub_le D u)) + (lagrangianConstant_pos (D-u)).le (by positivity)) (by positivity) +end CommonCenterCounts +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section ReducedCenterInjection +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] [FiniteDimensional K E] +variable (ω : LinearMap.BilinForm K E) +abbrev FixedCommonCenterProfile (c h₀ h₁ h₂ : ℕ) (S : IsotropicDimspace ω c) + (Y : SymplecticLagrangian ω) (r : ℕ) := + {p : TripleDimProfile ω c h₀ h₁ h₂ // tripleProfileCommon ω p = S ∧ + finrank K ↥(p.val.1.val ⊓ Y.val) = r ∧ + finrank K ↥(p.val.2.1.val ⊓ Y.val) = r ∧ + finrank K ↥(p.val.2.2.val ⊓ Y.val) = r} +noncomputable def generalReductionLagrangian (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (S : Submodule K E) (hS : S ≤ ω.orthogonal S) (Y : SymplecticLagrangian ω) : + SymplecticLagrangian (symplecticReductionForm ω S ha) := + ⟨reduceSubspace ω S Y.val,general_lagrangian_reduction ω S ha hω hS Y.val Y.property⟩ + + theorem fixedCommonCenter_injection (ha : ω.IsAlt) (hω : ω.Nondegenerate) + {c h₀ h₁ h₂ r u : ℕ} (S : IsotropicDimspace ω c) (Y : CommonCenterSet ω S.val u) : + ∃ f : FixedCommonCenterProfile ω c h₀ h₁ h₂ S Y.val r → + SymplecticCenterProfile (symplecticReductionForm ω S.val ha) + (generalReductionLagrangian ω ha hω S.val S.property.1 Y.val) + (r-u) (h₀-c) (h₁-c) (h₂-c), Function.Injective f := by + let F := FixedCommonCenterProfile ω c h₀ h₁ h₂ S Y.val r + let Y' := generalReductionLagrangian ω ha hω S.val S.property.1 Y.val + have heq (p : F) : (p.val.val.1.val ⊓ p.val.val.2.1.val) ⊓ p.val.val.2.2.val = S.val := + congrArg Subtype.val p.property.1 + have hL (p : F) : S.val ≤ p.val.val.1.val := (le_of_eq (heq p).symm).trans (inf_le_left.trans inf_le_left) + have hM (p : F) : S.val ≤ p.val.val.2.1.val := (le_of_eq (heq p).symm).trans (inf_le_left.trans inf_le_right) + have hN (p : F) : S.val ≤ p.val.val.2.2.val := (le_of_eq (heq p).symm).trans inf_le_right + let L (p : F) := commonReductionLagrangian ω S.val ha S.property.1 p.val.val.1 (hL p) + let M (p : F) := commonReductionLagrangian ω S.val ha S.property.1 p.val.val.2.1 (hM p) + let N (p : F) := commonReductionLagrangian ω S.val ha S.property.1 p.val.val.2.2 (hN p) + have hd (P : SymplecticLagrangian ω) (hSP : S.val ≤ P.val) + (hPr : finrank K ↥(P.val ⊓ Y.val.val) = r) : + finrank K ↥((commonReductionLagrangian ω S.val ha S.property.1 P hSP).val ⊓ Y'.val) = r-u := by + have hh := reduce_center_intersection_finrank ω S.val P.val Y.val.val hSP + (lagrangian_le_orthogonal ω S.val P.val P.property hSP) + rw [Y.property,hPr] at hh + change finrank K ↥(reduceSubspace ω S.val P.val ⊓ reduceSubspace ω S.val Y.val.val) = _ + omega + let L' (p : F) : SymplecticCenterStratum (symplecticReductionForm ω S.val ha) Y' (r-u) := + ⟨L p,hd _ _ p.property.2.1⟩ + let M' (p : F) : SymplecticCenterStratum (symplecticReductionForm ω S.val ha) Y' (r-u) := + ⟨M p,hd _ _ p.property.2.2.1⟩ + let N' (p : F) : SymplecticCenterStratum (symplecticReductionForm ω S.val ha) Y' (r-u) := + ⟨N p,hd _ _ p.property.2.2.2⟩ + have hzero (p : F) : ((L p).val ⊓ (M p).val) ⊓ (N p).val = ⊥ := by + change (reduceSubspace ω S.val p.val.val.1.val ⊓ reduceSubspace ω S.val p.val.val.2.1.val) ⊓ + reduceSubspace ω S.val p.val.val.2.2.val = ⊥ + rw [←reduceSubspace_inf ω S.val _ _ (hL p),←reduceSubspace_inf ω S.val _ _ (le_inf (hL p) (hM p)),heq p] + exact reduceSubspace_self ω S.val + have hp0 (p : F) : finrank K ↥((L p).val ⊓ (M p).val) = h₀-c := by + change finrank K ↥(reduceSubspace ω S.val p.val.val.1.val ⊓ reduceSubspace ω S.val p.val.val.2.1.val) = _ + rw [reducePair_finrank ω S.val _ _ (hL p) (hM p),p.val.property.2.1,S.property.2] + have hp1 (p : F) : finrank K ↥((L p).val ⊓ (N p).val) = h₁-c := by + change finrank K ↥(reduceSubspace ω S.val p.val.val.1.val ⊓ reduceSubspace ω S.val p.val.val.2.2.val) = _ + rw [reducePair_finrank ω S.val _ _ (hL p) (hN p),p.val.property.2.2.1,S.property.2] + have hp2 (p : F) : finrank K ↥((M p).val ⊓ (N p).val) = h₂-c := by + change finrank K ↥(reduceSubspace ω S.val p.val.val.2.1.val ⊓ reduceSubspace ω S.val p.val.val.2.2.val) = _ + rw [reducePair_finrank ω S.val _ _ (hM p) (hN p),p.val.property.2.2.2,S.property.2] + let f (p : F) : SymplecticCenterProfile (symplecticReductionForm ω S.val ha) Y' + (r-u) (h₀-c) (h₁-c) (h₂-c) := + ⟨(L' p,M' p,N' p),hzero p,hp0 p,hp1 p,hp2 p⟩ + refine ⟨f,?_⟩ + intro p q hpq + have heL : (L p).val = (L q).val := congrArg (fun r => r.val.1.val.val) hpq + have heM : (M p).val = (M q).val := congrArg (fun r => r.val.2.1.val.val) hpq + have heN : (N p).val = (N q).val := congrArg (fun r => r.val.2.2.val.val) hpq + have hpL : p.val.val.1 = q.val.val.1 := congrArg Subtype.val + (reduceLagrangian_injective ω S.val (a₁ := ⟨p.val.val.1,hL p⟩) (a₂ := ⟨q.val.val.1,hL q⟩) heL) + have hpM : p.val.val.2.1 = q.val.val.2.1 := congrArg Subtype.val + (reduceLagrangian_injective ω S.val (a₁ := ⟨p.val.val.2.1,hM p⟩) (a₂ := ⟨q.val.val.2.1,hM q⟩) heM) + have hpN : p.val.val.2.2 = q.val.val.2.2 := congrArg Subtype.val + (reduceLagrangian_injective ω S.val (a₁ := ⟨p.val.val.2.2,hN p⟩) (a₂ := ⟨q.val.val.2.2,hN q⟩) heN) + exact Subtype.ext (Subtype.ext (Prod.ext hpL (Prod.ext hpM hpN))) +end ReducedCenterInjection +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +noncomputable def reducedPlantedSum (d r s₀ s₁ s₂ : ℕ) (q : ℝ) : ℝ := + ∑ θ : BaseParameters d r s₀ s₁ s₂, + reducedPlantedConstant r s₀ s₁ s₂ θ.val * q^(reducedPlantedExponent d r s₀ s₁ s₂ θ.val) + theorem reducedPlantedSum_nonneg (d r s₀ s₁ s₂ : ℕ) (q : ℝ) (hq : 0 ≤ q) : + 0 ≤ reducedPlantedSum d r s₀ s₁ s₂ q := by + unfold reducedPlantedSum + apply Finset.sum_nonneg + intro θ _ + unfold reducedPlantedConstant + positivity + +section ReducedCardBound +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] [Fintype K] [Finite E] +variable (ω : LinearMap.BilinForm K E) + theorem symplectic_center_profile_card_upper (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D = finrank K E) (Y : SymplecticLagrangian ω) + (r s₀ s₁ s₂ : ℕ) (hr : r ≤ D) : + (Fintype.card K : ℝ)^(3*((r+1).choose 2)) * + (Nat.card (SymplecticCenterProfile ω Y r s₀ s₁ s₂) : ℝ) ≤ + 2^(3*D)*(Fintype.card K : ℝ)^(3*((D+1).choose 2))* + reducedPlantedSum D r s₀ s₁ s₂ (Fintype.card K) := by + have hd : finrank K Y.val = D := by + have hh := self_orthogonal_twice_finrank ω Y.val hω Y.property + omega + have hp := symplectic_pair_card_bounds ω h2 ha hω D hD Y r hr + have hq : (0:ℝ) < Fintype.card K := Nat.cast_pos.mpr Fintype.card_pos + have hc : (0:ℝ) < Nat.card (SymplecticCenterStratum ω Y r) := by + have hn : (0:ℝ) < (Fintype.card K : ℝ)^((r+1).choose 2) * + Nat.card (SymplecticCenterStratum ω Y r) := (by positivity : (0:ℝ) < + (Fintype.card K : ℝ)^((D+1).choose 2)).trans_le hp.1 + exact (mul_pos_iff_of_pos_left (pow_pos hq _)).mp hn + have hb := symplectic_center_profile_probability_bound ω h2 ha hω Y r s₀ s₁ s₂ (by omega) + rw [hd] at hb + change (_ / _) ≤ reducedPlantedSum D r s₀ s₁ s₂ (Fintype.card K) at hb + have hcount := (div_le_iff₀ (pow_pos hc 3)).mp hb + have hpair : ((Fintype.card K : ℝ)^((r+1).choose 2) * + Nat.card (SymplecticCenterStratum ω Y r))^3 ≤ + (2^D*(Fintype.card K : ℝ)^((D+1).choose 2))^3 := by + exact pow_le_pow_left₀ (by positivity) hp.2 3 + calc + _ ≤ (Fintype.card K : ℝ)^(3*((r+1).choose 2)) * + (reducedPlantedSum D r s₀ s₁ s₂ (Fintype.card K)* + (Nat.card (SymplecticCenterStratum ω Y r) : ℝ)^3) := + mul_le_mul_of_nonneg_left hcount (by positivity) + _ = ((Fintype.card K : ℝ)^((r+1).choose 2) * + Nat.card (SymplecticCenterStratum ω Y r))^3 * + reducedPlantedSum D r s₀ s₁ s₂ (Fintype.card K) := by + rw [mul_pow,←pow_mul,Nat.mul_comm 3]; ring + _ ≤ (2^D*(Fintype.card K : ℝ)^((D+1).choose 2))^3 * + reducedPlantedSum D r s₀ s₁ s₂ (Fintype.card K) := + mul_le_mul_of_nonneg_right hpair (reducedPlantedSum_nonneg _ _ _ _ _ _ (by positivity)) + _ = _ := by rw [mul_pow,←pow_mul,←pow_mul]; congr 2 <;> rw [Nat.mul_comm] + + theorem fixedCommonCenter_card_upper (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D = finrank K E) {c h₀ h₁ h₂ r u : ℕ} + (S : IsotropicDimspace ω c) (Y : CommonCenterSet ω S.val u) (hr : r-u ≤ D-c) : + (Fintype.card K : ℝ)^(3*((r-u+1).choose 2)) * + (Nat.card (FixedCommonCenterProfile ω c h₀ h₁ h₂ S Y.val r) : ℝ) ≤ + 2^(3*(D-c))*(Fintype.card K : ℝ)^(3*((D-c+1).choose 2))* + reducedPlantedSum (D-c) (r-u) (h₀-c) (h₁-c) (h₂-c) (Fintype.card K) := by + let := Module.finite_of_finite K (M := ReducedSpace ω S.val) + have hc := isotropic_finrank_le_half ω hω D hD S.val S.property.1 + rw [S.property.2] at hc + have hd := reducedSpace_finrank ω S.val hω S.property.1 + rw [S.property.2] at hd + obtain ⟨f,hf⟩ := fixedCommonCenter_injection ω ha hω (h₀ := h₀) (h₁ := h₁) (h₂ := h₂) (r := r) S Y + have hh := symplectic_center_profile_card_upper (symplecticReductionForm ω S.val ha) h2 + (symplecticReductionForm_alt ω S.val ha) (symplecticReductionForm_nondegenerate ω S.val ha hω) + (D-c) (by omega) (generalReductionLagrangian ω ha hω S.val S.property.1 Y.val) + (r-u) (h₀-c) (h₁-c) (h₂-c) hr + exact (mul_le_mul_of_nonneg_left (Nat.cast_le.mpr (Nat.card_le_card_of_injective f hf)) (by positivity)).trans hh +end ReducedCardBound +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section FullCenterCoding +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] [Fintype K] [Finite E] +variable (ω : LinearMap.BilinForm K E) +abbrev CommonParameters (D r c : ℕ) := {u : Fin (c+1) // u.val ≤ r ∧ r-u.val ≤ D-c} +noncomputable instance (D r c : ℕ) : Fintype (CommonParameters D r c) := Fintype.ofFinite _ +abbrev ProfileCenterSet (c h₀ h₁ h₂ r : ℕ) := + Σ p : TripleDimProfile ω c h₀ h₁ h₂, TripleCenterSet ω r p.val.1.val p.val.2.1.val p.val.2.2.val +abbrev PlantedCommonData (D c h₀ h₁ h₂ r : ℕ) := + Σ S : IsotropicDimspace ω c, Σ u : CommonParameters D r c, + Σ Y : CommonCenterSet ω S.val u.val.val, FixedCommonCenterProfile ω c h₀ h₁ h₂ S Y.val r + + theorem profileCenter_injection (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D = finrank K E) (c h₀ h₁ h₂ r : ℕ) : + ∃ f : ProfileCenterSet ω c h₀ h₁ h₂ r → PlantedCommonData ω D c h₀ h₁ h₂ r, + Function.Injective f := by + let F := ProfileCenterSet ω c h₀ h₁ h₂ r + let S (p : F) := tripleProfileCommon ω p.1 + let u (p : F) := finrank K ↥((S p).val ⊓ p.2.val.val) + have hS (p : F) : (S p).val ≤ p.1.val.1.val := inf_le_left.trans inf_le_left + have hu (p : F) : u p ≤ c := + (Submodule.finrank_mono (inf_le_left : (S p).val ⊓ p.2.val.val ≤ (S p).val)).trans_eq (S p).property.2 + have hur (p : F) : u p ≤ r := + (Submodule.finrank_mono (inf_le_inf_right p.2.val.val (hS p))).trans_eq p.2.property.1 + have hdr (p : F) : r-u p ≤ D-c := by + have hi := (S p).property.1 + have hc := isotropic_finrank_le_half ω hω D hD (S p).val hi + have hd := reducedSpace_finrank ω (S p).val hω hi + rw [(S p).property.2,hD.symm] at hd + rw [(S p).property.2] at hc + let Y' := generalReductionLagrangian ω ha hω (S p).val hi p.2.val + let := Module.finite_of_finite K (M := ReducedSpace ω (S p).val) + have hy := self_orthogonal_twice_finrank (symplecticReductionForm ω (S p).val ha) Y'.val + (symplecticReductionForm_nondegenerate ω (S p).val ha hω) Y'.property + have he := reduce_center_intersection_finrank ω (S p).val p.1.val.1.val p.2.val.val + (hS p) (lagrangian_le_orthogonal ω (S p).val p.1.val.1.val p.1.val.1.property (hS p)) + rw [p.2.property.1] at he + have hm := Submodule.finrank_mono (inf_le_right : + reduceSubspace ω (S p).val p.1.val.1.val ⊓ Y'.val ≤ Y'.val) + change finrank K ↥(reduceSubspace ω (S p).val p.1.val.1.val ⊓ Y'.val) + u p = r at he + omega + let f (p : F) : PlantedCommonData ω D c h₀ h₁ h₂ r := + ⟨S p,⟨⟨u p,by have := hu p; omega⟩,hur p,hdr p⟩,⟨p.2.val,rfl⟩, + ⟨p.1,rfl,p.2.property⟩⟩ + refine ⟨f,?_⟩ + intro p q hpq + have hprofile : p.1 = q.1 := congrArg (fun x : PlantedCommonData ω D c h₀ h₁ h₂ r => x.2.2.2.val) hpq + have hcenter : p.2.val = q.2.val := congrArg (fun x : PlantedCommonData ω D c h₀ h₁ h₂ r => x.2.2.1.val) hpq + cases p with + | mk p Y => + cases q with + | mk q Z => + dsimp only at hprofile hcenter + subst q + exact congrArg (Sigma.mk p) (Subtype.ext hcenter) +end FullCenterCoding +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators + theorem unweight_count_bound {q x C y : ℝ} (hq : 0 < q) (a b : ℕ) + (h : q^a*x ≤ C*q^b*y) : x ≤ C*q^((b:ℝ)-a)*y := by + apply le_of_mul_le_mul_left (a := q^a) ?_ (pow_pos hq _) + refine h.trans_eq ?_ + rw [Real.rpow_sub hq,Real.rpow_natCast,Real.rpow_natCast] + field_simp + +section CommonCountSummation +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] [Fintype K] [Finite E] +variable (ω : LinearMap.BilinForm K E) + theorem fixedCommonCenter_card_rpow_upper (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D = finrank K E) {c h₀ h₁ h₂ r u : ℕ} + (S : IsotropicDimspace ω c) (Y : CommonCenterSet ω S.val u) (hr : r-u ≤ D-c) : + (Nat.card (FixedCommonCenterProfile ω c h₀ h₁ h₂ S Y.val r) : ℝ) ≤ + 2^(3*(D-c))*(Fintype.card K : ℝ)^((3*((D-c+1).choose 2):ℕ)-(3*((r-u+1).choose 2):ℝ))* + reducedPlantedSum (D-c) (r-u) (h₀-c) (h₁-c) (h₂-c) (Fintype.card K) := +by + simpa only [Nat.cast_mul,Nat.cast_ofNat] using + unweight_count_bound (Nat.cast_pos.mpr Fintype.card_pos) _ _ + (fixedCommonCenter_card_upper ω h2 ha hω D hD (h₀ := h₀) (h₁ := h₁) (h₂ := h₂) S Y hr) + + theorem commonData_fixed_card_upper (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D = finrank K E) {c h₀ h₁ h₂ r : ℕ} + (S : IsotropicDimspace ω c) (u : CommonParameters D r c) : + (Nat.card (Σ Y : CommonCenterSet ω S.val u.val.val, + FixedCommonCenterProfile ω c h₀ h₁ h₂ S Y.val r) : ℝ) ≤ + (2^u.val.val*lagrangianConstant (D-u.val.val))*2^(3*(D-c)) * + (Fintype.card K : ℝ)^((u.val.val*(c-u.val.val)+(D-u.val.val+1).choose 2:ℕ)+ + (3*((D-c+1).choose 2):ℕ)-(3*((r-u.val.val+1).choose 2):ℝ))* + reducedPlantedSum (D-c) (r-u.val.val) (h₀-c) (h₁-c) (h₂-c) (Fintype.card K) := by + classical + let := Fintype.ofFinite (CommonCenterSet ω S.val u.val.val) + have hq : (0:ℝ) < Fintype.card K := Nat.cast_pos.mpr Fintype.card_pos + let A : ℝ := 2^(3*(D-c))*(Fintype.card K : ℝ)^((3*((D-c+1).choose 2):ℕ)-(3*((r-u.val.val+1).choose 2):ℝ))* + reducedPlantedSum (D-c) (r-u.val.val) (h₀-c) (h₁-c) (h₂-c) (Fintype.card K) + have hA : 0 ≤ A := mul_nonneg (mul_nonneg (by positivity) (Real.rpow_nonneg hq.le _)) + (reducedPlantedSum_nonneg _ _ _ _ _ _ hq.le) + have hu : u.val.val ≤ finrank K S.val := by rw [S.property.2]; exact Nat.le_of_lt_succ u.val.isLt + have hc := commonCenter_card_upper ω h2 ha hω D hD S.val S.property.1 u.val.val hu + rw [S.property.2] at hc + calc + _ = ∑ Y : CommonCenterSet ω S.val u.val.val, + (Nat.card (FixedCommonCenterProfile ω c h₀ h₁ h₂ S Y.val r) : ℝ) := by rw [Nat.card_sigma,Nat.cast_sum] + _ ≤ ∑ _Y : CommonCenterSet ω S.val u.val.val, A := + Finset.sum_le_sum (fun Y _ => fixedCommonCenter_card_rpow_upper ω h2 ha hω D hD S Y u.property.2) + _ = (Nat.card (CommonCenterSet ω S.val u.val.val) : ℝ)*A := by simp [Nat.card_eq_fintype_card] + _ ≤ (2^u.val.val*lagrangianConstant (D-u.val.val)* + (Fintype.card K : ℝ)^(u.val.val*(c-u.val.val)+(D-u.val.val+1).choose 2))*A := + mul_le_mul_of_nonneg_right hc hA + _ = _ := by + let a := u.val.val*(c-u.val.val)+(D-u.val.val+1).choose 2 + let b := 3*((D-c+1).choose 2) + let e : ℝ := 3*((r-u.val.val+1).choose 2:ℝ) + change (_*(Fintype.card K : ℝ)^a)*A = _*(Fintype.card K : ℝ)^((a:ℝ)+b-e)*_ + rw [show (a:ℝ)+b-e = a+((b:ℝ)-e) by ring,Real.rpow_add hq,Real.rpow_natCast] + dsimp [A,a,b,e] + ring +end CommonCountSummation +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +noncomputable def commonPlantedTerm (D c r h₀ h₁ h₂ : ℕ) (u : CommonParameters D r c) (q : ℝ) : ℝ := + (2^u.val.val*lagrangianConstant (D-u.val.val))*2^(3*(D-c)) * + q^((u.val.val*(c-u.val.val)+(D-u.val.val+1).choose 2:ℕ)+ + (3*((D-c+1).choose 2):ℕ)-(3*((r-u.val.val+1).choose 2):ℝ))* + reducedPlantedSum (D-c) (r-u.val.val) (h₀-c) (h₁-c) (h₂-c) q + theorem commonPlantedTerm_nonneg (D c r h₀ h₁ h₂ : ℕ) (u : CommonParameters D r c) (q : ℝ) + (hq : 0 ≤ q) : 0 ≤ commonPlantedTerm D c r h₀ h₁ h₂ u q := by + unfold commonPlantedTerm + exact mul_nonneg (mul_nonneg (mul_nonneg (mul_nonneg (by positivity) + (lagrangianConstant_pos _).le) (by positivity)) (Real.rpow_nonneg hq _)) + (reducedPlantedSum_nonneg _ _ _ _ _ _ hq) + +section FullProfileCenterBound +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] [Fintype K] [Finite E] +variable (ω : LinearMap.BilinForm K E) + theorem profileCenter_card_upper (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D = finrank K E) (c h₀ h₁ h₂ r : ℕ) (hc : c ≤ D) : + (Nat.card (ProfileCenterSet ω c h₀ h₁ h₂ r) : ℝ) ≤ + (lagrangianConstant D*2^c)*(Fintype.card K : ℝ)^(isotropicExponent D c) * + ∑ u : CommonParameters D r c, commonPlantedTerm D c r h₀ h₁ h₂ u (Fintype.card K) := by + classical + let := Fintype.ofFinite (IsotropicDimspace ω c) + obtain ⟨f,hf⟩ := profileCenter_injection ω ha hω D hD c h₀ h₁ h₂ r + have hs (S : IsotropicDimspace ω c) : + (Nat.card (Σ u : CommonParameters D r c, Σ Y : CommonCenterSet ω S.val u.val.val, + FixedCommonCenterProfile ω c h₀ h₁ h₂ S Y.val r) : ℝ) ≤ + ∑ u : CommonParameters D r c, commonPlantedTerm D c r h₀ h₁ h₂ u (Fintype.card K) := by + rw [Nat.card_sigma,Nat.cast_sum] + exact Finset.sum_le_sum (fun u _ => commonData_fixed_card_upper ω h2 ha hω D hD S u) + calc + _ ≤ (Nat.card (PlantedCommonData ω D c h₀ h₁ h₂ r) : ℝ) := + Nat.cast_le.mpr (Nat.card_le_card_of_injective f hf) + _ = ∑ S : IsotropicDimspace ω c, + (Nat.card (Σ u : CommonParameters D r c, Σ Y : CommonCenterSet ω S.val u.val.val, + FixedCommonCenterProfile ω c h₀ h₁ h₂ S Y.val r) : ℝ) := by rw [Nat.card_sigma,Nat.cast_sum] + _ ≤ ∑ _S : IsotropicDimspace ω c, + ∑ u : CommonParameters D r c, commonPlantedTerm D c r h₀ h₁ h₂ u (Fintype.card K) := + Finset.sum_le_sum (fun S _ => hs S) + _ = (Nat.card (IsotropicDimspace ω c) : ℝ)* + ∑ u : CommonParameters D r c, commonPlantedTerm D c r h₀ h₁ h₂ u (Fintype.card K) := by + simp [Nat.card_eq_fintype_card] + _ ≤ _ := mul_le_mul_of_nonneg_right (isotropic_card_bounds ω h2 ha hω D hD c hc).2 + (Finset.sum_nonneg (fun u _ => commonPlantedTerm_nonneg _ _ _ _ _ _ _ _ (by positivity))) +end FullProfileCenterBound +end SidorenkoCounterexample + +namespace SidorenkoCounterexample + theorem normalized_count_ratio_bound {p t s O Z T A L C B : ℝ} + (hp : 0 < p) (hA : 0 < A) (hZ : 0 ≤ Z) (hT : 0 ≤ T) (_hO : 0 ≤ O) + (hL : 0 ≤ L) (hC : 0 ≤ C) (_hB : 0 ≤ B) (hs : 0 ≤ s) (_ht : 0 ≤ t) + (hOrbit : p^3 ≤ C*s*O) (hCenter : O*Z ≤ T) + (hPair : p ≤ t*A) (hLag : L ≤ B*p) : + Z*L^2/A^3 ≤ C*B^2*s*t^3*T/p^4 := by + have hbar : p^3*Z ≤ C*s*T := by + calc + _ ≤ (C*s*O)*Z := mul_le_mul_of_nonneg_right hOrbit hZ + _ = (C*s)*(O*Z) := by ring + _ ≤ _ := mul_le_mul_of_nonneg_left hCenter (mul_nonneg hC hs) + have hl : L^2 ≤ (B*p)^2 := pow_le_pow_left₀ hL hLag 2 + have htt : p^3 ≤ (t*A)^3 := pow_le_pow_left₀ hp.le hPair 3 + apply (div_le_div_iff₀ (pow_pos hA 3) (pow_pos hp 4)).mpr + calc + Z*L^2*p^4 ≤ Z*(B*p)^2*p^4 := by gcongr + _ = (p^3*Z)*B^2*p^3 := by ring + _ ≤ (C*s*T)*B^2*(t*A)^3 := by + exact mul_le_mul (mul_le_mul_of_nonneg_right hbar (sq_nonneg B)) htt + (by positivity) (by positivity) + _ = _ := by ring + +open Module +section OrbitCenterProfile +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] [FiniteDimensional K E] +variable (ω : LinearMap.BilinForm K E) + omit [FiniteDimensional K E] in + theorem orbit_member_profile (L M N : SymplecticLagrangian ω) + (P : OrderedTripleOrbit ω L.val M.val N.val) : + ω.orthogonal P.val.1 = P.val.1 ∧ ω.orthogonal P.val.2.1 = P.val.2.1 ∧ + ω.orthogonal P.val.2.2 = P.val.2.2 ∧ + finrank K ↥((P.val.1 ⊓ P.val.2.1) ⊓ P.val.2.2) = finrank K ↥((L.val ⊓ M.val) ⊓ N.val) ∧ + finrank K ↥(P.val.1 ⊓ P.val.2.1) = finrank K ↥(L.val ⊓ M.val) ∧ + finrank K ↥(P.val.1 ⊓ P.val.2.2) = finrank K ↥(L.val ⊓ N.val) ∧ + finrank K ↥(P.val.2.1 ⊓ P.val.2.2) = finrank K ↥(M.val ⊓ N.val) := by + obtain ⟨e,he,hL,hM,hN⟩ := P.property + rw [←hL,←hM,←hN] + refine ⟨(lagrangianIsometryEquiv ω e he L).property, + (lagrangianIsometryEquiv ω e he M).property, + (lagrangianIsometryEquiv ω e he N).property,?_,map_pair_finrank e _ _,map_pair_finrank e _ _,map_pair_finrank e _ _⟩ + rw [←Submodule.map_inf e.toLinearMap e.injective,←Submodule.map_inf e.toLinearMap e.injective,e.finrank_map_eq] + +omit [FiniteDimensional K E] in + theorem orbitCenter_profile_injection (L M N : SymplecticLagrangian ω) (r : ℕ) : + ∃ f : (Σ P : OrderedTripleOrbit ω L.val M.val N.val, + TripleCenterSet ω r P.val.1 P.val.2.1 P.val.2.2) → + ProfileCenterSet ω (finrank K ↥((L.val ⊓ M.val) ⊓ N.val)) + (finrank K ↥(L.val ⊓ M.val)) (finrank K ↥(L.val ⊓ N.val)) (finrank K ↥(M.val ⊓ N.val)) r, + Function.Injective f := by + let F := Σ P : OrderedTripleOrbit ω L.val M.val N.val, + TripleCenterSet ω r P.val.1 P.val.2.1 P.val.2.2 + let G := ProfileCenterSet ω (finrank K ↥((L.val ⊓ M.val) ⊓ N.val)) + (finrank K ↥(L.val ⊓ M.val)) (finrank K ↥(L.val ⊓ N.val)) (finrank K ↥(M.val ⊓ N.val)) r + let f (p : F) : G := + let hp := orbit_member_profile ω L M N p.1 + ⟨⟨(⟨p.1.val.1,hp.1⟩,⟨p.1.val.2.1,hp.2.1⟩,⟨p.1.val.2.2,hp.2.2.1⟩),hp.2.2.2⟩,p.2⟩ + refine ⟨f,?_⟩ + intro p q h + have he : p.1 = q.1 := Subtype.ext (congrArg (fun s : G => (s.1.val.1.val,s.1.val.2.1.val,s.1.val.2.2.val)) h) + have hy : p.2.val = q.2.val := congrArg (fun s : G => s.2.val) h + cases p with + | mk p Y => + cases q with + | mk q Z => + dsimp only at he hy + subst q + exact congrArg (Sigma.mk p) (Subtype.ext hy) + + omit [FiniteDimensional K E] in + theorem orbit_center_count_le_profile [Finite E] (L M N : SymplecticLagrangian ω) (r : ℕ) : + Nat.card (OrderedTripleOrbit ω L.val M.val N.val) * Nat.card (TripleCenterSet ω r L.val M.val N.val) ≤ + Nat.card (ProfileCenterSet ω (finrank K ↥((L.val ⊓ M.val) ⊓ N.val)) + (finrank K ↥(L.val ⊓ M.val)) (finrank K ↥(L.val ⊓ N.val)) (finrank K ↥(M.val ⊓ N.val)) r) := by + rw [←tripleCenterOrbit_card] + obtain ⟨f,hf⟩ := orbitCenter_profile_injection ω L M N r + exact Nat.card_le_card_of_injective f hf +end OrbitCenterProfile +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section PointwisePlanted +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] [Fintype K] [Finite E] +variable (ω : LinearMap.BilinForm K E) +noncomputable def tripleFaceDensity (r : ℕ) (A L M N : SymplecticLagrangian ω) : ℝ := + (Nat.card (TripleCenterSet ω r L.val M.val N.val) : ℝ)* + (Nat.card (SymplecticLagrangian ω) : ℝ)^2 / + (Nat.card (SymplecticCenterStratum ω A r) : ℝ)^3 + + omit [Fintype K] [Finite E] in + theorem tripleFaceDensity_nonneg (r : ℕ) (A L M N : SymplecticLagrangian ω) : + 0 ≤ tripleFaceDensity ω r A L M N := by unfold tripleFaceDensity; positivity + + theorem symplectic_center_stratum_card_pos (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D = finrank K E) (A : SymplecticLagrangian ω) (r : ℕ) (hr : r ≤ D) : + (0:ℝ) < Nat.card (SymplecticCenterStratum ω A r) := by + have hp := (symplectic_pair_card_bounds ω h2 ha hω D hD A r hr).1 + have hq : (0:ℝ) < Fintype.card K := Nat.cast_pos.mpr Fintype.card_pos + have hn : (0:ℝ) < (Fintype.card K : ℝ)^((r+1).choose 2) * + Nat.card (SymplecticCenterStratum ω A r) := (by positivity : (0:ℝ) < + (Fintype.card K : ℝ)^((D+1).choose 2)).trans_le hp + exact (mul_pos_iff_of_pos_left (pow_pos hq _)).mp hn + + theorem tripleFaceDensity_profile_bound [Invertible (2:K)] + (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D = finrank K E) (hq : 4*lagrangianConstant D ≤ (Fintype.card K : ℝ)) + (r : ℕ) (hr : r ≤ D) (A L M N : SymplecticLagrangian ω) : + tripleFaceDensity ω r A L M N ≤ + (orbitMassConstant D*(lagrangianConstant D)^2) * + (Fintype.card K : ℝ)^((tripleDefect D L.val M.val N.val : ℝ)+ + (3*((r+1).choose 2):ℕ)-(4*((D+1).choose 2):ℕ)) * + (Nat.card (ProfileCenterSet ω (finrank K ↥((L.val ⊓ M.val) ⊓ N.val)) + (finrank K ↥(L.val ⊓ M.val)) (finrank K ↥(L.val ⊓ N.val)) (finrank K ↥(M.val ⊓ N.val)) r) : ℝ) := by + let q : ℝ := Fintype.card K + have hq0 : 0 < q := Nat.cast_pos.mpr Fintype.card_pos + have hOrbit := tripleOrbit_card_lower ω ha hω D hD hq L M N + have hCenter := orbit_center_count_le_profile ω L M N r + have hPair := (symplectic_pair_card_bounds ω h2 ha hω D hD A r hr).1 + have hLag := (symplecticLagrangian_card_bounds ω h2 ha hω D hD).2 + have hi := normalized_count_ratio_bound + (p := q^((D+1).choose 2)) (t := q^((r+1).choose 2)) + (s := q^(tripleDefect D L.val M.val N.val)) + (O := Nat.card (OrderedTripleOrbit ω L.val M.val N.val)) + (Z := Nat.card (TripleCenterSet ω r L.val M.val N.val)) + (T := Nat.card (ProfileCenterSet ω (finrank K ↥((L.val ⊓ M.val) ⊓ N.val)) + (finrank K ↥(L.val ⊓ M.val)) (finrank K ↥(L.val ⊓ N.val)) (finrank K ↥(M.val ⊓ N.val)) r)) + (A := Nat.card (SymplecticCenterStratum ω A r)) (L := Nat.card (SymplecticLagrangian ω)) + (C := orbitMassConstant D) (B := lagrangianConstant D) + (pow_pos hq0 _) (symplectic_center_stratum_card_pos ω h2 ha hω D hD A r hr) + (by positivity) (by positivity) (by positivity) (by positivity) + (orbitMassConstant_pos D).le (lagrangianConstant_pos D).le (by positivity) (by positivity) + (by simpa only [←pow_mul,Nat.mul_comm] using hOrbit) + (by exact_mod_cast hCenter) hPair hLag + refine hi.trans_eq ?_ + change _ = _*q^((tripleDefect D L.val M.val N.val : ℝ)+(3*((r+1).choose 2):ℕ)-(4*((D+1).choose 2):ℕ))*_ + rw [Real.rpow_sub hq0,Real.rpow_add hq0,Real.rpow_natCast,Real.rpow_natCast,Real.rpow_natCast] + simp only [pow_mul,pow_succ] + ring + + theorem tripleFaceDensity_full_bound [Invertible (2:K)] + (h2 : (2:K) ≠ 0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D = finrank K E) (hq : 4*lagrangianConstant D ≤ (Fintype.card K : ℝ)) + (r : ℕ) (hr : r ≤ D) (A L M N : SymplecticLagrangian ω) : + let c := finrank K ↥((L.val ⊓ M.val) ⊓ N.val) + let h₀ := finrank K ↥(L.val ⊓ M.val) + let h₁ := finrank K ↥(L.val ⊓ N.val) + let h₂ := finrank K ↥(M.val ⊓ N.val) + tripleFaceDensity ω r A L M N ≤ + (orbitMassConstant D*(lagrangianConstant D)^2) * + (Fintype.card K : ℝ)^((tripleDefect D L.val M.val N.val : ℝ)+ + (3*((r+1).choose 2):ℕ)-(4*((D+1).choose 2):ℕ)) * + ((lagrangianConstant D*2^c)*(Fintype.card K : ℝ)^(isotropicExponent D c) * + ∑ u : CommonParameters D r c, commonPlantedTerm D c r h₀ h₁ h₂ u (Fintype.card K)) := by + dsimp only + have hc : finrank K ↥((L.val ⊓ M.val) ⊓ N.val) ≤ D := + isotropic_finrank_le_half ω hω D hD _ (by intro x hx y hy; exact L.property.ge hx.1.1 y hy.1.1) + have hh := profileCenter_card_upper ω h2 ha hω D hD + (finrank K ↥((L.val ⊓ M.val) ⊓ N.val)) + (finrank K ↥(L.val ⊓ M.val)) (finrank K ↥(L.val ⊓ N.val)) (finrank K ↥(M.val ⊓ N.val)) r hc + have hq0 : (0:ℝ) ≤ Fintype.card K := by positivity + exact (tripleFaceDensity_profile_bound ω h2 ha hω D hD hq r hr A L M N).trans + (mul_le_mul_of_nonneg_left hh (mul_nonneg (mul_nonneg (orbitMassConstant_pos D).le (sq_nonneg _)) + (Real.rpow_nonneg hq0 _))) +end PointwisePlanted +end SidorenkoCounterexample + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/Projections.lean b/lean/OAI/Combinatorics/Sidorenko/Projections.lean new file mode 100644 index 0000000000000000000000000000000000000000..80f8f827a855f918bf31ca6f2a125c6800f53210 --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/Projections.lean @@ -0,0 +1,484 @@ +import OAI.Combinatorics.Sidorenko.Signs + +namespace OAI + + +section + +namespace SidorenkoCounterexample +open Module LinearMap +section Projections +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + +def FormSelfAdjoint (Q : LinearMap.BilinForm K V) (T : V →ₗ[K] V) : Prop := + ∀ x y, Q (T x) y = Q x (T y) + +theorem selfAdjoint_projection_ker (Q : LinearMap.BilinForm K V) (hQ : Q.Nondegenerate) + (T : V →ₗ[K] V) (hT : FormSelfAdjoint Q T) : + T.ker = Q.orthogonal T.range := by + ext x + constructor + · intro hx y hy + obtain ⟨z,rfl⟩ := hy + rw [hT,show T x=0 from hx,map_zero] + · intro hx + apply hQ.2 + intro y + rw [←hT] + exact hx (T y) ⟨y,rfl⟩ + +variable [FiniteDimensional K V] +theorem selfAdjoint_projection_nondegenerate (Q : LinearMap.BilinForm K V) + (hs : Q.IsSymm) (hQ : Q.Nondegenerate) (T : V →ₗ[K] V) + (hT : FormSelfAdjoint Q T) (hi : IsIdempotentElem T) : + (Q.restrict T.range).Nondegenerate := by + apply (Q.restrict_nondegenerate_iff_isCompl_orthogonal hs.isRefl).mpr + rw [←selfAdjoint_projection_ker Q hQ T hT] + exact hi.isCompl + +noncomputable def formProjection (Q : LinearMap.BilinForm K V) (hs : Q.IsSymm) + (U : Submodule K V) (hU : (Q.restrict U).Nondegenerate) : V →ₗ[K] V := + U.projection (Q.orthogonal U) (Q.isCompl_orthogonal_of_restrict_nondegenerate hs.isRefl hU) + +theorem formProjection_idempotent (Q : LinearMap.BilinForm K V) (hs : Q.IsSymm) + (U : Submodule K V) (hU : (Q.restrict U).Nondegenerate) : + IsIdempotentElem (formProjection Q hs U hU) := Submodule.isIdempotentElem_projection _ + +theorem formProjection_range (Q : LinearMap.BilinForm K V) (hs : Q.IsSymm) + (U : Submodule K V) (hU : (Q.restrict U).Nondegenerate) : + (formProjection Q hs U hU).range=U := Submodule.range_projection _ + +theorem formProjection_selfAdjoint (Q : LinearMap.BilinForm K V) (hs : Q.IsSymm) + (U : Submodule K V) (hU : (Q.restrict U).Nondegenerate) : + FormSelfAdjoint Q (formProjection Q hs U hU) := by + intro x y + let h := Q.isCompl_orthogonal_of_restrict_nondegenerate hs.isRefl hU + let p := U.projection (Q.orthogonal U) h + have hx : x-p x ∈ Q.orthogonal U := Submodule.sub_projection_mem h x + have hy : y-p y ∈ Q.orthogonal U := Submodule.sub_projection_mem h y + have hpx : p x ∈ U := Submodule.projection_apply_mem h x + have hpy : p y ∈ U := Submodule.projection_apply_mem h y + have h1 := hy (p x) hpx + have h2 := hx (p y) hpy + simp only [map_sub] at h1 h2 + change Q (p x) y=Q x (p y) + calc + _ = Q (p x) (p y) := sub_eq_zero.mp h1 + _ = Q (p y) (p x) := hs.eq _ _ + _ = Q (p y) x := (sub_eq_zero.mp h2).symm + _ = _ := hs.eq _ _ + +def SelfAdjointIdempotent (Q : LinearMap.BilinForm K V) := + {T : V →ₗ[K] V // IsIdempotentElem T ∧ FormSelfAdjoint Q T} + +noncomputable def selfAdjointProjectionEquiv (Q : LinearMap.BilinForm K V) + (hs : Q.IsSymm) (hQ : Q.Nondegenerate) : + SelfAdjointIdempotent Q ≃ {U : Submodule K V // (Q.restrict U).Nondegenerate} where + toFun T := ⟨T.val.range,selfAdjoint_projection_nondegenerate Q hs hQ T.val T.property.2 T.property.1⟩ + invFun U := ⟨formProjection Q hs U.val U.property,formProjection_idempotent Q hs U.val U.property, + formProjection_selfAdjoint Q hs U.val U.property⟩ + left_inv T := by + apply Subtype.ext + let hU := selfAdjoint_projection_nondegenerate Q hs hQ T.val T.property.2 T.property.1 + apply ((formProjection_idempotent Q hs T.val.range hU).ext_iff T.property.1).mpr + constructor + · exact formProjection_range Q hs T.val.range hU + · rw [selfAdjoint_projection_ker Q hQ _ (formProjection_selfAdjoint Q hs T.val.range hU), + formProjection_range,←selfAdjoint_projection_ker Q hQ T.val T.property.2] + right_inv U := Subtype.ext (formProjection_range Q hs U.val U.property) +end Projections +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module LinearMap +open scoped Matrix +section MatrixProjection +variable {K n : Type*} [Field K] [Fintype n] [DecidableEq n] + +theorem matrix_formSelfAdjoint_iff (Q : Matrix n n K) (T : (n → K) →ₗ[K] (n → K)) : + FormSelfAdjoint Q.toBilin' T ↔ T.toMatrix'ᵀ*Q=Q*T.toMatrix' := by + change (∀ x y, Q.toBilin'.compLeft T x y = Q.toBilin'.compRight T x y) ↔ _ + rw [←LinearMap.BilinForm.ext_iff] + rw [←LinearMap.BilinForm.toMatrix'.injective.eq_iff] + simp only [LinearMap.BilinForm.toMatrix'_compLeft,LinearMap.BilinForm.toMatrix'_compRight, + LinearMap.BilinForm.toMatrix'_toBilin'] + +theorem matrix_selfAdjoint_of_symmetric (Q A : Matrix n n K) (hQ : Q.IsSymm) (hA : A.IsSymm) : + FormSelfAdjoint Q.toBilin' (A*Q).toLin' := by + rw [matrix_formSelfAdjoint_iff,LinearMap.toMatrix'_toLin',Matrix.transpose_mul,hQ,hA, + Matrix.mul_assoc] + +theorem matrix_projection_idempotent (Q A : Matrix n n K) (hA : A*Q*A=A) : + IsIdempotentElem (A*Q).toLin' := by + change (A*Q).toLin'.comp (A*Q).toLin' = (A*Q).toLin' + rw [←Matrix.toLin'_mul] + congr 1 + rw [←Matrix.mul_assoc,hA] + +def CenterProjection (Q : Matrix n n K) := + {A : Matrix n n K // A.IsSymm ∧ A*Q*A=A} + +noncomputable def centerToProjection (Q : Matrix n n K) (hQ : Q.IsSymm) + (A : CenterProjection Q) : SelfAdjointIdempotent Q.toBilin' := + ⟨(A.val*Q).toLin',matrix_projection_idempotent Q A.val A.property.2, + matrix_selfAdjoint_of_symmetric Q A.val hQ A.property.1⟩ + +theorem projection_to_center_symmetric (Q : Matrix n n K) (hQ : Q.IsSymm) + (hdet : Q.det≠0) (T : SelfAdjointIdempotent Q.toBilin') : + (T.val.toMatrix'*Q⁻¹).IsSymm := by + have h := (matrix_formSelfAdjoint_iff Q T.val).mp T.property.2 + have hu : IsUnit Q.det := isUnit_iff_ne_zero.mpr hdet + change (T.val.toMatrix'*Q⁻¹)ᵀ=T.val.toMatrix'*Q⁻¹ + rw [Matrix.transpose_mul,hQ.inv] + calc + Q⁻¹*T.val.toMatrix'ᵀ = Q⁻¹*(T.val.toMatrix'ᵀ*Q)*Q⁻¹ := by + simp only [Matrix.mul_assoc,Matrix.mul_nonsing_inv Q hu,Matrix.mul_one] + _ = Q⁻¹*(Q*T.val.toMatrix')*Q⁻¹ := by rw [h] + _ = _ := by rw [←Matrix.mul_assoc Q⁻¹ Q,Matrix.nonsing_inv_mul Q hu,Matrix.one_mul] + +theorem projection_to_center_identity (Q : Matrix n n K) (hdet : Q.det≠0) + (T : SelfAdjointIdempotent Q.toBilin') : + (T.val.toMatrix'*Q⁻¹)*Q*(T.val.toMatrix'*Q⁻¹)=T.val.toMatrix'*Q⁻¹ := by + have hi : T.val.toMatrix'*T.val.toMatrix'=T.val.toMatrix' := by + rw [←LinearMap.toMatrix'_comp] + exact congrArg LinearMap.toMatrix' T.property.1 + have hu : IsUnit Q.det := isUnit_iff_ne_zero.mpr hdet + rw [Matrix.mul_assoc _ Q⁻¹ Q,Matrix.nonsing_inv_mul Q hu,Matrix.mul_one, + ←Matrix.mul_assoc,hi] + +noncomputable def centerProjectionEquiv (Q : Matrix n n K) (hQ : Q.IsSymm) + (hdet : Q.det≠0) : CenterProjection Q ≃ SelfAdjointIdempotent Q.toBilin' where + toFun := centerToProjection Q hQ + invFun T := ⟨T.val.toMatrix'*Q⁻¹,projection_to_center_symmetric Q hQ hdet T, + projection_to_center_identity Q hdet T⟩ + left_inv A := by + apply Subtype.ext + change (A.val*Q).toLin'.toMatrix'*Q⁻¹=A.val + rw [LinearMap.toMatrix'_toLin',Matrix.mul_assoc,Matrix.mul_nonsing_inv Q + (isUnit_iff_ne_zero.mpr hdet),Matrix.mul_one] + right_inv T := by + apply Subtype.ext + change (T.val.toMatrix'*Q⁻¹*Q).toLin'=T.val + rw [Matrix.mul_assoc,Matrix.nonsing_inv_mul Q (isUnit_iff_ne_zero.mpr hdet),Matrix.mul_one, + Matrix.toLin'_toMatrix'] + +noncomputable def centerSubspaceEquiv (Q : Matrix n n K) (hQ : Q.IsSymm) + (hdet : Q.det≠0) : CenterProjection Q ≃ + {U : Submodule K (n → K) // (Q.toBilin'.restrict U).Nondegenerate} := + (centerProjectionEquiv Q hQ hdet).trans + (selfAdjointProjectionEquiv Q.toBilin' (Matrix.isSymm_toBilin'_iff_isSymm.mpr hQ) + (Matrix.nondegenerate_toBilin'_iff.mpr (Matrix.nondegenerate_iff_det_ne_zero.mpr hdet))) +end MatrixProjection +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module LinearMap +open scoped Matrix +section Range +variable {K n : Type*} [Field K] [Fintype n] [DecidableEq n] + +theorem matrix_toLin_surjective (Q : Matrix n n K) (hQ : Q.det≠0) : + Function.Surjective Q.toLin' := by + intro x + refine ⟨Q⁻¹.toLin' x,?_⟩ + change (Q.toLin'.comp Q⁻¹.toLin') x=x + rw [←Matrix.toLin'_mul,Matrix.mul_nonsing_inv Q (isUnit_iff_ne_zero.mpr hQ),Matrix.toLin'_one] + rfl + +theorem matrix_mul_range (A Q : Matrix n n K) (hQ : Q.det≠0) : + (A*Q).toLin'.range=A.toLin'.range := by + rw [Matrix.toLin'_mul,LinearMap.range_comp_of_range_eq_top _ + (LinearMap.range_eq_top.mpr (matrix_toLin_surjective Q hQ))] + +theorem centerSubspaceEquiv_val (Q : Matrix n n K) (hQ : Q.IsSymm) (hdet : Q.det≠0) + (A : CenterProjection Q) : (centerSubspaceEquiv Q hQ hdet A).val=A.val.toLin'.range := + matrix_mul_range A.val Q hdet + +theorem center_restriction_nondegenerate (Q A : Matrix n n K) (hQ : Q.IsSymm) + (hdet : Q.det≠0) (hA : A.IsSymm) (hi : A*Q*A=A) : + (Q.toBilin'.restrict A.toLin'.range).Nondegenerate := by + have h := (centerSubspaceEquiv Q hQ hdet ⟨A,hA,hi⟩).property + rw [centerSubspaceEquiv_val Q hQ hdet ⟨A,hA,hi⟩] at h + exact h + +theorem center_form_pullback (Q A : Matrix n n K) (hA : A.IsSymm) (hi : A*Q*A=A) : + (Q.toBilin'.restrict A.toLin'.range).compl₁₂ A.toLin'.rangeRestrict A.toLin'.rangeRestrict = + A.toBilin' := by + change Q.toBilin'.comp A.toLin' A.toLin' = _ + rw [Matrix.toBilin'_comp,hA,hi] + +theorem center_second_equation (Q R A : Matrix n n K) (hA : A.IsSymm) (hi : A*Q*A=A) : + A*R*A=A ↔ ((Q-R).toBilin'.restrict A.toLin'.range)=0 := by + have hp : (Q-R).toBilin'.comp A.toLin' A.toLin' = (A-A*R*A).toBilin' := by + rw [Matrix.toBilin'_comp,hA,mul_sub,sub_mul,hi] + constructor + · intro h + rw [h,sub_self,map_zero] at hp + apply LinearMap.ext + intro x + apply LinearMap.ext + intro y + obtain ⟨x0,hx⟩ := x.property + obtain ⟨y0,hy⟩ := y.property + change (Q-R).toBilin' x.val y.val=0 + rw [←hx,←hy] + exact congrArg (fun B : LinearMap.BilinForm K (n → K) => B x0 y0) hp + · intro h + have hz : (Q-R).toBilin'.comp A.toLin' A.toLin'=0 := by + apply LinearMap.ext + intro x + apply LinearMap.ext + intro y + exact congrArg (fun B : LinearMap.BilinForm K A.toLin'.range => + B (A.toLin'.rangeRestrict x) (A.toLin'.rangeRestrict y)) h + rw [hz] at hp + have he := Matrix.toBilin'.injective (hp.symm.trans (map_zero Matrix.toBilin').symm) + exact (sub_eq_zero.mp he).symm + +variable [Fintype K] [DecidableEq K] +theorem center_discriminant (Q A : Matrix n n K) (hQ : Q.IsSymm) (hdet : Q.det≠0) + (hA : A.IsSymm) (hi : A*Q*A=A) : + discriminantSign A.toBilin' (Matrix.isSymm_toBilin'_iff_isSymm.mpr hA) = + discriminantSign (Q.toBilin'.restrict A.toLin'.range) + ((Matrix.isSymm_toBilin'_iff_isSymm.mpr hQ).restrict _) := by + let f := A.toLin'.rangeRestrict + let B := Q.toBilin'.restrict A.toLin'.range + have hs : B.IsSymm := (Matrix.isSymm_toBilin'_iff_isSymm.mpr hQ).restrict _ + have hb : B.Nondegenerate := center_restriction_nondegenerate Q A hQ hdet hA hi + have h := discriminantSign_pullback B hs hb f A.toLin'.surjective_rangeRestrict + (Module.finBasis K A.toLin'.range) + rw [discriminantSign_nondegenerate B hs hb (Module.finBasis K A.toLin'.range)] + rw [←h] + congr 1 + exact (center_form_pullback Q A hA hi).symm +end Range +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module LinearMap +open scoped Matrix +section FormSum +variable {K V : Type*} [Field K] [Fintype K] [DecidableEq K] + [AddCommGroup V] [Module K V] [FiniteDimensional K V] + +theorem discriminantSign_complements (Q : LinearMap.BilinForm K V) (hs : Q.IsSymm) + (hQ : Q.Nondegenerate) (U W : Submodule K V) (hc : IsCompl U W) + (hU : (Q.restrict U).Nondegenerate) (hW : (Q.restrict W).Nondegenerate) + (ho : ∀ u : U, ∀ w : W, Q u.val w.val=0) : + discriminantSign Q hs = discriminantSign (Q.restrict U) (hs.restrict U) * + discriminantSign (Q.restrict W) (hs.restrict W) := by + have he := discriminantSign_isometry + (orthogonalSumForm (Q.restrict U) (Q.restrict W)) Q + (orthogonalSumForm_isSymm _ _ (hs.restrict U) (hs.restrict W)) hs + (orthogonalSumForm_nondegenerate _ _ hU hW) hQ (U.prodEquivOfIsCompl W hc) + (fun x y => by + simp only [Submodule.coe_prodEquivOfIsCompl',map_add,LinearMap.add_apply, + orthogonalSumForm_apply,LinearMap.BilinForm.restrict_apply,LinearMap.domRestrict_apply] + rw [ho x.1 y.2,hs.eq x.2.val y.1.val,ho y.1 x.2] + ring) + rw [discriminantSign_orthogonalSum _ _ _ _ hU hW] at he + exact he.symm +end FormSum +section Complement +variable {K n : Type*} [Field K] [Fintype n] [DecidableEq n] + +theorem center_complement_equation (B A : Matrix n n K) (hB : B.det≠0) + (hi : A*B⁻¹*A=A) : (B-A)*B⁻¹*(B-A)=B-A := by + have hu : IsUnit B.det := isUnit_iff_ne_zero.mpr hB + rw [sub_mul,Matrix.mul_nonsing_inv B hu,sub_mul,one_mul,mul_sub,hi, + Matrix.mul_assoc A B⁻¹ B,Matrix.nonsing_inv_mul B hu,Matrix.mul_one] + abel + +theorem center_complement_ranges (B A : Matrix n n K) (hB : B.det≠0) + (hi : A*B⁻¹*A=A) : IsCompl A.toLin'.range (B-A).toLin'.range := by + let T := (A*B⁻¹).toLin' + have ht := matrix_projection_idempotent B⁻¹ A hi + have hiB : B⁻¹.det≠0 := by simpa only [Matrix.det_nonsing_inv, Ring.inverse_eq_inv] using inv_ne_zero hB + have hr := matrix_mul_range A B⁻¹ hiB + have hc : (B-A).toLin'.range = T.ker := by + rw [ht.ker_eq_range,←matrix_mul_range (B-A) B⁻¹ hiB] + congr 1 + change ((B-A)*B⁻¹).toLin' = LinearMap.id-(A*B⁻¹).toLin' + rw [sub_mul,Matrix.mul_nonsing_inv B (isUnit_iff_ne_zero.mpr hB),map_sub,Matrix.toLin'_one] + rw [hc] + simpa only [T,hr] using (matrix_projection_idempotent B⁻¹ A hi).isCompl + +theorem center_complement_orthogonal (B A : Matrix n n K) (hB : B.det≠0) + (hA : A.IsSymm) (hi : A*B⁻¹*A=A) : + ∀ u : A.toLin'.range, ∀ w : (B-A).toLin'.range, B⁻¹.toBilin' u.val w.val=0 := by + have hp : B⁻¹.toBilin'.comp A.toLin' (B-A).toLin'=0 := by + rw [Matrix.toBilin'_comp,hA,mul_sub,hi, + Matrix.mul_assoc A B⁻¹ B,Matrix.nonsing_inv_mul B (isUnit_iff_ne_zero.mpr hB), + Matrix.mul_one,sub_self,map_zero] + intro u w + obtain ⟨x,hx⟩ := u.property + obtain ⟨y,hy⟩ := w.property + rw [←hx,←hy] + exact congrArg (fun Q : LinearMap.BilinForm K (n → K) => Q x y) hp +end Complement +section Signs +variable {K n : Type*} [Field K] [Fintype K] [DecidableEq K] [Fintype n] [DecidableEq n] + +theorem quadraticChar_inverse {a : K} (ha : a≠0) : quadraticChar K a⁻¹=quadraticChar K a := by + have hm : quadraticChar K a * quadraticChar K a⁻¹=1 := by + rw [←map_mul,mul_inv_cancel₀ ha,map_one] + rcases quadraticChar_dichotomy ha with h | h <;> rw [h] at hm ⊢ <;> linarith + +theorem center_complement_sign (B A : Matrix n n K) (hs : B.IsSymm) (hB : B.det≠0) + (hA : A.IsSymm) (hi : A*B⁻¹*A=A) : + quadraticChar K B.det = + discriminantSign A.toBilin' (Matrix.isSymm_toBilin'_iff_isSymm.mpr hA) * + discriminantSign (B-A).toBilin' (Matrix.isSymm_toBilin'_iff_isSymm.mpr (hs.sub hA)) := by + have hsQ : B⁻¹.IsSymm := hs.inv + have hnQ : B⁻¹.det≠0 := by simpa only [Matrix.det_nonsing_inv, Ring.inverse_eq_inv] using inv_ne_zero hB + have hiC := center_complement_equation B A hB hi + rw [center_discriminant B⁻¹ A hsQ hnQ hA hi, + center_discriminant B⁻¹ (B-A) hsQ hnQ (hs.sub hA) hiC] + rw [←discriminantSign_complements B⁻¹.toBilin' + (Matrix.isSymm_toBilin'_iff_isSymm.mpr hsQ) + (Matrix.nondegenerate_toBilin'_iff.mpr (Matrix.nondegenerate_iff_det_ne_zero.mpr hnQ)) + A.toLin'.range (B-A).toLin'.range (center_complement_ranges B A hB hi) + (center_restriction_nondegenerate B⁻¹ A hsQ hnQ hA hi) + (center_restriction_nondegenerate B⁻¹ (B-A) hsQ hnQ (hs.sub hA) hiC) + (center_complement_orthogonal B A hB hA hi)] + rw [discriminantSign_nondegenerate _ _ + (Matrix.nondegenerate_toBilin'_iff.mpr (Matrix.nondegenerate_iff_det_ne_zero.mpr hnQ)) + (Pi.basisFun K n)] + change quadraticChar K B.det = quadraticChar K (B⁻¹.toBilin'.toMatrix').det + rw [LinearMap.BilinForm.toMatrix'_toBilin',Matrix.det_nonsing_inv,Ring.inverse_eq_inv,quadraticChar_inverse hB] +end Signs +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section Split +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] +def dualKerEquiv (φ : V →ₗ[K] K) (x : V) (hx : φ x=1) : (φ.ker × K) ≃ₗ[K] V where + toFun p := p.1.val+p.2 • x + invFun y := (⟨y-φ y • x, by simp [LinearMap.mem_ker,hx]⟩,φ y) + left_inv p := by + apply Prod.ext + · apply Subtype.ext + simp only [map_add,map_smul,smul_eq_mul,hx,mul_one, + show φ p.1.val=0 from p.1.property,zero_add,add_sub_cancel_right] + · simp [hx] + right_inv y := by simp + map_add' p q := by simp only [Prod.fst_add,Prod.snd_add,Submodule.coe_add,add_smul]; abel + map_smul' a p := by simp only [Prod.smul_fst,Prod.smul_snd,Submodule.coe_smul, + smul_add,smul_smul,smul_eq_mul,RingHom.id_apply] +@[simp] theorem dualKerEquiv_apply (φ : V →ₗ[K] K) (x : V) (hx : φ x=1) + (p : φ.ker × K) : dualKerEquiv φ x hx p = p.1.val + p.2 • x := rfl + +def rankOneForm (φ : V →ₗ[K] K) : SymForm K V := + ⟨(LinearMap.mul K K).compl₁₂ φ φ, by constructor; intro x y; exact mul_comm _ _⟩ +@[simp] theorem rankOneForm_apply (φ : V →ₗ[K] K) (x y : V) : + (rankOneForm φ).val x y = φ x * φ y := rfl + +theorem dualKer_finrank [FiniteDimensional K V] (φ : V →ₗ[K] K) (x : V) (hx : φ x=1) : + finrank K φ.ker+1=finrank K V := by + have h := (dualKerEquiv φ x hx).finrank_eq + simpa only [Module.finrank_prod,Module.finrank_self] using h +end Split +section Signs +variable {K V : Type*} [Field K] [Fintype K] [DecidableEq K] + [AddCommGroup V] [Module K V] [FiniteDimensional K V] + +noncomputable def dualKerBasis (φ : V →ₗ[K] K) (x : V) (hx : φ x=1) + {ι : Type*} (b : Basis ι K φ.ker) : Basis (ι ⊕ PUnit.{1}) K V := + (b.prod (Basis.singleton PUnit.{1} K)).map (dualKerEquiv φ x hx) +omit [Fintype K] [DecidableEq K] [FiniteDimensional K V] in +@[simp] theorem dualKerBasis_inl (φ : V →ₗ[K] K) (x : V) (hx : φ x=1) + {ι : Type*} (b : Basis ι K φ.ker) (i : ι) : dualKerBasis φ x hx b (.inl i) = (b i).val := by + simp [dualKerBasis,Basis.prod_apply] +omit [Fintype K] [DecidableEq K] [FiniteDimensional K V] in +@[simp] theorem dualKerBasis_inr (φ : V →ₗ[K] K) (x : V) (hx : φ x=1) + {ι : Type*} (b : Basis ι K φ.ker) (i : PUnit.{1}) : dualKerBasis φ x hx b (.inr i) = x := by + simp [dualKerBasis,Basis.prod_apply] + +omit [Fintype K] [DecidableEq K] in +theorem rankOne_shift_matrix (φ : V →ₗ[K] K) (x : V) (hx : φ x=1) + (Q : SymForm K V) (a : K) : + (Q+a • rankOneForm φ).val.toMatrix (dualKerBasis φ x hx (Module.finBasis K φ.ker)) = + borderRaw ((symFormPull φ.ker.subtype Q).val.toMatrix (Module.finBasis K φ.ker)) + (fun i => Q.val (Module.finBasis K φ.ker i).val x) (Q.val x x+a) := by + ext i j + cases i with + | inl i => cases j with + | inl j => + simp only [LinearMap.BilinForm.toMatrix_apply,dualKerBasis_inl,borderRaw, + Matrix.fromBlocks_apply₁₁] + change Q.val _ _ + a * (φ (Module.finBasis K φ.ker i).val * φ (Module.finBasis K φ.ker j).val) = _ + rw [show φ (Module.finBasis K φ.ker i).val=0 from (Module.finBasis K φ.ker i).property] + simp only [zero_mul,mul_zero,add_zero]; rfl + | inr j => + simp only [LinearMap.BilinForm.toMatrix_apply,dualKerBasis_inl,dualKerBasis_inr,borderRaw, + Matrix.fromBlocks_apply₁₂,Matrix.of_apply] + change Q.val _ x+a*(φ (Module.finBasis K φ.ker i).val * φ x) = _ + rw [show φ (Module.finBasis K φ.ker i).val=0 from (Module.finBasis K φ.ker i).property] + simp + | inr i => cases j with + | inl j => + simp only [LinearMap.BilinForm.toMatrix_apply,dualKerBasis_inl,dualKerBasis_inr,borderRaw, + Matrix.fromBlocks_apply₂₁,Matrix.of_apply] + change Q.val x _+a*(φ x * φ (Module.finBasis K φ.ker j).val) = _ + rw [show φ (Module.finBasis K φ.ker j).val=0 from (Module.finBasis K φ.ker j).property] + simpa using Q.property.eq x (Module.finBasis K φ.ker j).val + | inr j => + simp only [LinearMap.BilinForm.toMatrix_apply,dualKerBasis_inr,borderRaw, + Matrix.fromBlocks_apply₂₂,Matrix.of_apply] + change Q.val x x+a*(φ x * φ x) = Q.val x x+a + rw [hx,one_mul,mul_one] + +theorem rankOne_shift_mean (φ : V →ₗ[K] K) (x : V) (hx : φ x=1) + (Q : SymForm K V) (hQ : (symFormPull φ.ker.subtype Q).val.Nondegenerate) + (hK : ringChar K ≠ 2) {ξ : ℤ} (hξ : ξ=1 ∨ ξ = -1) : + uniformMean (fun a : K => formSignIndicator ξ (Q+a • rankOneForm φ)) = + (1-1/(Fintype.card K : ℝ))/2 := by + let b := Module.finBasis K φ.ker + let M : SymMatrix K (finrank K φ.ker) := ⟨(symFormPull φ.ker.subtype Q).val.toMatrix b, + ((symFormPull φ.ker.subtype Q).val.isSymm_toMatrix_iff_isSymm b).mpr + (symFormPull φ.ker.subtype Q).property⟩ + let z : Fin (finrank K φ.ker) → K := fun i => Q.val (b i).val x + have hM : M.val.det ≠ 0 := (LinearMap.BilinForm.nondegenerate_iff_det_ne_zero b).mp hQ + have he (a : K) : formSignIndicator ξ (Q+a • rankOneForm φ) = + characterSignIndicator ξ (M.val.det * (a- (z ⬝ᵥ (M.val⁻¹.mulVec z)-Q.val x x))) := by + rw [formSignIndicator_matrix (dualKerBasis φ x hx b) hξ,rankOne_shift_matrix] + have hd : (borderRaw M.val z (Q.val x x+a)).det = + (symmetricBorder M z (Q.val x x+a)).val.det := by + symm; exact Matrix.det_submatrix_equiv_self _ _ + rw [show (symFormPull φ.ker.subtype Q).val.toMatrix (Module.finBasis K φ.ker)=M.val from rfl, + show (fun i => Q.val (Module.finBasis K φ.ker i).val x)=z from rfl,hd, + symmetricBorder_det M z _ hM] + congr 2; ring + rw [uniformMean_congr he,uniformMean_affine _ _ hM,uniformMean_characterSignIndicator hK hξ] +end Signs +end SidorenkoCounterexample + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/RandomHost.lean b/lean/OAI/Combinatorics/Sidorenko/RandomHost.lean new file mode 100644 index 0000000000000000000000000000000000000000..c16e57e543789f938f972004f47ce3c5f6cf3d29 --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/RandomHost.lean @@ -0,0 +1,325 @@ +import OAI.Combinatorics.Sidorenko.Symmetrization + +namespace OAI + +/-! # Sampling a finite simple counterexample + +The strict kernel inequality survives independent random sampling at sufficiently +large finite size. Homomorphism counts include noninjective maps, whose collision +error is bounded separately. The resulting simple graph has at least one edge. +-/ + +section + +namespace SidorenkoCounterexample +open Classical +open scoped BigOperators +namespace FiniteLaw +variable {I A : Type*} [Fintype I] [DecidableEq I] [Fintype A] +lemma independent_mean_unit (p : FiniteLaw A) (f : A → ℝ) : + (independent (fun _ : Unit => p)).mean (fun x => f (x ()))=p.mean f := by + unfold mean independent + apply Fintype.sum_equiv (Equiv.funUnique Unit A) + intro x + simp only [Fintype.prod_unique]; rfl +lemma independent_mean_apply (p : I → FiniteLaw A) (i : I) (f : A → ℝ) : + (independent p).mean (fun x => f (x i))=(p i).mean f := by + have h := independent_mean_injective p (fun _ : Unit => i) (fun _ _ _ => Subsingleton.elim _ _) + (fun x => f (x ())) + exact h.trans (independent_mean_unit (p i) f) +lemma independent_mean_two (p : FiniteLaw A) {i j : I} (hij : i≠j) (f : A → A → ℝ) : + (independent (fun _ : I => p)).mean (fun x => f (x i) (x j))=p.mean (fun a => p.mean (f a)) := by + let e : Unit ⊕ Unit → I := Sum.elim (fun _ => i) (fun _ => j) + have he : Function.Injective e := by + intro x y h + cases x <;> cases y + · rfl + · exact (hij h).elim + · exact (hij h.symm).elim + · rfl + have h := independent_mean_injective (fun _ : I => p) e he + (fun x => f (x (.inl ())) (x (.inr ()))) + dsimp [e] at h + rw [h,independent_mean_sum] + change (independent (fun _ : Unit => p)).mean (fun x => + (independent (fun _ : Unit => p)).mean (fun y => f (x ()) (y ())))=_ + simp_rw [independent_mean_unit] + exact independent_mean_unit p (fun a => p.mean (f a)) +lemma uniform_mean_equal [Nonempty A] : + (uniform : FiniteLaw A).mean (fun a => uniform.mean (fun b => if a=b then (1:ℝ) else 0))= + (Fintype.card A : ℝ)⁻¹ := by + have hi (a : A) : (uniform : FiniteLaw A).mean (fun b => if a=b then (1:ℝ) else 0)=(Fintype.card A : ℝ)⁻¹ := by + simp [mean,uniform] + simp only [hi,mean_const] +noncomputable def coin (t : ℝ) (ht : 0≤t) (ht1 : t≤1) : FiniteLaw Bool := + mixture (dirac true) (dirac false) t ht ht1 +noncomputable def boolValue (b : Bool) : ℝ := if b then 1 else 0 +lemma boolValue_nonneg (b : Bool) : 0≤boolValue b := by cases b <;> norm_num [boolValue] +lemma boolValue_le_one (b : Bool) : boolValue b≤1 := by cases b <;> norm_num [boolValue] +lemma coin_mean (t : ℝ) (ht : 0≤t) (ht1 : t≤1) : (coin t ht ht1).mean boolValue=t := by + simp [coin,mean_mixture,boolValue] +end FiniteLaw +section Sample +variable {V : Type*} [Fintype V] [DecidableEq V] +def bitsGraph (b : Sym2 V → Bool) : SimpleGraph V where + Adj x y := x≠y ∧ b s(x,y)=true + symm.symm := by intro x y h; exact ⟨h.1.symm,by simpa only [Sym2.eq_swap] using h.2⟩ + loopless.irrefl := by intro x h; exact h.1 rfl +omit [Fintype V] in +lemma bitsGraph_edgeIndicator (b : Sym2 V → Bool) (x y : V) : + edgeIndicator (bitsGraph b) x y=if x=y then 0 else FiniteLaw.boolValue (b s(x,y)) := by + by_cases h : x=y <;> simp [edgeIndicator,bitsGraph,FiniteLaw.boolValue,h] +noncomputable def edgeCoinLaw (U : SymmetricCounterKernel) (z : V → U.Ω) : FiniteLaw (Sym2 V → Bool) := + FiniteLaw.independent (fun e => FiniteLaw.coin + (Sym2.lift ⟨fun a b => U.value (z a) (z b),fun a b => U.symm (z a) (z b)⟩ e) + (by induction e using Sym2.inductionOn; exact U.nonneg _ _) + (by induction e using Sym2.inductionOn; exact U.le_one _ _)) +lemma edgeCoinLaw_mean (U : SymmetricCounterKernel) (z : V → U.Ω) (x y : V) : + (edgeCoinLaw U z).mean (fun b => edgeIndicator (bitsGraph b) x y)= + if x=y then 0 else U.value (z x) (z y) := by + simp only [bitsGraph_edgeIndicator] + by_cases h : x=y + · simp [h] + · simp only [h,ite_false,edgeCoinLaw] + rw [FiniteLaw.independent_mean_apply,FiniteLaw.coin_mean]; rfl +end Sample +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Classical +open scoped BigOperators +def cornerEdge (k : ActCorner) : Sym2 PatternVertex := s(Sum.inl (cornerPoint k),Sum.inr k.1) +lemma cornerEdge_injective : Function.Injective cornerEdge := by + rintro ⟨j,r⟩ ⟨j',r'⟩ h + simp only [cornerEdge,cornerPoint,Sym2.eq_iff,Sum.inl.injEq,Sum.inr.injEq, + Sum.inl_ne_inr,Sum.inr_ne_inl,and_false,or_false] at h + obtain ⟨h,hj⟩ := h + subst j' + exact congrArg (Prod.mk j) (faceVertex_injective j h) +section Random +variable {V : Type*} [Fintype V] [DecidableEq V] +omit [Fintype V] [DecidableEq V] in +lemma mappedCorner_injective (f : PatternVertex → V) (hf : Function.Injective f) : + Function.Injective (fun k : ActCorner => s(f (.inl (cornerPoint k)),f (.inr k.1))) := + (Sym2.map.injective hf).comp cornerEdge_injective +omit [Fintype V] [DecidableEq V] in +lemma mappedCorner_ne (f : PatternVertex → V) (hf : Function.Injective f) (k : ActCorner) : + f (.inl (cornerPoint k))≠f (.inr k.1) := by + intro h; have hc := hf h; cases hc +lemma expectedHom_conditional (U : SymmetricCounterKernel) (z : V → U.Ω) + (f : PatternVertex → V) (hf : Function.Injective f) : + (edgeCoinLaw U z).mean (fun b => homIndicator (bitsGraph b) f)= + ∏ k : ActCorner,U.value (z (f (.inl (cornerPoint k)))) (z (f (.inr k.1))) := by + simp only [homIndicator,bitsGraph_edgeIndicator,mappedCorner_ne f hf,ite_false] + unfold edgeCoinLaw + rw [FiniteLaw.independent_mean_injective _ _ (mappedCorner_injective f hf) + (fun b => ∏ k : ActCorner,FiniteLaw.boolValue (b k))] + rw [FiniteLaw.independent_mean_product] + apply Finset.prod_congr rfl; intro k _ + rw [FiniteLaw.coin_mean]; rfl +noncomputable def hostBitsLaw (U : SymmetricCounterKernel) : FiniteLaw (Sym2 V → Bool) := + (FiniteLaw.independent (fun _ : V => U.law)).bind (edgeCoinLaw U) +lemma expectedHom_injective (U : SymmetricCounterKernel) (f : PatternVertex → V) (hf : Function.Injective f) : + (hostBitsLaw U).mean (fun b => homIndicator (bitsGraph b) f)=bipartiteMoment U.law U.law U.value := by + rw [hostBitsLaw,FiniteLaw.mean_bind] + simp_rw [expectedHom_conditional U _ f hf] + rw [FiniteLaw.independent_mean_injective _ _ hf (fun z => + ∏ k : ActCorner,U.value (z (.inl (cornerPoint k))) (z (.inr k.1)))] + exact sourceMoment_eq_bipartite U.law U.value +lemma expectedEdge (U : SymmetricCounterKernel) (x y : V) : + (hostBitsLaw U).mean (fun b => edgeIndicator (bitsGraph b) x y)= + if x=y then 0 else kernelMean U.law U.law U.value := by + rw [hostBitsLaw,FiniteLaw.mean_bind] + simp_rw [edgeCoinLaw_mean] + by_cases h : x=y + · simp only [h,ite_true,FiniteLaw.mean_const] + · simp only [h,ite_false] + exact FiniteLaw.independent_mean_two U.law h U.value +lemma expectedHom_nonneg (U : SymmetricCounterKernel) (f : PatternVertex → V) : + 0≤(hostBitsLaw U).mean (fun b => homIndicator (bitsGraph b) f) := + FiniteLaw.mean_nonneg _ (fun _b => homIndicator_nonneg _ _) +lemma expectedHom_le_one (U : SymmetricCounterKernel) (f : PatternVertex → V) : + (hostBitsLaw U).mean (fun b => homIndicator (bitsGraph b) f)≤1 := + FiniteLaw.mean_bound _ (fun _b => homIndicator_le_one _ _) +end Random +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Classical +open scoped BigOperators +abbrev CollisionPair := {ab : Fin 35 × Fin 35 // ab.1 norm_num +noncomputable def noninjectiveIndicator {V : Type*} (f : PatternVertex → V) : ℝ := + if Function.Injective f then 0 else 1 +lemma noninjective_le_collisionSum {V : Type*} (f : PatternVertex → V) : + noninjectiveIndicator f≤∑ p : CollisionPair,collisionValue p f := by + unfold noninjectiveIndicator + by_cases hf : Function.Injective f + · simp only [hf,ite_true]; exact Finset.sum_nonneg (fun p _ => collisionValue_nonneg p f) + · rw [ite_eq_right hf] + have hm : ∃ p : CollisionPair,f (sourceFinEquiv.symm p.1.1)=f (sourceFinEquiv.symm p.1.2) := by + simp only [Function.Injective,not_forall] at hf + obtain ⟨a,b,hfab,hne⟩ := hf + rcases lt_or_gt_of_ne (fun h => hne (sourceFinEquiv.injective h)) with h|h + · exact ⟨⟨(sourceFinEquiv a,sourceFinEquiv b),h⟩,by simpa using hfab⟩ + · exact ⟨⟨(sourceFinEquiv b,sourceFinEquiv a),h⟩,by simpa using hfab.symm⟩ + obtain ⟨p,hp⟩ := hm + calc + 1 = collisionValue p f := by simp [collisionValue,hp] + _ ≤ _ := Finset.single_le_sum (fun q _ => collisionValue_nonneg q f) (Finset.mem_univ p) +lemma collisionPair_ne (p : CollisionPair) : sourceFinEquiv.symm p.1.1≠sourceFinEquiv.symm p.1.2 := + fun h => (ne_of_lt p.2) (sourceFinEquiv.symm.injective h) +lemma collisionValue_mean {V : Type*} [Fintype V] [Nonempty V] (p : CollisionPair) : + (FiniteLaw.independent (fun _ : PatternVertex => (FiniteLaw.uniform : FiniteLaw V))).mean (collisionValue p)= + (Fintype.card V : ℝ)⁻¹ := by + unfold collisionValue + rw [FiniteLaw.independent_mean_two FiniteLaw.uniform (collisionPair_ne p) (fun a b : V => if a=b then (1:ℝ) else 0)] + exact FiniteLaw.uniform_mean_equal +lemma noninjective_mean_bound {V : Type*} [Fintype V] [Nonempty V] : + (FiniteLaw.independent (fun _ : PatternVertex => (FiniteLaw.uniform : FiniteLaw V))).mean + noninjectiveIndicator≤595/(Fintype.card V : ℝ) := by + calc + _ ≤ (FiniteLaw.independent (fun _ : PatternVertex => (FiniteLaw.uniform : FiniteLaw V))).mean + (fun f => ∑ p : CollisionPair,collisionValue p f) := FiniteLaw.mean_mono _ noninjective_le_collisionSum + _ = _ := by + rw [FiniteLaw.mean_sum] + simp only [collisionValue_mean,Finset.sum_const,Finset.card_univ,collisionPair_card,nsmul_eq_mul] + norm_num [div_eq_mul_inv] +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Classical +open scoped BigOperators +section Bounds +variable {V : Type*} [Fintype V] [DecidableEq V] [Nonempty V] +lemma uniformMean_offdiag (c : ℝ) : + uniformMean (fun ab : V × V => if ab.1=ab.2 then 0 else c)=(1-(Fintype.card V : ℝ)⁻¹)*c := by + rw [uniformMean_prod] + have hi (a : V) : uniformMean (fun b : V => if a=b then 0 else c)=(1-(Fintype.card V : ℝ)⁻¹)*c := by + calc + _ = uniformMean (fun b : V => c-c*(if a=b then (1:ℝ) else 0)) := by + apply uniformMean_congr; intro b; split <;> simp_all + _ = _ := by + rw [uniformMean_sub,uniformMean_const,uniformMean_mul] + simp [uniformMean]; ring + simp only [hi,uniformMean_const] +lemma expectedEdgeDensity (U : SymmetricCounterKernel) : + (hostBitsLaw U).mean (fun b : Sym2 V → Bool => edgeDensity (bitsGraph b))= + (1-(Fintype.card V : ℝ)⁻¹)*kernelMean U.law U.law U.value := by + simp_rw [edgeDensity_eq_mean] + rw [←uniformMean_law_swap] + simp_rw [expectedEdge] + exact uniformMean_offdiag _ +omit [Nonempty V] in +lemma expectedHom_map_bound (U : SymmetricCounterKernel) (f : PatternVertex → V) : + (hostBitsLaw U).mean (fun b => homIndicator (bitsGraph b) f)≤ + bipartiteMoment U.law U.law U.value+noninjectiveIndicator f := by + unfold noninjectiveIndicator + by_cases hf : Function.Injective f + · rw [ite_eq_left hf,add_zero,expectedHom_injective U f hf] + · rw [ite_eq_right hf] + have hτ := bipartiteMoment_nonneg U.law U.law U.value U.nonneg + exact (expectedHom_le_one U f).trans (by linarith) +lemma expectedHomDensity_bound (U : SymmetricCounterKernel) : + (hostBitsLaw U).mean (fun b : Sym2 V → Bool => homDensity H (bitsGraph b))≤ + bipartiteMoment U.law U.law U.value+595/(Fintype.card V : ℝ) := by + simp_rw [homDensity_eq_mean] + rw [←uniformMean_law_swap,←FiniteLaw.independent_uniform_mean] + calc + _ ≤ (FiniteLaw.independent (fun _ : PatternVertex => (FiniteLaw.uniform : FiniteLaw V))).mean + (fun f => bipartiteMoment U.law U.law U.value+noninjectiveIndicator f) := + FiniteLaw.mean_mono _ (expectedHom_map_bound U) + _ = bipartiteMoment U.law U.law U.value+ + (FiniteLaw.independent (fun _ : PatternVertex => (FiniteLaw.uniform : FiniteLaw V))).mean + noninjectiveIndicator := by rw [FiniteLaw.mean_add,FiniteLaw.mean_const] + _ ≤ _ := add_le_add le_rfl (noninjective_mean_bound (V := V)) +end Bounds +lemma finiteHost_arithmetic {μ τ : ℝ} (hμ : 0≤μ) (hgap : τ<μ^66) {n : ℕ} (hn : 0 homDensity H (bitsGraph b))< + ((hostBitsLaw U).mean (fun b : Sym2 (Fin n) → Bool => edgeDensity (bitsGraph b)))^66 := by + rw [expectedEdgeDensity,Fintype.card_fin] + exact (expectedHomDensity_bound U).trans_lt (by simpa only [Fintype.card_fin,one_div] using hmean) + have hj := FiniteLaw.mean_pow_le (hostBitsLaw U) + (fun b : Sym2 (Fin n) → Bool => edgeDensity (bitsGraph b)) (fun _b => edgeDensity_nonneg _) 66 + obtain ⟨b,hb⟩ := FiniteLaw.exists_lt_of_mean_lt (hostBitsLaw U) (hexp.trans_le hj) + refine ⟨bitsGraph b,?_,hb⟩ + by_contra h + push Not at h + rw [edgeDensity_eq_zero_of_edgeless _ h,zero_pow (by decide : 66≠0)] at hb + exact (not_lt_of_ge (homDensity_nonneg _)) hb +lemma finiteHost_main (U : SymmetricCounterKernel) : MainClaim := by + obtain ⟨n,hn⟩ := exists_nat_gt (max 0 ((595+66*(kernelMean U.law U.law U.value)^66)/ + ((kernelMean U.law U.law U.value)^66-bipartiteMoment U.law U.law U.value))) + have hnpos : 0 exact ha x.val + +theorem symplecticReductionForm_nondegenerate [FiniteDimensional K E] + (ha : ω.IsAlt) (hω : ω.Nondegenerate) : + (symplecticReductionForm ω S ha).Nondegenerate := by + have hl (x : ReducedSpace ω S) + (hx : ∀ y, symplecticReductionForm ω S ha x y = 0) : x = 0 := by + induction x using Submodule.Quotient.induction_on with + | H x => + apply (Submodule.Quotient.mk_eq_zero (reductionKernel ω S)).mpr + change x.val ∈ S + apply (ω.orthogonal_orthogonal hω ha.isRefl S).le + intro y hy + exact ha.isRefl _ _ (hx ((reductionKernel ω S).mkQ ⟨y,hy⟩)) + refine ⟨hl, ?_⟩ + intro x hx + apply hl + intro y + exact (symplecticReductionForm_alt ω S ha).isRefl _ _ (hx y) + +theorem reducedSpace_finrank [FiniteDimensional K E] + (hω : ω.Nondegenerate) (hS : S ≤ ω.orthogonal S) : + finrank K (ReducedSpace ω S) + 2 * finrank K S = finrank K E := by + have hker : finrank K (reductionKernel ω S) = finrank K S := + (Submodule.comapSubtypeEquivOfLe hS).finrank_eq + have hq := Submodule.finrank_quotient_add_finrank (reductionKernel ω S) + have hp := ω.finrank_orthogonal hω S + have hle := Submodule.finrank_le S + change finrank K (ReducedSpace ω S) + finrank K (reductionKernel ω S) = + finrank K (ω.orthogonal S) at hq + rw [hker] at hq + omega + + +def liftReduction (T : Submodule K (ReducedSpace ω S)) : Submodule K E := + (T.comap (reductionKernel ω S).mkQ).map (ω.orthogonal S).subtype + +@[simp] theorem mem_liftReduction (T : Submodule K (ReducedSpace ω S)) (x : E) : + x ∈ liftReduction ω S T ↔ ∃ hx : x ∈ ω.orthogonal S, + (reductionKernel ω S).mkQ ⟨x,hx⟩ ∈ T := by + constructor + · rintro ⟨y,hy,hx⟩ + cases hx + exact ⟨y.property,hy⟩ + · rintro ⟨hx,ht⟩ + exact ⟨⟨x,hx⟩,ht,rfl⟩ + +theorem le_liftReduction (hS : S ≤ ω.orthogonal S) + (T : Submodule K (ReducedSpace ω S)) : S ≤ liftReduction ω S T := by + intro x hx + apply (mem_liftReduction ω S T x).mpr + refine ⟨hS hx, ?_⟩ + have hz : (reductionKernel ω S).mkQ ⟨x,hS hx⟩ = 0 := + (Submodule.Quotient.mk_eq_zero (reductionKernel ω S)).mpr hx + rw [hz] + exact T.zero_mem + +theorem liftReduction_le (T : Submodule K (ReducedSpace ω S)) : + liftReduction ω S T ≤ ω.orthogonal S := by + rintro x ⟨y,hy,rfl⟩ + exact y.property + +/-- Orthogonality commutes exactly with lifting from an isotropic quotient. -/ +theorem orthogonal_liftReduction (ha : ω.IsAlt) (hS : S ≤ ω.orthogonal S) + (T : Submodule K (ReducedSpace ω S)) : + ω.orthogonal (liftReduction ω S T) = + liftReduction ω S ((symplecticReductionForm ω S ha).orthogonal T) := by + ext x + constructor + · intro hx + have hxP : x ∈ ω.orthogonal S := by + intro s hs + exact hx s (le_liftReduction ω S hS T hs) + apply (mem_liftReduction ω S _ x).mpr + refine ⟨hxP, ?_⟩ + intro y hy + induction y using Submodule.Quotient.induction_on with + | H y => + exact hx y.val ((mem_liftReduction ω S T y.val).mpr ⟨y.property,hy⟩) + · intro hx + obtain ⟨hxP,hxQ⟩ := (mem_liftReduction ω S _ x).mp hx + intro y hy + obtain ⟨hyP,hyQ⟩ := (mem_liftReduction ω S T y).mp hy + exact hxQ ((reductionKernel ω S).mkQ ⟨y,hyP⟩) hyQ + +/-- Thus every quotient Lagrangian lifts to a Lagrangian containing S. -/ +theorem liftReduction_lagrangian (ha : ω.IsAlt) (hS : S ≤ ω.orthogonal S) + (T : Submodule K (ReducedSpace ω S)) + (hT : (symplecticReductionForm ω S ha).orthogonal T = T) : + ω.orthogonal (liftReduction ω S T) = liftReduction ω S T := by + rw [orthogonal_liftReduction ω S ha hS, hT] + +/-- The image of a subspace intersected with Sᗮ in the quotient. -/ +def reduceSubspace (L : Submodule K E) : Submodule K (ReducedSpace ω S) := + (L.comap (ω.orthogonal S).subtype).map (reductionKernel ω S).mkQ + +theorem reduce_lift (T : Submodule K (ReducedSpace ω S)) : + reduceSubspace ω S (liftReduction ω S T) = T := by + ext z + induction z using Submodule.Quotient.induction_on with + | H z => + constructor + · rintro ⟨y,hy,heq⟩ + obtain ⟨hyP,hyT⟩ := (mem_liftReduction ω S T y.val).mp hy + change (reductionKernel ω S).mkQ y ∈ T at hyT + exact heq ▸ hyT + · intro hz + refine ⟨z,?_,rfl⟩ + exact (mem_liftReduction ω S T z.val).mpr ⟨z.property,hz⟩ + +theorem liftReduction_injective : Function.Injective (liftReduction ω S) := by + intro T U h + have hh := congrArg (reduceSubspace ω S) h + simpa only [reduce_lift] using hh + +theorem lift_reduce (L : Submodule K E) (hSL : S ≤ L) (hLP : L ≤ ω.orthogonal S) : + liftReduction ω S (reduceSubspace ω S L) = L := by + ext x + constructor + · intro hx + obtain ⟨hxP,y,hy,hyeq⟩ := (mem_liftReduction ω S _ x).mp hx + have hz : (reductionKernel ω S).mkQ (y - ⟨x,hxP⟩) = 0 := by + rw [map_sub,hyeq,sub_self] + have hzS : y.val-x ∈ S := (Submodule.Quotient.mk_eq_zero (reductionKernel ω S)).mp hz + have hxL := L.sub_mem hy (hSL hzS) + simpa only [Submodule.subtype_apply, sub_sub_cancel] using hxL + · intro hx + apply (mem_liftReduction ω S _ x).mpr + exact ⟨hLP hx,⟨⟨x,hLP hx⟩,hx,rfl⟩⟩ + +theorem lagrangian_le_orthogonal (L : Submodule K E) + (hL : ω.orthogonal L = L) (hSL : S ≤ L) : L ≤ ω.orthogonal S := by + intro x hx s hs + have hxO : x ∈ ω.orthogonal L := hL.symm ▸ hx + exact hxO s (hSL hs) + +theorem reduce_lagrangian (ha : ω.IsAlt) (hS : S ≤ ω.orthogonal S) + (L : Submodule K E) (hL : ω.orthogonal L = L) (hSL : S ≤ L) : + (symplecticReductionForm ω S ha).orthogonal (reduceSubspace ω S L) = + reduceSubspace ω S L := by + apply liftReduction_injective ω S + rw [← orthogonal_liftReduction ω S ha hS, + lift_reduce ω S L hSL (lagrangian_le_orthogonal ω S L hL hSL),hL] + + + +def containingLagrangianEquiv (ha : ω.IsAlt) (hS : S ≤ ω.orthogonal S) : + {L : Submodule K E // ω.orthogonal L = L ∧ S ≤ L} ≃ + {T : Submodule K (ReducedSpace ω S) // (symplecticReductionForm ω S ha).orthogonal T = T} where + toFun L := ⟨reduceSubspace ω S L.val,reduce_lagrangian ω S ha hS L.val L.property.1 L.property.2⟩ + invFun T := ⟨liftReduction ω S T.val, + liftReduction_lagrangian ω S ha hS T.val T.property,le_liftReduction ω S hS T.val⟩ + left_inv L := Subtype.ext (lift_reduce ω S L.val L.property.2 + (lagrangian_le_orthogonal ω S L.val L.property.1 L.property.2)) + right_inv T := Subtype.ext (reduce_lift ω S T.val) + +theorem orthogonal_sup_eq (U W : Submodule K E) : + ω.orthogonal (U ⊔ W) = ω.orthogonal U ⊓ ω.orthogonal W := by + ext x + constructor + · intro hx + exact ⟨fun y hy => hx y ((le_sup_left : U ≤ U ⊔ W) hy), fun y hy => hx y ((le_sup_right : W ≤ U ⊔ W) hy)⟩ + · rintro ⟨hU,hW⟩ y hy + obtain ⟨u,hu,w,hw,rfl⟩ := Submodule.mem_sup.mp hy + simp only [map_add,LinearMap.add_apply,hU u hu,hW w hw,add_zero] + +theorem orthogonal_inf_eq [FiniteDimensional K E] (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (U W : Submodule K E) : + ω.orthogonal (U ⊓ W) = ω.orthogonal U ⊔ ω.orthogonal W := by + have hinj : Function.Injective ω.orthogonal := by + intro A B h + have hh := congrArg ω.orthogonal h + simpa only [ω.orthogonal_orthogonal hω ha.isRefl] using hh + apply hinj + rw [ω.orthogonal_orthogonal hω ha.isRefl, orthogonal_sup_eq, + ω.orthogonal_orthogonal hω ha.isRefl,ω.orthogonal_orthogonal hω ha.isRefl] + +/-- Every Lagrangian has a Lagrangian reduction, even when it does not contain +or avoid the isotropic space S. -/ +theorem general_lagrangian_reduction [FiniteDimensional K E] + (ha : ω.IsAlt) (hω : ω.Nondegenerate) (hS : S ≤ ω.orthogonal S) + (L : Submodule K E) (hL : ω.orthogonal L = L) : + (symplecticReductionForm ω S ha).orthogonal (reduceSubspace ω S L) = + reduceSubspace ω S L := by + let U := (L ⊓ ω.orthogonal S) ⊔ S + have hUL : ω.orthogonal U = U := by + dsimp only [U] + rw [orthogonal_sup_eq, orthogonal_inf_eq ω ha hω, hL, + ω.orthogonal_orthogonal hω ha.isRefl] + apply le_antisymm + · rintro x ⟨hx,hxP⟩ + obtain ⟨l,hl,s,hs,rfl⟩ := Submodule.mem_sup.mp hx + have hlP : l ∈ ω.orthogonal S := by + have h := (ω.orthogonal S).sub_mem hxP (hS hs) + simpa only [add_sub_cancel_right] using h + exact Submodule.mem_sup.mpr ⟨l,⟨hl,hlP⟩,s,hs,rfl⟩ + · rintro x hx + obtain ⟨l,hl,s,hs,rfl⟩ := Submodule.mem_sup.mp hx + exact ⟨Submodule.mem_sup.mpr ⟨l,hl.1,s,hs,rfl⟩, + (ω.orthogonal S).add_mem hl.2 (hS hs)⟩ + have hUred : reduceSubspace ω S U = reduceSubspace ω S L := by + ext x + constructor + · rintro ⟨y,hy,rfl⟩ + obtain ⟨l,hl,s,hs,hls⟩ := Submodule.mem_sup.mp hy + refine ⟨⟨l,hl.2⟩,hl.1,?_⟩ + have hz : (reductionKernel ω S).mkQ ⟨s,hS hs⟩ = 0 := + (Submodule.Quotient.mk_eq_zero (reductionKernel ω S)).mpr hs + have heq : y = (⟨l,hl.2⟩ : ω.orthogonal S) + ⟨s,hS hs⟩ := + Subtype.ext hls.symm + rw [heq,map_add,hz,add_zero] + · rintro ⟨y,hy,rfl⟩ + exact ⟨y,(le_sup_left : L ⊓ ω.orthogonal S ≤ U) ⟨hy,y.property⟩,rfl⟩ + rw [← hUred] + exact reduce_lagrangian ω S ha hS U hUL le_sup_right + +end Reduction +section IsotropicExtension +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] [Finite E] +variable (ω : LinearMap.BilinForm K E) + +omit [Finite E] in +theorem isotropic_sup_line (ha : ω.IsAlt) (L : Submodule K E) + (hL : L ≤ ω.orthogonal L) (x : E) (hx : x ∈ ω.orthogonal L) : + L ⊔ K ∙ x ≤ ω.orthogonal (L ⊔ K ∙ x) := by + intro y hy z hz + obtain ⟨l,hl,v,hv,rfl⟩ := Submodule.mem_sup.mp hy + obtain ⟨m,hm,w,hw,rfl⟩ := Submodule.mem_sup.mp hz + obtain ⟨a,rfl⟩ := Submodule.mem_span_singleton.mp hv + obtain ⟨b,rfl⟩ := Submodule.mem_span_singleton.mp hw + have hxl : ω x l = 0 := ha.isRefl _ _ (hx l hl) + simp only [map_add,map_smul,LinearMap.add_apply,LinearMap.smul_apply, + hL hl m hm,hx m hm,hxl,ha x,smul_zero,add_zero] + +/-- Finite-dimensional finite-field spaces admit Lagrangian extensions of +all isotropic spaces; no completion or existence axiom is used. -/ +theorem exists_containing_lagrangian (ha : ω.IsAlt) (S : Submodule K E) + (hS : S ≤ ω.orthogonal S) : + ∃ L : Submodule K E, S ≤ L ∧ ω.orthogonal L = L := by + classical + let A : Set (Submodule K E) := {L | S ≤ L ∧ L ≤ ω.orthogonal L} + obtain ⟨L,hL,hmax⟩ := (Set.toFinite A).exists_maximal ⟨S,le_rfl,hS⟩ + refine ⟨L,hL.1,le_antisymm ?_ hL.2⟩ + intro x hx + have hU : (L ⊔ K ∙ x) ∈ A := + ⟨hL.1.trans le_sup_left,isotropic_sup_line ω ha L hL.2 x hx⟩ + exact hmax hU le_sup_left ((le_sup_right : K ∙ x ≤ L ⊔ K ∙ x) (Submodule.mem_span_singleton_self x)) + +end IsotropicExtension +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section QuotientExtension +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] +variable [FiniteDimensional K E] +variable (ω : LinearMap.BilinForm K E) (S : Submodule K E) + +omit [FiniteDimensional K E] in +/-- The form splits as an orthogonal direct sum along a nondegenerate subspace. -/ +theorem form_orthogonal_sum (ha : ω.IsAlt) (U : Submodule K E) + (x y : U × ω.orthogonal U) : + ω (x.1.val + x.2.val) (y.1.val + y.2.val) = + ω x.1.val y.1.val + ω x.2.val y.2.val := by + have hxy : ω x.1.val y.2.val = 0 := y.2.property x.1.val x.1.property + have hyx : ω x.2.val y.1.val = 0 := + ha.isRefl _ _ (x.2.property y.1.val y.1.property) + simp only [map_add, LinearMap.add_apply, hxy, hyx, add_zero, zero_add] + +/-- An isometry of a nondegenerate subspace extends by identity on its +orthogonal complement. This avoids any symplectic-basis assumptions. -/ +theorem exists_orthogonal_extension (ha : ω.IsAlt) (U : Submodule K E) + (hU : (ω.restrict U).Nondegenerate) (f : U ≃ₗ[K] U) + (hf : ∀ x y : U, ω (f x).val (f y).val = ω x.val y.val) : + ∃ e : E ≃ₗ[K] E, + (∀ x y, ω (e x) (e y) = ω x y) ∧ + (∀ x : U, e x.val = (f x).val) ∧ + (∀ x : ω.orthogonal U, e x.val = x.val) := by + let c := U.prodEquivOfIsCompl (ω.orthogonal U) + (ω.isCompl_orthogonal_of_restrict_nondegenerate ha.isRefl hU) + let e := c.symm.trans ((f.prodCongr (LinearEquiv.refl K (ω.orthogonal U))).trans c) + have he (x : U × ω.orthogonal U) : e (c x) = c (f x.1,x.2) := by + simp [e] + refine ⟨e, ?_, ?_, ?_⟩ + · intro x y + obtain ⟨x,rfl⟩ := c.surjective x + obtain ⟨y,rfl⟩ := c.surjective y + rw [he,he] + change ω ((f x.1).val + x.2.val) ((f y.1).val + y.2.val) = + ω (x.1.val + x.2.val) (y.1.val + y.2.val) + rw [form_orthogonal_sum ω ha U (f x.1,x.2) (f y.1,y.2), + form_orthogonal_sum ω ha U x y,hf] + · intro x + have h := he (x,0) + simpa [c] using h + · intro x + have h := he (0,x) + simpa [c] using h + +omit [FiniteDimensional K E] in +/-- A linear section of the symplectic quotient automatically preserves the +form, because that form was defined on representatives. -/ +theorem reduction_section_isometry (ha : ω.IsAlt) + (s : ReducedSpace ω S →ₗ[K] ω.orthogonal S) + (hs : (reductionKernel ω S).mkQ.comp s = LinearMap.id) + (x y : ReducedSpace ω S) : + ω (s x).val (s y).val = symplecticReductionForm ω S ha x y := by + have hx : (reductionKernel ω S).mkQ (s x) = x := LinearMap.congr_fun hs x + have hy : (reductionKernel ω S).mkQ (s y) = y := LinearMap.congr_fun hs y + calc + _ = symplecticReductionForm ω S ha + ((reductionKernel ω S).mkQ (s x)) ((reductionKernel ω S).mkQ (s y)) := rfl + _ = _ := by rw [hx,hy] + + + + + +theorem exists_reduction_isometry_extension (ha : ω.IsAlt) + (hω : ω.Nondegenerate) + (f : ReducedSpace ω S ≃ₗ[K] ReducedSpace ω S) + (hf : ∀ x y, symplecticReductionForm ω S ha (f x) (f y) = + symplecticReductionForm ω S ha x y) : + ∃ e : E ≃ₗ[K] E, + (∀ x y, ω (e x) (e y) = ω x y) ∧ + (∀ x : S, e x.val = x.val) ∧ + (∀ x : ω.orthogonal S, e x.val ∈ ω.orthogonal S) ∧ + (∀ x y : ω.orthogonal S, e x.val = y.val → + (reductionKernel ω S).mkQ y = f ((reductionKernel ω S).mkQ x)) := by + let π := (reductionKernel ω S).mkQ + obtain ⟨s,hs⟩ := π.exists_rightInverse_of_surjective + (LinearMap.range_eq_top.mpr (Submodule.mkQ_surjective _)) + let g : ReducedSpace ω S →ₗ[K] E := (ω.orthogonal S).subtype.comp s + have hπ (x : ReducedSpace ω S) : π (s x) = x := LinearMap.congr_fun hs x + have hg (x y : ReducedSpace ω S) : ω (g x) (g y) = + symplecticReductionForm ω S ha x y := + reduction_section_isometry ω S ha s hs x y + have hginj : Function.Injective g := by + intro x y h + have h' : s x = s y := Subtype.ext h + simpa only [hπ] using congrArg π h' + let U := g.range + let j : ReducedSpace ω S ≃ₗ[K] U := LinearEquiv.ofInjective g hginj + have hj (x : ReducedSpace ω S) : (j x).val = g x := rfl + have hUn : (ω.restrict U).Nondegenerate := by + have hn := symplecticReductionForm_nondegenerate ω S ha hω + have left (x : U) (hx : ∀ y : U, ω x.val y.val = 0) : x = 0 := by + obtain ⟨x,rfl⟩ := j.surjective x + have hx0 : x = 0 := hn.1 x (fun y => by + rw [← hg] + exact hx (j y)) + simp [hx0] + refine ⟨left, ?_⟩ + intro x hx + apply left + intro y + exact ha.isRefl _ _ (hx y) + let fU := j.symm.trans (f.trans j) + have hfU (x y : U) : ω (fU x).val (fU y).val = ω x.val y.val := by + obtain ⟨x,rfl⟩ := j.surjective x + obtain ⟨y,rfl⟩ := j.surjective y + change ω (j (f (j.symm (j x)))).val (j (f (j.symm (j y)))).val = ω (j x).val (j y).val + simp only [j.symm_apply_apply,hj,hg,hf] + obtain ⟨e,he,heU,heO⟩ := exists_orthogonal_extension ω ha U hUn fU hfU + have hSO : S ≤ ω.orthogonal U := by + intro x hx y hy + obtain ⟨z,rfl⟩ := hy + exact ha.isRefl _ _ ((s z).property x hx) + have heS (x : S) : e x.val = x.val := heO ⟨x.val,hSO x.property⟩ + have heP (x : ω.orthogonal S) : e x.val ∈ ω.orthogonal S := by + intro y hy + have hyfix : e y = y := heS ⟨y,hy⟩ + rw [← hyfix,he] + exact x.property y hy + refine ⟨e,he,heS,heP,?_⟩ + intro x y hxy + apply sub_eq_zero.mp + apply (symplecticReductionForm_nondegenerate ω S ha hω).1 + intro z + have hpair (a : ω.orthogonal S) (b : ReducedSpace ω S) : + symplecticReductionForm ω S ha (π a) b = ω a.val (g b) := by + calc + _ = symplecticReductionForm ω S ha (π a) (π (s b)) := by rw [hπ] + _ = _ := rfl + have hegj (z : ReducedSpace ω S) : e (g z) = g (f z) := by + have h := heU (j z) + simpa only [fU,LinearEquiv.trans_apply,j.symm_apply_apply,hj] using h + change symplecticReductionForm ω S ha (π y - f (π x)) z = 0 + rw [map_sub,LinearMap.sub_apply,sub_eq_zero] + rw [hpair] + calc + ω y.val (g z) = ω (e x.val) (e (g (f.symm z))) := by + rw [hxy,hegj,f.apply_symm_apply] + _ = ω x.val (g (f.symm z)) := he _ _ + _ = symplecticReductionForm ω S ha (π x) (f.symm z) := (hpair x _).symm + _ = symplecticReductionForm ω S ha (f (π x)) z := by + simpa only [f.apply_symm_apply] using (hf (π x) (f.symm z)).symm + +end QuotientExtension +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module + +/-- Equal fiber cardinalities imply an exactly uniform pushforward, without +any measure-theoretic identification or conditional-independence assumption. -/ +theorem equal_fiber_card_identity {A B : Type*} [Finite A] [Finite B] + (f : A → B) (b : B) + (h : ∀ c : B, Nonempty ({a : A // f a = b} ≃ {a : A // f a = c})) : + Nat.card {a : A // f a = b} * Nat.card B = Nat.card A := by + classical + let := Fintype.ofFinite A + let := Fintype.ofFinite B + have hc (c : B) : Nat.card {a : A // f a = c} = Nat.card {a : A // f a = b} := + (Nat.card_congr (h c).some).symm + calc + _ = ∑ c : B, Nat.card {a : A // f a = c} := by + simp only [hc,Finset.sum_const,Finset.card_univ,smul_eq_mul,Nat.card_eq_fintype_card] + exact Nat.mul_comm _ _ + _ = Nat.card (Σ c : B, {a : A // f a = c}) := by + simp only [Nat.card_eq_fintype_card,Fintype.card_sigma] + _ = Nat.card A := Nat.card_congr (Equiv.sigmaFiberEquiv f) + +section ReductionLaws +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] +variable (ω : LinearMap.BilinForm K E) (S : Submodule K E) + +/-- Naturality of reduction for an actual extension of a quotient map. -/ +theorem reduceSubspace_map (e : E ≃ₗ[K] E) + (f : ReducedSpace ω S ≃ₗ[K] ReducedSpace ω S) + (hP : (ω.orthogonal S).map e.toLinearMap = ω.orthogonal S) + (hQ : ∀ x y : ω.orthogonal S, e x.val = y.val → + (reductionKernel ω S).mkQ y = f ((reductionKernel ω S).mkQ x)) + (L : Submodule K E) : + reduceSubspace ω S (L.map e.toLinearMap) = + (reduceSubspace ω S L).map f.toLinearMap := by + ext z + constructor + · rintro ⟨y,⟨x,hx,hxy⟩,rfl⟩ + have hxP : x ∈ ω.orthogonal S := by + have hyP : y.val ∈ (ω.orthogonal S).map e.toLinearMap := hP.symm ▸ y.property + obtain ⟨x',hx',hx'y⟩ := hyP + have heq : x' = x := e.injective (hx'y.trans hxy.symm) + exact heq ▸ hx' + refine ⟨(reductionKernel ω S).mkQ ⟨x,hxP⟩,⟨⟨x,hxP⟩,hx,rfl⟩,?_⟩ + exact (hQ ⟨x,hxP⟩ y hxy).symm + · rintro ⟨w,⟨x,hx,rfl⟩,rfl⟩ + have hyP : e x.val ∈ ω.orthogonal S := hP.le ⟨x.val,x.property,rfl⟩ + refine ⟨⟨e x.val,hyP⟩,⟨x.val,hx,rfl⟩,?_⟩ + exact hQ x ⟨e x.val,hyP⟩ rfl + +/-- A pointwise-fixed subspace is fixed under the subspace action. -/ +theorem subspace_map_eq_of_fixed (e : E ≃ₗ[K] E) (U : Submodule K E) + (h : ∀ x : U, e x.val = x.val) : U.map e.toLinearMap = U := by + ext x + constructor + · rintro ⟨y,hy,rfl⟩ + change e y ∈ U + rw [h ⟨y,hy⟩] + exact hy + · intro hx + exact ⟨x,hx,h ⟨x,hx⟩⟩ + +abbrev AvoidanceSpace (A : Submodule K E) := + {L : Submodule K E // ω.orthogonal L = L ∧ L ⊓ S = A} + +/-- An extension fixing S preserves separately each containment-and-avoidance +condition A⊂L, L∩S=A used in the independent residual laws. -/ +noncomputable def avoidanceIsometryEquiv (A : Submodule K E) (hAS : A ≤ S) + (e : E ≃ₗ[K] E) (he : ∀ x y, ω (e x) (e y) = ω x y) + (hS : ∀ x : S, e x.val = x.val) : + AvoidanceSpace ω S A ≃ AvoidanceSpace ω S A := by + have hSm := subspace_map_eq_of_fixed e S hS + have hAm := subspace_map_eq_of_fixed e A (fun x => hS ⟨x.val,hAS x.property⟩) + refine (Submodule.orderIsoMapComap e).toEquiv.subtypeEquiv ?_ + intro L + change (ω.orthogonal L = L ∧ L ⊓ S = A) ↔ + (ω.orthogonal (L.map e.toLinearMap) = L.map e.toLinearMap ∧ + L.map e.toLinearMap ⊓ S = A) + have hinj := (Submodule.orderIsoMapComap e).injective + constructor + · rintro ⟨hL,hLA⟩ + constructor + · rw [orthogonal_map_of_isometry ω e he,hL] + · calc + L.map e.toLinearMap ⊓ S = L.map e.toLinearMap ⊓ S.map e.toLinearMap := by rw [hSm] + _ = (L ⊓ S).map e.toLinearMap := (Submodule.map_inf e.toLinearMap e.injective).symm + _ = A.map e.toLinearMap := congrArg (Submodule.map e.toLinearMap) hLA + _ = A := hAm + · rintro ⟨hL,hLA⟩ + constructor + · apply hinj + change (ω.orthogonal L).map e.toLinearMap = L.map e.toLinearMap + rw [← orthogonal_map_of_isometry ω e he,hL] + · apply hinj + change (L ⊓ S).map e.toLinearMap = A.map e.toLinearMap + rw [Submodule.map_inf e.toLinearMap e.injective,hSm,hAm,hLA] + +variable [FiniteDimensional K E] + +noncomputable def avoidanceReduction (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (hS : S ≤ ω.orthogonal S) (A : Submodule K E) : + AvoidanceSpace ω S A → + {T : Submodule K (ReducedSpace ω S) // + (symplecticReductionForm ω S ha).orthogonal T = T} := + fun L => ⟨reduceSubspace ω S L.val, + general_lagrangian_reduction ω S ha hω hS L.val L.property.1⟩ + + + +theorem avoidanceReduction_fiber_equiv (h2 : (2 : K) ≠ 0) (ha : ω.IsAlt) + (hω : ω.Nondegenerate) (hS : S ≤ ω.orthogonal S) + (A : Submodule K E) (hAS : A ≤ S) + (T U : {T : Submodule K (ReducedSpace ω S) // + (symplecticReductionForm ω S ha).orthogonal T = T}) : + Nonempty ({L : AvoidanceSpace ω S A // avoidanceReduction ω S ha hω hS A L = T} ≃ + {L : AvoidanceSpace ω S A // avoidanceReduction ω S ha hω hS A L = U}) := by + let B := symplecticReductionForm ω S ha + obtain ⟨f,hf,hTU⟩ := lagrangian_transitivity B T.val h2 + (symplecticReductionForm_alt ω S ha) + (symplecticReductionForm_nondegenerate ω S ha hω) T.property U.val U.property + obtain ⟨e,he,heS,_,heQ⟩ := exists_reduction_isometry_extension ω S ha hω f hf + let a := avoidanceIsometryEquiv ω S A hAS e he heS + have hPm : (ω.orthogonal S).map e.toLinearMap = ω.orthogonal S := by + rw [← orthogonal_map_of_isometry ω e he,subspace_map_eq_of_fixed e S heS] + have hred (L : AvoidanceSpace ω S A) : + (avoidanceReduction ω S ha hω hS A (a L)).val = + (avoidanceReduction ω S ha hω hS A L).val.map f.toLinearMap := + reduceSubspace_map ω S e f hPm heQ L.val + refine ⟨a.subtypeEquiv ?_⟩ + intro L + constructor + · intro hL + apply Subtype.ext + rw [hred,hL] + exact hTU + · intro hL + apply Subtype.ext + apply (Submodule.orderIsoMapComap f).injective + change (avoidanceReduction ω S ha hω hS A L).val.map f.toLinearMap = T.val.map f.toLinearMap + rw [← hred,hL,hTU] + +variable [Finite E] + +/-- The conditional residual law is exactly uniform, in cardinal form. +It remains valid when the conditioning event is empty, without division by 0. -/ +theorem avoidanceReduction_uniform (h2 : (2 : K) ≠ 0) (ha : ω.IsAlt) + (hω : ω.Nondegenerate) (hS : S ≤ ω.orthogonal S) + (A : Submodule K E) (hAS : A ≤ S) + (T : {T : Submodule K (ReducedSpace ω S) // + (symplecticReductionForm ω S ha).orthogonal T = T}) : + Nat.card {L : AvoidanceSpace ω S A // avoidanceReduction ω S ha hω hS A L = T} * + Nat.card {U : Submodule K (ReducedSpace ω S) // + (symplecticReductionForm ω S ha).orthogonal U = U} = + Nat.card (AvoidanceSpace ω S A) := by + classical + let := Fintype.ofFinite E + let := Fintype.ofFinite (ω.orthogonal S) + exact equal_fiber_card_identity (avoidanceReduction ω S ha hω hS A) T + (avoidanceReduction_fiber_equiv ω S h2 ha hω hS A hAS T) + +end ReductionLaws +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module + +/-- A prescribed equivalence of subspaces extends to the ambient spaces +when both ambient dimensions and the complementary dimensions agree. -/ +theorem exists_linearEquiv_extension + {K E F : Type*} [Field K] [AddCommGroup E] [Module K E] + [AddCommGroup F] [Module K F] [FiniteDimensional K E] [FiniteDimensional K F] + (U : Submodule K E) (W : Submodule K F) + (hEF : finrank K E = finrank K F) (f : U ≃ₗ[K] W) : + ∃ e : E ≃ₗ[K] F, ∀ u : U, e u.val = (f u).val := by + obtain ⟨U',hU⟩ := U.exists_isCompl + obtain ⟨W',hW⟩ := W.exists_isCompl + let cU := Submodule.prodEquivOfIsCompl U U' hU + let cW := Submodule.prodEquivOfIsCompl W W' hW + have hdim : finrank K U' = finrank K W' := by + have h1 := Submodule.finrank_add_eq_of_isCompl hU + have h2 := Submodule.finrank_add_eq_of_isCompl hW + have h3 := f.finrank_eq + omega + let g : U' ≃ₗ[K] W' := LinearEquiv.ofFinrankEq U' W' hdim + let e := cU.symm.trans ((f.prodCongr g).trans cW) + refine ⟨e, ?_⟩ + intro u + have hu : cU (u,0) = u.val := by simp [cU] + change cW ((f.prodCongr g) (cU.symm u.val)) = (f u).val + rw [← hu, cU.symm_apply_apply] + simp [cW] + +/-- Full linear groups are transitive on subspaces of each dimension. -/ +theorem subspace_transitivity + {K E F : Type*} [Field K] [AddCommGroup E] [Module K E] + [AddCommGroup F] [Module K F] [FiniteDimensional K E] [FiniteDimensional K F] + (U : Submodule K E) (W : Submodule K F) + (hEF : finrank K E = finrank K F) (hUW : finrank K U = finrank K W) : + ∃ e : E ≃ₗ[K] F, U.map e.toLinearMap = W := by + let f : U ≃ₗ[K] W := LinearEquiv.ofFinrankEq U W hUW + obtain ⟨e,he⟩ := exists_linearEquiv_extension U W hEF f + refine ⟨e, ?_⟩ + ext x + constructor + · rintro ⟨y,hy,rfl⟩ + change e y ∈ W + rw [he ⟨y,hy⟩] + exact (f ⟨y,hy⟩).property + · intro hx + let u := f.symm ⟨x,hx⟩ + refine ⟨u.val,u.property, ?_⟩ + change e u.val = x + rw [he] + exact congrArg Subtype.val (f.apply_symm_apply ⟨x,hx⟩) + +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section IsotropicTransitivity +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] + [FiniteDimensional K E] [Finite E] +variable (ω : LinearMap.BilinForm K E) + + + +theorem isotropic_transitivity (h2 : (2 : K) ≠ 0) (ha : ω.IsAlt) + (hω : ω.Nondegenerate) (S T : Submodule K E) + (hS : S ≤ ω.orthogonal S) (hT : T ≤ ω.orthogonal T) + (hST : finrank K S = finrank K T) : + ∃ e : E ≃ₗ[K] E, (∀ x y, ω (e x) (e y) = ω x y) ∧ S.map e.toLinearMap = T := by + obtain ⟨L,hSL,hL⟩ := exists_containing_lagrangian ω ha S hS + obtain ⟨M,hTM,hM⟩ := exists_containing_lagrangian ω ha T hT + obtain ⟨eL,hEL,hωL⟩ := exists_lagrangian_coordinates ω L h2 ha hω hL + obtain ⟨eM,hEM,hωM⟩ := exists_lagrangian_coordinates ω M h2 ha hω hM + have hdim : finrank K L = finrank K M := by + have h1 := self_orthogonal_twice_finrank ω L hω hL + have h2 := self_orthogonal_twice_finrank ω M hω hM + omega + let U := S.comap L.subtype + let W := T.comap M.subtype + have hUW : finrank K U = finrank K W := by + exact (Submodule.comapSubtypeEquivOfLe hSL).finrank_eq.trans + (hST.trans (Submodule.comapSubtypeEquivOfLe hTM).finrank_eq.symm) + obtain ⟨f,hf⟩ := subspace_transitivity U W hdim hUW + let c : (L × Module.Dual K L) ≃ₗ[K] (M × Module.Dual K M) := + f.prodCongr f.symm.dualMap + have hc (x y : L × Module.Dual K L) : + canonicalSymplectic (c x) (c y) = canonicalSymplectic x y := by + simp [c,canonicalSymplectic_apply] + let e := eL.symm.trans (c.trans eM) + have he (l : L) : e l.val = (f l).val := by + change eM (c (eL.symm l.val)) = (f l).val + rw [← hEL l, eL.symm_apply_apply] + simpa [c] using hEM (f l) + refine ⟨e, ?_, ?_⟩ + · intro x y + change ω (eM (c (eL.symm x))) (eM (c (eL.symm y))) = ω x y + rw [hωM, hc, ← hωL, eL.apply_symm_apply, eL.apply_symm_apply] + · ext x + constructor + · rintro ⟨y,hy,rfl⟩ + change e y ∈ T + rw [he ⟨y,hSL hy⟩] + have hfu : f ⟨y,hSL hy⟩ ∈ U.map f.toLinearMap := ⟨⟨y,hSL hy⟩,hy,rfl⟩ + exact hf.le hfu + · intro hx + have hw : (⟨x,hTM hx⟩ : M) ∈ W := hx + obtain ⟨l,hl,hel⟩ := hf.ge hw + refine ⟨l.val,hl, ?_⟩ + change e l.val = x + rw [he] + exact congrArg Subtype.val hel + +end IsotropicTransitivity +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section TransversePairs +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] + [FiniteDimensional K E] +variable (ω : LinearMap.BilinForm K E) + +theorem transverse_isCompl (hω : ω.Nondegenerate) + (L M : Submodule K E) (hL : ω.orthogonal L = L) (hM : ω.orthogonal M = M) + (hLM : L ⊓ M = ⊥) : IsCompl L M := by + have h1 := self_orthogonal_twice_finrank ω L hω hL + have h2 := self_orthogonal_twice_finrank ω M hω hM + apply (Submodule.isCompl_iff_disjoint L M (by omega)).mpr + exact disjoint_iff.mpr hLM + +/-- Darboux coordinates respecting a specified ordered transverse pair. -/ +theorem exists_transverse_pair_coordinates (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (L M : Submodule K E) (hL : ω.orthogonal L = L) (hM : ω.orthogonal M = M) + (hLM : L ⊓ M = ⊥) : + ∃ e : (L × Module.Dual K L) ≃ₗ[K] E, + (∀ x, e x ∈ L ↔ x.2 = 0) ∧ (∀ x, e x ∈ M ↔ x.1 = 0) ∧ + ∀ x y, ω (e x) (e y) = canonicalSymplectic x y := by + let p := (symplecticProjection ω L).comp M.subtype + have hp : Function.Injective p := by + apply (LinearMap.ker_eq_bot).mp + apply (Submodule.eq_bot_iff _).mpr + intro m hm + apply Subtype.ext + have hml : m.val ∈ L := (symplecticProjection_ker ω L hL).le hm + have hz : m.val ∈ L ⊓ M := ⟨hml,m.property⟩ + change m.val = 0 + simpa only [hLM,Submodule.mem_bot] using hz + have hd : finrank K M = finrank K (Module.Dual K L) := by + rw [Subspace.dual_finrank_eq] + have h1 := self_orthogonal_twice_finrank ω L hω hL + have h2 := self_orthogonal_twice_finrank ω M hω hM + omega + let f : M ≃ₗ[K] Module.Dual K L := LinearEquiv.ofBijective p + ⟨hp,(LinearMap.injective_iff_surjective_of_finrank_eq_finrank hd).mp hp⟩ + let d := Submodule.prodEquivOfIsCompl L M (transverse_isCompl ω hω L M hL hM hLM) + let e := ((LinearEquiv.refl K L).prodCongr f.symm).trans d + have he (x : L × Module.Dual K L) : e x = x.1.val + (f.symm x.2).val := rfl + have hproj (x : L × Module.Dual K L) : symplecticProjection ω L (e x) = x.2 := by + rw [he,map_add] + have hl : symplecticProjection ω L x.1.val = 0 := + (symplecticProjection_ker ω L hL).ge x.1.property + rw [hl,zero_add] + exact f.apply_symm_apply x.2 + refine ⟨e, ?_, ?_, ?_⟩ + · intro x + constructor + · intro hx + have hz : symplecticProjection ω L (e x) = 0 := + (symplecticProjection_ker ω L hL).ge hx + rwa [hproj] at hz + · intro hx + apply (symplecticProjection_ker ω L hL).le + change symplecticProjection ω L (e x) = 0 + rw [hproj,hx] + · intro x + constructor + · intro hx + have hv : x.1.val ∈ M := by + have hh := M.sub_mem hx (f.symm x.2).property + simpa only [he,add_sub_cancel_right] using hh + have hz : x.1.val ∈ L ⊓ M := ⟨x.1.property,hv⟩ + apply Subtype.ext + change x.1.val = 0 + simpa only [hLM,Submodule.mem_bot] using hz + · intro hx + rw [he,hx] + simp + · intro x y + have hLL : ω x.1.val y.1.val = 0 := (hL.ge y.1.property) x.1.val x.1.property + have hMM : ω (f.symm x.2).val (f.symm y.2).val = 0 := + (hM.ge (f.symm y.2).property) (f.symm x.2).val (f.symm x.2).property + have hfg (g : Module.Dual K L) (l : L) : ω l.val (f.symm g).val = g l := + LinearMap.congr_fun (f.apply_symm_apply g) l + rw [he,he] + simp only [map_add,LinearMap.add_apply,hLL,hMM, + ← ha.neg_eq y.1.val (f.symm x.2).val,hfg,canonicalSymplectic_apply] + ring + +end TransversePairs +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module + + theorem subspace_map_eq_of_mem_iff + {K E F : Type*} [Field K] [AddCommGroup E] [Module K E] + [AddCommGroup F] [Module K F] (e : E ≃ₗ[K] F) + (U : Submodule K E) (W : Submodule K F) + (h : ∀ x, e x ∈ W ↔ x ∈ U) : U.map e.toLinearMap = W := by + ext x + constructor + · rintro ⟨y,hy,rfl⟩ + exact (h y).mpr hy + · intro hx + refine ⟨e.symm x,(h (e.symm x)).mp ?_,e.apply_symm_apply x⟩ + simpa only [e.apply_symm_apply] using hx + +section PairTransitivity +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] + [FiniteDimensional K E] +variable (ω : LinearMap.BilinForm K E) + +theorem transverse_pair_transitivity (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (L M L' M' : Submodule K E) + (hL : ω.orthogonal L = L) (hM : ω.orthogonal M = M) + (hL' : ω.orthogonal L' = L') (hM' : ω.orthogonal M' = M') + (hLM : L ⊓ M = ⊥) (hLM' : L' ⊓ M' = ⊥) : + ∃ e : E ≃ₗ[K] E, (∀ x y, ω (e x) (e y) = ω x y) ∧ + L.map e.toLinearMap = L' ∧ M.map e.toLinearMap = M' := by + obtain ⟨eL,hEL,hEM,hωL⟩ := exists_transverse_pair_coordinates ω ha hω L M hL hM hLM + obtain ⟨eM,hEL',hEM',hωM⟩ := exists_transverse_pair_coordinates ω ha hω L' M' hL' hM' hLM' + have hdim : finrank K L = finrank K L' := by + have h1 := self_orthogonal_twice_finrank ω L hω hL + have h2 := self_orthogonal_twice_finrank ω L' hω hL' + omega + let f : L ≃ₗ[K] L' := LinearEquiv.ofFinrankEq L L' hdim + let c : (L × Module.Dual K L) ≃ₗ[K] (L' × Module.Dual K L') := + f.prodCongr f.symm.dualMap + have hc (x y : L × Module.Dual K L) : + canonicalSymplectic (c x) (c y) = canonicalSymplectic x y := by + simp [c,canonicalSymplectic_apply] + let e := eL.symm.trans (c.trans eM) + refine ⟨e, ?_, ?_, ?_⟩ + · intro x y + change ω (eM (c (eL.symm x))) (eM (c (eL.symm y))) = ω x y + rw [hωM, hc, ← hωL, eL.apply_symm_apply, eL.apply_symm_apply] + · apply subspace_map_eq_of_mem_iff e + intro x + change eM (c (eL.symm x)) ∈ L' ↔ x ∈ L + rw [hEL'] + change f.symm.dualMap ((eL.symm x).2) = 0 ↔ x ∈ L + rw [LinearEquiv.map_eq_zero_iff] + simpa only [eL.apply_symm_apply] using (hEL (eL.symm x)).symm + · apply subspace_map_eq_of_mem_iff e + intro x + change eM (c (eL.symm x)) ∈ M' ↔ x ∈ M + rw [hEM'] + change f ((eL.symm x).1) = 0 ↔ x ∈ M + rw [LinearEquiv.map_eq_zero_iff] + simpa only [eL.apply_symm_apply] using (hEM (eL.symm x)).symm + +end PairTransitivity +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section PairReduction +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] +variable (ω : LinearMap.BilinForm K E) (S : Submodule K E) + +theorem liftReduction_inf (T U : Submodule K (ReducedSpace ω S)) : + liftReduction ω S (T ⊓ U) = liftReduction ω S T ⊓ liftReduction ω S U := by + ext x + simp only [mem_liftReduction,Submodule.mem_inf] + tauto + +theorem liftReduction_bot (hS : S ≤ ω.orthogonal S) : + liftReduction ω S ⊥ = S := by + ext x + constructor + · intro hx + obtain ⟨hxP,hxQ⟩ := (mem_liftReduction ω S ⊥ x).mp hx + exact (Submodule.Quotient.mk_eq_zero (reductionKernel ω S)).mp hxQ + · intro hx + apply (mem_liftReduction ω S ⊥ x).mpr + refine ⟨hS hx, ?_⟩ + exact (Submodule.Quotient.mk_eq_zero (reductionKernel ω S)).mpr hx + +theorem reduced_pair_transverse (hS : S ≤ ω.orthogonal S) + (L M : Submodule K E) (hL : ω.orthogonal L = L) (hM : ω.orthogonal M = M) + (hLM : L ⊓ M = S) : + reduceSubspace ω S L ⊓ reduceSubspace ω S M = ⊥ := by + have hSL : S ≤ L := hLM.ge.trans inf_le_left + have hSM : S ≤ M := hLM.ge.trans inf_le_right + apply liftReduction_injective ω S + rw [liftReduction_inf,lift_reduce ω S L hSL (lagrangian_le_orthogonal ω S L hL hSL), + lift_reduce ω S M hSM (lagrangian_le_orthogonal ω S M hM hSM), + liftReduction_bot ω S hS,hLM] + +variable [FiniteDimensional K E] + +theorem pair_transitivity_fixed_intersection (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (hS : S ≤ ω.orthogonal S) (L M L' M' : Submodule K E) + (hL : ω.orthogonal L = L) (hM : ω.orthogonal M = M) + (hL' : ω.orthogonal L' = L') (hM' : ω.orthogonal M' = M') + (hLM : L ⊓ M = S) (hLM' : L' ⊓ M' = S) : + ∃ e : E ≃ₗ[K] E, (∀ x y, ω (e x) (e y) = ω x y) ∧ + L.map e.toLinearMap = L' ∧ M.map e.toLinearMap = M' := by + have hSL : S ≤ L := hLM.ge.trans inf_le_left + have hSM : S ≤ M := hLM.ge.trans inf_le_right + have hSL' : S ≤ L' := hLM'.ge.trans inf_le_left + have hSM' : S ≤ M' := hLM'.ge.trans inf_le_right + let Ω := symplecticReductionForm ω S ha + have hΩa : Ω.IsAlt := symplecticReductionForm_alt ω S ha + have hΩ : Ω.Nondegenerate := symplecticReductionForm_nondegenerate ω S ha hω + obtain ⟨f,hf,hfL,hfM⟩ := transverse_pair_transitivity Ω hΩa hΩ + (reduceSubspace ω S L) (reduceSubspace ω S M) + (reduceSubspace ω S L') (reduceSubspace ω S M') + (reduce_lagrangian ω S ha hS L hL hSL) + (reduce_lagrangian ω S ha hS M hM hSM) + (reduce_lagrangian ω S ha hS L' hL' hSL') + (reduce_lagrangian ω S ha hS M' hM' hSM') + (reduced_pair_transverse ω S hS L M hL hM hLM) + (reduced_pair_transverse ω S hS L' M' hL' hM' hLM') + obtain ⟨e,he,heS,heP,heQ⟩ := exists_reduction_isometry_extension ω S ha hω f hf + have hSe : S.map e.toLinearMap = S := subspace_map_eq_of_fixed e S heS + have hPe : (ω.orthogonal S).map e.toLinearMap = ω.orthogonal S := by + rw [← orthogonal_map_of_isometry ω e he,hSe] + have hmap (U W : Submodule K E) (hU : ω.orthogonal U = U) + (hW : ω.orthogonal W = W) (hSU : S ≤ U) (hSW : S ≤ W) + (hfU : (reduceSubspace ω S U).map f.toLinearMap = reduceSubspace ω S W) : + U.map e.toLinearMap = W := by + have hSUe : S ≤ U.map e.toLinearMap := by + rw [← hSe] + exact Submodule.map_mono hSU + have hUe : ω.orthogonal (U.map e.toLinearMap) = U.map e.toLinearMap := by + rw [orthogonal_map_of_isometry ω e he,hU] + calc + U.map e.toLinearMap = liftReduction ω S (reduceSubspace ω S (U.map e.toLinearMap)) := + (lift_reduce ω S _ hSUe (lagrangian_le_orthogonal ω S _ hUe hSUe)).symm + _ = liftReduction ω S (reduceSubspace ω S W) := by + rw [reduceSubspace_map ω S e f hPe heQ,hfU] + _ = W := lift_reduce ω S W hSW (lagrangian_le_orthogonal ω S W hW hSW) + exact ⟨e,he,hmap L L' hL hL' hSL hSL' hfL,hmap M M' hM hM' hSM hSM' hfM⟩ + +end PairReduction +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section OrderedPairTransitivity +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] + [FiniteDimensional K E] [Finite E] +variable (ω : LinearMap.BilinForm K E) + + + +theorem ordered_pair_transitivity (h2 : (2 : K) ≠ 0) (ha : ω.IsAlt) + (hω : ω.Nondegenerate) (L M L' M' : Submodule K E) + (hL : ω.orthogonal L = L) (hM : ω.orthogonal M = M) + (hL' : ω.orthogonal L' = L') (hM' : ω.orthogonal M' = M') + (hdim : finrank K ↥(L ⊓ M) = finrank K ↥(L' ⊓ M')) : + ∃ e : E ≃ₗ[K] E, (∀ x y, ω (e x) (e y) = ω x y) ∧ + L.map e.toLinearMap = L' ∧ M.map e.toLinearMap = M' := by + have hi (U V : Submodule K E) (hU : ω.orthogonal U = U) : + U ⊓ V ≤ ω.orthogonal (U ⊓ V) := by + intro x hx y hy + exact (hU.ge hx.1) y hy.1 + obtain ⟨e0,he0,hS⟩ := isotropic_transitivity ω h2 ha hω + (L ⊓ M) (L' ⊓ M') (hi L M hL) (hi L' M' hL') hdim + have hLe : ω.orthogonal (L.map e0.toLinearMap) = L.map e0.toLinearMap := by + rw [orthogonal_map_of_isometry ω e0 he0,hL] + have hMe : ω.orthogonal (M.map e0.toLinearMap) = M.map e0.toLinearMap := by + rw [orthogonal_map_of_isometry ω e0 he0,hM] + have hLM : L.map e0.toLinearMap ⊓ M.map e0.toLinearMap = L' ⊓ M' := by + rw [← Submodule.map_inf e0.toLinearMap e0.injective,hS] + obtain ⟨e1,he1,hL1,hM1⟩ := pair_transitivity_fixed_intersection ω (L' ⊓ M') ha hω + (hi L' M' hL') (L.map e0.toLinearMap) (M.map e0.toLinearMap) L' M' + hLe hMe hL' hM' hLM rfl + refine ⟨e0.trans e1, ?_, ?_, ?_⟩ + · intro x y + exact (he1 (e0 x) (e0 y)).trans (he0 x y) + · change L.map (e1.toLinearMap.comp e0.toLinearMap) = L' + rw [Submodule.map_comp,hL1] + · change M.map (e1.toLinearMap.comp e0.toLinearMap) = M' + rw [Submodule.map_comp,hM1] + +end OrderedPairTransitivity +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section TripleBlocks +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] + [FiniteDimensional K E] +variable (ω : LinearMap.BilinForm K E) + + + + +theorem pairing_from_lagrangian_surjective (ha : ω.IsAlt) + (S N : Submodule K E) (hN : ω.orthogonal N = N) (hSN : S ⊓ N = ⊥) : + Function.Surjective ((symplecticProjection ω S).comp N.subtype) := by + let p := (symplecticProjection ω S).comp N.subtype + apply LinearMap.dualMap_injective_iff.mp + apply (LinearMap.ker_eq_bot).mp + apply (Submodule.eq_bot_iff _).mpr + intro z hz + obtain ⟨s,rfl⟩ := (Module.evalEquiv K S).surjective z + have hsN : s.val ∈ N := by + apply hN.le + intro n hn + have hh := LinearMap.congr_fun (LinearMap.mem_ker.mp hz) (⟨n,hn⟩ : N) + change ω s.val n = 0 at hh + exact ha.isRefl _ _ hh + have hs0 : s = 0 := by + apply Subtype.ext + change s.val = 0 + exact hSN.le ⟨s.property,hsN⟩ + rw [hs0,map_zero] + +/-- A dual to a pair-intersection space may be chosen inside the third +Lagrangian; the resulting block is nondegenerate and has canonical coordinates. -/ +theorem exists_pair_block (ha : ω.IsAlt) + (S N : Submodule K E) (hS : S ≤ ω.orthogonal S) + (hN : ω.orthogonal N = N) (hSN : S ⊓ N = ⊥) : + ∃ B : Submodule K E, (ω.restrict B).Nondegenerate ∧ S ≤ B ∧ + ∃ e : (S × Module.Dual K S) ≃ₗ[K] B, + (∀ s : S, (e (s,0)).val = s.val) ∧ + (∀ f : Module.Dual K S, (e (0,f)).val ∈ N) ∧ + ∀ x y, ω (e x).val (e y).val = canonicalSymplectic x y := by + let p := (symplecticProjection ω S).comp N.subtype + obtain ⟨s,hs⟩ := p.exists_rightInverse_of_surjective + (LinearMap.range_eq_top.mpr (pairing_from_lagrangian_surjective ω ha S N hN hSN)) + let g := N.subtype.comp s + have hpair (l : S) (f : Module.Dual K S) : ω l.val (g f) = f l := + LinearMap.congr_fun (LinearMap.congr_fun hs f) l + let f : (S × Module.Dual K S) →ₗ[K] E := + S.subtype.comp (LinearMap.fst K S (Module.Dual K S)) + + g.comp (LinearMap.snd K S (Module.Dual K S)) + have hf (x : S × Module.Dual K S) : f x = x.1.val + g x.2 := rfl + have hform (x y : S × Module.Dual K S) : + ω (f x) (f y) = canonicalSymplectic x y := by + have hSS : ω x.1.val y.1.val = 0 := hS y.1.property x.1.val x.1.property + have hNN : ω (g x.2) (g y.2) = 0 := (hN.ge (s y.2).property) _ (s x.2).property + rw [hf,hf] + simp only [map_add,LinearMap.add_apply,hSS,hNN, + ← ha.neg_eq y.1.val (g x.2),hpair,canonicalSymplectic_apply] + ring + have hinj : Function.Injective f := by + apply (LinearMap.ker_eq_bot).mp + apply (Submodule.eq_bot_iff _).mpr + intro x hx + apply canonicalSymplectic_nondegenerate.1 + intro y + rw [← hform,hx] + simp + let B := f.range + let e : (S × Module.Dual K S) ≃ₗ[K] B := LinearEquiv.ofInjective f hinj + have he (x : S × Module.Dual K S) : (e x).val = f x := rfl + have hleft (x : B) (hx : ∀ y : B, ω x.val y.val = 0) : x = 0 := by + obtain ⟨z,rfl⟩ := e.surjective x + have hz : z = 0 := canonicalSymplectic_nondegenerate.1 z (fun w => by + rw [← hform] + exact hx (e w)) + rw [hz,map_zero] + refine ⟨B,⟨hleft, ?_⟩, ?_,e, ?_, ?_, ?_⟩ + · intro x hx + apply hleft + intro y + exact ha.isRefl _ _ (hx y) + · intro x hx + refine ⟨(⟨x,hx⟩,0),?_⟩ + simp [hf] + · intro l + simp [he,hf] + · intro l + change (0 : E) + (s l).val ∈ N + simpa only [zero_add] using (s l).property + · intro x y + exact hform x y + +/-- A Lagrangian containing a Lagrangian of a nondegenerate block splits +orthogonally over that block. No choice of extensions is hidden here. -/ +theorem forced_orthogonal_splitting (ha : ω.IsAlt) + (B L : Submodule K E) (hB : (ω.restrict B).Nondegenerate) + (hL : L ≤ ω.orthogonal L) (T : Submodule K B) + (hT : (ω.restrict B).orthogonal T = T) (hTL : T.map B.subtype ≤ L) : + L = T.map B.subtype ⊔ (L ⊓ ω.orthogonal B) := by + let c := B.prodEquivOfIsCompl (ω.orthogonal B) + (ω.isCompl_orthogonal_of_restrict_nondegenerate ha.isRefl hB) + apply le_antisymm + · intro x hx + let b := (c.symm x).1 + let p := (c.symm x).2 + have hxp : b.val + p.val = x := c.apply_symm_apply x + have hbT : b ∈ T := by + apply hT.le + intro t ht + have htL : t.val ∈ L := hTL ⟨t,ht,rfl⟩ + have htx : ω t.val x = 0 := hL hx t.val htL + have htp : ω t.val p.val = 0 := p.property t.val t.property + rw [← hxp,map_add,htp,add_zero] at htx + exact htx + have hbL : b.val ∈ L := hTL ⟨b,hbT,rfl⟩ + have hpL : p.val ∈ L := by + have hp : p.val = x - b.val := by rw [← hxp]; abel + rw [hp] + exact L.sub_mem hx hbL + exact Submodule.mem_sup.mpr ⟨b.val,⟨b,hbT,rfl⟩,p.val,⟨hpL,p.property⟩,hxp⟩ + · exact sup_le hTL inf_le_left + +/-- The remaining part of a split Lagrangian is a Lagrangian for the +restricted form on the orthogonal complement. -/ +theorem split_residual_lagrangian (ha : ω.IsAlt) + (B L : Submodule K E) (hB : (ω.restrict B).Nondegenerate) + (hL : ω.orthogonal L = L) (T : Submodule K B) + (hT : (ω.restrict B).orthogonal T = T) (hTL : T.map B.subtype ≤ L) : + (ω.restrict (ω.orthogonal B)).orthogonal + (L.comap (ω.orthogonal B).subtype) = L.comap (ω.orthogonal B).subtype := by + have hs := forced_orthogonal_splitting ω ha B L hB hL.ge T hT hTL + ext x + constructor + · intro hx + change x.val ∈ L + apply hL.le + intro y hy + rw [hs] at hy + obtain ⟨b,⟨bt,hbt,rfl⟩,p,hp,rfl⟩ := Submodule.mem_sup.mp hy + rw [map_add,LinearMap.add_apply] + have hb : ω bt.val x.val = 0 := x.property bt.val bt.property + have hq : ω p x.val = 0 := hx (⟨p,hp.2⟩ : ω.orthogonal B) hp.1 + change ω bt.val x.val + ω p x.val = 0 + rw [hb,hq,add_zero] + · intro hx y hy + exact hL.ge hx y.val hy + +end TripleBlocks +end SidorenkoCounterexample + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/Refinement.lean b/lean/OAI/Combinatorics/Sidorenko/Refinement.lean new file mode 100644 index 0000000000000000000000000000000000000000..24748c433d6f69c060a10d7b87bf2d3396f7d05b --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/Refinement.lean @@ -0,0 +1,626 @@ +import OAI.Combinatorics.Sidorenko.Dilution + +namespace OAI + + +section + +namespace SidorenkoCounterexample +open scoped BigOperators +def refineLeft0 : Fin 13 → Fin 35 := ![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] +def refineRight0 : Fin 22 → Fin 35 := ![1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] +def refineLeft1 : Fin 13 → Fin 35 := ![0, 2, 0, 2, 1, 0, 1, 1, 1, 2, 1, 2, 1] +def refineRight1 : Fin 22 → Fin 35 := ![3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3] +def refineLeft2 : Fin 13 → Fin 35 := ![0, 2, 0, 2, 1, 0, 1, 1, 1, 2, 1, 2, 1] +def refineRight2 : Fin 22 → Fin 35 := ![6, 6, 9, 9, 3, 4, 4, 3, 7, 7, 3, 3, 4, 4, 8, 7, 8, 7, 5, 4, 5, 4] +def refineLeft3 : Fin 13 → Fin 35 := ![2, 11, 0, 12, 6, 1, 3, 4, 5, 9, 8, 10, 7] +def refineRight3 : Fin 22 → Fin 35 := ![16, 16, 19, 19, 13, 14, 14, 13, 17, 17, 13, 13, 14, 14, 18, 17, 18, 17, 15, 14, 15, 14] +def refineLeft4 : Fin 13 → Fin 35 := ![2, 11, 0, 12, 6, 1, 3, 4, 5, 9, 8, 10, 7] +def refineRight4 : Fin 22 → Fin 35 := ![25, 26, 33, 34, 13, 20, 21, 15, 29, 30, 16, 14, 19, 18, 32, 28, 31, 27, 24, 22, 23, 17] +def histLeft0 : Fin 13 → Fin 35 → ℕ := ![![0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] +lemma histLeft0_0 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight0 k.1) 0 c=histLeft0 0 c := by decide +kernel +lemma histLeft0_1 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight0 k.1) 1 c=histLeft0 1 c := by decide +kernel +lemma histLeft0_2 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight0 k.1) 2 c=histLeft0 2 c := by decide +kernel +lemma histLeft0_3 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight0 k.1) 3 c=histLeft0 3 c := by decide +kernel +lemma histLeft0_4 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight0 k.1) 4 c=histLeft0 4 c := by decide +kernel +lemma histLeft0_5 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight0 k.1) 5 c=histLeft0 5 c := by decide +kernel +lemma histLeft0_6 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight0 k.1) 6 c=histLeft0 6 c := by decide +kernel +lemma histLeft0_7 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight0 k.1) 7 c=histLeft0 7 c := by decide +kernel +lemma histLeft0_8 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight0 k.1) 8 c=histLeft0 8 c := by decide +kernel +lemma histLeft0_9 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight0 k.1) 9 c=histLeft0 9 c := by decide +kernel +lemma histLeft0_10 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight0 k.1) 10 c=histLeft0 10 c := by decide +kernel +lemma histLeft0_11 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight0 k.1) 11 c=histLeft0 11 c := by decide +kernel +lemma histLeft0_12 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight0 k.1) 12 c=histLeft0 12 c := by decide +kernel +lemma histLeft0_correct : ∀ v c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight0 k.1) v c=histLeft0 v c := by + intro v; fin_cases v + · exact histLeft0_0 + · exact histLeft0_1 + · exact histLeft0_2 + · exact histLeft0_3 + · exact histLeft0_4 + · exact histLeft0_5 + · exact histLeft0_6 + · exact histLeft0_7 + · exact histLeft0_8 + · exact histLeft0_9 + · exact histLeft0_10 + · exact histLeft0_11 + · exact histLeft0_12 +lemma refineLeft0_iff_0 : ∀ w, refineLeft1 0=refineLeft1 w ↔ refineLeft0 0=refineLeft0 w ∧ histLeft0 0=histLeft0 w := by decide +kernel +lemma refineLeft0_iff_1 : ∀ w, refineLeft1 1=refineLeft1 w ↔ refineLeft0 1=refineLeft0 w ∧ histLeft0 1=histLeft0 w := by decide +kernel +lemma refineLeft0_iff_2 : ∀ w, refineLeft1 2=refineLeft1 w ↔ refineLeft0 2=refineLeft0 w ∧ histLeft0 2=histLeft0 w := by decide +kernel +lemma refineLeft0_iff_3 : ∀ w, refineLeft1 3=refineLeft1 w ↔ refineLeft0 3=refineLeft0 w ∧ histLeft0 3=histLeft0 w := by decide +kernel +lemma refineLeft0_iff_4 : ∀ w, refineLeft1 4=refineLeft1 w ↔ refineLeft0 4=refineLeft0 w ∧ histLeft0 4=histLeft0 w := by decide +kernel +lemma refineLeft0_iff_5 : ∀ w, refineLeft1 5=refineLeft1 w ↔ refineLeft0 5=refineLeft0 w ∧ histLeft0 5=histLeft0 w := by decide +kernel +lemma refineLeft0_iff_6 : ∀ w, refineLeft1 6=refineLeft1 w ↔ refineLeft0 6=refineLeft0 w ∧ histLeft0 6=histLeft0 w := by decide +kernel +lemma refineLeft0_iff_7 : ∀ w, refineLeft1 7=refineLeft1 w ↔ refineLeft0 7=refineLeft0 w ∧ histLeft0 7=histLeft0 w := by decide +kernel +lemma refineLeft0_iff_8 : ∀ w, refineLeft1 8=refineLeft1 w ↔ refineLeft0 8=refineLeft0 w ∧ histLeft0 8=histLeft0 w := by decide +kernel +lemma refineLeft0_iff_9 : ∀ w, refineLeft1 9=refineLeft1 w ↔ refineLeft0 9=refineLeft0 w ∧ histLeft0 9=histLeft0 w := by decide +kernel +lemma refineLeft0_iff_10 : ∀ w, refineLeft1 10=refineLeft1 w ↔ refineLeft0 10=refineLeft0 w ∧ histLeft0 10=histLeft0 w := by decide +kernel +lemma refineLeft0_iff_11 : ∀ w, refineLeft1 11=refineLeft1 w ↔ refineLeft0 11=refineLeft0 w ∧ histLeft0 11=histLeft0 w := by decide +kernel +lemma refineLeft0_iff_12 : ∀ w, refineLeft1 12=refineLeft1 w ↔ refineLeft0 12=refineLeft0 w ∧ histLeft0 12=histLeft0 w := by decide +kernel +lemma refineLeft0_iff : ∀ v w, refineLeft1 v=refineLeft1 w ↔ refineLeft0 v=refineLeft0 w ∧ histLeft0 v=histLeft0 w := by + intro v; fin_cases v + · exact refineLeft0_iff_0 + · exact refineLeft0_iff_1 + · exact refineLeft0_iff_2 + · exact refineLeft0_iff_3 + · exact refineLeft0_iff_4 + · exact refineLeft0_iff_5 + · exact refineLeft0_iff_6 + · exact refineLeft0_iff_7 + · exact refineLeft0_iff_8 + · exact refineLeft0_iff_9 + · exact refineLeft0_iff_10 + · exact refineLeft0_iff_11 + · exact refineLeft0_iff_12 +def histRight0 : Fin 22 → Fin 35 → ℕ := ![![3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] +lemma histRight0_0 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft0 (cornerPoint k)) 0 c=histRight0 0 c := by decide +kernel +lemma histRight0_1 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft0 (cornerPoint k)) 1 c=histRight0 1 c := by decide +kernel +lemma histRight0_2 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft0 (cornerPoint k)) 2 c=histRight0 2 c := by decide +kernel +lemma histRight0_3 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft0 (cornerPoint k)) 3 c=histRight0 3 c := by decide +kernel +lemma histRight0_4 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft0 (cornerPoint k)) 4 c=histRight0 4 c := by decide +kernel +lemma histRight0_5 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft0 (cornerPoint k)) 5 c=histRight0 5 c := by decide +kernel +lemma histRight0_6 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft0 (cornerPoint k)) 6 c=histRight0 6 c := by decide +kernel +lemma histRight0_7 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft0 (cornerPoint k)) 7 c=histRight0 7 c := by decide +kernel +lemma histRight0_8 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft0 (cornerPoint k)) 8 c=histRight0 8 c := by decide +kernel +lemma histRight0_9 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft0 (cornerPoint k)) 9 c=histRight0 9 c := by decide +kernel +lemma histRight0_10 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft0 (cornerPoint k)) 10 c=histRight0 10 c := by decide +kernel +lemma histRight0_11 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft0 (cornerPoint k)) 11 c=histRight0 11 c := by decide +kernel +lemma histRight0_12 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft0 (cornerPoint k)) 12 c=histRight0 12 c := by decide +kernel +lemma histRight0_13 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft0 (cornerPoint k)) 13 c=histRight0 13 c := by decide +kernel +lemma histRight0_14 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft0 (cornerPoint k)) 14 c=histRight0 14 c := by decide +kernel +lemma histRight0_15 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft0 (cornerPoint k)) 15 c=histRight0 15 c := by decide +kernel +lemma histRight0_16 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft0 (cornerPoint k)) 16 c=histRight0 16 c := by decide +kernel +lemma histRight0_17 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft0 (cornerPoint k)) 17 c=histRight0 17 c := by decide +kernel +lemma histRight0_18 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft0 (cornerPoint k)) 18 c=histRight0 18 c := by decide +kernel +lemma histRight0_19 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft0 (cornerPoint k)) 19 c=histRight0 19 c := by decide +kernel +lemma histRight0_20 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft0 (cornerPoint k)) 20 c=histRight0 20 c := by decide +kernel +lemma histRight0_21 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft0 (cornerPoint k)) 21 c=histRight0 21 c := by decide +kernel +lemma histRight0_correct : ∀ v c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft0 (cornerPoint k)) v c=histRight0 v c := by + intro v; fin_cases v + · exact histRight0_0 + · exact histRight0_1 + · exact histRight0_2 + · exact histRight0_3 + · exact histRight0_4 + · exact histRight0_5 + · exact histRight0_6 + · exact histRight0_7 + · exact histRight0_8 + · exact histRight0_9 + · exact histRight0_10 + · exact histRight0_11 + · exact histRight0_12 + · exact histRight0_13 + · exact histRight0_14 + · exact histRight0_15 + · exact histRight0_16 + · exact histRight0_17 + · exact histRight0_18 + · exact histRight0_19 + · exact histRight0_20 + · exact histRight0_21 +lemma refineRight0_iff_0 : ∀ w, refineRight1 0=refineRight1 w ↔ refineRight0 0=refineRight0 w ∧ histRight0 0=histRight0 w := by decide +kernel +lemma refineRight0_iff_1 : ∀ w, refineRight1 1=refineRight1 w ↔ refineRight0 1=refineRight0 w ∧ histRight0 1=histRight0 w := by decide +kernel +lemma refineRight0_iff_2 : ∀ w, refineRight1 2=refineRight1 w ↔ refineRight0 2=refineRight0 w ∧ histRight0 2=histRight0 w := by decide +kernel +lemma refineRight0_iff_3 : ∀ w, refineRight1 3=refineRight1 w ↔ refineRight0 3=refineRight0 w ∧ histRight0 3=histRight0 w := by decide +kernel +lemma refineRight0_iff_4 : ∀ w, refineRight1 4=refineRight1 w ↔ refineRight0 4=refineRight0 w ∧ histRight0 4=histRight0 w := by decide +kernel +lemma refineRight0_iff_5 : ∀ w, refineRight1 5=refineRight1 w ↔ refineRight0 5=refineRight0 w ∧ histRight0 5=histRight0 w := by decide +kernel +lemma refineRight0_iff_6 : ∀ w, refineRight1 6=refineRight1 w ↔ refineRight0 6=refineRight0 w ∧ histRight0 6=histRight0 w := by decide +kernel +lemma refineRight0_iff_7 : ∀ w, refineRight1 7=refineRight1 w ↔ refineRight0 7=refineRight0 w ∧ histRight0 7=histRight0 w := by decide +kernel +lemma refineRight0_iff_8 : ∀ w, refineRight1 8=refineRight1 w ↔ refineRight0 8=refineRight0 w ∧ histRight0 8=histRight0 w := by decide +kernel +lemma refineRight0_iff_9 : ∀ w, refineRight1 9=refineRight1 w ↔ refineRight0 9=refineRight0 w ∧ histRight0 9=histRight0 w := by decide +kernel +lemma refineRight0_iff_10 : ∀ w, refineRight1 10=refineRight1 w ↔ refineRight0 10=refineRight0 w ∧ histRight0 10=histRight0 w := by decide +kernel +lemma refineRight0_iff_11 : ∀ w, refineRight1 11=refineRight1 w ↔ refineRight0 11=refineRight0 w ∧ histRight0 11=histRight0 w := by decide +kernel +lemma refineRight0_iff_12 : ∀ w, refineRight1 12=refineRight1 w ↔ refineRight0 12=refineRight0 w ∧ histRight0 12=histRight0 w := by decide +kernel +lemma refineRight0_iff_13 : ∀ w, refineRight1 13=refineRight1 w ↔ refineRight0 13=refineRight0 w ∧ histRight0 13=histRight0 w := by decide +kernel +lemma refineRight0_iff_14 : ∀ w, refineRight1 14=refineRight1 w ↔ refineRight0 14=refineRight0 w ∧ histRight0 14=histRight0 w := by decide +kernel +lemma refineRight0_iff_15 : ∀ w, refineRight1 15=refineRight1 w ↔ refineRight0 15=refineRight0 w ∧ histRight0 15=histRight0 w := by decide +kernel +lemma refineRight0_iff_16 : ∀ w, refineRight1 16=refineRight1 w ↔ refineRight0 16=refineRight0 w ∧ histRight0 16=histRight0 w := by decide +kernel +lemma refineRight0_iff_17 : ∀ w, refineRight1 17=refineRight1 w ↔ refineRight0 17=refineRight0 w ∧ histRight0 17=histRight0 w := by decide +kernel +lemma refineRight0_iff_18 : ∀ w, refineRight1 18=refineRight1 w ↔ refineRight0 18=refineRight0 w ∧ histRight0 18=histRight0 w := by decide +kernel +lemma refineRight0_iff_19 : ∀ w, refineRight1 19=refineRight1 w ↔ refineRight0 19=refineRight0 w ∧ histRight0 19=histRight0 w := by decide +kernel +lemma refineRight0_iff_20 : ∀ w, refineRight1 20=refineRight1 w ↔ refineRight0 20=refineRight0 w ∧ histRight0 20=histRight0 w := by decide +kernel +lemma refineRight0_iff_21 : ∀ w, refineRight1 21=refineRight1 w ↔ refineRight0 21=refineRight0 w ∧ histRight0 21=histRight0 w := by decide +kernel +lemma refineRight0_iff : ∀ v w, refineRight1 v=refineRight1 w ↔ refineRight0 v=refineRight0 w ∧ histRight0 v=histRight0 w := by + intro v; fin_cases v + · exact refineRight0_iff_0 + · exact refineRight0_iff_1 + · exact refineRight0_iff_2 + · exact refineRight0_iff_3 + · exact refineRight0_iff_4 + · exact refineRight0_iff_5 + · exact refineRight0_iff_6 + · exact refineRight0_iff_7 + · exact refineRight0_iff_8 + · exact refineRight0_iff_9 + · exact refineRight0_iff_10 + · exact refineRight0_iff_11 + · exact refineRight0_iff_12 + · exact refineRight0_iff_13 + · exact refineRight0_iff_14 + · exact refineRight0_iff_15 + · exact refineRight0_iff_16 + · exact refineRight0_iff_17 + · exact refineRight0_iff_18 + · exact refineRight0_iff_19 + · exact refineRight0_iff_20 + · exact refineRight0_iff_21 +def histLeft1 : Fin 13 → Fin 35 → ℕ := ![![0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] +lemma histLeft1_0 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight1 k.1) 0 c=histLeft1 0 c := by decide +kernel +lemma histLeft1_1 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight1 k.1) 1 c=histLeft1 1 c := by decide +kernel +lemma histLeft1_2 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight1 k.1) 2 c=histLeft1 2 c := by decide +kernel +lemma histLeft1_3 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight1 k.1) 3 c=histLeft1 3 c := by decide +kernel +lemma histLeft1_4 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight1 k.1) 4 c=histLeft1 4 c := by decide +kernel +lemma histLeft1_5 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight1 k.1) 5 c=histLeft1 5 c := by decide +kernel +lemma histLeft1_6 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight1 k.1) 6 c=histLeft1 6 c := by decide +kernel +lemma histLeft1_7 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight1 k.1) 7 c=histLeft1 7 c := by decide +kernel +lemma histLeft1_8 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight1 k.1) 8 c=histLeft1 8 c := by decide +kernel +lemma histLeft1_9 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight1 k.1) 9 c=histLeft1 9 c := by decide +kernel +lemma histLeft1_10 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight1 k.1) 10 c=histLeft1 10 c := by decide +kernel +lemma histLeft1_11 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight1 k.1) 11 c=histLeft1 11 c := by decide +kernel +lemma histLeft1_12 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight1 k.1) 12 c=histLeft1 12 c := by decide +kernel +lemma histLeft1_correct : ∀ v c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight1 k.1) v c=histLeft1 v c := by + intro v; fin_cases v + · exact histLeft1_0 + · exact histLeft1_1 + · exact histLeft1_2 + · exact histLeft1_3 + · exact histLeft1_4 + · exact histLeft1_5 + · exact histLeft1_6 + · exact histLeft1_7 + · exact histLeft1_8 + · exact histLeft1_9 + · exact histLeft1_10 + · exact histLeft1_11 + · exact histLeft1_12 +lemma refineLeft1_iff_0 : ∀ w, refineLeft2 0=refineLeft2 w ↔ refineLeft1 0=refineLeft1 w ∧ histLeft1 0=histLeft1 w := by decide +kernel +lemma refineLeft1_iff_1 : ∀ w, refineLeft2 1=refineLeft2 w ↔ refineLeft1 1=refineLeft1 w ∧ histLeft1 1=histLeft1 w := by decide +kernel +lemma refineLeft1_iff_2 : ∀ w, refineLeft2 2=refineLeft2 w ↔ refineLeft1 2=refineLeft1 w ∧ histLeft1 2=histLeft1 w := by decide +kernel +lemma refineLeft1_iff_3 : ∀ w, refineLeft2 3=refineLeft2 w ↔ refineLeft1 3=refineLeft1 w ∧ histLeft1 3=histLeft1 w := by decide +kernel +lemma refineLeft1_iff_4 : ∀ w, refineLeft2 4=refineLeft2 w ↔ refineLeft1 4=refineLeft1 w ∧ histLeft1 4=histLeft1 w := by decide +kernel +lemma refineLeft1_iff_5 : ∀ w, refineLeft2 5=refineLeft2 w ↔ refineLeft1 5=refineLeft1 w ∧ histLeft1 5=histLeft1 w := by decide +kernel +lemma refineLeft1_iff_6 : ∀ w, refineLeft2 6=refineLeft2 w ↔ refineLeft1 6=refineLeft1 w ∧ histLeft1 6=histLeft1 w := by decide +kernel +lemma refineLeft1_iff_7 : ∀ w, refineLeft2 7=refineLeft2 w ↔ refineLeft1 7=refineLeft1 w ∧ histLeft1 7=histLeft1 w := by decide +kernel +lemma refineLeft1_iff_8 : ∀ w, refineLeft2 8=refineLeft2 w ↔ refineLeft1 8=refineLeft1 w ∧ histLeft1 8=histLeft1 w := by decide +kernel +lemma refineLeft1_iff_9 : ∀ w, refineLeft2 9=refineLeft2 w ↔ refineLeft1 9=refineLeft1 w ∧ histLeft1 9=histLeft1 w := by decide +kernel +lemma refineLeft1_iff_10 : ∀ w, refineLeft2 10=refineLeft2 w ↔ refineLeft1 10=refineLeft1 w ∧ histLeft1 10=histLeft1 w := by decide +kernel +lemma refineLeft1_iff_11 : ∀ w, refineLeft2 11=refineLeft2 w ↔ refineLeft1 11=refineLeft1 w ∧ histLeft1 11=histLeft1 w := by decide +kernel +lemma refineLeft1_iff_12 : ∀ w, refineLeft2 12=refineLeft2 w ↔ refineLeft1 12=refineLeft1 w ∧ histLeft1 12=histLeft1 w := by decide +kernel +lemma refineLeft1_iff : ∀ v w, refineLeft2 v=refineLeft2 w ↔ refineLeft1 v=refineLeft1 w ∧ histLeft1 v=histLeft1 w := by + intro v; fin_cases v + · exact refineLeft1_iff_0 + · exact refineLeft1_iff_1 + · exact refineLeft1_iff_2 + · exact refineLeft1_iff_3 + · exact refineLeft1_iff_4 + · exact refineLeft1_iff_5 + · exact refineLeft1_iff_6 + · exact refineLeft1_iff_7 + · exact refineLeft1_iff_8 + · exact refineLeft1_iff_9 + · exact refineLeft1_iff_10 + · exact refineLeft1_iff_11 + · exact refineLeft1_iff_12 +def histRight1 : Fin 22 → Fin 35 → ℕ := ![![1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] +lemma histRight1_0 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft1 (cornerPoint k)) 0 c=histRight1 0 c := by decide +kernel +lemma histRight1_1 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft1 (cornerPoint k)) 1 c=histRight1 1 c := by decide +kernel +lemma histRight1_2 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft1 (cornerPoint k)) 2 c=histRight1 2 c := by decide +kernel +lemma histRight1_3 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft1 (cornerPoint k)) 3 c=histRight1 3 c := by decide +kernel +lemma histRight1_4 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft1 (cornerPoint k)) 4 c=histRight1 4 c := by decide +kernel +lemma histRight1_5 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft1 (cornerPoint k)) 5 c=histRight1 5 c := by decide +kernel +lemma histRight1_6 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft1 (cornerPoint k)) 6 c=histRight1 6 c := by decide +kernel +lemma histRight1_7 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft1 (cornerPoint k)) 7 c=histRight1 7 c := by decide +kernel +lemma histRight1_8 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft1 (cornerPoint k)) 8 c=histRight1 8 c := by decide +kernel +lemma histRight1_9 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft1 (cornerPoint k)) 9 c=histRight1 9 c := by decide +kernel +lemma histRight1_10 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft1 (cornerPoint k)) 10 c=histRight1 10 c := by decide +kernel +lemma histRight1_11 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft1 (cornerPoint k)) 11 c=histRight1 11 c := by decide +kernel +lemma histRight1_12 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft1 (cornerPoint k)) 12 c=histRight1 12 c := by decide +kernel +lemma histRight1_13 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft1 (cornerPoint k)) 13 c=histRight1 13 c := by decide +kernel +lemma histRight1_14 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft1 (cornerPoint k)) 14 c=histRight1 14 c := by decide +kernel +lemma histRight1_15 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft1 (cornerPoint k)) 15 c=histRight1 15 c := by decide +kernel +lemma histRight1_16 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft1 (cornerPoint k)) 16 c=histRight1 16 c := by decide +kernel +lemma histRight1_17 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft1 (cornerPoint k)) 17 c=histRight1 17 c := by decide +kernel +lemma histRight1_18 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft1 (cornerPoint k)) 18 c=histRight1 18 c := by decide +kernel +lemma histRight1_19 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft1 (cornerPoint k)) 19 c=histRight1 19 c := by decide +kernel +lemma histRight1_20 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft1 (cornerPoint k)) 20 c=histRight1 20 c := by decide +kernel +lemma histRight1_21 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft1 (cornerPoint k)) 21 c=histRight1 21 c := by decide +kernel +lemma histRight1_correct : ∀ v c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft1 (cornerPoint k)) v c=histRight1 v c := by + intro v; fin_cases v + · exact histRight1_0 + · exact histRight1_1 + · exact histRight1_2 + · exact histRight1_3 + · exact histRight1_4 + · exact histRight1_5 + · exact histRight1_6 + · exact histRight1_7 + · exact histRight1_8 + · exact histRight1_9 + · exact histRight1_10 + · exact histRight1_11 + · exact histRight1_12 + · exact histRight1_13 + · exact histRight1_14 + · exact histRight1_15 + · exact histRight1_16 + · exact histRight1_17 + · exact histRight1_18 + · exact histRight1_19 + · exact histRight1_20 + · exact histRight1_21 +lemma refineRight1_iff_0 : ∀ w, refineRight2 0=refineRight2 w ↔ refineRight1 0=refineRight1 w ∧ histRight1 0=histRight1 w := by decide +kernel +lemma refineRight1_iff_1 : ∀ w, refineRight2 1=refineRight2 w ↔ refineRight1 1=refineRight1 w ∧ histRight1 1=histRight1 w := by decide +kernel +lemma refineRight1_iff_2 : ∀ w, refineRight2 2=refineRight2 w ↔ refineRight1 2=refineRight1 w ∧ histRight1 2=histRight1 w := by decide +kernel +lemma refineRight1_iff_3 : ∀ w, refineRight2 3=refineRight2 w ↔ refineRight1 3=refineRight1 w ∧ histRight1 3=histRight1 w := by decide +kernel +lemma refineRight1_iff_4 : ∀ w, refineRight2 4=refineRight2 w ↔ refineRight1 4=refineRight1 w ∧ histRight1 4=histRight1 w := by decide +kernel +lemma refineRight1_iff_5 : ∀ w, refineRight2 5=refineRight2 w ↔ refineRight1 5=refineRight1 w ∧ histRight1 5=histRight1 w := by decide +kernel +lemma refineRight1_iff_6 : ∀ w, refineRight2 6=refineRight2 w ↔ refineRight1 6=refineRight1 w ∧ histRight1 6=histRight1 w := by decide +kernel +lemma refineRight1_iff_7 : ∀ w, refineRight2 7=refineRight2 w ↔ refineRight1 7=refineRight1 w ∧ histRight1 7=histRight1 w := by decide +kernel +lemma refineRight1_iff_8 : ∀ w, refineRight2 8=refineRight2 w ↔ refineRight1 8=refineRight1 w ∧ histRight1 8=histRight1 w := by decide +kernel +lemma refineRight1_iff_9 : ∀ w, refineRight2 9=refineRight2 w ↔ refineRight1 9=refineRight1 w ∧ histRight1 9=histRight1 w := by decide +kernel +lemma refineRight1_iff_10 : ∀ w, refineRight2 10=refineRight2 w ↔ refineRight1 10=refineRight1 w ∧ histRight1 10=histRight1 w := by decide +kernel +lemma refineRight1_iff_11 : ∀ w, refineRight2 11=refineRight2 w ↔ refineRight1 11=refineRight1 w ∧ histRight1 11=histRight1 w := by decide +kernel +lemma refineRight1_iff_12 : ∀ w, refineRight2 12=refineRight2 w ↔ refineRight1 12=refineRight1 w ∧ histRight1 12=histRight1 w := by decide +kernel +lemma refineRight1_iff_13 : ∀ w, refineRight2 13=refineRight2 w ↔ refineRight1 13=refineRight1 w ∧ histRight1 13=histRight1 w := by decide +kernel +lemma refineRight1_iff_14 : ∀ w, refineRight2 14=refineRight2 w ↔ refineRight1 14=refineRight1 w ∧ histRight1 14=histRight1 w := by decide +kernel +lemma refineRight1_iff_15 : ∀ w, refineRight2 15=refineRight2 w ↔ refineRight1 15=refineRight1 w ∧ histRight1 15=histRight1 w := by decide +kernel +lemma refineRight1_iff_16 : ∀ w, refineRight2 16=refineRight2 w ↔ refineRight1 16=refineRight1 w ∧ histRight1 16=histRight1 w := by decide +kernel +lemma refineRight1_iff_17 : ∀ w, refineRight2 17=refineRight2 w ↔ refineRight1 17=refineRight1 w ∧ histRight1 17=histRight1 w := by decide +kernel +lemma refineRight1_iff_18 : ∀ w, refineRight2 18=refineRight2 w ↔ refineRight1 18=refineRight1 w ∧ histRight1 18=histRight1 w := by decide +kernel +lemma refineRight1_iff_19 : ∀ w, refineRight2 19=refineRight2 w ↔ refineRight1 19=refineRight1 w ∧ histRight1 19=histRight1 w := by decide +kernel +lemma refineRight1_iff_20 : ∀ w, refineRight2 20=refineRight2 w ↔ refineRight1 20=refineRight1 w ∧ histRight1 20=histRight1 w := by decide +kernel +lemma refineRight1_iff_21 : ∀ w, refineRight2 21=refineRight2 w ↔ refineRight1 21=refineRight1 w ∧ histRight1 21=histRight1 w := by decide +kernel +lemma refineRight1_iff : ∀ v w, refineRight2 v=refineRight2 w ↔ refineRight1 v=refineRight1 w ∧ histRight1 v=histRight1 w := by + intro v; fin_cases v + · exact refineRight1_iff_0 + · exact refineRight1_iff_1 + · exact refineRight1_iff_2 + · exact refineRight1_iff_3 + · exact refineRight1_iff_4 + · exact refineRight1_iff_5 + · exact refineRight1_iff_6 + · exact refineRight1_iff_7 + · exact refineRight1_iff_8 + · exact refineRight1_iff_9 + · exact refineRight1_iff_10 + · exact refineRight1_iff_11 + · exact refineRight1_iff_12 + · exact refineRight1_iff_13 + · exact refineRight1_iff_14 + · exact refineRight1_iff_15 + · exact refineRight1_iff_16 + · exact refineRight1_iff_17 + · exact refineRight1_iff_18 + · exact refineRight1_iff_19 + · exact refineRight1_iff_20 + · exact refineRight1_iff_21 +def histLeft2 : Fin 13 → Fin 35 → ℕ := ![![0, 0, 0, 0, 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 2, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 3, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 1, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 0, 1, 2, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 0, 2, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 0, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 1, 2, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 2, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 2, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] +lemma histLeft2_0 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight2 k.1) 0 c=histLeft2 0 c := by decide +kernel +lemma histLeft2_1 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight2 k.1) 1 c=histLeft2 1 c := by decide +kernel +lemma histLeft2_2 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight2 k.1) 2 c=histLeft2 2 c := by decide +kernel +lemma histLeft2_3 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight2 k.1) 3 c=histLeft2 3 c := by decide +kernel +lemma histLeft2_4 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight2 k.1) 4 c=histLeft2 4 c := by decide +kernel +lemma histLeft2_5 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight2 k.1) 5 c=histLeft2 5 c := by decide +kernel +lemma histLeft2_6 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight2 k.1) 6 c=histLeft2 6 c := by decide +kernel +lemma histLeft2_7 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight2 k.1) 7 c=histLeft2 7 c := by decide +kernel +lemma histLeft2_8 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight2 k.1) 8 c=histLeft2 8 c := by decide +kernel +lemma histLeft2_9 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight2 k.1) 9 c=histLeft2 9 c := by decide +kernel +lemma histLeft2_10 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight2 k.1) 10 c=histLeft2 10 c := by decide +kernel +lemma histLeft2_11 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight2 k.1) 11 c=histLeft2 11 c := by decide +kernel +lemma histLeft2_12 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight2 k.1) 12 c=histLeft2 12 c := by decide +kernel +lemma histLeft2_correct : ∀ v c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight2 k.1) v c=histLeft2 v c := by + intro v; fin_cases v + · exact histLeft2_0 + · exact histLeft2_1 + · exact histLeft2_2 + · exact histLeft2_3 + · exact histLeft2_4 + · exact histLeft2_5 + · exact histLeft2_6 + · exact histLeft2_7 + · exact histLeft2_8 + · exact histLeft2_9 + · exact histLeft2_10 + · exact histLeft2_11 + · exact histLeft2_12 +lemma refineLeft2_iff_0 : ∀ w, refineLeft3 0=refineLeft3 w ↔ refineLeft2 0=refineLeft2 w ∧ histLeft2 0=histLeft2 w := by decide +kernel +lemma refineLeft2_iff_1 : ∀ w, refineLeft3 1=refineLeft3 w ↔ refineLeft2 1=refineLeft2 w ∧ histLeft2 1=histLeft2 w := by decide +kernel +lemma refineLeft2_iff_2 : ∀ w, refineLeft3 2=refineLeft3 w ↔ refineLeft2 2=refineLeft2 w ∧ histLeft2 2=histLeft2 w := by decide +kernel +lemma refineLeft2_iff_3 : ∀ w, refineLeft3 3=refineLeft3 w ↔ refineLeft2 3=refineLeft2 w ∧ histLeft2 3=histLeft2 w := by decide +kernel +lemma refineLeft2_iff_4 : ∀ w, refineLeft3 4=refineLeft3 w ↔ refineLeft2 4=refineLeft2 w ∧ histLeft2 4=histLeft2 w := by decide +kernel +lemma refineLeft2_iff_5 : ∀ w, refineLeft3 5=refineLeft3 w ↔ refineLeft2 5=refineLeft2 w ∧ histLeft2 5=histLeft2 w := by decide +kernel +lemma refineLeft2_iff_6 : ∀ w, refineLeft3 6=refineLeft3 w ↔ refineLeft2 6=refineLeft2 w ∧ histLeft2 6=histLeft2 w := by decide +kernel +lemma refineLeft2_iff_7 : ∀ w, refineLeft3 7=refineLeft3 w ↔ refineLeft2 7=refineLeft2 w ∧ histLeft2 7=histLeft2 w := by decide +kernel +lemma refineLeft2_iff_8 : ∀ w, refineLeft3 8=refineLeft3 w ↔ refineLeft2 8=refineLeft2 w ∧ histLeft2 8=histLeft2 w := by decide +kernel +lemma refineLeft2_iff_9 : ∀ w, refineLeft3 9=refineLeft3 w ↔ refineLeft2 9=refineLeft2 w ∧ histLeft2 9=histLeft2 w := by decide +kernel +lemma refineLeft2_iff_10 : ∀ w, refineLeft3 10=refineLeft3 w ↔ refineLeft2 10=refineLeft2 w ∧ histLeft2 10=histLeft2 w := by decide +kernel +lemma refineLeft2_iff_11 : ∀ w, refineLeft3 11=refineLeft3 w ↔ refineLeft2 11=refineLeft2 w ∧ histLeft2 11=histLeft2 w := by decide +kernel +lemma refineLeft2_iff_12 : ∀ w, refineLeft3 12=refineLeft3 w ↔ refineLeft2 12=refineLeft2 w ∧ histLeft2 12=histLeft2 w := by decide +kernel +lemma refineLeft2_iff : ∀ v w, refineLeft3 v=refineLeft3 w ↔ refineLeft2 v=refineLeft2 w ∧ histLeft2 v=histLeft2 w := by + intro v; fin_cases v + · exact refineLeft2_iff_0 + · exact refineLeft2_iff_1 + · exact refineLeft2_iff_2 + · exact refineLeft2_iff_3 + · exact refineLeft2_iff_4 + · exact refineLeft2_iff_5 + · exact refineLeft2_iff_6 + · exact refineLeft2_iff_7 + · exact refineLeft2_iff_8 + · exact refineLeft2_iff_9 + · exact refineLeft2_iff_10 + · exact refineLeft2_iff_11 + · exact refineLeft2_iff_12 +def histRight2 : Fin 22 → Fin 35 → ℕ := ![![1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] +lemma histRight2_0 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft2 (cornerPoint k)) 0 c=histRight2 0 c := by decide +kernel +lemma histRight2_1 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft2 (cornerPoint k)) 1 c=histRight2 1 c := by decide +kernel +lemma histRight2_2 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft2 (cornerPoint k)) 2 c=histRight2 2 c := by decide +kernel +lemma histRight2_3 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft2 (cornerPoint k)) 3 c=histRight2 3 c := by decide +kernel +lemma histRight2_4 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft2 (cornerPoint k)) 4 c=histRight2 4 c := by decide +kernel +lemma histRight2_5 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft2 (cornerPoint k)) 5 c=histRight2 5 c := by decide +kernel +lemma histRight2_6 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft2 (cornerPoint k)) 6 c=histRight2 6 c := by decide +kernel +lemma histRight2_7 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft2 (cornerPoint k)) 7 c=histRight2 7 c := by decide +kernel +lemma histRight2_8 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft2 (cornerPoint k)) 8 c=histRight2 8 c := by decide +kernel +lemma histRight2_9 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft2 (cornerPoint k)) 9 c=histRight2 9 c := by decide +kernel +lemma histRight2_10 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft2 (cornerPoint k)) 10 c=histRight2 10 c := by decide +kernel +lemma histRight2_11 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft2 (cornerPoint k)) 11 c=histRight2 11 c := by decide +kernel +lemma histRight2_12 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft2 (cornerPoint k)) 12 c=histRight2 12 c := by decide +kernel +lemma histRight2_13 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft2 (cornerPoint k)) 13 c=histRight2 13 c := by decide +kernel +lemma histRight2_14 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft2 (cornerPoint k)) 14 c=histRight2 14 c := by decide +kernel +lemma histRight2_15 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft2 (cornerPoint k)) 15 c=histRight2 15 c := by decide +kernel +lemma histRight2_16 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft2 (cornerPoint k)) 16 c=histRight2 16 c := by decide +kernel +lemma histRight2_17 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft2 (cornerPoint k)) 17 c=histRight2 17 c := by decide +kernel +lemma histRight2_18 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft2 (cornerPoint k)) 18 c=histRight2 18 c := by decide +kernel +lemma histRight2_19 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft2 (cornerPoint k)) 19 c=histRight2 19 c := by decide +kernel +lemma histRight2_20 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft2 (cornerPoint k)) 20 c=histRight2 20 c := by decide +kernel +lemma histRight2_21 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft2 (cornerPoint k)) 21 c=histRight2 21 c := by decide +kernel +lemma histRight2_correct : ∀ v c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft2 (cornerPoint k)) v c=histRight2 v c := by + intro v; fin_cases v + · exact histRight2_0 + · exact histRight2_1 + · exact histRight2_2 + · exact histRight2_3 + · exact histRight2_4 + · exact histRight2_5 + · exact histRight2_6 + · exact histRight2_7 + · exact histRight2_8 + · exact histRight2_9 + · exact histRight2_10 + · exact histRight2_11 + · exact histRight2_12 + · exact histRight2_13 + · exact histRight2_14 + · exact histRight2_15 + · exact histRight2_16 + · exact histRight2_17 + · exact histRight2_18 + · exact histRight2_19 + · exact histRight2_20 + · exact histRight2_21 +lemma refineRight2_iff_0 : ∀ w, refineRight3 0=refineRight3 w ↔ refineRight2 0=refineRight2 w ∧ histRight2 0=histRight2 w := by decide +kernel +lemma refineRight2_iff_1 : ∀ w, refineRight3 1=refineRight3 w ↔ refineRight2 1=refineRight2 w ∧ histRight2 1=histRight2 w := by decide +kernel +lemma refineRight2_iff_2 : ∀ w, refineRight3 2=refineRight3 w ↔ refineRight2 2=refineRight2 w ∧ histRight2 2=histRight2 w := by decide +kernel +lemma refineRight2_iff_3 : ∀ w, refineRight3 3=refineRight3 w ↔ refineRight2 3=refineRight2 w ∧ histRight2 3=histRight2 w := by decide +kernel +lemma refineRight2_iff_4 : ∀ w, refineRight3 4=refineRight3 w ↔ refineRight2 4=refineRight2 w ∧ histRight2 4=histRight2 w := by decide +kernel +lemma refineRight2_iff_5 : ∀ w, refineRight3 5=refineRight3 w ↔ refineRight2 5=refineRight2 w ∧ histRight2 5=histRight2 w := by decide +kernel +lemma refineRight2_iff_6 : ∀ w, refineRight3 6=refineRight3 w ↔ refineRight2 6=refineRight2 w ∧ histRight2 6=histRight2 w := by decide +kernel +lemma refineRight2_iff_7 : ∀ w, refineRight3 7=refineRight3 w ↔ refineRight2 7=refineRight2 w ∧ histRight2 7=histRight2 w := by decide +kernel +lemma refineRight2_iff_8 : ∀ w, refineRight3 8=refineRight3 w ↔ refineRight2 8=refineRight2 w ∧ histRight2 8=histRight2 w := by decide +kernel +lemma refineRight2_iff_9 : ∀ w, refineRight3 9=refineRight3 w ↔ refineRight2 9=refineRight2 w ∧ histRight2 9=histRight2 w := by decide +kernel +lemma refineRight2_iff_10 : ∀ w, refineRight3 10=refineRight3 w ↔ refineRight2 10=refineRight2 w ∧ histRight2 10=histRight2 w := by decide +kernel +lemma refineRight2_iff_11 : ∀ w, refineRight3 11=refineRight3 w ↔ refineRight2 11=refineRight2 w ∧ histRight2 11=histRight2 w := by decide +kernel +lemma refineRight2_iff_12 : ∀ w, refineRight3 12=refineRight3 w ↔ refineRight2 12=refineRight2 w ∧ histRight2 12=histRight2 w := by decide +kernel +lemma refineRight2_iff_13 : ∀ w, refineRight3 13=refineRight3 w ↔ refineRight2 13=refineRight2 w ∧ histRight2 13=histRight2 w := by decide +kernel +lemma refineRight2_iff_14 : ∀ w, refineRight3 14=refineRight3 w ↔ refineRight2 14=refineRight2 w ∧ histRight2 14=histRight2 w := by decide +kernel +lemma refineRight2_iff_15 : ∀ w, refineRight3 15=refineRight3 w ↔ refineRight2 15=refineRight2 w ∧ histRight2 15=histRight2 w := by decide +kernel +lemma refineRight2_iff_16 : ∀ w, refineRight3 16=refineRight3 w ↔ refineRight2 16=refineRight2 w ∧ histRight2 16=histRight2 w := by decide +kernel +lemma refineRight2_iff_17 : ∀ w, refineRight3 17=refineRight3 w ↔ refineRight2 17=refineRight2 w ∧ histRight2 17=histRight2 w := by decide +kernel +lemma refineRight2_iff_18 : ∀ w, refineRight3 18=refineRight3 w ↔ refineRight2 18=refineRight2 w ∧ histRight2 18=histRight2 w := by decide +kernel +lemma refineRight2_iff_19 : ∀ w, refineRight3 19=refineRight3 w ↔ refineRight2 19=refineRight2 w ∧ histRight2 19=histRight2 w := by decide +kernel +lemma refineRight2_iff_20 : ∀ w, refineRight3 20=refineRight3 w ↔ refineRight2 20=refineRight2 w ∧ histRight2 20=histRight2 w := by decide +kernel +lemma refineRight2_iff_21 : ∀ w, refineRight3 21=refineRight3 w ↔ refineRight2 21=refineRight2 w ∧ histRight2 21=histRight2 w := by decide +kernel +lemma refineRight2_iff : ∀ v w, refineRight3 v=refineRight3 w ↔ refineRight2 v=refineRight2 w ∧ histRight2 v=histRight2 w := by + intro v; fin_cases v + · exact refineRight2_iff_0 + · exact refineRight2_iff_1 + · exact refineRight2_iff_2 + · exact refineRight2_iff_3 + · exact refineRight2_iff_4 + · exact refineRight2_iff_5 + · exact refineRight2_iff_6 + · exact refineRight2_iff_7 + · exact refineRight2_iff_8 + · exact refineRight2_iff_9 + · exact refineRight2_iff_10 + · exact refineRight2_iff_11 + · exact refineRight2_iff_12 + · exact refineRight2_iff_13 + · exact refineRight2_iff_14 + · exact refineRight2_iff_15 + · exact refineRight2_iff_16 + · exact refineRight2_iff_17 + · exact refineRight2_iff_18 + · exact refineRight2_iff_19 + · exact refineRight2_iff_20 + · exact refineRight2_iff_21 +def histLeft3 : Fin 13 → Fin 35 → ℕ := ![![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] +lemma histLeft3_0 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight3 k.1) 0 c=histLeft3 0 c := by decide +kernel +lemma histLeft3_1 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight3 k.1) 1 c=histLeft3 1 c := by decide +kernel +lemma histLeft3_2 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight3 k.1) 2 c=histLeft3 2 c := by decide +kernel +lemma histLeft3_3 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight3 k.1) 3 c=histLeft3 3 c := by decide +kernel +lemma histLeft3_4 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight3 k.1) 4 c=histLeft3 4 c := by decide +kernel +lemma histLeft3_5 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight3 k.1) 5 c=histLeft3 5 c := by decide +kernel +lemma histLeft3_6 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight3 k.1) 6 c=histLeft3 6 c := by decide +kernel +lemma histLeft3_7 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight3 k.1) 7 c=histLeft3 7 c := by decide +kernel +lemma histLeft3_8 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight3 k.1) 8 c=histLeft3 8 c := by decide +kernel +lemma histLeft3_9 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight3 k.1) 9 c=histLeft3 9 c := by decide +kernel +lemma histLeft3_10 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight3 k.1) 10 c=histLeft3 10 c := by decide +kernel +lemma histLeft3_11 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight3 k.1) 11 c=histLeft3 11 c := by decide +kernel +lemma histLeft3_12 : ∀ c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight3 k.1) 12 c=histLeft3 12 c := by decide +kernel +lemma histLeft3_correct : ∀ v c, neighborHistogram cornerPoint (fun k : ActCorner => refineRight3 k.1) v c=histLeft3 v c := by + intro v; fin_cases v + · exact histLeft3_0 + · exact histLeft3_1 + · exact histLeft3_2 + · exact histLeft3_3 + · exact histLeft3_4 + · exact histLeft3_5 + · exact histLeft3_6 + · exact histLeft3_7 + · exact histLeft3_8 + · exact histLeft3_9 + · exact histLeft3_10 + · exact histLeft3_11 + · exact histLeft3_12 +lemma refineLeft3_iff_0 : ∀ w, refineLeft4 0=refineLeft4 w ↔ refineLeft3 0=refineLeft3 w ∧ histLeft3 0=histLeft3 w := by decide +kernel +lemma refineLeft3_iff_1 : ∀ w, refineLeft4 1=refineLeft4 w ↔ refineLeft3 1=refineLeft3 w ∧ histLeft3 1=histLeft3 w := by decide +kernel +lemma refineLeft3_iff_2 : ∀ w, refineLeft4 2=refineLeft4 w ↔ refineLeft3 2=refineLeft3 w ∧ histLeft3 2=histLeft3 w := by decide +kernel +lemma refineLeft3_iff_3 : ∀ w, refineLeft4 3=refineLeft4 w ↔ refineLeft3 3=refineLeft3 w ∧ histLeft3 3=histLeft3 w := by decide +kernel +lemma refineLeft3_iff_4 : ∀ w, refineLeft4 4=refineLeft4 w ↔ refineLeft3 4=refineLeft3 w ∧ histLeft3 4=histLeft3 w := by decide +kernel +lemma refineLeft3_iff_5 : ∀ w, refineLeft4 5=refineLeft4 w ↔ refineLeft3 5=refineLeft3 w ∧ histLeft3 5=histLeft3 w := by decide +kernel +lemma refineLeft3_iff_6 : ∀ w, refineLeft4 6=refineLeft4 w ↔ refineLeft3 6=refineLeft3 w ∧ histLeft3 6=histLeft3 w := by decide +kernel +lemma refineLeft3_iff_7 : ∀ w, refineLeft4 7=refineLeft4 w ↔ refineLeft3 7=refineLeft3 w ∧ histLeft3 7=histLeft3 w := by decide +kernel +lemma refineLeft3_iff_8 : ∀ w, refineLeft4 8=refineLeft4 w ↔ refineLeft3 8=refineLeft3 w ∧ histLeft3 8=histLeft3 w := by decide +kernel +lemma refineLeft3_iff_9 : ∀ w, refineLeft4 9=refineLeft4 w ↔ refineLeft3 9=refineLeft3 w ∧ histLeft3 9=histLeft3 w := by decide +kernel +lemma refineLeft3_iff_10 : ∀ w, refineLeft4 10=refineLeft4 w ↔ refineLeft3 10=refineLeft3 w ∧ histLeft3 10=histLeft3 w := by decide +kernel +lemma refineLeft3_iff_11 : ∀ w, refineLeft4 11=refineLeft4 w ↔ refineLeft3 11=refineLeft3 w ∧ histLeft3 11=histLeft3 w := by decide +kernel +lemma refineLeft3_iff_12 : ∀ w, refineLeft4 12=refineLeft4 w ↔ refineLeft3 12=refineLeft3 w ∧ histLeft3 12=histLeft3 w := by decide +kernel +lemma refineLeft3_iff : ∀ v w, refineLeft4 v=refineLeft4 w ↔ refineLeft3 v=refineLeft3 w ∧ histLeft3 v=histLeft3 w := by + intro v; fin_cases v + · exact refineLeft3_iff_0 + · exact refineLeft3_iff_1 + · exact refineLeft3_iff_2 + · exact refineLeft3_iff_3 + · exact refineLeft3_iff_4 + · exact refineLeft3_iff_5 + · exact refineLeft3_iff_6 + · exact refineLeft3_iff_7 + · exact refineLeft3_iff_8 + · exact refineLeft3_iff_9 + · exact refineLeft3_iff_10 + · exact refineLeft3_iff_11 + · exact refineLeft3_iff_12 +def histRight3 : Fin 22 → Fin 35 → ℕ := ![![0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], ![0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] +lemma histRight3_0 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft3 (cornerPoint k)) 0 c=histRight3 0 c := by decide +kernel +lemma histRight3_1 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft3 (cornerPoint k)) 1 c=histRight3 1 c := by decide +kernel +lemma histRight3_2 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft3 (cornerPoint k)) 2 c=histRight3 2 c := by decide +kernel +lemma histRight3_3 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft3 (cornerPoint k)) 3 c=histRight3 3 c := by decide +kernel +lemma histRight3_4 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft3 (cornerPoint k)) 4 c=histRight3 4 c := by decide +kernel +lemma histRight3_5 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft3 (cornerPoint k)) 5 c=histRight3 5 c := by decide +kernel +lemma histRight3_6 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft3 (cornerPoint k)) 6 c=histRight3 6 c := by decide +kernel +lemma histRight3_7 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft3 (cornerPoint k)) 7 c=histRight3 7 c := by decide +kernel +lemma histRight3_8 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft3 (cornerPoint k)) 8 c=histRight3 8 c := by decide +kernel +lemma histRight3_9 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft3 (cornerPoint k)) 9 c=histRight3 9 c := by decide +kernel +lemma histRight3_10 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft3 (cornerPoint k)) 10 c=histRight3 10 c := by decide +kernel +lemma histRight3_11 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft3 (cornerPoint k)) 11 c=histRight3 11 c := by decide +kernel +lemma histRight3_12 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft3 (cornerPoint k)) 12 c=histRight3 12 c := by decide +kernel +lemma histRight3_13 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft3 (cornerPoint k)) 13 c=histRight3 13 c := by decide +kernel +lemma histRight3_14 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft3 (cornerPoint k)) 14 c=histRight3 14 c := by decide +kernel +lemma histRight3_15 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft3 (cornerPoint k)) 15 c=histRight3 15 c := by decide +kernel +lemma histRight3_16 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft3 (cornerPoint k)) 16 c=histRight3 16 c := by decide +kernel +lemma histRight3_17 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft3 (cornerPoint k)) 17 c=histRight3 17 c := by decide +kernel +lemma histRight3_18 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft3 (cornerPoint k)) 18 c=histRight3 18 c := by decide +kernel +lemma histRight3_19 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft3 (cornerPoint k)) 19 c=histRight3 19 c := by decide +kernel +lemma histRight3_20 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft3 (cornerPoint k)) 20 c=histRight3 20 c := by decide +kernel +lemma histRight3_21 : ∀ c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft3 (cornerPoint k)) 21 c=histRight3 21 c := by decide +kernel +lemma histRight3_correct : ∀ v c, neighborHistogram (fun k : ActCorner => k.1) (fun k : ActCorner => refineLeft3 (cornerPoint k)) v c=histRight3 v c := by + intro v; fin_cases v + · exact histRight3_0 + · exact histRight3_1 + · exact histRight3_2 + · exact histRight3_3 + · exact histRight3_4 + · exact histRight3_5 + · exact histRight3_6 + · exact histRight3_7 + · exact histRight3_8 + · exact histRight3_9 + · exact histRight3_10 + · exact histRight3_11 + · exact histRight3_12 + · exact histRight3_13 + · exact histRight3_14 + · exact histRight3_15 + · exact histRight3_16 + · exact histRight3_17 + · exact histRight3_18 + · exact histRight3_19 + · exact histRight3_20 + · exact histRight3_21 +lemma refineRight3_iff_0 : ∀ w, refineRight4 0=refineRight4 w ↔ refineRight3 0=refineRight3 w ∧ histRight3 0=histRight3 w := by decide +kernel +lemma refineRight3_iff_1 : ∀ w, refineRight4 1=refineRight4 w ↔ refineRight3 1=refineRight3 w ∧ histRight3 1=histRight3 w := by decide +kernel +lemma refineRight3_iff_2 : ∀ w, refineRight4 2=refineRight4 w ↔ refineRight3 2=refineRight3 w ∧ histRight3 2=histRight3 w := by decide +kernel +lemma refineRight3_iff_3 : ∀ w, refineRight4 3=refineRight4 w ↔ refineRight3 3=refineRight3 w ∧ histRight3 3=histRight3 w := by decide +kernel +lemma refineRight3_iff_4 : ∀ w, refineRight4 4=refineRight4 w ↔ refineRight3 4=refineRight3 w ∧ histRight3 4=histRight3 w := by decide +kernel +lemma refineRight3_iff_5 : ∀ w, refineRight4 5=refineRight4 w ↔ refineRight3 5=refineRight3 w ∧ histRight3 5=histRight3 w := by decide +kernel +lemma refineRight3_iff_6 : ∀ w, refineRight4 6=refineRight4 w ↔ refineRight3 6=refineRight3 w ∧ histRight3 6=histRight3 w := by decide +kernel +lemma refineRight3_iff_7 : ∀ w, refineRight4 7=refineRight4 w ↔ refineRight3 7=refineRight3 w ∧ histRight3 7=histRight3 w := by decide +kernel +lemma refineRight3_iff_8 : ∀ w, refineRight4 8=refineRight4 w ↔ refineRight3 8=refineRight3 w ∧ histRight3 8=histRight3 w := by decide +kernel +lemma refineRight3_iff_9 : ∀ w, refineRight4 9=refineRight4 w ↔ refineRight3 9=refineRight3 w ∧ histRight3 9=histRight3 w := by decide +kernel +lemma refineRight3_iff_10 : ∀ w, refineRight4 10=refineRight4 w ↔ refineRight3 10=refineRight3 w ∧ histRight3 10=histRight3 w := by decide +kernel +lemma refineRight3_iff_11 : ∀ w, refineRight4 11=refineRight4 w ↔ refineRight3 11=refineRight3 w ∧ histRight3 11=histRight3 w := by decide +kernel +lemma refineRight3_iff_12 : ∀ w, refineRight4 12=refineRight4 w ↔ refineRight3 12=refineRight3 w ∧ histRight3 12=histRight3 w := by decide +kernel +lemma refineRight3_iff_13 : ∀ w, refineRight4 13=refineRight4 w ↔ refineRight3 13=refineRight3 w ∧ histRight3 13=histRight3 w := by decide +kernel +lemma refineRight3_iff_14 : ∀ w, refineRight4 14=refineRight4 w ↔ refineRight3 14=refineRight3 w ∧ histRight3 14=histRight3 w := by decide +kernel +lemma refineRight3_iff_15 : ∀ w, refineRight4 15=refineRight4 w ↔ refineRight3 15=refineRight3 w ∧ histRight3 15=histRight3 w := by decide +kernel +lemma refineRight3_iff_16 : ∀ w, refineRight4 16=refineRight4 w ↔ refineRight3 16=refineRight3 w ∧ histRight3 16=histRight3 w := by decide +kernel +lemma refineRight3_iff_17 : ∀ w, refineRight4 17=refineRight4 w ↔ refineRight3 17=refineRight3 w ∧ histRight3 17=histRight3 w := by decide +kernel +lemma refineRight3_iff_18 : ∀ w, refineRight4 18=refineRight4 w ↔ refineRight3 18=refineRight3 w ∧ histRight3 18=histRight3 w := by decide +kernel +lemma refineRight3_iff_19 : ∀ w, refineRight4 19=refineRight4 w ↔ refineRight3 19=refineRight3 w ∧ histRight3 19=histRight3 w := by decide +kernel +lemma refineRight3_iff_20 : ∀ w, refineRight4 20=refineRight4 w ↔ refineRight3 20=refineRight3 w ∧ histRight3 20=histRight3 w := by decide +kernel +lemma refineRight3_iff_21 : ∀ w, refineRight4 21=refineRight4 w ↔ refineRight3 21=refineRight3 w ∧ histRight3 21=histRight3 w := by decide +kernel +lemma refineRight3_iff : ∀ v w, refineRight4 v=refineRight4 w ↔ refineRight3 v=refineRight3 w ∧ histRight3 v=histRight3 w := by + intro v; fin_cases v + · exact refineRight3_iff_0 + · exact refineRight3_iff_1 + · exact refineRight3_iff_2 + · exact refineRight3_iff_3 + · exact refineRight3_iff_4 + · exact refineRight3_iff_5 + · exact refineRight3_iff_6 + · exact refineRight3_iff_7 + · exact refineRight3_iff_8 + · exact refineRight3_iff_9 + · exact refineRight3_iff_10 + · exact refineRight3_iff_11 + · exact refineRight3_iff_12 + · exact refineRight3_iff_13 + · exact refineRight3_iff_14 + · exact refineRight3_iff_15 + · exact refineRight3_iff_16 + · exact refineRight3_iff_17 + · exact refineRight3_iff_18 + · exact refineRight3_iff_19 + · exact refineRight3_iff_20 + · exact refineRight3_iff_21 +lemma refineLeft_final : Function.Injective refineLeft4 := by decide +kernel +lemma refineRight_final : Function.Injective refineRight4 := by decide +kernel +end SidorenkoCounterexample + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/Restrictions.lean b/lean/OAI/Combinatorics/Sidorenko/Restrictions.lean new file mode 100644 index 0000000000000000000000000000000000000000..a2a7b5f3dafc65a52a4ac04fea786a1fa875f974 --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/Restrictions.lean @@ -0,0 +1,561 @@ +import OAI.Combinatorics.Sidorenko.Projections + +namespace OAI + + +section + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section Means +variable {A B : Type*} [Fintype A] [Fintype B] +theorem uniformMean_swap (f : A → B → ℝ) : + uniformMean (fun a => uniformMean (f a)) = + uniformMean (fun b => uniformMean fun a => f a b) := by + unfold uniformMean + simp only [←Finset.sum_div] + rw [Finset.sum_comm] + ring + +variable [AddGroup A] +theorem uniformMean_translate (f : A → ℝ) (t : A) : + uniformMean (fun a => f (a+t)) = uniformMean f := uniformMean_equiv (Equiv.addRight t) f + +theorem uniformMean_average_translate [Nonempty B] (f : A → ℝ) (t : B → A) : + uniformMean (fun a => uniformMean fun b => f (a+t b)) = uniformMean f := by + rw [uniformMean_swap] + simp_rw [uniformMean_translate,uniformMean_const] +end Means +section ShiftError +variable {K U : Type*} [Field K] [Fintype K] [DecidableEq K] + [AddCommGroup U] [Module K U] [FiniteDimensional K U] + +theorem rankOne_shift_error (φ : U →ₗ[K] K) (x : U) (hx : φ x=1) + (Q : SymForm K U) (hK : ringChar K ≠ 2) {ξ : ℤ} (hξ : ξ=1 ∨ ξ= -1) : + |uniformMean (fun a : K => formSignIndicator ξ (Q+a • rankOneForm φ))-1/2| ≤ + formSingularIndicator (symFormPull φ.ker.subtype Q)+1/(Fintype.card K : ℝ) := by + have hq : 0 < (Fintype.card K : ℝ) := Nat.cast_pos.mpr Fintype.card_pos + by_cases hQ : (symFormPull φ.ker.subtype Q).val.Nondegenerate + · rw [rankOne_shift_mean φ x hx Q hQ hK hξ] + simp only [formSingularIndicator,hQ,ite_true,zero_add] + apply abs_le.mpr + constructor <;> nlinarith [one_div_pos.mpr hq] + · have h0 := uniformMean_nonneg fun a : K => formSignIndicator_nonneg ξ (Q+a • rankOneForm φ) + have h1 := uniformMean_bound fun a : K => formSignIndicator_le_one ξ (Q+a • rankOneForm φ) + simp only [formSingularIndicator,hQ,ite_false] + apply abs_le.mpr + constructor <;> linarith [one_div_pos.mpr hq] + +theorem centered_formSign_abs (ξ : ℤ) (Q : SymForm K U) : + |formSignIndicator ξ Q-1/2| ≤ 1 := by + have h0 := formSignIndicator_nonneg ξ Q + have h1 := formSignIndicator_le_one ξ Q + exact abs_le.mpr ⟨by linarith,by linarith⟩ +end ShiftError +section Separate +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] [FiniteDimensional K V] +theorem equal_dimension_separating_dual (U W : Submodule K V) + (hd : finrank K U=finrank K W) (hne : U≠W) : + ∃ (φ : V →ₗ[K] K) (x : U), φ x.val=1 ∧ φ.comp W.subtype=0 := by + have hle : ¬ U ≤ W := by + intro h + exact hne (Submodule.eq_of_le_of_finrank_eq h hd) + have hex : ∃ x : V, x ∈ U ∧ x ∉ W := by + by_contra! hn + exact hle hn + obtain ⟨x,hx,hxW⟩ := hex + obtain ⟨φ,hφ,hW⟩ := Submodule.exists_dual_map_eq_bot_of_notMem hxW inferInstance + refine ⟨φ,(φ x)⁻¹ • (⟨x,hx⟩ : U),?_,?_⟩ + · simp only [Submodule.coe_smul,map_smul,smul_eq_mul,inv_mul_cancel₀ hφ] + · ext w + have hz : φ w.val ∈ W.map φ := Submodule.mem_map_of_mem w.property + rw [hW] at hz + exact hz +end Separate +section Covariance +variable {K V : Type*} [Field K] [Fintype K] [DecidableEq K] + [AddCommGroup V] [Module K V] [FiniteDimensional K V] + +omit [Fintype K] [DecidableEq K] [FiniteDimensional K V] in +theorem rankOne_restrict (φ : V →ₗ[K] K) (U : Submodule K V) : + symFormPull U.subtype (rankOneForm φ) = rankOneForm (φ.comp U.subtype) := rfl + +omit [Fintype K] [DecidableEq K] [FiniteDimensional K V] in +theorem rankOne_restrict_zero (φ : V →ₗ[K] K) (W : Submodule K V) + (h : φ.comp W.subtype=0) : symFormPull W.subtype (rankOneForm φ)=0 := by + rw [rankOne_restrict,h] + apply Subtype.ext + ext x y + change (0 : K)*0=0 + ring + +theorem restriction_covariance_bound (U W : Submodule K V) + (hd : finrank K U=finrank K W) (hne : U≠W) (hK : ringChar K ≠ 2) + {ξ ζ : ℤ} (hξ : ξ=1 ∨ ξ= -1) : + |uniformMean (fun Q : SymForm K V => + (formSignIndicator ξ (symFormPull U.subtype Q)-1/2) * + (formSignIndicator ζ (symFormPull W.subtype Q)-1/2))| ≤ + (finrank K U : ℝ)/(Fintype.card K : ℝ) := by + obtain ⟨φ,x,hx,hW⟩ := equal_dimension_separating_dual U W hd hne + let f : SymForm K V → ℝ := fun Q => formSignIndicator ξ (symFormPull U.subtype Q)-1/2 + let g : SymForm K V → ℝ := fun Q => formSignIndicator ζ (symFormPull W.subtype Q)-1/2 + let R := rankOneForm φ + let φU := φ.comp U.subtype + have hxU : φU x=1 := hx + have hg (Q : SymForm K V) (a : K) : g (Q+a • R)=g Q := by + dsimp [g] + rw [map_add,map_smul,rankOne_restrict_zero φ W hW,smul_zero,add_zero] + have he : uniformMean (fun Q => f Q*g Q) = + uniformMean (fun Q => (uniformMean fun a : K => f (Q+a • R))*g Q) := by + rw [←uniformMean_average_translate (fun Q => f Q*g Q) (fun a : K => a • R)] + apply uniformMean_congr + intro Q + simp only [hg] + have h := uniformMean_mul (g Q) (fun a : K => f (Q+a • R)) + simpa only [mul_comm] using h + have hf (Q : SymForm K V) : |uniformMean fun a : K => f (Q+a • R)| ≤ + formSingularIndicator (symFormPull φU.ker.subtype (symFormPull U.subtype Q))+ + 1/(Fintype.card K : ℝ) := by + dsimp only [f] + simp only [map_add,map_smul] + rw [uniformMean_sub,uniformMean_const] + exact rankOne_shift_error φU x hxU (symFormPull U.subtype Q) hK hξ + have hgs (Q : SymForm K V) : |g Q| ≤ 1 := centered_formSign_abs ζ _ + change |uniformMean (fun Q => f Q*g Q)| ≤ _ + rw [he] + calc + _ ≤ uniformMean (fun Q => |(uniformMean fun a : K => f (Q+a • R))*g Q|) := abs_uniformMean_le _ + _ ≤ uniformMean (fun Q => formSingularIndicator + (symFormPull φU.ker.subtype (symFormPull U.subtype Q))+1/(Fintype.card K : ℝ)) := by + apply uniformMean_mono + intro Q + rw [abs_mul] + calc + _ ≤ |uniformMean fun a : K => f (Q+a • R)| * 1 := + mul_le_mul_of_nonneg_left (hgs Q) (abs_nonneg _) + _ ≤ _ := by simpa only [mul_one] using hf Q + _ = uniformMean (formSingularIndicator (K := K) (V := φU.ker))+ + 1/(Fintype.card K : ℝ) := by + rw [uniformMean_add,uniformMean_const] + rw [uniformMean_restrict U.subtype U.subtype_injective + (fun T => formSingularIndicator (symFormPull φU.ker.subtype T)), + uniformMean_restrict φU.ker.subtype φU.ker.subtype_injective] + _ ≤ (finrank K φU.ker : ℝ)/(Fintype.card K : ℝ)+1/(Fintype.card K : ℝ) := + add_le_add formSingularMean_bound le_rfl + _ = _ := by + rw [←add_div,←Nat.cast_one,←Nat.cast_add,dualKer_finrank φU x hxU] +end Covariance +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section Variance +variable {A I : Type*} [Fintype A] [Fintype I] [Nonempty I] + +omit [Nonempty I] in +theorem uniformMean_square (f : I → ℝ) : + (uniformMean f)^2 = uniformMean fun i => uniformMean fun j => f i*f j := by + simp only [uniformMean_mul] + have h := uniformMean_mul (uniformMean f) f + simpa only [mul_comm,sq] using h.symm + +theorem uniformMean_abs_sq_le (f : A → ℝ) : + (uniformMean fun a => |f a|)^2 ≤ uniformMean fun a => (f a)^2 := by + simpa only [uniformMean,Finset.card_univ,sq_abs] using + (sum_div_card_sq_le_sum_sq_div_card (s := Finset.univ) (f := fun a => |f a|)) + +theorem family_variance_bound (f : I → A → ℝ) (ε : ℝ) (hε : 0≤ε) + (hb : ∀ i a, |f i a| ≤ 1) + (hc : ∀ i j, i≠j → |uniformMean fun a => f i a*f j a| ≤ ε) [Nonempty A] : + uniformMean (fun a => (uniformMean fun i => f i a)^2) ≤ ε+1/(Fintype.card I : ℝ) := by + classical + have he : uniformMean (fun a => (uniformMean fun i => f i a)^2) = + uniformMean fun i => uniformMean fun j => uniformMean fun a => f i a*f j a := by + simp only [uniformMean_square] + rw [uniformMean_swap] + apply uniformMean_congr + intro i + exact uniformMean_swap _ + rw [he] + calc + _ ≤ uniformMean (fun i => uniformMean fun j => ε+(if i=j then 1 else 0)) := by + apply uniformMean_mono + intro i + apply uniformMean_mono + intro j + by_cases hij : i=j + · subst j + simp only [ite_true] + apply (uniformMean_bound (fun a => ?_)).trans (le_add_of_nonneg_left hε) + calc + f i a*f i a ≤ |f i a| * |f i a| := le_abs_self _ |>.trans_eq (abs_mul _ _) + _ ≤ 1*1 := mul_le_mul (hb i a) (hb i a) (abs_nonneg _) (by norm_num) + _ = 1 := one_mul _ + · simp only [ite_eq_right hij,add_zero] + exact (le_abs_self _).trans (hc i j hij) + _ = _ := by + simp only [uniformMean_add,uniformMean_const] + have hi (i : I) : uniformMean (fun j : I => if i=j then (1 : ℝ) else 0) = + 1/(Fintype.card I : ℝ) := by simp [uniformMean] + simp only [hi,uniformMean_const] +end Variance +section Restriction +variable {K V I : Type*} [Field K] [Fintype K] [DecidableEq K] + [AddCommGroup V] [Module K V] [FiniteDimensional K V] [Fintype I] [Nonempty I] + +theorem restriction_family_variance (U : I → Submodule K V) (hinj : Function.Injective U) + (r : ℕ) (hd : ∀ i, finrank K (U i)=r) (hK : ringChar K ≠ 2) + {ξ : ℤ} (hξ : ξ=1 ∨ ξ= -1) : + uniformMean (fun Q : SymForm K V => + (uniformMean (fun i => formSignIndicator ξ (symFormPull (U i).subtype Q))-1/2)^2) ≤ + (r : ℝ)/(Fintype.card K : ℝ)+1/(Fintype.card I : ℝ) := by + have h := family_variance_bound + (fun i Q => formSignIndicator ξ (symFormPull (U i).subtype Q)-1/2) + ((r : ℝ)/(Fintype.card K : ℝ)) (by positivity) + (fun i Q => centered_formSign_abs ξ _) + (fun i j hij => by + have hne : U i≠U j := fun h => hij (hinj h) + simpa only [hd] using restriction_covariance_bound (U i) (U j) + ((hd i).trans (hd j).symm) hne hK hξ (ζ := ξ)) + simpa only [uniformMean_sub,uniformMean_const] using h + +theorem restriction_family_L1_sq (U : I → Submodule K V) (hinj : Function.Injective U) + (r : ℕ) (hd : ∀ i, finrank K (U i)=r) (hK : ringChar K ≠ 2) + {ξ : ℤ} (hξ : ξ=1 ∨ ξ= -1) : + (uniformMean (fun Q : SymForm K V => + |uniformMean (fun i => formSignIndicator ξ (symFormPull (U i).subtype Q))-1/2|))^2 ≤ + (r : ℝ)/(Fintype.card K : ℝ)+1/(Fintype.card I : ℝ) := + (uniformMean_abs_sq_le _).trans (restriction_family_variance U hinj r hd hK hξ) +end Restriction +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module +section AlternatingTwo +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] +abbrev AltForm := {B : LinearMap.BilinForm K V // B.IsAlt} + +instance altForm_finite [Finite K] [Finite V] : Finite (AltForm (K := K) (V := V)) := + Finite.of_injective (fun B : AltForm (K := K) (V := V) => fun x y => B.val x y) (by + intro B C h + apply Subtype.ext + ext x y + exact congrFun (congrFun h x) y) + +def altFormToMap (B : AltForm (K := K) (V := V)) : V [⋀^Fin 2]→ₗ[K] K where + toFun v := B.val (v 0) (v 1) + map_update_add' v i x y := by + fin_cases i <;> simp + map_update_smul' v i c x := by + fin_cases i <;> simp + map_eq_zero_of_eq' v i j hij hne := by + fin_cases i <;> fin_cases j <;> simp_all + · exact B.property _ + · exact B.property _ + +omit [AddCommGroup V] in +private theorem update_vec_zero (x y z : V) : Function.update ![x,y] (0 : Fin 2) z = ![z,y] := by + ext i + fin_cases i <;> simp +omit [AddCommGroup V] in +private theorem update_vec_one (x y z : V) : Function.update ![x,y] (1 : Fin 2) z = ![x,z] := by + ext i + fin_cases i <;> simp + +def mapToAltForm (f : V [⋀^Fin 2]→ₗ[K] K) : AltForm (K := K) (V := V) := + ⟨{ toFun := fun x => { + toFun := fun y => f ![x,y] + map_add' := fun y z => by + simpa only [update_vec_zero, update_vec_one, smul_eq_mul, RingHom.id_apply] using f.map_update_add ![x,(0:V)] (1 : Fin 2) y z + map_smul' := fun c y => by + simpa only [update_vec_zero, update_vec_one, smul_eq_mul, RingHom.id_apply] using f.map_update_smul ![x,(0:V)] (1 : Fin 2) c y } + map_add' := fun x y => by + ext z + change f ![x+y,z] = f ![x,z]+f ![y,z] + simpa only [update_vec_zero, update_vec_one, smul_eq_mul, RingHom.id_apply] using f.map_update_add ![(0:V),z] (0 : Fin 2) x y + map_smul' := fun c x => by + ext z + change f ![c • x,z] = c * f ![x,z] + simpa only [update_vec_zero, update_vec_one, smul_eq_mul, RingHom.id_apply] using f.map_update_smul ![(0:V),z] (0 : Fin 2) c x }, + fun x => f.map_eq_zero_of_eq ![x,x] (by simp : (![x,x] : Fin 2 → V) 0 = ![x,x] 1) (by decide : (0 : Fin 2) ≠ 1)⟩ + +def altFormMapEquiv : AltForm (K := K) (V := V) ≃ (V [⋀^Fin 2]→ₗ[K] K) where + toFun := altFormToMap + invFun := mapToAltForm + left_inv B := by apply Subtype.ext; ext x y; rfl + right_inv f := by + ext v + change f ![v 0,v 1] = f v + congr 1 + ext i + fin_cases i <;> rfl + +variable [FiniteDimensional K V] [Fintype K] +theorem altForm_card : Nat.card (AltForm (K := K) (V := V)) = + Fintype.card K ^ (finrank K V).choose 2 := by + rw [Nat.card_congr (altFormMapEquiv (K := K) (V := V)), + Nat.card_congr (exteriorPower.alternatingMapLinearEquiv (R := K) (M := V) (N := K) (n := 2)).toEquiv] + rw [Module.natCard_eq_pow_finrank (K := K), Subspace.dual_finrank_eq, exteriorPower.finrank_eq, + Nat.card_eq_fintype_card] +end AlternatingTwo +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module +section OrthogonalCharts +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] +def canonicalOrthogonal : LinearMap.BilinForm K (V × Module.Dual K V) where + toFun p := { + toFun := fun q => q.2 p.1 + p.2 q.1 + map_add' := by intros; simp; ring + map_smul' := by intros; simp; ring } + map_add' := by + intro p q + apply LinearMap.ext + intro z + change z.2 (p.1+q.1) + (p.2+q.2) z.1 = + (z.2 p.1 + p.2 z.1) + (z.2 q.1 + q.2 z.1) + simp + ring + map_smul' := by + intro a p + apply LinearMap.ext + intro z + change z.2 (a • p.1) + (a • p.2) z.1 = a * (z.2 p.1+p.2 z.1) + simp + ring + +@[simp] theorem canonicalOrthogonal_apply (p q : V × Module.Dual K V) : + canonicalOrthogonal p q = q.2 p.1 + p.2 q.1 := rfl + + theorem canonicalOrthogonal_symm : (canonicalOrthogonal (K := K) (V := V)).IsSymm := by + constructor + intro p q + simp only [canonicalOrthogonal_apply, add_comm] + + theorem canonicalOrthogonal_nondegenerate : + (canonicalOrthogonal (K := K) (V := V)).Nondegenerate := by + have hleft : ∀ p : V × Module.Dual K V, + (∀ q, canonicalOrthogonal p q = 0) → p = 0 := by + rintro ⟨x,f⟩ hp + have hx : x = 0 := (Module.forall_dual_apply_eq_zero_iff K x).mp (fun g => by + simpa using hp (0,g)) + have hf : f = 0 := by + ext y + simpa using hp (y,0) + simp [hx,hf] + refine ⟨hleft, ?_⟩ + intros p hp + apply hleft + intro q + exact canonicalOrthogonal_symm.isRefl _ _ (hp q) + +variable [FiniteDimensional K V] +/-- MaxOrthogonals are self-orthogonal subspaces, equivalently isotropic +subspaces of half the ambient dimension. -/ +abbrev MaxOrthogonal := {L : Submodule K (V × Module.Dual K V) // + canonicalOrthogonal.orthogonal L = L} + + theorem maxOrthogonal_finrank (L : MaxOrthogonal (K := K) (V := V)) : + finrank K L.val = finrank K V := by + have h := LinearMap.BilinForm.finrank_orthogonal canonicalOrthogonal_nondegenerate L.val + rw [L.property, Module.finrank_prod, Subspace.dual_finrank_eq] at h + have hle := Submodule.finrank_le L.val + rw [Module.finrank_prod, Subspace.dual_finrank_eq] at hle + omega + + +omit [FiniteDimensional K V] in + theorem formGraph_orthogonal_isotropic (U : Submodule K V) (B : AltForm (K := K) (V := U)) : + formGraph U B.val ≤ canonicalOrthogonal.orthogonal (formGraph U B.val) := by + rintro p ⟨u,hu,hf⟩ q ⟨v,hv,hg⟩ + change p.2 q.1 + q.2 p.1 = 0 + rw [←hu,←hv] + have hf' := congrArg (fun l : Module.Dual K U => l v) hf + have hg' := congrArg (fun l : Module.Dual K U => l u) hg + change p.2 v.val = B.val u v at hf' + change q.2 u.val = B.val v u at hg' + rw [hf',hg',← B.property.neg_eq u v] + exact add_neg_cancel _ + +noncomputable def graphMaxOrthogonal (U : Submodule K V) (B : AltForm (K := K) (V := U)) : + MaxOrthogonal (K := K) (V := V) := + ⟨formGraph U B.val, by + apply (Submodule.eq_of_le_of_finrank_eq (formGraph_orthogonal_isotropic U B) _).symm + rw [formGraph_finrank, LinearMap.BilinForm.finrank_orthogonal canonicalOrthogonal_nondegenerate, + Module.finrank_prod, Subspace.dual_finrank_eq, formGraph_finrank, Nat.add_sub_cancel_left]⟩ + + theorem graphMaxOrthogonal_form_injective (U : Submodule K V) : + Function.Injective (graphMaxOrthogonal (K := K) U) := by + intro B C h + apply Subtype.ext + apply LinearMap.ext + intro u + obtain ⟨f,hf⟩ := Subspace.dualRestrict_surjective (W := U) (B.val u) + have hp : (u.val,f) ∈ formGraph U B.val := ⟨u,rfl,hf⟩ + have he : formGraph U B.val = formGraph U C.val := congrArg Subtype.val h + rw [he] at hp + obtain ⟨v,hv,hg⟩ := hp + have hv' : v = u := Subtype.ext hv + exact hf.symm.trans (hv' ▸ hg) + +omit [FiniteDimensional K V] in + theorem maxOrthogonal_pairing_zero (L : MaxOrthogonal (K := K) (V := V)) + {p q : V × Module.Dual K V} (hp : p ∈ L.val) (hq : q ∈ L.val) : + canonicalOrthogonal p q = 0 := by + have hq' : q ∈ canonicalOrthogonal.orthogonal L.val := L.property.symm ▸ hq + exact hq' p hp + + theorem graphMaxOrthogonal_surjective (hK : ringChar K ≠ 2) : + Function.Surjective (fun S : Σ U : Submodule K V, AltForm (K := K) (V := U) => graphMaxOrthogonal S.1 S.2) := by + intro L + let U := L.val.map (LinearMap.fst K V (Module.Dual K V)) + let p : L.val →ₗ[K] U := { + toFun := fun x => ⟨x.val.1, ⟨x.val,x.property,rfl⟩⟩ + map_add' := fun _ _ => rfl + map_smul' := fun _ _ => rfl } + have hp : Function.Surjective p := by + rintro ⟨x,y,hy,hyx⟩ + exact ⟨⟨y,hy⟩,Subtype.ext hyx⟩ + obtain ⟨s,hs⟩ := p.exists_rightInverse_of_surjective (LinearMap.range_eq_top.mpr hp) + have hsfst (u : U) : (s u).val.1 = u.val := congrArg Subtype.val (LinearMap.congr_fun hs u) + let C : LinearMap.BilinForm K U := + (((LinearMap.snd K V (Module.Dual K V)).comp L.val.subtype).comp s).compl₂ U.subtype + have hC : C.IsAlt := by + intro u + have h := maxOrthogonal_pairing_zero L (s u).property (s u).property + change (s u).val.2 (s u).val.1 + (s u).val.2 (s u).val.1 = 0 at h + rw [hsfst] at h + change C u u + C u u = 0 at h + exact (mul_eq_zero.mp ((two_mul (C u u)).trans h)).resolve_left (Ring.two_ne_zero hK) + refine ⟨⟨U,⟨C,hC⟩⟩, ?_⟩ + apply Subtype.ext + symm + apply Submodule.eq_of_le_of_finrank_eq + · intro x hx + let u : U := ⟨x.1,⟨x,hx,rfl⟩⟩ + refine ⟨u,rfl,?_⟩ + apply LinearMap.ext + intro y + have h := maxOrthogonal_pairing_zero L hx (s y).property + change (s y).val.2 x.1 + x.2 (s y).val.1 = 0 at h + rw [hsfst] at h + change x.2 y.val = (s u).val.2 y.val + have hh : x.2 y.val = -(s y).val.2 u.val := (eq_neg_iff_add_eq_zero.mpr (by simpa only [add_comm] using h)) + exact hh.trans (hC.neg_eq y u) + · exact (maxOrthogonal_finrank L).trans (formGraph_finrank U C).symm + +noncomputable def maxOrthogonalGraphEquiv (hK : ringChar K ≠ 2) : + (Σ U : Submodule K V, AltForm (K := K) (V := U)) ≃ MaxOrthogonal (K := K) (V := V) := + Equiv.ofBijective (fun S => graphMaxOrthogonal S.1 S.2) ⟨by + rintro ⟨U,B⟩ ⟨W,C⟩ he + have h : U = W := by + rw [← formGraph_fst_range U B.val, ← formGraph_fst_range W C.val] + exact congrArg (fun L : MaxOrthogonal (K := K) (V := V) => + L.val.map (LinearMap.fst K V (Module.Dual K V))) he + cases h + congr 1 + exact graphMaxOrthogonal_form_injective U he, + graphMaxOrthogonal_surjective hK⟩ + +/-- Exact chart decomposition count: the vertical-annihilator stratum is +retained rather than discarded as a negligible exceptional event. -/ + theorem maxOrthogonal_card_sum [Fintype K] [Finite V] (hK : ringChar K ≠ 2) : + letI := Fintype.ofFinite (Submodule K V) + Nat.card (MaxOrthogonal (K := K) (V := V)) = + ∑ U : Submodule K V, (Fintype.card K)^((finrank K U).choose 2) := by + classical + let := Fintype.ofFinite (Submodule K V) + rw [← Nat.card_congr (maxOrthogonalGraphEquiv (K := K) (V := V) hK), Nat.card_sigma] + simp only [altForm_card] + +end OrthogonalCharts +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module +section SplitSign +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + + theorem canonicalOrthogonal_matrix {ι : Type*} [Fintype ι] [DecidableEq ι] + (b : Basis ι K V) : + canonicalOrthogonal.toMatrix (b.prod b.dualBasis) = + Matrix.fromBlocks (0 : Matrix ι ι K) 1 1 0 := by + ext i j + cases i <;> cases j <;> + simp [LinearMap.BilinForm.toMatrix_apply, Basis.prod_apply, Matrix.one_apply, + Finsupp.single_apply, eq_comm] + + theorem hyperbolic_block_det {ι : Type*} [Fintype ι] [DecidableEq ι] : + (Matrix.fromBlocks (0 : Matrix ι ι K) (1 : Matrix ι ι K) (1 : Matrix ι ι K) 0).det = (-1 : K) ^ Fintype.card ι := by + have hmul : Matrix.fromBlocks (0 : Matrix ι ι K) (1 : Matrix ι ι K) (1 : Matrix ι ι K) 0 * + Matrix.fromBlocks (1 : Matrix ι ι K) (1 : Matrix ι ι K) (0 : Matrix ι ι K) 1 = + Matrix.fromBlocks (0 : Matrix ι ι K) (1 : Matrix ι ι K) (1 : Matrix ι ι K) 1 := by + rw [Matrix.fromBlocks_multiply] + simp + have h := congrArg Matrix.det hmul + rw [Matrix.det_mul, Matrix.det_fromBlocks_zero₂₁, Matrix.det_one, one_mul, + mul_one, Matrix.det_fromBlocks_one₂₂] at h + simpa only [Matrix.one_mul, zero_sub, Matrix.det_neg, Matrix.det_one, mul_one] using h + +variable [FiniteDimensional K V] [Fintype K] [DecidableEq K] + theorem canonicalOrthogonal_sign : + discriminantSign (canonicalOrthogonal (K := K) (V := V)) canonicalOrthogonal_symm = + quadraticChar K ((-1 : K) ^ finrank K V) := by + rw [discriminantSign_nondegenerate _ _ canonicalOrthogonal_nondegenerate + ((Module.finBasis K V).prod (Module.finBasis K V).dualBasis), + canonicalOrthogonal_matrix, hyperbolic_block_det, Fintype.card_fin] + + theorem split_form_equivalent {E : Type*} [AddCommGroup E] [Module K E] + [FiniteDimensional K E] (B : LinearMap.BilinForm K E) + (hs : B.IsSymm) (hB : B.Nondegenerate) (hK : ringChar K ≠ 2) + (r : ℕ) (hd : finrank K E = 2*r) + (hc : discriminantSign B hs = quadraticChar K ((-1 : K)^r)) : + BilinEquivalent B (canonicalOrthogonal (K := K) (V := Fin r → K)) := by + apply symmetric_equivalent_of_dim_sign B _ hs canonicalOrthogonal_symm hB + canonicalOrthogonal_nondegenerate hK + · simpa only [Module.finrank_prod, Subspace.dual_finrank_eq, Module.finrank_pi, + Fintype.card_fin, two_mul] using hd + · simpa only [canonicalOrthogonal_sign, Module.finrank_pi, Fintype.card_fin] using hc + + theorem split_form_card {E : Type*} [AddCommGroup E] [Module K E] + [FiniteDimensional K E] (B : LinearMap.BilinForm K E) + (hs : B.IsSymm) (hB : B.Nondegenerate) (hK : ringChar K ≠ 2) + (r : ℕ) (hd : finrank K E = 2*r) + (hc : discriminantSign B hs = quadraticChar K ((-1 : K)^r)) : + Nat.card (SymplecticLagrangian B) = + Nat.card (MaxOrthogonal (K := K) (V := Fin r → K)) := by + obtain ⟨e,he⟩ := split_form_equivalent B hs hB hK r hd hc + exact Nat.card_congr (symplecticLagrangianEquiv _ _ e he) +end SplitSign +end SidorenkoCounterexample + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/SignMoments.lean b/lean/OAI/Combinatorics/Sidorenko/SignMoments.lean new file mode 100644 index 0000000000000000000000000000000000000000..5e6775514d3b64f735e357f497122bc03e28eb98 --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/SignMoments.lean @@ -0,0 +1,659 @@ +import OAI.Combinatorics.Sidorenko.LocalMoments + +namespace OAI + + +section + +namespace SidorenkoCounterexample +open scoped BigOperators +open Module +section Gauss +variable {K V : Type*} [Field K] [Fintype K] + [AddCommGroup V] [Module K V] [Fintype V] + + theorem char_conj (ψ : AddChar K ℂ) (a : K) : + star (ψ a) = (ψ a)⁻¹ := (Complex.inv_eq_conj (ψ.norm_apply a)).symm + +omit [Module K V] in + theorem character_differencing (ψ : AddChar K ℂ) (f : V → K) : + ‖∑ x, ψ (f x)‖ ^ 2 = ‖∑ u, ∑ z, ψ (f (z+u) - f z)‖ := by + classical + have h : (∑ u, ∑ z, ψ (f (z+u) - f z)) = + (∑ x, ψ (f x)) * star (∑ x, ψ (f x)) := by + simp only [AddChar.map_sub_eq_div, div_eq_mul_inv, ← char_conj] + rw [Finset.sum_comm] + simp only [← Finset.sum_mul] + have ht (z : V) : (∑ u, ψ (f (z+u))) = ∑ x, ψ (f x) := + Fintype.sum_equiv (Equiv.addLeft z) _ _ (fun _ => rfl) + simp only [ht, ← Finset.mul_sum, star_sum] + rw [h, norm_mul, norm_star, pow_two] + +omit [Fintype K] in + theorem linear_character_sum_zero (ψ : AddChar K ℂ) (hψ : ψ ≠ 0) + (f : V →ₗ[K] K) (hf : f ≠ 0) : ∑ x, ψ (f x) = 0 := by + classical + have hsurj : Function.Surjective f := by + have hex : ∃ x, f x ≠ 0 := by + by_contra! h + exact hf (LinearMap.ext h) + obtain ⟨x, hx⟩ := hex + intro a + refine ⟨(a / f x) • x, ?_⟩ + simp [hx] + change ∑ x, (ψ.compAddMonoidHom f.toAddMonoidHom) x = 0 + apply AddChar.sum_eq_zero_iff_ne_zero.mpr + intro heq + apply hψ + ext a + obtain ⟨x, rfl⟩ := hsurj a + exact congrArg (fun χ : AddChar V ℂ => χ x) heq + +omit [Fintype K] [Fintype V] in +/-- Exact one-step differencing for a symmetric quadratic polynomial. -/ + theorem quadratic_difference (B : LinearMap.BilinForm K V) (hB : B.IsSymm) + (l : V →ₗ[K] K) (c : K) (z u : V) : + (B (z+u) (z+u) + l (z+u) + c) - (B z z + l z + c) = + B u u + l u + (2 : K) * B u z := by + simp only [map_add, LinearMap.add_apply, hB.eq z u] + ring + +/-- The raw quadratic Gauss bound, with arbitrary linear and constant terms. +Its right side is exactly |V| times the size of the radical. -/ + theorem quadratic_gauss_bound (ψ : AddChar K ℂ) (hψ : ψ ≠ 0) + (hodd : (2 : K) ≠ 0) (B : LinearMap.BilinForm K V) (hB : B.IsSymm) + (l : V →ₗ[K] K) (c : K) : + ‖∑ x, ψ (B x x + l x + c)‖ ^ 2 ≤ + (Fintype.card V : ℝ) * Nat.card B.ker := by + classical + rw [character_differencing] + simp only [quadratic_difference B hB, AddChar.map_add_eq_mul] + have hi (u : V) : (∑ z, ψ ((2:K) * B u z)) = + if u ∈ B.ker then (Fintype.card V : ℂ) else 0 := by + by_cases hu : u ∈ B.ker + · have hz : B u = 0 := LinearMap.mem_ker.mp hu + simp [hu, hz] + · rw [ite_eq_right hu] + exact linear_character_sum_zero ψ hψ ((2:K) • B u) (by + intro heq + apply hu + apply LinearMap.mem_ker.mpr + exact (smul_eq_zero.mp heq).resolve_left hodd) + simp only [← Finset.mul_sum, hi] + calc + ‖∑ u, ψ (B u u) * ψ (l u) * + (if u ∈ B.ker then (Fintype.card V : ℂ) else 0)‖ ≤ + ∑ u, ‖ψ (B u u) * ψ (l u) * + (if u ∈ B.ker then (Fintype.card V : ℂ) else 0)‖ := norm_sum_le _ _ + _ = (Fintype.card V : ℝ) * Nat.card B.ker := by + simp only [norm_mul, AddChar.norm_apply, one_mul] + simp only [apply_ite norm, Complex.norm_natCast, norm_zero] + rw [Finset.sum_ite, Finset.sum_const_zero, add_zero, + Finset.sum_const, nsmul_eq_mul] + rw [mul_comm] + congr 1 + rw [Nat.card_eq_fintype_card] + simp [Fintype.card_subtype] + + + + theorem normalized_quadratic_gauss_bound (ψ : AddChar K ℂ) (hψ : ψ ≠ 0) + (hodd : (2 : K) ≠ 0) (B : LinearMap.BilinForm K V) (hB : B.IsSymm) + (l : V →ₗ[K] K) (c : K) : + ‖(Fintype.card V : ℂ)⁻¹ * ∑ x, ψ (B x x + l x + c)‖ ^ 2 ≤ + 1 / (Fintype.card K : ℝ) ^ finrank K B.range := by + classical + have h := quadratic_gauss_bound ψ hψ hodd B hB l c + have hv : (0 : ℝ) < Fintype.card V := by exact_mod_cast Fintype.card_pos + have hk : (0 : ℝ) < Fintype.card K := by exact_mod_cast Fintype.card_pos + have hc : (Fintype.card V : ℝ) = + (Fintype.card K : ℝ) ^ finrank K B.range * Nat.card B.ker := by + rw [Nat.card_eq_fintype_card, Module.card_eq_pow_finrank (K := K) (V := V), + Module.card_eq_pow_finrank (K := K) (V := B.ker)] + push_cast + rw [← pow_add, B.finrank_range_add_finrank_ker] + simp only [norm_mul, norm_inv, Complex.norm_natCast, mul_pow] + calc + (Fintype.card V : ℝ)⁻¹ ^ 2 * ‖∑ x, ψ (B x x + l x + c)‖ ^ 2 ≤ + (Fintype.card V : ℝ)⁻¹ ^ 2 * + ((Fintype.card V : ℝ) * Nat.card B.ker) := + mul_le_mul_of_nonneg_left h (sq_nonneg _) + _ = 1 / (Fintype.card K : ℝ) ^ finrank K B.range := by + have hp := pow_pos hk (finrank K B.range) + field_simp + nlinarith [hc] + +end Gauss +section Fourier +variable {K ι : Type*} [Field K] [Fintype K] [Fintype ι] [DecidableEq ι] [DecidableEq K] + +noncomputable def coordinatePairing (v : ι → K) : (ι → K) →ₗ[K] K where + toFun t := t ⬝ᵥ v + map_add' := fun _ _ => add_dotProduct _ _ _ + map_smul' := fun _ _ => smul_dotProduct _ _ _ + + theorem coordinate_character_sum (ψ : AddChar K ℂ) (hψ : ψ ≠ 0) + (v : ι → K) : + ∑ t : ι → K, ψ (t ⬝ᵥ v) = if v = 0 then (Fintype.card (ι → K) : ℂ) else 0 := by + classical + split_ifs with hv + · simp [hv] + · apply linear_character_sum_zero ψ hψ (coordinatePairing v) + intro h + apply hv + apply dotProduct_eq_zero_iff.mp + intro t + simpa [coordinatePairing, dotProduct_comm] using + congrArg (fun f : (ι → K) →ₗ[K] K => f t) h + +noncomputable def finiteFourier (ψ : AddChar K ℂ) (μ : (ι → K) → ℝ) + (t : ι → K) : ℂ := ∑ x, (μ x : ℂ) * ψ (t ⬝ᵥ x) + + theorem finite_parseval (ψ : AddChar K ℂ) (hψ : ψ ≠ 0) + (μ : (ι → K) → ℝ) : + ∑ t, ‖finiteFourier ψ μ t‖ ^ 2 = + (Fintype.card (ι → K) : ℝ) * ∑ x, (μ x)^2 := by + classical + apply Complex.ofReal_injective + have hn (z : ℂ) : ((‖z‖^2 : ℝ) : ℂ) = z * star z := by + rw [← Complex.normSq_eq_norm_sq, ← Complex.mul_conj]; rfl + have hs (x : ℝ) : star (x : ℂ) = x := by simp + simp only [Complex.ofReal_sum, Complex.ofReal_mul, hn, finiteFourier, + star_sum, star_mul, hs, + char_conj, Finset.sum_mul, Finset.mul_sum] + have he (x y : ι → K) : + (∑ t, (μ x : ℂ) * ψ (t ⬝ᵥ x) * ((ψ (t ⬝ᵥ y))⁻¹ * μ y)) = + (μ x : ℂ) * μ y * (if x = y then (Fintype.card (ι → K) : ℂ) else 0) := by + calc + _ = (μ x : ℂ) * μ y * ∑ t, ψ (t ⬝ᵥ (x-y)) := by + simp only [dotProduct_sub, AddChar.map_sub_eq_div, Finset.mul_sum] + apply Finset.sum_congr rfl + intro t _ + ring + _ = _ := by rw [coordinate_character_sum ψ hψ]; simp only [sub_eq_zero] + rw [Finset.sum_comm] + conv_lhs => enter [2, x]; rw [Finset.sum_comm] + simp only [he] + simp [Finset.sum_ite_eq', pow_two, mul_comm, mul_assoc] + + theorem finiteFourier_sub_uniform (ψ : AddChar K ℂ) (hψ : ψ ≠ 0) + (μ : (ι → K) → ℝ) (hμ : ∑ x, μ x = 1) (t : ι → K) : + finiteFourier ψ (fun x => μ x - (Fintype.card (ι → K) : ℝ)⁻¹) t = + if t = 0 then 0 else finiteFourier ψ μ t := by + classical + have hc : (Fintype.card (ι → K) : ℂ) ≠ 0 := by + exact_mod_cast Fintype.card_ne_zero + simp only [finiteFourier, Complex.ofReal_sub, sub_mul, Finset.sum_sub_distrib, + ← Finset.mul_sum, Complex.ofReal_inv, Complex.ofReal_natCast] + have hs : ∑ x : ι → K, ψ (t ⬝ᵥ x) = + if t = 0 then (Fintype.card (ι → K) : ℂ) else 0 := by + simpa only [dotProduct_comm] using coordinate_character_sum ψ hψ t + rw [hs] + split_ifs with ht + · simp [ht, ← Complex.ofReal_sum, hμ] + · simp + + + + theorem finite_fourier_l1_bound (ψ : AddChar K ℂ) (hψ : ψ ≠ 0) + (μ : (ι → K) → ℝ) (hμ : ∑ x, μ x = 1) : + (∑ x, |μ x - (Fintype.card (ι → K) : ℝ)⁻¹|)^2 ≤ + ∑ t, if t = 0 then 0 else ‖finiteFourier ψ μ t‖^2 := by + classical + have hp := finite_parseval ψ hψ (fun x => μ x - (Fintype.card (ι → K) : ℝ)⁻¹) + simp only [finiteFourier_sub_uniform ψ hψ μ hμ] at hp + have hs := Finset.sum_mul_sq_le_sq_mul_sq Finset.univ + (fun _ : ι → K => (1:ℝ)) + (fun x => |μ x - (Fintype.card (ι → K) : ℝ)⁻¹|) + simp only [one_mul, one_pow, Finset.sum_const, Finset.card_univ, + nsmul_eq_mul, mul_one, sq_abs] at hs + rw [← hp] at hs + simpa only [apply_ite norm, norm_zero, ite_pow, zero_pow (by decide : 2 ≠ 0)] using hs + + theorem finite_fourier_l1_of_uniform_bound (ψ : AddChar K ℂ) (hψ : ψ ≠ 0) + (μ : (ι → K) → ℝ) (hμ : ∑ x, μ x = 1) (ε : ℝ) (hε : 0 ≤ ε) + (hf : ∀ t ≠ 0, ‖finiteFourier ψ μ t‖ ^ 2 ≤ ε) : + (∑ x, |μ x - (Fintype.card (ι → K) : ℝ)⁻¹|)^2 ≤ + (Fintype.card (ι → K) : ℝ) * ε := by + classical + refine (finite_fourier_l1_bound ψ hψ μ hμ).trans ?_ + calc + _ ≤ ∑ _t : ι → K, ε := by + apply Finset.sum_le_sum + intro t _ + split_ifs with ht + · exact hε + · exact hf t ht + _ = _ := by simp + + +variable {Ω : Type*} [Fintype Ω] [Nonempty Ω] + +noncomputable def uniformLaw (f : Ω → ι → K) (x : ι → K) : ℝ := + (Fintype.card Ω : ℝ)⁻¹ * ∑ v, if f v = x then 1 else 0 + +omit [Field K] in + theorem uniformLaw_sum (f : Ω → ι → K) : ∑ x, uniformLaw f x = 1 := by + classical + simp only [uniformLaw, ← Finset.mul_sum] + rw [Finset.sum_comm] + simp + +omit [Field K] [Nonempty Ω] in + theorem uniformLaw_average (f : Ω → ι → K) (g : (ι → K) → ℝ) : + ∑ x, uniformLaw f x * g x = (Fintype.card Ω : ℝ)⁻¹ * ∑ v, g (f v) := by + classical + simp only [uniformLaw, mul_assoc, ← Finset.mul_sum, Finset.sum_mul] + rw [Finset.sum_comm] + congr 1 + apply Finset.sum_congr rfl + intro x _ + simp + +omit [Nonempty Ω] in + theorem finiteFourier_uniformLaw (ψ : AddChar K ℂ) (f : Ω → ι → K) (t : ι → K) : + finiteFourier ψ (uniformLaw f) t = + (Fintype.card Ω : ℂ)⁻¹ * ∑ v, ψ (t ⬝ᵥ f v) := by + classical + simp only [finiteFourier, uniformLaw, Complex.ofReal_mul, Complex.ofReal_inv, + Complex.ofReal_natCast, Complex.ofReal_sum, mul_assoc, ← Finset.mul_sum, Finset.sum_mul] + rw [Finset.sum_comm] + congr 1 + apply Finset.sum_congr rfl + intro v _ + simp only [apply_ite, Complex.ofReal_one, Complex.ofReal_zero, ite_mul, one_mul, zero_mul] + simp + +variable {V : Type*} [AddCommGroup V] [Module K V] [Fintype V] + +noncomputable def quadraticMap (B : ι → LinearMap.BilinForm K V) + (l : ι → V →ₗ[K] K) (c : ι → K) (v : V) (i : ι) : K := + B i v v + l i v + c i + +omit [Fintype K] [DecidableEq ι] [DecidableEq K] [Fintype V] in + theorem quadraticMap_frequency (B : ι → LinearMap.BilinForm K V) + (l : ι → V →ₗ[K] K) (c t : ι → K) (v : V) : + t ⬝ᵥ quadraticMap B l c v = + (∑ i, t i • B i) v v + (∑ i, t i • l i) v + ∑ i, t i * c i := by + simp [dotProduct, quadraticMap, Finset.sum_add_distrib, mul_add] + + theorem quadraticMap_fourier_bound (ψ : AddChar K ℂ) (hψ : ψ ≠ 0) + (hodd : (2:K) ≠ 0) (B : ι → LinearMap.BilinForm K V) + (hB : ∀ i, (B i).IsSymm) (l : ι → V →ₗ[K] K) (c t : ι → K) : + ‖finiteFourier ψ (uniformLaw (quadraticMap B l c)) t‖^2 ≤ + 1 / (Fintype.card K : ℝ) ^ finrank K (∑ i, t i • B i).range := by + rw [finiteFourier_uniformLaw] + simp only [quadraticMap_frequency] + apply normalized_quadratic_gauss_bound ψ hψ hodd + constructor + intro x y + simp only [LinearMap.sum_apply, LinearMap.smul_apply, smul_eq_mul] + apply Finset.sum_congr rfl + intro i _ + rw [(hB i).eq] + + + + + theorem quadraticMap_joint_l1_bound (ψ : AddChar K ℂ) (hψ : ψ ≠ 0) + (hodd : (2:K) ≠ 0) (B : ι → LinearMap.BilinForm K V) + (hB : ∀ i, (B i).IsSymm) (l : ι → V →ₗ[K] K) (c : ι → K) + (hrank : ∀ t : ι → K, t ≠ 0 → + Fintype.card ι + 1 ≤ finrank K (∑ i, t i • B i).range) : + (∑ x, |uniformLaw (quadraticMap B l c) x - + (Fintype.card (ι → K) : ℝ)⁻¹|)^2 ≤ 1 / (Fintype.card K : ℝ) := by + have hq : (1:ℝ) ≤ Fintype.card K := by exact_mod_cast Fintype.card_pos (α := K) + have hf (t : ι → K) (ht : t ≠ 0) : + ‖finiteFourier ψ (uniformLaw (quadraticMap B l c)) t‖^2 ≤ + 1 / (Fintype.card K : ℝ)^(Fintype.card ι+1) := by + refine (quadraticMap_fourier_bound ψ hψ hodd B hB l c t).trans ?_ + exact one_div_le_one_div_of_le (pow_pos (by linarith) _) + (pow_le_pow_right₀ hq (hrank t ht)) + have hh := finite_fourier_l1_of_uniform_bound ψ hψ _ + (uniformLaw_sum (quadraticMap B l c)) _ (by positivity) hf + convert hh using 1 + rw [Fintype.card_fun, Nat.cast_pow, pow_succ] + have hq0 : (Fintype.card K : ℝ) ≠ 0 := by linarith + field_simp + +end Fourier +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open scoped BigOperators +open Module +section SignMoments +variable {K ι : Type*} [Field K] [Fintype K] [DecidableEq K] + [Fintype ι] [DecidableEq ι] + +noncomputable def characterProduct (x : ι → K) : ℝ := ∏ i, (quadraticChar K (x i) : ℝ) + +omit [DecidableEq ι] in + theorem characterProduct_abs_le (x : ι → K) : |characterProduct x| ≤ 1 := by + rw [characterProduct, Finset.abs_prod] + exact Finset.prod_le_one₀ (fun _ _ => abs_nonneg _) (fun i _ => by + have h := quadraticChar_dichotomy (F := K) (a := x i) + by_cases hx : x i = 0 + · simp [hx] + · rcases h hx with h | h <;> simp [h]) + + theorem characterProduct_sum [Nonempty ι] (hodd : ringChar K ≠ 2) : + ∑ x : ι → K, characterProduct x = 0 := by + rw [show (∑ x : ι → K, characterProduct x) = + ∏ _i : ι, ∑ a : K, (quadraticChar K a : ℝ) from (Fintype.prod_sum (fun (_i : ι) (a : K) => (quadraticChar K a : ℝ))).symm] + have hz : ∑ a : K, (quadraticChar K a : ℝ) = 0 := by + exact_mod_cast quadraticChar_sum_zero hodd + rw [hz] + simp + +omit [Field K] [DecidableEq K] in + theorem bounded_test_l1 (μ ν : (ι → K) → ℝ) (g : (ι → K) → ℝ) + (hg : ∀ x, |g x| ≤ 1) : + |(∑ x, μ x * g x) - ∑ x, ν x * g x| ≤ ∑ x, |μ x-ν x| := by + rw [← Finset.sum_sub_distrib] + refine (Finset.abs_sum_le_sum_abs _ _).trans ?_ + apply Finset.sum_le_sum + intro x _ + rw [← sub_mul, abs_mul] + exact mul_le_of_le_one_right (abs_nonneg _) (hg x) + +variable {V : Type*} [AddCommGroup V] [Module K V] [Fintype V] + + + + theorem quadraticMap_character_moment [Nonempty ι] + (ψ : AddChar K ℂ) (hψ : ψ ≠ 0) (hodd : (2:K) ≠ 0) + (B : ι → LinearMap.BilinForm K V) (hB : ∀ i, (B i).IsSymm) + (l : ι → V →ₗ[K] K) (c : ι → K) + (hrank : ∀ t : ι → K, t ≠ 0 → + Fintype.card ι + 1 ≤ finrank K (∑ i, t i • B i).range) : + ((Fintype.card V : ℝ)⁻¹ * ∑ v, characterProduct (quadraticMap B l c v))^2 ≤ + 1 / (Fintype.card K : ℝ) := by + have hc : ringChar K ≠ 2 := by + intro h + apply hodd + simpa using (ringChar.spec K 2).mpr (by rw [h]) + have hz : ∑ x : ι → K, (Fintype.card (ι → K) : ℝ)⁻¹ * characterProduct x = 0 := by + rw [← Finset.mul_sum, characterProduct_sum hc, mul_zero] + have hb := bounded_test_l1 (uniformLaw (quadraticMap B l c)) + (fun _ => (Fintype.card (ι → K) : ℝ)⁻¹) characterProduct characterProduct_abs_le + rw [uniformLaw_average, hz, sub_zero] at hb + have hf := quadraticMap_joint_l1_bound ψ hψ hodd B hB l c hrank + have hh := ((sq_le_sq₀ (abs_nonneg _) (Finset.sum_nonneg (fun _ _ => abs_nonneg _))).mpr hb).trans hf + simpa only [sq_abs] using hh + +end SignMoments +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module LinearMap +open scoped Matrix BigOperators +section Mom +variable {K ι : Type*} [Field K] [Fintype K] [DecidableEq K] + [Fintype ι] [DecidableEq ι] [Nonempty ι] {N : ℕ} + +omit [Fintype K] [DecidableEq K] in +theorem matrix_form_rank (M : Matrix (Fin N) (Fin N) K) : + finrank K M.toBilin'.range=M.rank := by + rw [←matrix_radical_quotient_rank] + exact M.toBilin'.quotKerEquivRange.finrank_eq.symm + +omit [Fintype K] [DecidableEq K] in +theorem schur_polynomial (M : SymMatrix K N) (z w : Fin N → K) (a : K) : + a-(z-w) ⬝ᵥ M.val⁻¹.mulVec (z-w) = + (-M.val⁻¹.toBilin') z z + (2 • (M.val⁻¹.toBilin' w)) z + + (a-M.val⁻¹.toBilin' w w) := by + have hs := Matrix.isSymm_toBilin'_iff_isSymm.mpr M.property.inv + have he : (z-w) ⬝ᵥ M.val⁻¹.mulVec (z-w) = M.val⁻¹.toBilin' (z-w) (z-w) := by + rw [matrix_bilin_eval,M.property.inv,dotProduct_comm] + rw [he] + simp only [map_sub,LinearMap.sub_apply,LinearMap.neg_apply,LinearMap.smul_apply] + rw [hs.eq z w] + ring + +omit [Fintype K] [DecidableEq K] [DecidableEq ι] [Nonempty ι] in +theorem inverse_form_span_rank (M : ι → SymMatrix K N) (t : ι → K) : + finrank K (∑ i, t i • (-((M i).val⁻¹.toBilin'))).range = + (∑ i, t i • (M i).val⁻¹).rank := by + have he : (∑ i, t i • (-((M i).val⁻¹.toBilin'))) = + (-(∑ i, t i • (M i).val⁻¹)).toBilin' := by + simp only [map_neg,map_sum,map_smul] + apply LinearMap.ext + intro x + apply LinearMap.ext + intro y + simp + rw [he,matrix_form_rank,matrix_rank_neg] + +theorem schur_sign_moment (hodd : ringChar K≠2) + (M : ι → SymMatrix K N) (hM : ∀ i, (M i).val.det≠0) + (w : ι → Fin N → K) (a : ι → K) + (hrank : ∀ t : ι → K, t≠0 → + Fintype.card ι+1≤(∑ i, t i • (M i).val⁻¹).rank) : + (uniformMean (fun z : Fin N → K => + ∏ i, (quadraticChar K (symmetricBorder (M i) (z-w i) (a i)).val.det : ℝ)))^2 ≤ + 1/(Fintype.card K : ℝ) := by + obtain ⟨ψ,hψ⟩ := (AddChar.exists_apply_ne_zero (a := (1 : K))).mpr one_ne_zero + have hp : ψ≠0 := by intro h; apply hψ; simp [h] + have htwo : (2 : K)≠0 := by + exact Ring.two_ne_zero hodd + let B : ι → LinearMap.BilinForm K (Fin N → K) := fun i => -(M i).val⁻¹.toBilin' + let l : ι → (Fin N → K) →ₗ[K] K := fun i => 2 • ((M i).val⁻¹.toBilin' (w i)) + let c : ι → K := fun i => a i-(M i).val⁻¹.toBilin' (w i) (w i) + have hB : ∀ i, (B i).IsSymm := fun i => + (Matrix.isSymm_toBilin'_iff_isSymm.mpr (M i).property.inv).neg + have hb := quadraticMap_character_moment ψ hp htwo B hB l c (fun t ht => by + rw [inverse_form_span_rank M t]; exact hrank t ht) + have hb' : (uniformMean (fun z => characterProduct (quadraticMap B l c z)))^2 ≤ + 1/(Fintype.card K : ℝ) := by + simpa only [uniformMean,div_eq_mul_inv,mul_comm] using hb + have he (z : Fin N → K) : (∏ i, (quadraticChar K + (symmetricBorder (M i) (z-w i) (a i)).val.det : ℝ)) = + characterProduct (fun i => (M i).val.det) * characterProduct (quadraticMap B l c z) := by + unfold characterProduct + rw [←Finset.prod_mul_distrib] + apply Finset.prod_congr rfl + intro i _ + rw [symmetricBorder_det _ _ _ (hM i),map_mul,Int.cast_mul,schur_polynomial] + rfl + simp_rw [he] + rw [uniformMean_mul,mul_pow] + have hc := characterProduct_abs_le (fun i => (M i).val.det) + have hc2 : characterProduct (fun i => (M i).val.det)^2≤1 := by + simpa only [sq_abs,one_pow] using (sq_le_sq₀ (abs_nonneg _) zero_le_one).mpr hc + exact (mul_le_of_le_one_left (sq_nonneg _) hc2).trans hb' +end Mom +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module Classical +open scoped Matrix BigOperators +section Span +variable {K I : Type*} [Field K] [Fintype K] [DecidableEq K] + [Fintype I] [DecidableEq I] {N : ℕ} + +omit [Fintype K] [DecidableEq K] [DecidableEq I] in +theorem matrix_combination_form_rank (t : I → K) (Q : I → SymMatrix K N) : + finrank K (weightedCombination t (fun i => matrixFormEquiv N (Q i))).val.range = + (∑ i, t i • (Q i).val).rank := by + have he : (weightedCombination t (fun i => matrixFormEquiv N (Q i))).val = + (∑ i, t i • (Q i).val).toBilin' := by + simp only [weightedCombination, LinearMap.sum_apply, LinearMap.smul_apply, LinearMap.proj_apply] + change (symmetricFormSubmodule (K := K) (V := Fin N → K)).subtype + (∑ i, t i • matrixFormEquiv N (Q i)) = _ + calc + _ = ∑ i, (symmetricFormSubmodule (K := K) (V := Fin N → K)).subtype + (t i • matrixFormEquiv N (Q i)) := map_sum _ _ _ + _ = _ := by + simp only [map_sum,map_smul] + apply Finset.sum_congr rfl + intro i _ + exact map_smul (symmetricFormSubmodule (K := K) (V := Fin N → K)).subtype (t i) (matrixFormEquiv N (Q i)) + rw [he,matrix_form_rank] + +theorem matrix_low_rank_span_bound (s : ℕ) (hs : s ≤ N) : + uniformMean (fun Q : I → SymMatrix K N => if ∃ t : I → K, t≠0 ∧ + (∑ i, t i • (Q i).val).rank ≤ s then 1 else 0) ≤ + (Fintype.card K : ℝ)^(Fintype.card I) * + (2^(N-s)/(Fintype.card K : ℝ)^((N-s+1).choose 2)) := by + classical + let e : (I → SymMatrix K N) ≃ (I → SymForm K (Fin N → K)) := + Equiv.piCongrRight (fun _ => matrixFormEquiv N) + have hp (Q : I → SymMatrix K N) : (∃ t : I → K, t≠0 ∧ + (∑ i, t i • (Q i).val).rank ≤ s) ↔ + ∃ t : I → K, t≠0 ∧ finrank K (weightedCombination t (e Q)).val.range ≤ s := by + apply exists_congr + intro t + rw [show finrank K (weightedCombination t (e Q)).val.range = + (∑ i, t i • (Q i).val).rank from matrix_combination_form_rank t Q] + simp_rw [hp] + rw [←Function.comp_def (fun Q : I → SymForm K (Fin N → K) => if ∃ t : I → K, t≠0 ∧ + finrank K (weightedCombination t Q).val.range ≤ s then (1 : ℝ) else 0) e, + uniformMean_equiv e,uniformMean_indicator] + simpa only [Nat.card_eq_fintype_card,Module.finrank_fin_fun] using + (symmetric_low_rank_span_bound (K := K) (V := Fin N → K) (ι := I) s (by simpa using hs)) + +noncomputable def goodMinors (M : I → SymMatrix K N) : Prop := + (∀ i, (M i).val.det≠0) ∧ ∀ t : I → K, t≠0 → + Fintype.card I+1 ≤ (∑ i, t i • (M i).val⁻¹).rank + +noncomputable def minorBadBound (N s : ℕ) (q : ℝ) : ℝ := + (s : ℝ)*N/q + q^s*(2^(N-s)/q^((N-s+1).choose 2)) + +theorem badMinors_bound (hN : Fintype.card I ≤ N) : + uniformMean (fun M : I → SymMatrix K N => if goodMinors M then 0 else 1) ≤ + minorBadBound N (Fintype.card I) (Fintype.card K) := by + classical + let P (Q : I → SymMatrix K N) : Prop := ∃ t : I → K, t≠0 ∧ + (∑ i, t i • (Q i).val).rank ≤ Fintype.card I + let e : (I → SymMatrix K N) ≃ (I → SymMatrix K N) := + Equiv.piCongrRight (fun _ => symmetricInverseEquiv N) + have he (M : I → SymMatrix K N) (hM : ∀ i, (M i).val.det≠0) (i : I) : + (e M i).val=(M i).val⁻¹ := by simp [e,symmetricInverseEquiv,symmetricInverse,hM i] + have hp (M : I → SymMatrix K N) : + (if goodMinors M then (0 : ℝ) else 1) ≤ + (∑ i, if (M i).val.det=0 then 1 else 0)+(if P (e M) then 1 else 0) := by + by_cases hg : goodMinors M + · simp only [ite_eq_left hg]; positivity + · simp only [ite_eq_right hg] + by_cases hM : ∀ i, (M i).val.det≠0 + · have hr : P (e M) := by + simp only [goodMinors,not_and,not_forall] at hg + obtain ⟨t,ht⟩ := hg hM + obtain ⟨htt1,htt2⟩ := ht + refine ⟨t,htt1,?_⟩ + simp only [he M hM] + omega + simp only [ite_eq_left hr] + have : (0 : ℝ) ≤ ∑ i, if (M i).val.det=0 then (1 : ℝ) else 0 := by positivity + linarith + · push Not at hM + obtain ⟨i,hi⟩ := hM + have hb : (1 : ℝ) ≤ ∑ j, if (M j).val.det=0 then (1 : ℝ) else 0 := by + simpa only [hi,ite_true] using Finset.single_le_sum + (fun j (_ : j ∈ Finset.univ) => by positivity : ∀ j ∈ Finset.univ, 0 ≤ (if (M j).val.det=0 then (1 : ℝ) else 0)) + (Finset.mem_univ i) + exact hb.trans (le_add_of_nonneg_right (by positivity)) + apply (uniformMean_mono hp).trans + rw [uniformMean_add,uniformMean_sum] + have hs (i : I) : uniformMean (fun M : I → SymMatrix K N => if (M i).val.det=0 then (1 : ℝ) else 0) ≤ + (N : ℝ)/(Fintype.card K : ℝ) := by + rw [uniformMean_coordinate i (fun A : SymMatrix K N => if A.val.det = 0 then (1 : ℝ) else 0)] + exact symmetricSingularProb_bound (K := K) N + have hb : uniformMean (fun M => if P (e M) then (1 : ℝ) else 0) ≤ + (Fintype.card K : ℝ)^(Fintype.card I) * + (2^(N-Fintype.card I)/(Fintype.card K : ℝ)^((N-Fintype.card I+1).choose 2)) := by + rw [←Function.comp_def (fun M => if P M then (1 : ℝ) else 0) e,uniformMean_equiv] + exact matrix_low_rank_span_bound (Fintype.card I) hN + have hsum := Finset.sum_le_sum (fun i (_ : i ∈ Finset.univ) => hs i) + simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul] at hsum + unfold minorBadBound + rw [←mul_div_assoc] at hsum + exact add_le_add hsum hb +end Span +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module Classical +open scoped BigOperators +section Star +variable {K I J W : Type*} [Field K] [AddCommGroup W] [Module K W] + +def starDifference (v : I) (k : J → I) : (I → W) →ₗ[K] (J → W) where + toFun X j := X v-X (k j) + map_add' X Y := by ext j; simp only [Pi.add_apply]; abel + map_smul' c X := by ext j; simp only [Pi.smul_apply,RingHom.id_apply,smul_sub] + +theorem starDifference_surjective (v : I) (k : J → I) (hk : Function.Injective k) + (hv : ∀ j, k j≠v) : Function.Surjective (starDifference (K := K) (W := W) v k) := by + intro M + refine ⟨Function.extend k (fun j => -M j) (fun _ => 0),?_⟩ + ext j + change Function.extend k (fun j => -M j) (fun _ => (0 : W)) v- + Function.extend k (fun j => -M j) (fun _ => (0 : W)) (k j)=M j + rw [hk.extend_apply,Function.extend_apply' _ _ v (by simpa using hv)] + simp + +variable [Fintype I] [DecidableEq I] [Fintype J] [DecidableEq J] [Fintype W] +include K in +theorem uniformMean_starDifference (v : I) (k : J → I) (hk : Function.Injective k) + (hv : ∀ j, k j≠v) (f : (J → W) → ℝ) : + uniformMean (fun X : I → W => f (fun j => X v-X (k j)))=uniformMean f := + uniformMean_surjective_linear (starDifference (K := K) v k) + (starDifference_surjective v k hk hv) f +end Star +section Border +variable {K I : Type*} [Field K] [Fintype K] [DecidableEq K] [Fintype I] [DecidableEq I] + +omit [Fintype K] [DecidableEq K] in +theorem symmetricBorder_sub {N : ℕ} (W V : SymMatrix K N) (z w : Fin N → K) (a b : K) : + symmetricBorder W z a-symmetricBorder V w b=symmetricBorder (W-V) (z-w) (a-b) := by + apply Subtype.ext + ext i j + change borderRaw W.val z a (borderIndex N i) (borderIndex N j)- + borderRaw V.val w b (borderIndex N i) (borderIndex N j)= + borderRaw (W-V).val (z-w) (a-b) (borderIndex N i) (borderIndex N j) + cases borderIndex N i <;> cases borderIndex N j <;> rfl + +theorem uniformMean_pi_prod {A B : Type*} [Fintype A] [Fintype B] + (f : (I → A × B) → ℝ) : + uniformMean f=uniformMean fun a : I → A => uniformMean fun b : I → B => f (fun i => (a i,b i)) := by + rw [←uniformMean_equiv (Equiv.arrowProdEquivProdArrow I (fun _ => A) (fun _ => B)).symm, + uniformMean_prod] + rfl + +omit [DecidableEq K] in +theorem uniformMean_bordered (N : ℕ) (f : (I → SymMatrix K (N+1)) → ℝ) : + uniformMean f=uniformMean (fun W : I → SymMatrix K N => + uniformMean (fun z : I → (Fin N → K) => uniformMean (fun a : I → K => + f (fun i => symmetricBorder (W i) (z i) (a i))))) := by + rw [←uniformMean_equiv (Equiv.piCongrRight (fun _ : I => (symmetricBorderEquiv (K := K) N).symm))] + rw [uniformMean_pi_prod] + apply uniformMean_congr + intro W + rw [uniformMean_pi_prod] + rfl +end Border +end SidorenkoCounterexample + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/Signs.lean b/lean/OAI/Combinatorics/Sidorenko/Signs.lean new file mode 100644 index 0000000000000000000000000000000000000000..3250c7bd945399dc211d162b7a8d6bbd1a1df2a5 --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/Signs.lean @@ -0,0 +1,935 @@ +import OAI.Combinatorics.Sidorenko.Discriminant + +namespace OAI + + +section + +namespace SidorenkoCounterexample +open scoped BigOperators +section Scalar +variable {K : Type*} [Field K] [Fintype K] [DecidableEq K] +noncomputable def characterSignIndicator (ξ : ℤ) (a : K) : ℝ := + if quadraticChar K a = ξ then 1 else 0 + + theorem characterSignIndicator_nonneg (ξ : ℤ) (a : K) : 0 ≤ characterSignIndicator ξ a := by + unfold characterSignIndicator; split <;> norm_num + theorem characterSignIndicator_le_one (ξ : ℤ) (a : K) : characterSignIndicator ξ a ≤ 1 := by + unfold characterSignIndicator; split <;> norm_num + + theorem characterSignIndicator_formula {ξ : ℤ} (hξ : ξ = 1 ∨ ξ = -1) (a : K) : + 2 * characterSignIndicator ξ a = + (if a = 0 then 0 else 1) + (ξ : ℝ) * (quadraticChar K a : ℝ) := by + by_cases ha : a = 0 + · rcases hξ with rfl | rfl <;> simp [characterSignIndicator, ha] + · rcases quadraticChar_dichotomy ha with hc | hc <;> + rcases hξ with rfl | rfl <;> norm_num [characterSignIndicator, hc, ha] + +omit [Field K] in + theorem uniformMean_singleton (b : K) : + uniformMean (fun a : K => if a = b then 1 else 0) = 1 / (Fintype.card K : ℝ) := by + simp [uniformMean] + + theorem uniformMean_nonzero : + uniformMean (fun a : K => if a = 0 then 0 else 1) = 1 - 1 / (Fintype.card K : ℝ) := by + have h := uniformMean_sub (fun _ : K => (1 : ℝ)) (fun a => if a = 0 then 1 else 0) + simp only [uniformMean_const, uniformMean_singleton] at h + rw [← h] + apply uniformMean_congr + intro a; split <;> simp_all + + theorem uniformMean_character (hK : ringChar K ≠ 2) : + uniformMean (fun a : K => (quadraticChar K a : ℝ)) = 0 := by + unfold uniformMean + have h : (∑ a : K, (quadraticChar K a : ℝ)) = 0 := by + exact_mod_cast quadraticChar_sum_zero hK + rw [h, zero_div] + + theorem uniformMean_characterSignIndicator (hK : ringChar K ≠ 2) + {ξ : ℤ} (hξ : ξ = 1 ∨ ξ = -1) : + uniformMean (characterSignIndicator (K := K) ξ) = + (1 - 1 / (Fintype.card K : ℝ)) / 2 := by + have h := uniformMean_congr (characterSignIndicator_formula (K := K) hξ) + rw [uniformMean_mul, uniformMean_add, uniformMean_nonzero, + uniformMean_mul, uniformMean_character hK, mul_zero, add_zero] at h + linarith + + def scalarAffineEquiv (c b : K) (hc : c ≠ 0) : K ≃ K where + toFun a := c * (a-b) + invFun t := t/c+b + left_inv a := by field_simp; ring + right_inv t := by field_simp; ring + +omit [DecidableEq K] in + theorem uniformMean_affine (c b : K) (hc : c ≠ 0) (f : K → ℝ) : + uniformMean (fun a => f (c * (a-b))) = uniformMean f := + uniformMean_equiv (scalarAffineEquiv c b hc) f +end Scalar + +section MatrixSign +variable {K : Type*} [Field K] [Fintype K] [DecidableEq K] +noncomputable def symmetricSingularProb (n : ℕ) : ℝ := + uniformMean fun M : SymMatrix K n => if M.val.det = 0 then 1 else 0 +noncomputable def symmetricSignProb (n : ℕ) (ξ : ℤ) : ℝ := + uniformMean fun M : SymMatrix K n => characterSignIndicator ξ M.val.det + + theorem border_singularMean {n : ℕ} (M : SymMatrix K n) (z : Fin n → K) + (hM : M.val.det ≠ 0) : + uniformMean (fun a => if (symmetricBorder M z a).val.det = 0 then 1 else 0) = + 1 / (Fintype.card K : ℝ) := by + simp_rw [symmetricBorder_det M z _ hM, mul_eq_zero, hM, false_or, sub_eq_zero] + exact uniformMean_singleton _ + + theorem border_signMean {n : ℕ} (M : SymMatrix K n) (z : Fin n → K) + (hM : M.val.det ≠ 0) (hK : ringChar K ≠ 2) {ξ : ℤ} (hξ : ξ = 1 ∨ ξ = -1) : + uniformMean (fun a => characterSignIndicator ξ (symmetricBorder M z a).val.det) = + (1 - 1 / (Fintype.card K : ℝ)) / 2 := by + simp_rw [symmetricBorder_det M z _ hM] + rw [uniformMean_affine _ _ hM, uniformMean_characterSignIndicator hK hξ] + + theorem symmetricSingularProb_nonneg (n : ℕ) : 0 ≤ symmetricSingularProb (K := K) n := by + apply uniformMean_nonneg; intro M; split <;> norm_num + + theorem symmetricSingularProb_zero : symmetricSingularProb (K := K) 0 = 0 := by + unfold symmetricSingularProb + simp [Matrix.det_isEmpty, uniformMean] + + theorem symmetricSingularProb_succ (n : ℕ) : + symmetricSingularProb (K := K) (n+1) ≤ + symmetricSingularProb (K := K) n + 1 / (Fintype.card K : ℝ) := by + classical + unfold symmetricSingularProb + rw [← uniformMean_equiv (symmetricBorderEquiv (K := K) n).symm, + uniformMean_prod] + dsimp only [Function.comp_def, symmetricBorderEquiv, Equiv.coe_fn_symm_mk] + calc + _ ≤ uniformMean (fun M : SymMatrix K n => + (if M.val.det = 0 then 1 else 0) + 1 / (Fintype.card K : ℝ)) := by + apply uniformMean_mono + intro M + rw [uniformMean_prod] + by_cases hM : M.val.det = 0 + · simp only [hM, ite_true] + apply le_trans (show uniformMean (fun z => uniformMean (fun a => + if (symmetricBorder M z a).val.det = 0 then 1 else 0)) ≤ 1 from + uniformMean_bound fun z => uniformMean_bound fun a => by split <;> norm_num) + have : (0 : ℝ) ≤ 1 / (Fintype.card K : ℝ) := by positivity + linarith + · simp only [hM, ite_false, zero_add] + simp_rw [border_singularMean M _ hM] + exact le_of_eq (uniformMean_const _) + _ = _ := by rw [uniformMean_add, uniformMean_const] + + theorem symmetricSingularProb_bound (n : ℕ) : + symmetricSingularProb (K := K) n ≤ n / (Fintype.card K : ℝ) := by + induction n with + | zero => simp [symmetricSingularProb_zero] + | succ n ih => + calc + _ ≤ symmetricSingularProb (K := K) n + 1 / (Fintype.card K : ℝ) := + symmetricSingularProb_succ n + _ ≤ n / (Fintype.card K : ℝ) + 1 / (Fintype.card K : ℝ) := by linarith + _ = _ := by push_cast; ring + + theorem symmetricSignProb_nonneg (n : ℕ) (ξ : ℤ) : 0 ≤ symmetricSignProb (K := K) n ξ := + uniformMean_nonneg fun _ => characterSignIndicator_nonneg .. + + theorem symmetricSignProb_le_one (n : ℕ) (ξ : ℤ) : symmetricSignProb (K := K) n ξ ≤ 1 := + uniformMean_bound fun _ => characterSignIndicator_le_one .. + + theorem symmetricSignProb_succ_error (n : ℕ) (hK : ringChar K ≠ 2) + {ξ : ℤ} (hξ : ξ = 1 ∨ ξ = -1) : + |symmetricSignProb (K := K) (n+1) ξ - 1/2| ≤ + symmetricSingularProb (K := K) n + 1 / (Fintype.card K : ℝ) := by + classical + have hq : (0 : ℝ) ≤ 1 / (Fintype.card K : ℝ) := by positivity + unfold symmetricSignProb + rw [← uniformMean_equiv (symmetricBorderEquiv (K := K) n).symm, uniformMean_prod] + dsimp only [Function.comp_def, symmetricBorderEquiv, Equiv.coe_fn_symm_mk] + rw [← uniformMean_const (A := SymMatrix K n) (1/2), ← uniformMean_sub] + calc + _ ≤ uniformMean (fun M : SymMatrix K n => + |uniformMean (fun za : (Fin n → K) × K => + characterSignIndicator ξ (symmetricBorder M za.1 za.2).val.det) - 1/2|) := + abs_uniformMean_le _ + _ ≤ uniformMean (fun M : SymMatrix K n => + (if M.val.det = 0 then 1 else 0) + 1 / (Fintype.card K : ℝ)) := by + apply uniformMean_mono + intro M + rw [uniformMean_prod] + by_cases hM : M.val.det = 0 + · simp only [hM, ite_true] + have h0 := uniformMean_nonneg (fun z : Fin n → K => + uniformMean_nonneg fun a => characterSignIndicator_nonneg ξ + (symmetricBorder M z a).val.det) + have h1 := uniformMean_bound (fun z : Fin n → K => + uniformMean_bound fun a => characterSignIndicator_le_one ξ + (symmetricBorder M z a).val.det) + apply abs_le.mpr + constructor <;> linarith + · simp only [hM, ite_false, zero_add] + simp_rw [border_signMean M _ hM hK hξ] + rw [uniformMean_const] + apply abs_le.mpr + constructor <;> linarith + _ = _ := by rw [uniformMean_add, uniformMean_const]; rfl + + theorem symmetricSignProb_error (n : ℕ) (hn : 0 < n) (hK : ringChar K ≠ 2) + {ξ : ℤ} (hξ : ξ = 1 ∨ ξ = -1) : + |symmetricSignProb (K := K) n ξ - 1/2| ≤ n / (Fintype.card K : ℝ) := by + obtain ⟨m, rfl⟩ := Nat.exists_eq_succ_of_ne_zero (Nat.ne_of_gt hn) + calc + _ ≤ symmetricSingularProb (K := K) m + 1 / (Fintype.card K : ℝ) := + symmetricSignProb_succ_error m hK hξ + _ ≤ m / (Fintype.card K : ℝ) + 1 / (Fintype.card K : ℝ) := by + have := symmetricSingularProb_bound (K := K) m + linarith + _ = _ := by push_cast; ring + +end MatrixSign +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module LinearMap +section NondegSign +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] +variable [FiniteDimensional K V] [Fintype K] [DecidableEq K] +/-- For a nondegenerate form, the radical quotient definition reduces to +its ordinary determinant character in any basis. -/ +theorem discriminantSign_nondegenerate (B : LinearMap.BilinForm K V) + (hBs : B.IsSymm) (hB : B.Nondegenerate) + {ι : Type*} [Fintype ι] [DecidableEq ι] (b : Basis ι K V) : + discriminantSign B hBs = quadraticChar K (B.toMatrix b).det := by + simpa only [LinearMap.compl₁₂_id_id] using + discriminantSign_pullback B hBs hB LinearMap.id Function.surjective_id b + +end NondegSign +section SumForms +variable {K V W : Type*} [Field K] [AddCommGroup V] [Module K V] + [AddCommGroup W] [Module K W] + +def orthogonalSumForm (A : LinearMap.BilinForm K V) (B : LinearMap.BilinForm K W) : + LinearMap.BilinForm K (V × W) := + A.compl₁₂ (LinearMap.fst K V W) (LinearMap.fst K V W) + + B.compl₁₂ (LinearMap.snd K V W) (LinearMap.snd K V W) + +@[simp] theorem orthogonalSumForm_apply (A : LinearMap.BilinForm K V) + (B : LinearMap.BilinForm K W) (x y : V × W) : + orthogonalSumForm A B x y = A x.1 y.1 + B x.2 y.2 := rfl + +theorem orthogonalSumForm_isSymm (A : LinearMap.BilinForm K V) + (B : LinearMap.BilinForm K W) (hA : A.IsSymm) (hB : B.IsSymm) : + (orthogonalSumForm A B).IsSymm := by + constructor + intro x y + simp only [orthogonalSumForm_apply, hA.eq x.1 y.1, hB.eq x.2 y.2] + +theorem orthogonalSumForm_nondegenerate (A : LinearMap.BilinForm K V) + (B : LinearMap.BilinForm K W) (hA : A.Nondegenerate) (hB : B.Nondegenerate) : + (orthogonalSumForm A B).Nondegenerate := by + constructor + · intro x hx + apply Prod.ext + · apply hA.1 + intro y + simpa using hx (y, 0) + · apply hB.1 + intro y + simpa using hx (0, y) + · intro x hx + apply Prod.ext + · apply hA.2 + intro y + simpa using hx (y, 0) + · apply hB.2 + intro y + simpa using hx (0, y) + +theorem orthogonalSumForm_matrix (A : LinearMap.BilinForm K V) + (B : LinearMap.BilinForm K W) {ι κ : Type*} [Fintype ι] [Fintype κ] + [DecidableEq ι] [DecidableEq κ] (b : Basis ι K V) (c : Basis κ K W) : + (orthogonalSumForm A B).toMatrix (b.prod c) = + Matrix.fromBlocks (A.toMatrix b) 0 0 (B.toMatrix c) := by + ext i j + cases i <;> cases j <;> + simp [LinearMap.BilinForm.toMatrix_apply, Basis.prod_apply] + +variable [FiniteDimensional K V] [Fintype K] [DecidableEq K] + +/-- When the ranks add without loss and the sum is nondegenerate, determinant +characters multiply. The proof uses the actual radical quotients. -/ +theorem discriminantSign_add (A B : LinearMap.BilinForm K V) + (hA : A.IsSymm) (hB : B.IsSymm) (hS : (A+B).Nondegenerate) + (hdim : finrank K (V ⧸ A.ker) + finrank K (V ⧸ B.ker) = finrank K V) : + discriminantSign (A+B) (hA.add hB) = discriminantSign A hA * discriminantSign B hB := by + classical + let AQ := radicalQuotientForm A hA + let BQ := radicalQuotientForm B hB + let C := orthogonalSumForm AQ BQ + have hCs : C.IsSymm := orthogonalSumForm_isSymm _ _ + (radicalQuotientForm_isSymm A hA) (radicalQuotientForm_isSymm B hB) + have hC : C.Nondegenerate := orthogonalSumForm_nondegenerate _ _ + (radicalQuotientForm_nondegenerate A hA) (radicalQuotientForm_nondegenerate B hB) + let f : V →ₗ[K] (V ⧸ A.ker) × (V ⧸ B.ker) := A.ker.mkQ.prod B.ker.mkQ + have hfi : Function.Injective f := by + apply LinearMap.ker_eq_bot.mp + apply bot_unique + intro x hx + change f x = 0 at hx + have ha : A x = 0 := (Submodule.Quotient.mk_eq_zero A.ker).mp (congrArg Prod.fst hx) + have hb : B x = 0 := (Submodule.Quotient.mk_eq_zero B.ker).mp (congrArg Prod.snd hx) + apply hS.1 + intro y + simp only [LinearMap.add_apply, ha, hb, LinearMap.zero_apply, add_zero] + have hfs : Function.Surjective f := + (LinearMap.injective_iff_surjective_of_finrank_eq_finrank (by + simpa only [Module.finrank_prod] using hdim.symm)).mp hfi + have he : C.compl₁₂ f f = A+B := by ext x y; rfl + let b := Module.finBasis K (V ⧸ A.ker) + let c := Module.finBasis K (V ⧸ B.ker) + have hs := discriminantSign_pullback C hCs hC f hfs (b.prod c) + simp only [he] at hs + rw [hs] + change quadraticChar K ((orthogonalSumForm AQ BQ).toMatrix (b.prod c)).det = _ + rw [orthogonalSumForm_matrix, Matrix.det_fromBlocks_zero₂₁, map_mul] + rfl + +end SumForms +section PairSign +variable {K n : Type*} [Field K] [Fintype n] [DecidableEq n] +variable [Fintype K] [DecidableEq K] + + +theorem half_rank_pair_sign (r : ℕ) (hdim : Fintype.card n = 2*r) + (A B : Matrix n n K) (hAs : A.IsSymm) (hBs : B.IsSymm) + (hB : B.det ≠ 0) (hAr : A.rank = r) (hCr : (A-B).rank = r) : + quadraticChar K B.det = quadraticChar K ((-1 : K)^r) * + discriminantSign A.toBilin' (Matrix.isSymm_toBilin'_iff_isSymm.mpr hAs) * + discriminantSign (A-B).toBilin' (Matrix.isSymm_toBilin'_iff_isSymm.mpr (hAs.sub hBs)) := by + classical + have hAs' := Matrix.isSymm_toBilin'_iff_isSymm.mpr hAs + have hCs' := Matrix.isSymm_toBilin'_iff_isSymm.mpr (hBs.sub hAs) + have hadd : A.toBilin' + (B-A).toBilin' = B.toBilin' := by + rw [← map_add, add_sub_cancel] + have hBs' := Matrix.isSymm_toBilin'_iff_isSymm.mpr hBs + have hBnd : B.toBilin'.Nondegenerate := + LinearMap.BilinForm.nondegenerate_toBilin'_iff_det_ne_zero.mpr hB + have hdim' : finrank K ((n → K) ⧸ A.toBilin'.ker) + + finrank K ((n → K) ⧸ (B-A).toBilin'.ker) = finrank K (n → K) := by + rw [matrix_radical_quotient_rank, matrix_radical_quotient_rank, + show B-A = -(A-B) by abel, matrix_rank_neg, hAr, hCr, Module.finrank_pi, hdim] + omega + have hs := discriminantSign_add A.toBilin' (B-A).toBilin' hAs' hCs' + (hadd.symm ▸ hBnd) hdim' + simp only [hadd] at hs + have hb := discriminantSign_nondegenerate B.toBilin' hBs' hBnd (Pi.basisFun K n) + have hb' : discriminantSign B.toBilin' hBs' = quadraticChar K B.det := by + simpa only [show B.toBilin'.toMatrix (Pi.basisFun K n) = B from + LinearMap.BilinForm.toMatrix'_toBilin' B] using hb + rw [hb'] at hs + have hn := discriminantSign_neg (A-B).toBilin' + (Matrix.isSymm_toBilin'_iff_isSymm.mpr (hAs.sub hBs)) + rw [matrix_radical_quotient_rank, hCr] at hn + have hneg : -(A-B).toBilin' = (B-A).toBilin' := by + rw [show B-A = -(A-B) by abel, map_neg] + simp only [hneg] at hn + rw [hs, hn] + ring +end PairSign +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module LinearMap +section RadicalCount +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] [Fintype K] [DecidableEq K] + +omit [Fintype K] [DecidableEq K] in + theorem symFormQuotient_nondegenerate_iff (U : Submodule K V) (C : SymForm K (V ⧸ U)) : + (C.val.compl₁₂ U.mkQ U.mkQ).ker = U ↔ C.val.Nondegenerate := by + constructor + · intro h + apply LinearMap.BilinForm.nondegenerate_iff_ker_eq_bot.mpr + apply bot_unique + intro x hx + obtain ⟨y, rfl⟩ := U.mkQ_surjective x + apply (Submodule.Quotient.mk_eq_zero U).mpr + rw [← h] + apply LinearMap.mem_ker.mpr + ext z + exact congrArg (fun f => f (U.mkQ z)) hx + · intro h + rw [pullback_ker C.val h U.mkQ U.mkQ_surjective, Submodule.ker_mkQ] + + theorem discriminantSign_pullback_nondegenerate (U : Submodule K V) + (C : SymForm K (V ⧸ U)) (hC : C.val.Nondegenerate) : + discriminantSign (C.val.compl₁₂ U.mkQ U.mkQ) + (pullback_isSymm C.val C.property U.mkQ) = discriminantSign C.val C.property := by + rw [discriminantSign_pullback C.val C.property hC U.mkQ U.mkQ_surjective + (Module.finBasis K (V ⧸ U)), + discriminantSign_nondegenerate C.val C.property hC (Module.finBasis K (V ⧸ U))] + +noncomputable def signedRadicalFiberEquiv (U : Submodule K V) (ξ : ℤ) : + {B : SymForm K V // B.val.ker = U ∧ discriminantSign B.val B.property = ξ} ≃ + {C : SymForm K (V ⧸ U) // C.val.Nondegenerate ∧ + discriminantSign C.val C.property = ξ} := by + let e : {B : SymForm K V // B.val.ker = U ∧ discriminantSign B.val B.property = ξ} ≃ + {B : {B : SymForm K V // U ≤ B.val.ker} // + B.val.val.ker = U ∧ discriminantSign B.val.val B.val.property = ξ} := + { toFun := fun B => ⟨⟨B.val, le_of_eq B.property.1.symm⟩, B.property⟩ + invFun := fun B => ⟨B.val.val, B.property⟩ + left_inv := fun _ => rfl + right_inv := fun _ => rfl } + refine e.trans ((formRadicalEquiv U).subtypeEquiv ?_) + intro B + let C := formRadicalEquiv U B + have hback : C.val.compl₁₂ U.mkQ U.mkQ = B.val.val := rfl + have hn : B.val.val.ker = U ↔ C.val.Nondegenerate := by + rw [← hback]; exact symFormQuotient_nondegenerate_iff U C + constructor + · rintro ⟨hB,hξ⟩ + have hC := hn.mp hB + refine ⟨hC, ?_⟩ + have hs := discriminantSign_pullback_nondegenerate U C hC + change discriminantSign B.val.val B.val.property = discriminantSign C.val C.property at hs + exact hs.symm.trans hξ + · rintro ⟨hC,hξ⟩ + refine ⟨hn.mpr hC, ?_⟩ + have hs := discriminantSign_pullback_nondegenerate U C hC + change discriminantSign B.val.val B.val.property = discriminantSign C.val C.property at hs + exact hs.trans hξ + +noncomputable def nonsingularSignedMatrixEquiv (ξ : ℤ) : + {C : SymForm K V // C.val.Nondegenerate ∧ discriminantSign C.val C.property = ξ} ≃ + {M : SymMatrix K (finrank K V) // quadraticChar K M.val.det = ξ ∧ M.val.det ≠ 0} := by + refine (symFormMatrix K V).subtypeEquiv ?_ + intro C + have hn : C.val.Nondegenerate ↔ (C.val.toMatrix (Module.finBasis K V)).det ≠ 0 := + LinearMap.BilinForm.nondegenerate_iff_det_ne_zero (Module.finBasis K V) + constructor + · rintro ⟨hC,hξ⟩ + refine ⟨?_, hn.mp hC⟩ + change quadraticChar K (C.val.toMatrix (Module.finBasis K V)).det = ξ + rw [← discriminantSign_nondegenerate C.val C.property hC (Module.finBasis K V)] + exact hξ + · rintro ⟨hξ,hC⟩ + refine ⟨hn.mpr hC, ?_⟩ + rw [discriminantSign_nondegenerate C.val C.property (hn.mpr hC) (Module.finBasis K V)] + exact hξ + + theorem nonsingularSignedForm_card {r : ℕ} (hV : finrank K V = r) + {ξ : ℤ} (hξ : ξ = 1 ∨ ξ = -1) : + Nat.card {C : SymForm K V // C.val.Nondegenerate ∧ discriminantSign C.val C.property = ξ} = + Nat.card {M : SymMatrix K r // quadraticChar K M.val.det = ξ} := by + rw [Nat.card_congr (nonsingularSignedMatrixEquiv (K := K) (V := V) ξ), hV] + apply Nat.card_congr + apply Equiv.subtypeEquiv (Equiv.refl _) + intro M + simp only [Equiv.refl_apply, and_iff_left_iff_imp] + intro h + apply mt quadraticChar_eq_zero_iff.mpr + rw [h] + rcases hξ with rfl | rfl <;> norm_num + + theorem signedRadicalFiber_card (U : Submodule K V) {r : ℕ} + (hU : finrank K (V ⧸ U) = r) {ξ : ℤ} (hξ : ξ = 1 ∨ ξ = -1) : + Nat.card {B : SymForm K V // B.val.ker = U ∧ discriminantSign B.val B.property = ξ} = + Nat.card {M : SymMatrix K r // quadraticChar K M.val.det = ξ} := by + rw [Nat.card_congr (signedRadicalFiberEquiv U ξ)] + exact nonsingularSignedForm_card hU hξ + +end RadicalCount +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module LinearMap +open scoped BigOperators +section RankCard +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] [Fintype K] [DecidableEq K] + +noncomputable def signedNullityFiberEquiv (k : ℕ) (ξ : ℤ) : + {B : SymForm K V // finrank K B.val.ker = k ∧ discriminantSign B.val B.property = ξ} ≃ + Σ U : DimSubspace K V k, + {B : SymForm K V // B.val.ker = U.val ∧ discriminantSign B.val B.property = ξ} where + toFun B := ⟨⟨B.val.val.ker, B.property.1⟩, ⟨B.val, rfl, B.property.2⟩⟩ + invFun UB := ⟨UB.2.val, by rw [UB.2.property.1]; exact UB.1.property, UB.2.property.2⟩ + left_inv _ := rfl + right_inv := by + rintro ⟨⟨U,hU⟩,⟨B,hB,hξ⟩⟩ + dsimp only + change B.val.ker = U at hB + subst U + rfl + + theorem signedNullityForm_card (k : ℕ) (_hk : k ≤ finrank K V) + {ξ : ℤ} (hξ : ξ = 1 ∨ ξ = -1) : + Nat.card {B : SymForm K V // finrank K B.val.ker = k ∧ discriminantSign B.val B.property = ξ} = + Nat.card (DimSubspace K V k) * + Nat.card {M : SymMatrix K (finrank K V - k) // quadraticChar K M.val.det = ξ} := by + classical + let : Finite V := Module.finite_of_finite K + let : Fintype (DimSubspace K V k) := Fintype.ofFinite _ + rw [Nat.card_congr (signedNullityFiberEquiv k ξ), Nat.card_sigma] + have hf (U : DimSubspace K V k) : + Nat.card {B : SymForm K V // B.val.ker = U.val ∧ discriminantSign B.val B.property = ξ} = + Nat.card {M : SymMatrix K (finrank K V - k) // quadraticChar K M.val.det = ξ} := by + apply signedRadicalFiber_card U.val _ hξ + have := U.val.finrank_quotient_add_finrank + rw [U.property] at this + omega + simp only [hf, Finset.sum_const, nsmul_eq_mul, Finset.card_univ, Nat.card_eq_fintype_card, Nat.cast_id] + +end RankCard +section LayerCard +variable {K : Type*} [Field K] [Fintype K] [DecidableEq K] + +noncomputable def matrixFormEquiv (D : ℕ) : SymMatrix K D ≃ SymForm K (Fin D → K) := + Equiv.subtypeEquiv Matrix.toBilin'.toEquiv + (fun _M => Matrix.isSymm_toBilin'_iff_isSymm.symm) + + theorem signedLayer_card_exact (D r : ℕ) (hrD : r ≤ D) {ξ : ℤ} (hξ : ξ = 1 ∨ ξ = -1) : + (signedLayer K D r ξ).card = + Nat.card (DimSubspace K (Fin D → K) (D-r)) * + Nat.card {M : SymMatrix K r // quadraticChar K M.val.det = ξ} := by + classical + have e : {M : SymMatrix K D // M.val.rank = r ∧ matrixSign K D M = ξ} ≃ + {B : SymForm K (Fin D → K) // finrank K B.val.ker = D-r ∧ + discriminantSign B.val B.property = ξ} := by + apply (matrixFormEquiv D).subtypeEquiv + intro M + change (M.val.rank = r ∧ matrixSign K D M = ξ) ↔ + (finrank K M.val.toBilin'.ker = D-r ∧ matrixSign K D M = ξ) + have h := M.val.toBilin'.ker.finrank_quotient_add_finrank + rw [matrix_radical_quotient_rank] at h + simp only [Module.finrank_pi, Fintype.card_fin] at h + omega + calc + _ = Nat.card {M : SymMatrix K D // M.val.rank = r ∧ matrixSign K D M = ξ} := by + simp only [signedLayer, Nat.card_eq_fintype_card, Fintype.card_subtype] + _ = _ := by + rw [Nat.card_congr e, signedNullityForm_card (D-r) (by simp) hξ] + have hd : finrank K (Fin D → K) = D := by simp + rw [hd, Nat.sub_sub_self hrD] + + theorem symmetricSignProb_card (r : ℕ) (ξ : ℤ) : + symmetricSignProb (K := K) r ξ = + (Nat.card {M : SymMatrix K r // quadraticChar K M.val.det = ξ} : ℝ) / + (Fintype.card K : ℝ)^((r+1).choose 2) := by + unfold symmetricSignProb characterSignIndicator + rw [uniformMean_indicator, ← Nat.card_eq_fintype_card (α := SymMatrix K r), symMatrix_card] + simp only [Nat.card_eq_fintype_card, Nat.cast_pow] + + theorem layerMass_exact (D r : ℕ) (hrD : r ≤ D) {ξ : ℤ} (hξ : ξ = 1 ∨ ξ = -1) : + layerMass K D r ξ = + (Nat.card (DimSubspace K (Fin D → K) (D-r)) : ℝ) * + (Fintype.card K : ℝ)^((r+1).choose 2) * symmetricSignProb (K := K) r ξ / + (Fintype.card K : ℝ)^((D+1).choose 2) := by + unfold layerMass + rw [signedLayer_card_exact D r hrD hξ, ← Nat.card_eq_fintype_card, symMatrix_card, + symmetricSignProb_card] + push_cast + have hq : (Fintype.card K : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr Fintype.card_ne_zero + field_simp + +end LayerCard +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Module LinearMap +open scoped BigOperators +section Binary +variable {K : Type*} [Field K] [Fintype K] + +theorem binary_norm_surjective (hK : ringChar K ≠ 2) (a b t : K) + (ha : a ≠ 0) (hb : b ≠ 0) : ∃ x y : K, a*x^2+b*y^2=t := by + open Polynomial in + have hf : (C a * X^2 : K[X]).degree = 2 := degree_C_mul_X_pow 2 ha + open Polynomial in + have hg : (C b * X^2 - C t : K[X]).degree = 2 := by + rw [degree_sub_C (by rw [degree_C_mul_X_pow 2 hb]; decide), degree_C_mul_X_pow 2 hb] + norm_num + obtain ⟨x,y,hxy⟩ := FiniteField.exists_root_sum_quadratic hf hg + (FiniteField.odd_card_of_char_ne_two hK) + refine ⟨x,y,?_⟩ + simpa only [Polynomial.eval_add, Polynomial.eval_sub, Polynomial.eval_mul, + Polynomial.eval_C, Polynomial.eval_pow, Polynomial.eval_X, + ← add_sub_assoc, sub_eq_zero] using hxy +end Binary +section Norms +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] + [FiniteDimensional K E] + +theorem nondegenerate_ne_zero_of_pos (B : LinearMap.BilinForm K E) + (hB : B.Nondegenerate) (hd : 0 < finrank K E) : B ≠ 0 := by + intro h + have hz : ∀ x : E, x=0 := by + intro x + apply hB.1 + intro y + rw [h] + rfl + have hzdim : finrank K E=0 := (finrank_zero_iff_forall_zero).mpr hz + omega + +theorem orthogonal_line_finrank (B : LinearMap.BilinForm K E) {x : E} + (hx : B x x ≠ 0) : finrank K (B.orthogonal (K ∙ x)) + 1 = finrank K E := by + have hx0 : x ≠ 0 := by intro h; subst x; simp at hx + have h := Submodule.finrank_add_eq_of_isCompl (B.isCompl_span_singleton_orthogonal hx) + rw [finrank_span_singleton hx0] at h + omega + +variable [Fintype K] +theorem symmetric_norm_surjective (B : LinearMap.BilinForm K E) (hs : B.IsSymm) + (hB : B.Nondegenerate) (hD : 2 ≤ finrank K E) (hK : ringChar K ≠ 2) (t : K) : + ∃ v : E, B v v = t := by + let : Invertible (2 : K) := invertibleOfNonzero (Ring.two_ne_zero hK) + obtain ⟨x,hx⟩ := LinearMap.BilinForm.exists_bilinForm_self_ne_zero + (nondegenerate_ne_zero_of_pos B hB (by omega)) (LinearMap.BilinForm.isSymm_iff.mp hs) + let P := B.orthogonal (K ∙ x) + have hPs : (B.restrict P).IsSymm := by constructor; intro u v; exact hs.eq _ _ + have hP := B.restrict_nondegenerate_orthogonal_spanSingleton hB hs.isRefl hx + have hd : 0 < finrank K P := by have := orthogonal_line_finrank B hx; dsimp [P]; omega + obtain ⟨y,hy⟩ := LinearMap.BilinForm.exists_bilinForm_self_ne_zero + (nondegenerate_ne_zero_of_pos (B.restrict P) hP hd) (LinearMap.BilinForm.isSymm_iff.mp hPs) + obtain ⟨a,b,hab⟩ := binary_norm_surjective hK (B x x) (B y.val y.val) t hx hy + have hxy : B x y.val = 0 := y.property x (Submodule.mem_span_singleton_self x) + have hyx : B y.val x = 0 := (hs.eq _ _).trans hxy + refine ⟨a • x + b • y.val, ?_⟩ + simp only [map_add, map_smul, LinearMap.add_apply, LinearMap.smul_apply, smul_eq_mul, + hxy, hyx, mul_zero, add_zero, zero_add] + linear_combination hab +end Norms +section Equivalences +variable {K E F : Type*} [Field K] [AddCommGroup E] [Module K E] + [AddCommGroup F] [Module K F] + +def BilinEquivalent (B : LinearMap.BilinForm K E) (C : LinearMap.BilinForm K F) : Prop := + ∃ e : E ≃ₗ[K] F, ∀ x y, C (e x) (e y) = B x y + +def scalarBilin (a : K) : LinearMap.BilinForm K K := a • LinearMap.mul K K +@[simp] theorem scalarBilin_apply (a x y : K) : scalarBilin a x y = a*x*y := by + simp only [scalarBilin, LinearMap.smul_apply, LinearMap.mul_apply', smul_eq_mul] + ring + +theorem scalarBilin_symm (a : K) : (scalarBilin a).IsSymm := by + constructor; intro x y; simp only [scalarBilin_apply]; ring + +theorem scalarBilin_nondegenerate (a : K) (ha : a≠0) : (scalarBilin a).Nondegenerate := by + constructor + · intro x hx; have h := hx 1; simpa only [scalarBilin_apply, mul_one, mul_eq_zero,ha,false_or] using h + · intro x hx; have h := hx 1; simpa only [scalarBilin_apply, mul_one, mul_eq_zero,ha,false_or] using h + +noncomputable def lineOrthogonalEquiv (B : LinearMap.BilinForm K E) (x : E) + (hx : B x x ≠ 0) : (K × B.orthogonal (K ∙ x)) ≃ₗ[K] E := + ((LinearEquiv.toSpanNonzeroSingleton K E x (by intro h; subst x; simp at hx)).prodCongr + (LinearEquiv.refl K (B.orthogonal (K ∙ x)))).trans + ((K ∙ x).prodEquivOfIsCompl _ (B.isCompl_span_singleton_orthogonal hx)) + +theorem lineOrthogonalEquiv_apply (B : LinearMap.BilinForm K E) (x : E) + (hx : B x x ≠ 0) (z : K × B.orthogonal (K ∙ x)) : + lineOrthogonalEquiv B x hx z = z.1 • x + z.2.val := rfl + +theorem lineOrthogonalEquiv_form (B : LinearMap.BilinForm K E) (hs : B.IsSymm) + (x : E) (hx : B x x ≠ 0) (z w : K × B.orthogonal (K ∙ x)) : + B (lineOrthogonalEquiv B x hx z) (lineOrthogonalEquiv B x hx w) = + B x x * z.1 * w.1 + B z.2.val w.2.val := by + have h1 : B x w.2.val = 0 := w.2.property x (Submodule.mem_span_singleton_self x) + have h2 : B z.2.val x = 0 := (hs.eq _ _).trans (z.2.property x (Submodule.mem_span_singleton_self x)) + rw [lineOrthogonalEquiv_apply, lineOrthogonalEquiv_apply] + simp only [map_add, map_smul, LinearMap.add_apply, LinearMap.smul_apply, + smul_eq_mul,h1,h2,mul_zero,add_zero,zero_add] + ring + +variable [FiniteDimensional K E] [FiniteDimensional K F] [Fintype K] [DecidableEq K] +theorem discriminantSign_isometry (B : LinearMap.BilinForm K E) + (C : LinearMap.BilinForm K F) (hs : B.IsSymm) (ht : C.IsSymm) + (hB : B.Nondegenerate) (hC : C.Nondegenerate) + (e : E ≃ₗ[K] F) (he : ∀ x y, C (e x) (e y) = B x y) : + discriminantSign B hs = discriminantSign C ht := by + rw [discriminantSign_nondegenerate B hs hB (Module.finBasis K E), + discriminantSign_nondegenerate C ht hC ((Module.finBasis K E).map e)] + congr 2 + ext i j + simp only [LinearMap.BilinForm.toMatrix_apply, Basis.map_apply, he] + +theorem discriminantSign_orthogonalSum (B : LinearMap.BilinForm K E) + (C : LinearMap.BilinForm K F) (hs : B.IsSymm) (ht : C.IsSymm) + (hB : B.Nondegenerate) (hC : C.Nondegenerate) : + discriminantSign (orthogonalSumForm B C) (orthogonalSumForm_isSymm B C hs ht) = + discriminantSign B hs * discriminantSign C ht := by + rw [discriminantSign_nondegenerate _ _ (orthogonalSumForm_nondegenerate B C hB hC) + ((Module.finBasis K E).prod (Module.finBasis K F)), orthogonalSumForm_matrix, + Matrix.det_fromBlocks_zero₂₁, map_mul, + discriminantSign_nondegenerate B hs hB (Module.finBasis K E), + discriminantSign_nondegenerate C ht hC (Module.finBasis K F)] + + theorem discriminantSign_scalar (a : K) (ha : a≠0) : + discriminantSign (scalarBilin a) (scalarBilin_symm a) = quadraticChar K a := by + rw [discriminantSign_nondegenerate _ _ (scalarBilin_nondegenerate a ha) + (Basis.singleton Unit K), Matrix.det_unique] + simp only [LinearMap.BilinForm.toMatrix_apply, Basis.singleton_apply, scalarBilin_apply, mul_one] + + theorem discriminantSign_line_complement (B : LinearMap.BilinForm K E) + (hs : B.IsSymm) (hB : B.Nondegenerate) (x : E) (hx : B x x ≠ 0) : + discriminantSign B hs = quadraticChar K (B x x) * + discriminantSign (B.restrict (B.orthogonal (K ∙ x))) + (by constructor; intro u v; exact hs.eq u.val v.val) := by + let P := B.orthogonal (K ∙ x) + have hp : (B.restrict P).IsSymm := by constructor; intro u v; exact hs.eq _ _ + have hP := B.restrict_nondegenerate_orthogonal_spanSingleton hB hs.isRefl hx + have he : discriminantSign (orthogonalSumForm (scalarBilin (B x x)) (B.restrict P)) + (orthogonalSumForm_isSymm _ _ (scalarBilin_symm _) hp) = discriminantSign B hs := + discriminantSign_isometry _ _ _ hs + (orthogonalSumForm_nondegenerate _ _ (scalarBilin_nondegenerate _ hx) hP) hB + (lineOrthogonalEquiv B x hx) (fun z w => by + simpa only [orthogonalSumForm_apply,scalarBilin_apply,LinearMap.BilinForm.restrict_apply,LinearMap.domRestrict_apply] using lineOrthogonalEquiv_form B hs x hx z w) + rw [← he, discriminantSign_orthogonalSum _ _ (scalarBilin_symm _) hp (scalarBilin_nondegenerate _ hx) hP, + discriminantSign_scalar _ hx] +end Equivalences +section Classification +variable {K E F : Type*} [Field K] [AddCommGroup E] [Module K E] + [AddCommGroup F] [Module K F] [FiniteDimensional K E] [FiniteDimensional K F] + [Fintype K] [DecidableEq K] + +theorem scalarBilin_equivalent_of_sign (a b : K) (ha : a≠0) (hb : b≠0) + (h : quadraticChar K a = quadraticChar K b) : BilinEquivalent (scalarBilin a) (scalarBilin b) := by + have hc : quadraticChar K (a*b) = 1 := by + rw [map_mul,h,←pow_two,quadraticChar_sq_one hb] + obtain ⟨t,ht⟩ := (quadraticChar_one_iff_isSquare (mul_ne_zero ha hb)).mp hc + have ht0 : t≠0 := by intro hz; rw [hz,mul_zero] at ht; exact mul_ne_zero ha hb ht + have hscale : b*(t/b)^2=a := by + field_simp + linear_combination ht.symm + refine ⟨LinearEquiv.smulOfNeZero K K (t/b) (div_ne_zero ht0 hb), ?_⟩ + intro x y + simp only [LinearEquiv.smulOfNeZero_apply,smul_eq_mul,scalarBilin_apply] + linear_combination x*y*hscale + +omit [Fintype K] [DecidableEq K] in +theorem one_dimensional_form (B : LinearMap.BilinForm K E) (hD : finrank K E=1) : + ∃ e : K ≃ₗ[K] E, ∀ s t : K, B (e s) (e t) = B (e 1) (e 1)*s*t := by + let e := LinearEquiv.ofFinrankEq (R := K) K E (by simpa using hD.symm) + refine ⟨e,?_⟩ + intro s t + have hs : e s = s • e 1 := by rw [←map_smul]; simp + have ht : e t = t • e 1 := by rw [←map_smul]; simp + rw [hs,ht] + simp only [map_smul,LinearMap.smul_apply,smul_eq_mul] + ring + +theorem one_dimensional_equivalent (B : LinearMap.BilinForm K E) (C : LinearMap.BilinForm K F) + (hs : B.IsSymm) (ht : C.IsSymm) (hB : B.Nondegenerate) (hC : C.Nondegenerate) + (hE : finrank K E=1) (hF : finrank K F=1) + (h : discriminantSign B hs = discriminantSign C ht) : BilinEquivalent B C := by + obtain ⟨e,he⟩ := one_dimensional_form B hE + obtain ⟨f,hf⟩ := one_dimensional_form C hF + have ha : B (e 1) (e 1)≠0 := by + intro hz + have he1 : e 1=0 := hB.1 _ (fun y => by + obtain ⟨s,rfl⟩ := e.surjective y + rw [he,hz]; simp) + have : (1:K)=0 := e.injective (he1.trans e.map_zero.symm) + exact one_ne_zero this + have hb : C (f 1) (f 1)≠0 := by + intro hz + have hf1 : f 1=0 := hC.1 _ (fun y => by + obtain ⟨s,rfl⟩ := f.surjective y + rw [hf,hz]; simp) + exact one_ne_zero (f.injective (hf1.trans f.map_zero.symm)) + have hsa := discriminantSign_isometry (scalarBilin (B (e 1) (e 1))) B + (scalarBilin_symm _) hs (scalarBilin_nondegenerate _ ha) hB e + (fun s t => by simpa only [scalarBilin_apply] using he s t) + have hsb := discriminantSign_isometry (scalarBilin (C (f 1) (f 1))) C + (scalarBilin_symm _) ht (scalarBilin_nondegenerate _ hb) hC f + (fun s t => by simpa only [scalarBilin_apply] using hf s t) + rw [discriminantSign_scalar _ ha] at hsa + rw [discriminantSign_scalar _ hb] at hsb + obtain ⟨g,hg⟩ := scalarBilin_equivalent_of_sign _ _ ha hb (hsa.trans (h.trans hsb.symm)) + refine ⟨e.symm.trans (g.trans f), ?_⟩ + intro x y + change C (f (g (e.symm x))) (f (g (e.symm y))) = B x y + rw [hf] + have hg' := hg (e.symm x) (e.symm y) + simp only [scalarBilin_apply] at hg' + rw [hg'] + have hx := he (e.symm x) (e.symm y) + simpa only [e.apply_symm_apply,scalarBilin_apply] using hx.symm + + theorem symmetric_equivalent_of_dim_sign (B : LinearMap.BilinForm K E) + (C : LinearMap.BilinForm K F) (hs : B.IsSymm) (ht : C.IsSymm) + (hB : B.Nondegenerate) (hC : C.Nondegenerate) (hK : ringChar K≠2) + (hd : finrank K E = finrank K F) + (h : discriminantSign B hs = discriminantSign C ht) : BilinEquivalent B C := by + suffices ∀ n, finrank K E=n → finrank K F=n → BilinEquivalent B C by exact this _ rfl hd.symm + intro n hnE hnF + induction n using Nat.strong_induction_on generalizing E F with + | h n ih => + by_cases hn0 : n=0 + · let e := LinearEquiv.ofFinrankEq E F (hnE.trans hnF.symm) + have hzero : Subsingleton E := Module.finrank_zero_iff.mp (hnE.trans hn0) + refine ⟨e,?_⟩ + intro x y + have hx : x=0 := Subsingleton.elim _ _ + simp only [hx,map_zero,LinearMap.zero_apply] + by_cases hn1 : n=1 + · exact one_dimensional_equivalent B C hs ht hB hC (hnE.trans hn1) (hnF.trans hn1) h + have hn2 : 2≤n := by omega + obtain ⟨x,hx⟩ := symmetric_norm_surjective B hs hB (by omega) hK 1 + obtain ⟨y,hy⟩ := symmetric_norm_surjective C ht hC (by omega) hK 1 + have hx0 : B x x≠0 := hx ▸ one_ne_zero + have hy0 : C y y≠0 := hy ▸ one_ne_zero + let P := B.orthogonal (K ∙ x) + let Q := C.orthogonal (K ∙ y) + have hp : (B.restrict P).IsSymm := by constructor; intro u v; exact hs.eq _ _ + have hq : (C.restrict Q).IsSymm := by constructor; intro u v; exact ht.eq _ _ + have hP := B.restrict_nondegenerate_orthogonal_spanSingleton hB hs.isRefl hx0 + have hQ := C.restrict_nondegenerate_orthogonal_spanSingleton hC ht.isRefl hy0 + have hdP : finrank K P=n-1 := by have := orthogonal_line_finrank B hx0; dsimp [P]; omega + have hdQ : finrank K Q=n-1 := by have := orthogonal_line_finrank C hy0; dsimp [Q]; omega + have hdPQ : finrank K P=finrank K Q := hdP.trans hdQ.symm + have hsP := discriminantSign_line_complement B hs hB x hx0 + have hsQ := discriminantSign_line_complement C ht hC y hy0 + rw [hx,map_one,one_mul] at hsP + rw [hy,map_one,one_mul] at hsQ + have hh : discriminantSign (B.restrict P) hp = discriminantSign (C.restrict Q) hq := + hsP.symm.trans (h.trans hsQ) + obtain ⟨g,hg⟩ := ih (n-1) (by omega) (B.restrict P) (C.restrict Q) hp hq hP hQ hdPQ hh hdP hdQ + let e := (lineOrthogonalEquiv B x hx0).symm.trans + (((LinearEquiv.refl K K).prodCongr g).trans (lineOrthogonalEquiv C y hy0)) + refine ⟨e,?_⟩ + intro v w + let a := (lineOrthogonalEquiv B x hx0).symm v + let b := (lineOrthogonalEquiv B x hx0).symm w + change C (lineOrthogonalEquiv C y hy0 (a.1,g a.2)) + (lineOrthogonalEquiv C y hy0 (b.1,g b.2)) = B v w + rw [lineOrthogonalEquiv_form C ht,hy] + change 1*a.1*b.1 + (C.restrict Q) (g a.2) (g b.2) = B v w + rw [hg] + have he := lineOrthogonalEquiv_form B hs x hx0 a b + rw [hx] at he + simpa only [a,b,LinearEquiv.apply_symm_apply,LinearMap.BilinForm.restrict_apply,LinearMap.domRestrict_apply] using he.symm +end Classification +end SidorenkoCounterexample + + +end + + + +section + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section LinearMean +variable {K U W : Type*} [Field K] [AddCommGroup U] [Module K U] + [AddCommGroup W] [Module K W] [Fintype U] [Fintype W] +theorem uniformMean_surjective_linear (f : U →ₗ[K] W) (hf : Function.Surjective f) + (g : W → ℝ) : uniformMean (g ∘ f) = uniformMean g := by + classical + have hcard (y : W) : Fintype.card {x : U // f x = y} = Fintype.card f.ker := by + simpa [Fintype.card_subtype, LinearMap.mem_ker] using + AddMonoidHom.card_fiber_eq_of_mem_range f (hf y) (hf 0) + have hc : Fintype.card U = Fintype.card W * Fintype.card f.ker := by + simpa only [Nat.card_eq_fintype_card] using surjective_linear_card f hf + unfold uniformMean + simp only [Function.comp_def] + rw [←Fintype.sum_fiberwise f (fun x => g (f x))] + have hs (y : W) : (∑ x : {x : U // f x=y}, g (f x.val)) = + (Fintype.card f.ker : ℝ)*g y := by + have he (x : {x : U // f x=y}) : g (f x.val)=g y := congrArg g x.property + simp only [he,Finset.sum_const,Finset.card_univ,nsmul_eq_mul,hcard] + simp only [hs] + rw [←Finset.mul_sum, hc, Nat.cast_mul] + have hk : (Fintype.card f.ker : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr Fintype.card_ne_zero + field_simp +end LinearMean +section Forms +variable {K V : Type*} [Field K] [Fintype K] [DecidableEq K] + [AddCommGroup V] [Module K V] [FiniteDimensional K V] +noncomputable instance symForm_fintype : Fintype (SymForm K V) := Fintype.ofFinite _ +noncomputable def formSignIndicator (ξ : ℤ) (Q : SymForm K V) : ℝ := by + classical + exact if Q.val.Nondegenerate then if discriminantSign Q.val Q.property = ξ then 1 else 0 else 0 +noncomputable def formSingularIndicator (Q : SymForm K V) : ℝ := by + classical + exact if Q.val.Nondegenerate then 0 else 1 + +theorem formSignIndicator_matrix {ι : Type*} [Fintype ι] [DecidableEq ι] + (b : Basis ι K V) {ξ : ℤ} (hξ : ξ=1 ∨ ξ = -1) (Q : SymForm K V) : + formSignIndicator ξ Q = characterSignIndicator ξ (Q.val.toMatrix b).det := by + by_cases h : Q.val.Nondegenerate + · simp only [formSignIndicator,h,ite_true,characterSignIndicator, + discriminantSign_nondegenerate Q.val Q.property h b] + · have hd : (Q.val.toMatrix b).det=0 := by + simpa only [LinearMap.BilinForm.nondegenerate_iff_det_ne_zero b,not_not] using h + rcases hξ with rfl | rfl <;> + simp [formSignIndicator,h,characterSignIndicator,hd] + +omit [Fintype K] [FiniteDimensional K V] in +theorem formSingularIndicator_matrix {ι : Type*} [Fintype ι] [DecidableEq ι] + (b : Basis ι K V) (Q : SymForm K V) : + formSingularIndicator Q = if (Q.val.toMatrix b).det=0 then 1 else 0 := by + simp only [formSingularIndicator,LinearMap.BilinForm.nondegenerate_iff_det_ne_zero b] + split <;> simp_all + +theorem formSignIndicator_nonneg (ξ : ℤ) (Q : SymForm K V) : 0 ≤ formSignIndicator ξ Q := by + unfold formSignIndicator; split <;> (try split) <;> norm_num + +theorem formSignIndicator_le_one (ξ : ℤ) (Q : SymForm K V) : formSignIndicator ξ Q ≤ 1 := by + unfold formSignIndicator; split <;> (try split) <;> norm_num + +omit [Fintype K] [DecidableEq K] [FiniteDimensional K V] in +theorem formSingularIndicator_nonneg (Q : SymForm K V) : 0 ≤ formSingularIndicator Q := by + unfold formSingularIndicator; split <;> norm_num + +theorem formSingularMean_bound : + uniformMean (formSingularIndicator (K := K) (V := V)) ≤ + (finrank K V : ℝ)/(Fintype.card K : ℝ) := by + have h := uniformMean_equiv (symFormMatrix K V) + (fun M : SymMatrix K (finrank K V) => if M.val.det=0 then 1 else 0) + have he : uniformMean (formSingularIndicator (K := K) (V := V)) = + symmetricSingularProb (K := K) (finrank K V) := by + unfold symmetricSingularProb + rw [←h]; apply uniformMean_congr + intro Q; exact formSingularIndicator_matrix (Module.finBasis K V) Q + rw [he]; exact symmetricSingularProb_bound _ + +theorem formSignMean_error (hK : ringChar K ≠ 2) (hd : 0 < finrank K V) + {ξ : ℤ} (hξ : ξ=1 ∨ ξ = -1) : + |uniformMean (formSignIndicator (K := K) (V := V) ξ)-1/2| ≤ + (finrank K V : ℝ)/(Fintype.card K : ℝ) := by + have h := uniformMean_equiv (symFormMatrix K V) + (fun M : SymMatrix K (finrank K V) => characterSignIndicator ξ M.val.det) + have he : uniformMean (formSignIndicator (K := K) (V := V) ξ) = + symmetricSignProb (K := K) (finrank K V) ξ := by + unfold symmetricSignProb + rw [←h]; apply uniformMean_congr + intro Q; exact formSignIndicator_matrix (Module.finBasis K V) hξ Q + rw [he]; exact symmetricSignProb_error _ hd hK hξ + +variable {W : Type*} [AddCommGroup W] [Module K W] [FiniteDimensional K W] +omit [DecidableEq K] in +theorem uniformMean_restrict (f : W →ₗ[K] V) (hf : Function.Injective f) + (g : SymForm K W → ℝ) : + uniformMean (fun Q : SymForm K V => g (symFormPull f Q)) = uniformMean g := + uniformMean_surjective_linear (symFormPull f) (symFormPull_surjective f hf) g +end Forms +end SidorenkoCounterexample + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/Spans.lean b/lean/OAI/Combinatorics/Sidorenko/Spans.lean new file mode 100644 index 0000000000000000000000000000000000000000..549446b965b87aa619fd5124c377a6f6c19406e8 --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/Spans.lean @@ -0,0 +1,721 @@ +import OAI.Combinatorics.Sidorenko.Exposure + +namespace OAI + +namespace SidorenkoCounterexample +open Module + +section Span +variable {K V P : Type*} [Field K] [AddCommGroup V] [Module K V] + [FiniteDimensional K V] [Fintype P] [DecidableEq P] + +/-- The span of the spaces on the edges incident to a given vertex. -/ +def localSpan (s : Finset (Finset P)) (H : Finset P → Submodule K V) (i : P) : + Submodule K V := (s.filter fun e => i ∈ e).sup H + +omit [FiniteDimensional K V] [Fintype P] in +private theorem localSpan_le (s : Finset (Finset P)) (H : Finset P → Submodule K V) + (i : P) : localSpan s H i ≤ s.sup H := + Finset.sup_mono (Finset.filter_subset _ _) + +omit [FiniteDimensional K V] [Fintype P] in +private theorem localSpan_insert (s : Finset (Finset P)) (e : Finset P) + (H : Finset P → Submodule K V) (i : P) : + localSpan (insert e s) H i = if i ∈ e then H e ⊔ localSpan s H i + else localSpan s H i := by + classical + simp only [localSpan, Finset.filter_insert] + split_ifs <;> simp + +private theorem local_rank_insert (s : Finset (Finset P)) (e : Finset P) + (H : Finset P → Submodule K V) : + (∑ i, finrank K (localSpan (insert e s) H i)) + + (∑ i ∈ e, finrank K (H e ⊓ localSpan s H i : Submodule K V)) = + (∑ i, finrank K (localSpan s H i)) + e.card * finrank K (H e) := by + classical + have heq (i : P) : finrank K (localSpan (insert e s) H i) + + (if i ∈ e then finrank K (H e ⊓ localSpan s H i : Submodule K V) else 0) = + finrank K (localSpan s H i) + (if i ∈ e then finrank K (H e) else 0) := by + by_cases hi : i ∈ e + · rw [localSpan_insert, ite_eq_left hi, ite_eq_left hi, ite_eq_left hi] + exact (Submodule.finrank_sup_add_finrank_inf_eq (H e) (localSpan s H i)).trans (Nat.add_comm _ _) + · rw [localSpan_insert, ite_eq_right hi, ite_eq_right hi, ite_eq_right hi] + have h := congrArg (fun f : P → ℕ => ∑ i, f i) (funext heq) + simpa only [Finset.sum_add_distrib, Finset.sum_ite_mem, Finset.sum_const, + smul_eq_mul, Finset.univ_inter] using h + +/-- The dimension bound, together with its equality rigidity. Equality +forces the entire edge-space family to be a direct sum. -/ +theorem span_inequality_with_rigidity (s : Finset (Finset P)) + (H : Finset P → Submodule K V) (hs : ∀ e ∈ s, e.card = 2) : + 2 * finrank K (s.sup H : Submodule K V) ≤ ∑ i, finrank K (localSpan s H i) ∧ + ((∑ i, finrank K (localSpan s H i)) = 2 * finrank K (s.sup H : Submodule K V) → + s.SupIndep H) := by + classical + induction s using Finset.induction with + | empty => + rw [Finset.sup_empty] + constructor + · simp + · intro _ + exact Finset.supIndep_empty H + | @insert e s he ih => + have hse : ∀ f ∈ s, f.card = 2 := fun f hf => hs f (Finset.mem_insert_of_mem hf) + obtain ⟨hbound, hrigid⟩ := ih hse + have hecard := hs e (Finset.mem_insert_self _ _) + obtain ⟨a, b, hab, heab⟩ := Finset.card_eq_two.mp hecard + have hr := local_rank_insert s e H + rw [hecard, heab] at hr + simp only [Finset.sum_pair hab] at hr + rw [← heab] at hr + have hg := Submodule.finrank_sup_add_finrank_inf_eq (H e) (s.sup H) + have hda := Submodule.finrank_mono + (inf_le_inf_left (H e) (localSpan_le s H a)) + have hdb := Submodule.finrank_mono + (inf_le_inf_left (H e) (localSpan_le s H b)) + rw [Finset.sup_insert] + constructor + · omega + · intro heq + have hold : (∑ i, finrank K (localSpan s H i)) = 2 * finrank K (s.sup H : Submodule K V) := by omega + have hA : finrank K (H e ⊓ localSpan s H a : Submodule K V) = + finrank K (H e ⊓ s.sup H : Submodule K V) := by omega + have hB : finrank K (H e ⊓ localSpan s H b : Submodule K V) = + finrank K (H e ⊓ s.sup H : Submodule K V) := by omega + have hind := hrigid hold + have hfilters : Disjoint (s.filter fun f => a ∈ f) (s.filter fun f => b ∈ f) := by + rw [Finset.disjoint_left] + intro f hfa hfb + obtain ⟨hf, haf⟩ := Finset.mem_filter.mp hfa + have hbf := (Finset.mem_filter.mp hfb).2 + have hef : e ⊆ f := by + rw [heab] + intro x hx + rcases Finset.mem_insert.mp hx with hxa | hxb + · exact hxa ▸ haf + · exact (Finset.mem_singleton.mp hxb) ▸ hbf + have heqf : e = f := Finset.eq_of_subset_of_card_le hef (by rw [hse f hf, hecard]) + exact he (heqf.symm ▸ hf) + have hdis : Disjoint (localSpan s H a) (localSpan s H b) := + hind.disjoint_sup_sup (Finset.filter_subset _ _) (Finset.filter_subset _ _) hfilters + have hAe := Submodule.eq_of_le_of_finrank_eq + (inf_le_inf_left (H e) (localSpan_le s H a)) hA + have hBe := Submodule.eq_of_le_of_finrank_eq + (inf_le_inf_left (H e) (localSpan_le s H b)) hB + have hnew : Disjoint (H e) (s.sup H) := by + rw [disjoint_iff_inf_le] + calc + H e ⊓ s.sup H ≤ localSpan s H a ⊓ localSpan s H b := by + exact le_inf (hAe ▸ inf_le_right) (hBe ▸ inf_le_right) + _ ≤ ⊥ := hdis.le_bot + exact hind.insert hnew + +/-- Exact non-strict span inequality of the manuscript. -/ +theorem span_inequality (s : Finset (Finset P)) (H : Finset P → Submodule K V) + (hs : ∀ e ∈ s, e.card = 2) : + 2 * finrank K (s.sup H : Submodule K V) ≤ ∑ i, finrank K (localSpan s H i) := + (span_inequality_with_rigidity s H hs).1 + +/-- Exact strict improvement for a nondirect family, including partial +intersections. Zero spaces do not affect `SupIndep`. -/ +theorem strict_span_inequality (s : Finset (Finset P)) (H : Finset P → Submodule K V) + (hs : ∀ e ∈ s, e.card = 2) (hn : ¬s.SupIndep H) : + 2 * finrank K (s.sup H : Submodule K V) + 1 ≤ ∑ i, finrank K (localSpan s H i) := by + obtain ⟨hb, hr⟩ := span_inequality_with_rigidity s H hs + have hne : (∑ i, finrank K (localSpan s H i)) ≠ 2 * finrank K (s.sup H : Submodule K V) := + fun h => hn (hr h) + omega + +end Span +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section FiniteSpans +variable {K E I : Type*} [Field K] [AddCommGroup E] [Module K E] [FiniteDimensional K E] + theorem finrank_finset_sup_le (s : Finset I) (A : I → Submodule K E) : + finrank K ↥(s.sup A) ≤ ∑ i∈s, finrank K (A i) := by + classical + induction s using Finset.induction_on with + | empty => simp + | @insert i s hi ih => + rw [Finset.sup_insert,Finset.sum_insert hi] + have := Submodule.finrank_sup_add_finrank_inf_eq (A i) (s.sup A) + omega + theorem finrank_finite_iSup_le [Fintype I] (A : I → Submodule K E) : + finrank K ↥(⨆ i,A i) ≤ ∑ i, finrank K (A i) := by + have hh := finrank_finset_sup_le Finset.univ A + exact (le_of_eq (congrArg (fun S : Submodule K E=>finrank K S) + (Finset.sup_univ_eq_iSup A).symm)).trans hh + theorem finrank_finset_sup_direct (s : Finset I) (A : I → Submodule K E) + (ha : iSupIndep A) : finrank K ↥(s.sup A) = ∑ i∈s, finrank K (A i) := by + classical + induction s using Finset.induction_on with + | empty => simp + | @insert i s hi ih => + have hd : Disjoint (A i) (s.sup A) := by + rw [Finset.sup_eq_iSup] + exact ha.disjoint_biSup hi + have hh := Submodule.finrank_sup_add_finrank_inf_eq (A i) (s.sup A) + rw [hd.eq_bot,finrank_bot,add_zero] at hh + rw [Finset.sup_insert,Finset.sum_insert hi,hh,ih] +end FiniteSpans + +def incidentPairs (i : Fin 13) : Finset (Fin 33) := Finset.univ.filter (fun e => i∈pairVertices e) +def pairRelated (e f : Fin 33) : Prop := ¬Disjoint (pairVertices e) (pairVertices f) +instance (e f : Fin 33) : Decidable (pairRelated e f) := inferInstanceAs (Decidable (¬Disjoint _ _)) + theorem pairRelated_symm (e f : Fin 33) : pairRelated e f → pairRelated f e := by + unfold pairRelated; intro h hf; exact h hf.symm + theorem incidentPairs_card : ∀ i, (incidentPairs i).card = (![4,6,4,6,5,4,5,5,5,6,5,6,5] : Fin 13 → ℕ) i := by decide + theorem incidentPairs_card_le : ∀ i, (incidentPairs i).card≤6 := by decide + theorem pair_shared_card : ∀ e f, (Finset.univ.filter (fun i => e∈incidentPairs i ∧ f∈incidentPairs i)).card = + if e=f then 2 else if pairRelated e f then 1 else 0 := by decide + theorem incident_pair_card (e : Fin 33) : (Finset.univ.filter (fun i => e∈incidentPairs i)).card=2 := by + have he : Finset.univ.filter (fun i => e∈incidentPairs i)=pairVertices e := by + ext i; simp only [Finset.mem_filter,Finset.mem_univ,true_and,incidentPairs] + rw [he,pairVertices_card] + theorem sum_incident (f : Fin 33 → ℝ) : + (∑ i : Fin 13, ∑ e∈incidentPairs i, f e)=2*∑ e,f e := by + simp only [incidentPairs,Finset.sum_filter] + rw [Finset.sum_comm] + have hh (e : Fin 33) : (∑ i : Fin 13, if i∈pairVertices e then f e else 0)=2*f e := by + rw [←Finset.sum_filter,Finset.sum_const] + have hc : (Finset.univ.filter (fun i=>i∈pairVertices e)).card=2 := by + have he : Finset.univ.filter (fun i=>i∈pairVertices e)=pairVertices e := by ext i; simp + rw [he,pairVertices_card] + rw [hc]; simp only [nsmul_eq_mul,Nat.cast_ofNat] + simp_rw [hh] + rw [Finset.mul_sum] +noncomputable def localPairDim (h : Fin 33 → ℕ) (i : Fin 13) : ℕ := ∑ e∈incidentPairs i,h e + theorem localPairDim_le (h : Fin 33 → ℕ) (hh : ∀ e,h e≤2) (i : Fin 13) : localPairDim h i≤2*(incidentPairs i).card := by + unfold localPairDim + calc _ ≤ ∑ _e∈incidentPairs i, 2 := Finset.sum_le_sum (fun e _=>hh e) + _ = _ := by simp only [Finset.sum_const,nsmul_eq_mul,Nat.cast_id]; omega + theorem localPairDim_le_twelve (h : Fin 33 → ℕ) (hh : ∀ e,h e≤2) (i : Fin 13) : localPairDim h i≤12 := by + have := localPairDim_le h hh i + have := incidentPairs_card_le i + omega +section GraphSpans +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] +noncomputable def incidentSpan (A : Fin 33 → Submodule K E) (i : Fin 13) : Submodule K E := + (incidentPairs i).sup A + theorem incidentSpan_le {A : Fin 33 → Submodule K E} {i : Fin 13} {L : Submodule K E} + (h : ∀ e, i∈pairVertices e → A e≤L) : incidentSpan A i≤L := by + apply Finset.sup_le + intro e he + exact h e (Finset.mem_filter.mp he).2 +variable [FiniteDimensional K E] + theorem incidentSpan_finrank_le (h : Fin 33 → ℕ) (A : (e : Fin 33) → DimSubspace K E (h e)) (i : Fin 13) : + finrank K (incidentSpan (fun e=>(A e).val) i)≤localPairDim h i := by + unfold incidentSpan localPairDim + calc _ ≤ ∑ e∈incidentPairs i, finrank K (A e).val := finrank_finset_sup_le _ _ + _ = _ := Finset.sum_congr rfl (fun e _ => (A e).property) + theorem incidentSpan_finrank_direct (h : Fin 33 → ℕ) (A : (e : Fin 33) → DimSubspace K E (h e)) + (ha : iSupIndep (fun e=>(A e).val)) (i : Fin 13) : + finrank K (incidentSpan (fun e=>(A e).val) i)=localPairDim h i := by + unfold incidentSpan localPairDim + calc _ = ∑ e∈incidentPairs i, finrank K (A e).val := finrank_finset_sup_direct _ _ ha + _ = _ := Finset.sum_congr rfl (fun e _ => (A e).property) +noncomputable def extendPairSpace (A : Fin 33 → Submodule K E) : Finset (Fin 13) → Submodule K E := + Function.extend pairVertices A (fun _=>⊥) +omit [FiniteDimensional K E] in + theorem extendPairSpace_apply (A : Fin 33 → Submodule K E) (e : Fin 33) : + extendPairSpace A (pairVertices e)=A e := pairVertices_injective.extend_apply _ _ _ +omit [FiniteDimensional K E] in + theorem extend_global_span (A : Fin 33 → Submodule K E) : + (Finset.univ.image pairVertices).sup (extendPairSpace A)=⨆ e,A e := by + rw [Finset.sup_image] + simp only [Function.comp_def,extendPairSpace_apply,Finset.sup_eq_iSup,Finset.mem_univ,iSup_pos] +omit [FiniteDimensional K E] in + theorem extend_local_span (A : Fin 33 → Submodule K E) (i : Fin 13) : + localSpan (Finset.univ.image pairVertices) (extendPairSpace A) i=incidentSpan A i := by + unfold localSpan incidentSpan incidentPairs + rw [Finset.filter_image,Finset.sup_image] + simp only [Function.comp_def,extendPairSpace_apply] + theorem indexed_strict_span (A : Fin 33 → Submodule K E) (ha : ¬iSupIndep A) : + 2*finrank K ↥(⨆ e,A e)+1≤∑ i,finrank K (incidentSpan A i) := by + have hn : ¬(Finset.univ.image pairVertices).SupIndep (extendPairSpace A) := by + intro hs + have hi := hs.independent + have hj := hi.comp (f := fun e : Fin 33 => (⟨pairVertices e,Finset.mem_image.mpr ⟨e,Finset.mem_univ _,rfl⟩⟩ : ↥(Finset.univ.image pairVertices))) (by + intro e f hef + exact pairVertices_injective (congrArg Subtype.val hef)) + apply ha + simpa only [Function.comp_def,extendPairSpace_apply] using hj + have hb := strict_span_inequality (Finset.univ.image pairVertices) (extendPairSpace A) + (by intro e he; obtain ⟨f,_,rfl⟩:=Finset.mem_image.mp he; exact pairVertices_card f) hn + rw [extend_global_span] at hb + have hs : (∑ i : Fin 13,finrank K (localSpan (Finset.univ.image pairVertices) (extendPairSpace A) i))=∑ i,finrank K (incidentSpan A i) := + Finset.sum_congr rfl (fun i _ => congrArg (fun S : Submodule K E => finrank K S) (extend_local_span A i)) + rw [hs] at hb + exact hb +end GraphSpans +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open scoped BigOperators + theorem pairRelated_self (e : Fin 33) : pairRelated e e := by + intro he + have hb := disjoint_self.mp he + have hc := pairVertices_card e + rw [hb] at hc + simp at hc + theorem related_label_count (h : Fin 33 → ℕ) : + (Nat.card {p : (Σ e, Fin (h e))×(Σ e, Fin (h e)) // p.1≠p.2 ∧ pairRelated p.1.1 p.2.1}:ℝ)= + (∑ e, ∑ f, if pairRelated e f then (h e:ℝ)*h f else 0)-∑ e,(h e:ℝ) := by + classical + rw [nat_card_subtype_sum,Nat.cast_sum,Fintype.sum_prod_type] + have he (a b : Σ e, Fin (h e)) : + (if a≠b ∧ pairRelated a.1 b.1 then (1:ℝ) else 0)= + (if pairRelated a.1 b.1 then (1:ℝ) else 0)-(if a=b then 1 else 0) := by + by_cases hab : a=b + · subst b; simp [pairRelated_self] + · by_cases hr : pairRelated a.1 b.1 <;> simp [hab,hr] + simp only [Nat.cast_ite, Nat.cast_one, Nat.cast_zero] + simp only [he,Finset.sum_sub_distrib] + simp only [Finset.sum_ite_eq,Finset.mem_univ,ite_true,Finset.sum_const,Finset.card_univ, + nsmul_eq_mul,mul_one,Fintype.card_sigma,Fintype.card_fin,Nat.cast_sum] + congr 1 + simp_rw [Fintype.sum_sigma] + simp [Finset.sum_const,Finset.mul_sum] + apply Finset.sum_congr rfl + intro e _ + apply Finset.sum_congr rfl + intro f _ + by_cases hr : pairRelated e f <;> simp [hr] + + theorem sum_local_products (f g : Fin 33 → ℝ) : + (∑ i : Fin 13, (∑ e∈incidentPairs i,f e)*(∑ e∈incidentPairs i,g e))= + ∑ e,∑ a, ((Finset.univ.filter (fun i=>e∈incidentPairs i ∧ a∈incidentPairs i)).card:ℝ)*f e*g a := by + classical + have hf (i : Fin 13) : (∑ e∈incidentPairs i,∑ a∈incidentPairs i,f e*g a)= + ∑ e : Fin 33,∑ a : Fin 33, if e∈incidentPairs i ∧ a∈incidentPairs i then f e*g a else 0 := by + symm + simp only [ite_and] + simp_rw [Finset.sum_ite_irrel,Finset.sum_ite_mem] + simp only [Finset.sum_const_zero, Finset.sum_ite_mem, Finset.univ_inter] + have hp (i : Fin 13) : (∑ e∈incidentPairs i,f e)*(∑ e∈incidentPairs i,g e)= + ∑ e∈incidentPairs i,∑ a∈incidentPairs i,f e*g a := by + rw [Finset.sum_mul] + simp_rw [Finset.mul_sum] + simp_rw [hp,hf] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro e _ + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro a _ + rw [←Finset.sum_filter,Finset.sum_const] + simp only [nsmul_eq_mul,mul_assoc] + + theorem sum_local_squares (h : Fin 33 → ℕ) : + (∑ i : Fin 13,(localPairDim h i:ℝ)^2)= + (∑ e,(h e:ℝ)^2)+(∑ e,∑ f,if pairRelated e f then (h e:ℝ)*h f else 0) := by + classical + have he : (∑ i : Fin 13,(localPairDim h i:ℝ)^2)= + ∑ i : Fin 13,(∑ e∈incidentPairs i,(h e:ℝ))*(∑ e∈incidentPairs i,(h e:ℝ)) := by + simp only [localPairDim,Nat.cast_sum,pow_two] + rw [he,sum_local_products] + have hp (e f : Fin 33) : + ((Finset.univ.filter (fun i=>e∈incidentPairs i ∧ f∈incidentPairs i)).card:ℝ)*(h e:ℝ)*h f= + (if e=f then (h e:ℝ)^2 else 0)+(if pairRelated e f then (h e:ℝ)*h f else 0) := by + rw [pair_shared_card] + by_cases hef : e=f + · subst f; simp only [ite_true,pairRelated_self,Nat.cast_ofNat,pow_two]; ring + · by_cases hr : pairRelated e f <;> simp [hef,hr] + simp_rw [hp,Finset.sum_add_distrib] + simp only [Finset.sum_ite_eq,Finset.mem_univ,ite_true] + + theorem sum_localPairDim (h : Fin 33 → ℕ) : (∑ i,(localPairDim h i:ℝ))=2*∑ e,(h e:ℝ) := by + simpa only [localPairDim,Nat.cast_sum] using sum_incident (fun e=>(h e:ℝ)) + + theorem residual_direct_exponent (D : ℕ) (h : Fin 33 → ℕ) : + 2*(D:ℝ)*(∑ e,(h e:ℝ))- + (Nat.card {p : (Σ e, Fin (h e))×(Σ e, Fin (h e)) // p.1≠p.2 ∧ pairRelated p.1.1 p.2.1}:ℝ)/2- + (∑ e,(h e:ℝ)^2)+(∑ i : Fin 13, (-(D:ℝ)*localPairDim h i+(localPairDim h i:ℝ)*(localPairDim h i-1)/2))= + -∑ e,triangular (h e) := by + rw [related_label_count] + have hl : (∑ i : Fin 13, (-(D:ℝ)*localPairDim h i+(localPairDim h i:ℝ)*(localPairDim h i-1)/2))= + -(D:ℝ)*(∑ i,(localPairDim h i:ℝ))+((∑ i,(localPairDim h i:ℝ)^2)-(∑ i,(localPairDim h i:ℝ)))/2 := by + simp only [mul_sub,mul_one,sub_div,←pow_two] + simp only [Finset.sum_add_distrib,Finset.sum_sub_distrib,Finset.sum_div,Finset.mul_sum] + rw [hl,sum_localPairDim,sum_local_squares] + have ht : (∑ e,triangular (h e))=((∑ e,(h e:ℝ)^2)+(∑ e,(h e:ℝ)))/2 := by + unfold triangular + simp only [mul_add,mul_one,←pow_two] + rw [←Finset.sum_div,Finset.sum_add_distrib] + rw [ht] + ring +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open scoped BigOperators + theorem degree_choose_sum : (∑ i : Fin 13,(2*(incidentPairs i).card).choose 2)=618 := by decide + theorem local_choose_sum_bound (ki : Fin 13 → ℕ) (hk : ∀ i,ki i≤2*(incidentPairs i).card) : + (∑ i : Fin 13, (ki i:ℝ)*(ki i-1)/2)≤618 := by + have hb : (∑ i : Fin 13,(ki i).choose 2)≤618 := by + rw [←degree_choose_sum] + exact Finset.sum_le_sum (fun i _=>Nat.choose_le_choose 2 (hk i)) + have hc : (∑ i : Fin 13, ((ki i).choose 2:ℝ))≤618 := by exact_mod_cast hb + simpa only [Nat.cast_choose_two] using hc + theorem residual_nondirect_exponent (D k : ℕ) (h : Fin 33 → ℕ) (ki : Fin 13 → ℕ) + (hh : ∀ e,h e=0 ∨ h e=2) (hk : ∀ i,ki i≤2*(incidentPairs i).card) + (hs : 2*k+1≤∑ i,ki i) : + (k:ℝ)*(2*D-k)+(∑ e,(h e:ℝ)*(k-h e))+ + (∑ i : Fin 13, (-(D:ℝ)*ki i+(ki i:ℝ)*(ki i-1)/2))≤-(D:ℝ)+1575 := by + have hsq (e : Fin 33) : (h e:ℝ)^2=2*(h e:ℝ) := by rcases hh e with he|he <;> rw [he] <;> norm_num + have hle (e : Fin 33) : (h e:ℝ)≤2 := by rcases hh e with he|he <;> rw [he] <;> norm_num + have hb : (∑ e,(h e:ℝ))≤66 := by + calc _ ≤ ∑ _e : Fin 33,(2:ℝ) := Finset.sum_le_sum (fun e _=>hle e) + _ = _ := by norm_num + have hn : 0≤∑ e,(h e:ℝ) := Finset.sum_nonneg (fun _ _=>Nat.cast_nonneg _) + have hs' : 2*(k:ℝ)+1≤∑ i,(ki i:ℝ) := by exact_mod_cast hs + have hc := local_choose_sum_bound ki hk + have hh' : (∑ e,(h e:ℝ)*(k-h e))=(k:ℝ)*(∑ e,(h e:ℝ))-2*(∑ e,(h e:ℝ)) := by + simp_rw [mul_sub,←pow_two,hsq] + rw [Finset.sum_sub_distrib,←Finset.sum_mul,←Finset.mul_sum] + ring + have hg : (∑ i : Fin 13, (-(D:ℝ)*ki i+(ki i:ℝ)*(ki i-1)/2))= + -(D:ℝ)*(∑ i,(ki i:ℝ))+(∑ i : Fin 13,(ki i:ℝ)*(ki i-1)/2) := by + rw [Finset.sum_add_distrib,←Finset.mul_sum] + rw [hh',hg] + have hd := mul_nonneg (Nat.cast_nonneg D) (sub_nonneg.mpr hs') + have hm := mul_nonneg hn (sub_nonneg.mpr hb) + nlinarith [sq_nonneg ((k:ℝ)-(∑ e,(h e:ℝ))/2)] +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section Containment +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] +variable (ω : LinearMap.BilinForm K E) +noncomputable def pairSpaces (L : Fin 13 → SymplecticLagrangian ω) (e : Fin 33) : Submodule K E := + (pairVertices e).inf (fun i=>(L i).val) + theorem pairSpaces_le (L : Fin 13 → SymplecticLagrangian ω) (e : Fin 33) (i : Fin 13) + (hi : i∈pairVertices e) : pairSpaces ω L e≤(L i).val := Finset.inf_le hi + theorem incidentPairSpaces_le (L : Fin 13 → SymplecticLagrangian ω) (i : Fin 13) : + incidentSpan (pairSpaces ω L) i≤(L i).val := + incidentSpan_le (fun e he=>pairSpaces_le ω L e i he) + theorem pairSpaces_orthogonal (L : Fin 13 → SymplecticLagrangian ω) (e f : Fin 33) + (hr : pairRelated e f) {x y : E} (hx : x∈pairSpaces ω L e) (hy : y∈pairSpaces ω L f) : ω x y=0 := by + classical + obtain ⟨i,he,hf⟩ := Finset.not_disjoint_iff.mp hr + have hxi := pairSpaces_le ω L e i he hx + have hyi := pairSpaces_le ω L f i hf hy + have hyO : y∈ω.orthogonal (L i).val := (L i).property.symm ▸ hyi + exact hyO x hxi +abbrev PairDimProfile (h : Fin 33 → ℕ) := + {L : Fin 13 → SymplecticLagrangian ω // ∀ e,finrank K (pairSpaces ω L e)=h e} +abbrev DirectPairProfile (h : Fin 33 → ℕ) := + {L : PairDimProfile ω h // iSupIndep (pairSpaces ω L.val)} +abbrev FamilyContainment (A : Fin 33 → Submodule K E) := + (i : Fin 13) → {L : SymplecticLagrangian ω // incidentSpan A i≤L.val} +noncomputable def directPairProfileCoding (h : Fin 33 → ℕ) (L : DirectPairProfile ω h) : + Σ A : DirectFamily ω h pairRelated, FamilyContainment ω (fun e=>(A.val e).val) := + ⟨⟨fun e=>⟨pairSpaces ω L.val.val e,L.val.property e⟩,L.property, + fun e f hr _ hx _ hy=>pairSpaces_orthogonal ω L.val.val e f hr hx hy⟩, + fun i=>⟨L.val.val i,incidentPairSpaces_le ω L.val.val i⟩⟩ + theorem directPairProfileCoding_injective (h : Fin 33 → ℕ) : + Function.Injective (directPairProfileCoding ω h) := by + let recover : (Σ A : DirectFamily ω h pairRelated, FamilyContainment ω (fun e=>(A.val e).val)) → + (Fin 13 → SymplecticLagrangian ω) := fun x i=>(x.2 i).val + intro x y hxy + exact Subtype.ext (Subtype.ext (congrArg recover hxy)) +noncomputable def containmentExponent (D : ℕ) (ki : Fin 13 → ℕ) : ℝ := + ∑ i, (-(D:ℝ)*ki i+(ki i:ℝ)*(ki i-1)/2) +variable [Fintype K] [Finite E] + theorem familyContainment_card_bound (h2 : (2:K)≠0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D=finrank K E) (A : Fin 33 → Submodule K E) (ki : Fin 13 → ℕ) + (hk : ∀ i,finrank K (incidentSpan A i)=ki i) : + (Nat.card (FamilyContainment ω A):ℝ) ≤ (lagrangianConstant D)^13* + (Nat.card (SymplecticLagrangian ω):ℝ)^13*(Fintype.card K:ℝ)^(containmentExponent D ki) := by + have hq : 0<(Fintype.card K:ℝ) := by exact_mod_cast Fintype.card_pos (α:=K) + have hp (i : Fin 13) : (Nat.card {L : SymplecticLagrangian ω // incidentSpan A i≤L.val}:ℝ) ≤ + lagrangianConstant D*(Nat.card (SymplecticLagrangian ω):ℝ)* + (Fintype.card K:ℝ)^(-(D:ℝ)*ki i+(ki i:ℝ)*(ki i-1)/2) := by + simpa only [hk i] using containingLagrangian_card_rpow ω h2 ha hω D hD (incidentSpan A i) + have hh := Finset.prod_le_prod₀ (s:=Finset.univ) (fun i _=>Nat.cast_nonneg (Nat.card {L : SymplecticLagrangian ω // incidentSpan A i≤L.val})) (fun i _=>hp i) + rw [FamilyContainment,Nat.card_pi,Nat.cast_prod] + calc _ ≤ _ := hh + _ = _ := by + rw [Finset.prod_mul_distrib,Finset.prod_const,Finset.card_univ,Fintype.card_fin, + mul_pow,←Real.rpow_sum_of_pos hq] + rfl + theorem directPairProfile_card_bound (h2 : (2:K)≠0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D=finrank K E) (h : Fin 33 → ℕ) (hn : (∑ e,h e)≤2*D) : + (Nat.card (DirectPairProfile ω h):ℝ) ≤ + 2^(∑ e,h e)*(lagrangianConstant D)^13*(Nat.card (SymplecticLagrangian ω):ℝ)^13* + (Fintype.card K:ℝ)^(-(∑ e,triangular (h e))) := by + have hq : 0<(Fintype.card K:ℝ) := by exact_mod_cast Fintype.card_pos (α:=K) + have hs : ∀ A : DirectFamily ω h pairRelated, (Nat.card (FamilyContainment ω (fun e=>(A.val e).val)):ℝ) ≤ + (lagrangianConstant D)^13*(Nat.card (SymplecticLagrangian ω):ℝ)^13* + (Fintype.card K:ℝ)^(containmentExponent D (localPairDim h)) := by + intro A + exact familyContainment_card_bound ω h2 ha hω D hD _ _ (incidentSpan_finrank_direct h A.val A.property.1) + have hi : (Nat.card (DirectPairProfile ω h):ℝ)≤ + Nat.card (Σ A : DirectFamily ω h pairRelated,FamilyContainment ω (fun e=>(A.val e).val)) := by + exact_mod_cast Nat.card_le_card_of_injective _ (directPairProfileCoding_injective ω h) + have hn' : (∑ e,h e)≤finrank K E := hD ▸ hn + have hf := directFamily_card_bound ω hω h pairRelated pairRelated_symm hn' + rw [←hD,Nat.cast_mul,Nat.cast_ofNat,Nat.cast_sum] at hf + have hc : 0 ≤ (lagrangianConstant D)^13*(Nat.card (SymplecticLagrangian ω):ℝ)^13* + (Fintype.card K:ℝ)^(containmentExponent D (localPairDim h)) := + mul_nonneg (mul_nonneg (pow_nonneg (lagrangianConstant_pos D).le _) + (pow_nonneg (Nat.cast_nonneg _) _)) (Real.rpow_nonneg hq.le _) + calc _ ≤ _ := hi.trans (real_card_sigma_le _ hs) + _ ≤ _ := mul_le_mul_of_nonneg_right hf hc + _ = _ := by + have he := residual_direct_exponent D h + change _+containmentExponent D (localPairDim h)=_ at he + rw [←he,Real.rpow_add hq] + ring +end Containment +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section Nondirect +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] +variable (ω : LinearMap.BilinForm K E) +variable [Fintype K] [Finite E] +abbrev LocalFamilyStratum (h : Fin 33 → ℕ) (k : ℕ) (ki : Fin 13 → ℕ) := + {A : FamilySpanStratum (K:=K) (E:=E) h k // ∀ i,finrank K (incidentSpan (fun e=>(A.val e).val) i)=ki i} +abbrev PairSpanStratum (h : Fin 33 → ℕ) (k : ℕ) (ki : Fin 13 → ℕ) := + {L : PairDimProfile ω h // finrank K ↥(⨆ e,pairSpaces ω L.val e)=k ∧ + ∀ i,finrank K (incidentSpan (pairSpaces ω L.val) i)=ki i} +noncomputable def pairSpanStratumCoding (h : Fin 33 → ℕ) (k : ℕ) (ki : Fin 13 → ℕ) + (L : PairSpanStratum ω h k ki) : + Σ A : LocalFamilyStratum (K:=K) (E:=E) h k ki, FamilyContainment ω (fun e=>(A.val.val e).val) := + ⟨⟨⟨fun e=>⟨pairSpaces ω L.val.val e,L.val.property e⟩,L.property.1⟩,L.property.2⟩, + fun i=>⟨L.val.val i,incidentPairSpaces_le ω L.val.val i⟩⟩ +omit [Fintype K] [Finite E] in + theorem pairSpanStratumCoding_injective (h : Fin 33 → ℕ) (k : ℕ) (ki : Fin 13 → ℕ) : + Function.Injective (pairSpanStratumCoding ω h k ki) := by + let recover : (Σ A : LocalFamilyStratum (K:=K) (E:=E) h k ki, + FamilyContainment ω (fun e=>(A.val.val e).val)) → (Fin 13 → SymplecticLagrangian ω) := + fun x i=>(x.2 i).val + intro x y hxy + exact Subtype.ext (Subtype.ext (congrArg recover hxy)) + theorem localFamilyStratum_card_bound (h : Fin 33 → ℕ) (k : ℕ) (ki : Fin 13 → ℕ) + (hk : k≤finrank K E) (hh : ∀ e,h e≤k) : + (Nat.card (LocalFamilyStratum (K:=K) (E:=E) h k ki):ℝ)≤ + 2^(k+∑ e,h e)*(Fintype.card K:ℝ)^(k*(finrank K E-k)+∑ e,h e*(k-h e)) := by + have hi : Nat.card (LocalFamilyStratum (K:=K) (E:=E) h k ki)≤ + Nat.card (FamilySpanStratum (K:=K) (E:=E) h k) := + Nat.card_le_card_of_injective Subtype.val Subtype.val_injective + exact (Nat.cast_le.mpr hi).trans (familySpan_card_upper h k hk hh) + theorem familySpan_exponent_cast (h : Fin 33 → ℕ) (k n : ℕ) (hk : k≤n) (hh : ∀ e,h e≤k) : + ((k*(n-k)+∑ e,h e*(k-h e):ℕ):ℝ)= + (k:ℝ)*(n-k)+∑ e,(h e:ℝ)*(k-h e) := by + simp only [Nat.cast_add,Nat.cast_mul,Nat.cast_sub hk,Nat.cast_sum,Nat.cast_sub (hh _)] + theorem pairSpanStratum_card_bound (h2 : (2:K)≠0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D=finrank K E) (h : Fin 33 → ℕ) (k : ℕ) (ki : Fin 13 → ℕ) + (hk : k≤2*D) (hh : ∀ e,h e≤k) : + (Nat.card (PairSpanStratum ω h k ki):ℝ)≤ + 2^(k+∑ e,h e)*(lagrangianConstant D)^13*(Nat.card (SymplecticLagrangian ω):ℝ)^13* + (Fintype.card K:ℝ)^((k:ℝ)*(2*D-k)+(∑ e,(h e:ℝ)*(k-h e))+containmentExponent D ki) := by + have hq : 0<(Fintype.card K:ℝ) := by exact_mod_cast Fintype.card_pos (α:=K) + have hs : ∀ A : LocalFamilyStratum (K:=K) (E:=E) h k ki, + (Nat.card (FamilyContainment ω (fun e=>(A.val.val e).val)):ℝ) ≤ + (lagrangianConstant D)^13*(Nat.card (SymplecticLagrangian ω):ℝ)^13* + (Fintype.card K:ℝ)^(containmentExponent D ki) := by + intro A + exact familyContainment_card_bound ω h2 ha hω D hD _ _ A.property + have hi : (Nat.card (PairSpanStratum ω h k ki):ℝ)≤ + Nat.card (Σ A : LocalFamilyStratum (K:=K) (E:=E) h k ki,FamilyContainment ω (fun e=>(A.val.val e).val)) := by + exact_mod_cast Nat.card_le_card_of_injective _ (pairSpanStratumCoding_injective ω h k ki) + have hn : k≤finrank K E := hD ▸ hk + have hf := localFamilyStratum_card_bound h k ki hn hh + rw [←Real.rpow_natCast (Fintype.card K:ℝ),familySpan_exponent_cast h k _ hn hh,←hD, + Nat.cast_mul,Nat.cast_ofNat] at hf + have hc : 0 ≤ (lagrangianConstant D)^13*(Nat.card (SymplecticLagrangian ω):ℝ)^13* + (Fintype.card K:ℝ)^(containmentExponent D ki) := + mul_nonneg (mul_nonneg (pow_nonneg (lagrangianConstant_pos D).le _) + (pow_nonneg (Nat.cast_nonneg _) _)) (Real.rpow_nonneg hq.le _) + calc _ ≤ _ := hi.trans (real_card_sigma_le _ hs) + _ ≤ _ := mul_le_mul_of_nonneg_right hf hc + _ = _ := by simp only [Real.rpow_add hq];ring + theorem residual_h_sum_le (h : Fin 33 → ℕ) (hh : ∀ e,h e=0 ∨ h e=2) : (∑ e,h e)≤66 := by + calc _ ≤ ∑ _e : Fin 33,2 := Finset.sum_le_sum (fun e _=>by rcases hh e with he|he <;> omega) + _ = _ := by decide +omit [Fintype K] in + theorem pairProfile_global_dim_le (h : Fin 33 → ℕ) (L : PairDimProfile ω h) : + finrank K ↥(⨆ e,pairSpaces ω L.val e)≤∑ e,h e := by + have hh := finrank_finite_iSup_le (pairSpaces ω L.val) + simpa only [L.property] using hh +omit [Fintype K] in + theorem pairProfile_local_dim_le (h : Fin 33 → ℕ) (L : PairDimProfile ω h) (i : Fin 13) : + finrank K (incidentSpan (pairSpaces ω L.val) i)≤localPairDim h i := + incidentSpan_finrank_le h (fun e=>⟨_,L.property e⟩) i +abbrev ResidualDimensionBox := Fin 67 × (Fin 13 → Fin 13) +noncomputable def pairProfileDimension (h : Fin 33 → ℕ) (hh : ∀ e,h e=0 ∨ h e=2) + (L : PairDimProfile ω h) : ResidualDimensionBox := + (⟨finrank K ↥(⨆ e,pairSpaces ω L.val e),by + have := (pairProfile_global_dim_le ω h L).trans (residual_h_sum_le h hh); omega⟩, + fun i=>⟨finrank K (incidentSpan (pairSpaces ω L.val) i),by + have := (pairProfile_local_dim_le ω h L i).trans (localPairDim_le_twelve h (fun e=>by rcases hh e with he|he <;> omega) i) + omega⟩) +abbrev NonDirectPairProfile (h : Fin 33 → ℕ) := + {L : PairDimProfile ω h // ¬iSupIndep (pairSpaces ω L.val)} +noncomputable def nondirectDimension (h : Fin 33 → ℕ) (hh : ∀ e,h e=0 ∨ h e=2) + (L : NonDirectPairProfile ω h) : ResidualDimensionBox := pairProfileDimension ω h hh L.val +noncomputable def nondirectFiberInjection (h : Fin 33 → ℕ) (hh : ∀ e,h e=0 ∨ h e=2) + (b : ResidualDimensionBox) (L : {L : NonDirectPairProfile ω h // nondirectDimension ω h hh L=b}) : + PairSpanStratum ω h b.1.val (fun i=>(b.2 i).val) := by + refine ⟨L.val.val,?_,?_⟩ + · exact congrArg (fun b : ResidualDimensionBox=>b.1.val) L.property + · intro i + exact congrArg (fun b : ResidualDimensionBox=>(b.2 i).val) L.property +omit [Fintype K] in + theorem nondirectFiberInjection_injective (h : Fin 33 → ℕ) (hh : ∀ e,h e=0 ∨ h e=2) + (b : ResidualDimensionBox) : Function.Injective (nondirectFiberInjection ω h hh b) := by + intro x y hxy + apply Subtype.ext + apply Subtype.ext + exact congrArg (fun X : PairSpanStratum ω h b.1.val (fun i=>(b.2 i).val)=>X.val) hxy + theorem pairStratum_residual_bound (h2 : (2:K)≠0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D=finrank K E) (h : Fin 33 → ℕ) (hh : ∀ e,h e=0 ∨ h e=2) + (b : ResidualDimensionBox) (hk : b.1.val≤2*D) (he : ∀ e,h e≤b.1.val) + (hki : ∀ i,(b.2 i).val≤2*(incidentPairs i).card) (hs : 2*b.1.val+1≤∑ i,(b.2 i).val) : + (Nat.card (PairSpanStratum ω h b.1.val (fun i=>(b.2 i).val)):ℝ)≤ + 2^132*(lagrangianConstant D)^13*(Nat.card (SymplecticLagrangian ω):ℝ)^13* + (Fintype.card K:ℝ)^(-(D:ℝ)+1575) := by + have hf := pairSpanStratum_card_bound ω h2 ha hω D hD h b.1.val (fun i=>(b.2 i).val) hk he + have hq : 1≤(Fintype.card K:ℝ) := by exact_mod_cast Fintype.card_pos (α:=K) + have hfexp := Real.rpow_le_rpow_of_exponent_le hq + (residual_nondirect_exponent D b.1.val h (fun i=>(b.2 i).val) hh hki hs) + have hbpow : (2:ℝ)^(b.1.val+∑ e,h e)≤2^132 := by + apply pow_le_pow_right₀ (by norm_num) + have := b.1.isLt + have := residual_h_sum_le h hh + omega + have hC := pow_nonneg (lagrangianConstant_pos D).le 13 + have hL : 0≤(Nat.card (SymplecticLagrangian ω):ℝ)^13 := pow_nonneg (Nat.cast_nonneg _) _ + have hP : (0:ℝ)≤2^132 := pow_nonneg (by norm_num) _ + refine hf.trans ?_ + exact mul_le_mul (mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right hbpow hC) hL) + hfexp (Real.rpow_nonneg (le_trans (by norm_num) hq) _) (mul_nonneg (mul_nonneg hP hC) hL) + theorem nondirectFiber_card_bound (h2 : (2:K)≠0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D=finrank K E) (h : Fin 33 → ℕ) (hh : ∀ e,h e=0 ∨ h e=2) + (b : ResidualDimensionBox) : + (Nat.card {L : NonDirectPairProfile ω h // nondirectDimension ω h hh L=b}:ℝ)≤ + 2^132*(lagrangianConstant D)^13*(Nat.card (SymplecticLagrangian ω):ℝ)^13* + (Fintype.card K:ℝ)^(-(D:ℝ)+1575) := by + classical + by_cases hex : Nonempty {L : NonDirectPairProfile ω h // nondirectDimension ω h hh L=b} + · obtain ⟨L⟩ := hex + let A := pairSpaces ω L.val.val.val + have hb := (nondirectFiberInjection ω h hh b L).property + change finrank K ↥(⨆ e,pairSpaces ω L.val.val.val e)=b.1.val ∧ + (∀ i,finrank K (incidentSpan (pairSpaces ω L.val.val.val) i)=(b.2 i).val) at hb + have hk : b.1.val≤2*D := by + rw [hD,←hb.1] + exact Submodule.finrank_le _ + have he : ∀ e,h e≤b.1.val := by + intro e + rw [←L.val.val.property e,←hb.1] + exact Submodule.finrank_mono (le_iSup (pairSpaces ω L.val.val.val) e) + have hki : ∀ i,(b.2 i).val≤2*(incidentPairs i).card := by + intro i + rw [←hb.2 i] + exact (pairProfile_local_dim_le ω h L.val.val i).trans + (localPairDim_le h (fun e=>by rcases hh e with he|he <;> omega) i) + have hs : 2*b.1.val+1≤∑ i,(b.2 i).val := by + have hs := indexed_strict_span A L.val.property + change 2*finrank K ↥(⨆ e,pairSpaces ω L.val.val.val e)+1≤ + ∑ i,finrank K (incidentSpan (pairSpaces ω L.val.val.val) i) at hs + simpa only [hb.1,hb.2] using hs + have hi : (Nat.card {L : NonDirectPairProfile ω h // nondirectDimension ω h hh L=b}:ℝ)≤ + Nat.card (PairSpanStratum ω h b.1.val (fun i=>(b.2 i).val)) := by + exact_mod_cast Nat.card_le_card_of_injective _ (nondirectFiberInjection_injective ω h hh b) + exact hi.trans (pairStratum_residual_bound ω h2 ha hω D hD h hh b hk he hki hs) + · have : IsEmpty {L : NonDirectPairProfile ω h // nondirectDimension ω h hh L=b} := not_nonempty_iff.mp hex + rw [Nat.card_of_isEmpty,Nat.cast_zero] + exact mul_nonneg (mul_nonneg (mul_nonneg (pow_nonneg (by norm_num) _) + (pow_nonneg (lagrangianConstant_pos D).le _)) (pow_nonneg (Nat.cast_nonneg _) _)) + (Real.rpow_nonneg (Nat.cast_nonneg _) _) + theorem nondirectPairProfile_card_bound (h2 : (2:K)≠0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D=finrank K E) (h : Fin 33 → ℕ) (hh : ∀ e,h e=0 ∨ h e=2) : + (Nat.card (NonDirectPairProfile ω h):ℝ)≤ + (67*13^13)*2^132*(lagrangianConstant D)^13*(Nat.card (SymplecticLagrangian ω):ℝ)^13* + (Fintype.card K:ℝ)^(-(D:ℝ)+1575) := by + have he := Nat.card_congr (Equiv.sigmaFiberEquiv (nondirectDimension ω h hh)) + rw [←he] + have hb := real_card_sigma_le _ (nondirectFiber_card_bound ω h2 ha hω D hD h hh) + convert hb using 1 + simp only [ResidualDimensionBox,Nat.card_prod,Nat.card_fin,Nat.card_fun,Nat.cast_mul,Nat.cast_pow,Nat.cast_ofNat] + ring +end Nondirect +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +abbrev FullTailChoice (D r c : ℕ) (s : Fin 3 → ℕ) := + Σ u : CommonParameters D r c, BaseParameters (D-c) (r-u.val.val) (s 0) (s 1) (s 2) +noncomputable def fullTailConstant (D r c : ℕ) (s : Fin 3 → ℕ) + (x : FullTailChoice D r c s) : ℝ := + (orbitMassConstant D*(lagrangianConstant D)^2)*(lagrangianConstant D*2^c)* + ((2^x.1.val.val*lagrangianConstant (D-x.1.val.val))*2^(3*(D-c)))* + reducedPlantedConstant (r-x.1.val.val) (s 0) (s 1) (s 2) x.2.val + theorem fullTailConstant_nonneg (D r c : ℕ) (s : Fin 3 → ℕ) (x : FullTailChoice D r c s) : + 0 ≤ fullTailConstant D r c s x := by + have h₀ := (orbitMassConstant_pos D).le + have h₁ := (lagrangianConstant_pos D).le + have h₂ := (lagrangianConstant_pos (D-x.1.val.val)).le + unfold fullTailConstant reducedPlantedConstant + positivity +noncomputable def fullTailMajorant (D r c : ℕ) (s : Fin 3 → ℕ) (q : ℝ) : ℝ := + ∑ x : FullTailChoice D r c s, + fullTailConstant D r c s x * q^(tailGain D true (plantedTailTuple D r c s x.1 x.2)) + theorem fullTailMajorant_nonneg (D r c : ℕ) (s : Fin 3 → ℕ) (q : ℝ) (hq : 0≤q) : + 0 ≤ fullTailMajorant D r c s q := by + apply Finset.sum_nonneg + intro x _ + exact mul_nonneg (fullTailConstant_nonneg _ _ _ _ _) (Real.rpow_nonneg hq _) + theorem fullTailMajorant_eq (D r c : ℕ) (s : Fin 3 → ℕ) (q : ℝ) + (hD : D=2*r) (hc : c≤D) (hq : 0 ⟨L.val.val,L.val.property,L.property⟩ + invFun := fun L => ⟨⟨L.val,L.property.1⟩,L.property.2⟩ + left_inv := fun L => rfl + right_inv := fun L => rfl } + have he := Nat.card_congr (e.trans (containingLagrangianEquiv ω S ha hS)) + have hc := reducedSpace_finrank ω S hω hS + have hs := isotropic_finrank_le_half ω hω D hD S hS + let : Finite (ReducedSpace ω S) := Module.finite_of_finite K + rw [he] + exact symplecticLagrangian_card_bounds (symplecticReductionForm ω S ha) h2 + (symplecticReductionForm_alt ω S ha) (symplecticReductionForm_nondegenerate ω S ha hω) + (D-finrank K S) (by omega) + +abbrev IsotropicDimspace (c : ℕ) := + {S : Submodule K E // S ≤ ω.orthogonal S ∧ finrank K S = c} + +noncomputable def isotropicIncidenceEquiv (c : ℕ) : + (Σ S : IsotropicDimspace ω c, {L : SymplecticLagrangian ω // S.val ≤ L.val}) ≃ + (Σ L : SymplecticLagrangian ω, DimSubspace K L.val c) where + toFun p := ⟨p.2.val,⟨p.1.val.comap p.2.val.val.subtype, + (Submodule.comapSubtypeEquivOfLe p.2.property).finrank_eq.trans p.1.property.2⟩⟩ + invFun p := ⟨⟨p.2.val.map p.1.val.subtype,by + constructor + · intro x hx y hy + exact p.1.property.ge (Submodule.map_subtype_le p.1.val _ hx) y + (Submodule.map_subtype_le p.1.val _ hy) + · exact (Submodule.equivMapOfInjective p.1.val.subtype p.1.val.injective_subtype p.2.val).finrank_eq.symm.trans p.2.property⟩, + ⟨p.1,Submodule.map_subtype_le p.1.val _⟩⟩ + left_inv p := by + have hS : (p.1.val.comap p.2.val.val.subtype).map p.2.val.val.subtype = p.1.val := by + rw [Submodule.map_comap_subtype,inf_of_le_right p.2.property] + refine Sigma.ext (Subtype.ext hS) ?_ + apply (Subtype.heq_iff_coe_eq (fun L => ?_)).mpr + · rfl + · change (p.1.val.comap p.2.val.val.subtype).map p.2.val.val.subtype ≤ L.val ↔ p.1.val ≤ L.val + rw [hS] + right_inv p := by + apply Sigma.ext + · rfl + · apply heq_of_eq + apply Subtype.ext + exact Submodule.comap_map_eq_of_injective p.1.val.injective_subtype p.2.val + +omit [Fintype K] [Finite E] in + theorem isotropic_incidence_card (c : ℕ) : + Nat.card (Σ S : IsotropicDimspace ω c, {L : SymplecticLagrangian ω // S.val ≤ L.val}) = + Nat.card (Σ L : SymplecticLagrangian ω, DimSubspace K L.val c) := + Nat.card_congr (isotropicIncidenceEquiv ω c) +end GenericCounts +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators + +/-- The exponent 2Dc-(3c²-c)/2, written without truncated half-integers. -/ +def isotropicExponent (D c : ℕ) : ℕ := + (D+1).choose 2 + c*(D-c) - (D-c+1).choose 2 + + theorem isotropicExponent_add (D c : ℕ) (hc : c ≤ D) : + isotropicExponent D c + (D-c+1).choose 2 = (D+1).choose 2 + c*(D-c) := by + have h := symmetric_nullity_exponent D c hc + exact Nat.sub_add_cancel (by omega) + +section IsotropicCounts +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] + [Fintype K] [Finite E] +variable (ω : LinearMap.BilinForm K E) + + theorem isotropic_card_bounds (h2 : (2 : K) ≠ 0) + (ha : ω.IsAlt) (hω : ω.Nondegenerate) (D : ℕ) (hD : 2*D = finrank K E) + (c : ℕ) (hc : c ≤ D) : + (Fintype.card K : ℝ)^(isotropicExponent D c) ≤ + lagrangianConstant (D-c) * Nat.card (IsotropicDimspace ω c) ∧ + (Nat.card (IsotropicDimspace ω c) : ℝ) ≤ + (lagrangianConstant D * 2^c) * (Fintype.card K : ℝ)^(isotropicExponent D c) := by + classical + let := Fintype.ofFinite (IsotropicDimspace ω c) + let := Fintype.ofFinite (SymplecticLagrangian ω) + let q : ℝ := Fintype.card K + have hq : 0 < q := by + dsimp [q] + exact_mod_cast Fintype.card_pos (α := K) + have hdim (L : SymplecticLagrangian ω) : finrank K L.val = D := by + have h := self_orthogonal_twice_finrank ω L.val hω L.property + omega + have hs (S : IsotropicDimspace ω c) := + containingLagrangian_card_bounds ω h2 ha hω D hD S.val S.property.1 + have hs' (S : IsotropicDimspace ω c) : + q^((D-c+1).choose 2) ≤ Nat.card {L : SymplecticLagrangian ω // S.val ≤ L.val} ∧ + (Nat.card {L : SymplecticLagrangian ω // S.val ≤ L.val} : ℝ) ≤ + lagrangianConstant (D-c)*q^((D-c+1).choose 2) := by + simpa only [S.property.2] using hs S + have hsum : (∑ S : IsotropicDimspace ω c, + (Nat.card {L : SymplecticLagrangian ω // S.val ≤ L.val} : ℝ)) = + ∑ L : SymplecticLagrangian ω, (Nat.card (DimSubspace K L.val c) : ℝ) := by + have h := isotropic_incidence_card ω c + rw [Nat.card_sigma,Nat.card_sigma] at h + exact_mod_cast h + have hgrass (L : SymplecticLagrangian ω) : + q^(c*(D-c)) ≤ Nat.card (DimSubspace K L.val c) ∧ + (Nat.card (DimSubspace K L.val c) : ℝ) ≤ 2^c*q^(c*(D-c)) := by + have hcL : c ≤ finrank K L.val := (hdim L).symm ▸ hc + constructor + · simpa only [hdim L] using subspace_count_lower (K := K) (V := L.val) c hcL + · simpa only [hdim L] using subspace_count_upper (K := K) (V := L.val) c hcL + have hu : (Nat.card (IsotropicDimspace ω c) : ℝ)*q^((D-c+1).choose 2) ≤ + (Nat.card (SymplecticLagrangian ω) : ℝ)*(2^c*q^(c*(D-c))) := by + calc + _ = ∑ _S : IsotropicDimspace ω c, q^((D-c+1).choose 2) := by + simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,Nat.card_eq_fintype_card] + _ ≤ ∑ S : IsotropicDimspace ω c, + (Nat.card {L : SymplecticLagrangian ω // S.val ≤ L.val} : ℝ) := + Finset.sum_le_sum (fun S _ => (hs' S).1) + _ = _ := hsum + _ ≤ ∑ _L : SymplecticLagrangian ω, 2^c*q^(c*(D-c)) := + Finset.sum_le_sum (fun L _ => (hgrass L).2) + _ = _ := by simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,Nat.card_eq_fintype_card] + have hl : (Nat.card (SymplecticLagrangian ω) : ℝ)*q^(c*(D-c)) ≤ + (Nat.card (IsotropicDimspace ω c) : ℝ)*(lagrangianConstant (D-c)*q^((D-c+1).choose 2)) := by + calc + _ = ∑ _L : SymplecticLagrangian ω, q^(c*(D-c)) := by + simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,Nat.card_eq_fintype_card] + _ ≤ ∑ L : SymplecticLagrangian ω, (Nat.card (DimSubspace K L.val c) : ℝ) := + Finset.sum_le_sum (fun L _ => (hgrass L).1) + _ = _ := hsum.symm + _ ≤ ∑ _S : IsotropicDimspace ω c, lagrangianConstant (D-c)*q^((D-c+1).choose 2) := + Finset.sum_le_sum (fun S _ => (hs' S).2) + _ = _ := by simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,Nat.card_eq_fintype_card] + have hlag := symplecticLagrangian_card_bounds ω h2 ha hω D hD + have he : q^(isotropicExponent D c)*q^((D-c+1).choose 2) = + q^((D+1).choose 2)*q^(c*(D-c)) := by + rw [←pow_add,isotropicExponent_add D c hc,pow_add] + constructor + · apply (mul_le_mul_iff_left₀ (pow_pos hq ((D-c+1).choose 2))).mp + calc + _ = q^((D+1).choose 2)*q^(c*(D-c)) := he + _ ≤ (Nat.card (SymplecticLagrangian ω) : ℝ)*q^(c*(D-c)) := + mul_le_mul_of_nonneg_right hlag.1 (by positivity) + _ ≤ _ := hl + _ = _ := by ring + · apply (mul_le_mul_iff_left₀ (pow_pos hq ((D-c+1).choose 2))).mp + calc + _ ≤ _ := hu + _ ≤ (lagrangianConstant D*q^((D+1).choose 2))*(2^c*q^(c*(D-c))) := + mul_le_mul_of_nonneg_right hlag.2 (by positivity) + _ = (lagrangianConstant D*2^c)*(q^((D+1).choose 2)*q^(c*(D-c))) := by ring + _ = _ := by rw [←he]; ring +end IsotropicCounts +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators + + theorem lagrangianConstant_mono : Monotone lagrangianConstant := by + intro m n h + unfold lagrangianConstant + exact mul_le_mul (by exact_mod_cast Nat.add_le_add_right h 1) + (pow_le_pow_right₀ (by norm_num) h) (by positivity) (by positivity) + +section AvoidanceCounts +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] + [Fintype K] [Finite E] +variable (ω : LinearMap.BilinForm K E) + +/-- The elementary line union bound, expressed before taking probabilities. -/ +theorem lagrangian_bad_intersection_card (h2 : (2 : K) ≠ 0) + (ha : ω.IsAlt) (hω : ω.Nondegenerate) (D : ℕ) (hD : 2*D = finrank K E) + (S : Submodule K E) (hS : S ≤ ω.orthogonal S) (hpos : 0 < finrank K S) : + (Nat.card {L : SymplecticLagrangian ω // ¬ Disjoint L.val S} : ℝ) ≤ + (2*(Fintype.card K : ℝ)^(finrank K S-1)) * + (lagrangianConstant (D-1)*(Fintype.card K : ℝ)^((D-1+1).choose 2)) := by + classical + let Line := DimSubspace K S 1 + let B := {L : SymplecticLagrangian ω // ¬ Disjoint L.val S} + let Inc := Σ ℓ : Line, {L : SymplecticLagrangian ω // ℓ.val.map S.subtype ≤ L.val} + let := Fintype.ofFinite Line + have hex (L : B) : ∃ ℓ : Line, ℓ.val.map S.subtype ≤ L.val.val := by + have hne : L.val.val ⊓ S ≠ ⊥ := by simpa only [disjoint_iff] using L.property + obtain ⟨x,hx,hx0⟩ := Submodule.exists_mem_ne_zero_of_ne_bot hne + let v : S := ⟨x,hx.2⟩ + have hv : v ≠ 0 := by intro h; exact hx0 (congrArg Subtype.val h) + refine ⟨⟨K ∙ v, finrank_span_singleton hv⟩,?_⟩ + rintro y ⟨z,hz,rfl⟩ + obtain ⟨a,rfl⟩ := Submodule.mem_span_singleton.mp hz + exact L.val.val.smul_mem a hx.1 + let f : B → Inc := fun L => ⟨(hex L).choose,⟨L.val,(hex L).choose_spec⟩⟩ + have hfi : Function.Injective f := by + intro L M h + apply Subtype.ext + exact congrArg (fun i : Inc => i.2.val) h + have hi (ℓ : Line) : (Nat.card {L : SymplecticLagrangian ω // + ℓ.val.map S.subtype ≤ L.val} : ℝ) ≤ + lagrangianConstant (D-1)*(Fintype.card K : ℝ)^((D-1+1).choose 2) := by + have hle : ℓ.val.map S.subtype ≤ S := by rintro x ⟨y,_,rfl⟩; exact y.property + have hiso : ℓ.val.map S.subtype ≤ ω.orthogonal (ℓ.val.map S.subtype) := + hle.trans (hS.trans (ω.orthogonal_le hle)) + have hd : finrank K (ℓ.val.map S.subtype) = 1 := by + exact (Submodule.equivMapOfInjective S.subtype S.subtype_injective ℓ.val).finrank_eq.symm.trans ℓ.property + simpa only [hd] using (containingLagrangian_card_bounds ω h2 ha hω D hD + (ℓ.val.map S.subtype) hiso).2 + have hinc : (Nat.card Inc : ℝ) ≤ (Nat.card Line : ℝ)* + (lagrangianConstant (D-1)*(Fintype.card K : ℝ)^((D-1+1).choose 2)) := by + rw [Nat.card_sigma,Nat.cast_sum] + calc + _ ≤ ∑ _ℓ : Line, lagrangianConstant (D-1)*(Fintype.card K : ℝ)^((D-1+1).choose 2) := + Finset.sum_le_sum (fun ℓ _ => hi ℓ) + _ = _ := by simp [Nat.card_eq_fintype_card] + have hl : (Nat.card Line : ℝ) ≤ 2*(Fintype.card K : ℝ)^(finrank K S-1) := by + simpa [Line] using subspace_count_upper (K := K) (V := S) 1 hpos + calc + _ ≤ (Nat.card Inc : ℝ) := by exact_mod_cast Nat.card_le_card_of_injective f hfi + _ ≤ _ := hinc + _ ≤ _ := mul_le_mul_of_nonneg_right hl (by + exact mul_nonneg (lagrangianConstant_pos _).le (by positivity)) + +/-- For fixed dimension, failure of avoiding an isotropic space is O(1/q). +No transversality statement is used as a probabilistic assumption. -/ +theorem lagrangian_bad_intersection_scaled (h2 : (2 : K) ≠ 0) + (ha : ω.IsAlt) (hω : ω.Nondegenerate) (D : ℕ) (hD : 2*D = finrank K E) + (S : Submodule K E) (hS : S ≤ ω.orthogonal S) : + (Nat.card {L : SymplecticLagrangian ω // ¬ Disjoint L.val S} : ℝ) * + Fintype.card K ≤ 2*lagrangianConstant D*Nat.card (SymplecticLagrangian ω) := by + classical + let q : ℝ := Fintype.card K + have hq : 1 ≤ q := by dsimp [q]; exact_mod_cast Fintype.card_pos (α := K) + by_cases hp : 0 < finrank K S + · have hs := isotropic_finrank_le_half ω hω D hD S hS + have hDpos : 0 < D := lt_of_lt_of_le hp hs + have he : (D-1+1).choose 2 + D = (D+1).choose 2 := by + rw [Nat.sub_add_cancel hDpos, Nat.choose_succ_succ,Nat.choose_one_right] + change D.choose 2 + D = D + D.choose 2 + omega + have hpow : q^((finrank K S-1)+(D-1+1).choose 2+1) ≤ q^((D+1).choose 2) := by + apply pow_le_pow_right₀ hq + omega + have hc : lagrangianConstant (D-1) ≤ lagrangianConstant D := lagrangianConstant_mono (Nat.sub_le _ _) + calc + _ ≤ (2*q^(finrank K S-1))*(lagrangianConstant (D-1)*q^((D-1+1).choose 2))*q := + mul_le_mul_of_nonneg_right (lagrangian_bad_intersection_card ω h2 ha hω D hD S hS hp) (by positivity) + _ = 2*lagrangianConstant (D-1)*q^((finrank K S-1)+(D-1+1).choose 2+1) := by + simp only [pow_add,pow_one]; ring + _ ≤ 2*lagrangianConstant D*q^((D+1).choose 2) := + mul_le_mul (mul_le_mul_of_nonneg_left hc (by norm_num)) hpow + (by positivity) (by exact mul_nonneg (by norm_num) (lagrangianConstant_pos D).le) + _ ≤ _ := mul_le_mul_of_nonneg_left + (symplecticLagrangian_card_bounds ω h2 ha hω D hD).1 + (mul_nonneg (by norm_num) (lagrangianConstant_pos D).le) + · have hfin : finrank K S = 0 := by omega + have hbot : S = ⊥ := Submodule.finrank_eq_zero.mp hfin + have he : IsEmpty {L : SymplecticLagrangian ω // ¬ Disjoint L.val S} := by + rw [hbot] + exact ⟨fun L => L.property disjoint_bot_right⟩ + have := he + simp only [Nat.card_of_isEmpty,Nat.cast_zero,zero_mul] + exact mul_nonneg (mul_nonneg (by norm_num) (lagrangianConstant_pos D).le) (by positivity) + + + + +theorem lagrangian_disjoint_card_lower (h2 : (2 : K) ≠ 0) + (ha : ω.IsAlt) (hω : ω.Nondegenerate) (D : ℕ) (hD : 2*D = finrank K E) + (S : Submodule K E) (hS : S ≤ ω.orthogonal S) + (hq : 4*lagrangianConstant D ≤ (Fintype.card K : ℝ)) : + (Nat.card (SymplecticLagrangian ω) : ℝ) ≤ + 2*Nat.card {L : SymplecticLagrangian ω // Disjoint L.val S} := by + classical + let := Fintype.ofFinite (SymplecticLagrangian ω) + have hsum : Nat.card {L : SymplecticLagrangian ω // Disjoint L.val S} + + Nat.card {L : SymplecticLagrangian ω // ¬ Disjoint L.val S} = + Nat.card (SymplecticLagrangian ω) := by + simp only [Nat.card_eq_fintype_card,Fintype.card_subtype_compl] + exact Nat.add_sub_of_le (Fintype.card_subtype_le _) + have hsumR := congrArg (fun n : ℕ => (n : ℝ)) hsum + push_cast at hsumR + have hbad := lagrangian_bad_intersection_scaled ω h2 ha hω D hD S hS + have hC := lagrangianConstant_pos D + have hbad0 : (0 : ℝ) ≤ Nat.card {L : SymplecticLagrangian ω // ¬ Disjoint L.val S} := by positivity + nlinarith + +end AvoidanceCounts +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section ContainmentAvoidance +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] +variable (ω : LinearMap.BilinForm K E) + + theorem reduceSubspace_isotropic (ha : ω.IsAlt) (A S : Submodule K E) + (hS : S ≤ ω.orthogonal S) : + reduceSubspace ω A S ≤ (symplecticReductionForm ω A ha).orthogonal (reduceSubspace ω A S) := by + rintro x ⟨x,hx,rfl⟩ y ⟨y,hy,rfl⟩ + exact hS hx y.val hy + +/-- Containment and exact intersection become ordinary avoidance in the +containment quotient. This is a literal equivalence of finite sample spaces. -/ +noncomputable def containmentAvoidanceEquiv (ha : ω.IsAlt) + (A S : Submodule K E) (hAS : A ≤ S) (hS : S ≤ ω.orthogonal S) : + AvoidanceSpace ω S A ≃ + {L : SymplecticLagrangian (symplecticReductionForm ω A ha) // + Disjoint L.val (reduceSubspace ω A S)} := by + have hAP : A ≤ ω.orthogonal A := hAS.trans (hS.trans (ω.orthogonal_le hAS)) + have hSP : S ≤ ω.orthogonal A := hS.trans (ω.orthogonal_le hAS) + let e := containingLagrangianEquiv ω A ha hAP + let f : AvoidanceSpace ω S A → + {L : SymplecticLagrangian (symplecticReductionForm ω A ha) // + Disjoint L.val (reduceSubspace ω A S)} := fun L => by + have hAL : A ≤ L.val := L.property.2.ge.trans inf_le_left + refine ⟨e ⟨L.val,L.property.1,hAL⟩,?_⟩ + apply disjoint_iff.mpr + change reduceSubspace ω A L.val ⊓ reduceSubspace ω A S = ⊥ + rw [← reduceSubspace_inf ω A L.val S hAL,L.property.2,reduceSubspace_self] + have hfi : Function.Injective f := by + intro L M hh + apply Subtype.ext + have he := e.injective (congrArg Subtype.val hh) + exact congrArg (fun X : {T : Submodule K E // ω.orthogonal T = T ∧ A ≤ T} => X.val) he + have hfs : Function.Surjective f := by + intro L + let T := e.symm L.val + have hlast : T.val ⊓ S = A := by + calc + T.val ⊓ S = liftReduction ω A L.val.val ⊓ liftReduction ω A (reduceSubspace ω A S) := by + rw [lift_reduce ω A S hAS hSP] + rfl + _ = liftReduction ω A (L.val.val ⊓ reduceSubspace ω A S) := + (liftReduction_inf ω A _ _).symm + _ = A := by rw [L.property.eq_bot,liftReduction_bot ω A hAP] + refine ⟨⟨T.val,T.property.1,hlast⟩,?_⟩ + apply Subtype.ext + exact e.apply_symm_apply L.val + exact Equiv.ofBijective f ⟨hfi,hfs⟩ + +variable [Fintype K] [Finite E] + + theorem avoidance_card_lower (h2 : (2 : K) ≠ 0) (ha : ω.IsAlt) + (hω : ω.Nondegenerate) (D : ℕ) (hD : 2*D = finrank K E) + (A S : Submodule K E) (hAS : A ≤ S) (hS : S ≤ ω.orthogonal S) + (hq : 4*lagrangianConstant D ≤ (Fintype.card K : ℝ)) : + (Nat.card {L : SymplecticLagrangian ω // A ≤ L.val} : ℝ) ≤ + 2*Nat.card (AvoidanceSpace ω S A) := by + have hAP : A ≤ ω.orthogonal A := hAS.trans (hS.trans (ω.orthogonal_le hAS)) + have hdim := reducedSpace_finrank ω A hω hAP + have hle := isotropic_finrank_le_half ω hω D hD A hAP + let Ω := symplecticReductionForm ω A ha + have hΩa : Ω.IsAlt := symplecticReductionForm_alt ω A ha + have hΩ : Ω.Nondegenerate := symplecticReductionForm_nondegenerate ω A ha hω + let : Finite (ReducedSpace ω A) := Module.finite_of_finite K + have h := lagrangian_disjoint_card_lower Ω h2 hΩa hΩ (D-finrank K A) (by omega) + (reduceSubspace ω A S) (reduceSubspace_isotropic ω ha A S hS) + ((mul_le_mul_of_nonneg_left (lagrangianConstant_mono (Nat.sub_le D _)) (by norm_num)).trans hq) + have he₁ := Nat.card_congr (containmentAvoidanceEquiv ω ha A S hAS hS) + have e₂ : {L : SymplecticLagrangian ω // A ≤ L.val} ≃ + {L : Submodule K E // ω.orthogonal L = L ∧ A ≤ L} := + { toFun := fun L => ⟨L.val.val,L.val.property,L.property⟩ + invFun := fun L => ⟨⟨L.val,L.property.1⟩,L.property.2⟩ + left_inv := fun L => rfl + right_inv := fun L => rfl } + have he₂ := Nat.card_congr (e₂.trans (containingLagrangianEquiv ω A ha hAP)) + rwa [he₁,he₂] + +end ContainmentAvoidance +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section CommonSpaceLift +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] + [FiniteDimensional K E] +variable (ω : LinearMap.BilinForm K E) (S : Submodule K E) + +/-- An isometry of three containing reductions lifts to a simultaneous +isometry of the actual Lagrangians, fixing their common space pointwise. -/ +theorem triple_containing_isometry_lift (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (_hS : S ≤ ω.orthogonal S) (L M N L' M' N' : Submodule K E) + (hL : ω.orthogonal L = L) (hM : ω.orthogonal M = M) (hN : ω.orthogonal N = N) + (hL' : ω.orthogonal L' = L') (hM' : ω.orthogonal M' = M') (hN' : ω.orthogonal N' = N') + (hSL : S ≤ L) (hSM : S ≤ M) (hSN : S ≤ N) + (hSL' : S ≤ L') (hSM' : S ≤ M') (hSN' : S ≤ N') + (hres : TripleIsometry (symplecticReductionForm ω S ha) (symplecticReductionForm ω S ha) + (reduceSubspace ω S L) (reduceSubspace ω S M) (reduceSubspace ω S N) + (reduceSubspace ω S L') (reduceSubspace ω S M') (reduceSubspace ω S N')) : + TripleIsometry ω ω L M N L' M' N' := by + obtain ⟨f,hf,hfL,hfM,hfN⟩ := hres + obtain ⟨e,he,heS,heP,heQ⟩ := exists_reduction_isometry_extension ω S ha hω f hf + have hSe : S.map e.toLinearMap = S := subspace_map_eq_of_fixed e S heS + have hPe : (ω.orthogonal S).map e.toLinearMap = ω.orthogonal S := by + rw [←orthogonal_map_of_isometry ω e he,hSe] + have hmap (U W : Submodule K E) (hU : ω.orthogonal U = U) + (hW : ω.orthogonal W = W) (hSU : S ≤ U) (hSW : S ≤ W) + (hfU : (reduceSubspace ω S U).map f.toLinearMap = reduceSubspace ω S W) : + U.map e.toLinearMap = W := by + have hSUe : S ≤ U.map e.toLinearMap := by + rw [←hSe] + exact Submodule.map_mono hSU + have hUe : ω.orthogonal (U.map e.toLinearMap) = U.map e.toLinearMap := by + rw [orthogonal_map_of_isometry ω e he,hU] + calc + U.map e.toLinearMap = liftReduction ω S (reduceSubspace ω S (U.map e.toLinearMap)) := + (lift_reduce ω S _ hSUe (lagrangian_le_orthogonal ω S _ hUe hSUe)).symm + _ = liftReduction ω S (reduceSubspace ω S W) := by + rw [reduceSubspace_map ω S e f hPe heQ,hfU] + _ = W := lift_reduce ω S W hSW (lagrangian_le_orthogonal ω S W hW hSW) + exact ⟨e,he,hmap L L' hL hL' hSL hSL' hfL, + hmap M M' hM hM' hSM hSM' hfM,hmap N N' hN hN' hSN hSN' hfN⟩ + +end CommonSpaceLift +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section Decompositions +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] + +abbrev PairLinearOrbit (U V : Submodule K E) := + {p : Submodule K E × Submodule K E // ∃ e : E ≃ₗ[K] E, + U.map e.toLinearMap = p.1 ∧ V.map e.toLinearMap = p.2} + +abbrev PairLinearStabilizer (U V : Submodule K E) := + {e : E ≃ₗ[K] E // U.map e.toLinearMap = U ∧ V.map e.toLinearMap = V} + +def pairLinearOrbitMap (U V : Submodule K E) (e : E ≃ₗ[K] E) : PairLinearOrbit U V := + ⟨(U.map e.toLinearMap,V.map e.toLinearMap),e,rfl,rfl⟩ + + theorem submodule_map_trans (U : Submodule K E) (e f : E ≃ₗ[K] E) : + U.map (e.trans f).toLinearMap = (U.map e.toLinearMap).map f.toLinearMap := by + exact Submodule.map_comp _ _ _ + + theorem submodule_map_symm_cancel (U : Submodule K E) (e : E ≃ₗ[K] E) : + (U.map e.toLinearMap).map e.symm.toLinearMap = U := by + rw [←Submodule.map_comp] + simp + +noncomputable def pairLinearOrbitFiberEquiv (U V : Submodule K E) (p : PairLinearOrbit U V) : + {e : E ≃ₗ[K] E // pairLinearOrbitMap U V e = p} ≃ PairLinearStabilizer U V := by + classical + let e₀ := p.property.choose + have hU := p.property.choose_spec.1 + have hV := p.property.choose_spec.2 + have hm (e : {e : E ≃ₗ[K] E // pairLinearOrbitMap U V e = p}) : + U.map e.val.toLinearMap = p.val.1 ∧ V.map e.val.toLinearMap = p.val.2 := by + exact ⟨congrArg (fun a : PairLinearOrbit U V => a.val.1) e.property, + congrArg (fun a : PairLinearOrbit U V => a.val.2) e.property⟩ + refine + { toFun := fun e => ⟨e.val.trans e₀.symm,?_,?_⟩ + invFun := fun e => ⟨e.val.trans e₀,?_⟩ + left_inv := ?_ + right_inv := ?_ } + · rw [submodule_map_trans,(hm _).1,←hU,submodule_map_symm_cancel] + · rw [submodule_map_trans,(hm _).2,←hV,submodule_map_symm_cancel] + · apply Subtype.ext + apply Prod.ext + · change U.map (‹PairLinearStabilizer U V›.val.trans e₀).toLinearMap = p.val.1 + rw [submodule_map_trans] + exact (congrArg (Submodule.map e₀.toLinearMap) ‹PairLinearStabilizer U V›.property.1).trans hU + · change V.map (‹PairLinearStabilizer U V›.val.trans e₀).toLinearMap = p.val.2 + rw [submodule_map_trans] + exact (congrArg (Submodule.map e₀.toLinearMap) ‹PairLinearStabilizer U V›.property.2).trans hV + · intro e + apply Subtype.ext + ext x + simp + · intro e + apply Subtype.ext + ext x + simp + +noncomputable def pairLinearStabilizerRestriction (U V : Submodule K E) : + PairLinearStabilizer U V → (U ≃ₗ[K] U) × (V ≃ₗ[K] V) := fun e => + (e.val.ofSubmodules U U e.property.1,e.val.ofSubmodules V V e.property.2) + + theorem pairLinearStabilizerRestriction_bijective (U V : Submodule K E) (hUV : IsCompl U V) : + Function.Bijective (pairLinearStabilizerRestriction U V) := by + constructor + · intro e f hh + apply Subtype.ext + ext x + have hx : x ∈ U ⊔ V := by rw [hUV.sup_eq_top]; trivial + obtain ⟨u,hu,v,hv,rfl⟩ := Submodule.mem_sup.mp hx + have hU := congrArg (fun p : (U ≃ₗ[K] U) × (V ≃ₗ[K] V) => (p.1 ⟨u,hu⟩).val) hh + have hV := congrArg (fun p : (U ≃ₗ[K] U) × (V ≃ₗ[K] V) => (p.2 ⟨v,hv⟩).val) hh + change e.val u = f.val u at hU + change e.val v = f.val v at hV + simp only [map_add,hU,hV] + · intro g + let c := Submodule.prodEquivOfIsCompl U V hUV + let e : E ≃ₗ[K] E := c.symm.trans ((g.1.prodCongr g.2).trans c) + have heU (u : U) : e u.val = (g.1 u).val := by + have hc : c (u,0) = u.val := by simp [c] + change c ((g.1.prodCongr g.2) (c.symm u.val)) = _ + rw [←hc,c.symm_apply_apply] + simp [c] + have heV (v : V) : e v.val = (g.2 v).val := by + have hc : c (0,v) = v.val := by simp [c] + change c ((g.1.prodCongr g.2) (c.symm v.val)) = _ + rw [←hc,c.symm_apply_apply] + simp [c] + have hU : U.map e.toLinearMap = U := by + ext x + constructor + · rintro ⟨u,hu,rfl⟩ + change e u ∈ U + rw [heU ⟨u,hu⟩] + exact (g.1 ⟨u,hu⟩).property + · intro hx + refine ⟨(g.1.symm ⟨x,hx⟩).val,(g.1.symm ⟨x,hx⟩).property,?_⟩ + exact (heU _).trans (congrArg Subtype.val (g.1.apply_symm_apply ⟨x,hx⟩)) + have hV : V.map e.toLinearMap = V := by + ext x + constructor + · rintro ⟨v,hv,rfl⟩ + change e v ∈ V + rw [heV ⟨v,hv⟩] + exact (g.2 ⟨v,hv⟩).property + · intro hx + refine ⟨(g.2.symm ⟨x,hx⟩).val,(g.2.symm ⟨x,hx⟩).property,?_⟩ + exact (heV _).trans (congrArg Subtype.val (g.2.apply_symm_apply ⟨x,hx⟩)) + refine ⟨⟨e,hU,hV⟩,?_⟩ + apply Prod.ext + · ext u + exact heU u + · ext v + exact heV v + +variable [Fintype K] [Finite E] + + omit [Fintype K] in + theorem pairLinearOrbit_card_identity (U V : Submodule K E) (hUV : IsCompl U V) : + Nat.card (PairLinearOrbit U V) * + (Nat.card (U ≃ₗ[K] U)*Nat.card (V ≃ₗ[K] V)) = Nat.card (E ≃ₗ[K] E) := by + classical + let := Fintype.ofFinite (PairLinearOrbit U V) + have hc : Nat.card (PairLinearStabilizer U V) = + Nat.card (U ≃ₗ[K] U)*Nat.card (V ≃ₗ[K] V) := by + rw [Nat.card_congr (Equiv.ofBijective _ (pairLinearStabilizerRestriction_bijective U V hUV)),Nat.card_prod] + have he := (Nat.card_congr (Equiv.sigmaFiberEquiv (pairLinearOrbitMap U V))).symm + rw [Nat.card_sigma] at he + have hf (p : PairLinearOrbit U V) : Nat.card {e : E ≃ₗ[K] E // pairLinearOrbitMap U V e = p} = + Nat.card (U ≃ₗ[K] U)*Nat.card (V ≃ₗ[K] V) := + (Nat.card_congr (pairLinearOrbitFiberEquiv U V p)).trans hc + simpa only [hf,Finset.sum_const,Finset.card_univ,nsmul_eq_mul,Nat.card_eq_fintype_card,Nat.cast_id] using he.symm + + theorem linearAut_card_upper : Nat.card (E ≃ₗ[K] E) ≤ + Fintype.card K ^ (finrank K E * finrank K E) := by + rw [linearAut_card] + calc + _ ≤ ∏ _i : Fin (finrank K E), Fintype.card K ^ finrank K E := + Finset.prod_le_prod (fun i _ => Nat.sub_le _ _) + _ = _ := by simp only [Finset.prod_const,Finset.card_univ,Fintype.card_fin,←pow_mul] + +/-- Ordered complementary decompositions have q^(2uv) choices up to a +positive fixed-dimension constant; proved from their exact stabilizer. -/ +theorem pairLinearOrbit_card_bounds (U V : Submodule K E) (hUV : IsCompl U V) : + (Fintype.card K : ℝ)^(2*finrank K U*finrank K V) ≤ + 2^(finrank K E)*(Nat.card (PairLinearOrbit U V) : ℝ) ∧ + (Nat.card (PairLinearOrbit U V) : ℝ) ≤ + 2^(finrank K E)*(Fintype.card K : ℝ)^(2*finrank K U*finrank K V) := by + let u := finrank K U + let v := finrank K V + let n := finrank K E + let q : ℝ := Fintype.card K + have hn : u+v = n := Submodule.finrank_add_eq_of_isCompl hUV + have he : n*n = 2*u*v + (u*u+v*v) := by rw [←hn]; ring + have hq : 0 < q := by dsimp [q]; exact_mod_cast Fintype.card_pos (α := K) + have hi : (Nat.card (PairLinearOrbit U V) : ℝ)* + ((Nat.card (U ≃ₗ[K] U) : ℝ)*Nat.card (V ≃ₗ[K] V)) = Nat.card (E ≃ₗ[K] E) := by + exact_mod_cast pairLinearOrbit_card_identity U V hUV + have hu : (Nat.card (U ≃ₗ[K] U) : ℝ) ≤ q^(u*u) := by dsimp [q,u,v,n]; exact_mod_cast linearAut_card_upper (K := K) (E := U) + have hv : (Nat.card (V ≃ₗ[K] V) : ℝ) ≤ q^(v*v) := by dsimp [q,u,v,n]; exact_mod_cast linearAut_card_upper (K := K) (E := V) + have hl : q^(n*n) ≤ 2^n*(Nat.card (E ≃ₗ[K] E) : ℝ) := by dsimp [q,u,v,n]; exact_mod_cast linearAut_card_lower (K := K) (E := E) + have hu' : q^(u*u) ≤ 2^u*(Nat.card (U ≃ₗ[K] U) : ℝ) := by dsimp [q,u,v,n]; exact_mod_cast linearAut_card_lower (K := K) (E := U) + have hv' : q^(v*v) ≤ 2^v*(Nat.card (V ≃ₗ[K] V) : ℝ) := by dsimp [q,u,v,n]; exact_mod_cast linearAut_card_lower (K := K) (E := V) + have hn' : (Nat.card (E ≃ₗ[K] E) : ℝ) ≤ q^(n*n) := by dsimp [q,u,v,n]; exact_mod_cast linearAut_card_upper (K := K) (E := E) + constructor + · apply (mul_le_mul_iff_left₀ (pow_pos hq (u*u+v*v))).mp + calc + _ = q^(n*n) := by rw [←pow_add,←he] + _ ≤ _ := hl + _ = 2^n*((Nat.card (PairLinearOrbit U V) : ℝ)* + ((Nat.card (U ≃ₗ[K] U) : ℝ)*Nat.card (V ≃ₗ[K] V))) := by rw [hi] + _ ≤ 2^n*((Nat.card (PairLinearOrbit U V) : ℝ)*(q^(u*u)*q^(v*v))) := by gcongr + _ = _ := by rw [←pow_add]; ring + · apply (mul_le_mul_iff_left₀ (pow_pos hq (u*u+v*v))).mp + calc + _ = (Nat.card (PairLinearOrbit U V) : ℝ)*(q^(u*u)*q^(v*v)) := by rw [pow_add] + _ ≤ (Nat.card (PairLinearOrbit U V) : ℝ)*((2^u*Nat.card (U ≃ₗ[K] U))*(2^v*Nat.card (V ≃ₗ[K] V))) := by gcongr + _ = 2^n*Nat.card (E ≃ₗ[K] E) := by rw [←hi,←hn,pow_add]; ring + _ ≤ 2^n*q^(n*n) := mul_le_mul_of_nonneg_left hn' (by positivity) + _ = _ := by rw [he,pow_add]; ring + +end Decompositions +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section TripleDecompositions +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] + +/-- Literal coordinates for an ordered direct sum of three subspaces. -/ +noncomputable def tripleSumEquiv (U V W : Submodule K E) + (hU : IsCompl U (V ⊔ W)) (hVW : Disjoint V W) : (U × (V × W)) ≃ₗ[K] E := by + let f := V.subtype.coprod W.subtype + have hr : LinearMap.range f = V ⊔ W := by + rw [LinearMap.range_coprod,Submodule.range_subtype,Submodule.range_subtype] + have hk : LinearMap.ker f = ⊥ := by + rw [LinearMap.ker_coprod_of_disjoint_range,Submodule.ker_subtype,Submodule.ker_subtype,Submodule.prod_bot] + simpa only [Submodule.range_subtype] using hVW + apply LinearEquiv.ofBijective (U.subtype.coprod f) + constructor + · rw [←LinearMap.ker_eq_bot,LinearMap.ker_coprod_of_disjoint_range, + Submodule.ker_subtype,hk,Submodule.prod_bot] + simpa only [Submodule.range_subtype,hr] using hU.disjoint + · rw [←LinearMap.range_eq_top,LinearMap.range_coprod,Submodule.range_subtype,hr,hU.sup_eq_top] + +@[simp] theorem tripleSumEquiv_apply (U V W : Submodule K E) + (hU : IsCompl U (V ⊔ W)) (hVW : Disjoint V W) (u : U) (v : V) (w : W) : + tripleSumEquiv U V W hU hVW (u,(v,w)) = u.val+(v.val+w.val) := rfl + +abbrev TripleLinearOrbit (U V W : Submodule K E) := + {p : Submodule K E × Submodule K E × Submodule K E // ∃ e : E ≃ₗ[K] E, + U.map e.toLinearMap = p.1 ∧ V.map e.toLinearMap = p.2.1 ∧ W.map e.toLinearMap = p.2.2} + +abbrev TripleLinearStabilizer (U V W : Submodule K E) := + {e : E ≃ₗ[K] E // U.map e.toLinearMap = U ∧ V.map e.toLinearMap = V ∧ W.map e.toLinearMap = W} + +def tripleLinearOrbitMap (U V W : Submodule K E) (e : E ≃ₗ[K] E) : TripleLinearOrbit U V W := + ⟨(U.map e.toLinearMap,V.map e.toLinearMap,W.map e.toLinearMap),e,rfl,rfl,rfl⟩ + +noncomputable def tripleLinearOrbitFiberEquiv (U V W : Submodule K E) (p : TripleLinearOrbit U V W) : + {e : E ≃ₗ[K] E // tripleLinearOrbitMap U V W e = p} ≃ TripleLinearStabilizer U V W := by + classical + let e₀ := p.property.choose + have hU := p.property.choose_spec.1 + have hV := p.property.choose_spec.2.1 + have hW := p.property.choose_spec.2.2 + have hm (e : {e : E ≃ₗ[K] E // tripleLinearOrbitMap U V W e = p}) : + U.map e.val.toLinearMap = p.val.1 ∧ V.map e.val.toLinearMap = p.val.2.1 ∧ + W.map e.val.toLinearMap = p.val.2.2 := by + exact ⟨congrArg (fun a : TripleLinearOrbit U V W => a.val.1) e.property, + congrArg (fun a : TripleLinearOrbit U V W => a.val.2.1) e.property, + congrArg (fun a : TripleLinearOrbit U V W => a.val.2.2) e.property⟩ + refine + { toFun := fun e => ⟨e.val.trans e₀.symm,?_,?_,?_⟩ + invFun := fun e => ⟨e.val.trans e₀,?_⟩ + left_inv := ?_ + right_inv := ?_ } + · rw [submodule_map_trans,(hm _).1,←hU,submodule_map_symm_cancel] + · rw [submodule_map_trans,(hm _).2.1,←hV,submodule_map_symm_cancel] + · rw [submodule_map_trans,(hm _).2.2,←hW,submodule_map_symm_cancel] + · apply Subtype.ext + apply Prod.ext + · change U.map (‹TripleLinearStabilizer U V W›.val.trans e₀).toLinearMap = p.val.1 + rw [submodule_map_trans] + exact (congrArg (Submodule.map e₀.toLinearMap) ‹TripleLinearStabilizer U V W›.property.1).trans hU + · apply Prod.ext + · change V.map (‹TripleLinearStabilizer U V W›.val.trans e₀).toLinearMap = p.val.2.1 + rw [submodule_map_trans] + exact (congrArg (Submodule.map e₀.toLinearMap) ‹TripleLinearStabilizer U V W›.property.2.1).trans hV + · change W.map (‹TripleLinearStabilizer U V W›.val.trans e₀).toLinearMap = p.val.2.2 + rw [submodule_map_trans] + exact (congrArg (Submodule.map e₀.toLinearMap) ‹TripleLinearStabilizer U V W›.property.2.2).trans hW + · intro e + apply Subtype.ext + ext x + simp + · intro e + apply Subtype.ext + ext x + simp + +noncomputable def tripleLinearStabilizerRestriction (U V W : Submodule K E) : + TripleLinearStabilizer U V W → (U ≃ₗ[K] U) × (V ≃ₗ[K] V) × (W ≃ₗ[K] W) := fun e => + (e.val.ofSubmodules U U e.property.1,e.val.ofSubmodules V V e.property.2.1, + e.val.ofSubmodules W W e.property.2.2) + + theorem map_eq_of_restriction_aut (U : Submodule K E) (e : E ≃ₗ[K] E) (g : U ≃ₗ[K] U) + (h : ∀ u : U, e u.val = (g u).val) : U.map e.toLinearMap = U := by + ext x + constructor + · rintro ⟨u,hu,rfl⟩ + change e u ∈ U + rw [h ⟨u,hu⟩] + exact (g ⟨u,hu⟩).property + · intro hx + refine ⟨(g.symm ⟨x,hx⟩).val,(g.symm ⟨x,hx⟩).property,?_⟩ + exact (h _).trans (congrArg Subtype.val (g.apply_symm_apply ⟨x,hx⟩)) + + theorem tripleLinearStabilizerRestriction_bijective (U V W : Submodule K E) + (hU : IsCompl U (V ⊔ W)) (hVW : Disjoint V W) : + Function.Bijective (tripleLinearStabilizerRestriction U V W) := by + let c := tripleSumEquiv U V W hU hVW + constructor + · intro e f hh + apply Subtype.ext + ext x + obtain ⟨⟨u,v,w⟩,rfl⟩ := c.surjective x + have h₁ := congrArg (fun p : (U ≃ₗ[K] U) × (V ≃ₗ[K] V) × (W ≃ₗ[K] W) => (p.1 u).val) hh + have h₂ := congrArg (fun p : (U ≃ₗ[K] U) × (V ≃ₗ[K] V) × (W ≃ₗ[K] W) => (p.2.1 v).val) hh + have h₃ := congrArg (fun p : (U ≃ₗ[K] U) × (V ≃ₗ[K] V) × (W ≃ₗ[K] W) => (p.2.2 w).val) hh + change e.val u.val = f.val u.val at h₁ + change e.val v.val = f.val v.val at h₂ + change e.val w.val = f.val w.val at h₃ + change e.val (u.val+(v.val+w.val)) = f.val (u.val+(v.val+w.val)) + simp only [map_add,h₁,h₂,h₃] + · intro g + let e : E ≃ₗ[K] E := c.symm.trans ((g.1.prodCongr (g.2.1.prodCongr g.2.2)).trans c) + have heU (u : U) : e u.val = (g.1 u).val := by + have hc : c (u,(0,0)) = u.val := by simp [c] + change c ((g.1.prodCongr (g.2.1.prodCongr g.2.2)) (c.symm u.val)) = _ + rw [←hc,c.symm_apply_apply] + simp [c] + have heV (v : V) : e v.val = (g.2.1 v).val := by + have hc : c (0,(v,0)) = v.val := by simp [c] + change c ((g.1.prodCongr (g.2.1.prodCongr g.2.2)) (c.symm v.val)) = _ + rw [←hc,c.symm_apply_apply] + simp [c] + have heW (w : W) : e w.val = (g.2.2 w).val := by + have hc : c (0,(0,w)) = w.val := by simp [c] + change c ((g.1.prodCongr (g.2.1.prodCongr g.2.2)) (c.symm w.val)) = _ + rw [←hc,c.symm_apply_apply] + simp [c] + refine ⟨⟨e,map_eq_of_restriction_aut U e g.1 heU, + map_eq_of_restriction_aut V e g.2.1 heV,map_eq_of_restriction_aut W e g.2.2 heW⟩,?_⟩ + apply Prod.ext + · ext u + exact heU u + · apply Prod.ext + · ext v + exact heV v + · ext w + exact heW w + +variable [Finite E] + + theorem tripleLinearOrbit_card_identity (U V W : Submodule K E) + (hU : IsCompl U (V ⊔ W)) (hVW : Disjoint V W) : + Nat.card (TripleLinearOrbit U V W) * + (Nat.card (U ≃ₗ[K] U)*(Nat.card (V ≃ₗ[K] V)*Nat.card (W ≃ₗ[K] W))) = Nat.card (E ≃ₗ[K] E) := by + classical + let := Fintype.ofFinite (TripleLinearOrbit U V W) + have hc : Nat.card (TripleLinearStabilizer U V W) = + Nat.card (U ≃ₗ[K] U)*(Nat.card (V ≃ₗ[K] V)*Nat.card (W ≃ₗ[K] W)) := by + rw [Nat.card_congr (Equiv.ofBijective _ (tripleLinearStabilizerRestriction_bijective U V W hU hVW)), + Nat.card_prod,Nat.card_prod] + have he := (Nat.card_congr (Equiv.sigmaFiberEquiv (tripleLinearOrbitMap U V W))).symm + rw [Nat.card_sigma] at he + have hf (p : TripleLinearOrbit U V W) : Nat.card {e : E ≃ₗ[K] E // tripleLinearOrbitMap U V W e = p} = + Nat.card (U ≃ₗ[K] U)*(Nat.card (V ≃ₗ[K] V)*Nat.card (W ≃ₗ[K] W)) := + (Nat.card_congr (tripleLinearOrbitFiberEquiv U V W p)).trans hc + simpa only [hf,Finset.sum_const,Finset.card_univ,nsmul_eq_mul,Nat.card_eq_fintype_card,Nat.cast_id] using he.symm + +variable [Fintype K] + + theorem tripleLinearOrbit_card_bounds (U V W : Submodule K E) + (hU : IsCompl U (V ⊔ W)) (hVW : Disjoint V W) : + (Fintype.card K : ℝ)^(2*(finrank K U*finrank K V+finrank K U*finrank K W+finrank K V*finrank K W)) ≤ + 2^(finrank K E)*(Nat.card (TripleLinearOrbit U V W) : ℝ) ∧ + (Nat.card (TripleLinearOrbit U V W) : ℝ) ≤ + 2^(finrank K E)*(Fintype.card K : ℝ)^(2*(finrank K U*finrank K V+finrank K U*finrank K W+finrank K V*finrank K W)) := by + let u := finrank K U + let v := finrank K V + let w := finrank K W + let n := finrank K E + let q : ℝ := Fintype.card K + have hn : u+(v+w) = n := by + simpa only [Module.finrank_prod] using (tripleSumEquiv U V W hU hVW).finrank_eq + have he : n*n = 2*(u*v+u*w+v*w) + (u*u+(v*v+w*w)) := by rw [←hn]; ring + have hq : 0 < q := by dsimp [q]; exact_mod_cast Fintype.card_pos (α := K) + have hi : (Nat.card (TripleLinearOrbit U V W) : ℝ)* + ((Nat.card (U ≃ₗ[K] U) : ℝ)*(Nat.card (V ≃ₗ[K] V)*Nat.card (W ≃ₗ[K] W))) = Nat.card (E ≃ₗ[K] E) := by + exact_mod_cast tripleLinearOrbit_card_identity U V W hU hVW + have hu : (Nat.card (U ≃ₗ[K] U) : ℝ) ≤ q^(u*u) := by dsimp [q,u]; exact_mod_cast linearAut_card_upper (K := K) (E := U) + have hv : (Nat.card (V ≃ₗ[K] V) : ℝ) ≤ q^(v*v) := by dsimp [q,v]; exact_mod_cast linearAut_card_upper (K := K) (E := V) + have hw : (Nat.card (W ≃ₗ[K] W) : ℝ) ≤ q^(w*w) := by dsimp [q,w]; exact_mod_cast linearAut_card_upper (K := K) (E := W) + have hl : q^(n*n) ≤ 2^n*(Nat.card (E ≃ₗ[K] E) : ℝ) := by dsimp [q,n]; exact_mod_cast linearAut_card_lower (K := K) (E := E) + have hu' : q^(u*u) ≤ 2^u*(Nat.card (U ≃ₗ[K] U) : ℝ) := by dsimp [q,u]; exact_mod_cast linearAut_card_lower (K := K) (E := U) + have hv' : q^(v*v) ≤ 2^v*(Nat.card (V ≃ₗ[K] V) : ℝ) := by dsimp [q,v]; exact_mod_cast linearAut_card_lower (K := K) (E := V) + have hw' : q^(w*w) ≤ 2^w*(Nat.card (W ≃ₗ[K] W) : ℝ) := by dsimp [q,w]; exact_mod_cast linearAut_card_lower (K := K) (E := W) + have hn' : (Nat.card (E ≃ₗ[K] E) : ℝ) ≤ q^(n*n) := by dsimp [q,n]; exact_mod_cast linearAut_card_upper (K := K) (E := E) + constructor + · apply (mul_le_mul_iff_left₀ (pow_pos hq (u*u+(v*v+w*w)))).mp + calc + _ = q^(n*n) := by rw [←pow_add,←he] + _ ≤ _ := hl + _ = 2^n*((Nat.card (TripleLinearOrbit U V W) : ℝ)* + ((Nat.card (U ≃ₗ[K] U) : ℝ)*(Nat.card (V ≃ₗ[K] V)*Nat.card (W ≃ₗ[K] W)))) := by rw [hi] + _ ≤ 2^n*((Nat.card (TripleLinearOrbit U V W) : ℝ)*(q^(u*u)*(q^(v*v)*q^(w*w)))) := by gcongr + _ = _ := by simp only [pow_add]; ring + · apply (mul_le_mul_iff_left₀ (pow_pos hq (u*u+(v*v+w*w)))).mp + calc + _ = (Nat.card (TripleLinearOrbit U V W) : ℝ)*(q^(u*u)*(q^(v*v)*q^(w*w))) := by simp only [pow_add] + _ ≤ (Nat.card (TripleLinearOrbit U V W) : ℝ)*((2^u*Nat.card (U ≃ₗ[K] U))*((2^v*Nat.card (V ≃ₗ[K] V))*(2^w*Nat.card (W ≃ₗ[K] W)))) := by gcongr + _ = 2^n*Nat.card (E ≃ₗ[K] E) := by rw [←hi,←hn]; simp only [pow_add]; ring + _ ≤ 2^n*q^(n*n) := mul_le_mul_of_nonneg_left hn' (by positivity) + _ = _ := by rw [he,pow_add]; ring + +end TripleDecompositions +end SidorenkoCounterexample + + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section UniformCounts +variable {A B C D E F : Type*} + +noncomputable def prodFiberEquiv (f : A → B) (g : C → D) (b : B) (d : D) : + {x : A × C // (f x.1,g x.2) = (b,d)} ≃ + {a : A // f a = b} × {c : C // g c = d} where + toFun x := (⟨x.val.1,congrArg Prod.fst x.property⟩,⟨x.val.2,congrArg Prod.snd x.property⟩) + invFun x := ⟨(x.1.val,x.2.val),Prod.ext x.1.property x.2.property⟩ + left_inv _ := rfl + right_inv _ := rfl + + theorem uniform_prod_card [Finite A] [Finite B] [Finite C] [Finite D] + (f : A → B) (g : C → D) + (hf : ∀ b, Nat.card {a : A // f a = b} * Nat.card B = Nat.card A) + (hg : ∀ d, Nat.card {c : C // g c = d} * Nat.card D = Nat.card C) + (p : B × D) : + Nat.card {x : A × C // (f x.1,g x.2) = p} * Nat.card (B × D) = Nat.card (A × C) := by + rcases p with ⟨b,d⟩ + rw [Nat.card_congr (prodFiberEquiv f g b d),Nat.card_prod,Nat.card_prod,Nat.card_prod] + calc + _ = (Nat.card {a : A // f a = b} * Nat.card B) * + (Nat.card {c : C // g c = d} * Nat.card D) := by ring + _ = _ := by rw [hf,hg] + + theorem uniform_preimage_card [Finite A] [Finite B] (f : A → B) + (hf : ∀ b, Nat.card {a : A // f a = b} * Nat.card B = Nat.card A) (P : B → Prop) : + Nat.card {a : A // P (f a)} * Nat.card B = Nat.card {b : B // P b} * Nat.card A := by + classical + let := Fintype.ofFinite {b : B // P b} + let e : {a : A // P (f a)} ≃ Σ b : {b : B // P b}, {a : A // f a = b.val} := + { toFun := fun a => ⟨⟨f a.val,a.property⟩,⟨a.val,rfl⟩⟩ + invFun := fun b => ⟨b.2.val,by rw [b.2.property]; exact b.1.property⟩ + left_inv := fun a => rfl + right_inv := by rintro ⟨⟨b,hb⟩,a,ha⟩; dsimp at ha; subst b; rfl } + rw [Nat.card_congr e,Nat.card_sigma,Finset.sum_mul] + simp only [hf,Finset.sum_const,Finset.card_univ,smul_eq_mul,Nat.card_eq_fintype_card] +end UniformCounts + +section ExactPairs +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] +variable (ω : LinearMap.BilinForm K E) (S L M A B : Submodule K E) + + + + theorem avoidance_exact_intersection + (hL : ω.orthogonal L = L) (hM : ω.orthogonal M = M) + (hLA : L ⊓ S = A) (hMB : M ⊓ S = B) (hAB : A ⊔ B = S) + (hr : reduceSubspace ω S L ⊓ reduceSubspace ω S M = ⊥) : + L ⊓ M = A ⊓ B := by + apply le_antisymm + · intro x hx + have hxP : x ∈ ω.orthogonal S := by + intro y hy + rw [←hAB] at hy + obtain ⟨a,ha,b,hb,rfl⟩ := Submodule.mem_sup.mp hy + have haL : a ∈ L := (hLA.symm ▸ ha : a ∈ L ⊓ S).1 + have hbM : b ∈ M := (hMB.symm ▸ hb : b ∈ M ⊓ S).1 + rw [map_add,LinearMap.add_apply,(hL.ge hx.1) a haL,(hM.ge hx.2) b hbM,add_zero] + have hxq : (reductionKernel ω S).mkQ ⟨x,hxP⟩ = 0 := by + have hmem : (reductionKernel ω S).mkQ ⟨x,hxP⟩ ∈ + reduceSubspace ω S L ⊓ reduceSubspace ω S M := + ⟨⟨⟨x,hxP⟩,hx.1,rfl⟩,⟨⟨x,hxP⟩,hx.2,rfl⟩⟩ + simpa only [hr,Submodule.mem_bot] using hmem + have hxS : x ∈ S := (Submodule.Quotient.mk_eq_zero (reductionKernel ω S)).mp hxq + exact ⟨hLA ▸ (⟨hx.1,hxS⟩ : x ∈ L ⊓ S),hMB ▸ (⟨hx.2,hxS⟩ : x ∈ M ⊓ S)⟩ + · intro x hx + exact ⟨(hLA.symm ▸ hx.1 : x ∈ L ⊓ S).1,(hMB.symm ▸ hx.2 : x ∈ M ⊓ S).1⟩ +end ExactPairs +end SidorenkoCounterexample + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/Symmetrization.lean b/lean/OAI/Combinatorics/Sidorenko/Symmetrization.lean new file mode 100644 index 0000000000000000000000000000000000000000..1557dc753e59724d0485ee0c29c040804c45d3a0 --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/Symmetrization.lean @@ -0,0 +1,291 @@ +import OAI.Combinatorics.Sidorenko.Pinning + +namespace OAI + + +section + +namespace SidorenkoCounterexample +open Classical Filter +open scoped BigOperators +structure OrientedKernel where + X : Type + Y : Type + [finiteX : Fintype X] + [finiteY : Fintype Y] + [nonemptyX : Nonempty X] + [nonemptyY : Nonempty Y] + left : FiniteLaw X + right : FiniteLaw Y + value : X → Y → ℝ + nonneg : ∀ x y,0≤value x y + mean_one : kernelMean left right value=1 + gap : bipartiteMoment left right value*bipartiteMoment right left (fun y x => value x y)<1 +attribute [instance] OrientedKernel.finiteX OrientedKernel.finiteY OrientedKernel.nonemptyX OrientedKernel.nonemptyY +lemma exists_oriented_kernel : Nonempty OrientedKernel := by + obtain ⟨π,ν,p,hp,hneg⟩ := exists_negative_coefficient + obtain ⟨ε,hε,hε1,hgap⟩ := exists_dilution_gap (averagedCoefficient π ν p) + (averagedCoefficient ν π (fun b a => p a b)) hneg + let π' := π.diluted ε hε.le hε1.le + let p' := dilutedPairLaw p + have hp' := dilutedPairLaw_zero p hp + let r := singularTailThreshold + have hl : singularTailThreshold≤2*(2*r) := by dsimp [r]; omega + have hr : 0<2*r := by have := singularTailThreshold_large; dsimp [r]; omega + have ht0 := typedMatrixKernel_tendsto r hl π' ν p' hp' + have ht1 := typedMatrixKernel_tendsto r hl ν π' (fun b a => p' a b) (fun b a => hp' a b) + have ht := ht0.mul ht1 + have hcoef : (1+averagedCoefficient π' ν p')*(1+averagedCoefficient ν π' (fun b a => p' a b))<1 := by + simpa only [π',p',coefficient_dilution_left,coefficient_dilution_right] using hgap + obtain ⟨q,hq⟩ := (ht.eventually (gt_mem_nhds hcoef)).exists + let L := typedMatrixLaw (F := ZMod q.val) (K := ActCorner) (2*r) π' + let R := typedMatrixLaw (F := ZMod q.val) (K := ActCorner) (2*r) ν + let W := typedMatrixKernel (F := ZMod q.val) (2*r) p' + have hc : ringChar (ZMod q.val)≠2 := by simpa only [ZMod.ringChar_zmod_n] using q.property.2 + refine ⟨{ X := Option (Fin 13) × (ActCorner → SymMatrix (ZMod q.val) (2*(2*r))) + Y := Fin 22 × (ActCorner → SymMatrix (ZMod q.val) (2*(2*r))) + left := L + right := R + value := W + nonneg := typedMatrixKernel_nonneg (2*r) p' + mean_one := typedMatrixKernel_mean (2*r) hr hc π' ν p' + gap := ?_ }⟩ + have he : bipartiteMoment R L (fun y x => W x y)= + bipartiteMoment R L (typedMatrixKernel (F := ZMod q.val) (2*r) (fun b a => p' a b)) := by + apply bipartiteMoment_congr + intro y x; exact typedMatrixKernel_transpose r p' x y + rw [he]; exact hq +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Classical +open scoped BigOperators +section Cross +variable {A B C D X Y : Type*} [Fintype A] [Fintype B] [Fintype C] [Fintype D] [Fintype X] [Fintype Y] +lemma four_means_factor (p : FiniteLaw A) (q : FiniteLaw B) (r : FiniteLaw C) (s : FiniteLaw D) + (f : A → D → ℝ) (g : C → B → ℝ) : + p.mean (fun a => q.mean (fun b => r.mean (fun c => s.mean (fun d => f a d*g c b))))= + p.mean (fun a => s.mean (f a))*r.mean (fun c => q.mean (g c)) := by + simp_rw [FiniteLaw.mean_mul_right,FiniteLaw.mean_mul,FiniteLaw.mean_mul_right] + rw [FiniteLaw.mean_swap q r] +noncomputable def crossedKernel (W : X → Y → ℝ) (x y : X × Y) : ℝ := W x.1 y.2*W y.1 x.2 +omit [Fintype X] [Fintype Y] in +lemma crossedKernel_symm (W : X → Y → ℝ) (x y : X × Y) : crossedKernel W x y=crossedKernel W y x := mul_comm _ _ +omit [Fintype X] [Fintype Y] in +lemma crossedKernel_nonneg (W : X → Y → ℝ) (hW : ∀ x y,0≤W x y) (x y : X × Y) : 0≤crossedKernel W x y := + mul_nonneg (hW _ _) (hW _ _) +lemma crossedKernel_mean (π : FiniteLaw X) (ν : FiniteLaw Y) (W : X → Y → ℝ) : + kernelMean (π.prod ν) (π.prod ν) (crossedKernel W)=(kernelMean π ν W)^2 := by + unfold kernelMean + simp_rw [FiniteLaw.mean_prod] + simp only [crossedKernel] + rw [four_means_factor] + ring +lemma crossedKernel_moment (π : FiniteLaw X) (ν : FiniteLaw Y) (W : X → Y → ℝ) : + bipartiteMoment (π.prod ν) (π.prod ν) (crossedKernel W)= + bipartiteMoment π ν W*bipartiteMoment ν π (fun y x => W x y) := by + rw [bipartiteMoment_typed] + unfold typeMapLaw + rw [FiniteLaw.mean_prod] + simp only [crossedKernel,Finset.prod_mul_distrib] + rw [four_means_factor] + rfl +lemma kernelMean_div (π : FiniteLaw X) (ν : FiniteLaw Y) (W : X → Y → ℝ) (c : ℝ) : + kernelMean π ν (fun x y => W x y/c)=kernelMean π ν W/c := by + simp only [kernelMean,div_eq_mul_inv,FiniteLaw.mean_mul_right] +lemma bipartiteMoment_div (π : FiniteLaw X) (ν : FiniteLaw Y) (W : X → Y → ℝ) (c : ℝ) : + bipartiteMoment π ν (fun x y => W x y/c)=bipartiteMoment π ν W/c^66 := by + have hc : Fintype.card ActCorner=66 := by decide + unfold bipartiteMoment + simp_rw [Finset.prod_div_distrib] + simp only [Finset.prod_const,Finset.card_univ,hc,div_eq_mul_inv,FiniteLaw.mean_mul_right] +end Cross +structure SymmetricCounterKernel where + Ω : Type + [finite : Fintype Ω] + [nonempty : Nonempty Ω] + law : FiniteLaw Ω + value : Ω → Ω → ℝ + nonneg : ∀ x y,0≤value x y + le_one : ∀ x y,value x y≤1 + symm : ∀ x y,value x y=value y x + mean_pos : 0 V xy.1 xy.2) + have hL (x y : Ω) : V x y≤L := Finset.le_sup' (fun xy : Ω × Ω => V xy.1 xy.2) (Finset.mem_univ (x,y)) + have hmean : kernelMean p p V=1 := by rw [crossedKernel_mean,W.mean_one,one_pow] + have hone : 1≤L := by + rw [←hmean] + exact p.mean_bound (fun x => p.mean_bound (fun y => hL x y)) + have hpos : 0 V x y/L + nonneg := fun x y => div_nonneg (crossedKernel_nonneg _ W.nonneg x y) hpos.le + le_one := fun x y => (div_le_one hpos).mpr (hL x y) + symm := fun x y => congrArg (fun z => z/L) (crossedKernel_symm _ x y) + mean_pos := ?_ + gap := ?_ }⟩ + · rw [kernelMean_div,hmean]; exact div_pos zero_lt_one hpos + · rw [bipartiteMoment_div,kernelMean_div,hmean,div_pow,one_pow] + apply (div_lt_div_iff_of_pos_right (pow_pos hpos 66)).mpr + rw [crossedKernel_moment]; exact W.gap +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Classical +open scoped BigOperators +namespace FiniteLaw +section Marginal +variable {I J A B : Type*} [Fintype I] [Fintype J] [Fintype A] [Fintype B] [DecidableEq I] [DecidableEq J] +lemma independent_mean_sum (p : I ⊕ J → FiniteLaw A) (f : (I ⊕ J → A) → ℝ) : + (independent p).mean f=(independent (fun i => p (.inl i))).mean (fun x => + (independent (fun j => p (.inr j))).mean (fun y => f (Sum.elim x y))) := by + unfold mean independent + simp only [Finset.mul_sum] + rw [←Fintype.sum_prod_type (fun xy : (I → A) × (J → A) => + (∏ i,(p (.inl i)).weight (xy.1 i))*((∏ j,(p (.inr j)).weight (xy.2 j))*f (Sum.elim xy.1 xy.2)))] + apply Fintype.sum_equiv (Equiv.sumArrowEquivProdArrow I J A) + intro x + simp only [Fintype.prod_sum_type,Equiv.sumArrowEquivProdArrow,Equiv.coe_fn_mk] + have he : Sum.elim (fun i => x (.inl i)) (fun j => x (.inr j))=x := by funext ij; cases ij <;> rfl + change _ = (∏ i,(p (.inl i)).weight (x (.inl i)))* + ((∏ j,(p (.inr j)).weight (x (.inr j)))*f (Sum.elim (fun i => x (.inl i)) (fun j => x (.inr j)))) + rw [he]; ring +lemma independent_mean_injective (p : J → FiniteLaw A) (e : I → J) (he : Function.Injective e) + (f : (I → A) → ℝ) : + (independent p).mean (fun x => f (fun i => x (e i)))=(independent (fun i => p (e i))).mean f := by + let E : I ⊕ {j : J // j∉Set.range e} ≃ J := + (Equiv.sumCongr (Equiv.ofInjective e he) (Equiv.refl _)).trans (Equiv.Set.sumCompl (Set.range e)) + have hE (i : I) : E (.inl i)=e i := rfl + have h := independent_mean_equiv E p (fun x => f (fun i => x (e i))) + rw [←h,independent_mean_sum] + have hi (x : I → A) (y : {j : J // j∉Set.range e} → A) : + (fun i => Sum.elim x y (E.symm (e i)))=x := by + funext i; rw [←hE i,E.symm_apply_apply]; rfl + simp only [hi,mean_const,hE] +noncomputable def bind (p : FiniteLaw A) (q : A → FiniteLaw B) : FiniteLaw B where + weight b := ∑ a,p.weight a*(q a).weight b + nonneg b := Finset.sum_nonneg (fun a _ => mul_nonneg (p.nonneg a) ((q a).nonneg b)) + total := by rw [Finset.sum_comm]; simp_rw [←Finset.mul_sum,(q _).total,mul_one]; exact p.total +lemma mean_bind (p : FiniteLaw A) (q : A → FiniteLaw B) (f : B → ℝ) : + (p.bind q).mean f=p.mean (fun a => (q a).mean f) := by + simp only [mean,bind,Finset.sum_mul,Finset.mul_sum,mul_assoc] + rw [Finset.sum_comm] +lemma mean_pow_le (p : FiniteLaw A) (f : A → ℝ) (hf : ∀ a,0≤f a) (n : ℕ) : + (p.mean f)^n≤p.mean (fun a => (f a)^n) := by + simpa only [mean,smul_eq_mul] using (convexOn_pow (𝕜 := ℝ) n).map_sum_le + (t := Finset.univ) (w := p.weight) (p := f) (fun a _ => p.nonneg a) p.total (fun a _ => hf a) +lemma exists_lt_of_mean_lt (p : FiniteLaw A) {f g : A → ℝ} (h : p.mean f norm_num +lemma edgeIndicator_le_one {V : Type*} (G : SimpleGraph V) (a b : V) : edgeIndicator G a b≤1 := by + unfold edgeIndicator; split <;> norm_num +lemma edgeIndicator_symm {V : Type*} (G : SimpleGraph V) (a b : V) : edgeIndicator G a b=edgeIndicator G b a := by + simp only [edgeIndicator,G.adj_comm] +lemma mem_faces_iff (j : Fin 22) (i : Fin 13) : i∈faces j ↔ ∃ r,faceVertex j r=i := by + rw [faceVertex_correct] + constructor + · simp only [Finset.mem_insert,Finset.mem_singleton] + rintro (h|h|h) + · exact ⟨0,h.symm⟩ + · exact ⟨1,h.symm⟩ + · exact ⟨2,h.symm⟩ + · rintro ⟨r,rfl⟩; fin_cases r <;> simp +lemma hom_iff_corners {V : Type*} (G : SimpleGraph V) (f : PatternVertex → V) : + (∀ u v,H.Adj u v → G.Adj (f u) (f v)) ↔ + ∀ k : ActCorner,G.Adj (f (.inl (cornerPoint k))) (f (.inr k.1)) := by + constructor + · intro h k; exact h _ _ (faceVertex_mem k.1 k.2) + · intro h u v huv + cases u with + | inl i => + cases v with + | inl i' => exact False.elim huv + | inr j => + obtain ⟨r,hr⟩ := (mem_faces_iff j i).mp huv + simpa only [cornerPoint,hr] using h (j,r) + | inr j => + cases v with + | inl i => + obtain ⟨r,hr⟩ := (mem_faces_iff j i).mp huv + simpa only [cornerPoint,hr] using (h (j,r)).symm + | inr j' => exact False.elim huv +noncomputable def homIndicator {V : Type*} (G : SimpleGraph V) (f : PatternVertex → V) : ℝ := + ∏ k : ActCorner,edgeIndicator G (f (.inl (cornerPoint k))) (f (.inr k.1)) +lemma homIndicator_eq {V : Type*} (G : SimpleGraph V) (f : PatternVertex → V) : + homIndicator G f=if ∀ u v,H.Adj u v → G.Adj (f u) (f v) then 1 else 0 := by + simp only [homIndicator,edgeIndicator,Fintype.prod_boole,hom_iff_corners] +lemma homIndicator_nonneg {V : Type*} (G : SimpleGraph V) (f : PatternVertex → V) : 0≤homIndicator G f := by + rw [homIndicator_eq]; split <;> norm_num +lemma homIndicator_le_one {V : Type*} (G : SimpleGraph V) (f : PatternVertex → V) : homIndicator G f≤1 := by + rw [homIndicator_eq]; split <;> norm_num +lemma homDensity_eq_mean {V : Type*} [Fintype V] (G : SimpleGraph V) : + homDensity H G=uniformMean (homIndicator G) := by + unfold homDensity homCount uniformMean + simp only [Nat.card_eq_fintype_card,Fintype.card_fun,homIndicator_eq,Nat.cast_pow] + congr 1 + simp [Fintype.card_subtype] +lemma edgeDensity_eq_mean {V : Type*} [Fintype V] (G : SimpleGraph V) : + edgeDensity G=uniformMean (fun ab : V × V => edgeIndicator G ab.1 ab.2) := by + have hs : (∑ a,∑ b,edgeIndicator G a b)=(2*(Fintype.card G.edgeSet) : ℕ) := by + calc + _ = ∑ a,(G.degree a : ℝ) := by + apply Finset.sum_congr rfl; intro a _ + simp [edgeIndicator,←G.card_neighborFinset_eq_degree,G.neighborFinset_eq_filter] + _ = _ := by exact_mod_cast (G.sum_degrees_eq_twice_card_edges.trans (congrArg (2*·) G.edgeFinset_card)) + unfold edgeDensity uniformMean + rw [Fintype.sum_prod_type,hs] + simp only [Nat.card_eq_fintype_card,Fintype.card_prod,Nat.cast_mul,Nat.cast_ofNat] + congr 1; ring +lemma homDensity_nonneg {V : Type*} (G : SimpleGraph V) : 0≤homDensity H G := by + unfold homDensity; positivity +lemma edgeDensity_nonneg {V : Type*} (G : SimpleGraph V) : 0≤edgeDensity G := by + unfold edgeDensity; positivity +lemma edgeDensity_eq_zero_of_edgeless {V : Type*} [Fintype V] (G : SimpleGraph V) + (h : ∀ a b,¬G.Adj a b) : edgeDensity G=0 := by + rw [edgeDensity_eq_mean]; simp [uniformMean,edgeIndicator,h] +lemma sourceMoment_eq_bipartite {A : Type*} [Fintype A] (π : FiniteLaw A) (U : A → A → ℝ) : + (FiniteLaw.independent (fun _ : PatternVertex => π)).mean (fun z => + ∏ k : ActCorner,U (z (.inl (cornerPoint k))) (z (.inr k.1)))=bipartiteMoment π π U := by + rw [FiniteLaw.independent_mean_sum]; rfl +end SidorenkoCounterexample + +end + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/Tail.lean b/lean/OAI/Combinatorics/Sidorenko/Tail.lean new file mode 100644 index 0000000000000000000000000000000000000000..ad86c54968da01f38d67c65c21b83fcc0a87fd6d --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/Tail.lean @@ -0,0 +1,769 @@ +import OAI.Combinatorics.Sidorenko.Spans + +namespace OAI + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators + +def lowerTailTuple (c : ℕ) (s : Fin 3 → ℕ) : TailTuple := ⟨c,0,0,s,fun _=>0⟩ + theorem lowerTailTuple_s (c : ℕ) (s : Fin 3 → ℕ) (i : Fin 3) : + (lowerTailTuple c s).s i=s i := Nat.add_zero _ + theorem lowerTailTuple_feasible (D c : ℕ) (s : Fin 3 → ℕ) (hc : c≤D) (hs : (∑ i,s i)≤D-c) : + TailFeasible D false (lowerTailTuple c s) := by + refine ⟨hc,?_,by simp⟩ + change (∑ i,s i+0)≤D-c + simpa only [Nat.add_zero] using hs +noncomputable def lowerTailConstant (D r : ℕ) : ℝ := + max 1 ((lagrangianConstant D)^2*(r+1)*2^(2*D)) + theorem lowerTailConstant_pos (D r : ℕ) : 0 FullTailChoice D r c s +| false => Unit +noncomputable instance faceTailChoiceFintype (D r c : ℕ) (s : Fin 3 → ℕ) (b : Bool) : + Fintype (FaceTailChoice D r c s b) := by cases b <;> unfold FaceTailChoice <;> infer_instance +noncomputable def faceTailTuple (D r c : ℕ) (s : Fin 3 → ℕ) : + (b : Bool) → FaceTailChoice D r c s b → TailTuple +| true,x => plantedTailTuple D r c s x.1 x.2 +| false,_ => lowerTailTuple c s +noncomputable def faceTailConstant (D r c : ℕ) (s : Fin 3 → ℕ) : + (b : Bool) → FaceTailChoice D r c s b → ℝ +| true,x => fullTailConstant D r c s x +| false,_ => lowerTailConstant D r + theorem faceTailConstant_pos (D r c : ℕ) (s : Fin 3 → ℕ) (b : Bool) + (x : FaceTailChoice D r c s b) : 0≤faceTailConstant D r c s b x := by + cases b + · exact (lowerTailConstant_pos D r).le + · exact fullTailConstant_nonneg D r c s x + theorem faceTailTuple_c (D r c : ℕ) (s : Fin 3 → ℕ) (b : Bool) + (x : FaceTailChoice D r c s b) : (faceTailTuple D r c s b x).c=c := by cases b <;> rfl + theorem faceTailTuple_s (D r c : ℕ) (s : Fin 3 → ℕ) (b : Bool) + (x : FaceTailChoice D r c s b) (i : Fin 3) : (faceTailTuple D r c s b x).s i=s i := by + cases b + · exact lowerTailTuple_s _ _ _ + · exact plantedTailTuple_s _ _ _ _ _ _ _ + theorem faceTailTuple_feasible (D r c : ℕ) (s : Fin 3 → ℕ) (hr : D=2*r) + (hc : c≤D) (hs : (∑ i,s i)≤D-c) (b : Bool) (x : FaceTailChoice D r c s b) : + TailFeasible D b (faceTailTuple D r c s b x) := by + cases b + · exact lowerTailTuple_feasible D c s hc hs + · exact plantedTailTuple_feasible D r c hr hc s hs x.1 x.2 +noncomputable def faceTailMajorant (D r c : ℕ) (s : Fin 3 → ℕ) (b : Bool) (q : ℝ) : ℝ := + ∑ x : FaceTailChoice D r c s b, + faceTailConstant D r c s b x*q^(tailGain D b (faceTailTuple D r c s b x)) + theorem faceTailMajorant_true (D r c : ℕ) (s : Fin 3 → ℕ) (q : ℝ) : + faceTailMajorant D r c s true q=fullTailMajorant D r c s q := rfl + theorem faceTailMajorant_false (D r c : ℕ) (s : Fin 3 → ℕ) (q : ℝ) : + faceTailMajorant D r c s false q=lowerTailConstant D r*q^(tailGain D false (lowerTailTuple c s)) := by + let : Unique (FaceTailChoice D r c s false) := inferInstanceAs (Unique Unit) + rw [faceTailMajorant,Fintype.sum_unique] + rfl + theorem faceTailMajorant_nonneg (D r c : ℕ) (s : Fin 3 → ℕ) (b : Bool) (q : ℝ) (hq : 0≤q) : + 0≤faceTailMajorant D r c s b q := by + apply Finset.sum_nonneg + intro x _ + exact mul_nonneg (faceTailConstant_pos _ _ _ _ _ _) (Real.rpow_nonneg hq _) +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open Module +open scoped BigOperators + +def profileS (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) (j : Fin 22) (i : Fin 3) : ℕ := h (facePair j i)-c j +def GeometricProfile (D : ℕ) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) : Prop := + (∀ j,c j≤D) ∧ (∀ j i,c j≤h (facePair j i)) ∧ ∀ j,(∑ i,profileS c h j i)≤D-c j + +section Actual +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] [Fintype K] [Finite E] +variable (ω : LinearMap.BilinForm K E) +omit [Fintype K] [Finite E] in + theorem PointProfile.faceLocal {c : Fin 22 → ℕ} {h : Fin 33 → ℕ} {L : Fin 13 → SymplecticLagrangian ω} + (hL : PointProfile ω c h L) (j : Fin 22) : + LocalProfile ω (c j) (h (facePair j 0)) (h (facePair j 1)) (h (facePair j 2)) + (L (faceVertex j 0)) (L (faceVertex j 1)) (L (faceVertex j 2)) := by + apply PointProfile.local ω hL j (faceVertex j 0) (faceVertex j 1) (faceVertex j 2) + (facePair j 0) (facePair j 1) (facePair j 2) (faceVertex_correct j) + · exact faceVertex_pairs j 0 + · exact faceVertex_pairs j 1 + · exact faceVertex_pairs j 2 + theorem PointProfile.geometric (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D=finrank K E) {c : Fin 22 → ℕ} {h : Fin 33 → ℕ} + {L : Fin 13 → SymplecticLagrangian ω} (hL : PointProfile ω c h L) : GeometricProfile D c h := by + have hl := hL.faceLocal ω + have hc (j : Fin 22) : c j≤D := by + rw [←(hl j).1] + exact isotropic_finrank_le_half ω hω D hD _ + (by intro x hx y hy; exact (L (faceVertex j 0)).property.ge hx.1.1 y hy.1.1) + refine ⟨hc,?_,?_⟩ + · intro j i + have hp := hl j + fin_cases i + · change c j≤h (facePair j 0) + rw [←hp.1,←hp.2.1]; exact Submodule.finrank_mono inf_le_left + · change c j≤h (facePair j 1) + rw [←hp.1,←hp.2.2.1]; exact Submodule.finrank_mono (inf_le_inf inf_le_left le_rfl) + · change c j≤h (facePair j 2) + rw [←hp.1,←hp.2.2.2]; exact Submodule.finrank_mono (inf_le_inf inf_le_right le_rfl) + · intro j + have hp := actual_profile_pair_sum_le ω ha hω D (c j) (h (facePair j 0)) + (h (facePair j 1)) (h (facePair j 2)) hD + ⟨⟨L (faceVertex j 0),L (faceVertex j 1),L (faceVertex j 2)⟩,hl j⟩ + simpa only [profileS,Fin.sum_univ_three] using hp +end Actual + + theorem profileCost_baseline (D : ℕ) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) + (hc : ∀ j i,c j≤h (facePair j i)) : + profileCost D c h=(∑ j,faceBaseline D (c j) (fun i=>profileS c h j i))+separationExcess h := by + have he (j : Fin 22) (i : Fin 3) : (c j:ℝ)+((h (facePair j i)-c j:ℕ):ℝ)=(h (facePair j i):ℝ) := by + rw [Nat.cast_sub (hc j i)] + ring + unfold profileCost faceNaturalCost faceBaseline + simp only [Nat.cast_add,Nat.cast_mul,Nat.cast_one,Nat.cast_sum,triangular_nat,Finset.sum_sub_distrib, + ←Finset.sum_div,profileS,he] + rw [sum_face_pairs (fun e=>triangular (h e))] + unfold separationExcess + simp only [div_mul_eq_mul_div,←Finset.sum_div,sub_mul,Finset.sum_sub_distrib,one_mul,←Finset.mul_sum] + ring + +abbrev GlobalTailChoice (D r : ℕ) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) (full : Fin 22 → Bool) := + (j : Fin 22) → FaceTailChoice D r (c j) (profileS c h j) (full j) +noncomputable def globalTailTuple (D r : ℕ) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) (full : Fin 22 → Bool) + (x : GlobalTailChoice D r c h full) (j : Fin 22) : TailTuple := + faceTailTuple D r (c j) (profileS c h j) (full j) (x j) +noncomputable def globalTailConstant (D r : ℕ) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) (full : Fin 22 → Bool) + (x : GlobalTailChoice D r c h full) : ℝ := ∏ j,faceTailConstant D r (c j) (profileS c h j) (full j) (x j) +noncomputable def globalTailGain (D r : ℕ) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) (full : Fin 22 → Bool) + (x : GlobalTailChoice D r c h full) : ℝ := ∑ j,tailGain D (full j) (globalTailTuple D r c h full x j) + theorem globalTailConstant_nonneg (D r : ℕ) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) (full : Fin 22 → Bool) + (x : GlobalTailChoice D r c h full) : 0≤globalTailConstant D r c h full x := + Finset.prod_nonneg (fun j _=>faceTailConstant_pos D r (c j) (profileS c h j) (full j) (x j)) + theorem globalTailTuple_feasible (D r : ℕ) (hr : D=2*r) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) + (hp : GeometricProfile D c h) (full : Fin 22 → Bool) (x : GlobalTailChoice D r c h full) : + GlobalTailFeasible D full (globalTailTuple D r c h full x) h := by + refine ⟨fun j=>faceTailTuple_feasible D r (c j) (profileS c h j) hr (hp.1 j) (hp.2.2 j) (full j) (x j),?_⟩ + intro j i + simp only [globalTailTuple,TailTuple.h,faceTailTuple_c,faceTailTuple_s,profileS] + exact Nat.add_sub_of_le (hp.2.1 j i) + theorem globalTailGain_cost (D r : ℕ) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) + (hp : GeometricProfile D c h) (full : Fin 22 → Bool) (x : GlobalTailChoice D r c h full) : + profileCost D c h-globalTailGain D r c h full x= + (∑ j,tailSlack D (full j) (globalTailTuple D r c h full x j))+separationExcess h := by + rw [profileCost_baseline D c h hp.2.1] + simp only [tailSlack,globalTailTuple,faceTailTuple_c,faceTailTuple_s,Finset.sum_sub_distrib,globalTailGain] + ring + theorem prod_faceTailMajorant (D r : ℕ) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) (full : Fin 22 → Bool) + (q : ℝ) (hq : 0iSupIndep (pairSpaces ω L.val)))).symm.trans Nat.card_sum + theorem pairDimProfile_residual_card_bound (h2 : (2:K)≠0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D=finrank K E) (h : Fin 33 → ℕ) (hh : ∀ e,h e=0 ∨ h e=2) (hlarge : 33≤D) : + (Nat.card (PairDimProfile ω h):ℝ)≤(Nat.card (SymplecticLagrangian ω):ℝ)^13* + (residualDirectConstant D h*(Fintype.card K:ℝ)^(-(∑ e,triangular (h e)))+ + residualNondirectConstant D*(Fintype.card K:ℝ)^(-(D:ℝ)+1575)) := by + rw [pairDimProfile_card_split,Nat.cast_add] + have hd := directPairProfile_card_bound ω h2 ha hω D hD h + ((residual_h_sum_le h hh).trans (by omega)) + have hn := nondirectPairProfile_card_bound ω h2 ha hω D hD h hh + exact (add_le_add hd hn).trans_eq (by unfold residualDirectConstant residualNondirectConstant;ring) +omit [Fintype K] in + theorem pointProfile_card_le_pair (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) : + Nat.card {L : Fin 13 → SymplecticLagrangian ω // PointProfile ω c h L}≤Nat.card (PairDimProfile ω h) := by + let f : {L : Fin 13 → SymplecticLagrangian ω // PointProfile ω c h L} → PairDimProfile ω h := + fun L=>⟨L.val,L.property.2⟩ + exact Nat.card_le_card_of_injective f (fun x y hxy=>Subtype.ext (congrArg (fun L : PairDimProfile ω h=>L.val) hxy)) +noncomputable def normalizedPointProfileCount (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) : ℝ := + (Nat.card {L : Fin 13 → SymplecticLagrangian ω // PointProfile ω c h L}:ℝ)/(Nat.card (SymplecticLagrangian ω):ℝ)^13 +omit [Fintype K] [Finite E] in + theorem normalizedPointProfileCount_nonneg (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) : + 0≤normalizedPointProfileCount ω c h := by unfold normalizedPointProfileCount; positivity + theorem lagrangianRealCard_pos (h2 : (2:K)≠0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D : ℕ) (hD : 2*D=finrank K E) : (0:ℝ) norm_num [he,triangular] + _ = _ := by norm_num + theorem singular_triangular_sum_pos (h : Fin 33 → ℕ) (hs : ∃ e,h e≠0) : + 0<(∑ e,triangular (h e)) := by + obtain ⟨e,he⟩ := hs + exact (triangular_pos (by exact_mod_cast Nat.pos_of_ne_zero he)).trans_le + (Finset.single_le_sum (fun f _=>triangular_nonneg (Nat.cast_nonneg _)) (Finset.mem_univ e)) + theorem globalTail_dichotomy : ∃ D₀ : ℕ, 1642≤D₀ ∧ ∀ D≥D₀, + ∀ (r : ℕ), D=2*r → ∀ (c : Fin 22 → ℕ) (h : Fin 33 → ℕ), GeometricProfile D c h → + ∀ (full : Fin 22 → Bool) (x : GlobalTailChoice D r c h full), + 0q^e) Filter.atTop (nhds 0) := by + simpa only [neg_neg] using tendsto_rpow_neg_atTop (neg_pos.mpr he) + theorem profileTermMajorant_tendsto_zero (D r : ℕ) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) + (full : Fin 22 → Bool) (x : GlobalTailChoice D r c h full) (hD : 1642≤D) (hh : ∃ e,h e≠0) : + Filter.Tendsto (profileTermMajorant D r c h full x) Filter.atTop (nhds 0) := by + unfold profileTermMajorant + split_ifs with hs + · have he : globalTailGain D r c h full x-profileCost D c h<0 := by linarith + convert (negative_rpow_tendsto_zero _ he).const_mul ((fullProfileConstant D)^11) using 1; simp + · have he : -(∑ e,triangular (h e))/3<0 := by have := singular_triangular_sum_pos h hh; linarith + have hD' : -(D:ℝ)+1641<0 := by + have hDc : (1642:ℝ)≤D := by exact_mod_cast hD + linarith + convert ((negative_rpow_tendsto_zero _ he).const_mul (residualDirectConstant D h)).add + ((negative_rpow_tendsto_zero _ hD').const_mul (residualNondirectConstant D)) using 1; simp + + theorem residual_gain_bound (q N A B D S G : ℝ) (hq : 1≤q) (hB : 0≤B) + (hN : N≤A*q^(-S)+B*q^(-D+1575)) (hg : G=(2/3:ℝ)*S) (hS : S≤99) : + N*q^G≤A*q^(-S/3)+B*q^(-D+1641) := by + have hq0 : 0globalTailConstant D r c h full x*profileTermMajorant D r c h full x q) Filter.atTop (nhds 0) := by + convert (profileTermMajorant_tendsto_zero D r c h full x hD hh).const_mul + (globalTailConstant D r c h full x) using 1; simp + change Filter.Tendsto (fun q=>∑ x : GlobalTailChoice D r c h full, + globalTailConstant D r c h full x*profileTermMajorant D r c h full x q) _ _ + simpa only [Finset.sum_const_zero] using tendsto_finsetSum Finset.univ (fun x _=>ht x) +section ActualProduct +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] [Fintype K] [Finite E] +variable (ω : LinearMap.BilinForm K E) + theorem normalizedPointProfile_product_bound (h2 : (2:K)≠0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D r : ℕ) (hD : 2*D=finrank K E) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) (hc : ∀ j,c j≤D) + (full : Fin 22 → Bool) (hlarge : 33≤D) + (hdich : ∀ x : GlobalTailChoice D r c h full, 0 simp + rwa [hs] at hb + · simp only [ht,decide_false] + exact activeFaceDensity_lower_bound ω h2 ha hω D r hD hr c s A L hL T ht +end ActiveFaceBound +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +abbrev DimProfile (D : ℕ) := (Fin 22 → Fin (D+1)) × (Fin 33 → Fin (D+1)) +def DimProfile.c {D : ℕ} (p : DimProfile D) (j : Fin 22) : ℕ := p.1 j +def DimProfile.h {D : ℕ} (p : DimProfile D) (e : Fin 33) : ℕ := p.2 e +section Integrated +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] [Fintype K] [Finite E] +variable (ω : LinearMap.BilinForm K E) +noncomputable def profileActiveDensity (r : ℕ) (A : SymplecticLagrangian ω) + (T : Fin 22 → Finset (Fin 3)) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) : ℝ := by + classical + let := Fintype.ofFinite {L : Fin 13 → SymplecticLagrangian ω // PointProfile ω c h L} + exact (∑ L : {L : Fin 13 → SymplecticLagrangian ω // PointProfile ω c h L}, + ∏ j,activeFaceDensity ω r A (fun i=>L.val (faceVertex j i)) (T j))/(Nat.card (SymplecticLagrangian ω):ℝ)^13 + omit [Fintype K] in + theorem profileActiveDensity_nonneg (r : ℕ) (A : SymplecticLagrangian ω) + (T : Fin 22 → Finset (Fin 3)) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) : + 0 ≤ profileActiveDensity ω r A T c h := by + classical + unfold profileActiveDensity + exact div_nonneg (Finset.sum_nonneg (fun L _=>Finset.prod_nonneg + (fun j _=>activeFaceDensity_nonneg ω r A _ (T j)))) (by positivity) + theorem profileActiveDensity_bound [Invertible (2:K)] + (h2 : (2:K)≠0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D r : ℕ) (hD : 2*D=finrank K E) (hr : D=2*r) + (hq : 4*lagrangianConstant D ≤ (Fintype.card K:ℝ)) + (A : SymplecticLagrangian ω) (T : Fin 22 → Finset (Fin 3)) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) : + profileActiveDensity ω r A T c h ≤ normalizedPointProfileCount ω c h* + ∏ j,faceTailMajorant D r (c j) (profileS c h j) (decide (T j=Finset.univ)) (Fintype.card K) := by + classical + let := Fintype.ofFinite {L : Fin 13 → SymplecticLagrangian ω // PointProfile ω c h L} + unfold profileActiveDensity normalizedPointProfileCount + rw [div_mul_eq_mul_div] + apply div_le_div_of_nonneg_right _ (by positivity) + calc _ ≤ ∑ _L : {L : Fin 13 → SymplecticLagrangian ω // PointProfile ω c h L}, + ∏ j,faceTailMajorant D r (c j) (profileS c h j) (decide (T j=Finset.univ)) (Fintype.card K) := by + apply Finset.sum_le_sum + intro L _ + apply Finset.prod_le_prod₀ + · intro j _; exact activeFaceDensity_nonneg ω r A _ (T j) + · intro j _ + have hl := L.property.faceLocal ω j + have hp := L.property.geometric ω ha hω D hD + have hs (i : Fin 3) : c j+profileS c h j i=h (facePair j i) := + Nat.add_sub_of_le (hp.2.1 j i) + exact activeFaceDensity_tail_bound ω h2 ha hω D r hD hr (c j) (profileS c h j) hq A + (fun i=>L.val (faceVertex j i)) (by simpa only [hs] using hl) (T j) + _ = _ := by simp only [Finset.sum_const,Finset.card_univ,nsmul_eq_mul,Nat.card_eq_fintype_card] +end Integrated + theorem profileTailMajorant_nonneg (D r : ℕ) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) + (full : Fin 22 → Bool) (q : ℝ) (hq : 0 ≤ q) : 0 ≤ profileTailMajorant D r c h full q := by + exact Finset.sum_nonneg (fun x _=>mul_nonneg (globalTailConstant_nonneg _ _ _ _ _ _) + (profileTermMajorant_nonneg _ _ _ _ _ _ _ hq)) +noncomputable def integratedTailMajorant (D r : ℕ) (full : Fin 22 → Bool) (q : ℝ) : ℝ := by + classical + exact ∑ p : DimProfile D, if ∃ e,p.h e≠0 then profileTailMajorant D r p.c p.h full q else 0 + theorem integratedTailMajorant_tendsto_zero (D r : ℕ) (full : Fin 22 → Bool) (hD : 1642 ≤ D) : + Filter.Tendsto (integratedTailMajorant D r full) Filter.atTop (nhds 0) := by + classical + have ht (p : DimProfile D) : Filter.Tendsto + (fun q=>if ∃ e,p.h e≠0 then profileTailMajorant D r p.c p.h full q else 0) Filter.atTop (nhds 0) := by + by_cases hp : ∃ e,p.h e≠0 + · simpa only [hp,reduceIte] using profileTailMajorant_tendsto_zero D r p.c p.h full hD hp + · simpa only [hp,reduceIte] using (tendsto_const_nhds (x:=(0:ℝ)) (f:=Filter.atTop)) + change Filter.Tendsto (fun q=>∑ p : DimProfile D, if ∃ e,p.h e≠0 then profileTailMajorant D r p.c p.h full q else 0) _ _ + simpa only [Finset.sum_const_zero] using tendsto_finsetSum Finset.univ (fun p _=>ht p) +end SidorenkoCounterexample +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +noncomputable def singularTailThreshold : ℕ := Classical.choose globalTail_dichotomy + theorem singularTailThreshold_large : 1642 ≤ singularTailThreshold := (Classical.choose_spec globalTail_dichotomy).1 + theorem singularTailThreshold_dichotomy (D : ℕ) (hD : singularTailThreshold ≤ D) + (r : ℕ) (hr : D=2*r) (c : Fin 22 → ℕ) (h : Fin 33 → ℕ) (hp : GeometricProfile D c h) + (full : Fin 22 → Bool) (x : GlobalTailChoice D r c h full) : + 0decide (T j=Finset.univ)) (Fintype.card K) := by + classical + by_cases hp : Nonempty {L : Fin 13 → SymplecticLagrangian ω // PointProfile ω c h L} + · obtain ⟨L⟩ := hp + have hg := L.property.geometric ω ha hω D hD + refine (profileActiveDensity_bound ω h2 ha hω D r hD hr hq A T c h).trans ?_ + apply normalizedPointProfile_product_bound ω h2 ha hω D r hD c h hg.1 _ + (by have := singularTailThreshold_large; omega) + exact singularTailThreshold_dichotomy D hlarge r hr c h hg _ + · let : IsEmpty {L : Fin 13 → SymplecticLagrangian ω // PointProfile ω c h L} := not_nonempty_iff.mp hp + have hz : profileActiveDensity ω r A T c h=0 := by simp [profileActiveDensity] + rw [hz] + exact profileTailMajorant_nonneg _ _ _ _ _ _ (Nat.cast_nonneg _) +noncomputable def integratedActiveTail (D r : ℕ) (A : SymplecticLagrangian ω) + (T : Fin 22 → Finset (Fin 3)) : ℝ := by + classical + exact ∑ p : DimProfile D, if ∃ e,p.h e≠0 then profileActiveDensity ω r A T p.c p.h else 0 + omit [Fintype K] in + theorem integratedActiveTail_nonneg (D r : ℕ) (A : SymplecticLagrangian ω) + (T : Fin 22 → Finset (Fin 3)) : 0 ≤ integratedActiveTail ω D r A T := by + classical + unfold integratedActiveTail + exact Finset.sum_nonneg (fun p _=>by split_ifs; exact profileActiveDensity_nonneg _ _ _ _ _ _; rfl) + theorem integratedActiveTail_bound [Invertible (2:K)] + (h2 : (2:K)≠0) (ha : ω.IsAlt) (hω : ω.Nondegenerate) + (D r : ℕ) (hD : 2*D=finrank K E) (hr : D=2*r) (hlarge : singularTailThreshold ≤ D) + (hq : 4*lagrangianConstant D ≤ (Fintype.card K:ℝ)) + (A : SymplecticLagrangian ω) (T : Fin 22 → Finset (Fin 3)) : + integratedActiveTail ω D r A T ≤ integratedTailMajorant D r (fun j=>decide (T j=Finset.univ)) (Fintype.card K) := by + classical + unfold integratedActiveTail integratedTailMajorant + apply Finset.sum_le_sum + intro p _ + split_ifs + · exact profileActiveDensity_tail_bound ω h2 ha hω D r hD hr hlarge hq A T p.c p.h + · rfl +end IntegratedBound +end SidorenkoCounterexample + + +namespace SidorenkoCounterexample +open Module +open scoped BigOperators +section ActualProfile +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] + [Finite E] +variable (ω : LinearMap.BilinForm K E) (hω : ω.Nondegenerate) +variable (D : ℕ) (hD : 2 * D = finrank K E) + +include hω hD in +theorem finite_inf_lagrangians_finrank_le (L : Fin 13 → SymplecticLagrangian ω) + (s : Finset (Fin 13)) (hs : s.Nonempty) : + finrank K ↥(s.inf fun i => (L i).val : Submodule K E) ≤ D := by + obtain ⟨i, hi⟩ := hs + have hd := self_orthogonal_twice_finrank ω (L i).val hω (L i).property + have hb : (s.inf fun i => (L i).val : Submodule K E) ≤ (L i).val := Finset.inf_le hi + have := Submodule.finrank_mono hb + omega + +noncomputable def configProfile (L : Fin 13 → SymplecticLagrangian ω) : DimProfile D := + (fun j => ⟨finrank K ↥((faces j).inf fun i => (L i).val : Submodule K E), + Nat.lt_succ_of_le (finite_inf_lagrangians_finrank_le ω hω D hD L (faces j) + (Finset.card_pos.mp (by rw [faces_card]; omega)))⟩, + fun e => ⟨finrank K ↥((pairVertices e).inf fun i => (L i).val : Submodule K E), + Nat.lt_succ_of_le (finite_inf_lagrangians_finrank_le ω hω D hD L (pairVertices e) + (Finset.card_pos.mp (by rw [pairVertices_card]; omega)))⟩) + +theorem configProfile_property (L : Fin 13 → SymplecticLagrangian ω) : + PointProfile ω (configProfile ω hω D hD L).c (configProfile ω hω D hD L).h L := + ⟨fun _ => rfl, fun _ => rfl⟩ + +theorem configProfile_eq_iff (L : Fin 13 → SymplecticLagrangian ω) (p : DimProfile D) : + configProfile ω hω D hD L = p ↔ PointProfile ω p.c p.h L := by + constructor + · intro h; rw [← h]; exact configProfile_property ω hω D hD L + · intro h + apply Prod.ext + · funext j; exact Fin.ext (h.1 j) + · funext e; exact Fin.ext (h.2 e) + +noncomputable def actualSingularTail (r : ℕ) (A : SymplecticLagrangian ω) + (T : Fin 22 → Finset (Fin 3)) : ℝ := by + classical + let := Fintype.ofFinite (Fin 13 → SymplecticLagrangian ω) + exact (∑ L : Fin 13 → SymplecticLagrangian ω, + if ∃ e, finrank K ↥((pairVertices e).inf fun i => (L i).val : Submodule K E) ≠ 0 + then ∏ j, activeFaceDensity ω r A (fun i => L (faceVertex j i)) (T j) else 0) / + (Nat.card (SymplecticLagrangian ω) : ℝ)^13 + + include hω hD in + theorem actualSingularTail_eq_integrated (r : ℕ) (A : SymplecticLagrangian ω) + (T : Fin 22 → Finset (Fin 3)) : + actualSingularTail ω r A T = integratedActiveTail ω D r A T := by + classical + let := Fintype.ofFinite (Fin 13 → SymplecticLagrangian ω) + let := fun p : DimProfile D => Fintype.ofFinite + {L : Fin 13 → SymplecticLagrangian ω // PointProfile ω p.c p.h L} + let w (L : Fin 13 → SymplecticLagrangian ω) : ℝ := + ∏ j, activeFaceDensity ω r A (fun i => L (faceVertex j i)) (T j) + let f (L : Fin 13 → SymplecticLagrangian ω) : ℝ := + if ∃ e, (configProfile ω hω D hD L).h e ≠ 0 then w L else 0 + have he (p : DimProfile D) : + (∑ L : {L // configProfile ω hω D hD L = p}, f L.val) = + if ∃ e, p.h e ≠ 0 then + ∑ L : {L // PointProfile ω p.c p.h L}, w L.val else 0 := by + let e : {L // configProfile ω hω D hD L = p} ≃ {L // PointProfile ω p.c p.h L} := + Equiv.subtypeEquivRight (fun L => configProfile_eq_iff ω hω D hD L p) + have hf (L : {L // configProfile ω hω D hD L = p}) : + f L.val = if ∃ e, p.h e ≠ 0 then w (e L).val else 0 := by + dsimp only [f]; rw [L.property]; rfl + simp_rw [hf] + by_cases hp : ∃ e, p.h e ≠ 0 + · simp only [hp,reduceIte]; exact Equiv.sum_comp e (fun L => w L.val) + · simp only [hp,reduceIte,Finset.sum_const_zero] + have hsum : (∑ L, f L) = ∑ p : DimProfile D, + if ∃ e, p.h e ≠ 0 then ∑ L : {L // PointProfile ω p.c p.h L}, w L.val else 0 := by + rw [← Fintype.sum_fiberwise (configProfile ω hω D hD) f] + exact Finset.sum_congr rfl (fun p _ => he p) + change (∑ L, f L) / (Nat.card (SymplecticLagrangian ω) : ℝ)^13 = + ∑ p : DimProfile D, if ∃ e, p.h e ≠ 0 then + (∑ L : {L // PointProfile ω p.c p.h L}, w L.val) / + (Nat.card (SymplecticLagrangian ω) : ℝ)^13 else 0 + rw [hsum,Finset.sum_div] + apply Finset.sum_congr rfl + intro p _ + split_ifs <;> simp + + theorem actualSingularTail_nonneg (r : ℕ) (A : SymplecticLagrangian ω) + (T : Fin 22 → Finset (Fin 3)) : 0 ≤ actualSingularTail ω r A T := by + classical + unfold actualSingularTail + apply div_nonneg _ (by positivity) + apply Finset.sum_nonneg + intro L _ + split_ifs + · exact Finset.prod_nonneg (fun j _ => activeFaceDensity_nonneg ω r A _ (T j)) + · rfl + + include hω hD in + theorem actualSingularTail_bound [Fintype K] [Invertible (2 : K)] + (h2 : (2 : K) ≠ 0) (ha : ω.IsAlt) (r : ℕ) (hr : D = 2*r) + (hlarge : singularTailThreshold ≤ D) + (hq : 4*lagrangianConstant D ≤ (Fintype.card K : ℝ)) + (A : SymplecticLagrangian ω) (T : Fin 22 → Finset (Fin 3)) : + actualSingularTail ω r A T ≤ + integratedTailMajorant D r (fun j => decide (T j = Finset.univ)) (Fintype.card K) := by + rw [actualSingularTail_eq_integrated ω hω D hD] + exact integratedActiveTail_bound ω h2 ha hω D r hD hr hlarge hq A T + +end ActualProfile +end SidorenkoCounterexample + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/TripleRanks.lean b/lean/OAI/Combinatorics/Sidorenko/TripleRanks.lean new file mode 100644 index 0000000000000000000000000000000000000000..fa30002e275139377154ac8bab95817d1a4059fa --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/TripleRanks.lean @@ -0,0 +1,1164 @@ +import OAI.Combinatorics.Sidorenko.Reduction + +namespace OAI + +namespace SidorenkoCounterexample +open Module +section GeneralIsometry +variable {K E F : Type*} [Field K] [AddCommGroup E] [Module K E] + [AddCommGroup F] [Module K F] + +/-- Orthogonal complements commute with isometries between different spaces. -/ +theorem orthogonal_map_isometry_between + (ω : LinearMap.BilinForm K E) (η : LinearMap.BilinForm K F) + (e : E ≃ₗ[K] F) (he : ∀ x y, η (e x) (e y) = ω x y) + (U : Submodule K E) : + η.orthogonal (U.map e.toLinearMap) = (ω.orthogonal U).map e.toLinearMap := by + ext x + constructor + · intro hx + refine ⟨e.symm x,?_,e.apply_symm_apply x⟩ + intro u hu + rw [← he,e.apply_symm_apply] + exact hx (e u) ⟨u,hu,rfl⟩ + · rintro ⟨y,hy,rfl⟩ _ ⟨u,hu,rfl⟩ + change η (e u) (e y) = 0 + rw [he] + exact hy u hu + +end GeneralIsometry +section Horizontal +variable {K V : Type*} [Field K] [AddCommGroup V] [Module K V] + +def horizontalSpace : Submodule K (V × Module.Dual K V) := + (LinearMap.snd K V (Module.Dual K V)).ker + +@[simp] theorem mem_horizontalSpace (p : V × Module.Dual K V) : + p ∈ horizontalSpace (K := K) ↔ p.2 = 0 := Iff.rfl + +theorem horizontalSpace_selforthogonal : + canonicalSymplectic.orthogonal (horizontalSpace (K := K) (V := V)) = horizontalSpace := by + ext x + constructor + · intro hx + change x.2 = 0 + ext v + have hh := hx (v,0) (by rfl) + simpa only [canonicalSymplectic_apply,LinearMap.zero_apply,sub_zero] using hh + · intro hx v hv + change x.2 v.1 - v.2 x.1 = 0 + rw [(mem_horizontalSpace x).mp hx,(mem_horizontalSpace v).mp hv] + simp + +noncomputable def verticalSpaceEquiv : Module.Dual K V ≃ₗ[K] + verticalSpace (K := K) (V := V) where + toFun f := ⟨(0,f),rfl⟩ + invFun x := x.val.2 + map_add' _ _ := by ext <;> simp + map_smul' a f := by ext <;> simp + left_inv _ := rfl + right_inv x := by + apply Subtype.ext + exact Prod.ext ((mem_verticalSpace x.val).mp x.property).symm rfl + +end Horizontal +section TripleOneBlock +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] + [FiniteDimensional K E] +variable (ω : LinearMap.BilinForm K E) + + + +theorem triple_pair_block (ha : ω.IsAlt) + (L M N : Submodule K E) (hL : ω.orthogonal L = L) + (hM : ω.orthogonal M = M) (hN : ω.orthogonal N = N) + (hzero : (L ⊓ M) ⊓ N = ⊥) : + ∃ B Q : Submodule K E, + (ω.restrict B).Nondegenerate ∧ (L ⊓ M) ≤ B ∧ Q ≤ B ∧ Q ≤ N ∧ + finrank K Q = finrank K ↥(L ⊓ M) ∧ + B = (L ⊓ M) ⊔ Q ∧ + L = (L ⊓ M) ⊔ (L ⊓ ω.orthogonal B) ∧ + M = (L ⊓ M) ⊔ (M ⊓ ω.orthogonal B) ∧ + N = Q ⊔ (N ⊓ ω.orthogonal B) ∧ + L ⊓ N ≤ ω.orthogonal B ∧ M ⊓ N ≤ ω.orthogonal B ∧ + (L ⊓ ω.orthogonal B) ⊓ (M ⊓ ω.orthogonal B) = ⊥ ∧ + (∀ A ∈ ({L,M,N} : Set (Submodule K E)), + (ω.restrict (ω.orthogonal B)).orthogonal (A.comap (ω.orthogonal B).subtype) = + A.comap (ω.orthogonal B).subtype) ∧ + ∃ e : (↥(L ⊓ M) × Module.Dual K ↥(L ⊓ M)) ≃ₗ[K] B, + (∀ s : ↥(L ⊓ M), (e (s,0)).val = s.val) ∧ + (verticalSpace.map e.toLinearMap).map B.subtype = Q ∧ + ∀ x y, ω (e x).val (e y).val = canonicalSymplectic x y := by + let S := L ⊓ M + have hS : S ≤ ω.orthogonal S := by + intro s hs t ht + exact hL.ge hs.1 t ht.1 + obtain ⟨B,hB,hSB,e,heS,heN,heform⟩ := exists_pair_block ω ha S N hS hN hzero + let T : Submodule K B := (horizontalSpace (K := K) (V := S)).map e.toLinearMap + let U : Submodule K B := (verticalSpace (K := K) (V := S)).map e.toLinearMap + let Q := U.map B.subtype + have hT : (ω.restrict B).orthogonal T = T := by + change (ω.restrict B).orthogonal (horizontalSpace.map e.toLinearMap) = horizontalSpace.map e.toLinearMap + rw [orthogonal_map_isometry_between (canonicalSymplectic (K := K) (V := S)) + (ω.restrict B) e (fun x y => heform x y),horizontalSpace_selforthogonal] + have hU : (ω.restrict B).orthogonal U = U := by + change (ω.restrict B).orthogonal (verticalSpace.map e.toLinearMap) = verticalSpace.map e.toLinearMap + rw [orthogonal_map_isometry_between (canonicalSymplectic (K := K) (V := S)) + (ω.restrict B) e (fun x y => heform x y)] + exact congrArg (fun U : Submodule K (S × Module.Dual K S) => U.map e.toLinearMap) + (verticalLagrangian (K := K) (V := S)).property + have hTS : T.map B.subtype = S := by + ext x + constructor + · rintro ⟨b,⟨z,hz,rfl⟩,rfl⟩ + obtain ⟨s,f⟩ := z + have hf : f = 0 := hz + subst f + change (e (s,0)).val ∈ S + rw [heS] + exact s.property + · intro hx + refine ⟨e (⟨x,hx⟩,0),⟨(⟨x,hx⟩,0),rfl,rfl⟩,?_⟩ + exact heS ⟨x,hx⟩ + have hQN : Q ≤ N := by + rintro x ⟨b,⟨z,hz,rfl⟩,rfl⟩ + obtain ⟨s,f⟩ := z + have hs : s = 0 := hz + subst s + exact heN f + have hQB : Q ≤ B := by rintro x ⟨b,_,rfl⟩; exact b.property + have hdim : finrank K Q = finrank K S := by + change finrank K (U.map B.subtype) = finrank K S + rw [← (Submodule.equivMapOfInjective B.subtype B.injective_subtype U).finrank_eq] + change finrank K (verticalSpace.map e.toLinearMap) = finrank K S + rw [e.finrank_map_eq] + rw [← (verticalSpaceEquiv (K := K) (V := S)).finrank_eq,Subspace.dual_finrank_eq] + have hBQ : B = S ⊔ Q := by + apply le_antisymm + · intro x hx + obtain ⟨z,hz⟩ := e.surjective ⟨x,hx⟩ + have hsum : x = z.1.val + (e (0,z.2)).val := by + have headd := e.map_add (z.1,0) (0,z.2) + have headd' := congrArg Subtype.val headd + simp only [Prod.mk_add_mk,add_zero,zero_add] at headd' + rw [hz] at headd' + change x = (e (z.1,0)).val + (e (0,z.2)).val at headd' + rw [heS] at headd' + exact headd' + rw [hsum] + exact Submodule.add_mem_sup z.1.property ⟨e (0,z.2),⟨(0,z.2),rfl,rfl⟩,rfl⟩ + · exact sup_le hSB hQB + have hsplitL : L = S ⊔ (L ⊓ ω.orthogonal B) := by + simpa only [hTS] using forced_orthogonal_splitting ω ha B L hB hL.ge T hT + (by rw [hTS]; exact inf_le_left) + have hsplitM : M = S ⊔ (M ⊓ ω.orthogonal B) := by + simpa only [hTS] using forced_orthogonal_splitting ω ha B M hB hM.ge T hT + (by rw [hTS]; exact inf_le_right) + have hsplitN : N = Q ⊔ (N ⊓ ω.orthogonal B) := + forced_orthogonal_splitting ω ha B N hB hN.ge U hU hQN + have hsurvive (A : Submodule K E) (hA : ω.orthogonal A = A) (hSA : S ≤ A) : + A ⊓ N ≤ ω.orthogonal B := by + intro x hx b hb + rw [hBQ] at hb + obtain ⟨s,hs,q,hq,rfl⟩ := Submodule.mem_sup.mp hb + simp only [map_add,LinearMap.add_apply] + rw [hA.ge hx.1 s (hSA hs),hN.ge hx.2 q (hQN hq),add_zero] + have hdisj : (L ⊓ ω.orthogonal B) ⊓ (M ⊓ ω.orthogonal B) = ⊥ := by + apply (Submodule.eq_bot_iff _).mpr + intro x hx + have hb : x ∈ B := hSB ⟨hx.1.1,hx.2.1⟩ + exact (ω.isCompl_orthogonal_of_restrict_nondegenerate ha.isRefl hB).disjoint.le_bot + ⟨hb,hx.1.2⟩ + refine ⟨B,Q,hB,hSB,hQB,hQN,hdim,hBQ,hsplitL,hsplitM,hsplitN, + hsurvive L hL inf_le_left,hsurvive M hM inf_le_right,hdisj,?_,e,heS,rfl,heform⟩ + intro A hA + rcases (show A = L ∨ A = M ∨ A = N from hA) with hA | hA | hA + · subst A + exact split_residual_lagrangian ω ha B L hB hL T hT (by rw [hTS]; exact inf_le_left) + · subst A + exact split_residual_lagrangian ω ha B M hB hM T hT (by rw [hTS]; exact inf_le_right) + · subst A + exact split_residual_lagrangian ω ha B N hB hN U hU hQN + +end TripleOneBlock +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section OrthogonalReduction +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] + [FiniteDimensional K E] +variable (ω : LinearMap.BilinForm K E) + +/-- If an isotropic space is Lagrangian in a nondegenerate block, its +symplectic quotient is the orthogonal complement of that block, with the +literal quotient map as isometry. -/ +theorem exists_complement_reduction_equiv (ha : ω.IsAlt) + (S B : Submodule K E) (hB : (ω.restrict B).Nondegenerate) + (hSB : S ≤ B) (hBS : B ⊓ ω.orthogonal S = S) : + ∃ e : ω.orthogonal B ≃ₗ[K] ReducedSpace ω S, + (∀ x : ω.orthogonal B, e x = (reductionKernel ω S).mkQ + ⟨x.val,by intro s hs; exact x.property s (hSB hs)⟩) ∧ + (∀ x y, symplecticReductionForm ω S ha (e x) (e y) = ω x.val y.val) ∧ + ∀ L : Submodule K E, L = (L ⊓ B) ⊔ (L ⊓ ω.orthogonal B) → + (L.comap (ω.orthogonal B).subtype).map e.toLinearMap = reduceSubspace ω S L := by + let U := ω.orthogonal B + have hUS : U ≤ ω.orthogonal S := by + intro x hx s hs + exact hx s (hSB hs) + let f : U →ₗ[K] ReducedSpace ω S := + (reductionKernel ω S).mkQ.comp (Submodule.inclusion hUS) + have hf (x : U) : f x = (reductionKernel ω S).mkQ ⟨x.val,hUS x.property⟩ := rfl + have hc := ω.isCompl_orthogonal_of_restrict_nondegenerate ha.isRefl hB + have hinj : Function.Injective f := by + apply LinearMap.ker_eq_bot.mp + apply (Submodule.eq_bot_iff _).mpr + intro x hx + have hxS : x.val ∈ S := (Submodule.Quotient.mk_eq_zero (reductionKernel ω S)).mp hx + apply Subtype.ext + exact hc.disjoint.le_bot ⟨hSB hxS,x.property⟩ + have hsurj : Function.Surjective f := by + intro z + induction z using Submodule.Quotient.induction_on with + | H z => + have hz : z.val ∈ B ⊔ U := hc.sup_eq_top.symm ▸ Submodule.mem_top + obtain ⟨b,hb,u,hu,hbu⟩ := Submodule.mem_sup.mp hz + have hbS : b ∈ S := by + apply hBS.le + refine ⟨hb,?_⟩ + have hbval : b = z.val-u := by rw [←hbu]; abel + rw [hbval] + exact (ω.orthogonal S).sub_mem z.property (hUS hu) + refine ⟨⟨u,hu⟩,?_⟩ + apply (Submodule.Quotient.eq (reductionKernel ω S)).mpr + change u-z.val ∈ S + have huval : u-z.val = -b := by rw [←hbu]; abel + rw [huval] + exact S.neg_mem hbS + let e : U ≃ₗ[K] ReducedSpace ω S := LinearEquiv.ofBijective f ⟨hinj,hsurj⟩ + refine ⟨e,fun _ => rfl,fun _ _ => rfl,?_⟩ + intro L hL + ext z + constructor + · rintro ⟨u,hu,rfl⟩ + exact ⟨⟨u.val,hUS u.property⟩,hu,rfl⟩ + · rintro ⟨x,hx,rfl⟩ + have hx' : x.val ∈ (L ⊓ B) ⊔ (L ⊓ U) := hL ▸ hx + obtain ⟨b,hb,u,hu,hbu⟩ := Submodule.mem_sup.mp hx' + have hbS : b ∈ S := by + apply hBS.le + refine ⟨hb.2,?_⟩ + have hbval : b = x.val-u := by rw [←hbu]; abel + rw [hbval] + exact (ω.orthogonal S).sub_mem x.property (hUS hu.2) + refine ⟨⟨u,hu.2⟩,hu.1,?_⟩ + change (reductionKernel ω S).mkQ ⟨u,hUS hu.2⟩ = (reductionKernel ω S).mkQ x + apply (Submodule.Quotient.eq (reductionKernel ω S)).mpr + change u-x.val ∈ S + have huval : u-x.val = -b := by rw [←hbu]; abel + rw [huval] + exact S.neg_mem hbS +end OrthogonalReduction +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section ReductionInStages +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] +variable (ω : LinearMap.BilinForm K E) (ha : ω.IsAlt) + +/-- Symplectic reduction in two nested isotropic spaces agrees with direct +reduction. The equivalence also identifies the general (not merely containing) +reduction of every subspace. -/ +theorem exists_reduction_in_stages (S T : Submodule K E) + (hST : S ≤ T) (hT : T ≤ ω.orthogonal T) : + ∃ e : ReducedSpace ω T ≃ₗ[K] + ReducedSpace (symplecticReductionForm ω S ha) (reduceSubspace ω S T), + (∀ x y, symplecticReductionForm (symplecticReductionForm ω S ha) + (reduceSubspace ω S T) (symplecticReductionForm_alt ω S ha) (e x) (e y) = + symplecticReductionForm ω T ha x y) ∧ + ∀ L : Submodule K E, + (reduceSubspace ω T L).map e.toLinearMap = + reduceSubspace (symplecticReductionForm ω S ha) + (reduceSubspace ω S T) (reduceSubspace ω S L) := by + let α := symplecticReductionForm ω S ha + let R := reduceSubspace ω S T + have hPS : ω.orthogonal T ≤ ω.orthogonal S := by + intro x hx s hs + exact hx s (hST hs) + have hmem (x : ω.orthogonal S) : + (reductionKernel ω S).mkQ x ∈ α.orthogonal R ↔ x.val ∈ ω.orthogonal T := by + constructor + · intro hx t ht + have htS : t ∈ ω.orthogonal S := hPS (hT ht) + exact hx ((reductionKernel ω S).mkQ ⟨t,htS⟩) ⟨⟨t,htS⟩,ht,rfl⟩ + · intro hx z hz + obtain ⟨t,ht,rfl⟩ := hz + exact hx t.val ht + let p : ω.orthogonal T →ₗ[K] α.orthogonal R := + { toFun := fun x => ⟨(reductionKernel ω S).mkQ ⟨x.val,hPS x.property⟩, + (hmem _).mpr x.property⟩ + map_add' := by + intro x y + apply Subtype.ext + exact (reductionKernel ω S).mkQ.map_add + ⟨x.val,hPS x.property⟩ ⟨y.val,hPS y.property⟩ + map_smul' := by + intro c x + apply Subtype.ext + exact (reductionKernel ω S).mkQ.map_smul c ⟨x.val,hPS x.property⟩ } + let g : ω.orthogonal T →ₗ[K] ReducedSpace α R := (reductionKernel α R).mkQ.comp p + have hker : reductionKernel ω T ≤ g.ker := by + intro x hx + apply (Submodule.Quotient.mk_eq_zero (reductionKernel α R)).mpr + exact ⟨⟨x.val,hPS x.property⟩,hx,rfl⟩ + let f : ReducedSpace ω T →ₗ[K] ReducedSpace α R := (reductionKernel ω T).liftQ g hker + have hf (x : ω.orthogonal T) : f ((reductionKernel ω T).mkQ x) = + (reductionKernel α R).mkQ (p x) := rfl + have hinj : Function.Injective f := by + apply LinearMap.ker_eq_bot.mp + apply (Submodule.eq_bot_iff _).mpr + intro z hz + induction z using Submodule.Quotient.induction_on with + | H x => + have hxR : (p x).val ∈ R := + (Submodule.Quotient.mk_eq_zero (reductionKernel α R)).mp hz + obtain ⟨t,ht,heq⟩ := hxR + have hdiff : t.val-x.val ∈ S := + (Submodule.Quotient.eq (reductionKernel ω S)).mp heq + apply (Submodule.Quotient.mk_eq_zero (reductionKernel ω T)).mpr + have hxT := T.sub_mem ht (hST hdiff) + change x.val ∈ T + simpa only [Submodule.subtype_apply,sub_sub_cancel] using hxT + have hsurj : Function.Surjective f := by + intro z + induction z using Submodule.Quotient.induction_on with + | H y => + obtain ⟨x,hx⟩ := (reductionKernel ω S).mkQ_surjective y.val + have hxT : x.val ∈ ω.orthogonal T := (hmem x).mp (hx.symm ▸ y.property) + refine ⟨(reductionKernel ω T).mkQ ⟨x.val,hxT⟩,?_⟩ + rw [hf] + apply congrArg (reductionKernel α R).mkQ + apply Subtype.ext + exact hx + let e : ReducedSpace ω T ≃ₗ[K] ReducedSpace α R := LinearEquiv.ofBijective f ⟨hinj,hsurj⟩ + refine ⟨e,?_,?_⟩ + · intro x y + induction x using Submodule.Quotient.induction_on with + | H x => + induction y using Submodule.Quotient.induction_on with + | H y => rfl + · intro L + ext z + constructor + · rintro ⟨y,⟨x,hx,rfl⟩,rfl⟩ + refine ⟨p x,?_,rfl⟩ + exact ⟨⟨x.val,hPS x.property⟩,hx,rfl⟩ + · rintro ⟨y,hy,rfl⟩ + obtain ⟨x,hx,hxy⟩ := hy + have hxT : x.val ∈ ω.orthogonal T := (hmem x).mp (hxy.symm ▸ y.property) + refine ⟨(reductionKernel ω T).mkQ ⟨x.val,hxT⟩, + ⟨⟨x.val,hxT⟩,hx,rfl⟩,?_⟩ + change (reductionKernel α R).mkQ (p ⟨x.val,hxT⟩) = (reductionKernel α R).mkQ y + congr 1 + apply Subtype.ext + exact hxy +end ReductionInStages +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +section ReductionIsometry +variable {K E F : Type*} [Field K] [AddCommGroup E] [Module K E] + [AddCommGroup F] [Module K F] + +/-- Naturality of symplectic reduction under an isometry between arbitrary +ambient spaces. Both forms and every reduced subspace are preserved. -/ +theorem exists_reduction_isometry_between + (ω : LinearMap.BilinForm K E) (η : LinearMap.BilinForm K F) + (ha : ω.IsAlt) (hb : η.IsAlt) (e : E ≃ₗ[K] F) + (he : ∀ x y, η (e x) (e y) = ω x y) + (S : Submodule K E) (T : Submodule K F) (hST : S.map e.toLinearMap = T) : + ∃ f : ReducedSpace ω S ≃ₗ[K] ReducedSpace η T, + (∀ x y, symplecticReductionForm η T hb (f x) (f y) = + symplecticReductionForm ω S ha x y) ∧ + ∀ L : Submodule K E, + (reduceSubspace ω S L).map f.toLinearMap = reduceSubspace η T (L.map e.toLinearMap) := by + have hP : (ω.orthogonal S).map e.toLinearMap = η.orthogonal T := by + ext y + constructor + · rintro ⟨x,hx,rfl⟩ t ht + rw [←hST] at ht + obtain ⟨s,hs,rfl⟩ := ht + change η (e s) (e x) = 0 + rw [he] + exact hx s hs + · intro hy + refine ⟨e.symm y,?_,e.apply_symm_apply y⟩ + intro s hs + rw [←he,e.apply_symm_apply] + exact hy (e s) (hST.le ⟨s,hs,rfl⟩) + let p : ω.orthogonal S ≃ₗ[K] η.orthogonal T := e.ofSubmodules _ _ hP + have hp (x : ω.orthogonal S) : (p x).val = e x.val := rfl + have hker : (reductionKernel ω S).map p.toLinearMap = reductionKernel η T := by + ext y + constructor + · rintro ⟨x,hx,rfl⟩ + exact hST.le ⟨x.val,hx,rfl⟩ + · intro hy + obtain ⟨x,rfl⟩ := p.surjective y + have hex : e x.val ∈ T := hy + rw [←hST] at hex + obtain ⟨s,hs,hse⟩ := hex + have hsx : s = x.val := e.injective hse + refine ⟨x,?_,rfl⟩ + change x.val ∈ S + exact hsx ▸ hs + let f := Submodule.Quotient.equiv (reductionKernel ω S) (reductionKernel η T) p hker + have hf (x : ω.orthogonal S) : f ((reductionKernel ω S).mkQ x) = + (reductionKernel η T).mkQ (p x) := rfl + refine ⟨f,?_,?_⟩ + · intro x y + induction x using Submodule.Quotient.induction_on with + | H x => + induction y using Submodule.Quotient.induction_on with + | H y => exact he x.val y.val + · intro L + ext z + constructor + · rintro ⟨y,⟨x,hx,rfl⟩,rfl⟩ + refine ⟨p x,?_,rfl⟩ + exact ⟨x.val,hx,rfl⟩ + · rintro ⟨y,hy,rfl⟩ + obtain ⟨x,rfl⟩ := p.surjective y + obtain ⟨l,hl,hlx⟩ := hy + have hlx' : l = x.val := e.injective hlx + refine ⟨(reductionKernel ω S).mkQ x,⟨x,?_,rfl⟩,rfl⟩ + change x.val ∈ L + exact hlx' ▸ hl +end ReductionIsometry +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section OrthogonalIsometries +variable {K E F : Type*} [Field K] [AddCommGroup E] [Module K E] + [AddCommGroup F] [Module K F] [FiniteDimensional K E] [FiniteDimensional K F] + +/-- Assemble isometries on a nondegenerate block and its orthogonal complement. -/ +theorem exists_orthogonal_isometry_between + (ω : LinearMap.BilinForm K E) (η : LinearMap.BilinForm K F) + (ha : ω.IsAlt) (hb : η.IsAlt) + (B : Submodule K E) (C : Submodule K F) + (hB : (ω.restrict B).Nondegenerate) (hC : (η.restrict C).Nondegenerate) + (f : B ≃ₗ[K] C) (g : ω.orthogonal B ≃ₗ[K] η.orthogonal C) + (hf : ∀ x y, η (f x).val (f y).val = ω x.val y.val) + (hg : ∀ x y, η (g x).val (g y).val = ω x.val y.val) : + ∃ e : E ≃ₗ[K] F, (∀ x y, η (e x) (e y) = ω x y) ∧ + (∀ x : B, e x.val = (f x).val) ∧ + (∀ x : ω.orthogonal B, e x.val = (g x).val) := by + let c := B.prodEquivOfIsCompl (ω.orthogonal B) + (ω.isCompl_orthogonal_of_restrict_nondegenerate ha.isRefl hB) + let d := C.prodEquivOfIsCompl (η.orthogonal C) + (η.isCompl_orthogonal_of_restrict_nondegenerate hb.isRefl hC) + let e := c.symm.trans ((f.prodCongr g).trans d) + have he (x : B × ω.orthogonal B) : e (c x) = d (f x.1,g x.2) := by simp [e] + refine ⟨e,?_,?_,?_⟩ + · intro x y + obtain ⟨x,rfl⟩ := c.surjective x + obtain ⟨y,rfl⟩ := c.surjective y + rw [he,he] + change η ((f x.1).val + (g x.2).val) ((f y.1).val + (g y.2).val) = + ω (x.1.val + x.2.val) (y.1.val + y.2.val) + rw [form_orthogonal_sum η hb C (f x.1,g x.2) (f y.1,g y.2), + form_orthogonal_sum ω ha B x y,hf,hg] + · intro x + have h := he (x,0) + simpa [c,d] using h + · intro x + have h := he (0,x) + simpa [c,d] using h + +omit [FiniteDimensional K E] [FiniteDimensional K F] in +/-- Mapping the two honest summands maps their sum, including repeated or zero +summands. This is used only for actual orthogonal splittings of Lagrangians. -/ +theorem map_orthogonal_split (e : E ≃ₗ[K] F) + (B : Submodule K E) (C : Submodule K F) + (f : B ≃ₗ[K] C) (heB : ∀ x : B, e x.val = (f x).val) + (U : Submodule K E) (W : Submodule K F) + (g : U ≃ₗ[K] W) (heU : ∀ x : U, e x.val = (g x).val) + (L : Submodule K E) (M : Submodule K F) + (hL : L = (L ⊓ B) ⊔ (L ⊓ U)) (hM : M = (M ⊓ C) ⊔ (M ⊓ W)) + (hf : (L.comap B.subtype).map f.toLinearMap = M.comap C.subtype) + (hg : (L.comap U.subtype).map g.toLinearMap = M.comap W.subtype) : + L.map e.toLinearMap = M := by + have hblock : (L ⊓ B).map e.toLinearMap = M ⊓ C := by + ext y + constructor + · rintro ⟨x,hx,rfl⟩ + have hy : f ⟨x,hx.2⟩ ∈ M.comap C.subtype := hf.le ⟨⟨x,hx.2⟩,hx.1,rfl⟩ + change e x ∈ M ⊓ C + rw [heB ⟨x,hx.2⟩] + exact ⟨hy,(f ⟨x,hx.2⟩).property⟩ + · intro hy + have hy' : (⟨y,hy.2⟩ : C) ∈ (L.comap B.subtype).map f.toLinearMap := hf.ge hy.1 + obtain ⟨x,hx,hxy⟩ := hy' + refine ⟨x.val,⟨hx,x.property⟩,?_⟩ + change e x.val = y + exact (heB x).trans (congrArg Subtype.val hxy) + have hres : (L ⊓ U).map e.toLinearMap = M ⊓ W := by + ext y + constructor + · rintro ⟨x,hx,rfl⟩ + have hy : g ⟨x,hx.2⟩ ∈ M.comap W.subtype := hg.le ⟨⟨x,hx.2⟩,hx.1,rfl⟩ + change e x ∈ M ⊓ W + rw [heU ⟨x,hx.2⟩] + exact ⟨hy,(g ⟨x,hx.2⟩).property⟩ + · intro hy + have hy' : (⟨y,hy.2⟩ : W) ∈ (L.comap U.subtype).map g.toLinearMap := hg.ge hy.1 + obtain ⟨x,hx,hxy⟩ := hy' + refine ⟨x.val,⟨hx,x.property⟩,?_⟩ + change e x.val = y + exact (heU x).trans (congrArg Subtype.val hxy) + calc + L.map e.toLinearMap = ((L ⊓ B) ⊔ (L ⊓ U)).map e.toLinearMap := congrArg _ hL + _ = (M ⊓ C) ⊔ (M ⊓ W) := by rw [Submodule.map_sup,hblock,hres] + _ = M := hM.symm +end OrthogonalIsometries +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +section SplitHelpers +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] + +theorem split_inter_block (L A B U : Submodule K E) + (hBU : Disjoint B U) (hAB : A ≤ B) (hL : L = A ⊔ (L ⊓ U)) : + L ⊓ B = A := by + apply le_antisymm + · intro x hx + have hxL : x ∈ A ⊔ (L ⊓ U) := hL ▸ hx.1 + obtain ⟨a,ha,u,hu,hau⟩ := Submodule.mem_sup.mp hxL + have huB : u ∈ B := by + have huval : u = x-a := by rw [←hau]; abel + rw [huval] + exact B.sub_mem hx.2 (hAB ha) + have hu0 : u = 0 := hBU.le_bot ⟨huB,hu.2⟩ + rw [hu0,add_zero] at hau + exact hau ▸ ha + · exact le_inf (hL.symm ▸ le_sup_left) hAB + +theorem split_over_block (L A B U : Submodule K E) + (hAB : A ≤ B) (hL : L = A ⊔ (L ⊓ U)) : + L = (L ⊓ B) ⊔ (L ⊓ U) := by + apply le_antisymm + · calc + L = A ⊔ (L ⊓ U) := hL + _ ≤ (L ⊓ B) ⊔ (L ⊓ U) := + sup_le_sup (le_inf (hL.symm ▸ le_sup_left) hAB) le_rfl + · exact sup_le inf_le_left inf_le_left +end SplitHelpers +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section TripleBlockData +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] + [FiniteDimensional K E] +variable (ω : LinearMap.BilinForm K E) + +/-- A common-zero triple has honest pair-block coordinates and the same +residual triple as direct symplectic reduction by that pair intersection. -/ +theorem triple_block_reduction_data (ha : ω.IsAlt) + (L M N : Submodule K E) (hL : ω.orthogonal L = L) + (hM : ω.orthogonal M = M) (hN : ω.orthogonal N = N) + (hzero : (L ⊓ M) ⊓ N = ⊥) : + ∃ B : Submodule K E, (ω.restrict B).Nondegenerate ∧ + ∃ e : (↥(L ⊓ M) × Module.Dual K ↥(L ⊓ M)) ≃ₗ[K] B, + ∃ f : ω.orthogonal B ≃ₗ[K] ReducedSpace ω (L ⊓ M), + (∀ x y, ω (e x).val (e y).val = canonicalSymplectic x y) ∧ + (∀ x y, symplecticReductionForm ω (L ⊓ M) ha (f x) (f y) = ω x.val y.val) ∧ + L.comap B.subtype = horizontalSpace.map e.toLinearMap ∧ + M.comap B.subtype = horizontalSpace.map e.toLinearMap ∧ + N.comap B.subtype = verticalSpace.map e.toLinearMap ∧ + ∀ A ∈ ({L,M,N} : Set (Submodule K E)), + A = (A ⊓ B) ⊔ (A ⊓ ω.orthogonal B) ∧ + (A.comap (ω.orthogonal B).subtype).map f.toLinearMap = + reduceSubspace ω (L ⊓ M) A := by + obtain ⟨B,Q,hB,hSB,hQB,_hQN,_hdim,_hBQ,hSL,hSM,hSN,_hsL,_hsM,_hdisj,_hres, + e,heS,heQ,heform⟩ := triple_pair_block ω ha L M N hL hM hN hzero + let S := L ⊓ M + let T : Submodule K B := horizontalSpace.map e.toLinearMap + have hTS : T.map B.subtype = S := by + ext x + constructor + · rintro ⟨b,⟨z,hz,rfl⟩,rfl⟩ + obtain ⟨s,g⟩ := z + have hg : g = 0 := hz + subst g + change (e (s,0)).val ∈ S + rw [heS] + exact s.property + · intro hx + refine ⟨e (⟨x,hx⟩,0),⟨(⟨x,hx⟩,0),rfl,rfl⟩,?_⟩ + exact heS ⟨x,hx⟩ + have hT : (ω.restrict B).orthogonal T = T := by + rw [orthogonal_map_isometry_between (canonicalSymplectic (K := K) (V := S)) + (ω.restrict B) e (fun x y => heform x y),horizontalSpace_selforthogonal] + have hBS : B ⊓ ω.orthogonal S = S := by + apply le_antisymm + · intro x hx + have hxT : (⟨x,hx.1⟩ : B) ∈ T := by + apply hT.le + intro b hb + exact hx.2 b.val (hTS.le ⟨b,hb,rfl⟩) + exact hTS.le ⟨⟨x,hx.1⟩,hxT,rfl⟩ + · refine le_inf hSB ?_ + intro s hs t ht + exact hL.ge hs.1 t ht.1 + have hLU := split_over_block L S B (ω.orthogonal B) hSB hSL + have hMU := split_over_block M S B (ω.orthogonal B) hSB hSM + have hNU := split_over_block N Q B (ω.orthogonal B) hQB hSN + obtain ⟨f,_hf,hfform,hfred⟩ := exists_complement_reduction_equiv ω ha S B hB hSB hBS + have hcompl := ω.isCompl_orthogonal_of_restrict_nondegenerate ha.isRefl hB + have hLB := split_inter_block L S B (ω.orthogonal B) hcompl.disjoint hSB hSL + have hMB := split_inter_block M S B (ω.orthogonal B) hcompl.disjoint hSB hSM + have hNB := split_inter_block N Q B (ω.orthogonal B) hcompl.disjoint hQB hSN + refine ⟨B,hB,e,f,heform,hfform,?_,?_,?_,?_⟩ + · apply Submodule.map_injective_of_injective B.injective_subtype + rw [Submodule.map_comap_subtype,inf_comm,hLB] + exact hTS.symm + · apply Submodule.map_injective_of_injective B.injective_subtype + rw [Submodule.map_comap_subtype,inf_comm,hMB] + exact hTS.symm + · apply Submodule.map_injective_of_injective B.injective_subtype + rw [Submodule.map_comap_subtype,inf_comm,hNB] + exact heQ.symm + · intro A hA + rcases (show A = L ∨ A = M ∨ A = N from hA) with heq | heq | heq + · subst A; exact ⟨hLU,hfred L hLU⟩ + · subst A; exact ⟨hMU,hfred M hMU⟩ + · subst A; exact ⟨hNU,hfred N hNU⟩ +end TripleBlockData +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +section MapTransport +variable {K E F E' F' : Type*} [Field K] + [AddCommGroup E] [Module K E] [AddCommGroup F] [Module K F] + [AddCommGroup E'] [Module K E'] [AddCommGroup F'] [Module K F'] + +theorem map_transport_equiv (u : E ≃ₗ[K] E') (v : F ≃ₗ[K] F') + (r : E' ≃ₗ[K] F') (A : Submodule K E) (B : Submodule K F) + (h : (A.map u.toLinearMap).map r.toLinearMap = B.map v.toLinearMap) : + A.map (u.trans (r.trans v.symm)).toLinearMap = B := by + apply Submodule.map_injective_of_injective v.injective + calc + (A.map (u.trans (r.trans v.symm)).toLinearMap).map v.toLinearMap = + (A.map u.toLinearMap).map r.toLinearMap := by + simp only [← Submodule.map_comp] + congr 1 + ext x + simp + _ = B.map v.toLinearMap := h + +theorem map_conjugate_equiv (u : E ≃ₗ[K] E') (v : F ≃ₗ[K] F') + (r : E ≃ₗ[K] F) (A : Submodule K E) : + (A.map u.toLinearMap).map (u.symm.trans (r.trans v)).toLinearMap = + (A.map r.toLinearMap).map v.toLinearMap := by + simp only [← Submodule.map_comp] + congr 1 + ext x + simp +end MapTransport + +open Module +section TripleOneBlockLift +variable {K E F : Type*} [Field K] + [AddCommGroup E] [Module K E] [AddCommGroup F] [Module K F] + [FiniteDimensional K E] [FiniteDimensional K F] + +/-- The extension across one pair block. No extension invariant remains: +any isometry of the three reduced Lagrangians lifts to the triple. -/ +theorem triple_one_block_lift + (ω : LinearMap.BilinForm K E) (η : LinearMap.BilinForm K F) + (ha : ω.IsAlt) (hb : η.IsAlt) + (L M N : Submodule K E) (L' M' N' : Submodule K F) + (hL : ω.orthogonal L = L) (hM : ω.orthogonal M = M) (hN : ω.orthogonal N = N) + (hL' : η.orthogonal L' = L') (hM' : η.orthogonal M' = M') + (hN' : η.orthogonal N' = N') + (hzero : (L ⊓ M) ⊓ N = ⊥) (hzero' : (L' ⊓ M') ⊓ N' = ⊥) + (hdim : finrank K ↥(L ⊓ M) = finrank K ↥(L' ⊓ M')) + (r : ReducedSpace ω (L ⊓ M) ≃ₗ[K] ReducedSpace η (L' ⊓ M')) + (hr : ∀ x y, symplecticReductionForm η (L' ⊓ M') hb (r x) (r y) = + symplecticReductionForm ω (L ⊓ M) ha x y) + (hrL : (reduceSubspace ω (L ⊓ M) L).map r.toLinearMap = + reduceSubspace η (L' ⊓ M') L') + (hrM : (reduceSubspace ω (L ⊓ M) M).map r.toLinearMap = + reduceSubspace η (L' ⊓ M') M') + (hrN : (reduceSubspace ω (L ⊓ M) N).map r.toLinearMap = + reduceSubspace η (L' ⊓ M') N') : + ∃ e : E ≃ₗ[K] F, (∀ x y, η (e x) (e y) = ω x y) ∧ + L.map e.toLinearMap = L' ∧ M.map e.toLinearMap = M' ∧ + N.map e.toLinearMap = N' := by + obtain ⟨B,hB,b,f,hbform,hfform,hLb,hMb,hNb,hsplit⟩ := + triple_block_reduction_data ω ha L M N hL hM hN hzero + obtain ⟨C,hC,c,g,hcform,hgform,hLc,hMc,hNc,hsplit'⟩ := + triple_block_reduction_data η hb L' M' N' hL' hM' hN' hzero' + let t : ↥(L ⊓ M) ≃ₗ[K] ↥(L' ⊓ M') := LinearEquiv.ofFinrankEq _ _ hdim + let w := t.prodCongr t.symm.dualMap + have hw (x y : ↥(L ⊓ M) × Module.Dual K ↥(L ⊓ M)) : + canonicalSymplectic (w x) (w y) = canonicalSymplectic x y := by + simp [w,canonicalSymplectic_apply] + have hwH : horizontalSpace.map w.toLinearMap = horizontalSpace := by + apply subspace_map_eq_of_mem_iff + intro x + change t.symm.dualMap x.2 = 0 ↔ x.2 = 0 + exact t.symm.dualMap.map_eq_zero_iff + have hwV : verticalSpace.map w.toLinearMap = verticalSpace := by + apply subspace_map_eq_of_mem_iff + intro x + change t x.1 = 0 ↔ x.1 = 0 + exact t.map_eq_zero_iff + let u := b.symm.trans (w.trans c) + let v := f.trans (r.trans g.symm) + have hu (x y : B) : η (u x).val (u y).val = ω x.val y.val := by + change η (c (w (b.symm x))).val (c (w (b.symm y))).val = _ + rw [hcform,hw,←hbform,b.apply_symm_apply,b.apply_symm_apply] + have hv (x y : ω.orthogonal B) : η (v x).val (v y).val = ω x.val y.val := by + rw [← hgform] + change symplecticReductionForm η (L' ⊓ M') hb + (g (g.symm (r (f x)))) (g (g.symm (r (f y)))) = _ + rw [g.apply_symm_apply,g.apply_symm_apply,hr,hfform] + obtain ⟨e,he,heB,heU⟩ := exists_orthogonal_isometry_between ω η ha hb B C hB hC u v hu hv + have hblockH : (horizontalSpace.map b.toLinearMap).map u.toLinearMap = + horizontalSpace.map c.toLinearMap := by + rw [map_conjugate_equiv b c w,hwH] + have hblockV : (verticalSpace.map b.toLinearMap).map u.toLinearMap = + verticalSpace.map c.toLinearMap := by + rw [map_conjugate_equiv b c w,hwV] + have hmap (A : Submodule K E) (A' : Submodule K F) + (hA : A ∈ ({L,M,N} : Set (Submodule K E))) + (hA' : A' ∈ ({L',M',N'} : Set (Submodule K F))) + (hblock : (A.comap B.subtype).map u.toLinearMap = A'.comap C.subtype) + (hres : (reduceSubspace ω (L ⊓ M) A).map r.toLinearMap = + reduceSubspace η (L' ⊓ M') A') : A.map e.toLinearMap = A' := by + obtain ⟨hAs,hAr⟩ := hsplit A hA + obtain ⟨hAs',hAr'⟩ := hsplit' A' hA' + apply map_orthogonal_split e B C u heB (ω.orthogonal B) (η.orthogonal C) + v heU A A' hAs hAs' hblock + apply map_transport_equiv f g r + rw [hAr,hAr',hres] + refine ⟨e,he,?_,?_,?_⟩ + · exact hmap L L' (by simp) (by simp) (by rw [hLb,hLc]; exact hblockH) hrL + · exact hmap M M' (by simp) (by simp) (by rw [hMb,hMc]; exact hblockH) hrM + · exact hmap N N' (by simp) (by simp) (by rw [hNb,hNc]; exact hblockV) hrN +end TripleOneBlockLift +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section ReductionIntersections +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] +variable (ω : LinearMap.BilinForm K E) (S : Submodule K E) + +@[simp] theorem reduceSubspace_self : reduceSubspace ω S S = ⊥ := by + apply (Submodule.eq_bot_iff _).mpr + rintro x ⟨y,hy,rfl⟩ + exact (Submodule.Quotient.mk_eq_zero (reductionKernel ω S)).mpr hy + +/-- Intersections commute with quotienting when the first subspace contains +its kernel. This includes the two pair intersections which survive a split. -/ +theorem reduceSubspace_inf (L N : Submodule K E) (hSL : S ≤ L) : + reduceSubspace ω S (L ⊓ N) = + reduceSubspace ω S L ⊓ reduceSubspace ω S N := by + apply le_antisymm + · rintro x ⟨y,hy,rfl⟩ + exact ⟨⟨y,hy.1,rfl⟩,⟨y,hy.2,rfl⟩⟩ + · rintro x ⟨⟨l,hl,hlx⟩,⟨n,hn,hnx⟩⟩ + have heq : (reductionKernel ω S).mkQ (l-n) = 0 := by + rw [map_sub,hlx,hnx,sub_self] + have hln : l.val-n.val ∈ S := + (Submodule.Quotient.mk_eq_zero (reductionKernel ω S)).mp heq + have hnL : n.val ∈ L := by + have h := L.sub_mem hl (hSL hln) + simpa using h + exact ⟨n,⟨hnL,hn⟩,hnx⟩ + +/-- Reduction preserves a subspace disjoint from the quotient kernel. -/ +theorem reduceSubspace_finrank_of_disjoint [FiniteDimensional K E] + (A : Submodule K E) (hAP : A ≤ ω.orthogonal S) (hAS : Disjoint A S) : + finrank K (reduceSubspace ω S A) = finrank K A := by + let f : A →ₗ[K] ReducedSpace ω S := + (reductionKernel ω S).mkQ.comp ((Submodule.inclusion hAP)) + have hf : Function.Injective f := by + apply LinearMap.ker_eq_bot.mp + apply (Submodule.eq_bot_iff _).mpr + intro x hx + apply Subtype.ext + have hxS : x.val ∈ S := + (Submodule.Quotient.mk_eq_zero (reductionKernel ω S)).mp hx + exact hAS.le_bot ⟨x.property,hxS⟩ + have hfr : LinearMap.range f = reduceSubspace ω S A := by + ext y + constructor + · rintro ⟨x,rfl⟩ + exact ⟨⟨x.val,hAP x.property⟩,x.property,rfl⟩ + · rintro ⟨x,hx,rfl⟩ + exact ⟨⟨x.val,hx⟩,rfl⟩ + rw [←hfr] + exact (LinearEquiv.ofInjective f hf).finrank_eq.symm + +theorem reduceSubspace_sup (A B : Submodule K E) + (hA : A ≤ ω.orthogonal S) (hB : B ≤ ω.orthogonal S) : + reduceSubspace ω S (A ⊔ B) = reduceSubspace ω S A ⊔ reduceSubspace ω S B := by + have hcomap : (A ⊔ B).comap (ω.orthogonal S).subtype = + A.comap (ω.orthogonal S).subtype ⊔ B.comap (ω.orthogonal S).subtype := by + ext x + constructor + · intro hx + obtain ⟨a,ha,b,hb,hab⟩ := Submodule.mem_sup.mp hx + exact Submodule.mem_sup.mpr + ⟨⟨a,hA ha⟩,ha,⟨b,hB hb⟩,hb,Subtype.ext hab⟩ + · intro hx + obtain ⟨a,ha,b,hb,rfl⟩ := Submodule.mem_sup.mp hx + exact Submodule.mem_sup.mpr ⟨a.val,ha,b.val,hb,rfl⟩ + unfold reduceSubspace + rw [hcomap,Submodule.map_sup] +end ReductionIntersections + +section PairSum +variable {K E : Type*} [Field K] [AddCommGroup E] [Module K E] +variable (ω : LinearMap.BilinForm K E) + +def triplePairSum (L M N : Submodule K E) : Submodule K E := + (L ⊓ M) ⊔ (L ⊓ N) ⊔ (M ⊓ N) + +theorem triplePairSum_isotropic (L M N : Submodule K E) + (hL : ω.orthogonal L = L) (hM : ω.orthogonal M = M) + (hN : ω.orthogonal N = N) : + triplePairSum L M N ≤ ω.orthogonal (triplePairSum L M N) := by + rw [triplePairSum,orthogonal_sup_eq,orthogonal_sup_eq] + refine sup_le (sup_le (le_inf (le_inf ?_ ?_) ?_) (le_inf (le_inf ?_ ?_) ?_)) + (le_inf (le_inf ?_ ?_) ?_) + all_goals intro x hx y hy + · exact hL.ge hx.1 y hy.1 + · exact hL.ge hx.1 y hy.1 + · exact hM.ge hx.2 y hy.1 + · exact hL.ge hx.1 y hy.1 + · exact hL.ge hx.1 y hy.1 + · exact hN.ge hx.2 y hy.2 + · exact hM.ge hx.1 y hy.2 + · exact hN.ge hx.2 y hy.2 + · exact hM.ge hx.1 y hy.1 + +theorem triple_pair_reduction_intersections [FiniteDimensional K E] + (L M N : Submodule K E) + (hL : ω.orthogonal L = L) (hM : ω.orthogonal M = M) + (hzero : (L ⊓ M) ⊓ N = ⊥) : + let S := L ⊓ M + let P := reduceSubspace ω S L + let Q := reduceSubspace ω S M + let R := reduceSubspace ω S N + P ⊓ Q = ⊥ ∧ + P ⊓ R = reduceSubspace ω S (L ⊓ N) ∧ + Q ⊓ R = reduceSubspace ω S (M ⊓ N) ∧ + finrank K ↥(P ⊓ R) = finrank K ↥(L ⊓ N) ∧ + finrank K ↥(Q ⊓ R) = finrank K ↥(M ⊓ N) ∧ + triplePairSum P Q R = reduceSubspace ω S (triplePairSum L M N) := by + dsimp only + have hLM := reduceSubspace_inf ω (L ⊓ M) L M inf_le_left + have hLN := reduceSubspace_inf ω (L ⊓ M) L N inf_le_left + have hMN := reduceSubspace_inf ω (L ⊓ M) M N inf_le_right + have hLP : L ≤ ω.orthogonal (L ⊓ M) := lagrangian_le_orthogonal ω _ L hL inf_le_left + have hMP : M ≤ ω.orthogonal (L ⊓ M) := lagrangian_le_orthogonal ω _ M hM inf_le_right + have hLNdis : Disjoint (L ⊓ N) (L ⊓ M) := by + apply disjoint_iff.mpr + apply (Submodule.eq_bot_iff _).mpr + intro x hx + exact hzero.le ⟨hx.2,hx.1.2⟩ + have hMNdis : Disjoint (M ⊓ N) (L ⊓ M) := by + apply disjoint_iff.mpr + apply (Submodule.eq_bot_iff _).mpr + intro x hx + exact hzero.le ⟨hx.2,hx.1.2⟩ + rw [←hLM,reduceSubspace_self,←hLN,←hMN] + refine ⟨rfl,rfl,rfl,?_,?_,?_⟩ + · exact reduceSubspace_finrank_of_disjoint ω _ _ (inf_le_left.trans hLP) hLNdis + · exact reduceSubspace_finrank_of_disjoint ω _ _ (inf_le_left.trans hMP) hMNdis + · rw [triplePairSum,triplePairSum, + reduceSubspace_sup ω _ _ _ (sup_le (inf_le_left.trans hLP) + (inf_le_left.trans hLP)) (inf_le_left.trans hMP), + reduceSubspace_sup ω _ _ _ (inf_le_left.trans hLP) (inf_le_left.trans hLP), + reduceSubspace_self,←hLM,←hLN,←hMN,reduceSubspace_self] +end PairSum +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section ClassificationPredicates +variable {K E F : Type*} [Field K] + [AddCommGroup E] [Module K E] [AddCommGroup F] [Module K F] + +def TripleIsometry (ω : LinearMap.BilinForm K E) (η : LinearMap.BilinForm K F) + (L M N : Submodule K E) (L' M' N' : Submodule K F) : Prop := + ∃ e : E ≃ₗ[K] F, (∀ x y, η (e x) (e y) = ω x y) ∧ + L.map e.toLinearMap = L' ∧ M.map e.toLinearMap = M' ∧ N.map e.toLinearMap = N' + +def TripleResidualIsometry (ω : LinearMap.BilinForm K E) (η : LinearMap.BilinForm K F) + (ha : ω.IsAlt) (hb : η.IsAlt) + (L M N : Submodule K E) (L' M' N' : Submodule K F) : Prop := + TripleIsometry (symplecticReductionForm ω (triplePairSum L M N) ha) + (symplecticReductionForm η (triplePairSum L' M' N') hb) + (reduceSubspace ω (triplePairSum L M N) L) + (reduceSubspace ω (triplePairSum L M N) M) + (reduceSubspace ω (triplePairSum L M N) N) + (reduceSubspace η (triplePairSum L' M' N') L') + (reduceSubspace η (triplePairSum L' M' N') M') + (reduceSubspace η (triplePairSum L' M' N') N') + +theorem TripleResidualIsometry.swap_right + {ω : LinearMap.BilinForm K E} {η : LinearMap.BilinForm K F} + {ha : ω.IsAlt} {hb : η.IsAlt} + {L M N : Submodule K E} {L' M' N' : Submodule K F} + (h : TripleResidualIsometry ω η ha hb L M N L' M' N') : + TripleResidualIsometry ω η ha hb L N M L' N' M' := by + have hs : triplePairSum L N M = triplePairSum L M N := by unfold triplePairSum; ac_rfl + have hs' : triplePairSum L' N' M' = triplePairSum L' M' N' := by unfold triplePairSum; ac_rfl + unfold TripleResidualIsometry at * + rw [hs,hs'] + obtain ⟨e,he,hL,hM,hN⟩ := h + exact ⟨e,he,hL,hN,hM⟩ + +theorem TripleResidualIsometry.rotate + {ω : LinearMap.BilinForm K E} {η : LinearMap.BilinForm K F} + {ha : ω.IsAlt} {hb : η.IsAlt} + {L M N : Submodule K E} {L' M' N' : Submodule K F} + (h : TripleResidualIsometry ω η ha hb L M N L' M' N') : + TripleResidualIsometry ω η ha hb M N L M' N' L' := by + have hs : triplePairSum M N L = triplePairSum L M N := by unfold triplePairSum; ac_rfl + have hs' : triplePairSum M' N' L' = triplePairSum L' M' N' := by unfold triplePairSum; ac_rfl + unfold TripleResidualIsometry at * + rw [hs,hs'] + obtain ⟨e,he,hL,hM,hN⟩ := h + exact ⟨e,he,hM,hN,hL⟩ +end ClassificationPredicates + +section ResidualClassificationStep +variable {K E F : Type*} [Field K] + [AddCommGroup E] [Module K E] [AddCommGroup F] [Module K F] + [FiniteDimensional K E] [FiniteDimensional K F] + +theorem triple_residual_isometry_reduce_pair + (ω : LinearMap.BilinForm K E) (η : LinearMap.BilinForm K F) + (ha : ω.IsAlt) (hb : η.IsAlt) + (L M N : Submodule K E) (L' M' N' : Submodule K F) + (hL : ω.orthogonal L = L) (hM : ω.orthogonal M = M) (hN : ω.orthogonal N = N) + (hL' : η.orthogonal L' = L') (hM' : η.orthogonal M' = M') (hN' : η.orthogonal N' = N') + (hzero : (L ⊓ M) ⊓ N = ⊥) (hzero' : (L' ⊓ M') ⊓ N' = ⊥) + (h : TripleResidualIsometry ω η ha hb L M N L' M' N') : + TripleResidualIsometry (symplecticReductionForm ω (L ⊓ M) ha) + (symplecticReductionForm η (L' ⊓ M') hb) + (symplecticReductionForm_alt ω (L ⊓ M) ha) + (symplecticReductionForm_alt η (L' ⊓ M') hb) + (reduceSubspace ω (L ⊓ M) L) (reduceSubspace ω (L ⊓ M) M) + (reduceSubspace ω (L ⊓ M) N) (reduceSubspace η (L' ⊓ M') L') + (reduceSubspace η (L' ⊓ M') M') (reduceSubspace η (L' ⊓ M') N') := by + have hs := (triple_pair_reduction_intersections ω L M N hL hM hzero).2.2.2.2.2 + have hs' := (triple_pair_reduction_intersections η L' M' N' hL' hM' hzero').2.2.2.2.2 + + unfold TripleResidualIsometry + rw [hs,hs'] + obtain ⟨u,hu,huA⟩ := exists_reduction_in_stages ω ha (L ⊓ M) (triplePairSum L M N) + (le_sup_left.trans le_sup_left) (triplePairSum_isotropic ω L M N hL hM hN) + obtain ⟨v,hv,hvA⟩ := exists_reduction_in_stages η hb (L' ⊓ M') (triplePairSum L' M' N') + (le_sup_left.trans le_sup_left) (triplePairSum_isotropic η L' M' N' hL' hM' hN') + obtain ⟨r,hr,hrL,hrM,hrN⟩ := h + let e := u.symm.trans (r.trans v) + refine ⟨e,?_,?_,?_,?_⟩ + · intro x y + change symplecticReductionForm (symplecticReductionForm η (L' ⊓ M') hb) + (reduceSubspace η (L' ⊓ M') (triplePairSum L' M' N')) + (symplecticReductionForm_alt η (L' ⊓ M') hb) + (v (r (u.symm x))) (v (r (u.symm y))) = _ + rw [hv,hr,←hu,u.apply_symm_apply,u.apply_symm_apply] + · rw [←huA L,←hvA L',map_conjugate_equiv,hrL] + · rw [←huA M,←hvA M',map_conjugate_equiv,hrM] + · rw [←huA N,←hvA N',map_conjugate_equiv,hrN] + +/-- When the pair intersections vanish, the final quotient already carries +all of the ambient ordered triple. -/ +theorem triple_isometry_of_zero_pairs + (ω : LinearMap.BilinForm K E) (η : LinearMap.BilinForm K F) + (ha : ω.IsAlt) (hb : η.IsAlt) + (L M N : Submodule K E) (L' M' N' : Submodule K F) + (hL : ω.orthogonal L = L) (hM : ω.orthogonal M = M) (hN : ω.orthogonal N = N) + (hL' : η.orthogonal L' = L') (hM' : η.orthogonal M' = M') (hN' : η.orthogonal N' = N') + (hLM : L ⊓ M = ⊥) (hLN : L ⊓ N = ⊥) (hMN : M ⊓ N = ⊥) + (hLM' : L' ⊓ M' = ⊥) (hLN' : L' ⊓ N' = ⊥) (hMN' : M' ⊓ N' = ⊥) + (h : TripleResidualIsometry ω η ha hb L M N L' M' N') : + TripleIsometry ω η L M N L' M' N' := by + have hs : triplePairSum L M N = L ⊓ M := by simp [triplePairSum,hLM,hLN,hMN] + have hs' : triplePairSum L' M' N' = L' ⊓ M' := by simp [triplePairSum,hLM',hLN',hMN'] + unfold TripleResidualIsometry at h + rw [hs,hs'] at h + obtain ⟨r,hr,hrL,hrM,hrN⟩ := h + exact triple_one_block_lift ω η ha hb L M N L' M' N' hL hM hN hL' hM' hN' + (by rw [hLM,bot_inf_eq]) (by rw [hLM',bot_inf_eq]) (by rw [hLM,hLM']; simp) + r hr hrL hrM hrN +end ResidualClassificationStep +end SidorenkoCounterexample + +namespace SidorenkoCounterexample +open Module +section FullClassification +variable {K E F : Type*} [Field K] + [AddCommGroup E] [Module K E] [AddCommGroup F] [Module K F] + [FiniteDimensional K E] [FiniteDimensional K F] + +omit [FiniteDimensional K E] in +@[simp] theorem reduceSubspace_bot (ω : LinearMap.BilinForm K E) (S : Submodule K E) : + reduceSubspace ω S ⊥ = ⊥ := by + unfold reduceSubspace + simp + +theorem triple_isometry_of_two_zero_pairs + (ω : LinearMap.BilinForm K E) (η : LinearMap.BilinForm K F) + (ha : ω.IsAlt) (hb : η.IsAlt) (hω : ω.Nondegenerate) (hη : η.Nondegenerate) + (L M N : Submodule K E) (L' M' N' : Submodule K F) + (hL : ω.orthogonal L = L) (hM : ω.orthogonal M = M) (hN : ω.orthogonal N = N) + (hL' : η.orthogonal L' = L') (hM' : η.orthogonal M' = M') (hN' : η.orthogonal N' = N') + (hLM : L ⊓ M = ⊥) (hLN : L ⊓ N = ⊥) + (hLM' : L' ⊓ M' = ⊥) (hLN' : L' ⊓ N' = ⊥) + (hdim : finrank K ↥(M ⊓ N) = finrank K ↥(M' ⊓ N')) + (h : TripleResidualIsometry ω η ha hb L M N L' M' N') : + TripleIsometry ω η L M N L' M' N' := by + have hz : (M ⊓ N) ⊓ L = ⊥ := by + calc + _ = (L ⊓ M) ⊓ N := by ac_rfl + _ = ⊥ := by rw [hLM,bot_inf_eq] + have hz' : (M' ⊓ N') ⊓ L' = ⊥ := by + calc + _ = (L' ⊓ M') ⊓ N' := by ac_rfl + _ = ⊥ := by rw [hLM',bot_inf_eq] + have hS : M ⊓ N ≤ ω.orthogonal (M ⊓ N) := by + intro x hx y hy + exact hM.ge hx.1 y hy.1 + have hS' : M' ⊓ N' ≤ η.orthogonal (M' ⊓ N') := by + intro x hx y hy + exact hM'.ge hx.1 y hy.1 + let α := symplecticReductionForm ω (M ⊓ N) ha + let β := symplecticReductionForm η (M' ⊓ N') hb + have ha' := symplecticReductionForm_alt ω (M ⊓ N) ha + have hb' := symplecticReductionForm_alt η (M' ⊓ N') hb + have hred := general_lagrangian_reduction ω (M ⊓ N) ha hω hS + have hred' := general_lagrangian_reduction η (M' ⊓ N') hb hη hS' + obtain ⟨hpq,hpr,hqr,_hd1,_hd2,_hs⟩ := + triple_pair_reduction_intersections ω M N L hM hN hz + obtain ⟨hpq',hpr',hqr',_hd1',_hd2',_hs'⟩ := + triple_pair_reduction_intersections η M' N' L' hM' hN' hz' + have hh := triple_residual_isometry_reduce_pair ω η ha hb M N L M' N' L' + hM hN hL hM' hN' hL' hz hz' h.rotate + obtain ⟨r,hr,hrM,hrN,hrL⟩ := triple_isometry_of_zero_pairs α β ha' hb' + _ _ _ _ _ _ (hred M hM) (hred N hN) (hred L hL) + (hred' M' hM') (hred' N' hN') (hred' L' hL') hpq + (by rw [hpr,inf_comm M L,hLM,reduceSubspace_bot]) + (by rw [hqr,inf_comm N L,hLN,reduceSubspace_bot]) hpq' + (by rw [hpr',inf_comm M' L',hLM',reduceSubspace_bot]) + (by rw [hqr',inf_comm N' L',hLN',reduceSubspace_bot]) hh + obtain ⟨e,he,heM,heN,heL⟩ := triple_one_block_lift ω η ha hb M N L M' N' L' + hM hN hL hM' hN' hL' hz hz' hdim r hr hrM hrN hrL + exact ⟨e,he,heL,heM,heN⟩ + +theorem triple_isometry_of_one_zero_pair + (ω : LinearMap.BilinForm K E) (η : LinearMap.BilinForm K F) + (ha : ω.IsAlt) (hb : η.IsAlt) (hω : ω.Nondegenerate) (hη : η.Nondegenerate) + (L M N : Submodule K E) (L' M' N' : Submodule K F) + (hL : ω.orthogonal L = L) (hM : ω.orthogonal M = M) (hN : ω.orthogonal N = N) + (hL' : η.orthogonal L' = L') (hM' : η.orthogonal M' = M') (hN' : η.orthogonal N' = N') + (hLM : L ⊓ M = ⊥) (hLM' : L' ⊓ M' = ⊥) + (hdimLN : finrank K ↥(L ⊓ N) = finrank K ↥(L' ⊓ N')) + (hdimMN : finrank K ↥(M ⊓ N) = finrank K ↥(M' ⊓ N')) + (h : TripleResidualIsometry ω η ha hb L M N L' M' N') : + TripleIsometry ω η L M N L' M' N' := by + have hz : (L ⊓ N) ⊓ M = ⊥ := by + calc + _ = (L ⊓ M) ⊓ N := by ac_rfl + _ = ⊥ := by rw [hLM,bot_inf_eq] + have hz' : (L' ⊓ N') ⊓ M' = ⊥ := by + calc + _ = (L' ⊓ M') ⊓ N' := by ac_rfl + _ = ⊥ := by rw [hLM',bot_inf_eq] + have hS : L ⊓ N ≤ ω.orthogonal (L ⊓ N) := by + intro x hx y hy + exact hL.ge hx.1 y hy.1 + have hS' : L' ⊓ N' ≤ η.orthogonal (L' ⊓ N') := by + intro x hx y hy + exact hL'.ge hx.1 y hy.1 + let α := symplecticReductionForm ω (L ⊓ N) ha + let β := symplecticReductionForm η (L' ⊓ N') hb + have ha' := symplecticReductionForm_alt ω (L ⊓ N) ha + have hb' := symplecticReductionForm_alt η (L' ⊓ N') hb + have hω' := symplecticReductionForm_nondegenerate ω (L ⊓ N) ha hω + have hη' := symplecticReductionForm_nondegenerate η (L' ⊓ N') hb hη + have hred := general_lagrangian_reduction ω (L ⊓ N) ha hω hS + have hred' := general_lagrangian_reduction η (L' ⊓ N') hb hη hS' + obtain ⟨hpq,hpr,_hqr,_hd1,hd2,_hs⟩ := + triple_pair_reduction_intersections ω L N M hL hN hz + obtain ⟨hpq',hpr',_hqr',_hd1',hd2',_hs'⟩ := + triple_pair_reduction_intersections η L' N' M' hL' hN' hz' + have hh := triple_residual_isometry_reduce_pair ω η ha hb L N M L' N' M' + hL hN hM hL' hN' hM' hz hz' h.swap_right + obtain ⟨r,hr,hrL,hrN,hrM⟩ := triple_isometry_of_two_zero_pairs α β ha' hb' hω' hη' + _ _ _ _ _ _ (hred L hL) (hred N hN) (hred M hM) + (hred' L' hL') (hred' N' hN') (hred' M' hM') hpq + (by rw [hpr,hLM,reduceSubspace_bot]) hpq' + (by rw [hpr',hLM',reduceSubspace_bot]) + (by rw [hd2,hd2',inf_comm N M,inf_comm N' M']; exact hdimMN) hh + obtain ⟨e,he,heL,heN,heM⟩ := triple_one_block_lift ω η ha hb L N M L' N' M' + hL hN hM hL' hN' hM' hz hz' hdimLN r hr hrL hrN hrM + exact ⟨e,he,heL,heM,heN⟩ + + + + +theorem triple_common_zero_classification + (ω : LinearMap.BilinForm K E) (η : LinearMap.BilinForm K F) + (ha : ω.IsAlt) (hb : η.IsAlt) (hω : ω.Nondegenerate) (hη : η.Nondegenerate) + (L M N : Submodule K E) (L' M' N' : Submodule K F) + (hL : ω.orthogonal L = L) (hM : ω.orthogonal M = M) (hN : ω.orthogonal N = N) + (hL' : η.orthogonal L' = L') (hM' : η.orthogonal M' = M') (hN' : η.orthogonal N' = N') + (hzero : (L ⊓ M) ⊓ N = ⊥) (hzero' : (L' ⊓ M') ⊓ N' = ⊥) + (hdimLM : finrank K ↥(L ⊓ M) = finrank K ↥(L' ⊓ M')) + (hdimLN : finrank K ↥(L ⊓ N) = finrank K ↥(L' ⊓ N')) + (hdimMN : finrank K ↥(M ⊓ N) = finrank K ↥(M' ⊓ N')) + (h : TripleResidualIsometry ω η ha hb L M N L' M' N') : + TripleIsometry ω η L M N L' M' N' := by + have hS : L ⊓ M ≤ ω.orthogonal (L ⊓ M) := by + intro x hx y hy + exact hL.ge hx.1 y hy.1 + have hS' : L' ⊓ M' ≤ η.orthogonal (L' ⊓ M') := by + intro x hx y hy + exact hL'.ge hx.1 y hy.1 + let α := symplecticReductionForm ω (L ⊓ M) ha + let β := symplecticReductionForm η (L' ⊓ M') hb + have ha' := symplecticReductionForm_alt ω (L ⊓ M) ha + have hb' := symplecticReductionForm_alt η (L' ⊓ M') hb + have hω' := symplecticReductionForm_nondegenerate ω (L ⊓ M) ha hω + have hη' := symplecticReductionForm_nondegenerate η (L' ⊓ M') hb hη + have hred := general_lagrangian_reduction ω (L ⊓ M) ha hω hS + have hred' := general_lagrangian_reduction η (L' ⊓ M') hb hη hS' + obtain ⟨hpq,_hpr,_hqr,hd1,hd2,_hs⟩ := + triple_pair_reduction_intersections ω L M N hL hM hzero + obtain ⟨hpq',_hpr',_hqr',hd1',hd2',_hs'⟩ := + triple_pair_reduction_intersections η L' M' N' hL' hM' hzero' + have hh := triple_residual_isometry_reduce_pair ω η ha hb L M N L' M' N' + hL hM hN hL' hM' hN' hzero hzero' h + obtain ⟨r,hr,hrL,hrM,hrN⟩ := triple_isometry_of_one_zero_pair α β ha' hb' hω' hη' + _ _ _ _ _ _ (hred L hL) (hred M hM) (hred N hN) + (hred' L' hL') (hred' M' hM') (hred' N' hN') hpq hpq' + (by rw [hd1,hd1']; exact hdimLN) (by rw [hd2,hd2']; exact hdimMN) hh + exact triple_one_block_lift ω η ha hb L M N L' M' N' hL hM hN hL' hM' hN' + hzero hzero' hdimLM r hr hrL hrM hrN +end FullClassification +end SidorenkoCounterexample + +end OAI diff --git a/lean/OAI/Combinatorics/Sidorenko/Types.lean b/lean/OAI/Combinatorics/Sidorenko/Types.lean new file mode 100644 index 0000000000000000000000000000000000000000..10bab57f4adefc9edd8a3e95fa6759c71feb314f --- /dev/null +++ b/lean/OAI/Combinatorics/Sidorenko/Types.lean @@ -0,0 +1,390 @@ +import OAI.Combinatorics.Sidorenko.Coefficients + +namespace OAI + + +section + +namespace SidorenkoCounterexample +open Classical Filter +open scoped BigOperators +section MatrixActivation +variable {F K : Type*} [Field F] [Fintype F] [DecidableEq F] [Fintype K] [DecidableEq K] + +noncomputable def sampleMatrixKernel (r : ℕ) (z : Activation K) + (x y : K → SymMatrix F (2*r)) : ℝ := + ∏ κ∈z.1,rankKernel F (2*r) r (if z.2 κ then 1 else -1) (x κ-y κ) +noncomputable def activationMatrixKernel (r : ℕ) (p : FiniteLaw (Activation K)) + (x y : K → SymMatrix F (2*r)) : ℝ := p.mean (fun z => sampleMatrixKernel r z x y) +noncomputable def matrixSampleProduct (r : ℕ) (z : ActCorner → Activation K) + (x : Fin 13 → K → SymMatrix F (2*r)) (y : Fin 22 → K → SymMatrix F (2*r)) : ℝ := + ∏ k,sampleMatrixKernel r (z k) (x (cornerPoint k)) (y k.1) +noncomputable def conditionalMatrixMoment (r : ℕ) (p : ActCorner → FiniteLaw (Activation K)) : ℝ := + uniformMean (fun xy : (Fin 13 → K → SymMatrix F (2*r)) × (Fin 22 → K → SymMatrix F (2*r)) => + ∏ k,activationMatrixKernel r (p k) (xy.1 (cornerPoint k)) (xy.2 k.1)) + +lemma matrixSampleProduct_coordinates (r : ℕ) (z : ActCorner → Activation K) + (x : Fin 13 → K → SymMatrix F (2*r)) (y : Fin 22 → K → SymMatrix F (2*r)) : + matrixSampleProduct r z x y=∏ κ,∏ j,∏ k∈coordinateActive z κ j, + rankKernel F (2*r) r (coordinateSigns z κ j k) (x (faceVertex j k) κ-y j κ) := by + unfold matrixSampleProduct sampleMatrixKernel + have he (k : ActCorner) : + (∏ κ∈(z k).1,rankKernel F (2*r) r (if (z k).2 κ then 1 else -1) (x (cornerPoint k) κ-y k.1 κ))= + ∏ κ,if κ∈(z k).1 then rankKernel F (2*r) r (if (z k).2 κ then 1 else -1) (x (cornerPoint k) κ-y k.1 κ) else 1 := by + simp only [Finset.prod_ite_mem,Finset.univ_inter] + simp_rw [he] + rw [Finset.prod_comm] + apply Finset.prod_congr rfl; intro κ _ + rw [Fintype.prod_prod_type] + apply Finset.prod_congr rfl; intro j _ + rw [coordinateActive,Finset.prod_filter] + rfl + +lemma coordinateMatrixIntegral (r : ℕ) (T : Fin 22 → Finset (Fin 3)) (ξ : Fin 22 → Fin 3 → ℤ) : + uniformMean (fun xy : (Fin 13 → SymMatrix F (2*r)) × (Fin 22 → SymMatrix F (2*r)) => + ∏ j,∏ k∈T j,rankKernel F (2*r) r (ξ j k) (xy.1 (faceVertex j k)-xy.2 j))= + uniformMean (configurationProduct (K := F) r T ξ) := by + rw [uniformMean_prod] + apply uniformMean_congr; intro X + rw [uniformMean_pi_product (fun j Y => ∏ k∈T j,rankKernel F (2*r) r (ξ j k) (X (faceVertex j k)-Y))] + rfl + +lemma matrixSampleProduct_mean (r : ℕ) (z : ActCorner → Activation K) : + uniformMean (fun xy : (Fin 13 → K → SymMatrix F (2*r)) × (Fin 22 → K → SymMatrix F (2*r)) => + matrixSampleProduct r z xy.1 xy.2)= + ∏ κ,uniformMean (configurationProduct (K := F) r (coordinateActive z κ) (coordinateSigns z κ)) := by + simp_rw [matrixSampleProduct_coordinates] + rw [uniformMean_coordinate_factor (fun κ X Y => ∏ j,∏ k∈coordinateActive z κ j, + rankKernel F (2*r) r (coordinateSigns z κ j k) (X (faceVertex j k)-Y j))] + simp_rw [coordinateMatrixIntegral] + +lemma conditionalMatrixMoment_law (r : ℕ) (p : ActCorner → FiniteLaw (Activation K)) : + conditionalMatrixMoment (F := F) r p=(FiniteLaw.independent p).mean (fun z => + ∏ κ,uniformMean (configurationProduct (K := F) r (coordinateActive z κ) (coordinateSigns z κ))) := by + unfold conditionalMatrixMoment activationMatrixKernel + simp_rw [←FiniteLaw.independent_mean_product] + rw [uniformMean_law_swap] + apply FiniteLaw.mean_congr; intro z + exact matrixSampleProduct_mean r z + +omit [Fintype K] [DecidableEq K] in +lemma sampleMatrixKernel_nonneg (r : ℕ) (z : Activation K) (x y : K → SymMatrix F (2*r)) : + 0≤ sampleMatrixKernel r z x y := Finset.prod_nonneg (fun _ _ => rankKernel_nonneg ..) +lemma activationMatrixKernel_nonneg (r : ℕ) (p : FiniteLaw (Activation K)) (x y : K → SymMatrix F (2*r)) : + 0≤activationMatrixKernel r p x y := p.mean_nonneg (fun z => sampleMatrixKernel_nonneg r z x y) +end MatrixActivation + +lemma configuration_even_rank_limit (r : ℕ) (hl : singularTailThreshold≤2*(2*r)) + (T : Fin 22 → Finset (Fin 3)) (ξ : Fin 22 → Fin 3 → ℤ) + (hξ : ∀ j k,ξ j k=1 ∨ ξ j k= -1) : Tendsto + (fun q : OddPrime => uniformMean (configurationProduct (K := ZMod q.val) (2*r) T ξ)) + primeInfinity (nhds (uniformMean (boolConfiguration 1 T ξ))) := by + have hch (q : OddPrime) : (quadraticChar (ZMod q.val) ((-1:ZMod q.val)^(2*r)):ℝ)=1 := by + rw [Even.neg_one_pow (even_two_mul r)]; simp + have h₁ := configuration_bool_tendsto (2*r) T ξ hξ hl + have h₂ := boolTestError_tendsto (2*r) (by have := singularTailThreshold_large; omega) T ξ 1 + simp_rw [hch] at h₁ + have h := (h₁.add h₂).add_const (uniformMean (boolConfiguration 1 T ξ)) + simp only [zero_add,add_zero] at h + convert h using 1 + funext q + unfold boolTestError + ring + +lemma conditionalMatrixMoment_tendsto {K : Type*} [Fintype K] [DecidableEq K] + (r : ℕ) (hl : singularTailThreshold≤2*(2*r)) (p : ActCorner → FiniteLaw (Activation K)) + (hp : ∀ k α,α≠∅ → (p k).mean (activationPhi α)=0) : Tendsto + (fun q : OddPrime => conditionalMatrixMoment (F := ZMod q.val) (2*r) p) primeInfinity + (nhds (1+activeCoefficient (fun k => activationMoment (p k)))) := by + have h (z : ActCorner → Activation K) := tendsto_finsetProd Finset.univ (fun κ _ => + configuration_even_rank_limit r hl (coordinateActive z κ) (coordinateSigns z κ) (coordinateSigns_good z κ)) + have ht := FiniteLaw.mean_tendsto (FiniteLaw.independent p) _ _ h + simp only [coordinateModels_product,expandedModel_mean p hp] at ht + simpa only [conditionalMatrixMoment_law] using ht +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Classical +open scoped BigOperators +section Types +variable {K : Type*} [Fintype K] [DecidableEq K] +noncomputable def inactiveLaw : FiniteLaw (Activation K) := FiniteLaw.dirac (∅,fun _ => false) +omit [Fintype K] in +lemma inactivePhi (α : Finset K) : activationPhi α (∅,fun _ => false)=if α=∅ then 1 else 0 := by + by_cases he : α=∅ + · subst α; simp + · simp [activationPhi,Finset.subset_empty,he] +lemma inactiveLaw_zero (α : Finset K) (hα : α≠∅) : inactiveLaw.mean (activationPhi α)=0 := by + simp only [inactiveLaw,FiniteLaw.mean_dirac,inactivePhi,ite_eq_right hα] +lemma inactiveLaw_moment (α β : Finset K) : activationMoment inactiveLaw α β=if α=∅ ∧ β=∅ then 1 else 0 := by + simp only [activationMoment,inactiveLaw,FiniteLaw.mean_dirac,inactivePhi] + by_cases hα : α=∅ <;> by_cases hβ : β=∅ <;> simp [hα,hβ] +noncomputable def thinnedLaw (p : FiniteLaw (Activation K)) (lam : ℝ) (hlam : 0≤lam) (hlam1 : lam≤1) := + FiniteLaw.mixture p inactiveLaw lam hlam hlam1 +lemma thinnedLaw_zero (p : FiniteLaw (Activation K)) (hp : ∀ α,α≠∅ → p.mean (activationPhi α)=0) + (lam : ℝ) (hlam : 0≤lam) (hlam1 : lam≤1) (α : Finset K) (hα : α≠∅) : + (thinnedLaw p lam hlam hlam1).mean (activationPhi α)=0 := by + rw [thinnedLaw,FiniteLaw.mean_mixture,hp α hα,inactiveLaw_zero α hα]; ring +lemma thinnedLaw_active (p : FiniteLaw (Activation K)) (lam : ℝ) (hlam : 0≤lam) (hlam1 : lam≤1) + (α β : Finset K) (hα : α≠∅) : + activationMoment (thinnedLaw p lam hlam hlam1) α β=lam*activationMoment p α β := by + unfold activationMoment thinnedLaw + rw [FiniteLaw.mean_mixture] + have hz : inactiveLaw.mean (fun z : Activation K => activationPhi α z*activationPhi β z)=0 := by + change activationMoment inactiveLaw α β=0 + simp only [inactiveLaw_moment,hα,false_and,ite_false] + rw [hz]; ring +lemma activeCoefficient_scaling (p : ActCorner → FiniteLaw (Activation K)) (lam : ActCorner → ℝ) + (hlam : ∀ k,0≤lam k) (hlam1 : ∀ k,lam k≤1) : + activeCoefficient (fun k => activationMoment (thinnedLaw (p k) (lam k) (hlam k) (hlam1 k)))= + (∏ k,lam k)*activeCoefficient (fun k => activationMoment (p k)) := by + unfold activeCoefficient + rw [Finset.mul_sum] + apply Finset.sum_congr rfl; intro α hα + have ha := (mem_nonemptyLabels α).mp hα + unfold labelProduct + simp_rw [thinnedLaw_active _ _ _ _ _ _ (ha _),Finset.prod_mul_distrib] +lemma activeCoefficient_inactive (p : ActCorner → FiniteLaw (Activation K)) (k : ActCorner) + (hk : p k=inactiveLaw) : activeCoefficient (fun k => activationMoment (p k))=0 := by + unfold activeCoefficient + apply Finset.sum_eq_zero; intro α hα + have ha := (mem_nonemptyLabels α).mp hα + unfold labelProduct + apply Finset.prod_eq_zero (Finset.mem_univ k) + dsimp only + rw [hk,inactiveLaw_moment] + simp only [ha,false_and,ite_false] +end Types +noncomputable def basePairLaw (a : Fin 13) (b : Fin 22) : FiniteLaw (Activation ActCorner) := + if a=faceVertex b 0 then cornerLaw (b,0) else + if a=faceVertex b 1 then cornerLaw (b,1) else + if a=faceVertex b 2 then cornerLaw (b,2) else inactiveLaw +lemma basePairLaw_corner (k : ActCorner) : basePairLaw (cornerPoint k) k.1=cornerLaw k := by + obtain ⟨j,k⟩ := k + have hinj := faceVertex_injective j + have h01 : faceVertex j 1≠faceVertex j 0 := fun h => (by decide : (1:Fin 3)≠0) (hinj h) + have h20 : faceVertex j 2≠faceVertex j 0 := fun h => (by decide : (2:Fin 3)≠0) (hinj h) + have h21 : faceVertex j 2≠faceVertex j 1 := fun h => (by decide : (2:Fin 3)≠1) (hinj h) + fin_cases k <;> simp [basePairLaw,cornerPoint,h01,h20,h21] +lemma basePairLaw_zero (a : Fin 13) (b : Fin 22) (α : Finset ActCorner) (hα : α≠∅) : + (basePairLaw a b).mean (activationPhi α)=0 := by + unfold basePairLaw; split + · exact cornerLaw_zero _ α hα + · split + · exact cornerLaw_zero _ α hα + · split + · exact cornerLaw_zero _ α hα + · exact inactiveLaw_zero α hα +lemma basePairLaw_identity : activeCoefficient (fun k => activationMoment (basePairLaw (cornerPoint k) k.1))= -(1/4:ℝ)^66 := by + simp only [basePairLaw_corner] + exact identity_activeCoefficient +lemma cornerPoint_surjective : Function.Surjective cornerPoint := by decide +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Classical +open scoped BigOperators +section Typed +variable {A B K : Type*} [Fintype A] [Fintype B] [Fintype K] [DecidableEq K] +noncomputable def typedCoefficient (p : A → B → FiniteLaw (Activation K)) (a : Fin 13 → A) (b : Fin 22 → B) : ℝ := + activeCoefficient (fun k => activationMoment (p (a (cornerPoint k)) (b k.1))) +noncomputable def typeMapLaw (π : FiniteLaw A) (ν : FiniteLaw B) : FiniteLaw ((Fin 13 → A) × (Fin 22 → B)) := + (FiniteLaw.independent (fun _ => π)).prod (FiniteLaw.independent (fun _ => ν)) +noncomputable def averagedCoefficient (π : FiniteLaw A) (ν : FiniteLaw B) (p : A → B → FiniteLaw (Activation K)) : ℝ := + (typeMapLaw π ν).mean (fun ab => typedCoefficient p ab.1 ab.2) +omit [Fintype A] [Fintype B] in +lemma typedCoefficient_thinned (p : A → B → FiniteLaw (Activation K)) (lam : A → B → ℝ) + (h0 : ∀ a b,0≤lam a b) (h1 : ∀ a b,lam a b≤1) (a : Fin 13 → A) (b : Fin 22 → B) : + typedCoefficient (fun a b => thinnedLaw (p a b) (lam a b) (h0 a b) (h1 a b)) a b= + (∏ k : ActCorner,lam (a (cornerPoint k)) (b k.1))*typedCoefficient p a b := + activeCoefficient_scaling _ _ _ _ +omit [Fintype A] [Fintype B] in +lemma typedCoefficient_inactive_left (p : A → B → FiniteLaw (Activation K)) (a : Fin 13 → A) + (b : Fin 22 → B) (i : Fin 13) (hi : ∀ j,p (a i) j=inactiveLaw) : typedCoefficient p a b=0 := by + obtain ⟨k,hk⟩ := cornerPoint_surjective i + exact activeCoefficient_inactive _ k (by rw [hk]; exact hi _) +omit [Fintype A] [Fintype B] in +lemma typedCoefficient_inactive_right (p : A → B → FiniteLaw (Activation K)) (a : Fin 13 → A) + (b : Fin 22 → B) (j : Fin 22) (hj : ∀ i,p i (b j)=inactiveLaw) : typedCoefficient p a b=0 := + activeCoefficient_inactive _ (j,0) (hj _) +end Typed +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Classical +open scoped BigOperators +section Kernel +variable {X Y A B : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] +noncomputable def kernelMean (π : FiniteLaw X) (ν : FiniteLaw Y) (W : X → Y → ℝ) : ℝ := + π.mean (fun x => ν.mean (W x)) +noncomputable def bipartiteMoment (π : FiniteLaw X) (ν : FiniteLaw Y) (W : X → Y → ℝ) : ℝ := + (FiniteLaw.independent (fun _ : Fin 13 => π)).mean (fun x => + (FiniteLaw.independent (fun _ : Fin 22 => ν)).mean (fun y => + ∏ k : ActCorner,W (x (cornerPoint k)) (y k.1))) +lemma bipartiteMoment_nonneg (π : FiniteLaw X) (ν : FiniteLaw Y) (W : X → Y → ℝ) + (hW : ∀ x y,0≤W x y) : 0≤bipartiteMoment π ν W := + FiniteLaw.mean_nonneg _ (fun _ => FiniteLaw.mean_nonneg _ (fun _ => Finset.prod_nonneg (fun _ _ => hW _ _))) +lemma bipartiteMoment_congr (π : FiniteLaw X) (ν : FiniteLaw Y) {W Z : X → Y → ℝ} + (h : ∀ x y,W x y=Z x y) : bipartiteMoment π ν W=bipartiteMoment π ν Z := by + unfold bipartiteMoment + apply FiniteLaw.mean_congr; intro x + apply FiniteLaw.mean_congr; intro y + exact Finset.prod_congr rfl fun k _ => h _ _ +lemma bipartiteMoment_typed (π : FiniteLaw A) (ν : FiniteLaw B) (σ : FiniteLaw X) (τ : FiniteLaw Y) + (W : A × X → B × Y → ℝ) : + bipartiteMoment (π.prod σ) (ν.prod τ) W= + (typeMapLaw π ν).mean (fun ab => (FiniteLaw.independent (fun _ : Fin 13 => σ)).mean (fun x => + (FiniteLaw.independent (fun _ : Fin 22 => τ)).mean (fun y => + ∏ k : ActCorner,W (ab.1 (cornerPoint k),x (cornerPoint k)) (ab.2 k.1,y k.1)))) := by + unfold bipartiteMoment typeMapLaw + rw [FiniteLaw.mean_prod,independent_mean_prod] + apply FiniteLaw.mean_congr; intro a + simp_rw [independent_mean_prod] + exact FiniteLaw.mean_swap _ _ _ +lemma kernelMean_prod (π : FiniteLaw A) (ν : FiniteLaw B) (σ : FiniteLaw X) (τ : FiniteLaw Y) + (W : A × X → B × Y → ℝ) : kernelMean (π.prod σ) (ν.prod τ) W= + π.mean (fun a => ν.mean (fun b => σ.mean (fun x => τ.mean (fun y => W (a,x) (b,y))))) := by + unfold kernelMean + rw [FiniteLaw.mean_prod] + apply FiniteLaw.mean_congr; intro a + simp_rw [FiniteLaw.mean_prod] + exact FiniteLaw.mean_swap _ _ _ +end Kernel +namespace FiniteLaw +lemma independent_uniform_mean {I A : Type*} [Fintype I] [DecidableEq I] [Fintype A] [Nonempty A] + (f : (I → A) → ℝ) : (independent (fun _ : I => (uniform : FiniteLaw A))).mean f=uniformMean f := by + unfold mean independent uniform uniformMean + simp only [Finset.prod_const,Finset.card_univ,Fintype.card_fun,Nat.cast_pow,←inv_pow,←Finset.mul_sum,div_eq_mul_inv] + ring +end FiniteLaw +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Classical +open scoped BigOperators +section MatrixMean +variable {F K : Type*} [Field F] [Fintype F] [DecidableEq F] [Fintype K] [DecidableEq K] +lemma uniformMean_sub_right {A : Type*} [AddGroup A] [Fintype A] (y : A) (f : A → ℝ) : + uniformMean (fun x => f (x-y))=uniformMean f := uniformMean_equiv (Equiv.subRight y) f +lemma sampleMatrixKernel_mean (r : ℕ) (hr : 0 sampleMatrixKernel r z x y)=1 := by + have he (x : K → SymMatrix F (2*r)) : sampleMatrixKernel r z x y= + ∏ κ,if κ∈z.1 then rankKernel F (2*r) r (if z.2 κ then 1 else -1) (x κ-y κ) else 1 := by + simp only [sampleMatrixKernel,Finset.prod_ite_mem,Finset.univ_inter] + simp only [he] + rw [uniformMean_pi_product (fun κ x => if κ∈z.1 then rankKernel F (2*r) r (if z.2 κ then 1 else -1) (x-y κ) else 1)] + have hm (κ : K) : uniformMean (fun x : SymMatrix F (2*r) => + if κ∈z.1 then rankKernel F (2*r) r (if z.2 κ then 1 else -1) (x-y κ) else 1)=1 := by + by_cases hκ : κ∈z.1 + · simp only [hκ,ite_true,uniformMean_sub_right] + exact uniformMean_rankKernel (2*r) r hr (by omega) hF (by split <;> simp) + · simp only [hκ,ite_false,uniformMean_const] + simp only [hm,Finset.prod_const_one] +lemma activationMatrixKernel_mean (r : ℕ) (hr : 0 activationMatrixKernel r p x y)=1 := by + unfold activationMatrixKernel + rw [uniformMean_law_swap] + simp only [sampleMatrixKernel_mean r hr hF,FiniteLaw.mean_const] +omit [Fintype K] [DecidableEq K] in +lemma sampleMatrixKernel_symm (r : ℕ) (z : Activation K) (x y : K → SymMatrix F (2*(2*r))) : + sampleMatrixKernel (2*r) z x y=sampleMatrixKernel (2*r) z y x := by + unfold sampleMatrixKernel + apply Finset.prod_congr rfl; intro κ _ + have hc : quadraticChar F ((-1:F)^(2*r))=1 := by rw [Even.neg_one_pow (even_two_mul r)]; simp + rw [←neg_sub (x κ) (y κ),rankKernel_neg,hc,one_mul] +lemma activationMatrixKernel_symm (r : ℕ) (p : FiniteLaw (Activation K)) (x y : K → SymMatrix F (2*(2*r))) : + activationMatrixKernel (2*r) p x y=activationMatrixKernel (2*r) p y x := by + apply FiniteLaw.mean_congr; intro z; exact sampleMatrixKernel_symm r z x y +end MatrixMean +end SidorenkoCounterexample + +end + + + +section + +namespace SidorenkoCounterexample +open Classical Filter +open scoped BigOperators +section TypedMatrix +variable {A B K F : Type*} [Fintype A] [Fintype B] [Fintype K] [DecidableEq K] + [Field F] [Fintype F] [DecidableEq F] +noncomputable def typedMatrixLaw (r : ℕ) (π : FiniteLaw A) : FiniteLaw (A × (K → SymMatrix F (2*r))) := + π.prod FiniteLaw.uniform +noncomputable def typedMatrixKernel (r : ℕ) (p : A → B → FiniteLaw (Activation K)) + (x : A × (K → SymMatrix F (2*r))) (y : B × (K → SymMatrix F (2*r))) : ℝ := + activationMatrixKernel r (p x.1 y.1) x.2 y.2 +omit [Fintype A] [Fintype B] in +lemma typedMatrixKernel_nonneg (r : ℕ) (p : A → B → FiniteLaw (Activation K)) + (x : A × (K → SymMatrix F (2*r))) (y : B × (K → SymMatrix F (2*r))) : + 0≤typedMatrixKernel r p x y := activationMatrixKernel_nonneg r _ _ _ +lemma typedMatrixKernel_moment (r : ℕ) (π : FiniteLaw A) (ν : FiniteLaw B) + (p : A → B → FiniteLaw (Activation K)) : + bipartiteMoment (typedMatrixLaw (F := F) (K := K) r π) (typedMatrixLaw r ν) (typedMatrixKernel r p)= + (typeMapLaw π ν).mean (fun ab => conditionalMatrixMoment (F := F) r (fun k => p (ab.1 (cornerPoint k)) (ab.2 k.1))) := by + rw [typedMatrixLaw,typedMatrixLaw,bipartiteMoment_typed] + apply FiniteLaw.mean_congr; intro ab + simp_rw [FiniteLaw.independent_uniform_mean] + rw [conditionalMatrixMoment,uniformMean_prod] + rfl +lemma typedMatrixKernel_mean (r : ℕ) (hr : 0 + FiniteLaw.uniform.mean (fun y => typedMatrixKernel r p (a,x) (b,y)))=1 := by + rw [FiniteLaw.mean_swap] + simp only [FiniteLaw.mean_uniform,typedMatrixKernel,activationMatrixKernel_mean r hr hF,uniformMean_const] + simp only [h,FiniteLaw.mean_const] +omit [Fintype A] [Fintype B] in +lemma typedMatrixKernel_transpose (r : ℕ) (p : A → B → FiniteLaw (Activation K)) + (x : A × (K → SymMatrix F (2*(2*r)))) (y : B × (K → SymMatrix F (2*(2*r)))) : + typedMatrixKernel (2*r) p x y=typedMatrixKernel (2*r) (fun b a => p a b) y x := + activationMatrixKernel_symm r _ _ _ +end TypedMatrix +lemma typedMatrixKernel_tendsto {A B K : Type*} [Fintype A] [Fintype B] [Fintype K] [DecidableEq K] + (r : ℕ) (hl : singularTailThreshold≤2*(2*r)) (π : FiniteLaw A) (ν : FiniteLaw B) + (p : A → B → FiniteLaw (Activation K)) + (hp : ∀ a b α,α≠∅ → (p a b).mean (activationPhi α)=0) : + Tendsto (fun q : OddPrime => bipartiteMoment + (typedMatrixLaw (F := ZMod q.val) (K := K) (2*r) π) (typedMatrixLaw (2*r) ν) (typedMatrixKernel (2*r) p)) + primeInfinity (nhds (1+averagedCoefficient π ν p)) := by + have ht := FiniteLaw.mean_tendsto (typeMapLaw π ν) + (fun q : OddPrime => fun ab => conditionalMatrixMoment (F := ZMod q.val) (2*r) (fun k => p (ab.1 (cornerPoint k)) (ab.2 k.1))) + (fun ab => 1+typedCoefficient p ab.1 ab.2) + (fun ab => conditionalMatrixMoment_tendsto r hl _ (fun k => hp _ _)) + simp only [FiniteLaw.mean_add,FiniteLaw.mean_const] at ht + simpa only [typedMatrixKernel_moment,averagedCoefficient] using ht +end SidorenkoCounterexample + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Basic.lean b/lean/OAI/Combinatorics/SnakyCertificate/Basic.lean new file mode 100644 index 0000000000000000000000000000000000000000..8491b8cb8128bfe49c18ff1eaddfc049828fdce3 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Basic.lean @@ -0,0 +1,55 @@ +import Mathlib + +namespace OAI + +namespace SnakyCertificate + +instance rotationModulus_neZero : NeZero 8 := @Nat.instNeZeroSucc 7 + +instance digitModulus_neZero : NeZero 10 := @Nat.instNeZeroSucc 9 + +abbrev Cell := ℤ × ℤ + +def origin : Cell := (0, 0) + +def snaky : Finset Cell := {(0, 0), (1, 0), (2, 0), (3, 0), (3, 1), (4, 1)} + +def orient (r : Fin 8) (p : Cell) : Cell := + match r.val with + | 0 => (p.1, p.2) + | 1 => (p.2, p.1) + | 2 => (p.1, -p.2) + | 3 => (-p.2, p.1) + | 4 => (-p.1, p.2) + | 5 => (p.2, -p.1) + | 6 => (-p.1, -p.2) + | _ => (-p.2, -p.1) + +def placement (r : Fin 8) (t p : Cell) : Cell := orient r p + t + +def basePoint (i : Fin 6) : Cell := ![(0,0),(1,0),(2,0),(3,0),(3,1),(4,1)] i + +def baseEnvelope (i : Fin 6) : Finset Cell := + snaky.image (placement 0 (-basePoint i)) + +def baseRequired (i : Fin 6) : Finset Cell := (baseEnvelope i).erase origin + +structure Term where + child : ℕ + rotation : Fin 8 + xDigit : Fin 10 + yDigit : Fin 10 + deriving DecidableEq, Repr + +def Term.shift (t : Term) : Cell := ((t.xDigit.val : ℤ) - 4, (t.yDigit.val : ℤ) - 4) + +structure Entry where + index : ℕ + terms : List Term + deriving DecidableEq, Repr + +def emptyEntry : Entry := ⟨0, []⟩ + +end SnakyCertificate + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Cache.lean b/lean/OAI/Combinatorics/SnakyCertificate/Cache.lean new file mode 100644 index 0000000000000000000000000000000000000000..64fa53470795b8dfcdbe7784c73204f3d7693d1b --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Cache.lean @@ -0,0 +1,98 @@ +import OAI.Combinatorics.SnakyCertificate.CacheData00 +import OAI.Combinatorics.SnakyCertificate.CacheData01 +import OAI.Combinatorics.SnakyCertificate.CacheData02 +import OAI.Combinatorics.SnakyCertificate.CacheData03 +import OAI.Combinatorics.SnakyCertificate.CacheData04 +import OAI.Combinatorics.SnakyCertificate.CacheData05 +import OAI.Combinatorics.SnakyCertificate.CacheData06 +import OAI.Combinatorics.SnakyCertificate.CacheData07 +import OAI.Combinatorics.SnakyCertificate.CacheData08 +import OAI.Combinatorics.SnakyCertificate.CacheData09 +import OAI.Combinatorics.SnakyCertificate.CacheData10 +import OAI.Combinatorics.SnakyCertificate.CacheData11 +import OAI.Combinatorics.SnakyCertificate.CacheData12 +import OAI.Combinatorics.SnakyCertificate.CacheData13 +import OAI.Combinatorics.SnakyCertificate.CacheData14 +import OAI.Combinatorics.SnakyCertificate.CacheData15 + +namespace OAI + +namespace SnakyCertificate.Check + +def cacheChunk_0 : Array ListRow := #[cache_0, cache_1, cache_2, cache_3, cache_4, cache_5, cache_6, cache_7, cache_8, cache_9, cache_10, cache_11, cache_12, cache_13, cache_14, cache_15, cache_16, cache_17, cache_18, cache_19] + +def cacheChunk_1 : Array ListRow := #[cache_20, cache_21, cache_22, cache_23, cache_24, cache_25, cache_26, cache_27, cache_28, cache_29, cache_30, cache_31, cache_32, cache_33, cache_34, cache_35, cache_36, cache_37, cache_38, cache_39] + +def cacheChunk_2 : Array ListRow := #[cache_40, cache_41, cache_42, cache_43, cache_44, cache_45, cache_46, cache_47, cache_48, cache_49, cache_50, cache_51, cache_52, cache_53, cache_54, cache_55, cache_56, cache_57, cache_58, cache_59] + +def cacheChunk_3 : Array ListRow := #[cache_60, cache_61, cache_62, cache_63, cache_64, cache_65, cache_66, cache_67, cache_68, cache_69, cache_70, cache_71, cache_72, cache_73, cache_74, cache_75, cache_76, cache_77, cache_78, cache_79] + +def cacheChunk_4 : Array ListRow := #[cache_80, cache_81, cache_82, cache_83, cache_84, cache_85, cache_86, cache_87, cache_88, cache_89, cache_90, cache_91, cache_92, cache_93, cache_94, cache_95, cache_96, cache_97, cache_98, cache_99] + +def cacheChunk_5 : Array ListRow := #[cache_100, cache_101, cache_102, cache_103, cache_104, cache_105, cache_106, cache_107, cache_108, cache_109, cache_110, cache_111, cache_112, cache_113, cache_114, cache_115, cache_116, cache_117, cache_118, cache_119] + +def cacheChunk_6 : Array ListRow := #[cache_120, cache_121, cache_122, cache_123, cache_124, cache_125, cache_126, cache_127, cache_128, cache_129, cache_130, cache_131, cache_132, cache_133, cache_134, cache_135, cache_136, cache_137, cache_138, cache_139] + +def cacheChunk_7 : Array ListRow := #[cache_140, cache_141, cache_142, cache_143, cache_144, cache_145, cache_146, cache_147, cache_148, cache_149, cache_150, cache_151, cache_152, cache_153, cache_154, cache_155, cache_156, cache_157, cache_158, cache_159] + +def cacheChunk_8 : Array ListRow := #[cache_160, cache_161, cache_162, cache_163, cache_164, cache_165, cache_166, cache_167, cache_168, cache_169, cache_170, cache_171, cache_172, cache_173, cache_174, cache_175, cache_176, cache_177, cache_178, cache_179] + +def cacheChunk_9 : Array ListRow := #[cache_180, cache_181, cache_182, cache_183, cache_184, cache_185, cache_186, cache_187, cache_188, cache_189, cache_190, cache_191, cache_192, cache_193, cache_194, cache_195, cache_196, cache_197, cache_198, cache_199] + +def cacheChunk_10 : Array ListRow := #[cache_200, cache_201, cache_202, cache_203, cache_204, cache_205, cache_206, cache_207, cache_208, cache_209, cache_210, cache_211, cache_212, cache_213, cache_214, cache_215, cache_216, cache_217, cache_218, cache_219] + +def cacheChunk_11 : Array ListRow := #[cache_220, cache_221, cache_222, cache_223, cache_224, cache_225, cache_226, cache_227, cache_228, cache_229, cache_230, cache_231, cache_232, cache_233, cache_234, cache_235, cache_236, cache_237, cache_238, cache_239] + +def cacheChunk_12 : Array ListRow := #[cache_240, cache_241, cache_242, cache_243, cache_244, cache_245, cache_246, cache_247, cache_248, cache_249, cache_250, cache_251, cache_252, cache_253, cache_254, cache_255, cache_256, cache_257, cache_258, cache_259] + +def cacheChunk_13 : Array ListRow := #[cache_260, cache_261, cache_262, cache_263, cache_264, cache_265, cache_266, cache_267, cache_268, cache_269, cache_270, cache_271, cache_272, cache_273, cache_274, cache_275, cache_276, cache_277, cache_278, cache_279] + +def cacheChunk_14 : Array ListRow := #[cache_280, cache_281, cache_282, cache_283, cache_284, cache_285, cache_286, cache_287, cache_288, cache_289, cache_290, cache_291, cache_292, cache_293, cache_294, cache_295, cache_296, cache_297, cache_298, cache_299] + +def cacheChunk_15 : Array ListRow := #[cache_300, cache_301, cache_302, cache_303, cache_304, cache_305, cache_306, cache_307, cache_308, cache_309, cache_310, cache_311, cache_312, cache_313, cache_314, cache_315, cache_316, cache_317, cache_318, cache_319] + +def cacheChunk_16 : Array ListRow := #[cache_320, cache_321, cache_322, cache_323, cache_324, cache_325, cache_326, cache_327, cache_328, cache_329, cache_330, cache_331, cache_332, cache_333, cache_334, cache_335, cache_336, cache_337, cache_338, cache_339] + +def cacheChunk_17 : Array ListRow := #[cache_340, cache_341, cache_342, cache_343, cache_344, cache_345, cache_346, cache_347, cache_348, cache_349, cache_350, cache_351, cache_352, cache_353, cache_354, cache_355, cache_356, cache_357, cache_358, cache_359] + +def cacheChunk_18 : Array ListRow := #[cache_360, cache_361, cache_362, cache_363, cache_364, cache_365, cache_366, cache_367, cache_368, cache_369, cache_370, cache_371, cache_372, cache_373, cache_374, cache_375, cache_376, cache_377, cache_378, cache_379] + +def cacheChunk_19 : Array ListRow := #[cache_380, cache_381, cache_382, cache_383, cache_384, cache_385, cache_386, cache_387, cache_388, cache_389, cache_390, cache_391, cache_392, cache_393, cache_394, cache_395, cache_396, cache_397, cache_398, cache_399] + +def cacheChunk_20 : Array ListRow := #[cache_400, cache_401, cache_402, cache_403, cache_404, cache_405, cache_406, cache_407, cache_408, cache_409, cache_410, cache_411, cache_412, cache_413, cache_414, cache_415, cache_416, cache_417, cache_418, cache_419] + +def cacheChunk_21 : Array ListRow := #[cache_420, cache_421, cache_422, cache_423, cache_424, cache_425, cache_426, cache_427, cache_428, cache_429, cache_430, cache_431, cache_432, cache_433, cache_434, cache_435, cache_436, cache_437, cache_438, cache_439] + +def cacheChunk_22 : Array ListRow := #[cache_440, cache_441, cache_442, cache_443, cache_444, cache_445, cache_446, cache_447, cache_448, cache_449, cache_450, cache_451, cache_452, cache_453, cache_454, cache_455, cache_456, cache_457, cache_458, cache_459] + +def cacheChunk_23 : Array ListRow := #[cache_460, cache_461, cache_462, cache_463, cache_464, cache_465, cache_466, cache_467, cache_468, cache_469, cache_470, cache_471, cache_472, cache_473, cache_474, cache_475, cache_476, cache_477, cache_478, cache_479] + +def cacheChunk_24 : Array ListRow := #[cache_480, cache_481, cache_482, cache_483, cache_484, cache_485, cache_486, cache_487, cache_488, cache_489, cache_490, cache_491, cache_492, cache_493, cache_494, cache_495, cache_496, cache_497, cache_498, cache_499] + +def cacheChunk_25 : Array ListRow := #[cache_500, cache_501, cache_502, cache_503, cache_504, cache_505, cache_506, cache_507, cache_508, cache_509, cache_510, cache_511, cache_512, cache_513, cache_514, cache_515, cache_516, cache_517, cache_518, cache_519] + +def cacheChunk_26 : Array ListRow := #[cache_520, cache_521, cache_522, cache_523, cache_524, cache_525, cache_526, cache_527, cache_528, cache_529, cache_530, cache_531, cache_532, cache_533, cache_534, cache_535, cache_536, cache_537, cache_538, cache_539] + +def cacheChunk_27 : Array ListRow := #[cache_540, cache_541, cache_542, cache_543, cache_544, cache_545, cache_546, cache_547, cache_548, cache_549, cache_550, cache_551, cache_552, cache_553, cache_554, cache_555, cache_556, cache_557, cache_558, cache_559] + +def cacheChunk_28 : Array ListRow := #[cache_560, cache_561, cache_562, cache_563, cache_564, cache_565, cache_566, cache_567, cache_568, cache_569, cache_570, cache_571, cache_572, cache_573, cache_574, cache_575, cache_576, cache_577, cache_578, cache_579] + +def cacheChunk_29 : Array ListRow := #[cache_580, cache_581, cache_582, cache_583, cache_584, cache_585, cache_586, cache_587, cache_588, cache_589, cache_590, cache_591, cache_592, cache_593, cache_594, cache_595, cache_596, cache_597, cache_598, cache_599] + +def cacheChunk_30 : Array ListRow := #[cache_600, cache_601, cache_602, cache_603, cache_604, cache_605, cache_606, cache_607, cache_608, cache_609, cache_610, cache_611, cache_612, cache_613, cache_614, cache_615] + +def cacheChunks : Array (Array ListRow) := #[cacheChunk_0, cacheChunk_1, cacheChunk_2, cacheChunk_3, cacheChunk_4, cacheChunk_5, cacheChunk_6, cacheChunk_7, cacheChunk_8, cacheChunk_9, cacheChunk_10, cacheChunk_11, cacheChunk_12, cacheChunk_13, cacheChunk_14, cacheChunk_15, cacheChunk_16, cacheChunk_17, cacheChunk_18, cacheChunk_19, cacheChunk_20, cacheChunk_21, cacheChunk_22, cacheChunk_23, cacheChunk_24, cacheChunk_25, cacheChunk_26, cacheChunk_27, cacheChunk_28, cacheChunk_29, cacheChunk_30] + +def emptyListRow : ListRow := ⟨[], [], 0⟩ + +def cached (i : ℕ) : ListRow := + ((cacheChunks[i / 20]?.getD #[])[i % 20]?).getD emptyListRow + +def CacheEquation (i : ℕ) : Prop := + if h : i < 6 then baseRow ⟨i, h⟩ = denote (cached i) else + forkRow ((entryAt i).terms.map fun t => placeRow t (denote (cached t.child))) = + denote (cached i) + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/CacheData00.lean b/lean/OAI/Combinatorics/SnakyCertificate/CacheData00.lean new file mode 100644 index 0000000000000000000000000000000000000000..576cf5959824edfd96e69e0b43d411cbbb430483 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/CacheData00.lean @@ -0,0 +1,409 @@ +import OAI.Combinatorics.SnakyCertificate.Lists + +namespace OAI + +namespace SnakyCertificate.Check + +def cache_0_A_part0 : List Cell := [(1, 0), (2, 0), (3, 0), (3, 1), (4, 1)] + +def cache_0_A : List Cell := cache_0_A_part0 + +def cache_0_H_part0 : List Cell := [(0, 0), (1, 0), (2, 0), (3, 0), (3, 1), (4, 1)] + +def cache_0_H : List Cell := cache_0_H_part0 + +def cache_0 : ListRow := ⟨cache_0_A, cache_0_H, 1⟩ + +def cache_1_A_part0 : List Cell := [(-1, 0), (1, 0), (2, 0), (2, 1), (3, 1)] + +def cache_1_A : List Cell := cache_1_A_part0 + +def cache_1_H_part0 : List Cell := [(-1, 0), (0, 0), (1, 0), (2, 0), (2, 1), (3, 1)] + +def cache_1_H : List Cell := cache_1_H_part0 + +def cache_1 : ListRow := ⟨cache_1_A, cache_1_H, 1⟩ + +def cache_2_A_part0 : List Cell := [(-2, 0), (-1, 0), (1, 0), (1, 1), (2, 1)] + +def cache_2_A : List Cell := cache_2_A_part0 + +def cache_2_H_part0 : List Cell := [(-2, 0), (-1, 0), (0, 0), (1, 0), (1, 1), (2, 1)] + +def cache_2_H : List Cell := cache_2_H_part0 + +def cache_2 : ListRow := ⟨cache_2_A, cache_2_H, 1⟩ + +def cache_3_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0), (0, 1), (1, 1)] + +def cache_3_A : List Cell := cache_3_A_part0 + +def cache_3_H_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0), (0, 0), (0, 1), (1, 1)] + +def cache_3_H : List Cell := cache_3_H_part0 + +def cache_3 : ListRow := ⟨cache_3_A, cache_3_H, 1⟩ + +def cache_4_A_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -1), (0, -1), (1, 0)] + +def cache_4_A : List Cell := cache_4_A_part0 + +def cache_4_H_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -1), (0, -1), (0, 0), (1, 0)] + +def cache_4_H : List Cell := cache_4_H_part0 + +def cache_4 : ListRow := ⟨cache_4_A, cache_4_H, 1⟩ + +def cache_5_A_part0 : List Cell := [(-4, -1), (-3, -1), (-2, -1), (-1, -1), (-1, 0)] + +def cache_5_A : List Cell := cache_5_A_part0 + +def cache_5_H_part0 : List Cell := [(-4, -1), (-3, -1), (-2, -1), (-1, -1), (-1, 0), (0, 0)] + +def cache_5_H : List Cell := cache_5_H_part0 + +def cache_5 : ListRow := ⟨cache_5_A, cache_5_H, 1⟩ + +def cache_6_A_part0 : List Cell := [(-4, -1), (-3, -1), (-2, -1), (-1, -1), (-1, 0)] + +def cache_6_A : List Cell := cache_6_A_part0 + +def cache_6_H_part0 : List Cell := [(-4, -1), (-3, -1), (-2, -1), (-1, -1), (-1, 0), (0, 0)] + +def cache_6_H : List Cell := cache_6_H_part0 + +def cache_6 : ListRow := ⟨cache_6_A, cache_6_H, 2⟩ + +def cache_7_A_part0 : List Cell := [(-4, -1), (-3, -1), (-2, -1), (-1, -1), (0, -1)] + +def cache_7_A : List Cell := cache_7_A_part0 + +def cache_7_H_part0 : List Cell := [(-4, -1), (-3, -1), (-2, -1), (-1, -1), (-1, 0), (0, -1), (0, 0), (1, 0)] + +def cache_7_H : List Cell := cache_7_H_part0 + +def cache_7 : ListRow := ⟨cache_7_A, cache_7_H, 3⟩ + +def cache_8_A_part0 : List Cell := [(0, -1), (1, -1), (1, 0), (2, -1), (3, -1)] + +def cache_8_A : List Cell := cache_8_A_part0 + +def cache_8_H_part0 : List Cell := [(-1, 0), (0, -1), (0, 0), (1, -1), (1, 0), (2, -1), (3, -1), (4, -1)] + +def cache_8_H : List Cell := cache_8_H_part0 + +def cache_8 : ListRow := ⟨cache_8_A, cache_8_H, 3⟩ + +def cache_9_A_part0 : List Cell := [(-3, 0), (-3, 1), (-2, 0), (-2, 1), (-1, 0)] + +def cache_9_A : List Cell := cache_9_A_part0 + +def cache_9_H_part0 : List Cell := [(-4, 1), (-3, 0), (-3, 1), (-2, 0), (-2, 1), (-1, 0), (0, 0), (1, 0)] + +def cache_9_H : List Cell := cache_9_H_part0 + +def cache_9 : ListRow := ⟨cache_9_A, cache_9_H, 3⟩ + +def cache_10_A_part0 : List Cell := [(-4, -1), (-3, -1), (-3, 0), (-1, -1), (-1, 0)] + +def cache_10_A : List Cell := cache_10_A_part0 + +def cache_10_H_part0 : List Cell := [(-4, -1), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, 0)] + +def cache_10_H : List Cell := cache_10_H_part0 + +def cache_10 : ListRow := ⟨cache_10_A, cache_10_H, 2⟩ + +def cache_11_A_part0 : List Cell := [(-1, -1), (-1, 0), (-1, 1), (1, 0), (2, 0)] + +def cache_11_A : List Cell := cache_11_A_part0 + +def cache_11_H_part0 : List Cell := [(-2, -1), (-2, 1), (-1, -1), (-1, 0), (-1, 1), (0, 0), (1, 0), (2, 0)] + +def cache_11_H : List Cell := cache_11_H_part0 + +def cache_11 : ListRow := ⟨cache_11_A, cache_11_H, 3⟩ + +def cache_12_A_part0 : List Cell := [(-3, -1), (-2, -1), (-2, 0), (-1, -1), (-1, 0)] + +def cache_12_A : List Cell := cache_12_A_part0 + +def cache_12_H_part0 : List Cell := [(-4, -1), (-3, -1), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, 0), (1, 0)] + +def cache_12_H : List Cell := cache_12_H_part0 + +def cache_12 : ListRow := ⟨cache_12_A, cache_12_H, 2⟩ + +def cache_13_A_part0 : List Cell := [(-3, -1), (-3, 0), (-3, 1), (-2, 0), (-1, 0)] + +def cache_13_A : List Cell := cache_13_A_part0 + +def cache_13_H_part0 : List Cell := [(-4, -1), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, 0), (-1, 0), (0, 0)] + +def cache_13_H : List Cell := cache_13_H_part0 + +def cache_13 : ListRow := ⟨cache_13_A, cache_13_H, 3⟩ + +def cache_14_A_part0 : List Cell := [(-4, -1), (-3, -1), (-2, -1), (-2, 0), (-1, 0)] + +def cache_14_A : List Cell := cache_14_A_part0 + +def cache_14_H_part0 : List Cell := [(-4, -1), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, 0), (0, 0), (1, 0)] + +def cache_14_H : List Cell := cache_14_H_part0 + +def cache_14 : ListRow := ⟨cache_14_A, cache_14_H, 2⟩ + +def cache_15_A_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -1), (-1, 0), (1, 0)] + +def cache_15_A : List Cell := cache_15_A_part0 + +def cache_15_H_part0 : List Cell := [(-3, -1), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, 0), (1, 0), (2, 0)] + +def cache_15_H : List Cell := cache_15_H_part0 + +def cache_15 : ListRow := ⟨cache_15_A, cache_15_H, 2⟩ + +def cache_16_A_part0 : List Cell := [(-2, -1), (-1, -1), (0, -1), (1, 0), (2, 0)] + +def cache_16_A : List Cell := cache_16_A_part0 + +def cache_16_H_part0 : List Cell := [(-2, -1), (-1, -1), (-1, 0), (0, -1), (0, 0), (1, 0), (2, 0), (3, 0)] + +def cache_16_H : List Cell := cache_16_H_part0 + +def cache_16 : ListRow := ⟨cache_16_A, cache_16_H, 2⟩ + +def cache_17_A_part0 : List Cell := [(-4, -1), (-3, -1), (-2, -1), (-2, 0), (-1, 0)] + +def cache_17_A : List Cell := cache_17_A_part0 + +def cache_17_H_part0 : List Cell := [(-4, -1), (-3, -1), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, 0), (1, 0)] + +def cache_17_H : List Cell := cache_17_H_part0 + +def cache_17 : ListRow := ⟨cache_17_A, cache_17_H, 2⟩ + +def cache_18_A_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -1), (-1, 0), (1, 0)] + +def cache_18_A : List Cell := cache_18_A_part0 + +def cache_18_H_part0 : List Cell := [(-3, -1), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, -1), (0, 0), (1, 0)] + +def cache_18_H : List Cell := cache_18_H_part0 + +def cache_18 : ListRow := ⟨cache_18_A, cache_18_H, 2⟩ + +def cache_19_A_part0 : List Cell := [(-2, 0), (-2, 1), (-1, 0), (1, 0), (1, 1)] + +def cache_19_A : List Cell := cache_19_A_part0 + +def cache_19_H_part0 : List Cell := [(-3, 1), (-2, 0), (-2, 1), (-1, 0), (0, 0), (1, 0), (1, 1), (2, 1)] + +def cache_19_H : List Cell := cache_19_H_part0 + +def cache_19 : ListRow := ⟨cache_19_A, cache_19_H, 3⟩ + +def cache_20_A_part0 : List Cell := [(-3, 0), (-3, 1), (-2, 0), (-1, 0), (0, 1)] + +def cache_20_A : List Cell := cache_20_A_part0 + +def cache_20_H_part0 : List Cell := [(-4, 1), (-3, 0), (-3, 1), (-2, 0), (-1, 0), (0, 0), (0, 1), (1, 1)] + +def cache_20_H : List Cell := cache_20_H_part0 + +def cache_20 : ListRow := ⟨cache_20_A, cache_20_H, 3⟩ + +def cache_21_A_part0 : List Cell := [(-3, -1), (-2, 0), (-1, 0), (1, 0), (1, 1)] + +def cache_21_A : List Cell := cache_21_A_part0 + +def cache_21_H_part0 : List Cell := [(-3, -1), (-2, -1), (-2, 0), (-1, 0), (0, 0), (1, 0), (1, 1), (2, 1)] + +def cache_21_H : List Cell := cache_21_H_part0 + +def cache_21 : ListRow := ⟨cache_21_A, cache_21_H, 3⟩ + +def cache_22_A_part0 : List Cell := [(-2, 0), (-1, 0), (0, 1), (1, 1), (2, 1)] + +def cache_22_A : List Cell := cache_22_A_part0 + +def cache_22_H_part0 : List Cell := [(-2, 0), (-1, 0), (0, 0), (0, 1), (1, 0), (1, 1), (2, 1), (3, 1)] + +def cache_22_H : List Cell := cache_22_H_part0 + +def cache_22 : ListRow := ⟨cache_22_A, cache_22_H, 2⟩ + +def cache_23_A_part0 : List Cell := [(-2, -1), (-1, -1), (-1, 0), (0, -1), (1, 0)] + +def cache_23_A : List Cell := cache_23_A_part0 + +def cache_23_H_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -1), (-1, 0), (0, -1), (0, 0), (1, 0), (2, 0)] + +def cache_23_H : List Cell := cache_23_H_part0 + +def cache_23 : ListRow := ⟨cache_23_A, cache_23_H, 2⟩ + +def cache_24_A_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -1), (-1, 0)] + +def cache_24_A : List Cell := cache_24_A_part0 + +def cache_24_H_part0 : List Cell := [(-4, -1), (-3, -1), (-2, -1), (-1, -1), (-1, 0), (0, -1), (0, 0), (1, 0), (2, 0)] + +def cache_24_H : List Cell := cache_24_H_part0 + +def cache_24 : ListRow := ⟨cache_24_A, cache_24_H, 3⟩ + +def cache_25_A_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -1), (-1, 0)] + +def cache_25_A : List Cell := cache_25_A_part0 + +def cache_25_H_part0 : List Cell := [(-4, -1), (-3, -1), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, 0), (1, 0), (2, 0)] + +def cache_25_H : List Cell := cache_25_H_part0 + +def cache_25 : ListRow := ⟨cache_25_A, cache_25_H, 3⟩ + +def cache_26_A_part0 : List Cell := [(-2, 0), (-2, 1), (-1, 0), (-1, 1), (1, 0), (1, 1)] + +def cache_26_A : List Cell := cache_26_A_part0 + +def cache_26_H_part0 : List Cell := [(-2, 0), (-2, 1), (-1, 0), (-1, 1), (0, 0), (1, 0), (1, 1), (2, 0), (2, 1)] + +def cache_26_H : List Cell := cache_26_H_part0 + +def cache_26 : ListRow := ⟨cache_26_A, cache_26_H, 3⟩ + +def cache_27_A_part0 : List Cell := [(-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-1, 0)] + +def cache_27_A : List Cell := cache_27_A_part0 + +def cache_27_H_part0 : List Cell := [(-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-1, 0), (0, 0), (1, 0)] + +def cache_27_H : List Cell := cache_27_H_part0 + +def cache_27 : ListRow := ⟨cache_27_A, cache_27_H, 3⟩ + +def cache_28_A_part0 : List Cell := [(-2, -1), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (1, 0)] + +def cache_28_A : List Cell := cache_28_A_part0 + +def cache_28_H_part0 : List Cell := [(-2, -1), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, 0), (0, 1), (1, 0), (2, 0)] + +def cache_28_H : List Cell := cache_28_H_part0 + +def cache_28 : ListRow := ⟨cache_28_A, cache_28_H, 3⟩ + +def cache_29_A_part0 : List Cell := [(1, -3), (1, -2), (1, -1), (1, 0), (2, -1), (4, -1)] + +def cache_29_A : List Cell := cache_29_A_part0 + +def cache_29_H_part0 : List Cell := [(0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (2, -1), (3, -1), (4, -1)] + +def cache_29_H : List Cell := cache_29_H_part0 + +def cache_29 : ListRow := ⟨cache_29_A, cache_29_H, 3⟩ + +def cache_30_A_part0 : List Cell := [(-2, -1), (-1, -1), (0, -1), (1, 0)] + +def cache_30_A : List Cell := cache_30_A_part0 + +def cache_30_H_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -1), (-1, 0), (0, -1), (0, 0), (1, 0), (2, 0), (3, 0)] + +def cache_30_H : List Cell := cache_30_H_part0 + +def cache_30 : ListRow := ⟨cache_30_A, cache_30_H, 3⟩ + +def cache_31_A_part0 : List Cell := [(-2, 0), (-1, 0), (0, 1), (1, 1)] + +def cache_31_A : List Cell := cache_31_A_part0 + +def cache_31_H_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0), (0, 0), (0, 1), (1, 0), (1, 1), (2, 1), (3, 1)] + +def cache_31_H : List Cell := cache_31_H_part0 + +def cache_31 : ListRow := ⟨cache_31_A, cache_31_H, 3⟩ + +def cache_32_A_part0 : List Cell := [(1, -3), (1, -2), (1, -1), (1, 0), (2, -1), (3, -1)] + +def cache_32_A : List Cell := cache_32_A_part0 + +def cache_32_H_part0 : List Cell := [(0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (2, -1), (3, -1), (4, -1)] + +def cache_32_H : List Cell := cache_32_H_part0 + +def cache_32 : ListRow := ⟨cache_32_A, cache_32_H, 3⟩ + +def cache_33_A_part0 : List Cell := [(-1, 0), (1, 0), (1, 1), (2, 1)] + +def cache_33_A : List Cell := cache_33_A_part0 + +def cache_33_H_part0 : List Cell := [(-2, 0), (-1, 0), (0, 0), (1, 0), (1, 1), (2, 0), (2, 1), (3, 1), (4, 1)] + +def cache_33_H : List Cell := cache_33_H_part0 + +def cache_33 : ListRow := ⟨cache_33_A, cache_33_H, 3⟩ + +def cache_34_A_part0 : List Cell := [(-2, -1), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (2, 0)] + +def cache_34_A : List Cell := cache_34_A_part0 + +def cache_34_H_part0 : List Cell := [(-2, -1), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, 0), (0, 1), (1, 0), (2, 0)] + +def cache_34_H : List Cell := cache_34_H_part0 + +def cache_34 : ListRow := ⟨cache_34_A, cache_34_H, 3⟩ + +def cache_35_A_part0 : List Cell := [(-1, 0), (1, 0), (1, 1), (2, 1)] + +def cache_35_A : List Cell := cache_35_A_part0 + +def cache_35_H_part0 : List Cell := [(-2, 0), (-1, 0), (0, 0), (0, 1), (1, 0), (1, 1), (2, 1), (3, 1), (4, 1)] + +def cache_35_H : List Cell := cache_35_H_part0 + +def cache_35 : ListRow := ⟨cache_35_A, cache_35_H, 3⟩ + +def cache_36_A_part0 : List Cell := [(1, 0), (2, 0), (2, 1), (3, 1)] + +def cache_36_A : List Cell := cache_36_A_part0 + +def cache_36_H_part0 : List Cell := [(-1, 0), (0, 0), (1, 0), (2, 0), (2, 1), (3, 0), (3, 1), (4, 1), (5, 1)] + +def cache_36_H : List Cell := cache_36_H_part0 + +def cache_36 : ListRow := ⟨cache_36_A, cache_36_H, 3⟩ + +def cache_37_A_part0 : List Cell := [(1, -3), (1, -2), (1, -1), (1, 0), (3, -1), (4, -1)] + +def cache_37_A : List Cell := cache_37_A_part0 + +def cache_37_H_part0 : List Cell := [(0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (2, -1), (3, -1), (4, -1)] + +def cache_37_H : List Cell := cache_37_H_part0 + +def cache_37 : ListRow := ⟨cache_37_A, cache_37_H, 3⟩ + +def cache_38_A_part0 : List Cell := [(-4, -1), (-3, -1), (-2, -1), (-1, 0)] + +def cache_38_A : List Cell := cache_38_A_part0 + +def cache_38_H_part0 : List Cell := [(-4, -1), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, 0), (1, 0)] + +def cache_38_H : List Cell := cache_38_H_part0 + +def cache_38 : ListRow := ⟨cache_38_A, cache_38_H, 3⟩ + +def cache_39_A_part0 : List Cell := [(-2, -1), (-1, -1), (0, -1), (1, 0)] + +def cache_39_A : List Cell := cache_39_A_part0 + +def cache_39_H_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -1), (0, -1), (0, 0), (1, -1), (1, 0), (2, 0), (3, 0)] + +def cache_39_H : List Cell := cache_39_H_part0 + +def cache_39 : ListRow := ⟨cache_39_A, cache_39_H, 3⟩ + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/CacheData01.lean b/lean/OAI/Combinatorics/SnakyCertificate/CacheData01.lean new file mode 100644 index 0000000000000000000000000000000000000000..6cde28770dfe8812c4cf813b426e52968540d89c --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/CacheData01.lean @@ -0,0 +1,409 @@ +import OAI.Combinatorics.SnakyCertificate.Lists + +namespace OAI + +namespace SnakyCertificate.Check + +def cache_40_A_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -1), (1, 0)] + +def cache_40_A : List Cell := cache_40_A_part0 + +def cache_40_H_part0 : List Cell := [(-3, -1), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, -1), (0, 0), (1, 0), (2, 0)] + +def cache_40_H : List Cell := cache_40_H_part0 + +def cache_40 : ListRow := ⟨cache_40_A, cache_40_H, 3⟩ + +def cache_41_A_part0 : List Cell := [(-1, 0), (0, -3), (0, -2), (0, -1), (1, -1), (3, -1)] + +def cache_41_A : List Cell := cache_41_A_part0 + +def cache_41_H_part0 : List Cell := [(-1, 0), (-1, 1), (0, -3), (0, -2), (0, -1), (0, 0), (1, -1), (2, -1), (3, -1)] + +def cache_41_H : List Cell := cache_41_H_part0 + +def cache_41 : ListRow := ⟨cache_41_A, cache_41_H, 3⟩ + +def cache_42_A_part0 : List Cell := [(-2, -1), (-2, 0), (-2, 1), (-1, -1), (-1, 0), (1, 0)] + +def cache_42_A : List Cell := cache_42_A_part0 + +def cache_42_H_part0 : List Cell := [(-3, 1), (-2, -1), (-2, 0), (-2, 1), (-1, -1), (-1, 0), (0, 0), (1, 0), (2, 0)] + +def cache_42_H : List Cell := cache_42_H_part0 + +def cache_42 : ListRow := ⟨cache_42_A, cache_42_H, 3⟩ + +def cache_43_A_part0 : List Cell := [(-1, 0), (0, -3), (0, -2), (0, -1), (2, -1), (3, -1)] + +def cache_43_A : List Cell := cache_43_A_part0 + +def cache_43_H_part0 : List Cell := [(-1, 0), (-1, 1), (0, -3), (0, -2), (0, -1), (0, 0), (1, -1), (2, -1), (3, -1)] + +def cache_43_H : List Cell := cache_43_H_part0 + +def cache_43 : ListRow := ⟨cache_43_A, cache_43_H, 3⟩ + +def cache_44_A_part0 : List Cell := [(-4, 0), (-4, 1), (-3, 0), (-2, 0), (-1, 0)] + +def cache_44_A : List Cell := cache_44_A_part0 + +def cache_44_H_part0 : List Cell := [(-4, 0), (-4, 1), (-3, 0), (-3, 1), (-2, 0), (-1, 0), (-1, 1), (0, 0), (0, 1), (1, 1)] + +def cache_44_H : List Cell := cache_44_H_part0 + +def cache_44 : ListRow := ⟨cache_44_A, cache_44_H, 4⟩ + +def cache_45_A_part0 : List Cell := [(-4, 0), (-3, 0), (-3, 1), (-2, 0), (-1, 0)] + +def cache_45_A : List Cell := cache_45_A_part0 + +def cache_45_H_part0 : List Cell := [(-4, 0), (-4, 1), (-3, 0), (-3, 1), (-2, 0), (-1, 0), (-1, 1), (0, 0), (0, 1), (1, 1)] + +def cache_45_H : List Cell := cache_45_H_part0 + +def cache_45 : ListRow := ⟨cache_45_A, cache_45_H, 4⟩ + +def cache_46_A_part0 : List Cell := [(-4, 0), (-3, -1), (-3, 0), (-2, 0), (-1, 0)] + +def cache_46_A : List Cell := cache_46_A_part0 + +def cache_46_H_part0 : List Cell := [(-4, -1), (-4, 0), (-3, -1), (-3, 0), (-2, 0), (-1, 0), (-1, 1), (0, 0), (0, 1), (1, 1)] + +def cache_46_H : List Cell := cache_46_H_part0 + +def cache_46 : ListRow := ⟨cache_46_A, cache_46_H, 4⟩ + +def cache_47_A_part0 : List Cell := [(-1, 0), (0, -3), (0, -2), (0, -1), (1, 0), (2, -1), (2, 0)] + +def cache_47_A : List Cell := cache_47_A_part0 + +def cache_47_H_part0 : List Cell := [(-1, 0), (-1, 1), (0, -3), (0, -2), (0, -1), (0, 0), (1, 0), (2, -1), (2, 0), (3, -1)] + +def cache_47_H : List Cell := cache_47_H_part0 + +def cache_47 : ListRow := ⟨cache_47_A, cache_47_H, 3⟩ + +def cache_48_A_part0 : List Cell := [(1, -3), (1, -2), (1, -1), (1, 0), (2, 0), (3, -1), (3, 0)] + +def cache_48_A : List Cell := cache_48_A_part0 + +def cache_48_H_part0 : List Cell := [(0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (2, 0), (3, -1), (3, 0), (4, -1)] + +def cache_48_H : List Cell := cache_48_H_part0 + +def cache_48 : ListRow := ⟨cache_48_A, cache_48_H, 3⟩ + +def cache_49_A_part0 : List Cell := [(-1, -4), (0, -4), (0, -3), (0, -2), (0, -1)] + +def cache_49_A : List Cell := cache_49_A_part0 + +def cache_49_H_part0 : List Cell := [(-1, -4), (-1, -3), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (1, -1), (1, 0), (1, 1)] + +def cache_49_H : List Cell := cache_49_H_part0 + +def cache_49 : ListRow := ⟨cache_49_A, cache_49_H, 4⟩ + +def cache_50_A_part0 : List Cell := [(-1, 0), (0, -4), (0, -3), (0, -2), (0, -1)] + +def cache_50_A : List Cell := cache_50_A_part0 + +def cache_50_H_part0 : List Cell := [(-1, 0), (-1, 1), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (1, -1), (1, 0), (1, 1)] + +def cache_50_H : List Cell := cache_50_H_part0 + +def cache_50 : ListRow := ⟨cache_50_A, cache_50_H, 4⟩ + +def cache_51_A_part0 : List Cell := [(-3, -1), (-3, 0), (-2, -1), (-2, 0), (0, -1)] + +def cache_51_A : List Cell := cache_51_A_part0 + +def cache_51_H_part0 : List Cell := [(-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, -1), (0, 0), (1, -1), (1, 0)] + +def cache_51_H : List Cell := cache_51_H_part0 + +def cache_51 : ListRow := ⟨cache_51_A, cache_51_H, 4⟩ + +def cache_52_A_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -1), (-1, 0), (0, -1), (1, -1), (2, -1)] + +def cache_52_A : List Cell := cache_52_A_part0 + +def cache_52_H_part0 : List Cell := [(-4, -1), (-3, -1), (-2, -1), (-1, -1), (-1, 0), (0, -1), (0, 0), (1, -1), (2, -1), (3, -1)] + +def cache_52_H : List Cell := cache_52_H_part0 + +def cache_52 : ListRow := ⟨cache_52_A, cache_52_H, 2⟩ + +def cache_53_A_part0 : List Cell := [(0, -2), (0, -1), (1, -1), (1, 1), (1, 2), (2, -1), (3, -1)] + +def cache_53_A : List Cell := cache_53_A_part0 + +def cache_53_H_part0 : List Cell := [(-1, 0), (0, -2), (0, -1), (0, 0), (0, 1), (1, -1), (1, 1), (1, 2), (2, -1), (3, -1)] + +def cache_53_H : List Cell := cache_53_H_part0 + +def cache_53 : ListRow := ⟨cache_53_A, cache_53_H, 3⟩ + +def cache_54_A_part0 : List Cell := [(-4, -1), (-3, -1), (-2, 0), (-1, 0)] + +def cache_54_A : List Cell := cache_54_A_part0 + +def cache_54_H_part0 : List Cell := [(-4, -1), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, 0), (1, 0)] + +def cache_54_H : List Cell := cache_54_H_part0 + +def cache_54 : ListRow := ⟨cache_54_A, cache_54_H, 3⟩ + +def cache_55_A_part0 : List Cell := [(-4, 0), (-3, 0), (-2, 0), (-1, 0)] + +def cache_55_A : List Cell := cache_55_A_part0 + +def cache_55_H_part0 : List Cell := [(-5, 1), (-4, 0), (-4, 1), (-3, 0), (-3, 1), (-2, 0), (-1, 0), (-1, 1), (0, 0), (0, 1), (1, 1)] + +def cache_55_H : List Cell := cache_55_H_part0 + +def cache_55 : ListRow := ⟨cache_55_A, cache_55_H, 4⟩ + +def cache_56_A_part0 : List Cell := [(-4, 0), (-3, 0), (-2, 0), (-1, 0)] + +def cache_56_A : List Cell := cache_56_A_part0 + +def cache_56_H_part0 : List Cell := [(-5, -1), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, 0), (-1, 0), (0, 0)] + +def cache_56_H : List Cell := cache_56_H_part0 + +def cache_56 : ListRow := ⟨cache_56_A, cache_56_H, 4⟩ + +def cache_57_A_part0 : List Cell := [(-4, 0), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, 0)] + +def cache_57_A : List Cell := cache_57_A_part0 + +def cache_57_H_part0 : List Cell := [(-4, 0), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, 0), (-1, 1), (0, 0), (0, 1), (1, 0), (1, 1)] + +def cache_57_H : List Cell := cache_57_H_part0 + +def cache_57 : ListRow := ⟨cache_57_A, cache_57_H, 4⟩ + +def cache_58_A_part0 : List Cell := [(-4, 0), (-3, 0), (-3, 1), (-2, 0), (-2, 1), (-1, 0)] + +def cache_58_A : List Cell := cache_58_A_part0 + +def cache_58_H_part0 : List Cell := [(-4, 0), (-3, 0), (-3, 1), (-2, 0), (-2, 1), (-1, 0), (-1, 1), (0, 0), (0, 1), (1, 0), (1, 1)] + +def cache_58_H : List Cell := cache_58_H_part0 + +def cache_58 : ListRow := ⟨cache_58_A, cache_58_H, 4⟩ + +def cache_59_A_part0 : List Cell := [(-4, 0), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, 0)] + +def cache_59_A : List Cell := cache_59_A_part0 + +def cache_59_H_part0 : List Cell := [(-5, 1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-1, 0), (0, 0), (1, 0)] + +def cache_59_H : List Cell := cache_59_H_part0 + +def cache_59 : ListRow := ⟨cache_59_A, cache_59_H, 4⟩ + +def cache_60_A_part0 : List Cell := [(-2, -1), (-2, 0), (-1, 0), (1, 0)] + +def cache_60_A : List Cell := cache_60_A_part0 + +def cache_60_H_part0 : List Cell := [(-3, -1), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, 0), (1, 0), (1, 1), (2, 0), (2, 1), (3, 1)] + +def cache_60_H : List Cell := cache_60_H_part0 + +def cache_60 : ListRow := ⟨cache_60_A, cache_60_H, 5⟩ + +def cache_61_A_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -3), (-1, -2), (-1, -1), (0, -1)] + +def cache_61_A : List Cell := cache_61_A_part0 + +def cache_61_H_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -3), (-1, -2), (-1, -1), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, 0)] + +def cache_61_H : List Cell := cache_61_H_part0 + +def cache_61 : ListRow := ⟨cache_61_A, cache_61_H, 3⟩ + +def cache_62_A_part0 : List Cell := [(-3, -1), (-3, 0), (-2, 0), (-2, 2), (-2, 3), (-1, 0)] + +def cache_62_A : List Cell := cache_62_A_part0 + +def cache_62_H_part0 : List Cell := [(-4, -1), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-2, 0), (-2, 2), (-2, 3), (-1, 0), (0, 0)] + +def cache_62_H : List Cell := cache_62_H_part0 + +def cache_62 : ListRow := ⟨cache_62_A, cache_62_H, 4⟩ + +def cache_63_A_part0 : List Cell := [(1, -4), (1, -3), (1, -2), (1, -1)] + +def cache_63_A : List Cell := cache_63_A_part0 + +def cache_63_H_part0 : List Cell := [(0, -1), (0, 0), (0, 1), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (2, -1), (2, 0), (2, 1)] + +def cache_63_H : List Cell := cache_63_H_part0 + +def cache_63 : ListRow := ⟨cache_63_A, cache_63_H, 5⟩ + +def cache_64_A_part0 : List Cell := [(0, 1), (1, 1), (2, 1), (3, 1)] + +def cache_64_A : List Cell := cache_64_A_part0 + +def cache_64_H_part0 : List Cell := [(-1, 0), (0, 0), (0, 1), (1, 0), (1, 1), (2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (5, 2)] + +def cache_64_H : List Cell := cache_64_H_part0 + +def cache_64 : ListRow := ⟨cache_64_A, cache_64_H, 5⟩ + +def cache_65_A_part0 : List Cell := [(-3, -1), (-3, 0), (-2, 0), (-1, 0)] + +def cache_65_A : List Cell := cache_65_A_part0 + +def cache_65_H_part0 : List Cell := [(-4, -1), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, 0), (0, 0), (0, 1), (1, 0), (1, 1), (2, 1)] + +def cache_65_H : List Cell := cache_65_H_part0 + +def cache_65 : ListRow := ⟨cache_65_A, cache_65_H, 5⟩ + +def cache_66_A_part0 : List Cell := [(1, -3), (1, -2), (1, -1), (1, 0), (3, -1), (4, -1)] + +def cache_66_A : List Cell := cache_66_A_part0 + +def cache_66_H_part0 : List Cell := [(0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (2, 0), (2, 1), (3, -1), (3, 0), (4, -1)] + +def cache_66_H : List Cell := cache_66_H_part0 + +def cache_66 : ListRow := ⟨cache_66_A, cache_66_H, 4⟩ + +def cache_67_A_part0 : List Cell := [(-2, -1), (-2, 0), (-1, -3), (-1, -2), (-1, -1), (-1, 0)] + +def cache_67_A : List Cell := cache_67_A_part0 + +def cache_67_H_part0 : List Cell := [(-3, -1), (-2, -1), (-2, 0), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, 0), (0, 1), (1, 0), (2, 0)] + +def cache_67_H : List Cell := cache_67_H_part0 + +def cache_67 : ListRow := ⟨cache_67_A, cache_67_H, 4⟩ + +def cache_68_A_part0 : List Cell := [(-3, 0), (-3, 1), (-2, 0), (-1, 0)] + +def cache_68_A : List Cell := cache_68_A_part0 + +def cache_68_H_part0 : List Cell := [(-4, 1), (-3, 0), (-3, 1), (-2, 0), (-2, 1), (-1, 0), (0, 0), (0, 1), (1, 0), (1, 1), (2, 1)] + +def cache_68_H : List Cell := cache_68_H_part0 + +def cache_68 : ListRow := ⟨cache_68_A, cache_68_H, 5⟩ + +def cache_69_A_part0 : List Cell := [(1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (4, 1)] + +def cache_69_A : List Cell := cache_69_A_part0 + +def cache_69_H_part0 : List Cell := [(0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (2, 1), (2, 2), (3, 1), (4, 1)] + +def cache_69_H : List Cell := cache_69_H_part0 + +def cache_69 : ListRow := ⟨cache_69_A, cache_69_H, 4⟩ + +def cache_70_A_part0 : List Cell := [(1, -4), (1, -3), (1, -2), (1, -1), (2, -1), (4, -1)] + +def cache_70_A : List Cell := cache_70_A_part0 + +def cache_70_H_part0 : List Cell := [(0, -1), (0, 0), (0, 1), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (2, -1), (3, -1), (4, -1)] + +def cache_70_H : List Cell := cache_70_H_part0 + +def cache_70 : ListRow := ⟨cache_70_A, cache_70_H, 4⟩ + +def cache_71_A_part0 : List Cell := [(-2, 0), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (1, -1)] + +def cache_71_A : List Cell := cache_71_A_part0 + +def cache_71_H_part0 : List Cell := [(-3, 0), (-2, 0), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -1), (0, 0), (0, 1), (1, -1), (2, -1)] + +def cache_71_H : List Cell := cache_71_H_part0 + +def cache_71 : ListRow := ⟨cache_71_A, cache_71_H, 3⟩ + +def cache_72_A_part0 : List Cell := [(-2, 1), (-1, 1), (-1, 2), (-1, 3), (0, 1), (1, 1)] + +def cache_72_A : List Cell := cache_72_A_part0 + +def cache_72_H_part0 : List Cell := [(-3, 1), (-2, 1), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, 0), (0, 1), (1, 0), (1, 1), (2, 0)] + +def cache_72_H : List Cell := cache_72_H_part0 + +def cache_72 : ListRow := ⟨cache_72_A, cache_72_H, 4⟩ + +def cache_73_A_part0 : List Cell := [(-1, 1), (0, -3), (0, -2), (0, -1)] + +def cache_73_A : List Cell := cache_73_A_part0 + +def cache_73_H_part0 : List Cell := [(-1, 0), (-1, 1), (-1, 2), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, 0), (1, 1), (1, 2)] + +def cache_73_H : List Cell := cache_73_H_part0 + +def cache_73 : ListRow := ⟨cache_73_A, cache_73_H, 5⟩ + +def cache_74_A_part0 : List Cell := [(-1, -3), (-1, -2), (0, -2), (0, 1), (1, -2), (2, -2)] + +def cache_74_A : List Cell := cache_74_A_part0 + +def cache_74_H_part0 : List Cell := [(-2, -1), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -2), (0, -1), (0, 0), (0, 1), (1, -2), (2, -2)] + +def cache_74_H : List Cell := cache_74_H_part0 + +def cache_74 : ListRow := ⟨cache_74_A, cache_74_H, 4⟩ + +def cache_75_A_part0 : List Cell := [(-2, -1), (-1, -1), (0, -1), (1, -1), (1, 0), (2, -1)] + +def cache_75_A : List Cell := cache_75_A_part0 + +def cache_75_H_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -1), (-1, 0), (0, -1), (0, 0), (1, -1), (1, 0), (2, -1), (3, -1), (4, -1)] + +def cache_75_H : List Cell := cache_75_H_part0 + +def cache_75 : ListRow := ⟨cache_75_A, cache_75_H, 4⟩ + +def cache_76_A_part0 : List Cell := [(-1, 0), (0, -1), (1, 0), (1, 1), (1, 2), (2, 1)] + +def cache_76_A : List Cell := cache_76_A_part0 + +def cache_76_H_part0 : List Cell := [(-1, 0), (0, -1), (0, 0), (0, 1), (1, 0), (1, 1), (1, 2), (1, 3), (2, 1), (3, 1), (4, 1)] + +def cache_76_H : List Cell := cache_76_H_part0 + +def cache_76 : ListRow := ⟨cache_76_A, cache_76_H, 3⟩ + +def cache_77_A_part0 : List Cell := [(-2, -1), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (0, -1)] + +def cache_77_A : List Cell := cache_77_A_part0 + +def cache_77_H_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -1), (0, 0), (1, 0), (2, 0)] + +def cache_77_H : List Cell := cache_77_H_part0 + +def cache_77 : ListRow := ⟨cache_77_A, cache_77_H, 3⟩ + +def cache_78_A_part0 : List Cell := [(-2, -1), (-1, -1), (0, -1), (1, -1), (2, -1), (3, -1)] + +def cache_78_A : List Cell := cache_78_A_part0 + +def cache_78_H_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -1), (-1, 0), (0, -1), (0, 0), (1, -1), (1, 0), (2, -1), (3, -1), (4, -1)] + +def cache_78_H : List Cell := cache_78_H_part0 + +def cache_78 : ListRow := ⟨cache_78_A, cache_78_H, 3⟩ + +def cache_79_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1), (1, 0), (2, -1), (2, 0)] + +def cache_79_A : List Cell := cache_79_A_part0 + +def cache_79_H_part0 : List Cell := [(-1, 0), (-1, 1), (0, -3), (0, -2), (0, -1), (0, 0), (1, 0), (1, 1), (2, -1), (2, 0), (3, -1)] + +def cache_79_H : List Cell := cache_79_H_part0 + +def cache_79 : ListRow := ⟨cache_79_A, cache_79_H, 4⟩ + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/CacheData02.lean b/lean/OAI/Combinatorics/SnakyCertificate/CacheData02.lean new file mode 100644 index 0000000000000000000000000000000000000000..405a1f9516f2cd2ec31baf6c2787a9d791be0c33 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/CacheData02.lean @@ -0,0 +1,409 @@ +import OAI.Combinatorics.SnakyCertificate.Lists + +namespace OAI + +namespace SnakyCertificate.Check + +def cache_80_A_part0 : List Cell := [(-2, -1), (-1, -1), (-1, 0), (1, -1), (1, 0), (1, 1)] + +def cache_80_A : List Cell := cache_80_A_part0 + +def cache_80_H_part0 : List Cell := [(-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, 0), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1)] + +def cache_80_H : List Cell := cache_80_H_part0 + +def cache_80 : ListRow := ⟨cache_80_A, cache_80_H, 4⟩ + +def cache_81_A_part0 : List Cell := [(1, -4), (1, -3), (1, -2), (1, -1), (3, -1), (4, -1)] + +def cache_81_A : List Cell := cache_81_A_part0 + +def cache_81_H_part0 : List Cell := [(0, -1), (0, 0), (0, 1), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (2, -1), (3, -1), (4, -1)] + +def cache_81_H : List Cell := cache_81_H_part0 + +def cache_81 : ListRow := ⟨cache_81_A, cache_81_H, 4⟩ + +def cache_82_A_part0 : List Cell := [(-2, -1), (-1, -3), (-1, -2), (-1, -1), (-1, 0)] + +def cache_82_A : List Cell := cache_82_A_part0 + +def cache_82_H_part0 : List Cell := [(-4, -1), (-3, -1), (-2, -1), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -1), (0, 0), (0, 1), (1, 0), (2, 0)] + +def cache_82_H : List Cell := cache_82_H_part0 + +def cache_82 : ListRow := ⟨cache_82_A, cache_82_H, 4⟩ + +def cache_83_A_part0 : List Cell := [(0, -1), (1, -1), (1, 0), (1, 1), (1, 2)] + +def cache_83_A : List Cell := cache_83_A_part0 + +def cache_83_H_part0 : List Cell := [(-1, 0), (0, -1), (0, 0), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, -2), (2, -1), (3, -1), (4, -1)] + +def cache_83_H : List Cell := cache_83_H_part0 + +def cache_83 : ListRow := ⟨cache_83_A, cache_83_H, 5⟩ + +def cache_84_A_part0 : List Cell := [(0, -1), (1, -3), (1, -2), (1, -1), (1, 0)] + +def cache_84_A : List Cell := cache_84_A_part0 + +def cache_84_H_part0 : List Cell := [(-1, -1), (0, -1), (0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (2, 0), (2, 1), (3, 0), (4, 0)] + +def cache_84_H : List Cell := cache_84_H_part0 + +def cache_84 : ListRow := ⟨cache_84_A, cache_84_H, 5⟩ + +def cache_85_A_part0 : List Cell := [(-2, -1), (-1, -1), (-1, 0), (0, -1), (1, -1)] + +def cache_85_A : List Cell := cache_85_A_part0 + +def cache_85_H_part0 : List Cell := [(-3, -1), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, -1), (0, 0), (1, -1), (1, 0), (2, -1), (2, 0), (3, -1)] + +def cache_85_H : List Cell := cache_85_H_part0 + +def cache_85 : ListRow := ⟨cache_85_A, cache_85_H, 4⟩ + +def cache_86_A_part0 : List Cell := [(-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, 0)] + +def cache_86_A : List Cell := cache_86_A_part0 + +def cache_86_H_part0 : List Cell := [(-4, 1), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-2, -2), (-2, -1), (-2, 0), (-1, 0), (0, 0), (1, 0)] + +def cache_86_H : List Cell := cache_86_H_part0 + +def cache_86 : ListRow := ⟨cache_86_A, cache_86_H, 5⟩ + +def cache_87_A_part0 : List Cell := [(-2, 0), (-1, 0), (-1, 1), (-1, 2), (0, -1)] + +def cache_87_A : List Cell := cache_87_A_part0 + +def cache_87_H_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -1), (0, 0), (1, -1), (1, 0), (2, -1), (3, -1)] + +def cache_87_H : List Cell := cache_87_H_part0 + +def cache_87 : ListRow := ⟨cache_87_A, cache_87_H, 4⟩ + +def cache_88_A_part0 : List Cell := [(-2, -1), (-2, 0), (-1, -1), (-1, 0), (1, 0)] + +def cache_88_A : List Cell := cache_88_A_part0 + +def cache_88_H_part0 : List Cell := [(-3, 1), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-1, -2), (-1, -1), (-1, 0), (0, 0), (1, 0), (2, 0)] + +def cache_88_H : List Cell := cache_88_H_part0 + +def cache_88 : ListRow := ⟨cache_88_A, cache_88_H, 5⟩ + +def cache_89_A_part0 : List Cell := [(-1, -2), (0, -4), (0, -3), (0, -2), (0, -1)] + +def cache_89_A : List Cell := cache_89_A_part0 + +def cache_89_H_part0 : List Cell := [(-1, -4), (-1, -3), (-1, -2), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1)] + +def cache_89_H : List Cell := cache_89_H_part0 + +def cache_89 : ListRow := ⟨cache_89_A, cache_89_H, 4⟩ + +def cache_90_A_part0 : List Cell := [(-3, -1), (-2, -1), (-1, 0)] + +def cache_90_A : List Cell := cache_90_A_part0 + +def cache_90_H_part0 : List Cell := [(-5, -1), (-4, -1), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, -1), (0, 0), (1, 0), (2, 0)] + +def cache_90_H : List Cell := cache_90_H_part0 + +def cache_90 : ListRow := ⟨cache_90_A, cache_90_H, 4⟩ + +def cache_91_A_part0 : List Cell := [(1, -3), (1, -2), (1, -1), (1, 0), (4, -1)] + +def cache_91_A : List Cell := cache_91_A_part0 + +def cache_91_H_part0 : List Cell := [(0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (4, -1)] + +def cache_91_H : List Cell := cache_91_H_part0 + +def cache_91 : ListRow := ⟨cache_91_A, cache_91_H, 5⟩ + +def cache_92_A_part0 : List Cell := [(-3, -1), (-1, -3), (-1, -2), (-1, -1), (-1, 0)] + +def cache_92_A : List Cell := cache_92_A_part0 + +def cache_92_H_part0 : List Cell := [(-4, -1), (-3, -1), (-2, -1), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -1), (0, 0), (0, 1), (1, 0), (2, 0)] + +def cache_92_H : List Cell := cache_92_H_part0 + +def cache_92 : ListRow := ⟨cache_92_A, cache_92_H, 4⟩ + +def cache_93_A_part0 : List Cell := [(1, -4), (1, -3), (1, -2), (1, -1), (2, 0), (3, -1), (3, 0)] + +def cache_93_A : List Cell := cache_93_A_part0 + +def cache_93_H_part0 : List Cell := [(0, -1), (0, 0), (0, 1), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (2, 0), (3, -1), (3, 0), (4, -1)] + +def cache_93_H : List Cell := cache_93_H_part0 + +def cache_93 : ListRow := ⟨cache_93_A, cache_93_H, 4⟩ + +def cache_94_A_part0 : List Cell := [(-2, -1), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (0, -1)] + +def cache_94_A : List Cell := cache_94_A_part0 + +def cache_94_H_part0 : List Cell := [(-2, -2), (-2, -1), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -1), (0, 0), (0, 1)] + +def cache_94_H : List Cell := cache_94_H_part0 + +def cache_94 : ListRow := ⟨cache_94_A, cache_94_H, 4⟩ + +def cache_95_A_part0 : List Cell := [(-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (0, -1), (2, 0)] + +def cache_95_A : List Cell := cache_95_A_part0 + +def cache_95_H_part0 : List Cell := [(-2, 1), (-2, 2), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -1), (0, 0), (1, 0), (2, 0)] + +def cache_95_H : List Cell := cache_95_H_part0 + +def cache_95 : ListRow := ⟨cache_95_A, cache_95_H, 4⟩ + +def cache_96_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1), (1, 0), (3, 0)] + +def cache_96_A : List Cell := cache_96_A_part0 + +def cache_96_H_part0 : List Cell := [(-1, 0), (-1, 1), (-1, 2), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, 0), (1, 1), (2, 0), (3, 0)] + +def cache_96_H : List Cell := cache_96_H_part0 + +def cache_96 : ListRow := ⟨cache_96_A, cache_96_H, 5⟩ + +def cache_97_A_part0 : List Cell := [(-3, -1), (-3, 0), (-3, 1), (-2, 0), (-1, 0)] + +def cache_97_A : List Cell := cache_97_A_part0 + +def cache_97_H_part0 : List Cell := [(-4, -1), (-3, -1), (-3, 0), (-3, 1), (-2, 0), (-2, 1), (-1, 0), (0, 0), (0, 1), (1, 0), (1, 1), (2, 1)] + +def cache_97_H : List Cell := cache_97_H_part0 + +def cache_97 : ListRow := ⟨cache_97_A, cache_97_H, 5⟩ + +def cache_98_A_part0 : List Cell := [(-1, -1), (-1, 0), (-1, 1), (1, 0), (2, 0)] + +def cache_98_A : List Cell := cache_98_A_part0 + +def cache_98_H_part0 : List Cell := [(-2, -1), (-1, -1), (-1, 0), (-1, 1), (0, 0), (0, 1), (1, 0), (2, 0), (2, 1), (3, 0), (3, 1), (4, 1)] + +def cache_98_H : List Cell := cache_98_H_part0 + +def cache_98 : ListRow := ⟨cache_98_A, cache_98_H, 5⟩ + +def cache_99_A_part0 : List Cell := [(-2, -1), (-1, -4), (-1, -3), (-1, -1), (0, -1)] + +def cache_99_A : List Cell := cache_99_A_part0 + +def cache_99_H_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (0, -1), (0, 0), (1, -1), (1, 0), (2, 0), (3, 0)] + +def cache_99_H : List Cell := cache_99_H_part0 + +def cache_99 : ListRow := ⟨cache_99_A, cache_99_H, 4⟩ + +def cache_100_A_part0 : List Cell := [(-3, -1), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-1, 0), (0, -1)] + +def cache_100_A : List Cell := cache_100_A_part0 + +def cache_100_H_part0 : List Cell := [(-3, -1), (-3, 0), (-3, 1), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-1, 0), (0, -1), (0, 0), (1, -1), (1, 0)] + +def cache_100_H : List Cell := cache_100_H_part0 + +def cache_100 : ListRow := ⟨cache_100_A, cache_100_H, 4⟩ + +def cache_101_A_part0 : List Cell := [(-2, -1), (-1, -2), (-1, -1), (0, -1), (0, 1)] + +def cache_101_A : List Cell := cache_101_A_part0 + +def cache_101_H_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -2), (-1, -1), (0, -1), (0, 0), (0, 1), (0, 2), (1, -1), (1, 0), (2, 0), (3, 0)] + +def cache_101_H : List Cell := cache_101_H_part0 + +def cache_101 : ListRow := ⟨cache_101_A, cache_101_H, 4⟩ + +def cache_102_A_part0 : List Cell := [(-1, 0), (1, -3), (1, -2), (1, -1), (1, 0)] + +def cache_102_A : List Cell := cache_102_A_part0 + +def cache_102_H_part0 : List Cell := [(-2, 0), (-1, 0), (0, -1), (0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (2, -1), (3, -1), (4, -1)] + +def cache_102_H : List Cell := cache_102_H_part0 + +def cache_102 : ListRow := ⟨cache_102_A, cache_102_H, 4⟩ + +def cache_103_A_part0 : List Cell := [(1, -3), (1, -2), (1, -1), (1, 0), (3, -1)] + +def cache_103_A : List Cell := cache_103_A_part0 + +def cache_103_H_part0 : List Cell := [(-1, 0), (0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (2, -1), (2, 0), (2, 1), (3, -1), (4, -1)] + +def cache_103_H : List Cell := cache_103_H_part0 + +def cache_103 : ListRow := ⟨cache_103_A, cache_103_H, 4⟩ + +def cache_104_A_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -1), (0, -1), (1, -1)] + +def cache_104_A : List Cell := cache_104_A_part0 + +def cache_104_H_part0 : List Cell := [(-4, -1), (-3, -1), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, -1), (0, 0), (1, -1), (1, 0), (2, -1), (3, -1)] + +def cache_104_H : List Cell := cache_104_H_part0 + +def cache_104 : ListRow := ⟨cache_104_A, cache_104_H, 5⟩ + +def cache_105_A_part0 : List Cell := [(-2, 0), (-1, 0), (-1, 1), (-1, 2), (-1, 3)] + +def cache_105_A : List Cell := cache_105_A_part0 + +def cache_105_H_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -1), (0, 0), (0, 1), (1, 1), (2, 1)] + +def cache_105_H : List Cell := cache_105_H_part0 + +def cache_105 : ListRow := ⟨cache_105_A, cache_105_H, 4⟩ + +def cache_106_A_part0 : List Cell := [(-2, -1), (-1, -3), (-1, -2), (-1, -1), (-1, 0)] + +def cache_106_A : List Cell := cache_106_A_part0 + +def cache_106_H_part0 : List Cell := [(-4, -1), (-3, -1), (-2, -1), (-2, 0), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, 0), (0, 1), (1, 0), (2, 0)] + +def cache_106_H : List Cell := cache_106_H_part0 + +def cache_106 : ListRow := ⟨cache_106_A, cache_106_H, 4⟩ + +def cache_107_A_part0 : List Cell := [(-3, -1), (-3, 0), (-2, 0), (-1, 0)] + +def cache_107_A : List Cell := cache_107_A_part0 + +def cache_107_H_part0 : List Cell := [(-4, -1), (-3, -1), (-3, 0), (-2, 0), (-1, 0), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1), (2, 1)] + +def cache_107_H : List Cell := cache_107_H_part0 + +def cache_107 : ListRow := ⟨cache_107_A, cache_107_H, 6⟩ + +def cache_108_A_part0 : List Cell := [(-4, -1), (-3, 0), (-2, 0), (-1, 0)] + +def cache_108_A : List Cell := cache_108_A_part0 + +def cache_108_H_part0 : List Cell := [(-4, -1), (-3, -1), (-3, 0), (-2, 0), (-1, 0), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1), (2, 1)] + +def cache_108_H : List Cell := cache_108_H_part0 + +def cache_108 : ListRow := ⟨cache_108_A, cache_108_H, 6⟩ + +def cache_109_A_part0 : List Cell := [(-4, -1), (-3, 0), (-2, 0), (-1, 0)] + +def cache_109_A : List Cell := cache_109_A_part0 + +def cache_109_H_part0 : List Cell := [(-4, -1), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, 0), (-2, 1), (-1, 0), (0, 0), (0, 1), (1, 0), (1, 1), (2, 1)] + +def cache_109_H : List Cell := cache_109_H_part0 + +def cache_109 : ListRow := ⟨cache_109_A, cache_109_H, 5⟩ + +def cache_110_A_part0 : List Cell := [(-2, -1), (-2, 0), (-1, 0), (1, 0)] + +def cache_110_A : List Cell := cache_110_A_part0 + +def cache_110_H_part0 : List Cell := [(-3, -1), (-2, -1), (-2, 0), (-1, 0), (0, 0), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, -1), (3, 1)] + +def cache_110_H : List Cell := cache_110_H_part0 + +def cache_110 : ListRow := ⟨cache_110_A, cache_110_H, 6⟩ + +def cache_111_A_part0 : List Cell := [(1, 0), (1, 1), (1, 2), (1, 3)] + +def cache_111_A : List Cell := cache_111_A_part0 + +def cache_111_H_part0 : List Cell := [(-1, 1), (0, -1), (0, 0), (0, 1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -1), (2, 0), (3, 0), (4, 0)] + +def cache_111_H : List Cell := cache_111_H_part0 + +def cache_111 : ListRow := ⟨cache_111_A, cache_111_H, 6⟩ + +def cache_112_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1), (1, 1), (2, 0), (2, 1)] + +def cache_112_A : List Cell := cache_112_A_part0 + +def cache_112_H_part0 : List Cell := [(-1, 0), (-1, 1), (-1, 2), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, 0), (1, 1), (2, 0), (2, 1), (3, 0)] + +def cache_112_H : List Cell := cache_112_H_part0 + +def cache_112 : ListRow := ⟨cache_112_A, cache_112_H, 5⟩ + +def cache_113_A_part0 : List Cell := [(-1, -1), (0, -1), (1, 0), (1, 1), (2, 1), (3, 0)] + +def cache_113_A : List Cell := cache_113_A_part0 + +def cache_113_H_part0 : List Cell := [(-2, 0), (-1, -1), (-1, 0), (0, -1), (0, 0), (0, 1), (1, 0), (1, 1), (2, 0), (2, 1), (3, 0), (3, 1), (4, 1)] + +def cache_113_H : List Cell := cache_113_H_part0 + +def cache_113 : ListRow := ⟨cache_113_A, cache_113_H, 4⟩ + +def cache_114_A_part0 : List Cell := [(-2, -1), (-2, 0), (-1, -1), (-1, 0), (1, 0), (1, 1)] + +def cache_114_A : List Cell := cache_114_A_part0 + +def cache_114_H_part0 : List Cell := [(-3, 1), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-1, -2), (-1, -1), (-1, 0), (0, 0), (1, 0), (1, 1), (2, 1)] + +def cache_114_H : List Cell := cache_114_H_part0 + +def cache_114 : ListRow := ⟨cache_114_A, cache_114_H, 5⟩ + +def cache_115_A_part0 : List Cell := [(-1, -3), (-1, -1), (-1, 0), (1, 0), (2, -1), (2, 0)] + +def cache_115_A : List Cell := cache_115_A_part0 + +def cache_115_H_part0 : List Cell := [(-3, 1), (-2, 0), (-2, 1), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (0, 0), (1, 0), (2, -1), (2, 0), (3, -1)] + +def cache_115_H : List Cell := cache_115_H_part0 + +def cache_115 : ListRow := ⟨cache_115_A, cache_115_H, 5⟩ + +def cache_116_A_part0 : List Cell := [(-2, 1), (-1, -2), (-1, -1), (-1, 1), (0, -1), (0, 1)] + +def cache_116_A : List Cell := cache_116_A_part0 + +def cache_116_H_part0 : List Cell := [(-3, 1), (-2, 1), (-1, -2), (-1, -1), (-1, 1), (0, -1), (0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (2, 0), (3, 0)] + +def cache_116_H : List Cell := cache_116_H_part0 + +def cache_116 : ListRow := ⟨cache_116_A, cache_116_H, 4⟩ + +def cache_117_A_part0 : List Cell := [(-2, -1), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (1, -1)] + +def cache_117_A : List Cell := cache_117_A_part0 + +def cache_117_H_part0 : List Cell := [(-2, -1), (-2, 0), (-2, 1), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, 0), (0, 1), (1, -1), (1, 0), (2, -1), (2, 0)] + +def cache_117_H : List Cell := cache_117_H_part0 + +def cache_117 : ListRow := ⟨cache_117_A, cache_117_H, 5⟩ + +def cache_118_A_part0 : List Cell := [(-2, -1), (-1, -4), (-1, -1), (0, -3), (0, -2), (0, -1)] + +def cache_118_A : List Cell := cache_118_A_part0 + +def cache_118_H_part0 : List Cell := [(-2, -1), (-1, -4), (-1, -3), (-1, -1), (-1, 0), (0, -3), (0, -2), (0, -1), (0, 0), (1, 0), (1, 1), (2, 0), (3, 0)] + +def cache_118_H : List Cell := cache_118_H_part0 + +def cache_118 : ListRow := ⟨cache_118_A, cache_118_H, 4⟩ + +def cache_119_A_part0 : List Cell := [(-2, -1), (-2, 0), (-1, 0), (1, 0)] + +def cache_119_A : List Cell := cache_119_A_part0 + +def cache_119_H_part0 : List Cell := [(-3, -1), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-1, 0), (-1, 1), (0, 0), (1, 0), (1, 1), (2, 0), (2, 1), (3, 1)] + +def cache_119_H : List Cell := cache_119_H_part0 + +def cache_119 : ListRow := ⟨cache_119_A, cache_119_H, 5⟩ + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/CacheData03.lean b/lean/OAI/Combinatorics/SnakyCertificate/CacheData03.lean new file mode 100644 index 0000000000000000000000000000000000000000..8adec5b6b50a765162fd3fd2636ba63b0160a911 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/CacheData03.lean @@ -0,0 +1,409 @@ +import OAI.Combinatorics.SnakyCertificate.Lists + +namespace OAI + +namespace SnakyCertificate.Check + +def cache_120_A_part0 : List Cell := [(-3, 0), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (1, 1)] + +def cache_120_A : List Cell := cache_120_A_part0 + +def cache_120_H_part0 : List Cell := [(-3, 0), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0)] + +def cache_120_H : List Cell := cache_120_H_part0 + +def cache_120 : ListRow := ⟨cache_120_A, cache_120_H, 5⟩ + +def cache_121_A_part0 : List Cell := [(-1, -2), (-1, -1), (0, -4), (0, -3), (0, -2), (0, -1)] + +def cache_121_A : List Cell := cache_121_A_part0 + +def cache_121_H_part0 : List Cell := [(-1, -3), (-1, -2), (-1, -1), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -1), (1, 0), (1, 1)] + +def cache_121_H : List Cell := cache_121_H_part0 + +def cache_121 : ListRow := ⟨cache_121_A, cache_121_H, 4⟩ + +def cache_122_A_part0 : List Cell := [(0, -1), (1, 0), (2, 0), (3, 0)] + +def cache_122_A : List Cell := cache_122_A_part0 + +def cache_122_H_part0 : List Cell := [(-1, -1), (-1, 1), (0, -2), (0, -1), (0, 0), (0, 1), (1, 0), (1, 1), (1, 2), (1, 3), (2, 0), (3, 0), (4, 0)] + +def cache_122_H : List Cell := cache_122_H_part0 + +def cache_122 : ListRow := ⟨cache_122_A, cache_122_H, 5⟩ + +def cache_123_A_part0 : List Cell := [(-2, -1), (-2, 0), (-1, 0), (1, 0)] + +def cache_123_A : List Cell := cache_123_A_part0 + +def cache_123_H_part0 : List Cell := [(-3, -1), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-1, 0), (-1, 1), (0, 0), (1, -1), (1, 0), (2, -1), (2, 0), (3, -1)] + +def cache_123_H : List Cell := cache_123_H_part0 + +def cache_123 : ListRow := ⟨cache_123_A, cache_123_H, 6⟩ + +def cache_124_A_part0 : List Cell := [(-1, -3), (-1, -2), (-1, -1), (-1, 0), (1, -1), (2, -1)] + +def cache_124_A : List Cell := cache_124_A_part0 + +def cache_124_H_part0 : List Cell := [(-2, 0), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, 0), (0, 1), (1, -1), (1, 0), (2, -1), (2, 0), (3, -1), (4, -1)] + +def cache_124_H : List Cell := cache_124_H_part0 + +def cache_124 : ListRow := ⟨cache_124_A, cache_124_H, 4⟩ + +def cache_125_A_part0 : List Cell := [(-3, -1), (-2, -1), (-2, 1), (-1, -1), (-1, 1), (1, 0)] + +def cache_125_A : List Cell := cache_125_A_part0 + +def cache_125_H_part0 : List Cell := [(-3, -1), (-3, 1), (-2, -1), (-2, 1), (-1, -1), (-1, 1), (0, -1), (0, 0), (0, 1), (1, 0), (1, 1), (2, 0), (3, 0)] + +def cache_125_H : List Cell := cache_125_H_part0 + +def cache_125 : ListRow := ⟨cache_125_A, cache_125_H, 4⟩ + +def cache_126_A_part0 : List Cell := [(1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2)] + +def cache_126_A : List Cell := cache_126_A_part0 + +def cache_126_H_part0 : List Cell := [(0, -1), (0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, 2), (2, 3), (2, 4)] + +def cache_126_H : List Cell := cache_126_H_part0 + +def cache_126 : ListRow := ⟨cache_126_A, cache_126_H, 5⟩ + +def cache_127_A_part0 : List Cell := [(-4, 0), (-3, -1), (-3, 0), (-2, 0), (-1, 0)] + +def cache_127_A : List Cell := cache_127_A_part0 + +def cache_127_H_part0 : List Cell := [(-4, 0), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, 0), (-1, 1), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1)] + +def cache_127_H : List Cell := cache_127_H_part0 + +def cache_127 : ListRow := ⟨cache_127_A, cache_127_H, 5⟩ + +def cache_128_A_part0 : List Cell := [(-2, 1), (-1, 0), (-1, 1), (0, 1), (1, 1)] + +def cache_128_A : List Cell := cache_128_A_part0 + +def cache_128_H_part0 : List Cell := [(-4, 1), (-3, 1), (-2, 1), (-1, 0), (-1, 1), (0, 0), (0, 1), (1, 0), (1, 1), (1, 2), (2, 1), (2, 2), (3, 1), (3, 2)] + +def cache_128_H : List Cell := cache_128_H_part0 + +def cache_128 : ListRow := ⟨cache_128_A, cache_128_H, 5⟩ + +def cache_129_A_part0 : List Cell := [(-1, -2), (-1, -1), (-1, 0), (-1, 1), (0, -1), (1, 0), (2, 0)] + +def cache_129_A : List Cell := cache_129_A_part0 + +def cache_129_H_part0 : List Cell := [(-2, 1), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (2, 0)] + +def cache_129_H : List Cell := cache_129_H_part0 + +def cache_129 : ListRow := ⟨cache_129_A, cache_129_H, 5⟩ + +def cache_130_A_part0 : List Cell := [(-1, -3), (-1, -2), (-1, -1), (-1, 0), (2, 0)] + +def cache_130_A : List Cell := cache_130_A_part0 + +def cache_130_H_part0 : List Cell := [(-2, -1), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -1), (0, 0), (0, 1), (1, 0), (2, 0), (2, 1), (3, 0), (3, 1), (4, 1)] + +def cache_130_H : List Cell := cache_130_H_part0 + +def cache_130 : ListRow := ⟨cache_130_A, cache_130_H, 6⟩ + +def cache_131_A_part0 : List Cell := [(-1, -2), (0, -4), (0, -3), (0, -2), (0, -1)] + +def cache_131_A : List Cell := cache_131_A_part0 + +def cache_131_H_part0 : List Cell := [(-1, -3), (-1, -2), (-1, 0), (-1, 1), (-1, 2), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1)] + +def cache_131_H : List Cell := cache_131_H_part0 + +def cache_131 : ListRow := ⟨cache_131_A, cache_131_H, 5⟩ + +def cache_132_A_part0 : List Cell := [(1, -3), (1, -2), (1, -1), (1, 0), (1, 1)] + +def cache_132_A : List Cell := cache_132_A_part0 + +def cache_132_H_part0 : List Cell := [(0, -2), (0, -1), (0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3)] + +def cache_132_H : List Cell := cache_132_H_part0 + +def cache_132 : ListRow := ⟨cache_132_A, cache_132_H, 5⟩ + +def cache_133_A_part0 : List Cell := [(-2, 0), (-1, -2), (0, -2), (0, -1), (0, 1)] + +def cache_133_A : List Cell := cache_133_A_part0 + +def cache_133_H_part0 : List Cell := [(-3, 0), (-2, 0), (-1, -3), (-1, -2), (-1, 0), (0, -2), (0, -1), (0, 0), (0, 1), (1, 0), (1, 1), (1, 2), (2, 1), (3, 1)] + +def cache_133_H : List Cell := cache_133_H_part0 + +def cache_133 : ListRow := ⟨cache_133_A, cache_133_H, 5⟩ + +def cache_134_A_part0 : List Cell := [(-1, -3), (-1, -1), (0, -3), (0, -2), (0, -1)] + +def cache_134_A : List Cell := cache_134_A_part0 + +def cache_134_H_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -4), (-1, -3), (-1, -1), (0, -3), (0, -2), (0, -1), (0, 0), (1, -1), (1, 0), (1, 1), (2, 0), (3, 0)] + +def cache_134_H : List Cell := cache_134_H_part0 + +def cache_134 : ListRow := ⟨cache_134_A, cache_134_H, 5⟩ + +def cache_135_A_part0 : List Cell := [(-4, 0), (-3, 0), (-3, 1), (-2, 0), (-1, 0)] + +def cache_135_A : List Cell := cache_135_A_part0 + +def cache_135_H_part0 : List Cell := [(-6, 0), (-5, 0), (-4, 0), (-3, 0), (-3, 1), (-2, 0), (-2, 1), (-1, 0), (-1, 1), (0, 0), (0, 1), (1, 0), (1, 1), (2, 1)] + +def cache_135_H : List Cell := cache_135_H_part0 + +def cache_135 : ListRow := ⟨cache_135_A, cache_135_H, 5⟩ + +def cache_136_A_part0 : List Cell := [(-2, -1), (-1, 2), (0, -1), (0, 1), (0, 2)] + +def cache_136_A : List Cell := cache_136_A_part0 + +def cache_136_H_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -2), (-1, -1), (-1, 0), (-1, 2), (-1, 3), (0, -1), (0, 0), (0, 1), (0, 2), (1, 0), (2, 0), (3, 0)] + +def cache_136_H : List Cell := cache_136_H_part0 + +def cache_136 : ListRow := ⟨cache_136_A, cache_136_H, 5⟩ + +def cache_137_A_part0 : List Cell := [(-1, -4), (-1, -3), (-1, -2), (-1, -1), (2, 0)] + +def cache_137_A : List Cell := cache_137_A_part0 + +def cache_137_H_part0 : List Cell := [(-2, 0), (-2, 1), (-2, 2), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 0), (0, 1), (1, 0), (2, 0)] + +def cache_137_H : List Cell := cache_137_H_part0 + +def cache_137 : ListRow := ⟨cache_137_A, cache_137_H, 6⟩ + +def cache_138_A_part0 : List Cell := [(-2, -1), (-2, 0), (-2, 1), (-1, -1), (-1, 0), (-1, 2), (0, 2)] + +def cache_138_A : List Cell := cache_138_A_part0 + +def cache_138_H_part0 : List Cell := [(-3, 1), (-2, -1), (-2, 0), (-2, 1), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (2, 0)] + +def cache_138_H : List Cell := cache_138_H_part0 + +def cache_138 : ListRow := ⟨cache_138_A, cache_138_H, 4⟩ + +def cache_139_A_part0 : List Cell := [(-3, 0), (-2, -1), (-2, 0), (-2, 1), (-1, -1), (-1, 0), (0, 2)] + +def cache_139_A : List Cell := cache_139_A_part0 + +def cache_139_H_part0 : List Cell := [(-3, 0), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-1, -1), (-1, 0), (0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (2, 0)] + +def cache_139_H : List Cell := cache_139_H_part0 + +def cache_139 : ListRow := ⟨cache_139_A, cache_139_H, 4⟩ + +def cache_140_A_part0 : List Cell := [(-1, -1), (-1, 1), (0, -1), (0, 1), (0, 2)] + +def cache_140_A : List Cell := cache_140_A_part0 + +def cache_140_H_part0 : List Cell := [(-3, 1), (-2, 1), (-1, -2), (-1, -1), (-1, 1), (0, -1), (0, 0), (0, 1), (0, 2), (1, 1), (1, 2), (1, 3), (2, 2), (3, 2)] + +def cache_140_H : List Cell := cache_140_H_part0 + +def cache_140 : ListRow := ⟨cache_140_A, cache_140_H, 5⟩ + +def cache_141_A_part0 : List Cell := [(-5, 0), (-4, 0), (-3, 0), (-2, 0), (-1, 0)] + +def cache_141_A : List Cell := cache_141_A_part0 + +def cache_141_H_part0 : List Cell := [(-6, 0), (-5, 0), (-4, -1), (-4, 0), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, 0), (-1, 1), (0, 0), (0, 1), (1, 0), (1, 1)] + +def cache_141_H : List Cell := cache_141_H_part0 + +def cache_141 : ListRow := ⟨cache_141_A, cache_141_H, 4⟩ + +def cache_142_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0), (-1, 1), (-1, 2)] + +def cache_142_A : List Cell := cache_142_A_part0 + +def cache_142_H_part0 : List Cell := [(-4, -1), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -1), (0, 0), (1, -1), (1, 0), (2, -1)] + +def cache_142_H : List Cell := cache_142_H_part0 + +def cache_142 : ListRow := ⟨cache_142_A, cache_142_H, 5⟩ + +def cache_143_A_part0 : List Cell := [(0, 1), (1, 1), (2, 1), (3, 1)] + +def cache_143_A : List Cell := cache_143_A_part0 + +def cache_143_H_part0 : List Cell := [(-1, 0), (0, 0), (0, 1), (1, 0), (1, 1), (2, 1), (3, 1), (4, 0), (4, 1), (4, 2), (5, 0), (5, 1), (5, 2), (6, 0), (6, 2)] + +def cache_143_H : List Cell := cache_143_H_part0 + +def cache_143 : ListRow := ⟨cache_143_A, cache_143_H, 7⟩ + +def cache_144_A_part0 : List Cell := [(-4, 0), (-3, 0), (-2, 0), (-1, 0)] + +def cache_144_A : List Cell := cache_144_A_part0 + +def cache_144_H_part0 : List Cell := [(-6, 0), (-5, 0), (-4, 0), (-4, 1), (-3, 0), (-3, 1), (-2, 0), (-2, 1), (-1, 0), (-1, 1), (0, 0), (0, 1), (1, 0), (1, 1), (2, 1)] + +def cache_144_H : List Cell := cache_144_H_part0 + +def cache_144 : ListRow := ⟨cache_144_A, cache_144_H, 6⟩ + +def cache_145_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1), (1, -3), (1, -2), (3, -1)] + +def cache_145_A : List Cell := cache_145_A_part0 + +def cache_145_H_part0 : List Cell := [(-1, 0), (-1, 1), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (3, -1)] + +def cache_145_H : List Cell := cache_145_H_part0 + +def cache_145 : ListRow := ⟨cache_145_A, cache_145_H, 6⟩ + +def cache_146_A_part0 : List Cell := [(-2, -1), (-1, -2), (-1, -1), (-1, 0)] + +def cache_146_A : List Cell := cache_146_A_part0 + +def cache_146_H_part0 : List Cell := [(-4, -1), (-3, -1), (-2, -1), (-2, 0), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (2, 0)] + +def cache_146_H : List Cell := cache_146_H_part0 + +def cache_146 : ListRow := ⟨cache_146_A, cache_146_H, 4⟩ + +def cache_147_A_part0 : List Cell := [(-3, -1), (-3, 0), (-2, 0), (-2, 2), (-2, 3), (-1, 0)] + +def cache_147_A : List Cell := cache_147_A_part0 + +def cache_147_H_part0 : List Cell := [(-4, 1), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-2, -1), (-2, 0), (-2, 2), (-2, 3), (-1, 0), (0, -1), (0, 0), (1, -1), (1, 0), (2, -1)] + +def cache_147_H : List Cell := cache_147_H_part0 + +def cache_147 : ListRow := ⟨cache_147_A, cache_147_H, 5⟩ + +def cache_148_A_part0 : List Cell := [(-1, -2), (0, -4), (0, -3), (0, -2), (0, -1), (1, -2)] + +def cache_148_A : List Cell := cache_148_A_part0 + +def cache_148_H_part0 : List Cell := [(-1, -3), (-1, -2), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3)] + +def cache_148_H : List Cell := cache_148_H_part0 + +def cache_148 : ListRow := ⟨cache_148_A, cache_148_H, 6⟩ + +def cache_149_A_part0 : List Cell := [(-2, 1), (-1, -3), (-1, -2), (-1, -1), (-1, 1), (0, 1)] + +def cache_149_A : List Cell := cache_149_A_part0 + +def cache_149_H_part0 : List Cell := [(-3, 1), (-2, 1), (-1, -3), (-1, -2), (-1, -1), (-1, 1), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (2, 0), (3, 0)] + +def cache_149_H : List Cell := cache_149_H_part0 + +def cache_149 : ListRow := ⟨cache_149_A, cache_149_H, 4⟩ + +def cache_150_A_part0 : List Cell := [(-5, 0), (-4, -1), (-4, 0), (-3, 0), (-2, 0), (-1, 0)] + +def cache_150_A : List Cell := cache_150_A_part0 + +def cache_150_H_part0 : List Cell := [(-5, 0), (-4, -1), (-4, 0), (-3, -1), (-3, 0), (-3, 1), (-2, 0), (-2, 1), (-1, 0), (-1, 1), (0, -1), (0, 0), (1, -1), (1, 0), (2, -1)] + +def cache_150_H : List Cell := cache_150_H_part0 + +def cache_150 : ListRow := ⟨cache_150_A, cache_150_H, 6⟩ + +def cache_151_A_part0 : List Cell := [(0, -3), (0, -2), (1, 0), (1, 1), (2, -2), (2, 0)] + +def cache_151_A : List Cell := cache_151_A_part0 + +def cache_151_H_part0 : List Cell := [(-1, 0), (0, -3), (0, -2), (0, -1), (0, 0), (1, 0), (1, 1), (2, -3), (2, -2), (2, -1), (2, 0), (3, -1), (3, 0), (4, -1), (5, -1)] + +def cache_151_H : List Cell := cache_151_H_part0 + +def cache_151 : ListRow := ⟨cache_151_A, cache_151_H, 5⟩ + +def cache_152_A_part0 : List Cell := [(1, -3), (1, -2), (1, -1), (1, 0), (2, 0), (4, -1)] + +def cache_152_A : List Cell := cache_152_A_part0 + +def cache_152_H_part0 : List Cell := [(0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (2, 0), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1), (5, 1)] + +def cache_152_H : List Cell := cache_152_H_part0 + +def cache_152 : ListRow := ⟨cache_152_A, cache_152_H, 6⟩ + +def cache_153_A_part0 : List Cell := [(-3, 0), (-2, -1), (-2, 0), (-2, 1), (-1, -1), (-1, 0)] + +def cache_153_A : List Cell := cache_153_A_part0 + +def cache_153_H_part0 : List Cell := [(-5, 0), (-4, 0), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-1, -1), (-1, 0), (-1, 1), (0, 0), (0, 1), (1, 0), (1, 1), (2, 0)] + +def cache_153_H : List Cell := cache_153_H_part0 + +def cache_153 : ListRow := ⟨cache_153_A, cache_153_H, 5⟩ + +def cache_154_A_part0 : List Cell := [(1, 0), (2, 0), (3, 0), (4, 0)] + +def cache_154_A : List Cell := cache_154_A_part0 + +def cache_154_H_part0 : List Cell := [(-1, -1), (-1, 0), (0, -1), (0, 0), (1, -1), (1, 0), (1, 1), (2, 0), (2, 1), (3, 0), (3, 1), (4, 0), (4, 1), (5, 0), (6, 0)] + +def cache_154_H : List Cell := cache_154_H_part0 + +def cache_154 : ListRow := ⟨cache_154_A, cache_154_H, 6⟩ + +def cache_155_A_part0 : List Cell := [(0, -4), (0, -3), (0, -2), (0, -1)] + +def cache_155_A : List Cell := cache_155_A_part0 + +def cache_155_H_part0 : List Cell := [(-1, -4), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (-1, 2), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1)] + +def cache_155_H : List Cell := cache_155_H_part0 + +def cache_155 : ListRow := ⟨cache_155_A, cache_155_H, 5⟩ + +def cache_156_A_part0 : List Cell := [(-3, -1), (-3, 0), (-3, 1), (-1, -1), (-1, 0)] + +def cache_156_A : List Cell := cache_156_A_part0 + +def cache_156_H_part0 : List Cell := [(-4, -1), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, -1), (0, 0), (1, -1), (1, 0), (2, -1), (2, 0)] + +def cache_156_H : List Cell := cache_156_H_part0 + +def cache_156 : ListRow := ⟨cache_156_A, cache_156_H, 6⟩ + +def cache_157_A_part0 : List Cell := [(0, -1), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1)] + +def cache_157_A : List Cell := cache_157_A_part0 + +def cache_157_H_part0 : List Cell := [(0, -1), (0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3)] + +def cache_157_H : List Cell := cache_157_H_part0 + +def cache_157 : ListRow := ⟨cache_157_A, cache_157_H, 5⟩ + +def cache_158_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1), (1, -2), (2, -1), (3, -1)] + +def cache_158_A : List Cell := cache_158_A_part0 + +def cache_158_H_part0 : List Cell := [(-1, 0), (-1, 1), (-1, 2), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -3), (1, -2), (1, 0), (1, 1), (1, 2), (2, -1), (2, 0), (3, -1)] + +def cache_158_H : List Cell := cache_158_H_part0 + +def cache_158 : ListRow := ⟨cache_158_A, cache_158_H, 5⟩ + +def cache_159_A_part0 : List Cell := [(-1, -2), (0, -4), (0, -3), (0, -2), (0, -1)] + +def cache_159_A : List Cell := cache_159_A_part0 + +def cache_159_H_part0 : List Cell := [(-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, 1), (1, 2), (1, 3)] + +def cache_159_H : List Cell := cache_159_H_part0 + +def cache_159 : ListRow := ⟨cache_159_A, cache_159_H, 6⟩ + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/CacheData04.lean b/lean/OAI/Combinatorics/SnakyCertificate/CacheData04.lean new file mode 100644 index 0000000000000000000000000000000000000000..b7260d3a4adbfee35308269be5ce1b8b3e589087 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/CacheData04.lean @@ -0,0 +1,409 @@ +import OAI.Combinatorics.SnakyCertificate.Lists + +namespace OAI + +namespace SnakyCertificate.Check + +def cache_160_A_part0 : List Cell := [(1, 0), (1, 1), (1, 2), (2, 0), (3, 0)] + +def cache_160_A : List Cell := cache_160_A_part0 + +def cache_160_H_part0 : List Cell := [(-1, -1), (0, -1), (0, 0), (1, 0), (1, 1), (1, 2), (1, 3), (2, 0), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1), (5, 1)] + +def cache_160_H : List Cell := cache_160_H_part0 + +def cache_160 : ListRow := ⟨cache_160_A, cache_160_H, 6⟩ + +def cache_161_A_part0 : List Cell := [(-2, -1), (-2, 0), (-1, -2), (-1, -1), (-1, 0), (0, 2)] + +def cache_161_A : List Cell := cache_161_A_part0 + +def cache_161_H_part0 : List Cell := [(-3, 1), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-1, -2), (-1, -1), (-1, 0), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (2, 0)] + +def cache_161_H : List Cell := cache_161_H_part0 + +def cache_161 : ListRow := ⟨cache_161_A, cache_161_H, 6⟩ + +def cache_162_A_part0 : List Cell := [(-1, -2), (0, -4), (0, -3), (0, -2), (0, -1)] + +def cache_162_A : List Cell := cache_162_A_part0 + +def cache_162_H_part0 : List Cell := [(-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2)] + +def cache_162_H : List Cell := cache_162_H_part0 + +def cache_162 : ListRow := ⟨cache_162_A, cache_162_H, 6⟩ + +def cache_163_A_part0 : List Cell := [(-3, -1), (-3, 0), (-2, 0), (-1, 0)] + +def cache_163_A : List Cell := cache_163_A_part0 + +def cache_163_H_part0 : List Cell := [(-4, 0), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1), (2, 1)] + +def cache_163_H : List Cell := cache_163_H_part0 + +def cache_163 : ListRow := ⟨cache_163_A, cache_163_H, 5⟩ + +def cache_164_A_part0 : List Cell := [(-1, -3), (-1, -2), (-1, -1), (-1, 0), (2, 0)] + +def cache_164_A : List Cell := cache_164_A_part0 + +def cache_164_H_part0 : List Cell := [(-2, -1), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, 0), (0, 1), (1, 0), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, -1), (4, 1)] + +def cache_164_H : List Cell := cache_164_H_part0 + +def cache_164 : ListRow := ⟨cache_164_A, cache_164_H, 7⟩ + +def cache_165_A_part0 : List Cell := [(0, 1), (1, 1), (1, 2), (1, 3), (2, 1)] + +def cache_165_A : List Cell := cache_165_A_part0 + +def cache_165_H_part0 : List Cell := [(-1, 0), (0, 0), (0, 1), (1, 1), (1, 2), (1, 3), (1, 4), (2, 1), (3, 0), (3, 1), (3, 2), (4, 0), (4, 1), (4, 2), (5, 0), (5, 2)] + +def cache_165_H : List Cell := cache_165_H_part0 + +def cache_165 : ListRow := ⟨cache_165_A, cache_165_H, 7⟩ + +def cache_166_A_part0 : List Cell := [(-1, -1), (-1, 0), (0, 2), (0, 3), (1, 0)] + +def cache_166_A : List Cell := cache_166_A_part0 + +def cache_166_H_part0 : List Cell := [(-2, -1), (-1, -1), (-1, 0), (0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, -1), (4, 1)] + +def cache_166_H : List Cell := cache_166_H_part0 + +def cache_166 : ListRow := ⟨cache_166_A, cache_166_H, 7⟩ + +def cache_167_A_part0 : List Cell := [(-3, 0), (-2, -1), (-2, 0), (-1, -1), (-1, 0)] + +def cache_167_A : List Cell := cache_167_A_part0 + +def cache_167_H_part0 : List Cell := [(-5, 0), (-5, 1), (-4, 0), (-4, 1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, 0), (0, 1), (1, 0), (1, 1), (2, 0), (2, 1)] + +def cache_167_H : List Cell := cache_167_H_part0 + +def cache_167 : ListRow := ⟨cache_167_A, cache_167_H, 5⟩ + +def cache_168_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1), (1, 0), (3, -1)] + +def cache_168_A : List Cell := cache_168_A_part0 + +def cache_168_H_part0 : List Cell := [(-1, 0), (-1, 1), (0, -3), (0, -2), (0, -1), (0, 0), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, -1), (4, 1)] + +def cache_168_H : List Cell := cache_168_H_part0 + +def cache_168 : ListRow := ⟨cache_168_A, cache_168_H, 7⟩ + +def cache_169_A_part0 : List Cell := [(0, 2), (1, -1), (1, 0), (2, 0), (3, 0)] + +def cache_169_A : List Cell := cache_169_A_part0 + +def cache_169_H_part0 : List Cell := [(-1, 1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -1), (1, 0), (2, 0), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1), (5, 1)] + +def cache_169_H : List Cell := cache_169_H_part0 + +def cache_169 : ListRow := ⟨cache_169_A, cache_169_H, 6⟩ + +def cache_170_A_part0 : List Cell := [(-4, -1), (-3, 0), (-2, 0), (-2, 1), (-1, 0)] + +def cache_170_A : List Cell := cache_170_A_part0 + +def cache_170_H_part0 : List Cell := [(-4, -1), (-3, -1), (-3, 0), (-2, 0), (-2, 1), (-1, 0), (-1, 1), (0, -1), (0, 0), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, 1)] + +def cache_170_H : List Cell := cache_170_H_part0 + +def cache_170 : ListRow := ⟨cache_170_A, cache_170_H, 6⟩ + +def cache_171_A_part0 : List Cell := [(-3, -2), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-1, -1), (0, -1)] + +def cache_171_A : List Cell := cache_171_A_part0 + +def cache_171_H_part0 : List Cell := [(-4, 1), (-4, 2), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 0), (1, 0)] + +def cache_171_H : List Cell := cache_171_H_part0 + +def cache_171 : ListRow := ⟨cache_171_A, cache_171_H, 6⟩ + +def cache_172_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0)] + +def cache_172_A : List Cell := cache_172_A_part0 + +def cache_172_H_part0 : List Cell := [(-5, -1), (-4, -1), (-4, 0), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1), (2, 1)] + +def cache_172_H : List Cell := cache_172_H_part0 + +def cache_172 : ListRow := ⟨cache_172_A, cache_172_H, 6⟩ + +def cache_173_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0)] + +def cache_173_A : List Cell := cache_173_A_part0 + +def cache_173_H_part0 : List Cell := [(-5, -1), (-4, -1), (-4, 0), (-3, -1), (-3, 0), (-2, 0), (-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1), (2, 1)] + +def cache_173_H : List Cell := cache_173_H_part0 + +def cache_173 : ListRow := ⟨cache_173_A, cache_173_H, 6⟩ + +def cache_174_A_part0 : List Cell := [(-1, -2), (-1, -1), (0, -3), (0, -2), (0, -1)] + +def cache_174_A : List Cell := cache_174_A_part0 + +def cache_174_H_part0 : List Cell := [(-2, -1), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (3, 0)] + +def cache_174_H : List Cell := cache_174_H_part0 + +def cache_174 : ListRow := ⟨cache_174_A, cache_174_H, 6⟩ + +def cache_175_A_part0 : List Cell := [(-4, 0), (-3, 0), (-2, 0), (-1, 0)] + +def cache_175_A : List Cell := cache_175_A_part0 + +def cache_175_H_part0 : List Cell := [(-5, 0), (-4, 0), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1)] + +def cache_175_H : List Cell := cache_175_H_part0 + +def cache_175 : ListRow := ⟨cache_175_A, cache_175_H, 6⟩ + +def cache_176_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0)] + +def cache_176_A : List Cell := cache_176_A_part0 + +def cache_176_H_part0 : List Cell := [(-5, -1), (-4, -1), (-4, 0), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, 0), (-1, 1), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1), (2, 1)] + +def cache_176_H : List Cell := cache_176_H_part0 + +def cache_176 : ListRow := ⟨cache_176_A, cache_176_H, 6⟩ + +def cache_177_A_part0 : List Cell := [(-1, -3), (-1, -2), (-1, -1), (-1, 0), (2, -2), (2, 0)] + +def cache_177_A : List Cell := cache_177_A_part0 + +def cache_177_H_part0 : List Cell := [(-2, -1), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, -3), (2, -2), (2, -1), (2, 0), (3, -1)] + +def cache_177_H : List Cell := cache_177_H_part0 + +def cache_177 : ListRow := ⟨cache_177_A, cache_177_H, 6⟩ + +def cache_178_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1), (1, -2), (2, -1), (3, -1)] + +def cache_178_A : List Cell := cache_178_A_part0 + +def cache_178_H_part0 : List Cell := [(-1, 0), (-1, 1), (-1, 2), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -3), (1, -2), (1, -1), (1, 1), (1, 2), (1, 3), (2, -1), (3, -1)] + +def cache_178_H : List Cell := cache_178_H_part0 + +def cache_178 : ListRow := ⟨cache_178_A, cache_178_H, 6⟩ + +def cache_179_A_part0 : List Cell := [(-3, -1), (-3, 0), (-2, 0), (-1, -1), (-1, 0), (-1, 1)] + +def cache_179_A : List Cell := cache_179_A_part0 + +def cache_179_H_part0 : List Cell := [(-4, -1), (-3, -1), (-3, 0), (-2, 0), (-2, 1), (-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 0), (1, -1), (1, 0), (2, -1), (2, 0), (3, -1), (3, 0), (4, -1)] + +def cache_179_H : List Cell := cache_179_H_part0 + +def cache_179 : ListRow := ⟨cache_179_A, cache_179_H, 7⟩ + +def cache_180_A_part0 : List Cell := [(0, -4), (0, -3), (0, -2), (0, -1)] + +def cache_180_A : List Cell := cache_180_A_part0 + +def cache_180_H_part0 : List Cell := [(-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2)] + +def cache_180_H : List Cell := cache_180_H_part0 + +def cache_180 : ListRow := ⟨cache_180_A, cache_180_H, 6⟩ + +def cache_181_A_part0 : List Cell := [(1, -2), (1, -1), (1, 0), (2, 1)] + +def cache_181_A : List Cell := cache_181_A_part0 + +def cache_181_H_part0 : List Cell := [(-2, 0), (-1, 0), (0, 0), (0, 1), (0, 2), (0, 3), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (2, 0), (2, 1), (3, 0), (3, 1), (4, 1), (5, 1)] + +def cache_181_H : List Cell := cache_181_H_part0 + +def cache_181 : ListRow := ⟨cache_181_A, cache_181_H, 5⟩ + +def cache_182_A_part0 : List Cell := [(1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (3, 2)] + +def cache_182_A : List Cell := cache_182_A_part0 + +def cache_182_H_part0 : List Cell := [(-1, 0), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (4, -1), (4, 0), (4, 1), (5, 0)] + +def cache_182_H : List Cell := cache_182_H_part0 + +def cache_182 : ListRow := ⟨cache_182_A, cache_182_H, 5⟩ + +def cache_183_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0)] + +def cache_183_A : List Cell := cache_183_A_part0 + +def cache_183_H_part0 : List Cell := [(-5, -1), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-1, 0), (0, -1), (0, 0), (1, -1), (1, 0), (2, -1)] + +def cache_183_H : List Cell := cache_183_H_part0 + +def cache_183 : ListRow := ⟨cache_183_A, cache_183_H, 6⟩ + +def cache_184_A_part0 : List Cell := [(0, -3), (1, -4), (1, -3), (2, -3), (2, -1), (2, 0), (3, -3), (3, -1)] + +def cache_184_A : List Cell := cache_184_A_part0 + +def cache_184_H_part0 : List Cell := [(-1, -2), (-1, 0), (0, -3), (0, -2), (0, -1), (0, 0), (1, -4), (1, -3), (1, -1), (1, 0), (2, -3), (2, -1), (2, 0), (3, -3), (3, -1), (4, -1), (5, -1)] + +def cache_184_H : List Cell := cache_184_H_part0 + +def cache_184 : ListRow := ⟨cache_184_A, cache_184_H, 4⟩ + +def cache_185_A_part0 : List Cell := [(-1, -3), (-1, -1), (0, -3), (0, -2), (0, -1)] + +def cache_185_A : List Cell := cache_185_A_part0 + +def cache_185_H_part0 : List Cell := [(-2, -1), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, 0), (1, 1), (1, 2), (2, 0), (3, 0)] + +def cache_185_H : List Cell := cache_185_H_part0 + +def cache_185 : ListRow := ⟨cache_185_A, cache_185_H, 6⟩ + +def cache_186_A_part0 : List Cell := [(-4, 0), (-3, 0), (-2, 0), (-1, 0)] + +def cache_186_A : List Cell := cache_186_A_part0 + +def cache_186_H_part0 : List Cell := [(-5, -1), (-5, 0), (-4, -1), (-4, 0), (-3, -1), (-3, 0), (-3, 1), (-2, 0), (-2, 1), (-1, 0), (-1, 1), (0, -1), (0, 0), (1, -1), (1, 0), (2, -1), (2, 0)] + +def cache_186_H : List Cell := cache_186_H_part0 + +def cache_186 : ListRow := ⟨cache_186_A, cache_186_H, 5⟩ + +def cache_187_A_part0 : List Cell := [(0, -2), (0, -1), (1, -3), (1, -1), (2, -1), (3, -1)] + +def cache_187_A : List Cell := cache_187_A_part0 + +def cache_187_H_part0 : List Cell := [(-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -3), (1, -2), (1, -1), (1, 1), (1, 2), (1, 3), (2, -1), (3, -1)] + +def cache_187_H : List Cell := cache_187_H_part0 + +def cache_187 : ListRow := ⟨cache_187_A, cache_187_H, 7⟩ + +def cache_188_A_part0 : List Cell := [(1, -3), (1, -2), (1, -1), (1, 0), (2, 0), (3, -2), (4, -2), (4, -1)] + +def cache_188_A : List Cell := cache_188_A_part0 + +def cache_188_H_part0 : List Cell := [(0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (2, 0), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (4, -2), (4, -1), (4, 0), (4, 1), (5, 1)] + +def cache_188_H : List Cell := cache_188_H_part0 + +def cache_188 : ListRow := ⟨cache_188_A, cache_188_H, 6⟩ + +def cache_189_A_part0 : List Cell := [(-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, -1)] + +def cache_189_A : List Cell := cache_189_A_part0 + +def cache_189_H_part0 : List Cell := [(-4, 0), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, -2), (-1, -1), (-1, 0), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (2, 0)] + +def cache_189_H : List Cell := cache_189_H_part0 + +def cache_189 : ListRow := ⟨cache_189_A, cache_189_H, 6⟩ + +def cache_190_A_part0 : List Cell := [(-3, 0), (-2, -1), (-2, 0), (-1, 0)] + +def cache_190_A : List Cell := cache_190_A_part0 + +def cache_190_H_part0 : List Cell := [(-4, 0), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, -2), (-1, -1), (-1, 0), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -1), (1, 0), (1, 1), (2, 0), (2, 1)] + +def cache_190_H : List Cell := cache_190_H_part0 + +def cache_190 : ListRow := ⟨cache_190_A, cache_190_H, 7⟩ + +def cache_191_A_part0 : List Cell := [(0, -2), (0, -1), (1, -2), (1, -1), (2, -1), (3, -1), (3, 0)] + +def cache_191_A : List Cell := cache_191_A_part0 + +def cache_191_H_part0 : List Cell := [(-1, 0), (-1, 1), (-1, 2), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0)] + +def cache_191_H : List Cell := cache_191_H_part0 + +def cache_191 : ListRow := ⟨cache_191_A, cache_191_H, 7⟩ + +def cache_192_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1), (2, -1)] + +def cache_192_A : List Cell := cache_192_A_part0 + +def cache_192_H_part0 : List Cell := [(-2, 0), (-1, -4), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (-1, 2), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (1, 2), (2, -1), (3, -1)] + +def cache_192_H : List Cell := cache_192_H_part0 + +def cache_192 : ListRow := ⟨cache_192_A, cache_192_H, 6⟩ + +def cache_193_A_part0 : List Cell := [(-1, -1), (-1, 0), (1, -1), (1, 0), (2, 0)] + +def cache_193_A : List Cell := cache_193_A_part0 + +def cache_193_H_part0 : List Cell := [(-2, -1), (-1, -1), (-1, 0), (0, 0), (1, -1), (1, 0), (2, -1), (2, 0), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1), (5, 0), (5, 1), (6, -1)] + +def cache_193_H : List Cell := cache_193_H_part0 + +def cache_193 : ListRow := ⟨cache_193_A, cache_193_H, 7⟩ + +def cache_194_A_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -1), (-1, 0), (-1, 1)] + +def cache_194_A : List Cell := cache_194_A_part0 + +def cache_194_H_part0 : List Cell := [(-4, -1), (-4, 1), (-3, -1), (-3, 1), (-2, -1), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (0, 0), (0, 1), (1, 0), (2, 0)] + +def cache_194_H : List Cell := cache_194_H_part0 + +def cache_194 : ListRow := ⟨cache_194_A, cache_194_H, 5⟩ + +def cache_195_A_part0 : List Cell := [(-3, -1), (-3, 0), (-2, 0), (-1, -1), (-1, 0)] + +def cache_195_A : List Cell := cache_195_A_part0 + +def cache_195_H_part0 : List Cell := [(-4, -1), (-3, -1), (-3, 0), (-2, 0), (-1, -1), (-1, 0), (0, -1), (0, 0), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, -1)] + +def cache_195_H : List Cell := cache_195_H_part0 + +def cache_195 : ListRow := ⟨cache_195_A, cache_195_H, 7⟩ + +def cache_196_A_part0 : List Cell := [(-1, -1), (1, -3), (1, -2), (1, -1), (1, 0)] + +def cache_196_A : List Cell := cache_196_A_part0 + +def cache_196_H_part0 : List Cell := [(-1, -1), (0, -1), (0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1), (5, 1)] + +def cache_196_H : List Cell := cache_196_H_part0 + +def cache_196 : ListRow := ⟨cache_196_A, cache_196_H, 8⟩ + +def cache_197_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0)] + +def cache_197_A : List Cell := cache_197_A_part0 + +def cache_197_H_part0 : List Cell := [(-5, -1), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, 0), (-1, 0), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1), (2, 1)] + +def cache_197_H : List Cell := cache_197_H_part0 + +def cache_197 : ListRow := ⟨cache_197_A, cache_197_H, 6⟩ + +def cache_198_A_part0 : List Cell := [(-4, 0), (-3, 0), (-2, 0), (-1, -1), (-1, 0)] + +def cache_198_A : List Cell := cache_198_A_part0 + +def cache_198_H_part0 : List Cell := [(-5, 1), (-4, 0), (-4, 1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, -1)] + +def cache_198_H : List Cell := cache_198_H_part0 + +def cache_198 : ListRow := ⟨cache_198_A, cache_198_H, 6⟩ + +def cache_199_A_part0 : List Cell := [(-1, -1), (0, -3), (0, -2), (0, -1)] + +def cache_199_A : List Cell := cache_199_A_part0 + +def cache_199_H_part0 : List Cell := [(-2, -1), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -4), (1, -3), (1, -2), (1, 0), (1, 1), (1, 2), (2, 0), (3, 0)] + +def cache_199_H : List Cell := cache_199_H_part0 + +def cache_199 : ListRow := ⟨cache_199_A, cache_199_H, 6⟩ + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/CacheData05.lean b/lean/OAI/Combinatorics/SnakyCertificate/CacheData05.lean new file mode 100644 index 0000000000000000000000000000000000000000..5ba35f975b1a11f2701a0b9ff1c71b15892982a5 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/CacheData05.lean @@ -0,0 +1,409 @@ +import OAI.Combinatorics.SnakyCertificate.Lists + +namespace OAI + +namespace SnakyCertificate.Check + +def cache_200_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1), (2, -1)] + +def cache_200_A : List Cell := cache_200_A_part0 + +def cache_200_H_part0 : List Cell := [(-2, 0), (-1, 0), (-1, 1), (-1, 2), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (2, -1), (3, -1)] + +def cache_200_H : List Cell := cache_200_H_part0 + +def cache_200 : ListRow := ⟨cache_200_A, cache_200_H, 6⟩ + +def cache_201_A_part0 : List Cell := [(1, -2), (1, -1), (1, 0), (1, 1), (1, 2)] + +def cache_201_A : List Cell := cache_201_A_part0 + +def cache_201_H_part0 : List Cell := [(-2, 0), (-1, 0), (0, -1), (0, 0), (0, 2), (0, 3), (0, 4), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, 0), (2, 1), (2, 2), (3, 1), (4, 1)] + +def cache_201_H : List Cell := cache_201_H_part0 + +def cache_201 : ListRow := ⟨cache_201_A, cache_201_H, 5⟩ + +def cache_202_A_part0 : List Cell := [(-4, 0), (-3, -1), (-3, 0), (-2, 0), (-1, 0)] + +def cache_202_A : List Cell := cache_202_A_part0 + +def cache_202_H_part0 : List Cell := [(-4, 0), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-2, 1), (-1, 0), (-1, 1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, -1), (3, 1)] + +def cache_202_H : List Cell := cache_202_H_part0 + +def cache_202 : ListRow := ⟨cache_202_A, cache_202_H, 7⟩ + +def cache_203_A_part0 : List Cell := [(-4, -1), (-2, -1), (-2, 0), (-1, 0)] + +def cache_203_A : List Cell := cache_203_A_part0 + +def cache_203_H_part0 : List Cell := [(-4, -1), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, -1), (3, 1)] + +def cache_203_H : List Cell := cache_203_H_part0 + +def cache_203 : ListRow := ⟨cache_203_A, cache_203_H, 7⟩ + +def cache_204_A_part0 : List Cell := [(0, -3), (0, -1), (1, -4), (1, -3), (2, -1)] + +def cache_204_A : List Cell := cache_204_A_part0 + +def cache_204_H_part0 : List Cell := [(-1, 0), (0, -3), (0, -2), (0, -1), (0, 0), (1, -4), (1, -3), (1, -2), (1, -1), (2, -1), (3, -2), (3, -1), (3, 0), (4, -2), (4, -1), (4, 0), (5, -2), (5, 0)] + +def cache_204_H : List Cell := cache_204_H_part0 + +def cache_204 : ListRow := ⟨cache_204_A, cache_204_H, 8⟩ + +def cache_205_A_part0 : List Cell := [(-1, -4), (-1, -3), (-1, -2), (-1, -1), (2, -1)] + +def cache_205_A : List Cell := cache_205_A_part0 + +def cache_205_H_part0 : List Cell := [(-2, 0), (-2, 1), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, -1), (3, 1)] + +def cache_205_H : List Cell := cache_205_H_part0 + +def cache_205 : ListRow := ⟨cache_205_A, cache_205_H, 8⟩ + +def cache_206_A_part0 : List Cell := [(0, 2), (1, -1), (1, 0), (2, 0), (3, 0)] + +def cache_206_A : List Cell := cache_206_A_part0 + +def cache_206_H_part0 : List Cell := [(-2, 0), (-1, 0), (-1, 1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -1), (1, 0), (2, -1), (2, 0), (3, -1), (3, 0), (4, -1), (4, 0), (5, -1), (5, 0), (6, -1)] + +def cache_206_H : List Cell := cache_206_H_part0 + +def cache_206 : ListRow := ⟨cache_206_A, cache_206_H, 6⟩ + +def cache_207_A_part0 : List Cell := [(0, 2), (1, -1), (1, 0), (2, 0), (3, 0)] + +def cache_207_A : List Cell := cache_207_A_part0 + +def cache_207_H_part0 : List Cell := [(-1, 1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -1), (1, 0), (2, -1), (2, 0), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1), (5, 0), (5, 1), (6, -1)] + +def cache_207_H : List Cell := cache_207_H_part0 + +def cache_207 : ListRow := ⟨cache_207_A, cache_207_H, 6⟩ + +def cache_208_A_part0 : List Cell := [(-4, 0), (-3, 0), (-2, -1), (-2, 0), (-1, 0)] + +def cache_208_A : List Cell := cache_208_A_part0 + +def cache_208_H_part0 : List Cell := [(-5, 1), (-4, 0), (-4, 1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, -1)] + +def cache_208_H : List Cell := cache_208_H_part0 + +def cache_208 : ListRow := ⟨cache_208_A, cache_208_H, 6⟩ + +def cache_209_A_part0 : List Cell := [(-3, 2), (-2, -1), (-2, 2), (-1, -1), (-1, 2), (0, -1), (0, 2)] + +def cache_209_A : List Cell := cache_209_A_part0 + +def cache_209_H_part0 : List Cell := [(-3, -1), (-3, 2), (-2, -1), (-2, 2), (-1, -1), (-1, 0), (-1, 2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 2), (1, 3), (2, 0), (2, 3), (3, 0)] + +def cache_209_H : List Cell := cache_209_H_part0 + +def cache_209 : ListRow := ⟨cache_209_A, cache_209_H, 5⟩ + +def cache_210_A_part0 : List Cell := [(-3, 0), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (-1, 2)] + +def cache_210_A : List Cell := cache_210_A_part0 + +def cache_210_H_part0 : List Cell := [(-3, 0), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (-1, 2), (-1, 3), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1)] + +def cache_210_H : List Cell := cache_210_H_part0 + +def cache_210 : ListRow := ⟨cache_210_A, cache_210_H, 6⟩ + +def cache_211_A_part0 : List Cell := [(-3, -1), (-3, 0), (-3, 1), (-2, 0), (-1, 0)] + +def cache_211_A : List Cell := cache_211_A_part0 + +def cache_211_H_part0 : List Cell := [(-4, -1), (-3, -1), (-3, 0), (-3, 1), (-2, 0), (-2, 1), (-1, 0), (0, -1), (0, 0), (1, -1), (1, 0), (2, -1)] + +def cache_211_H : List Cell := cache_211_H_part0 + +def cache_211 : ListRow := ⟨cache_211_A, cache_211_H, 5⟩ + +def cache_212_A_part0 : List Cell := [(-3, -2), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 1), (-1, -1), (0, -1)] + +def cache_212_A : List Cell := cache_212_A_part0 + +def cache_212_H_part0 : List Cell := [(-4, 1), (-4, 2), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 1), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (0, -1), (0, 0), (0, 1), (0, 2), (1, 0), (1, 2)] + +def cache_212_H : List Cell := cache_212_H_part0 + +def cache_212 : ListRow := ⟨cache_212_A, cache_212_H, 7⟩ + +def cache_213_A_part0 : List Cell := [(-1, -1), (-1, 0), (0, -1), (1, 0), (2, 0), (2, 1)] + +def cache_213_A : List Cell := cache_213_A_part0 + +def cache_213_H_part0 : List Cell := [(-2, 1), (-2, 2), (-2, 3), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (3, 1)] + +def cache_213_H : List Cell := cache_213_H_part0 + +def cache_213 : ListRow := ⟨cache_213_A, cache_213_H, 8⟩ + +def cache_214_A_part0 : List Cell := [(0, -4), (0, -3), (0, -2), (0, -1), (1, -3), (3, -2)] + +def cache_214_A : List Cell := cache_214_A_part0 + +def cache_214_H_part0 : List Cell := [(-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -3), (1, -2), (1, 1), (1, 2), (1, 3), (2, -2), (3, -2)] + +def cache_214_H : List Cell := cache_214_H_part0 + +def cache_214 : ListRow := ⟨cache_214_A, cache_214_H, 7⟩ + +def cache_215_A_part0 : List Cell := [(-2, -1), (-1, -1), (0, -1), (0, 1)] + +def cache_215_A : List Cell := cache_215_A_part0 + +def cache_215_H_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -2), (-1, -1), (-1, 2), (-1, 3), (-1, 4), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -1), (1, 0), (1, 2), (1, 3), (1, 4), (2, 0), (3, 0)] + +def cache_215_H : List Cell := cache_215_H_part0 + +def cache_215 : ListRow := ⟨cache_215_A, cache_215_H, 7⟩ + +def cache_216_A_part0 : List Cell := [(-4, 0), (-3, 0), (-2, 0), (-1, 0)] + +def cache_216_A : List Cell := cache_216_A_part0 + +def cache_216_H_part0 : List Cell := [(-5, -1), (-4, -1), (-4, 0), (-3, -1), (-3, 0), (-3, 1), (-2, 0), (-2, 1), (-1, 0), (-1, 1), (0, -1), (0, 0), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, 1)] + +def cache_216_H : List Cell := cache_216_H_part0 + +def cache_216 : ListRow := ⟨cache_216_A, cache_216_H, 6⟩ + +def cache_217_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0)] + +def cache_217_A : List Cell := cache_217_A_part0 + +def cache_217_H_part0 : List Cell := [(-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-2, -2), (-2, -1), (-2, 0), (-1, 0), (-1, 1), (0, 0), (0, 1), (1, 0), (1, 1), (2, 1)] + +def cache_217_H : List Cell := cache_217_H_part0 + +def cache_217 : ListRow := ⟨cache_217_A, cache_217_H, 7⟩ + +def cache_218_A_part0 : List Cell := [(-1, -1), (-1, 0), (-1, 1), (-1, 2), (0, -1), (1, 2)] + +def cache_218_A : List Cell := cache_218_A_part0 + +def cache_218_H_part0 : List Cell := [(-3, 0), (-2, 0), (-2, 1), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -1), (0, 0), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, -1), (2, 0), (2, 1), (3, 0)] + +def cache_218_H : List Cell := cache_218_H_part0 + +def cache_218 : ListRow := ⟨cache_218_A, cache_218_H, 6⟩ + +def cache_219_A_part0 : List Cell := [(-1, 0), (-1, 1), (-1, 2), (0, -1), (1, -1), (1, 0), (1, 1)] + +def cache_219_A : List Cell := cache_219_A_part0 + +def cache_219_H_part0 : List Cell := [(-2, 1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -1), (0, 0), (1, -1), (1, 0), (1, 1), (2, 0), (2, 1), (3, 0), (3, 1), (4, 0), (4, 1), (5, 0), (5, 1), (6, 1)] + +def cache_219_H : List Cell := cache_219_H_part0 + +def cache_219 : ListRow := ⟨cache_219_A, cache_219_H, 8⟩ + +def cache_220_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0)] + +def cache_220_A : List Cell := cache_220_A_part0 + +def cache_220_H_part0 : List Cell := [(-5, 0), (-4, 0), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, -1)] + +def cache_220_H : List Cell := cache_220_H_part0 + +def cache_220 : ListRow := ⟨cache_220_A, cache_220_H, 7⟩ + +def cache_221_A_part0 : List Cell := [(-3, -1), (-3, 0), (-2, 0), (-1, 0)] + +def cache_221_A : List Cell := cache_221_A_part0 + +def cache_221_H_part0 : List Cell := [(-4, -1), (-3, -1), (-3, 0), (-2, 0), (-2, 1), (-1, 0), (-1, 1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, 1)] + +def cache_221_H : List Cell := cache_221_H_part0 + +def cache_221 : ListRow := ⟨cache_221_A, cache_221_H, 7⟩ + +def cache_222_A_part0 : List Cell := [(-2, 0), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -3), (0, -2)] + +def cache_222_A : List Cell := cache_222_A_part0 + +def cache_222_H_part0 : List Cell := [(-2, -1), (-2, 0), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -3), (0, -2), (0, 0), (0, 1), (1, -2), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, -1), (3, 1)] + +def cache_222_H : List Cell := cache_222_H_part0 + +def cache_222 : ListRow := ⟨cache_222_A, cache_222_H, 6⟩ + +def cache_223_A_part0 : List Cell := [(-3, 0), (-2, -1), (-2, 0), (-1, 0)] + +def cache_223_A : List Cell := cache_223_A_part0 + +def cache_223_H_part0 : List Cell := [(-5, 0), (-4, 0), (-3, 0), (-2, -1), (-2, 0), (-1, -2), (-1, -1), (-1, 0), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, -1)] + +def cache_223_H : List Cell := cache_223_H_part0 + +def cache_223 : ListRow := ⟨cache_223_A, cache_223_H, 7⟩ + +def cache_224_A_part0 : List Cell := [(-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -2), (1, -2), (2, -2)] + +def cache_224_A : List Cell := cache_224_A_part0 + +def cache_224_H_part0 : List Cell := [(-2, 0), (-2, 1), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -2), (0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (2, -2), (2, -1), (2, 0), (2, 1), (3, -1), (3, 1)] + +def cache_224_H : List Cell := cache_224_H_part0 + +def cache_224 : ListRow := ⟨cache_224_A, cache_224_H, 8⟩ + +def cache_225_A_part0 : List Cell := [(1, -2), (1, -1), (1, 0), (2, 0), (3, 0)] + +def cache_225_A : List Cell := cache_225_A_part0 + +def cache_225_H_part0 : List Cell := [(-1, 0), (-1, 1), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -2), (1, -1), (1, 0), (2, 0), (2, 1), (2, 2), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (4, -1), (4, 1)] + +def cache_225_H : List Cell := cache_225_H_part0 + +def cache_225 : ListRow := ⟨cache_225_A, cache_225_H, 7⟩ + +def cache_226_A_part0 : List Cell := [(-3, -1), (-3, 0), (-1, -1), (-1, 0)] + +def cache_226_A : List Cell := cache_226_A_part0 + +def cache_226_H_part0 : List Cell := [(-4, -1), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, -1), (0, 0), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, -1), (4, 1)] + +def cache_226_H : List Cell := cache_226_H_part0 + +def cache_226 : ListRow := ⟨cache_226_A, cache_226_H, 8⟩ + +def cache_227_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1), (1, -2), (1, 0), (2, -2), (3, -2)] + +def cache_227_A : List Cell := cache_227_A_part0 + +def cache_227_H_part0 : List Cell := [(-1, 0), (-1, 1), (0, -3), (0, -2), (0, -1), (0, 0), (1, -2), (1, 0), (1, 1), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (3, -2), (3, -1), (3, 0), (3, 1), (4, -1), (4, 1)] + +def cache_227_H : List Cell := cache_227_H_part0 + +def cache_227 : ListRow := ⟨cache_227_A, cache_227_H, 8⟩ + +def cache_228_A_part0 : List Cell := [(1, -2), (1, -1), (1, 0), (1, 1), (1, 2)] + +def cache_228_A : List Cell := cache_228_A_part0 + +def cache_228_H_part0 : List Cell := [(-2, 0), (-1, 0), (0, -1), (0, 0), (0, 1), (0, 3), (0, 4), (0, 5), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, 0), (2, 1), (2, 2), (3, 1), (4, 1)] + +def cache_228_H : List Cell := cache_228_H_part0 + +def cache_228 : ListRow := ⟨cache_228_A, cache_228_H, 6⟩ + +def cache_229_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1), (1, -2), (2, -2), (3, -2)] + +def cache_229_A : List Cell := cache_229_A_part0 + +def cache_229_H_part0 : List Cell := [(-1, 0), (-1, 1), (-1, 2), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (2, -2), (2, -1), (2, 0), (3, -2), (3, -1), (4, -1)] + +def cache_229_H : List Cell := cache_229_H_part0 + +def cache_229 : ListRow := ⟨cache_229_A, cache_229_H, 7⟩ + +def cache_230_A_part0 : List Cell := [(0, 1), (2, 0), (2, 1), (3, 1)] + +def cache_230_A : List Cell := cache_230_A_part0 + +def cache_230_H_part0 : List Cell := [(-1, 0), (0, 0), (0, 1), (1, 0), (1, 1), (2, 0), (2, 1), (3, 0), (3, 1), (4, 0), (4, 1), (4, 2), (5, 0), (5, 1), (5, 2), (6, 0), (6, 1), (6, 2), (7, 0), (7, 2)] + +def cache_230_H : List Cell := cache_230_H_part0 + +def cache_230 : ListRow := ⟨cache_230_A, cache_230_H, 8⟩ + +def cache_231_A_part0 : List Cell := [(1, -3), (1, -2), (1, -1), (1, 0), (2, -3), (2, -2)] + +def cache_231_A : List Cell := cache_231_A_part0 + +def cache_231_H_part0 : List Cell := [(0, -1), (0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (2, -3), (2, -2), (2, 0), (2, 1), (3, -2), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1), (5, 1)] + +def cache_231_H : List Cell := cache_231_H_part0 + +def cache_231 : ListRow := ⟨cache_231_A, cache_231_H, 7⟩ + +def cache_232_A_part0 : List Cell := [(-2, 1), (-1, -1), (-1, 1), (0, -1), (0, 1)] + +def cache_232_A : List Cell := cache_232_A_part0 + +def cache_232_H_part0 : List Cell := [(-3, 1), (-2, 1), (-1, -2), (-1, -1), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, 0), (3, 0)] + +def cache_232_H : List Cell := cache_232_H_part0 + +def cache_232 : ListRow := ⟨cache_232_A, cache_232_H, 7⟩ + +def cache_233_A_part0 : List Cell := [(-1, -2), (0, -2), (0, -1), (1, -2), (2, -2), (2, -1), (2, 1)] + +def cache_233_A : List Cell := cache_233_A_part0 + +def cache_233_H_part0 : List Cell := [(-2, -3), (-1, -3), (-1, -2), (-1, 0), (0, -2), (0, -1), (0, 0), (0, 1), (1, -3), (1, -2), (1, 0), (2, -2), (2, -1), (2, 0), (2, 1), (3, 0), (3, 1), (3, 2), (4, 1), (5, 1)] + +def cache_233_H : List Cell := cache_233_H_part0 + +def cache_233 : ListRow := ⟨cache_233_A, cache_233_H, 6⟩ + +def cache_234_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1), (1, -2), (2, -1), (3, -1)] + +def cache_234_A : List Cell := cache_234_A_part0 + +def cache_234_H_part0 : List Cell := [(-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -1), (3, -1)] + +def cache_234_H : List Cell := cache_234_H_part0 + +def cache_234 : ListRow := ⟨cache_234_A, cache_234_H, 7⟩ + +def cache_235_A_part0 : List Cell := [(0, -4), (0, -3), (0, -2), (0, -1), (1, 0), (3, 0)] + +def cache_235_A : List Cell := cache_235_A_part0 + +def cache_235_H_part0 : List Cell := [(-1, -1), (-1, 0), (-1, 1), (-1, 2), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, 0), (2, 0), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1), (5, 1)] + +def cache_235_H : List Cell := cache_235_H_part0 + +def cache_235 : ListRow := ⟨cache_235_A, cache_235_H, 7⟩ + +def cache_236_A_part0 : List Cell := [(-1, -3), (-1, -2), (-1, -1)] + +def cache_236_A : List Cell := cache_236_A_part0 + +def cache_236_H_part0 : List Cell := [(-4, -1), (-3, -1), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -1), (1, 0), (2, 0), (3, 0)] + +def cache_236_H : List Cell := cache_236_H_part0 + +def cache_236 : ListRow := ⟨cache_236_A, cache_236_H, 6⟩ + +def cache_237_A_part0 : List Cell := [(1, -3), (1, -2), (1, -1), (1, 0), (2, 0)] + +def cache_237_A : List Cell := cache_237_A_part0 + +def cache_237_H_part0 : List Cell := [(-2, -1), (-1, -1), (-1, 0), (0, -1), (0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (2, -1), (2, 0), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1), (5, 1)] + +def cache_237_H : List Cell := cache_237_H_part0 + +def cache_237 : ListRow := ⟨cache_237_A, cache_237_H, 7⟩ + +def cache_238_A_part0 : List Cell := [(1, -3), (1, -2), (1, -1), (1, 0), (2, -3), (2, -2), (2, 0)] + +def cache_238_A : List Cell := cache_238_A_part0 + +def cache_238_H_part0 : List Cell := [(0, -1), (0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (2, -3), (2, -2), (2, -1), (2, 0), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1), (5, 0), (5, 1), (6, -1)] + +def cache_238_H : List Cell := cache_238_H_part0 + +def cache_238 : ListRow := ⟨cache_238_A, cache_238_H, 7⟩ + +def cache_239_A_part0 : List Cell := [(-1, -2), (-1, -1), (-1, 0), (0, -1), (1, -1), (2, -1)] + +def cache_239_A : List Cell := cache_239_A_part0 + +def cache_239_H_part0 : List Cell := [(-4, 1), (-3, 1), (-2, 1), (-2, 2), (-2, 3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -1), (1, 0), (2, -1), (3, -1)] + +def cache_239_H : List Cell := cache_239_H_part0 + +def cache_239 : ListRow := ⟨cache_239_A, cache_239_H, 7⟩ + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/CacheData06.lean b/lean/OAI/Combinatorics/SnakyCertificate/CacheData06.lean new file mode 100644 index 0000000000000000000000000000000000000000..8d5bd214d993f45f8fc08e2b12137fb9c7cc73aa --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/CacheData06.lean @@ -0,0 +1,409 @@ +import OAI.Combinatorics.SnakyCertificate.Lists + +namespace OAI + +namespace SnakyCertificate.Check + +def cache_240_A_part0 : List Cell := [(-1, -3), (-1, -2), (-1, -1), (-1, 0)] + +def cache_240_A : List Cell := cache_240_A_part0 + +def cache_240_H_part0 : List Cell := [(-4, -1), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-2, 1), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, -1), (3, 1)] + +def cache_240_H : List Cell := cache_240_H_part0 + +def cache_240 : ListRow := ⟨cache_240_A, cache_240_H, 8⟩ + +def cache_241_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, -2), (-1, -1), (-1, 0)] + +def cache_241_A : List Cell := cache_241_A_part0 + +def cache_241_H_part0 : List Cell := [(-3, 0), (-2, -1), (-2, 0), (-1, -2), (-1, -1), (-1, 0), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, 1)] + +def cache_241_H : List Cell := cache_241_H_part0 + +def cache_241 : ListRow := ⟨cache_241_A, cache_241_H, 7⟩ + +def cache_242_A_part0 : List Cell := [(-2, 0), (-1, -3), (-1, -2), (-1, -1), (-1, 0)] + +def cache_242_A : List Cell := cache_242_A_part0 + +def cache_242_H_part0 : List Cell := [(-3, 0), (-2, -1), (-2, 0), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -2), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, -1), (2, 0), (2, 1), (3, 0), (3, 1)] + +def cache_242_H : List Cell := cache_242_H_part0 + +def cache_242 : ListRow := ⟨cache_242_A, cache_242_H, 8⟩ + +def cache_243_A_part0 : List Cell := [(-3, -1), (-2, -1), (-2, 0), (-1, -1), (0, -1), (0, 2)] + +def cache_243_A : List Cell := cache_243_A_part0 + +def cache_243_H_part0 : List Cell := [(-4, -2), (-3, -2), (-3, -1), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-1, -2), (-1, -1), (-1, 1), (0, -1), (0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (1, 3), (2, 2), (3, 2)] + +def cache_243_H : List Cell := cache_243_H_part0 + +def cache_243 : ListRow := ⟨cache_243_A, cache_243_H, 7⟩ + +def cache_244_A_part0 : List Cell := [(-2, 0), (-1, -3), (-1, -2), (-1, 0)] + +def cache_244_A : List Cell := cache_244_A_part0 + +def cache_244_H_part0 : List Cell := [(-5, 1), (-4, 1), (-3, 0), (-3, 1), (-2, 0), (-2, 1), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, -1), (3, 1)] + +def cache_244_H : List Cell := cache_244_H_part0 + +def cache_244 : ListRow := ⟨cache_244_A, cache_244_H, 7⟩ + +def cache_245_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0)] + +def cache_245_A : List Cell := cache_245_A_part0 + +def cache_245_H_part0 : List Cell := [(-6, -1), (-6, 0), (-6, 1), (-5, -1), (-5, 0), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (-1, 1), (0, 0), (0, 1), (1, 0), (1, 1), (2, 1)] + +def cache_245_H : List Cell := cache_245_H_part0 + +def cache_245 : ListRow := ⟨cache_245_A, cache_245_H, 8⟩ + +def cache_246_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0)] + +def cache_246_A : List Cell := cache_246_A_part0 + +def cache_246_H_part0 : List Cell := [(-5, -1), (-4, -1), (-4, 0), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-2, 1), (-1, 0), (-1, 1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1)] + +def cache_246_H : List Cell := cache_246_H_part0 + +def cache_246 : ListRow := ⟨cache_246_A, cache_246_H, 8⟩ + +def cache_247_A_part0 : List Cell := [(0, -2), (0, -1), (1, -1), (2, -1), (3, -1)] + +def cache_247_A : List Cell := cache_247_A_part0 + +def cache_247_H_part0 : List Cell := [(-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (4, 0)] + +def cache_247_H : List Cell := cache_247_H_part0 + +def cache_247 : ListRow := ⟨cache_247_A, cache_247_H, 8⟩ + +def cache_248_A_part0 : List Cell := [(-1, 0), (1, 0), (2, 0)] + +def cache_248_A : List Cell := cache_248_A_part0 + +def cache_248_H_part0 : List Cell := [(-3, -1), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, -1), (0, 0), (0, 1), (1, 0), (1, 1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1), (5, 0), (5, 1)] + +def cache_248_H : List Cell := cache_248_H_part0 + +def cache_248 : ListRow := ⟨cache_248_A, cache_248_H, 8⟩ + +def cache_249_A_part0 : List Cell := [(-2, -2), (-1, -3), (-1, -2), (0, -2), (0, -1)] + +def cache_249_A : List Cell := cache_249_A_part0 + +def cache_249_H_part0 : List Cell := [(-3, 0), (-2, -2), (-2, 0), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -4), (1, -3), (1, -1), (1, 0), (1, 1), (2, -3), (2, -1), (3, -3)] + +def cache_249_H : List Cell := cache_249_H_part0 + +def cache_249 : ListRow := ⟨cache_249_A, cache_249_H, 8⟩ + +def cache_250_A_part0 : List Cell := [(-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -3), (0, -2)] + +def cache_250_A : List Cell := cache_250_A_part0 + +def cache_250_H_part0 : List Cell := [(-2, -1), (-2, 0), (-2, 1), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, -1)] + +def cache_250_H : List Cell := cache_250_H_part0 + +def cache_250 : ListRow := ⟨cache_250_A, cache_250_H, 8⟩ + +def cache_251_A_part0 : List Cell := [(-3, 1), (-2, 1), (-1, 1), (0, 1), (0, 2)] + +def cache_251_A : List Cell := cache_251_A_part0 + +def cache_251_H_part0 : List Cell := [(-4, 1), (-3, 1), (-2, 1), (-2, 2), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, 0), (1, 3), (1, 4), (1, 5), (2, 3), (3, 3)] + +def cache_251_H : List Cell := cache_251_H_part0 + +def cache_251 : ListRow := ⟨cache_251_A, cache_251_H, 8⟩ + +def cache_252_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0)] + +def cache_252_A : List Cell := cache_252_A_part0 + +def cache_252_H_part0 : List Cell := [(-5, 0), (-4, 0), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, -2), (-1, -1), (-1, 0), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, -1)] + +def cache_252_H : List Cell := cache_252_H_part0 + +def cache_252 : ListRow := ⟨cache_252_A, cache_252_H, 7⟩ + +def cache_253_A_part0 : List Cell := [(-1, -3), (0, -3), (0, -2), (1, -3), (2, -3), (2, 0)] + +def cache_253_A : List Cell := cache_253_A_part0 + +def cache_253_H_part0 : List Cell := [(-2, -4), (-1, -4), (-1, -3), (-1, 0), (0, -3), (0, -2), (0, -1), (0, 0), (1, -4), (1, -3), (1, -1), (1, 0), (1, 1), (2, -3), (2, -2), (2, -1), (2, 0), (3, -2), (3, -1), (4, -1), (5, -1)] + +def cache_253_H : List Cell := cache_253_H_part0 + +def cache_253 : ListRow := ⟨cache_253_A, cache_253_H, 7⟩ + +def cache_254_A_part0 : List Cell := [(0, -2), (1, 1), (2, 1), (3, 1)] + +def cache_254_A : List Cell := cache_254_A_part0 + +def cache_254_H_part0 : List Cell := [(-2, 2), (-1, 0), (-1, 1), (-1, 2), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (2, 1), (3, 1), (4, 0), (4, 1), (4, 2), (5, 0), (5, 1), (5, 2), (6, 0), (6, 2)] + +def cache_254_H : List Cell := cache_254_H_part0 + +def cache_254 : ListRow := ⟨cache_254_A, cache_254_H, 7⟩ + +def cache_255_A_part0 : List Cell := [(0, -4), (0, -3), (0, -2), (0, -1), (3, 0)] + +def cache_255_A : List Cell := cache_255_A_part0 + +def cache_255_H_part0 : List Cell := [(-1, -1), (-1, 0), (-1, 1), (-1, 2), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2), (3, 0), (3, 1), (3, 2), (4, 0), (4, 2)] + +def cache_255_H : List Cell := cache_255_H_part0 + +def cache_255 : ListRow := ⟨cache_255_A, cache_255_H, 9⟩ + +def cache_256_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1), (1, -3), (1, -2)] + +def cache_256_A : List Cell := cache_256_A_part0 + +def cache_256_H_part0 : List Cell := [(-1, -1), (-1, 0), (-1, 1), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -3), (1, -2), (1, 0), (1, 1), (2, -2), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, -1), (4, 1)] + +def cache_256_H : List Cell := cache_256_H_part0 + +def cache_256 : ListRow := ⟨cache_256_A, cache_256_H, 8⟩ + +def cache_257_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1), (1, 1), (3, 1)] + +def cache_257_A : List Cell := cache_257_A_part0 + +def cache_257_H_part0 : List Cell := [(-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (2, 1), (3, 0), (3, 1), (3, 2), (4, 0), (4, 1), (4, 2), (5, 0), (5, 2)] + +def cache_257_H : List Cell := cache_257_H_part0 + +def cache_257 : ListRow := ⟨cache_257_A, cache_257_H, 8⟩ + +def cache_258_A_part0 : List Cell := [(0, -2), (0, -1), (1, -1), (1, 1), (2, -1), (3, -1)] + +def cache_258_A : List Cell := cache_258_A_part0 + +def cache_258_H_part0 : List Cell := [(-1, 0), (-1, 1), (-1, 2), (0, -2), (0, -1), (0, 0), (0, 1), (1, -1), (1, 1), (1, 2), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (3, -1), (3, 0), (3, 1), (3, 2), (4, 0), (4, 2)] + +def cache_258_H : List Cell := cache_258_H_part0 + +def cache_258 : ListRow := ⟨cache_258_A, cache_258_H, 9⟩ + +def cache_259_A_part0 : List Cell := [(0, -1), (1, -1), (1, 0), (2, -1), (3, -1)] + +def cache_259_A : List Cell := cache_259_A_part0 + +def cache_259_H_part0 : List Cell := [(-1, 0), (0, -1), (0, 0), (1, -1), (1, 0), (1, 1), (2, -2), (2, -1), (2, 1), (2, 2), (2, 3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (4, -2), (4, 0), (4, 1), (4, 2), (4, 3)] + +def cache_259_H : List Cell := cache_259_H_part0 + +def cache_259 : ListRow := ⟨cache_259_A, cache_259_H, 8⟩ + +def cache_260_A_part0 : List Cell := [(0, -2), (0, -1), (0, 1), (1, -2), (1, -1)] + +def cache_260_A : List Cell := cache_260_A_part0 + +def cache_260_H_part0 : List Cell := [(-1, 0), (-1, 1), (-1, 2), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -2), (1, -1), (1, 1), (1, 2), (2, -1), (2, 0), (2, 1), (2, 2), (3, 0), (3, 1), (3, 2), (4, 0), (4, 2)] + +def cache_260_H : List Cell := cache_260_H_part0 + +def cache_260 : ListRow := ⟨cache_260_A, cache_260_H, 8⟩ + +def cache_261_A_part0 : List Cell := [(1, -3), (1, -2), (1, -1), (1, 0)] + +def cache_261_A : List Cell := cache_261_A_part0 + +def cache_261_H_part0 : List Cell := [(-1, 0), (0, -1), (0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (2, -2), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (4, -1), (4, 0), (4, 1), (5, 0), (5, 1)] + +def cache_261_H : List Cell := cache_261_H_part0 + +def cache_261 : ListRow := ⟨cache_261_A, cache_261_H, 9⟩ + +def cache_262_A_part0 : List Cell := [(-2, -1), (-2, 0), (-1, -1), (0, -1), (1, 0), (1, 1), (1, 2)] + +def cache_262_A : List Cell := cache_262_A_part0 + +def cache_262_H_part0 : List Cell := [(-3, 1), (-3, 2), (-3, 3), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -1), (0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (1, 3), (2, 1)] + +def cache_262_H : List Cell := cache_262_H_part0 + +def cache_262 : ListRow := ⟨cache_262_A, cache_262_H, 9⟩ + +def cache_263_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0)] + +def cache_263_A : List Cell := cache_263_A_part0 + +def cache_263_H_part0 : List Cell := [(-6, -1), (-5, -1), (-5, 0), (-4, -1), (-4, 0), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, -1), (0, 0), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1)] + +def cache_263_H : List Cell := cache_263_H_part0 + +def cache_263 : ListRow := ⟨cache_263_A, cache_263_H, 8⟩ + +def cache_264_A_part0 : List Cell := [(0, -1), (1, -1), (1, 0), (2, -1), (3, -1)] + +def cache_264_A : List Cell := cache_264_A_part0 + +def cache_264_H_part0 : List Cell := [(-1, 0), (0, -1), (0, 0), (1, -1), (1, 0), (2, -2), (2, -1), (2, 0), (2, 2), (2, 3), (2, 4), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (4, -2), (4, 0), (4, 1), (4, 2), (4, 3)] + +def cache_264_H : List Cell := cache_264_H_part0 + +def cache_264 : ListRow := ⟨cache_264_A, cache_264_H, 9⟩ + +def cache_265_A_part0 : List Cell := [(0, 1), (1, 1), (2, 1), (3, 1)] + +def cache_265_A : List Cell := cache_265_A_part0 + +def cache_265_H_part0 : List Cell := [(-1, 0), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, 1), (2, 2), (2, 3), (3, 1), (3, 2), (4, 2)] + +def cache_265_H : List Cell := cache_265_H_part0 + +def cache_265 : ListRow := ⟨cache_265_A, cache_265_H, 9⟩ + +def cache_266_A_part0 : List Cell := [(-1, 0), (0, -3), (0, -2), (0, -1)] + +def cache_266_A : List Cell := cache_266_A_part0 + +def cache_266_H_part0 : List Cell := [(-2, 0), (-1, -1), (-1, 0), (-1, 1), (0, -3), (0, -2), (0, -1), (0, 0), (1, -2), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (3, -1), (3, 0), (3, 1), (4, 0), (4, 1)] + +def cache_266_H : List Cell := cache_266_H_part0 + +def cache_266 : ListRow := ⟨cache_266_A, cache_266_H, 9⟩ + +def cache_267_A_part0 : List Cell := [(-2, 0), (-1, 0), (1, 0)] + +def cache_267_A : List Cell := cache_267_A_part0 + +def cache_267_H_part0 : List Cell := [(-5, -1), (-5, 0), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, -1), (0, 0), (1, -1), (1, 0), (2, -1), (2, 0), (3, -1), (3, 0), (4, -1)] + +def cache_267_H : List Cell := cache_267_H_part0 + +def cache_267 : ListRow := ⟨cache_267_A, cache_267_H, 8⟩ + +def cache_268_A_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -1), (0, -1)] + +def cache_268_A : List Cell := cache_268_A_part0 + +def cache_268_H_part0 : List Cell := [(-4, -1), (-3, -1), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -2), (1, 0), (1, 1), (1, 2), (1, 3), (2, 1), (3, 1)] + +def cache_268_H : List Cell := cache_268_H_part0 + +def cache_268 : ListRow := ⟨cache_268_A, cache_268_H, 9⟩ + +def cache_269_A_part0 : List Cell := [(-1, 1), (-1, 3), (0, 1), (1, 1), (2, 1)] + +def cache_269_A : List Cell := cache_269_A_part0 + +def cache_269_H_part0 : List Cell := [(-2, 2), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, 0), (0, 1), (1, 0), (1, 1), (1, 2), (2, 1), (2, 2), (3, 1), (3, 2), (4, 0), (4, 1), (4, 2), (5, 0), (5, 1), (5, 2), (6, 0), (6, 2)] + +def cache_269_H : List Cell := cache_269_H_part0 + +def cache_269 : ListRow := ⟨cache_269_A, cache_269_H, 8⟩ + +def cache_270_A_part0 : List Cell := [(-1, -1), (0, -1), (0, 1), (0, 2)] + +def cache_270_A : List Cell := cache_270_A_part0 + +def cache_270_H_part0 : List Cell := [(-1, -2), (-1, -1), (-1, 2), (-1, 3), (-1, 4), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (1, 4)] + +def cache_270_H : List Cell := cache_270_H_part0 + +def cache_270 : ListRow := ⟨cache_270_A, cache_270_H, 6⟩ + +def cache_271_A_part0 : List Cell := [(0, -1), (0, 1), (1, -1), (2, -1)] + +def cache_271_A : List Cell := cache_271_A_part0 + +def cache_271_H_part0 : List Cell := [(-1, 0), (-1, 2), (-1, 3), (-1, 4), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -2), (1, -1), (1, 2), (1, 3), (1, 4), (2, -1), (3, -2), (3, -1), (3, 0), (4, -2), (4, -1), (4, 0), (5, -2), (5, 0)] + +def cache_271_H : List Cell := cache_271_H_part0 + +def cache_271 : ListRow := ⟨cache_271_A, cache_271_H, 7⟩ + +def cache_272_A_part0 : List Cell := [(-2, -1), (-1, -4), (-1, -2), (-1, -1), (0, -1)] + +def cache_272_A : List Cell := cache_272_A_part0 + +def cache_272_H_part0 : List Cell := [(-3, 1), (-2, -1), (-2, 1), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 1), (-1, 2), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -3), (1, -2), (1, 0), (1, 1), (1, 2), (2, -2), (2, 0), (3, -2)] + +def cache_272_H : List Cell := cache_272_H_part0 + +def cache_272 : ListRow := ⟨cache_272_A, cache_272_H, 9⟩ + +def cache_273_A_part0 : List Cell := [(-2, 0), (-1, -3), (-1, -2), (-1, -1), (-1, 0)] + +def cache_273_A : List Cell := cache_273_A_part0 + +def cache_273_H_part0 : List Cell := [(-4, 0), (-3, 0), (-2, 0), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -2), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, -1)] + +def cache_273_H : List Cell := cache_273_H_part0 + +def cache_273 : ListRow := ⟨cache_273_A, cache_273_H, 8⟩ + +def cache_274_A_part0 : List Cell := [(-1, -2), (0, -2), (0, -1), (0, 1)] + +def cache_274_A : List Cell := cache_274_A_part0 + +def cache_274_H_part0 : List Cell := [(-3, 0), (-2, 0), (-2, 1), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (-1, 2), (0, -2), (0, -1), (0, 0), (0, 1), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2), (3, 0), (3, 1), (3, 2), (4, 0), (4, 2)] + +def cache_274_H : List Cell := cache_274_H_part0 + +def cache_274 : ListRow := ⟨cache_274_A, cache_274_H, 9⟩ + +def cache_275_A_part0 : List Cell := [(-3, -1), (-3, 0), (-2, 0), (-1, 0)] + +def cache_275_A : List Cell := cache_275_A_part0 + +def cache_275_H_part0 : List Cell := [(-7, -1), (-6, -1), (-6, 0), (-6, 1), (-5, -1), (-5, 0), (-5, 1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, 0), (-1, 1), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1), (2, 1)] + +def cache_275_H : List Cell := cache_275_H_part0 + +def cache_275 : ListRow := ⟨cache_275_A, cache_275_H, 7⟩ + +def cache_276_A_part0 : List Cell := [(0, -4), (0, -3), (0, -2), (0, -1), (3, -2), (3, 0)] + +def cache_276_A : List Cell := cache_276_A_part0 + +def cache_276_H_part0 : List Cell := [(-1, -1), (-1, 0), (-1, 1), (-1, 2), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, 0), (1, 1), (1, 2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (3, -3), (3, -2), (3, -1), (3, 0), (4, -1)] + +def cache_276_H : List Cell := cache_276_H_part0 + +def cache_276 : ListRow := ⟨cache_276_A, cache_276_H, 7⟩ + +def cache_277_A_part0 : List Cell := [(-1, -3), (-1, -1), (0, -1), (1, -3), (1, -2), (1, -1)] + +def cache_277_A : List Cell := cache_277_A_part0 + +def cache_277_H_part0 : List Cell := [(-2, -4), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -3), (1, -2), (1, -1), (2, -4), (2, -3), (2, -2), (3, -4), (3, -3), (3, -2), (4, -4), (4, -2)] + +def cache_277_H : List Cell := cache_277_H_part0 + +def cache_277 : ListRow := ⟨cache_277_A, cache_277_H, 9⟩ + +def cache_278_A_part0 : List Cell := [(1, 0), (2, -1), (2, 0), (3, 0)] + +def cache_278_A : List Cell := cache_278_A_part0 + +def cache_278_H_part0 : List Cell := [(-2, -1), (-2, 1), (-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 0), (0, 1), (1, 0), (2, -1), (2, 0), (3, -1), (3, 0), (4, -1), (4, 0), (4, 1), (5, -1), (5, 0), (5, 1), (6, -1), (6, 0), (6, 1), (7, -1)] + +def cache_278_H : List Cell := cache_278_H_part0 + +def cache_278 : ListRow := ⟨cache_278_A, cache_278_H, 7⟩ + +def cache_279_A_part0 : List Cell := [(1, -3), (1, -2), (1, -1), (1, 0), (2, -3), (2, -2), (2, 0)] + +def cache_279_A : List Cell := cache_279_A_part0 + +def cache_279_H_part0 : List Cell := [(0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (2, -3), (2, -2), (2, -1), (2, 0), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1), (5, 0), (5, 1), (6, -1), (6, 0), (6, 1), (7, -1)] + +def cache_279_H : List Cell := cache_279_H_part0 + +def cache_279 : ListRow := ⟨cache_279_A, cache_279_H, 8⟩ + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/CacheData07.lean b/lean/OAI/Combinatorics/SnakyCertificate/CacheData07.lean new file mode 100644 index 0000000000000000000000000000000000000000..62b42b7ea969e04541e4e6a8cc415dd7277f8972 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/CacheData07.lean @@ -0,0 +1,461 @@ +import OAI.Combinatorics.SnakyCertificate.Lists + +namespace OAI + +namespace SnakyCertificate.Check + +def cache_280_A_part0 : List Cell := [(-3, -2), (-2, -3), (-2, -2), (-1, -2), (-1, 0), (-1, 1), (0, -2)] + +def cache_280_A : List Cell := cache_280_A_part0 + +def cache_280_H_part0 : List Cell := [(-4, -1), (-4, 1), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-2, -3), (-2, -2), (-2, 0), (-2, 1), (-1, -2), (-1, 0), (-1, 1), (0, -3), (0, -2), (0, -1), (0, 0), (1, -2), (1, -1), (1, 0), (2, -1), (2, 0), (3, -1)] + +def cache_280_H : List Cell := cache_280_H_part0 + +def cache_280 : ListRow := ⟨cache_280_A, cache_280_H, 5⟩ + +def cache_281_A_part0 : List Cell := [(-2, 0), (-2, 1), (-1, 0), (-1, 1)] + +def cache_281_A : List Cell := cache_281_A_part0 + +def cache_281_H_part0 : List Cell := [(-4, 1), (-3, 0), (-3, 1), (-2, 0), (-2, 1), (-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -1), (1, 0), (1, 1), (1, 2), (2, -1), (2, 0), (2, 1), (3, -1), (3, 1)] + +def cache_281_H : List Cell := cache_281_H_part0 + +def cache_281 : ListRow := ⟨cache_281_A, cache_281_H, 7⟩ + +def cache_282_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0)] + +def cache_282_A : List Cell := cache_282_A_part0 + +def cache_282_H_part0 : List Cell := [(-4, -1), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-1, 0), (-1, 1), (-1, 2), (0, 0), (0, 1), (1, 0), (1, 1), (2, 1)] + +def cache_282_H : List Cell := cache_282_H_part0 + +def cache_282 : ListRow := ⟨cache_282_A, cache_282_H, 10⟩ + +def cache_283_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, -2), (-1, 0)] + +def cache_283_A : List Cell := cache_283_A_part0 + +def cache_283_H_part0 : List Cell := [(-4, -1), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, -2), (-1, -1), (-1, 0), (-1, 2), (-1, 3), (-1, 4), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -1), (2, 1)] + +def cache_283_H : List Cell := cache_283_H_part0 + +def cache_283 : ListRow := ⟨cache_283_A, cache_283_H, 9⟩ + +def cache_284_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1), (1, -2), (2, -2), (3, -2)] + +def cache_284_A : List Cell := cache_284_A_part0 + +def cache_284_H_part0 : List Cell := [(-1, 0), (-1, 1), (-1, 2), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -3), (1, -2), (1, 0), (1, 1), (1, 2), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (3, -2), (3, -1), (3, 0), (3, 1), (4, -1), (4, 1)] + +def cache_284_H : List Cell := cache_284_H_part0 + +def cache_284 : ListRow := ⟨cache_284_A, cache_284_H, 9⟩ + +def cache_285_A_part0 : List Cell := [(1, -3), (1, -2), (1, -1), (1, 0)] + +def cache_285_A : List Cell := cache_285_A_part0 + +def cache_285_H_part0 : List Cell := [(-2, 0), (-1, 0), (0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (2, -2), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (4, -1), (4, 0), (4, 1), (5, -1), (5, 0), (5, 1), (6, -1)] + +def cache_285_H : List Cell := cache_285_H_part0 + +def cache_285 : ListRow := ⟨cache_285_A, cache_285_H, 9⟩ + +def cache_286_A_part0 : List Cell := [(-1, -3), (0, -3), (0, -2), (0, -1)] + +def cache_286_A : List Cell := cache_286_A_part0 + +def cache_286_H_part0 : List Cell := [(-2, 0), (-1, -4), (-1, -3), (-1, -1), (-1, 0), (-1, 1), (0, -3), (0, -2), (0, -1), (0, 0), (1, -2), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (3, -1), (3, 0), (3, 1), (4, 0), (4, 1)] + +def cache_286_H : List Cell := cache_286_H_part0 + +def cache_286 : ListRow := ⟨cache_286_A, cache_286_H, 10⟩ + +def cache_287_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0), (-1, 1)] + +def cache_287_A : List Cell := cache_287_A_part0 + +def cache_287_H_part0 : List Cell := [(-4, -1), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-2, -1), (-2, 0), (-2, 1), (-2, 3), (-2, 4), (-2, 5), (-1, 0), (-1, 1), (0, 0), (0, 1), (1, 0), (1, 1), (2, 1)] + +def cache_287_H : List Cell := cache_287_H_part0 + +def cache_287 : ListRow := ⟨cache_287_A, cache_287_H, 10⟩ + +def cache_288_A_part0 : List Cell := [(-3, -3), (-3, -2), (-3, -1), (-2, -3), (-2, 0), (-1, -3), (0, -3)] + +def cache_288_A : List Cell := cache_288_A_part0 + +def cache_288_H_part0 : List Cell := [(-4, 0), (-4, 1), (-4, 2), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-2, -3), (-2, 0), (-2, 1), (-1, -4), (-1, -3), (-1, -2), (-1, 0), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -2), (1, 0), (1, 1), (1, 2)] + +def cache_288_H : List Cell := cache_288_H_part0 + +def cache_288 : ListRow := ⟨cache_288_A, cache_288_H, 7⟩ + +def cache_289_A_part0 : List Cell := [(-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -3), (0, -2)] + +def cache_289_A : List Cell := cache_289_A_part0 + +def cache_289_H_part0 : List Cell := [(-2, 0), (-2, 1), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1)] + +def cache_289_H : List Cell := cache_289_H_part0 + +def cache_289 : ListRow := ⟨cache_289_A, cache_289_H, 9⟩ + +def cache_290_A_part0 : List Cell := [(-2, -1), (-1, -2), (-1, -1), (0, -2), (0, -1), (0, 1)] + +def cache_290_A : List Cell := cache_290_A_part0 + +def cache_290_H_part0 : List Cell := [(-4, 0), (-4, 2), (-3, 0), (-3, 1), (-3, 2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-1, -2), (-1, -1), (-1, 1), (-1, 2), (0, -2), (0, -1), (0, 0), (0, 1), (1, -3), (1, -2), (1, 0), (1, 1), (1, 2), (2, -2), (3, -2)] + +def cache_290_H : List Cell := cache_290_H_part0 + +def cache_290 : ListRow := ⟨cache_290_A, cache_290_H, 8⟩ + +def cache_291_A_part0 : List Cell := [(1, -1), (1, 0), (2, 0), (3, 0)] + +def cache_291_A : List Cell := cache_291_A_part0 + +def cache_291_H_part0 : List Cell := [(-2, 0), (-2, 1), (-1, 0), (-1, 1), (0, 0), (0, 1), (1, -1), (1, 0), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, 0), (4, 1), (5, -1), (5, 0), (5, 1), (6, -1), (6, 0), (6, 1), (7, -1), (7, 1)] + +def cache_291_H : List Cell := cache_291_H_part0 + +def cache_291 : ListRow := ⟨cache_291_A, cache_291_H, 8⟩ + +def cache_292_A_part0 : List Cell := [(-3, -1), (-2, -1), (-2, 1), (-1, -1), (-1, 1), (0, 1)] + +def cache_292_A : List Cell := cache_292_A_part0 + +def cache_292_H_part0 : List Cell := [(-4, -1), (-3, -1), (-2, -2), (-2, -1), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, -2), (0, -1), (0, 0), (0, 1), (1, -2), (1, 0), (2, 0)] + +def cache_292_H : List Cell := cache_292_H_part0 + +def cache_292 : ListRow := ⟨cache_292_A, cache_292_H, 9⟩ + +def cache_293_A_part0 : List Cell := [(-2, -2), (-1, -3), (-1, -2), (0, -2), (0, 1), (1, -2)] + +def cache_293_A : List Cell := cache_293_A_part0 + +def cache_293_H_part0 : List Cell := [(-3, -1), (-3, 1), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (0, -2), (0, -1), (0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (2, -2), (2, -1), (2, 0), (3, -1), (3, 0), (4, -1)] + +def cache_293_H : List Cell := cache_293_H_part0 + +def cache_293 : ListRow := ⟨cache_293_A, cache_293_H, 6⟩ + +def cache_294_A_part0 : List Cell := [(-3, 0), (-2, -2), (-2, 0), (-1, 0)] + +def cache_294_A : List Cell := cache_294_A_part0 + +def cache_294_H_part0 : List Cell := [(-4, -1), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-2, -2), (-2, -1), (-2, 0), (-2, 2), (-2, 3), (-2, 4), (-1, 0), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1)] + +def cache_294_H_part1 : List Cell := [(2, 1)] + +def cache_294_H : List Cell := (cache_294_H_part0 ++ cache_294_H_part1) + +def cache_294 : ListRow := ⟨cache_294_A, cache_294_H, 9⟩ + +def cache_295_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0)] + +def cache_295_A : List Cell := cache_295_A_part0 + +def cache_295_H_part0 : List Cell := [(-4, 1), (-3, 0), (-3, 1), (-2, 0), (-2, 1), (-2, 2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -1)] + +def cache_295_H_part1 : List Cell := [(2, 1)] + +def cache_295_H : List Cell := (cache_295_H_part0 ++ cache_295_H_part1) + +def cache_295 : ListRow := ⟨cache_295_A, cache_295_H, 10⟩ + +def cache_296_A_part0 : List Cell := [(-3, -3), (-3, -2), (-3, -1), (-3, 0), (-1, -2), (0, -2), (0, -1)] + +def cache_296_A : List Cell := cache_296_A_part0 + +def cache_296_H_part0 : List Cell := [(-4, 0), (-4, 1), (-4, 2), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-2, 0), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, 1), (1, 2)] + +def cache_296_H_part1 : List Cell := [(1, 3)] + +def cache_296_H : List Cell := (cache_296_H_part0 ++ cache_296_H_part1) + +def cache_296 : ListRow := ⟨cache_296_A, cache_296_H, 7⟩ + +def cache_297_A_part0 : List Cell := [(0, -1), (1, -1), (1, 0), (2, -1), (3, -1)] + +def cache_297_A : List Cell := cache_297_A_part0 + +def cache_297_H_part0 : List Cell := [(-1, 0), (0, -1), (0, 0), (1, -1), (1, 0), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -2), (4, 0), (4, 1), (4, 2), (4, 3)] + +def cache_297_H_part1 : List Cell := [(4, 4)] + +def cache_297_H : List Cell := (cache_297_H_part0 ++ cache_297_H_part1) + +def cache_297 : ListRow := ⟨cache_297_A, cache_297_H, 10⟩ + +def cache_298_A_part0 : List Cell := [(0, -1), (1, 0), (2, -1), (2, 0)] + +def cache_298_A : List Cell := cache_298_A_part0 + +def cache_298_H_part0 : List Cell := [(-3, -1), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 0), (1, 0), (2, -1), (2, 0), (3, -1), (3, 0), (4, -1), (4, 0), (4, 1), (5, -1), (5, 0), (5, 1), (6, -1), (6, 0), (6, 1)] + +def cache_298_H_part1 : List Cell := [(7, -1)] + +def cache_298_H : List Cell := (cache_298_H_part0 ++ cache_298_H_part1) + +def cache_298 : ListRow := ⟨cache_298_A, cache_298_H, 8⟩ + +def cache_299_A_part0 : List Cell := [(0, -2), (0, -1), (1, -1), (2, -1), (3, -1)] + +def cache_299_A : List Cell := cache_299_A_part0 + +def cache_299_H_part0 : List Cell := [(-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -2), (1, -1), (1, 1), (1, 2), (1, 3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (3, -1), (3, 0), (3, 1), (3, 2), (4, 0)] + +def cache_299_H_part1 : List Cell := [(4, 2)] + +def cache_299_H : List Cell := (cache_299_H_part0 ++ cache_299_H_part1) + +def cache_299 : ListRow := ⟨cache_299_A, cache_299_H, 10⟩ + +def cache_300_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1)] + +def cache_300_A : List Cell := cache_300_A_part0 + +def cache_300_H_part0 : List Cell := [(-3, -2), (-2, -3), (-2, -2), (-1, -4), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (-1, 2), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -4), (1, -3), (1, -2), (2, -4), (2, -3), (2, -2), (3, -4), (3, -3), (3, -2), (4, -4)] + +def cache_300_H_part1 : List Cell := [(4, -2)] + +def cache_300_H : List Cell := (cache_300_H_part0 ++ cache_300_H_part1) + +def cache_300 : ListRow := ⟨cache_300_A, cache_300_H, 9⟩ + +def cache_301_A_part0 : List Cell := [(-3, 0), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (-1, 2), (0, -1)] + +def cache_301_A : List Cell := cache_301_A_part0 + +def cache_301_H_part0 : List Cell := [(-4, 1), (-4, 3), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-1, -1), (-1, 0), (-1, 2), (-1, 3), (0, -1), (0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (1, 3), (2, 0)] + +def cache_301_H_part1 : List Cell := [(2, 1)] + +def cache_301_H : List Cell := (cache_301_H_part0 ++ cache_301_H_part1) + +def cache_301 : ListRow := ⟨cache_301_A, cache_301_H, 10⟩ + +def cache_302_A_part0 : List Cell := [(-2, -2), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (0, -2), (2, -1)] + +def cache_302_A : List Cell := cache_302_A_part0 + +def cache_302_H_part0 : List Cell := [(-2, -2), (-2, 0), (-2, 2), (-2, 3), (-2, 4), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -2), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, -2), (1, -1), (1, 0), (2, -1), (2, 0)] + +def cache_302_H_part1 : List Cell := [(3, -1), (4, -1)] + +def cache_302_H : List Cell := (cache_302_H_part0 ++ cache_302_H_part1) + +def cache_302 : ListRow := ⟨cache_302_A, cache_302_H, 7⟩ + +def cache_303_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1), (1, -3)] + +def cache_303_A : List Cell := cache_303_A_part0 + +def cache_303_H_part0 : List Cell := [(-2, 0), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (3, -1), (3, 0), (3, 1)] + +def cache_303_H_part1 : List Cell := [(4, 0), (4, 1)] + +def cache_303_H : List Cell := (cache_303_H_part0 ++ cache_303_H_part1) + +def cache_303 : ListRow := ⟨cache_303_A, cache_303_H, 10⟩ + +def cache_304_A_part0 : List Cell := [(1, -1), (1, 0), (2, 0), (3, 0)] + +def cache_304_A : List Cell := cache_304_A_part0 + +def cache_304_H_part0 : List Cell := [(-3, -1), (-2, -1), (-2, 0), (-2, 1), (-1, -1), (-1, 0), (-1, 1), (0, 0), (0, 1), (1, -1), (1, 0), (2, -1), (2, 0), (2, 1), (3, 0), (3, 1), (4, 0), (4, 1), (5, -1), (5, 0), (5, 1), (6, -1), (6, 0), (6, 1)] + +def cache_304_H_part1 : List Cell := [(7, -1), (7, 1)] + +def cache_304_H : List Cell := (cache_304_H_part0 ++ cache_304_H_part1) + +def cache_304 : ListRow := ⟨cache_304_A, cache_304_H, 8⟩ + +def cache_305_A_part0 : List Cell := [(-2, 0), (-1, -3), (-1, -2), (-1, -1), (-1, 0)] + +def cache_305_A : List Cell := cache_305_A_part0 + +def cache_305_H_part0 : List Cell := [(-5, -1), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, 0), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0)] + +def cache_305_H_part1 : List Cell := [(3, 1), (4, -1)] + +def cache_305_H : List Cell := (cache_305_H_part0 ++ cache_305_H_part1) + +def cache_305 : ListRow := ⟨cache_305_A, cache_305_H, 8⟩ + +def cache_306_A_part0 : List Cell := [(-1, -4), (-1, -3), (-1, -2), (-1, -1), (0, -3), (1, -3), (2, -3)] + +def cache_306_A : List Cell := cache_306_A_part0 + +def cache_306_H_part0 : List Cell := [(-2, 0), (-2, 1), (-2, 2), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (0, -3), (0, -1), (0, 0), (0, 1), (1, -4), (1, -3), (1, -2), (1, 0), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (3, -2), (3, 0)] + +def cache_306_H_part1 : List Cell := [(3, 1), (3, 2)] + +def cache_306_H : List Cell := (cache_306_H_part0 ++ cache_306_H_part1) + +def cache_306 : ListRow := ⟨cache_306_A, cache_306_H, 8⟩ + +def cache_307_A_part0 : List Cell := [(-1, -2), (-1, -1), (-1, 1), (0, -2), (0, -1), (0, 1)] + +def cache_307_A : List Cell := cache_307_A_part0 + +def cache_307_H_part0 : List Cell := [(-3, 1), (-2, 1), (-1, -2), (-1, -1), (-1, 1), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -1), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, 0), (3, 1), (3, 2), (4, 0), (4, 1)] + +def cache_307_H_part1 : List Cell := [(4, 2), (5, 0)] + +def cache_307_H : List Cell := (cache_307_H_part0 ++ cache_307_H_part1) + +def cache_307 : ListRow := ⟨cache_307_A, cache_307_H, 9⟩ + +def cache_308_A_part0 : List Cell := [(0, 1), (1, 1), (2, 1), (3, 1)] + +def cache_308_A : List Cell := cache_308_A_part0 + +def cache_308_H_part0 : List Cell := [(-1, 0), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, 0), (1, 1), (1, 3), (1, 4), (1, 5), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, 1), (3, 2), (3, 3), (3, 4)] + +def cache_308_H_part1 : List Cell := [(4, 2), (4, 4)] + +def cache_308_H : List Cell := (cache_308_H_part0 ++ cache_308_H_part1) + +def cache_308 : ListRow := ⟨cache_308_A, cache_308_H, 11⟩ + +def cache_309_A_part0 : List Cell := [(-2, 0), (0, 1), (0, 2), (0, 3), (1, 1)] + +def cache_309_A : List Cell := cache_309_A_part0 + +def cache_309_H_part0 : List Cell := [(-3, 0), (-2, 0), (-1, -1), (-1, 0), (-1, 3), (-1, 4), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, 2), (3, 3), (3, 4), (4, 2)] + +def cache_309_H_part1 : List Cell := [(4, 3), (4, 4)] + +def cache_309_H : List Cell := (cache_309_H_part0 ++ cache_309_H_part1) + +def cache_309 : ListRow := ⟨cache_309_A, cache_309_H, 10⟩ + +def cache_310_A_part0 : List Cell := [(-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -1)] + +def cache_310_A : List Cell := cache_310_A_part0 + +def cache_310_H_part0 : List Cell := [(-3, 0), (-2, -1), (-2, 0), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -2), (0, -1), (0, 0), (0, 1), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, -2), (2, -1), (2, 0), (2, 1), (3, -2), (3, -1), (3, 0)] + +def cache_310_H_part1 : List Cell := [(4, -2), (4, 0)] + +def cache_310_H : List Cell := (cache_310_H_part0 ++ cache_310_H_part1) + +def cache_310 : ListRow := ⟨cache_310_A, cache_310_H, 8⟩ + +def cache_311_A_part0 : List Cell := [(-1, 0), (0, -3), (0, -2), (0, -1), (1, 0)] + +def cache_311_A : List Cell := cache_311_A_part0 + +def cache_311_H_part0 : List Cell := [(-4, -1), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-1, 0), (-1, 1), (0, -3), (0, -2), (0, -1), (0, 0), (1, -1), (1, 0), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0)] + +def cache_311_H_part1 : List Cell := [(4, 1), (5, -1)] + +def cache_311_H : List Cell := (cache_311_H_part0 ++ cache_311_H_part1) + +def cache_311 : ListRow := ⟨cache_311_A, cache_311_H, 8⟩ + +def cache_312_A_part0 : List Cell := [(-2, -1), (-2, 0), (-1, -3), (-1, -1), (-1, 0)] + +def cache_312_A : List Cell := cache_312_A_part0 + +def cache_312_H_part0 : List Cell := [(-3, -1), (-3, 2), (-2, -1), (-2, 0), (-2, 2), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 2), (-1, 3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, -1)] + +def cache_312_H_part1 : List Cell := [(2, 0), (2, 1), (3, -1)] + +def cache_312_H : List Cell := (cache_312_H_part0 ++ cache_312_H_part1) + +def cache_312 : ListRow := ⟨cache_312_A, cache_312_H, 10⟩ + +def cache_313_A_part0 : List Cell := [(-2, -1), (-1, -1), (0, -3), (0, -2), (0, -1), (1, -1)] + +def cache_313_A : List Cell := cache_313_A_part0 + +def cache_313_H_part0 : List Cell := [(-2, -1), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -2), (2, -1), (3, -2), (3, -1)] + +def cache_313_H_part1 : List Cell := [(4, -2), (4, -1), (5, -2)] + +def cache_313_H : List Cell := (cache_313_H_part0 ++ cache_313_H_part1) + +def cache_313 : ListRow := ⟨cache_313_A, cache_313_H, 7⟩ + +def cache_314_A_part0 : List Cell := [(1, -3), (1, -2), (1, -1), (1, 0)] + +def cache_314_A : List Cell := cache_314_A_part0 + +def cache_314_H_part0 : List Cell := [(-3, -1), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-1, -1), (-1, 0), (-1, 1), (0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1)] + +def cache_314_H_part1 : List Cell := [(5, 0), (5, 1), (6, -1)] + +def cache_314_H : List Cell := (cache_314_H_part0 ++ cache_314_H_part1) + +def cache_314 : ListRow := ⟨cache_314_A, cache_314_H, 9⟩ + +def cache_315_A_part0 : List Cell := [(-3, -2), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-1, -1), (0, -1)] + +def cache_315_A : List Cell := cache_315_A_part0 + +def cache_315_H_part0 : List Cell := [(-4, 1), (-4, 2), (-4, 3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-2, -1), (-2, 1), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, 0)] + +def cache_315_H_part1 : List Cell := [(1, 2), (1, 3), (1, 4)] + +def cache_315_H : List Cell := (cache_315_H_part0 ++ cache_315_H_part1) + +def cache_315 : ListRow := ⟨cache_315_A, cache_315_H, 8⟩ + +def cache_316_A_part0 : List Cell := [(0, 1), (0, 2), (0, 3), (1, 1), (2, 1), (3, 1)] + +def cache_316_A : List Cell := cache_316_A_part0 + +def cache_316_H_part0 : List Cell := [(-1, 0), (-1, 4), (-1, 5), (-1, 6), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, 1), (1, 3), (1, 4), (1, 5), (2, 0), (2, 1), (2, 2), (2, 4), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (4, 2)] + +def cache_316_H_part1 : List Cell := [(4, 4), (4, 5), (4, 6)] + +def cache_316_H : List Cell := (cache_316_H_part0 ++ cache_316_H_part1) + +def cache_316 : ListRow := ⟨cache_316_A, cache_316_H, 9⟩ + +def cache_317_A_part0 : List Cell := [(-1, -3), (-1, -2), (-1, 0), (0, -3), (0, -2), (1, 0)] + +def cache_317_A : List Cell := cache_317_A_part0 + +def cache_317_H_part0 : List Cell := [(-4, 1), (-3, 0), (-3, 1), (-2, 0), (-2, 1), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, 0), (1, 1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1)] + +def cache_317_H_part1 : List Cell := [(5, -1), (5, 0), (5, 1)] + +def cache_317_H : List Cell := (cache_317_H_part0 ++ cache_317_H_part1) + +def cache_317 : ListRow := ⟨cache_317_A, cache_317_H, 9⟩ + +def cache_318_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1)] + +def cache_318_A : List Cell := cache_318_A_part0 + +def cache_318_H_part0 : List Cell := [(-2, 0), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (3, -1), (3, 0)] + +def cache_318_H_part1 : List Cell := [(3, 1), (4, 0), (4, 1)] + +def cache_318_H : List Cell := (cache_318_H_part0 ++ cache_318_H_part1) + +def cache_318 : ListRow := ⟨cache_318_A, cache_318_H, 10⟩ + +def cache_319_A_part0 : List Cell := [(-3, 1), (-2, 1), (-1, 1)] + +def cache_319_A : List Cell := cache_319_A_part0 + +def cache_319_H_part0 : List Cell := [(-6, 2), (-5, 1), (-5, 2), (-4, 1), (-4, 2), (-3, 1), (-2, 1), (-2, 2), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, 0), (1, 2), (1, 3), (1, 4)] + +def cache_319_H_part1 : List Cell := [(1, 5), (2, 0), (2, 3), (3, 3)] + +def cache_319_H : List Cell := (cache_319_H_part0 ++ cache_319_H_part1) + +def cache_319 : ListRow := ⟨cache_319_A, cache_319_H, 10⟩ + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/CacheData08.lean b/lean/OAI/Combinatorics/SnakyCertificate/CacheData08.lean new file mode 100644 index 0000000000000000000000000000000000000000..876410c581be4561b6d9f44c7b21227cdb8d8e01 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/CacheData08.lean @@ -0,0 +1,485 @@ +import OAI.Combinatorics.SnakyCertificate.Lists + +namespace OAI + +namespace SnakyCertificate.Check + +def cache_320_A_part0 : List Cell := [(0, -3), (0, -2), (1, -3), (1, 0), (3, 0)] + +def cache_320_A : List Cell := cache_320_A_part0 + +def cache_320_H_part0 : List Cell := [(-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -4), (1, -3), (1, 0), (1, 1), (2, 0), (2, 1), (3, 0), (3, 1), (4, 0)] + +def cache_320_H_part1 : List Cell := [(4, 1), (5, 0), (5, 1), (6, 1)] + +def cache_320_H : List Cell := (cache_320_H_part0 ++ cache_320_H_part1) + +def cache_320 : ListRow := ⟨cache_320_A, cache_320_H, 9⟩ + +def cache_321_A_part0 : List Cell := [(0, 1), (0, 2), (1, 1), (2, 1)] + +def cache_321_A : List Cell := cache_321_A_part0 + +def cache_321_H_part0 : List Cell := [(-3, 3), (-2, 3), (-1, -1), (-1, 0), (-1, 3), (-1, 4), (-1, 5), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (2, 1), (2, 2), (3, 1)] + +def cache_321_H_part1 : List Cell := [(3, 2), (4, 1), (4, 2), (5, 2)] + +def cache_321_H : List Cell := (cache_321_H_part0 ++ cache_321_H_part1) + +def cache_321 : ListRow := ⟨cache_321_A, cache_321_H, 8⟩ + +def cache_322_A_part0 : List Cell := [(-3, -3), (-3, -2), (-3, -1), (-2, -3), (-2, 0), (-1, -3), (0, -3)] + +def cache_322_A : List Cell := cache_322_A_part0 + +def cache_322_H_part0 : List Cell := [(-4, 0), (-4, 1), (-4, 2), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-2, -3), (-2, 0), (-2, 1), (-1, -3), (-1, 0), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (2, -4)] + +def cache_322_H_part1 : List Cell := [(2, -2), (2, -1), (2, 0), (2, 1)] + +def cache_322_H : List Cell := (cache_322_H_part0 ++ cache_322_H_part1) + +def cache_322 : ListRow := ⟨cache_322_A, cache_322_H, 9⟩ + +def cache_323_A_part0 : List Cell := [(-2, 0), (-1, -2), (-1, -1), (-1, 0)] + +def cache_323_A : List Cell := cache_323_A_part0 + +def cache_323_H_part0 : List Cell := [(-5, -1), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, 0), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1)] + +def cache_323_H_part1 : List Cell := [(3, -1), (3, 0), (3, 1), (4, -1)] + +def cache_323_H : List Cell := (cache_323_H_part0 ++ cache_323_H_part1) + +def cache_323 : ListRow := ⟨cache_323_A, cache_323_H, 8⟩ + +def cache_324_A_part0 : List Cell := [(-1, -1), (1, -3), (1, -2), (1, -1), (1, 0)] + +def cache_324_A : List Cell := cache_324_A_part0 + +def cache_324_H_part0 : List Cell := [(-4, -1), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-1, -1), (-1, 0), (0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (2, -1), (2, 0), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1)] + +def cache_324_H_part1 : List Cell := [(5, -1), (5, 0), (5, 1), (6, -1)] + +def cache_324_H : List Cell := (cache_324_H_part0 ++ cache_324_H_part1) + +def cache_324 : ListRow := ⟨cache_324_A, cache_324_H, 9⟩ + +def cache_325_A_part0 : List Cell := [(-1, 0), (1, -2), (1, -1), (1, 0), (1, 1)] + +def cache_325_A : List Cell := cache_325_A_part0 + +def cache_325_H_part0 : List Cell := [(-2, 0), (-1, 0), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1)] + +def cache_325_H_part1 : List Cell := [(5, -1), (5, 0), (5, 1), (6, 1)] + +def cache_325_H : List Cell := (cache_325_H_part0 ++ cache_325_H_part1) + +def cache_325 : ListRow := ⟨cache_325_A, cache_325_H, 8⟩ + +def cache_326_A_part0 : List Cell := [(-4, -3), (-3, 0), (-2, 0), (-1, 0)] + +def cache_326_A : List Cell := cache_326_A_part0 + +def cache_326_H_part0 : List Cell := [(-6, -4), (-6, -3), (-6, -2), (-6, -1), (-6, 1), (-5, -3), (-5, -2), (-5, -1), (-5, 0), (-5, 1), (-4, -4), (-4, -3), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-3, 0), (-3, 1), (-2, 0), (-1, 0), (0, -1), (0, 0), (0, 1), (1, -1)] + +def cache_326_H_part1 : List Cell := [(1, 0), (1, 1), (2, -1), (2, 1)] + +def cache_326_H : List Cell := (cache_326_H_part0 ++ cache_326_H_part1) + +def cache_326 : ListRow := ⟨cache_326_A, cache_326_H, 10⟩ + +def cache_327_A_part0 : List Cell := [(-1, -1), (-1, 0), (1, -1), (1, 0)] + +def cache_327_A : List Cell := cache_327_A_part0 + +def cache_327_H_part0 : List Cell := [(-6, -1), (-5, -1), (-5, 0), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, 0), (1, -1), (1, 0), (2, -1), (2, 0), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0)] + +def cache_327_H_part1 : List Cell := [(4, 1), (5, -1), (5, 0), (5, 1), (6, -1)] + +def cache_327_H : List Cell := (cache_327_H_part0 ++ cache_327_H_part1) + +def cache_327 : ListRow := ⟨cache_327_A, cache_327_H, 8⟩ + +def cache_328_A_part0 : List Cell := [(-1, -3), (0, -3), (0, -2), (0, -1)] + +def cache_328_A : List Cell := cache_328_A_part0 + +def cache_328_H_part0 : List Cell := [(-3, 0), (-2, 0), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (-1, 2), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (3, -1), (3, 0)] + +def cache_328_H_part1 : List Cell := [(3, 1), (4, -1), (4, 0), (4, 1), (5, -1)] + +def cache_328_H : List Cell := (cache_328_H_part0 ++ cache_328_H_part1) + +def cache_328 : ListRow := ⟨cache_328_A, cache_328_H, 10⟩ + +def cache_329_A_part0 : List Cell := [(-1, -2), (-1, -1), (-1, 1), (0, -2), (0, -1), (0, 1)] + +def cache_329_A : List Cell := cache_329_A_part0 + +def cache_329_H_part0 : List Cell := [(-4, 0), (-4, 2), (-3, 0), (-3, 1), (-3, 2), (-2, 0), (-2, 1), (-2, 2), (-1, -2), (-1, -1), (-1, 1), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2), (3, 0), (3, 1)] + +def cache_329_H_part1 : List Cell := [(3, 2), (4, 0), (4, 1), (4, 2), (5, 0)] + +def cache_329_H : List Cell := (cache_329_H_part0 ++ cache_329_H_part1) + +def cache_329 : ListRow := ⟨cache_329_A, cache_329_H, 9⟩ + +def cache_330_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0)] + +def cache_330_A : List Cell := cache_330_A_part0 + +def cache_330_H_part0 : List Cell := [(-5, 0), (-4, 0), (-3, 0), (-3, 1), (-2, 0), (-2, 1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -1)] + +def cache_330_H_part1 : List Cell := [(2, 0), (2, 1), (2, 2), (3, 1), (3, 2)] + +def cache_330_H : List Cell := (cache_330_H_part0 ++ cache_330_H_part1) + +def cache_330 : ListRow := ⟨cache_330_A, cache_330_H, 10⟩ + +def cache_331_A_part0 : List Cell := [(-4, -1), (-3, -1), (-2, -1), (-2, 0), (-2, 1), (-1, 1)] + +def cache_331_A : List Cell := cache_331_A_part0 + +def cache_331_H_part0 : List Cell := [(-7, 0), (-6, 0), (-6, 1), (-6, 2), (-5, 0), (-5, 1), (-5, 2), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-1, 0), (-1, 1), (0, 0), (0, 1), (1, 0), (1, 1), (1, 2)] + +def cache_331_H_part1 : List Cell := [(2, 0), (2, 1), (2, 2), (3, 0), (3, 2)] + +def cache_331_H : List Cell := (cache_331_H_part0 ++ cache_331_H_part1) + +def cache_331 : ListRow := ⟨cache_331_A, cache_331_H, 9⟩ + +def cache_332_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1), (1, -1), (1, 0)] + +def cache_332_A : List Cell := cache_332_A_part0 + +def cache_332_H_part0 : List Cell := [(-3, 0), (-2, 0), (-1, -4), (-1, -3), (-1, 0), (-1, 1), (0, -3), (0, -2), (0, -1), (0, 0), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (2, -4), (2, -3), (2, -2), (2, -1), (3, -4), (3, -3), (3, -2), (4, -4), (4, -3)] + +def cache_332_H_part1 : List Cell := [(4, -2), (5, -4), (5, -3), (5, -2), (6, -2)] + +def cache_332_H : List Cell := (cache_332_H_part0 ++ cache_332_H_part1) + +def cache_332 : ListRow := ⟨cache_332_A, cache_332_H, 10⟩ + +def cache_333_A_part0 : List Cell := [(0, -3), (0, -2), (1, -4), (1, -3), (1, -2), (2, 0)] + +def cache_333_A : List Cell := cache_333_A_part0 + +def cache_333_H_part0 : List Cell := [(-3, 1), (-2, 0), (-2, 1), (-1, 0), (-1, 1), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (2, 0), (2, 1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1)] + +def cache_333_H_part1 : List Cell := [(5, 0), (5, 1), (6, -1), (6, 0), (6, 1)] + +def cache_333_H : List Cell := (cache_333_H_part0 ++ cache_333_H_part1) + +def cache_333 : ListRow := ⟨cache_333_A, cache_333_H, 10⟩ + +def cache_334_A_part0 : List Cell := [(0, -2), (0, -1), (0, 1), (1, -2), (1, -1)] + +def cache_334_A : List Cell := cache_334_A_part0 + +def cache_334_H_part0 : List Cell := [(-3, -2), (-2, -2), (-1, -3), (-1, -2), (-1, 1), (-1, 2), (0, -2), (0, -1), (0, 0), (0, 1), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (2, -1), (2, 0), (2, 1), (2, 2), (3, 0), (3, 1), (3, 2), (4, 0), (4, 1)] + +def cache_334_H_part1 : List Cell := [(4, 2), (5, 0), (5, 1), (5, 2), (6, 0)] + +def cache_334_H : List Cell := (cache_334_H_part0 ++ cache_334_H_part1) + +def cache_334 : ListRow := ⟨cache_334_A, cache_334_H, 10⟩ + +def cache_335_A_part0 : List Cell := [(-3, 0), (-2, -2), (-2, 0), (-1, -1), (-1, 0)] + +def cache_335_A : List Cell := cache_335_A_part0 + +def cache_335_H_part0 : List Cell := [(-4, -1), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-2, -2), (-2, -1), (-2, 0), (-2, 2), (-2, 3), (-2, 4), (-1, -1), (-1, 0), (0, -1), (0, 0), (1, -1), (1, 0), (1, 1), (2, -1)] + +def cache_335_H_part1 : List Cell := [(2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, -1)] + +def cache_335_H : List Cell := (cache_335_H_part0 ++ cache_335_H_part1) + +def cache_335 : ListRow := ⟨cache_335_A, cache_335_H, 9⟩ + +def cache_336_A_part0 : List Cell := [(-1, -1), (-1, 0), (1, 0)] + +def cache_336_A : List Cell := cache_336_A_part0 + +def cache_336_H_part0 : List Cell := [(-5, -1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-1, -2), (-1, -1), (-1, 0), (0, -1), (0, 0), (0, 1), (1, 0), (1, 1), (2, 0), (2, 1), (3, -1), (3, 0)] + +def cache_336_H_part1 : List Cell := [(3, 1), (4, -1), (4, 0), (4, 1), (5, -1), (5, 1)] + +def cache_336_H : List Cell := (cache_336_H_part0 ++ cache_336_H_part1) + +def cache_336 : ListRow := ⟨cache_336_A, cache_336_H, 9⟩ + +def cache_337_A_part0 : List Cell := [(-3, 0), (-1, 0), (-1, 1), (-1, 2)] + +def cache_337_A : List Cell := cache_337_A_part0 + +def cache_337_H_part0 : List Cell := [(-4, 1), (-3, 0), (-3, 1), (-2, 0), (-2, 1), (-2, 3), (-2, 4), (-2, 5), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -1), (0, 0), (0, 1), (0, 3), (0, 4), (0, 5), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0)] + +def cache_337_H_part1 : List Cell := [(2, 1), (3, -1), (3, 0), (3, 1), (4, -1), (4, 1)] + +def cache_337_H : List Cell := (cache_337_H_part0 ++ cache_337_H_part1) + +def cache_337 : ListRow := ⟨cache_337_A, cache_337_H, 9⟩ + +def cache_338_A_part0 : List Cell := [(-1, 0), (1, -2), (1, -1), (1, 0)] + +def cache_338_A : List Cell := cache_338_A_part0 + +def cache_338_H_part0 : List Cell := [(-4, -1), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-1, 0), (-1, 1), (0, -1), (0, 0), (1, -2), (1, -1), (1, 0), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (3, -1), (3, 0), (3, 1), (4, -1)] + +def cache_338_H_part1 : List Cell := [(4, 0), (4, 1), (5, -1), (5, 0), (5, 1), (6, 1)] + +def cache_338_H : List Cell := (cache_338_H_part0 ++ cache_338_H_part1) + +def cache_338 : ListRow := ⟨cache_338_A, cache_338_H, 8⟩ + +def cache_339_A_part0 : List Cell := [(-1, -4), (-1, -3), (-1, -2), (-1, -1), (0, -3), (1, -3), (2, -3)] + +def cache_339_A : List Cell := cache_339_A_part0 + +def cache_339_H_part0 : List Cell := [(-2, 0), (-2, 1), (-2, 2), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (0, -3), (0, -1), (0, 0), (0, 1), (1, -3), (1, 0), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (3, -4), (3, -3), (3, -2), (3, -1)] + +def cache_339_H_part1 : List Cell := [(3, 0), (4, -4), (4, -2), (4, -1), (4, 0), (4, 1)] + +def cache_339_H : List Cell := (cache_339_H_part0 ++ cache_339_H_part1) + +def cache_339 : ListRow := ⟨cache_339_A, cache_339_H, 10⟩ + +def cache_340_A_part0 : List Cell := [(-1, 1), (0, -1), (0, 1)] + +def cache_340_A : List Cell := cache_340_A_part0 + +def cache_340_H_part0 : List Cell := [(-4, -2), (-4, 0), (-3, -2), (-3, -1), (-3, 0), (-2, -2), (-2, -1), (-2, 0), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -2), (1, -1), (1, 0)] + +def cache_340_H_part1 : List Cell := [(1, 2), (1, 3), (1, 4), (2, -1), (2, 0), (3, 0)] + +def cache_340_H : List Cell := (cache_340_H_part0 ++ cache_340_H_part1) + +def cache_340 : ListRow := ⟨cache_340_A, cache_340_H, 10⟩ + +def cache_341_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0), (-1, 1)] + +def cache_341_A : List Cell := cache_341_A_part0 + +def cache_341_H_part0 : List Cell := [(-4, -1), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-2, -1), (-2, 0), (-2, 2), (-2, 3), (-2, 4), (-1, 0), (-1, 1), (-1, 2), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1)] + +def cache_341_H_part1 : List Cell := [(2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, 1)] + +def cache_341_H : List Cell := (cache_341_H_part0 ++ cache_341_H_part1) + +def cache_341 : ListRow := ⟨cache_341_A, cache_341_H, 9⟩ + +def cache_342_A_part0 : List Cell := [(-2, -2), (-1, -3), (-1, -2), (0, -3), (0, -2)] + +def cache_342_A : List Cell := cache_342_A_part0 + +def cache_342_H_part0 : List Cell := [(-4, -1), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1)] + +def cache_342_H_part1 : List Cell := [(2, -3), (2, -2), (2, -1), (3, -3), (3, -2), (3, -1)] + +def cache_342_H : List Cell := (cache_342_H_part0 ++ cache_342_H_part1) + +def cache_342 : ListRow := ⟨cache_342_A, cache_342_H, 9⟩ + +def cache_343_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1), (1, -3), (1, -2)] + +def cache_343_A : List Cell := cache_343_A_part0 + +def cache_343_H_part0 : List Cell := [(-1, -1), (-1, 0), (-1, 1), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1)] + +def cache_343_H : List Cell := cache_343_H_part0 + +def cache_343 : ListRow := ⟨cache_343_A, cache_343_H, 9⟩ + +def cache_344_A_part0 : List Cell := [(0, -4), (0, -3), (0, -2), (0, -1), (1, -3), (2, -3), (3, -3), (3, -2)] + +def cache_344_A : List Cell := cache_344_A_part0 + +def cache_344_H_part0 : List Cell := [(-1, -1), (-1, 1), (-1, 2), (-1, 3), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (3, -3)] + +def cache_344_H_part1 : List Cell := [(3, -2), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1)] + +def cache_344_H : List Cell := (cache_344_H_part0 ++ cache_344_H_part1) + +def cache_344 : ListRow := ⟨cache_344_A, cache_344_H, 10⟩ + +def cache_345_A_part0 : List Cell := [(-3, 0), (-3, 3), (-2, 0), (-1, 0), (-1, 3), (0, 1)] + +def cache_345_A : List Cell := cache_345_A_part0 + +def cache_345_H_part0 : List Cell := [(-6, 4), (-5, 3), (-5, 4), (-4, 3), (-4, 4), (-3, 0), (-3, 3), (-3, 4), (-2, 0), (-2, 3), (-2, 4), (-1, -1), (-1, 0), (-1, 3), (-1, 4), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, 1), (1, 2), (1, 3), (1, 4)] + +def cache_345_H_part1 : List Cell := [(1, 5), (2, 2), (2, 3), (2, 4), (3, 2), (3, 3), (3, 4)] + +def cache_345_H : List Cell := (cache_345_H_part0 ++ cache_345_H_part1) + +def cache_345 : ListRow := ⟨cache_345_A, cache_345_H, 10⟩ + +def cache_346_A_part0 : List Cell := [(-3, -4), (-3, -3), (-3, -2), (-3, -1), (-1, -3), (0, -3), (0, -2)] + +def cache_346_A : List Cell := cache_346_A_part0 + +def cache_346_H_part0 : List Cell := [(-4, -1), (-4, 0), (-4, 1), (-4, 2), (-3, -4), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-2, 0), (-2, 1), (-2, 2), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -3), (0, -2), (0, -1)] + +def cache_346_H_part1 : List Cell := [(0, 0), (0, 1), (0, 2), (1, -1), (1, 0), (1, 1), (1, 2)] + +def cache_346_H : List Cell := (cache_346_H_part0 ++ cache_346_H_part1) + +def cache_346 : ListRow := ⟨cache_346_A, cache_346_H, 10⟩ + +def cache_347_A_part0 : List Cell := [(0, 1), (0, 2), (0, 3), (1, 1), (2, 1), (3, 1)] + +def cache_347_A : List Cell := cache_347_A_part0 + +def cache_347_H_part0 : List Cell := [(-1, 0), (-1, 4), (-1, 5), (-1, 6), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, 1), (1, 3), (1, 4), (1, 5), (2, 1), (2, 4), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (4, 0), (4, 1), (4, 2)] + +def cache_347_H_part1 : List Cell := [(4, 3), (4, 4), (5, 0), (5, 2), (5, 3), (5, 4), (5, 5)] + +def cache_347_H : List Cell := (cache_347_H_part0 ++ cache_347_H_part1) + +def cache_347 : ListRow := ⟨cache_347_A, cache_347_H, 11⟩ + +def cache_348_A_part0 : List Cell := [(-2, 0), (-2, 1), (-1, -1), (0, -2), (0, -1), (1, -1), (1, 0)] + +def cache_348_A : List Cell := cache_348_A_part0 + +def cache_348_H_part0 : List Cell := [(-3, 1), (-2, 0), (-2, 1), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3), (3, -2)] + +def cache_348_H_part1 : List Cell := [(3, -1), (3, 0), (3, 1), (3, 2), (4, 0), (4, 1), (4, 2)] + +def cache_348_H : List Cell := (cache_348_H_part0 ++ cache_348_H_part1) + +def cache_348 : ListRow := ⟨cache_348_A, cache_348_H, 11⟩ + +def cache_349_A_part0 : List Cell := [(-1, -3), (-1, -2), (-1, -1), (0, -1)] + +def cache_349_A : List Cell := cache_349_A_part0 + +def cache_349_H_part0 : List Cell := [(-4, 0), (-3, 0), (-2, -4), (-2, -3), (-2, 0), (-2, 1), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -4), (1, -3), (1, -2), (1, -1), (2, -4), (2, -3), (2, -2)] + +def cache_349_H_part1 : List Cell := [(3, -4), (3, -3), (3, -2), (4, -4), (4, -3), (4, -2), (5, -2)] + +def cache_349_H : List Cell := (cache_349_H_part0 ++ cache_349_H_part1) + +def cache_349 : ListRow := ⟨cache_349_A, cache_349_H, 11⟩ + +def cache_350_A_part0 : List Cell := [(-1, 0), (-1, 1), (1, 0), (1, 2)] + +def cache_350_A : List Cell := cache_350_A_part0 + +def cache_350_H_part0 : List Cell := [(-4, -1), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-1, 0), (-1, 1), (0, -1), (0, 0), (0, 3), (0, 4), (0, 5), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -1), (2, 0), (2, 1), (2, 3)] + +def cache_350_H_part1 : List Cell := [(2, 4), (2, 5), (3, -1), (3, 0), (3, 1), (4, -1), (4, 1)] + +def cache_350_H : List Cell := (cache_350_H_part0 ++ cache_350_H_part1) + +def cache_350 : ListRow := ⟨cache_350_A, cache_350_H, 8⟩ + +def cache_351_A_part0 : List Cell := [(-2, -1), (-2, 0), (-2, 1), (-1, 0)] + +def cache_351_A : List Cell := cache_351_A_part0 + +def cache_351_H_part0 : List Cell := [(-5, 1), (-4, 0), (-4, 1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-1, -1), (-1, 0), (-1, 1), (-1, 3), (-1, 4), (-1, 5), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -1), (1, 0), (1, 1), (1, 2)] + +def cache_351_H_part1 : List Cell := [(1, 3), (1, 4), (2, -1), (2, 0), (2, 1), (3, -1), (3, 1)] + +def cache_351_H : List Cell := (cache_351_H_part0 ++ cache_351_H_part1) + +def cache_351 : ListRow := ⟨cache_351_A, cache_351_H, 11⟩ + +def cache_352_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1), (1, -2), (2, -2), (3, -2), (3, -1)] + +def cache_352_A : List Cell := cache_352_A_part0 + +def cache_352_H_part0 : List Cell := [(-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2)] + +def cache_352_H_part1 : List Cell := [(3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (4, 0), (4, 1), (4, 2)] + +def cache_352_H : List Cell := (cache_352_H_part0 ++ cache_352_H_part1) + +def cache_352 : ListRow := ⟨cache_352_A, cache_352_H, 11⟩ + +def cache_353_A_part0 : List Cell := [(-3, 0), (-3, 1), (-3, 2), (-2, 0), (-1, 0)] + +def cache_353_A : List Cell := cache_353_A_part0 + +def cache_353_H_part0 : List Cell := [(-4, -1), (-4, 1), (-4, 3), (-4, 4), (-4, 5), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-2, 0), (-2, 2), (-2, 3), (-2, 4), (-1, 0), (-1, 3), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -1), (1, 0)] + +def cache_353_H_part1 : List Cell := [(1, 1), (1, 2), (1, 3), (2, -1), (2, 1), (2, 2), (2, 3), (2, 4)] + +def cache_353_H : List Cell := (cache_353_H_part0 ++ cache_353_H_part1) + +def cache_353 : ListRow := ⟨cache_353_A, cache_353_H, 12⟩ + +def cache_354_A_part0 : List Cell := [(-1, -1), (-1, 0), (-1, 1), (0, -2), (0, 1), (1, -2)] + +def cache_354_A : List Cell := cache_354_A_part0 + +def cache_354_H_part0 : List Cell := [(-3, 0), (-2, -1), (-2, 0), (-2, 3), (-1, -1), (-1, 0), (-1, 1), (-1, 3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 3), (0, 4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -1), (2, 0)] + +def cache_354_H_part1 : List Cell := [(2, 1), (2, 2), (2, 3), (2, 4), (3, 0), (3, 1), (3, 2), (4, 0)] + +def cache_354_H : List Cell := (cache_354_H_part0 ++ cache_354_H_part1) + +def cache_354 : ListRow := ⟨cache_354_A, cache_354_H, 11⟩ + +def cache_355_A_part0 : List Cell := [(1, -1), (1, 0), (2, -1), (2, 0)] + +def cache_355_A : List Cell := cache_355_A_part0 + +def cache_355_H_part0 : List Cell := [(-2, 0), (-2, 1), (-2, 3), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, 0), (0, 1), (0, 2), (0, 3), (1, -1), (1, 0), (1, 2), (1, 3), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (3, -2), (3, -1), (3, 0), (3, 1)] + +def cache_355_H_part1 : List Cell := [(3, 2), (3, 3), (4, -1), (4, 0), (4, 1), (5, -1), (5, 0), (5, 1)] + +def cache_355_H : List Cell := (cache_355_H_part0 ++ cache_355_H_part1) + +def cache_355 : ListRow := ⟨cache_355_A, cache_355_H, 10⟩ + +def cache_356_A_part0 : List Cell := [(-1, -1), (-1, 0), (1, -1), (1, 0), (1, 1)] + +def cache_356_A : List Cell := cache_356_A_part0 + +def cache_356_H_part0 : List Cell := [(-4, -1), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (3, -1), (3, 0), (4, -1), (4, 0), (5, -1), (5, 0), (6, -1)] + +def cache_356_H : List Cell := cache_356_H_part0 + +def cache_356 : ListRow := ⟨cache_356_A, cache_356_H, 8⟩ + +def cache_357_A_part0 : List Cell := [(-2, 2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (0, 2)] + +def cache_357_A : List Cell := cache_357_A_part0 + +def cache_357_H_part0 : List Cell := [(-4, -1), (-3, -1), (-3, 1), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (0, 0), (0, 1), (0, 2), (0, 4), (0, 5), (0, 6), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5)] + +def cache_357_H_part1 : List Cell := [(2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, 1), (3, 3)] + +def cache_357_H : List Cell := (cache_357_H_part0 ++ cache_357_H_part1) + +def cache_357 : ListRow := ⟨cache_357_A, cache_357_H, 10⟩ + +def cache_358_A_part0 : List Cell := [(-3, -2), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-1, -1), (0, -1)] + +def cache_358_A : List Cell := cache_358_A_part0 + +def cache_358_H_part0 : List Cell := [(-4, 1), (-4, 2), (-4, 3), (-4, 4), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-2, -1), (-2, 2), (-2, 3), (-2, 4), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, -1), (0, 0)] + +def cache_358_H_part1 : List Cell := [(0, 1), (0, 2), (0, 3), (0, 4), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4)] + +def cache_358_H : List Cell := (cache_358_H_part0 ++ cache_358_H_part1) + +def cache_358 : ListRow := ⟨cache_358_A, cache_358_H, 11⟩ + +def cache_359_A_part0 : List Cell := [(-1, -1), (-1, 1), (0, -1), (0, 1)] + +def cache_359_A : List Cell := cache_359_A_part0 + +def cache_359_H_part0 : List Cell := [(-4, 0), (-4, 2), (-3, 0), (-3, 1), (-3, 2), (-2, 0), (-2, 1), (-2, 2), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 1), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, 0)] + +def cache_359_H_part1 : List Cell := [(2, 1), (2, 2), (3, 0), (3, 1), (3, 2), (4, 0), (4, 1), (4, 2), (5, 0)] + +def cache_359_H : List Cell := (cache_359_H_part0 ++ cache_359_H_part1) + +def cache_359 : ListRow := ⟨cache_359_A, cache_359_H, 9⟩ + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/CacheData09.lean b/lean/OAI/Combinatorics/SnakyCertificate/CacheData09.lean new file mode 100644 index 0000000000000000000000000000000000000000..a3d33ebfd994f9e728c5f6ba95ad97c0cc72ab47 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/CacheData09.lean @@ -0,0 +1,487 @@ +import OAI.Combinatorics.SnakyCertificate.Lists + +namespace OAI + +namespace SnakyCertificate.Check + +def cache_360_A_part0 : List Cell := [(-2, -2), (0, -4), (0, -3), (0, -2), (0, -1)] + +def cache_360_A : List Cell := cache_360_A_part0 + +def cache_360_H_part0 : List Cell := [(-3, -1), (-2, -2), (-2, -1), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -3), (1, -2), (1, -1), (1, 1), (1, 2), (1, 3), (2, -3), (2, -2)] + +def cache_360_H_part1 : List Cell := [(2, -1), (3, -3), (3, -2), (3, -1), (4, -3), (4, -2), (4, -1), (5, -3), (5, -1)] + +def cache_360_H : List Cell := (cache_360_H_part0 ++ cache_360_H_part1) + +def cache_360 : ListRow := ⟨cache_360_A, cache_360_H, 10⟩ + +def cache_361_A_part0 : List Cell := [(0, -2), (0, -1), (1, -1), (2, -1), (3, -1), (3, 0)] + +def cache_361_A : List Cell := cache_361_A_part0 + +def cache_361_H_part0 : List Cell := [(-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, -1), (2, 0), (2, 1), (2, 2)] + +def cache_361_H_part1 : List Cell := [(2, 3), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (4, 1), (4, 2), (4, 3)] + +def cache_361_H : List Cell := (cache_361_H_part0 ++ cache_361_H_part1) + +def cache_361 : ListRow := ⟨cache_361_A, cache_361_H, 12⟩ + +def cache_362_A_part0 : List Cell := [(-4, -1), (-3, -1), (-3, 2), (-2, -1), (-1, -1), (-1, 2)] + +def cache_362_A : List Cell := cache_362_A_part0 + +def cache_362_H_part0 : List Cell := [(-6, 3), (-5, 2), (-5, 3), (-4, -1), (-4, 2), (-4, 3), (-3, -1), (-3, 2), (-3, 3), (-2, -1), (-2, 2), (-2, 3), (-1, -2), (-1, -1), (-1, 0), (-1, 2), (-1, 3), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1)] + +def cache_362_H_part1 : List Cell := [(1, 2), (1, 3), (1, 4), (2, 1), (2, 2), (2, 3), (3, 1), (3, 2), (3, 3)] + +def cache_362_H : List Cell := (cache_362_H_part0 ++ cache_362_H_part1) + +def cache_362 : ListRow := ⟨cache_362_A, cache_362_H, 11⟩ + +def cache_363_A_part0 : List Cell := [(-4, -3), (-3, -3), (-3, 0), (-2, -3), (-1, -3), (-1, 0)] + +def cache_363_A : List Cell := cache_363_A_part0 + +def cache_363_H_part0 : List Cell := [(-5, -1), (-4, -3), (-4, -1), (-4, 0), (-3, -3), (-3, -1), (-3, 0), (-2, -3), (-2, -1), (-2, 0), (-2, 1), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -4), (1, -3), (1, -2)] + +def cache_363_H_part1 : List Cell := [(1, -1), (1, 0), (1, 1), (2, -4), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1)] + +def cache_363_H : List Cell := (cache_363_H_part0 ++ cache_363_H_part1) + +def cache_363 : ListRow := ⟨cache_363_A, cache_363_H, 9⟩ + +def cache_364_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1)] + +def cache_364_A : List Cell := cache_364_A_part0 + +def cache_364_H_part0 : List Cell := [(-4, -4), (-4, -2), (-3, -4), (-3, -3), (-3, -2), (-2, -4), (-2, -3), (-2, -2), (-1, -4), (-1, -3), (-1, 0), (-1, 1), (-1, 2), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -4), (1, -3), (1, -2), (1, 0), (1, 1), (1, 2)] + +def cache_364_H_part1 : List Cell := [(2, -4), (2, -3), (2, -2), (3, -4), (3, -3), (3, -2), (4, -4), (4, -3), (4, -2), (5, -2)] + +def cache_364_H : List Cell := (cache_364_H_part0 ++ cache_364_H_part1) + +def cache_364 : ListRow := ⟨cache_364_A, cache_364_H, 10⟩ + +def cache_365_A_part0 : List Cell := [(-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -3), (1, -3)] + +def cache_365_A : List Cell := cache_365_A_part0 + +def cache_365_H_part0 : List Cell := [(-3, -1), (-2, -2), (-2, -1), (-2, 2), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 2), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3)] + +def cache_365_H_part1 : List Cell := [(2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (3, -1), (3, 0), (3, 1), (4, -1)] + +def cache_365_H : List Cell := (cache_365_H_part0 ++ cache_365_H_part1) + +def cache_365 : ListRow := ⟨cache_365_A, cache_365_H, 12⟩ + +def cache_366_A_part0 : List Cell := [(1, -3), (1, -2), (1, -1), (1, 0), (2, 0)] + +def cache_366_A : List Cell := cache_366_A_part0 + +def cache_366_H_part0 : List Cell := [(-2, -3), (-1, -3), (-1, -1), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -3), (1, -2), (1, -1), (1, 0), (2, -2), (2, -1), (2, 0), (2, 2), (2, 3), (2, 4), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2)] + +def cache_366_H_part1 : List Cell := [(3, 3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (5, -1), (5, 1)] + +def cache_366_H : List Cell := (cache_366_H_part0 ++ cache_366_H_part1) + +def cache_366 : ListRow := ⟨cache_366_A, cache_366_H, 11⟩ + +def cache_367_A_part0 : List Cell := [(-3, 1), (-3, 2), (-2, 1), (-1, 1), (0, 1)] + +def cache_367_A : List Cell := cache_367_A_part0 + +def cache_367_H_part0 : List Cell := [(-4, 3), (-4, 4), (-4, 5), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (0, 0), (0, 1), (0, 2), (0, 3)] + +def cache_367_H_part1 : List Cell := [(0, 4), (0, 5), (0, 6), (1, 0), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7)] + +def cache_367_H : List Cell := (cache_367_H_part0 ++ cache_367_H_part1) + +def cache_367 : ListRow := ⟨cache_367_A, cache_367_H, 13⟩ + +def cache_368_A_part0 : List Cell := [(-1, -3), (-1, -2), (-1, -1), (-1, 0)] + +def cache_368_A : List Cell := cache_368_A_part0 + +def cache_368_H_part0 : List Cell := [(-4, -3), (-3, -3), (-3, -1), (-2, -4), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -2), (1, -1), (1, 0), (1, 1)] + +def cache_368_H_part1 : List Cell := [(1, 2), (1, 3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -1), (3, 1)] + +def cache_368_H : List Cell := (cache_368_H_part0 ++ cache_368_H_part1) + +def cache_368 : ListRow := ⟨cache_368_A, cache_368_H, 12⟩ + +def cache_369_A_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -1), (0, -1)] + +def cache_369_A : List Cell := cache_369_A_part0 + +def cache_369_H_part0 : List Cell := [(-4, -2), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-1, -1), (-1, 0), (-1, 1)] + +def cache_369_H_part1 : List Cell := [(-1, 2), (-1, 3), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3)] + +def cache_369_H : List Cell := (cache_369_H_part0 ++ cache_369_H_part1) + +def cache_369 : ListRow := ⟨cache_369_A, cache_369_H, 14⟩ + +def cache_370_A_part0 : List Cell := [(-2, -1), (-2, 0), (-1, 0)] + +def cache_370_A : List Cell := cache_370_A_part0 + +def cache_370_H_part0 : List Cell := [(-5, -1), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-2, -2), (-2, -1), (-2, 0), (-1, 0), (-1, 1), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -2), (1, -1), (1, 0), (1, 1)] + +def cache_370_H_part1 : List Cell := [(1, 2), (1, 3), (1, 4), (2, -1), (2, 1), (2, 2), (2, 3), (2, 4), (3, -1), (3, 2), (4, 2)] + +def cache_370_H : List Cell := (cache_370_H_part0 ++ cache_370_H_part1) + +def cache_370 : ListRow := ⟨cache_370_A, cache_370_H, 11⟩ + +def cache_371_A_part0 : List Cell := [(-4, -3), (-3, -3), (-3, 0), (-2, -3), (-1, -3), (-1, 0)] + +def cache_371_A : List Cell := cache_371_A_part0 + +def cache_371_H_part0 : List Cell := [(-6, 1), (-5, 0), (-5, 1), (-4, -3), (-4, 0), (-4, 1), (-3, -3), (-3, 0), (-3, 1), (-2, -3), (-2, 0), (-2, 1), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -4), (1, -3)] + +def cache_371_H_part1 : List Cell := [(1, -2), (1, -1), (1, 0), (1, 1), (2, -4), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1)] + +def cache_371_H : List Cell := (cache_371_H_part0 ++ cache_371_H_part1) + +def cache_371 : ListRow := ⟨cache_371_A, cache_371_H, 9⟩ + +def cache_372_A_part0 : List Cell := [(-2, -3), (-2, -2), (-1, -4), (-1, -3), (-1, -2)] + +def cache_372_A : List Cell := cache_372_A_part0 + +def cache_372_H_part0 : List Cell := [(-5, 1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -2), (1, 0)] + +def cache_372_H_part1 : List Cell := [(1, 1), (2, -2), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1)] + +def cache_372_H : List Cell := (cache_372_H_part0 ++ cache_372_H_part1) + +def cache_372 : ListRow := ⟨cache_372_A, cache_372_H, 11⟩ + +def cache_373_A_part0 : List Cell := [(-1, -1), (0, -1), (0, 1), (2, -1), (2, 0), (2, 1)] + +def cache_373_A : List Cell := cache_373_A_part0 + +def cache_373_H_part0 : List Cell := [(-5, 0), (-5, 2), (-4, 0), (-4, 1), (-4, 2), (-3, 0), (-3, 1), (-3, 2), (-2, 0), (-2, 1), (-2, 2), (-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 0), (0, 1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0)] + +def cache_373_H_part1 : List Cell := [(3, 1), (4, 0), (4, 1), (4, 2), (5, 0), (5, 1), (5, 2), (6, 0), (6, 1), (6, 2), (7, 0)] + +def cache_373_H : List Cell := (cache_373_H_part0 ++ cache_373_H_part1) + +def cache_373 : ListRow := ⟨cache_373_A, cache_373_H, 9⟩ + +def cache_374_A_part0 : List Cell := [(1, -2), (1, 0), (2, -1), (2, 0)] + +def cache_374_A : List Cell := cache_374_A_part0 + +def cache_374_H_part0 : List Cell := [(-3, -1), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -2), (1, -1), (1, 0), (1, 2), (1, 3), (1, 4), (2, -1), (2, 0)] + +def cache_374_H_part1 : List Cell := [(3, -1), (3, 0), (4, -1), (4, 0), (4, 1), (5, -1), (5, 0), (5, 1), (6, -1), (6, 0), (6, 1), (7, -1)] + +def cache_374_H : List Cell := (cache_374_H_part0 ++ cache_374_H_part1) + +def cache_374 : ListRow := ⟨cache_374_A, cache_374_H, 10⟩ + +def cache_375_A_part0 : List Cell := [(-2, -1), (-2, 0), (-1, 1), (0, -1), (0, 1)] + +def cache_375_A : List Cell := cache_375_A_part0 + +def cache_375_H_part0 : List Cell := [(-7, 0), (-6, -2), (-6, -1), (-6, 0), (-5, -2), (-5, -1), (-5, 0), (-4, -2), (-4, -1), (-4, 0), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, -1), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2)] + +def cache_375_H_part1 : List Cell := [(1, -1), (1, 0), (2, -2), (2, -1), (2, 0), (3, -2), (3, -1), (3, 0), (4, -2), (4, -1), (4, 0), (5, 0)] + +def cache_375_H : List Cell := (cache_375_H_part0 ++ cache_375_H_part1) + +def cache_375 : ListRow := ⟨cache_375_A, cache_375_H, 9⟩ + +def cache_376_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, -1), (-1, 0)] + +def cache_376_A : List Cell := cache_376_A_part0 + +def cache_376_H_part0 : List Cell := [(-6, 2), (-5, 2), (-4, -1), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-1, -1), (-1, 0), (-1, 1)] + +def cache_376_H_part1 : List Cell := [(0, -1), (0, 0), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, -1)] + +def cache_376_H : List Cell := (cache_376_H_part0 ++ cache_376_H_part1) + +def cache_376 : ListRow := ⟨cache_376_A, cache_376_H, 10⟩ + +def cache_377_A_part0 : List Cell := [(-1, -3), (0, -3), (0, -2), (1, -3), (2, -3), (2, 0)] + +def cache_377_A : List Cell := cache_377_A_part0 + +def cache_377_H_part0 : List Cell := [(-3, 1), (-2, -4), (-2, 0), (-2, 1), (-1, -4), (-1, -3), (-1, 0), (-1, 1), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -3), (1, 0), (1, 1), (2, -4), (2, -3), (2, -2), (2, 0), (2, 1), (3, -3), (3, -2), (3, -1)] + +def cache_377_H_part1 : List Cell := [(3, 0), (3, 1), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (5, -1), (5, 0), (5, 1), (6, -1), (6, 0), (6, 1)] + +def cache_377_H : List Cell := (cache_377_H_part0 ++ cache_377_H_part1) + +def cache_377 : ListRow := ⟨cache_377_A, cache_377_H, 12⟩ + +def cache_378_A_part0 : List Cell := [(-2, 0), (-1, -2), (-1, 0)] + +def cache_378_A : List Cell := cache_378_A_part0 + +def cache_378_H_part0 : List Cell := [(-5, -1), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, 0), (-2, 1), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -1)] + +def cache_378_H_part1 : List Cell := [(1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -1), (3, 1)] + +def cache_378_H : List Cell := (cache_378_H_part0 ++ cache_378_H_part1) + +def cache_378 : ListRow := ⟨cache_378_A, cache_378_H, 11⟩ + +def cache_379_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1)] + +def cache_379_A : List Cell := cache_379_A_part0 + +def cache_379_H_part0 : List Cell := [(-3, -3), (-2, -3), (-2, -1), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -2), (2, -1)] + +def cache_379_H_part1 : List Cell := [(2, 0), (2, 1), (2, 2), (2, 3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -1), (4, 1)] + +def cache_379_H : List Cell := (cache_379_H_part0 ++ cache_379_H_part1) + +def cache_379 : ListRow := ⟨cache_379_A, cache_379_H, 13⟩ + +def cache_380_A_part0 : List Cell := [(-2, 0), (-2, 2), (-1, -1), (-1, 0)] + +def cache_380_A : List Cell := cache_380_A_part0 + +def cache_380_H_part0 : List Cell := [(-5, -1), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 3), (-3, 4), (-3, 5), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-1, -1), (-1, 0), (-1, 3), (-1, 4), (-1, 5), (0, -2), (0, -1)] + +def cache_380_H_part1 : List Cell := [(0, 0), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, -1)] + +def cache_380_H : List Cell := (cache_380_H_part0 ++ cache_380_H_part1) + +def cache_380 : ListRow := ⟨cache_380_A, cache_380_H, 8⟩ + +def cache_381_A_part0 : List Cell := [(1, 0), (2, -1), (2, 0), (2, 1)] + +def cache_381_A : List Cell := cache_381_A_part0 + +def cache_381_H_part0 : List Cell := [(-3, -1), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -1), (1, 0), (1, 2), (1, 3), (1, 4), (2, -1), (2, 0), (2, 1)] + +def cache_381_H_part1 : List Cell := [(2, 2), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1), (5, 0), (5, 1), (6, -1), (6, 0), (6, 1), (7, 1)] + +def cache_381_H : List Cell := (cache_381_H_part0 ++ cache_381_H_part1) + +def cache_381 : ListRow := ⟨cache_381_A, cache_381_H, 10⟩ + +def cache_382_A_part0 : List Cell := [(-2, -2), (-1, -3), (-1, -2), (0, -2), (0, 1), (1, -2)] + +def cache_382_A : List Cell := cache_382_A_part0 + +def cache_382_H_part0 : List Cell := [(-2, -2), (-1, -3), (-1, -2), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (2, -1)] + +def cache_382_H : List Cell := cache_382_H_part0 + +def cache_382 : ListRow := ⟨cache_382_A, cache_382_H, 5⟩ + +def cache_383_A_part0 : List Cell := [(-1, 0), (-1, 2), (1, 0)] + +def cache_383_A : List Cell := cache_383_A_part0 + +def cache_383_H_part0 : List Cell := [(-4, -1), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 3), (-2, 4), (-2, 5), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -1), (0, 0), (0, 3), (0, 4), (0, 5), (1, -1)] + +def cache_383_H_part1 : List Cell := [(1, 0), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, -1), (4, 1)] + +def cache_383_H : List Cell := (cache_383_H_part0 ++ cache_383_H_part1) + +def cache_383 : ListRow := ⟨cache_383_A, cache_383_H, 8⟩ + +def cache_384_A_part0 : List Cell := [(-1, 0), (1, 0)] + +def cache_384_A : List Cell := cache_384_A_part0 + +def cache_384_H_part0 : List Cell := [(-4, 1), (-3, 0), (-3, 1), (-2, 0), (-2, 1), (-1, 0), (-1, 1), (-1, 2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -1), (2, 0), (2, 1), (2, 2)] + +def cache_384_H_part1 : List Cell := [(2, 3), (2, 4), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -1), (4, 0), (4, 1), (5, -1), (5, 0), (5, 1)] + +def cache_384_H : List Cell := (cache_384_H_part0 ++ cache_384_H_part1) + +def cache_384 : ListRow := ⟨cache_384_A, cache_384_H, 11⟩ + +def cache_385_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0)] + +def cache_385_A : List Cell := cache_385_A_part0 + +def cache_385_H_part0 : List Cell := [(-4, 1), (-4, 2), (-4, 3), (-4, 4), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (0, -1), (0, 0), (0, 1)] + +def cache_385_H_part1 : List Cell := [(0, 2), (0, 3), (0, 4), (0, 5), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (2, -1), (2, 1)] + +def cache_385_H : List Cell := (cache_385_H_part0 ++ cache_385_H_part1) + +def cache_385 : ListRow := ⟨cache_385_A, cache_385_H, 15⟩ + +def cache_386_A_part0 : List Cell := [(-2, 0), (-1, -2), (-1, 0)] + +def cache_386_A : List Cell := cache_386_A_part0 + +def cache_386_H_part0 : List Cell := [(-5, -1), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-1, -2), (-1, -1), (-1, 0), (-1, 2), (-1, 3), (-1, 4), (0, -1), (0, 0)] + +def cache_386_H_part1 : List Cell := [(0, 1), (0, 2), (0, 3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -1), (2, 0), (2, 1), (3, -1), (3, 1)] + +def cache_386_H : List Cell := (cache_386_H_part0 ++ cache_386_H_part1) + +def cache_386 : ListRow := ⟨cache_386_A, cache_386_H, 10⟩ + +def cache_387_A_part0 : List Cell := [(-1, -2), (-1, -1), (-1, 0), (0, 1)] + +def cache_387_A : List Cell := cache_387_A_part0 + +def cache_387_H_part0 : List Cell := [(-4, -1), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-1, -2), (-1, -1), (-1, 0), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, -2)] + +def cache_387_H_part1 : List Cell := [(2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -1), (3, 1), (3, 2), (3, 3), (3, 4), (4, -1), (4, 2), (5, 2)] + +def cache_387_H : List Cell := (cache_387_H_part0 ++ cache_387_H_part1) + +def cache_387 : ListRow := ⟨cache_387_A, cache_387_H, 12⟩ + +def cache_388_A_part0 : List Cell := [(0, -2), (1, -3), (1, -2), (1, -1), (1, 0)] + +def cache_388_A : List Cell := cache_388_A_part0 + +def cache_388_H_part0 : List Cell := [(-4, -1), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -3)] + +def cache_388_H_part1 : List Cell := [(1, -2), (1, -1), (1, 0), (2, -1), (2, 0), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1), (5, 0), (5, 1), (6, -1)] + +def cache_388_H : List Cell := (cache_388_H_part0 ++ cache_388_H_part1) + +def cache_388 : ListRow := ⟨cache_388_A, cache_388_H, 11⟩ + +def cache_389_A_part0 : List Cell := [(-2, -2), (0, -2), (0, -1)] + +def cache_389_A : List Cell := cache_389_A_part0 + +def cache_389_H_part0 : List Cell := [(-5, -3), (-5, -1), (-4, -3), (-4, -2), (-4, -1), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-2, -2), (-2, 0), (-1, -5), (-1, -4), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0)] + +def cache_389_H_part1 : List Cell := [(0, 1), (0, 2), (1, -5), (1, -4), (1, -3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, -3), (2, 0), (2, 1), (3, 1), (4, 1)] + +def cache_389_H : List Cell := (cache_389_H_part0 ++ cache_389_H_part1) + +def cache_389 : ListRow := ⟨cache_389_A, cache_389_H, 8⟩ + +def cache_390_A_part0 : List Cell := [(-1, -2), (-1, -1), (0, -2), (0, -1)] + +def cache_390_A : List Cell := cache_390_A_part0 + +def cache_390_H_part0 : List Cell := [(-4, -5), (-3, -5), (-3, -4), (-2, -5), (-2, -4), (-2, -3), (-1, -5), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (0, -5), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -5), (1, -4), (1, -3), (1, -2), (1, -1)] + +def cache_390_H_part1 : List Cell := [(1, 0), (1, 1), (1, 2), (2, -5), (2, -4), (2, -2), (3, -5), (3, -4), (3, -3), (3, -2), (4, -5), (4, -4), (4, -3), (5, -5), (5, -4), (5, -3)] + +def cache_390_H : List Cell := (cache_390_H_part0 ++ cache_390_H_part1) + +def cache_390 : ListRow := ⟨cache_390_A, cache_390_H, 12⟩ + +def cache_391_A_part0 : List Cell := [(-1, -1), (0, -2), (0, -1), (0, 1), (1, -2)] + +def cache_391_A : List Cell := cache_391_A_part0 + +def cache_391_H_part0 : List Cell := [(-5, 0), (-5, 2), (-4, 0), (-4, 1), (-4, 2), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, -2)] + +def cache_391_H_part1 : List Cell := [(0, -1), (0, 0), (0, 1), (1, -3), (1, -2), (1, 0), (1, 1), (2, 0), (2, 1), (2, 2), (3, 0), (3, 1), (3, 2), (4, 0), (4, 1), (4, 2), (5, 0)] + +def cache_391_H : List Cell := (cache_391_H_part0 ++ cache_391_H_part1) + +def cache_391 : ListRow := ⟨cache_391_A, cache_391_H, 12⟩ + +def cache_392_A_part0 : List Cell := [(-1, -2), (0, -2), (0, -1)] + +def cache_392_A : List Cell := cache_392_A_part0 + +def cache_392_H_part0 : List Cell := [(-4, -1), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-1, -5), (-1, -4), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -5)] + +def cache_392_H_part1 : List Cell := [(1, -4), (1, -3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1)] + +def cache_392_H : List Cell := (cache_392_H_part0 ++ cache_392_H_part1) + +def cache_392 : ListRow := ⟨cache_392_A, cache_392_H, 11⟩ + +def cache_393_A_part0 : List Cell := [(0, -2), (0, -1), (1, -2), (2, -3), (2, -2), (3, -2), (3, -1)] + +def cache_393_A : List Cell := cache_393_A_part0 + +def cache_393_H_part0 : List Cell := [(-2, 1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3)] + +def cache_393_H_part1 : List Cell := [(2, 4), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (4, 0), (4, 1), (4, 2), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (6, -1), (6, 0), (6, 1)] + +def cache_393_H : List Cell := (cache_393_H_part0 ++ cache_393_H_part1) + +def cache_393 : ListRow := ⟨cache_393_A, cache_393_H, 12⟩ + +def cache_394_A_part0 : List Cell := [(-2, -1), (-2, 0), (0, -1)] + +def cache_394_A : List Cell := cache_394_A_part0 + +def cache_394_H_part0 : List Cell := [(-7, -2), (-7, -1), (-7, 0), (-7, 1), (-6, -2), (-6, -1), (-6, 0), (-6, 1), (-5, -2), (-5, -1), (-5, 0), (-5, 1), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, -1), (0, 0)] + +def cache_394_H_part1 : List Cell := [(1, -1), (1, 0), (2, -2), (2, -1), (2, 0), (2, 1), (3, -2), (3, -1), (3, 0), (3, 1), (4, -2), (4, -1), (4, 0), (4, 1), (5, -2), (5, -1), (5, 0), (5, 1)] + +def cache_394_H : List Cell := (cache_394_H_part0 ++ cache_394_H_part1) + +def cache_394 : ListRow := ⟨cache_394_A, cache_394_H, 9⟩ + +def cache_395_A_part0 : List Cell := [(-1, 0), (1, -1), (1, 0), (1, 1)] + +def cache_395_A : List Cell := cache_395_A_part0 + +def cache_395_H_part0 : List Cell := [(-4, -1), (-4, 1), (-4, 2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, 0), (0, 1), (0, 2)] + +def cache_395_H_part1 : List Cell := [(0, 3), (0, 4), (0, 5), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1), (5, 0), (5, 1), (6, -1)] + +def cache_395_H : List Cell := (cache_395_H_part0 ++ cache_395_H_part1) + +def cache_395 : ListRow := ⟨cache_395_A, cache_395_H, 11⟩ + +def cache_396_A_part0 : List Cell := [(0, -2), (0, -1), (1, -2), (2, -2), (3, -2)] + +def cache_396_A : List Cell := cache_396_A_part0 + +def cache_396_H_part0 : List Cell := [(-2, 1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2)] + +def cache_396_H_part1 : List Cell := [(2, 3), (2, 4), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (4, -1), (4, 0), (4, 1), (4, 2), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (6, -1), (6, 0), (6, 1)] + +def cache_396_H : List Cell := (cache_396_H_part0 ++ cache_396_H_part1) + +def cache_396 : ListRow := ⟨cache_396_A, cache_396_H, 13⟩ + +def cache_397_A_part0 : List Cell := [(0, -2), (1, -2), (1, -1), (1, 0)] + +def cache_397_A : List Cell := cache_397_A_part0 + +def cache_397_H_part0 : List Cell := [(-4, -1), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -4)] + +def cache_397_H_part1 : List Cell := [(1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (2, -5), (2, -4), (2, -3), (2, -1), (2, 0), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1), (5, 0), (5, 1), (6, -1)] + +def cache_397_H : List Cell := (cache_397_H_part0 ++ cache_397_H_part1) + +def cache_397 : ListRow := ⟨cache_397_A, cache_397_H, 11⟩ + +def cache_398_A_part0 : List Cell := [(-3, -4), (-3, -3), (-3, -2), (-2, -3), (-2, 0), (-1, -3), (0, -3)] + +def cache_398_A : List Cell := cache_398_A_part0 + +def cache_398_H_part0 : List Cell := [(-4, -1), (-4, 0), (-4, 1), (-4, 2), (-3, -4), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-2, -3), (-2, -1), (-2, 0), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1)] + +def cache_398_H_part1 : List Cell := [(1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (3, -4), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1)] + +def cache_398_H : List Cell := (cache_398_H_part0 ++ cache_398_H_part1) + +def cache_398 : ListRow := ⟨cache_398_A, cache_398_H, 10⟩ + +def cache_399_A_part0 : List Cell := [(-2, -2), (0, -2), (0, -1)] + +def cache_399_A : List Cell := cache_399_A_part0 + +def cache_399_H_part0 : List Cell := [(-5, -3), (-5, -1), (-4, -3), (-4, -2), (-4, -1), (-3, -3), (-3, -2), (-3, -1), (-2, -2), (-2, 1), (-1, -5), (-1, -4), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1)] + +def cache_399_H_part1 : List Cell := [(0, 2), (1, -5), (1, -4), (1, -3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, -3), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, 0), (3, 1), (3, 2), (4, 1), (4, 2)] + +def cache_399_H : List Cell := (cache_399_H_part0 ++ cache_399_H_part1) + +def cache_399 : ListRow := ⟨cache_399_A, cache_399_H, 11⟩ + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/CacheData10.lean b/lean/OAI/Combinatorics/SnakyCertificate/CacheData10.lean new file mode 100644 index 0000000000000000000000000000000000000000..487f5b325a61a3dc43a9068566f98fa6aff336e1 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/CacheData10.lean @@ -0,0 +1,541 @@ +import OAI.Combinatorics.SnakyCertificate.Lists + +namespace OAI + +namespace SnakyCertificate.Check + +def cache_400_A_part0 : List Cell := [(-1, -2), (-1, 0), (1, -2), (1, 0)] + +def cache_400_A : List Cell := cache_400_A_part0 + +def cache_400_H_part0 : List Cell := [(-5, -1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -1), (0, 0)] + +def cache_400_H_part1 : List Cell := [(1, -2), (1, -1), (1, 0), (1, 2), (1, 3), (1, 4), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -1), (4, 0), (4, 1)] + +def cache_400_H : List Cell := (cache_400_H_part0 ++ cache_400_H_part1) + +def cache_400 : ListRow := ⟨cache_400_A, cache_400_H, 10⟩ + +def cache_401_A_part0 : List Cell := [(-1, -1), (0, -1), (0, 1)] + +def cache_401_A : List Cell := cache_401_A_part0 + +def cache_401_H_part0 : List Cell := [(-4, 0), (-4, 2), (-3, 0), (-3, 1), (-3, 2), (-2, 0), (-2, 1), (-2, 2), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -4), (1, -3)] + +def cache_401_H_part1 : List Cell := [(1, -2), (1, 0), (1, 1), (1, 2), (1, 3), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (3, 0), (3, 1), (3, 2), (3, 3), (4, 0), (4, 1), (4, 2), (4, 3), (5, 0)] + +def cache_401_H : List Cell := (cache_401_H_part0 ++ cache_401_H_part1) + +def cache_401 : ListRow := ⟨cache_401_A, cache_401_H, 11⟩ + +def cache_402_A_part0 : List Cell := [(-1, -3), (0, -3), (0, -2), (1, -3), (2, -3), (2, 0)] + +def cache_402_A : List Cell := cache_402_A_part0 + +def cache_402_H_part0 : List Cell := [(-3, 1), (-2, -4), (-2, 0), (-2, 1), (-1, -4), (-1, -3), (-1, 0), (-1, 1), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -3), (2, -1), (2, 0)] + +def cache_402_H_part1 : List Cell := [(2, 1), (2, 2), (2, 3), (2, 4), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (5, -1), (5, 0), (5, 1), (6, -1), (6, 0), (6, 1)] + +def cache_402_H : List Cell := (cache_402_H_part0 ++ cache_402_H_part1) + +def cache_402 : ListRow := ⟨cache_402_A, cache_402_H, 12⟩ + +def cache_403_A_part0 : List Cell := [(-1, -2), (0, -3), (0, -2), (0, -1)] + +def cache_403_A : List Cell := cache_403_A_part0 + +def cache_403_H_part0 : List Cell := [(-5, -1), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -3)] + +def cache_403_H_part1 : List Cell := [(0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1)] + +def cache_403_H : List Cell := (cache_403_H_part0 ++ cache_403_H_part1) + +def cache_403 : ListRow := ⟨cache_403_A, cache_403_H, 12⟩ + +def cache_404_A_part0 : List Cell := [(-1, -1), (-1, 0), (-1, 1), (-1, 2)] + +def cache_404_A : List Cell := cache_404_A_part0 + +def cache_404_H_part0 : List Cell := [(-6, 1), (-5, 1), (-5, 2), (-5, 3), (-4, -1), (-4, 1), (-4, 2), (-4, 3), (-3, -1), (-3, 1), (-3, 2), (-3, 3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (0, 0), (0, 1), (0, 2)] + +def cache_404_H_part1 : List Cell := [(0, 3), (0, 4), (0, 5), (0, 6), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, 1), (3, 2), (3, 3), (4, 1), (4, 3)] + +def cache_404_H : List Cell := (cache_404_H_part0 ++ cache_404_H_part1) + +def cache_404 : ListRow := ⟨cache_404_A, cache_404_H, 12⟩ + +def cache_405_A_part0 : List Cell := [(-2, -2), (-1, -3), (-1, -2), (0, -3), (0, -2), (1, -3)] + +def cache_405_A : List Cell := cache_405_A_part0 + +def cache_405_H_part0 : List Cell := [(-5, -1), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3)] + +def cache_405_H_part1 : List Cell := [(-1, 4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (2, -2), (2, -1), (2, 0), (2, 1), (3, -2), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1)] + +def cache_405_H : List Cell := (cache_405_H_part0 ++ cache_405_H_part1) + +def cache_405 : ListRow := ⟨cache_405_A, cache_405_H, 13⟩ + +def cache_406_A_part0 : List Cell := [(0, -2), (0, -1)] + +def cache_406_A : List Cell := cache_406_A_part0 + +def cache_406_H_part0 : List Cell := [(-4, -1), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-1, -5), (-1, -4), (-1, -3), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -5), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -5)] + +def cache_406_H_part1 : List Cell := [(1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, -1), (2, 0), (2, 1), (2, 2), (3, -1), (3, 0), (3, 1), (3, 2), (4, -1), (4, 0), (4, 1), (4, 2), (5, -1)] + +def cache_406_H : List Cell := (cache_406_H_part0 ++ cache_406_H_part1) + +def cache_406 : ListRow := ⟨cache_406_A, cache_406_H, 11⟩ + +def cache_407_A_part0 : List Cell := [(0, 1), (0, 2), (0, 3)] + +def cache_407_A : List Cell := cache_407_A_part0 + +def cache_407_H_part0 : List Cell := [(-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-3, 3), (-2, -1), (-2, 0), (-2, 1), (-2, 3), (-1, -1), (-1, 0), (-1, 1), (-1, 3), (-1, 4), (0, 0), (0, 1), (0, 2), (0, 3), (1, -1), (1, 0), (1, 1)] + +def cache_407_H_part1 : List Cell := [(1, 2), (1, 3), (1, 4), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -1), (4, 1), (4, 2), (4, 3), (4, 4), (5, 2)] + +def cache_407_H : List Cell := (cache_407_H_part0 ++ cache_407_H_part1) + +def cache_407 : ListRow := ⟨cache_407_A, cache_407_H, 10⟩ + +def cache_408_A_part0 : List Cell := [(-1, 0), (0, -3), (0, -2), (0, -1), (1, 0)] + +def cache_408_A : List Cell := cache_408_A_part0 + +def cache_408_H_part0 : List Cell := [(-5, -1), (-4, -1), (-4, 0), (-4, 1), (-3, -3), (-3, -1), (-3, 0), (-3, 1), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -3), (0, -2), (0, -1), (0, 0)] + +def cache_408_H_part1 : List Cell := [(1, -2), (1, -1), (1, 0), (1, 2), (1, 3), (1, 4), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -1), (4, 0), (4, 1), (5, -1)] + +def cache_408_H : List Cell := (cache_408_H_part0 ++ cache_408_H_part1) + +def cache_408 : ListRow := ⟨cache_408_A, cache_408_H, 11⟩ + +def cache_409_A_part0 : List Cell := [(0, -3), (0, -2), (1, -3), (2, -1), (2, 0)] + +def cache_409_A : List Cell := cache_409_A_part0 + +def cache_409_H_part0 : List Cell := [(-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -4), (1, -3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4)] + +def cache_409_H_part1 : List Cell := [(2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (5, -1), (5, 0), (5, 1), (6, -1), (6, 0), (6, 1)] + +def cache_409_H : List Cell := (cache_409_H_part0 ++ cache_409_H_part1) + +def cache_409 : ListRow := ⟨cache_409_A, cache_409_H, 12⟩ + +def cache_410_A_part0 : List Cell := [(-3, 1), (-2, 0), (-2, 1), (-1, 0), (-1, 1)] + +def cache_410_A : List Cell := cache_410_A_part0 + +def cache_410_H_part0 : List Cell := [(-6, 2), (-6, 4), (-5, 2), (-5, 3), (-5, 4), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6)] + +def cache_410_H_part1 : List Cell := [(-2, 7), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, 1), (2, 2), (2, 3), (2, 4), (3, 2), (3, 3), (3, 4), (4, 2)] + +def cache_410_H : List Cell := (cache_410_H_part0 ++ cache_410_H_part1) + +def cache_410 : ListRow := ⟨cache_410_A, cache_410_H, 14⟩ + +def cache_411_A_part0 : List Cell := [(1, 0), (2, 0)] + +def cache_411_A : List Cell := cache_411_A_part0 + +def cache_411_H_part0 : List Cell := [(-3, -1), (-2, -1), (-2, 0), (-1, -1), (-1, 0), (0, -3), (0, -2), (0, -1), (0, 0), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4)] + +def cache_411_H_part1 : List Cell := [(3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (7, 1), (7, 3)] + +def cache_411_H : List Cell := (cache_411_H_part0 ++ cache_411_H_part1) + +def cache_411 : ListRow := ⟨cache_411_A, cache_411_H, 14⟩ + +def cache_412_A_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -1), (-1, 0), (-1, 1)] + +def cache_412_A : List Cell := cache_412_A_part0 + +def cache_412_H_part0 : List Cell := [(-6, 1), (-5, 1), (-5, 2), (-5, 3), (-4, -1), (-4, 1), (-4, 2), (-4, 3), (-3, -1), (-3, 1), (-3, 2), (-3, 3), (-2, -1), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3)] + +def cache_412_H_part1 : List Cell := [(-1, 4), (-1, 5), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, 1), (3, 2), (3, 3), (4, 1)] + +def cache_412_H_part2 : List Cell := [(4, 3)] + +def cache_412_H : List Cell := (cache_412_H_part0 ++ (cache_412_H_part1 ++ cache_412_H_part2)) + +def cache_412 : ListRow := ⟨cache_412_A, cache_412_H, 13⟩ + +def cache_413_A_part0 : List Cell := [(-1, -2), (-1, -1), (-1, 1), (0, 1), (0, 2)] + +def cache_413_A : List Cell := cache_413_A_part0 + +def cache_413_H_part0 : List Cell := [(-5, 2), (-5, 4), (-4, 2), (-4, 3), (-4, 4), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-1, -2), (-1, -1), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6)] + +def cache_413_H_part1 : List Cell := [(-1, 7), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (2, 2), (2, 3), (2, 4), (3, 2), (3, 3), (3, 4), (4, 2), (4, 3), (4, 4)] + +def cache_413_H_part2 : List Cell := [(5, 2)] + +def cache_413_H : List Cell := (cache_413_H_part0 ++ (cache_413_H_part1 ++ cache_413_H_part2)) + +def cache_413 : ListRow := ⟨cache_413_A, cache_413_H, 13⟩ + +def cache_414_A_part0 : List Cell := [(-1, -1), (-1, 1), (0, -1), (0, 1)] + +def cache_414_A : List Cell := cache_414_A_part0 + +def cache_414_H_part0 : List Cell := [(-5, 0), (-5, 2), (-4, 0), (-4, 1), (-4, 2), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 3)] + +def cache_414_H_part1 : List Cell := [(-1, 4), (-1, 5), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -4), (1, -3), (1, -2), (1, 0), (1, 1), (1, 2), (2, -2), (2, 0), (2, 1), (2, 2), (3, -2), (3, 0), (3, 1), (3, 2), (4, 0), (4, 1), (4, 2)] + +def cache_414_H_part2 : List Cell := [(5, 0)] + +def cache_414_H : List Cell := (cache_414_H_part0 ++ (cache_414_H_part1 ++ cache_414_H_part2)) + +def cache_414 : ListRow := ⟨cache_414_A, cache_414_H, 11⟩ + +def cache_415_A_part0 : List Cell := [(-3, -3), (-2, -3), (-2, 0), (-1, -3), (0, -3)] + +def cache_415_A : List Cell := cache_415_A_part0 + +def cache_415_H_part0 : List Cell := [(-5, 1), (-4, 0), (-4, 1), (-3, -3), (-3, 0), (-3, 1), (-2, -3), (-2, 0), (-2, 1), (-2, 2), (-1, -4), (-1, -3), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2)] + +def cache_415_H_part1 : List Cell := [(0, 3), (0, 4), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -4), (3, -1), (3, 0), (3, 1)] + +def cache_415_H_part2 : List Cell := [(4, -1), (4, 0), (4, 1)] + +def cache_415_H : List Cell := (cache_415_H_part0 ++ (cache_415_H_part1 ++ cache_415_H_part2)) + +def cache_415 : ListRow := ⟨cache_415_A, cache_415_H, 12⟩ + +def cache_416_A_part0 : List Cell := [(-2, 0), (-1, 0)] + +def cache_416_A : List Cell := cache_416_A_part0 + +def cache_416_H_part0 : List Cell := [(-5, -1), (-5, 0), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5)] + +def cache_416_H_part1 : List Cell := [(-2, 6), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4)] + +def cache_416_H_part2 : List Cell := [(3, -1), (3, 0), (3, 1), (4, 1)] + +def cache_416_H : List Cell := (cache_416_H_part0 ++ (cache_416_H_part1 ++ cache_416_H_part2)) + +def cache_416 : ListRow := ⟨cache_416_A, cache_416_H, 16⟩ + +def cache_417_A_part0 : List Cell := [(-2, -3), (-2, -2), (-1, -3), (0, -3), (0, -1), (1, -3)] + +def cache_417_A : List Cell := cache_417_A_part0 + +def cache_417_H_part0 : List Cell := [(-5, -1), (-5, 0), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-1, -4), (-1, -3), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4)] + +def cache_417_H_part1 : List Cell := [(0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -4), (1, -3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -1), (3, 0)] + +def cache_417_H_part2 : List Cell := [(3, 1), (4, -1), (4, 0), (4, 1)] + +def cache_417_H : List Cell := (cache_417_H_part0 ++ (cache_417_H_part1 ++ cache_417_H_part2)) + +def cache_417 : ListRow := ⟨cache_417_A, cache_417_H, 13⟩ + +def cache_418_A_part0 : List Cell := [(-2, -1), (-1, -4), (-1, -3), (-1, -1), (0, -1)] + +def cache_418_A : List Cell := cache_418_A_part0 + +def cache_418_H_part0 : List Cell := [(-5, 0), (-5, 2), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-1, -4), (-1, -3), (-1, -1), (-1, 0), (-1, 1)] + +def cache_418_H_part1 : List Cell := [(-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -2), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, 0), (2, 1), (2, 2), (3, 0), (3, 1)] + +def cache_418_H_part2 : List Cell := [(3, 2), (4, 0), (4, 1), (4, 2), (5, 0)] + +def cache_418_H : List Cell := (cache_418_H_part0 ++ (cache_418_H_part1 ++ cache_418_H_part2)) + +def cache_418 : ListRow := ⟨cache_418_A, cache_418_H, 14⟩ + +def cache_419_A_part0 : List Cell := [(-3, -3), (-2, -3), (-2, -2), (-1, -3), (0, -3)] + +def cache_419_A : List Cell := cache_419_A_part0 + +def cache_419_H_part0 : List Cell := [(-5, 1), (-4, -4), (-4, 0), (-4, 1), (-3, -4), (-3, -3), (-3, -1), (-3, 0), (-3, 1), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-1, -4), (-1, -3), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -4)] + +def cache_419_H_part1 : List Cell := [(0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -1)] + +def cache_419_H_part2 : List Cell := [(3, 0), (3, 1), (4, -1), (4, 0), (4, 1)] + +def cache_419_H : List Cell := (cache_419_H_part0 ++ (cache_419_H_part1 ++ cache_419_H_part2)) + +def cache_419 : ListRow := ⟨cache_419_A, cache_419_H, 13⟩ + +def cache_420_A_part0 : List Cell := [(-1, -3), (0, -3), (0, -2), (1, -3), (2, -3)] + +def cache_420_A : List Cell := cache_420_A_part0 + +def cache_420_H_part0 : List Cell := [(-3, 1), (-2, -4), (-2, 0), (-2, 1), (-1, -4), (-1, -3), (-1, 0), (-1, 1), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -4), (1, -3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -3), (2, -2)] + +def cache_420_H_part1 : List Cell := [(2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4)] + +def cache_420_H_part2 : List Cell := [(5, -4), (5, -1), (5, 0), (5, 1), (6, -1), (6, 0), (6, 1)] + +def cache_420_H : List Cell := (cache_420_H_part0 ++ (cache_420_H_part1 ++ cache_420_H_part2)) + +def cache_420 : ListRow := ⟨cache_420_A, cache_420_H, 13⟩ + +def cache_421_A_part0 : List Cell := [(-1, -2), (-1, -1), (-1, 0), (1, 0)] + +def cache_421_A : List Cell := cache_421_A_part0 + +def cache_421_H_part0 : List Cell := [(-6, 1), (-5, -1), (-5, 0), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-1, -2), (-1, -1), (-1, 0), (0, -5), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0)] + +def cache_421_H_part1 : List Cell := [(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 2), (2, 3), (2, 4), (3, -3)] + +def cache_421_H_part2 : List Cell := [(3, -2), (3, -1), (4, -3), (4, -2), (4, -1), (5, -3), (5, -1)] + +def cache_421_H : List Cell := (cache_421_H_part0 ++ (cache_421_H_part1 ++ cache_421_H_part2)) + +def cache_421 : ListRow := ⟨cache_421_A, cache_421_H, 12⟩ + +def cache_422_A_part0 : List Cell := [(-1, -1), (-1, 0), (-1, 1), (-1, 2)] + +def cache_422_A : List Cell := cache_422_A_part0 + +def cache_422_H_part0 : List Cell := [(-4, -1), (-3, -1), (-2, -2), (-2, -1), (-2, 1), (-2, 2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -1), (0, 0), (0, 2), (0, 3), (0, 4), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6)] + +def cache_422_H_part1 : List Cell := [(2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4)] + +def cache_422_H_part2 : List Cell := [(5, 1), (5, 2), (5, 3), (5, 4), (6, 1), (6, 2), (6, 3), (6, 4)] + +def cache_422_H : List Cell := (cache_422_H_part0 ++ (cache_422_H_part1 ++ cache_422_H_part2)) + +def cache_422 : ListRow := ⟨cache_422_A, cache_422_H, 14⟩ + +def cache_423_A_part0 : List Cell := [(-1, -2), (-1, 0), (0, -2)] + +def cache_423_A : List Cell := cache_423_A_part0 + +def cache_423_H_part0 : List Cell := [(-5, -1), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-1, -2), (-1, -1), (-1, 0)] + +def cache_423_H_part1 : List Cell := [(-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3)] + +def cache_423_H_part2 : List Cell := [(2, 4), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -1), (4, 1)] + +def cache_423_H : List Cell := (cache_423_H_part0 ++ (cache_423_H_part1 ++ cache_423_H_part2)) + +def cache_423 : ListRow := ⟨cache_423_A, cache_423_H, 12⟩ + +def cache_424_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1), (2, -1)] + +def cache_424_A : List Cell := cache_424_A_part0 + +def cache_424_H_part0 : List Cell := [(-5, -2), (-5, -1), (-5, 0), (-5, 1), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-1, -2), (-1, -1), (-1, 0), (-1, 2), (-1, 3), (-1, 4), (0, -3), (0, -2)] + +def cache_424_H_part1 : List Cell := [(0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, -1), (2, 0), (3, -1), (3, 0), (4, -2), (4, -1), (4, 0), (4, 1), (5, -2), (5, -1), (5, 0)] + +def cache_424_H_part2 : List Cell := [(5, 1), (6, -2), (6, -1), (6, 0), (6, 1), (7, -2), (7, -1), (7, 0), (7, 1)] + +def cache_424_H : List Cell := (cache_424_H_part0 ++ (cache_424_H_part1 ++ cache_424_H_part2)) + +def cache_424 : ListRow := ⟨cache_424_A, cache_424_H, 10⟩ + +def cache_425_A_part0 : List Cell := [(-1, -2), (-1, 0), (0, -2)] + +def cache_425_A : List Cell := cache_425_A_part0 + +def cache_425_H_part0 : List Cell := [(-5, -1), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-1, -3), (-1, -2), (-1, -1), (-1, 0)] + +def cache_425_H_part1 : List Cell := [(-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3)] + +def cache_425_H_part2 : List Cell := [(2, 4), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -1), (4, 1)] + +def cache_425_H : List Cell := (cache_425_H_part0 ++ (cache_425_H_part1 ++ cache_425_H_part2)) + +def cache_425 : ListRow := ⟨cache_425_A, cache_425_H, 12⟩ + +def cache_426_A_part0 : List Cell := [(-1, -2), (0, -2), (0, -1)] + +def cache_426_A : List Cell := cache_426_A_part0 + +def cache_426_H_part0 : List Cell := [(-5, -1), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -5)] + +def cache_426_H_part1 : List Cell := [(0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -5), (1, -4), (1, -3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -1)] + +def cache_426_H_part2 : List Cell := [(3, 0), (3, 1), (3, 2), (4, -1), (4, 0), (4, 1), (4, 2), (5, -1), (5, 0)] + +def cache_426_H : List Cell := (cache_426_H_part0 ++ (cache_426_H_part1 ++ cache_426_H_part2)) + +def cache_426 : ListRow := ⟨cache_426_A, cache_426_H, 12⟩ + +def cache_427_A_part0 : List Cell := [(-1, -1), (-1, 0), (-1, 1), (-1, 2)] + +def cache_427_A : List Cell := cache_427_A_part0 + +def cache_427_H_part0 : List Cell := [(-4, -1), (-3, -1), (-2, -2), (-2, -1), (-2, 1), (-2, 3), (-2, 4), (-2, 5), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -1), (0, 0), (0, 2), (0, 3), (0, 4), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4)] + +def cache_427_H_part1 : List Cell := [(1, 5), (1, 6), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (4, 0), (4, 1), (4, 2)] + +def cache_427_H_part2 : List Cell := [(4, 3), (4, 4), (5, 1), (5, 2), (5, 3), (5, 4), (6, 1), (6, 2), (6, 3), (6, 4)] + +def cache_427_H : List Cell := (cache_427_H_part0 ++ (cache_427_H_part1 ++ cache_427_H_part2)) + +def cache_427 : ListRow := ⟨cache_427_A, cache_427_H, 14⟩ + +def cache_428_A_part0 : List Cell := [(-1, -3), (-1, -2), (-1, 0), (0, -3), (0, -2)] + +def cache_428_A : List Cell := cache_428_A_part0 + +def cache_428_H_part0 : List Cell := [(-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (-1, 2), (-1, 3)] + +def cache_428_H_part1 : List Cell := [(-1, 4), (-1, 5), (-1, 6), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -1)] + +def cache_428_H_part2 : List Cell := [(3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -1), (4, 0), (4, 1), (5, -1), (5, 1)] + +def cache_428_H : List Cell := (cache_428_H_part0 ++ (cache_428_H_part1 ++ cache_428_H_part2)) + +def cache_428 : ListRow := ⟨cache_428_A, cache_428_H, 17⟩ + +def cache_429_A_part0 : List Cell := [(0, 2), (1, -1), (1, 0), (2, 0), (3, 0)] + +def cache_429_A : List Cell := cache_429_A_part0 + +def cache_429_H_part0 : List Cell := [(-2, 0), (-1, 0), (-1, 1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -1), (1, 0), (2, -1), (2, 0), (3, -1), (3, 0), (3, 1), (4, 0), (4, 1), (5, 0), (5, 1)] + +def cache_429_H : List Cell := cache_429_H_part0 + +def cache_429 : ListRow := ⟨cache_429_A, cache_429_H, 6⟩ + +def cache_430_A_part0 : List Cell := [(-2, -2), (-2, -1), (-2, 0), (-1, -2), (0, -2)] + +def cache_430_A : List Cell := cache_430_A_part0 + +def cache_430_H_part0 : List Cell := [(-7, -1), (-7, 1), (-6, -1), (-6, 0), (-6, 1), (-5, -1), (-5, 0), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-2, -2), (-2, -1), (-2, 0), (-1, -6), (-1, -5), (-1, -4), (-1, -3), (-1, -2)] + +def cache_430_H_part1 : List Cell := [(-1, -1), (-1, 0), (-1, 2), (-1, 3), (-1, 4), (0, -5), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -5), (1, -4), (1, -3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -3)] + +def cache_430_H_part2 : List Cell := [(2, -1), (2, 0), (2, 1), (3, -3), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1)] + +def cache_430_H : List Cell := (cache_430_H_part0 ++ (cache_430_H_part1 ++ cache_430_H_part2)) + +def cache_430 : ListRow := ⟨cache_430_A, cache_430_H, 10⟩ + +def cache_431_A_part0 : List Cell := [(-1, -4), (-1, -3), (-1, -2), (0, -3), (1, -3), (2, -3)] + +def cache_431_A : List Cell := cache_431_A_part0 + +def cache_431_H_part0 : List Cell := [(-3, 1), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (0, -3), (0, -1), (0, 0), (0, 1), (0, 2), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3)] + +def cache_431_H_part1 : List Cell := [(1, 4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1)] + +def cache_431_H_part2 : List Cell := [(4, 2), (4, 3), (4, 4), (5, -4), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (6, -2), (6, -1), (6, 0), (6, 1)] + +def cache_431_H : List Cell := (cache_431_H_part0 ++ (cache_431_H_part1 ++ cache_431_H_part2)) + +def cache_431 : ListRow := ⟨cache_431_A, cache_431_H, 13⟩ + +def cache_432_A_part0 : List Cell := [(-1, -3), (0, -3), (0, -2), (1, -3), (1, -2)] + +def cache_432_A : List Cell := cache_432_A_part0 + +def cache_432_H_part0 : List Cell := [(-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-1, -4), (-1, -3), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, -3), (0, -2), (0, -1), (0, 0)] + +def cache_432_H_part1 : List Cell := [(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -1), (3, 0), (3, 1), (3, 2)] + +def cache_432_H_part2 : List Cell := [(3, 3), (3, 4), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (5, -1), (5, 0), (5, 1), (6, -1), (6, 1)] + +def cache_432_H : List Cell := (cache_432_H_part0 ++ (cache_432_H_part1 ++ cache_432_H_part2)) + +def cache_432 : ListRow := ⟨cache_432_A, cache_432_H, 18⟩ + +def cache_433_A_part0 : List Cell := [(0, -4), (0, -3), (0, -2), (0, -1)] + +def cache_433_A : List Cell := cache_433_A_part0 + +def cache_433_H_part0 : List Cell := [(-3, -3), (-2, -3), (-1, -4), (-1, -3), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -3), (1, -2), (1, 0), (1, 1), (1, 2), (2, -3), (2, -2), (2, -1)] + +def cache_433_H_part1 : List Cell := [(2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4)] + +def cache_433_H_part2 : List Cell := [(5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (6, -1), (6, 0), (6, 1), (6, 2), (7, -1), (7, 0), (7, 1), (7, 2)] + +def cache_433_H : List Cell := (cache_433_H_part0 ++ (cache_433_H_part1 ++ cache_433_H_part2)) + +def cache_433 : ListRow := ⟨cache_433_A, cache_433_H, 15⟩ + +def cache_434_A_part0 : List Cell := [(-2, 0), (-1, -3), (-1, -2), (-1, 0), (0, -2)] + +def cache_434_A : List Cell := cache_434_A_part0 + +def cache_434_H_part0 : List Cell := [(-5, 1), (-5, 3), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (-1, 2)] + +def cache_434_H_part1 : List Cell := [(-1, 3), (-1, 4), (-1, 5), (-1, 6), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (2, -1), (2, 0), (2, 1), (2, 2)] + +def cache_434_H_part2 : List Cell := [(2, 3), (2, 4), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (5, 1)] + +def cache_434_H : List Cell := (cache_434_H_part0 ++ (cache_434_H_part1 ++ cache_434_H_part2)) + +def cache_434 : ListRow := ⟨cache_434_A, cache_434_H, 15⟩ + +def cache_435_A_part0 : List Cell := [(0, -2), (0, -1), (1, -1), (2, -1), (3, -1)] + +def cache_435_A : List Cell := cache_435_A_part0 + +def cache_435_H_part0 : List Cell := [(-2, 3), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -1), (1, 1), (1, 2), (1, 3), (1, 4), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4)] + +def cache_435_H_part1 : List Cell := [(2, 5), (2, 6), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2)] + +def cache_435_H_part2 : List Cell := [(5, 3), (5, 4), (5, 5), (5, 6), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (7, 0), (7, 1), (7, 2), (7, 3)] + +def cache_435_H : List Cell := (cache_435_H_part0 ++ (cache_435_H_part1 ++ cache_435_H_part2)) + +def cache_435 : ListRow := ⟨cache_435_A, cache_435_H, 14⟩ + +def cache_436_A_part0 : List Cell := [(0, -3), (0, -2), (1, -3), (1, -2)] + +def cache_436_A : List Cell := cache_436_A_part0 + +def cache_436_H_part0 : List Cell := [(-4, -1), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, -3), (0, -2), (0, -1), (0, 0)] + +def cache_436_H_part1 : List Cell := [(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -1), (3, 0), (3, 1)] + +def cache_436_H_part2 : List Cell := [(3, 2), (3, 3), (3, 4), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (5, -1), (5, 0), (5, 1), (6, -1), (6, 1)] + +def cache_436_H : List Cell := (cache_436_H_part0 ++ (cache_436_H_part1 ++ cache_436_H_part2)) + +def cache_436 : ListRow := ⟨cache_436_A, cache_436_H, 18⟩ + +def cache_437_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1)] + +def cache_437_A : List Cell := cache_437_A_part0 + +def cache_437_H_part0 : List Cell := [(-3, -3), (-2, -3), (-1, -5), (-1, -4), (-1, -3), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -3), (1, -2), (1, 0), (1, 1), (1, 2), (2, -3), (2, -2)] + +def cache_437_H_part1 : List Cell := [(2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3)] + +def cache_437_H_part2 : List Cell := [(4, 4), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (6, -1), (6, 0), (6, 1), (6, 2), (7, -1), (7, 0), (7, 1), (7, 2)] + +def cache_437_H : List Cell := (cache_437_H_part0 ++ (cache_437_H_part1 ++ cache_437_H_part2)) + +def cache_437 : ListRow := ⟨cache_437_A, cache_437_H, 15⟩ + +def cache_438_A_part0 : List Cell := [(-2, -1), (-1, -1), (0, -1), (1, -1), (1, 0)] + +def cache_438_A : List Cell := cache_438_A_part0 + +def cache_438_H_part0 : List Cell := [(-3, -1), (-3, 1), (-3, 2), (-3, 3), (-2, -1), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-1, -2), (-1, -1), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (0, -1), (0, 0)] + +def cache_438_H_part1 : List Cell := [(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, 1), (3, 2)] + +def cache_438_H_part2 : List Cell := [(3, 3), (3, 4), (3, 5), (3, 6), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (5, 1), (5, 2), (5, 3), (6, 1), (6, 3)] + +def cache_438_H : List Cell := (cache_438_H_part0 ++ (cache_438_H_part1 ++ cache_438_H_part2)) + +def cache_438 : ListRow := ⟨cache_438_A, cache_438_H, 19⟩ + +def cache_439_A_part0 : List Cell := [(-2, 0), (-1, -4), (-1, -3), (-1, -2), (-1, 0)] + +def cache_439_A : List Cell := cache_439_A_part0 + +def cache_439_H_part0 : List Cell := [(-5, 1), (-5, 3), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-1, -4), (-1, -3), (-1, -2), (-1, 0), (-1, 1)] + +def cache_439_H_part1 : List Cell := [(-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (2, -1), (2, 0)] + +def cache_439_H_part2 : List Cell := [(2, 1), (2, 2), (2, 3), (2, 4), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (5, 1)] + +def cache_439_H : List Cell := (cache_439_H_part0 ++ (cache_439_H_part1 ++ cache_439_H_part2)) + +def cache_439 : ListRow := ⟨cache_439_A, cache_439_H, 15⟩ + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/CacheData11.lean b/lean/OAI/Combinatorics/SnakyCertificate/CacheData11.lean new file mode 100644 index 0000000000000000000000000000000000000000..a415cb52bac2368242e52ad497b65c97433f5e52 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/CacheData11.lean @@ -0,0 +1,597 @@ +import OAI.Combinatorics.SnakyCertificate.Lists + +namespace OAI + +namespace SnakyCertificate.Check + +def cache_440_A_part0 : List Cell := [(-2, -1), (-2, 0), (-1, 0), (1, 0)] + +def cache_440_A : List Cell := cache_440_A_part0 + +def cache_440_H_part0 : List Cell := [(-4, 4), (-3, -1), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-1, 0), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4)] + +def cache_440_H_part1 : List Cell := [(0, 5), (0, 6), (0, 7), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (3, -1), (3, 0), (3, 1), (3, 2)] + +def cache_440_H_part2 : List Cell := [(3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (5, 1), (5, 2), (5, 3), (5, 4)] + +def cache_440_H : List Cell := (cache_440_H_part0 ++ (cache_440_H_part1 ++ cache_440_H_part2)) + +def cache_440 : ListRow := ⟨cache_440_A, cache_440_H, 15⟩ + +def cache_441_A_part0 : List Cell := [(0, 1), (1, 1), (2, 1), (3, 1)] + +def cache_441_A : List Cell := cache_441_A_part0 + +def cache_441_H_part0 : List Cell := [(-2, 5), (-1, 0), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, 1), (1, 3), (1, 4), (1, 5), (1, 6), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5)] + +def cache_441_H_part1 : List Cell := [(2, 6), (2, 7), (2, 8), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (5, 0), (5, 1), (5, 2), (5, 3)] + +def cache_441_H_part2 : List Cell := [(5, 4), (5, 5), (5, 6), (5, 7), (5, 8), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (7, 2), (7, 3), (7, 4), (7, 5)] + +def cache_441_H : List Cell := (cache_441_H_part0 ++ (cache_441_H_part1 ++ cache_441_H_part2)) + +def cache_441 : ListRow := ⟨cache_441_A, cache_441_H, 15⟩ + +def cache_442_A_part0 : List Cell := [(0, -4), (0, -3), (0, -2), (0, -1)] + +def cache_442_A : List Cell := cache_442_A_part0 + +def cache_442_H_part0 : List Cell := [(-3, -2), (-2, -2), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, -2)] + +def cache_442_H_part1 : List Cell := [(2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3)] + +def cache_442_H_part2 : List Cell := [(4, 4), (4, 5), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (6, 0), (6, 1), (6, 2), (6, 3), (7, 0), (7, 1), (7, 2), (7, 3)] + +def cache_442_H : List Cell := (cache_442_H_part0 ++ (cache_442_H_part1 ++ cache_442_H_part2)) + +def cache_442 : ListRow := ⟨cache_442_A, cache_442_H, 16⟩ + +def cache_443_A_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -1), (0, -1)] + +def cache_443_A : List Cell := cache_443_A_part0 + +def cache_443_H_part0 : List Cell := [(-4, -1), (-4, 1), (-4, 2), (-4, 3), (-3, -1), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8), (-2, -2), (-2, -1), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-1, -1), (-1, 0)] + +def cache_443_H_part1 : List Cell := [(-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (2, 1)] + +def cache_443_H_part2 : List Cell := [(2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (4, 1), (4, 2), (4, 3), (5, 1), (5, 3)] + +def cache_443_H : List Cell := (cache_443_H_part0 ++ (cache_443_H_part1 ++ cache_443_H_part2)) + +def cache_443 : ListRow := ⟨cache_443_A, cache_443_H, 20⟩ + +def cache_444_A_part0 : List Cell := [(-2, -2), (-1, -2), (0, -2), (0, -1)] + +def cache_444_A : List Cell := cache_444_A_part0 + +def cache_444_H_part0 : List Cell := [(-5, -3), (-5, -1), (-5, 0), (-5, 1), (-5, 2), (-4, -3), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-2, -2), (-2, 0), (-2, 1), (-2, 2), (-1, -2), (-1, 0), (-1, 1), (-1, 2)] + +def cache_444_H_part1 : List Cell := [(-1, 3), (-1, 4), (-1, 5), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -5), (1, -4), (1, -3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, -1), (2, 0)] + +def cache_444_H_part2 : List Cell := [(2, 1), (2, 2), (2, 3), (2, 4), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (4, 0), (4, 1), (4, 2), (5, 0), (5, 2)] + +def cache_444_H : List Cell := (cache_444_H_part0 ++ (cache_444_H_part1 ++ cache_444_H_part2)) + +def cache_444 : ListRow := ⟨cache_444_A, cache_444_H, 14⟩ + +def cache_445_A_part0 : List Cell := [(1, 0), (1, 1), (2, 0), (2, 1)] + +def cache_445_A : List Cell := cache_445_A_part0 + +def cache_445_H_part0 : List Cell := [(-2, 0), (-2, 2), (-2, 3), (-2, 4), (-1, 0), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (0, -1), (0, 0), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (1, 0), (1, 1)] + +def cache_445_H_part1 : List Cell := [(1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (4, 2)] + +def cache_445_H_part2 : List Cell := [(4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (6, 2), (6, 3), (6, 4), (7, 2), (7, 4)] + +def cache_445_H : List Cell := (cache_445_H_part0 ++ (cache_445_H_part1 ++ cache_445_H_part2)) + +def cache_445 : ListRow := ⟨cache_445_A, cache_445_H, 19⟩ + +def cache_446_A_part0 : List Cell := [(-1, -1), (1, 0), (2, 0), (3, 0), (3, 1)] + +def cache_446_A : List Cell := cache_446_A_part0 + +def cache_446_H_part0 : List Cell := [(-1, -1), (-1, 0), (-1, 2), (-1, 3), (-1, 4), (0, -1), (0, 0), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (1, -1), (1, 0), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8)] + +def cache_446_H_part1 : List Cell := [(2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7)] + +def cache_446_H_part2 : List Cell := [(5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (7, 2), (7, 3), (7, 4), (8, 2), (8, 4)] + +def cache_446_H : List Cell := (cache_446_H_part0 ++ (cache_446_H_part1 ++ cache_446_H_part2)) + +def cache_446 : ListRow := ⟨cache_446_A, cache_446_H, 20⟩ + +def cache_447_A_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -1), (-1, 0), (0, -1)] + +def cache_447_A : List Cell := cache_447_A_part0 + +def cache_447_H_part0 : List Cell := [(-6, 1), (-6, 3), (-5, 1), (-5, 2), (-5, 3), (-4, -1), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-3, -1), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-2, -1), (-2, 1), (-2, 2), (-2, 3), (-2, 4)] + +def cache_447_H_part1 : List Cell := [(-2, 5), (-2, 6), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (1, 1), (1, 2), (1, 3)] + +def cache_447_H_part2 : List Cell := [(1, 4), (1, 5), (1, 6), (1, 7), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (3, 1), (3, 2), (3, 3), (4, 1), (4, 3)] + +def cache_447_H : List Cell := (cache_447_H_part0 ++ (cache_447_H_part1 ++ cache_447_H_part2)) + +def cache_447 : ListRow := ⟨cache_447_A, cache_447_H, 19⟩ + +def cache_448_A_part0 : List Cell := [(-2, -1), (-1, -1), (-1, 0), (0, -1)] + +def cache_448_A : List Cell := cache_448_A_part0 + +def cache_448_H_part0 : List Cell := [(-5, 1), (-5, 3), (-4, -1), (-4, 1), (-4, 2), (-4, 3), (-3, -1), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8), (-2, -1), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-1, -1)] + +def cache_448_H_part1 : List Cell := [(-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5)] + +def cache_448_H_part2 : List Cell := [(1, 6), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (4, 1), (4, 2), (4, 3), (5, 1), (5, 3)] + +def cache_448_H : List Cell := (cache_448_H_part0 ++ (cache_448_H_part1 ++ cache_448_H_part2)) + +def cache_448 : ListRow := ⟨cache_448_A, cache_448_H, 19⟩ + +def cache_449_A_part0 : List Cell := [(-1, -3), (-1, -2), (-1, 0), (0, -4), (0, -3), (0, -2)] + +def cache_449_A : List Cell := cache_449_A_part0 + +def cache_449_H_part0 : List Cell := [(-4, 1), (-4, 3), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, -4), (0, -3), (0, -2)] + +def cache_449_H_part1 : List Cell := [(0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5)] + +def cache_449_H_part2 : List Cell := [(2, 6), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (6, 1)] + +def cache_449_H : List Cell := (cache_449_H_part0 ++ (cache_449_H_part1 ++ cache_449_H_part2)) + +def cache_449 : ListRow := ⟨cache_449_A, cache_449_H, 16⟩ + +def cache_450_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1), (1, 0), (3, 0)] + +def cache_450_A : List Cell := cache_450_A_part0 + +def cache_450_H_part0 : List Cell := [(-2, 4), (-1, -1), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, -1), (2, 0), (2, 1)] + +def cache_450_H_part1 : List Cell := [(2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (5, -1)] + +def cache_450_H_part2 : List Cell := [(5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (7, 1), (7, 2), (7, 3), (7, 4)] + +def cache_450_H : List Cell := (cache_450_H_part0 ++ (cache_450_H_part1 ++ cache_450_H_part2)) + +def cache_450 : ListRow := ⟨cache_450_A, cache_450_H, 16⟩ + +def cache_451_A_part0 : List Cell := [(0, -3), (0, -2), (1, -4), (1, -3), (1, -2)] + +def cache_451_A : List Cell := cache_451_A_part0 + +def cache_451_H_part0 : List Cell := [(-3, 1), (-3, 3), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, -4), (1, -3)] + +def cache_451_H_part1 : List Cell := [(1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4)] + +def cache_451_H_part2 : List Cell := [(3, 5), (3, 6), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (7, 1)] + +def cache_451_H : List Cell := (cache_451_H_part0 ++ (cache_451_H_part1 ++ cache_451_H_part2)) + +def cache_451 : ListRow := ⟨cache_451_A, cache_451_H, 17⟩ + +def cache_452_A_part0 : List Cell := [(-1, 1), (-1, 2), (0, 1), (0, 2), (1, 2)] + +def cache_452_A : List Cell := cache_452_A_part0 + +def cache_452_H_part0 : List Cell := [(-4, 5), (-4, 7), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (0, -1), (0, 0)] + +def cache_452_H_part1 : List Cell := [(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7)] + +def cache_452_H_part2 : List Cell := [(2, 8), (2, 9), (2, 10), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (6, 5)] + +def cache_452_H : List Cell := (cache_452_H_part0 ++ (cache_452_H_part1 ++ cache_452_H_part2)) + +def cache_452 : ListRow := ⟨cache_452_A, cache_452_H, 18⟩ + +def cache_453_A_part0 : List Cell := [(-1, -2), (-1, 0), (0, -2)] + +def cache_453_A : List Cell := cache_453_A_part0 + +def cache_453_H_part0 : List Cell := [(-6, -1), (-5, -1), (-5, 0), (-5, 1), (-4, -3), (-4, -1), (-4, 0), (-4, 1), (-3, -3), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-2, -7), (-2, -6), (-2, -5), (-2, -4), (-2, -3), (-2, -1), (-2, 0), (-2, 1), (-2, 2)] + +def cache_453_H_part1 : List Cell := [(-2, 3), (-1, -6), (-1, -5), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 2), (-1, 3), (-1, 4), (0, -7), (0, -6), (0, -5), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -3)] + +def cache_453_H_part2 : List Cell := [(1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1)] + +def cache_453_H : List Cell := (cache_453_H_part0 ++ (cache_453_H_part1 ++ cache_453_H_part2)) + +def cache_453 : ListRow := ⟨cache_453_A, cache_453_H, 12⟩ + +def cache_454_A_part0 : List Cell := [(-2, -1), (-1, -1), (-1, 0), (0, -1), (1, -1)] + +def cache_454_A : List Cell := cache_454_A_part0 + +def cache_454_H_part0 : List Cell := [(-5, 1), (-5, 3), (-4, 1), (-4, 2), (-4, 3), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8), (-2, -1), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-1, -1), (-1, 0), (-1, 1)] + +def cache_454_H_part1 : List Cell := [(-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6)] + +def cache_454_H_part2 : List Cell := [(2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (4, 1), (4, 2), (4, 3), (5, 1), (5, 3)] + +def cache_454_H : List Cell := (cache_454_H_part0 ++ (cache_454_H_part1 ++ cache_454_H_part2)) + +def cache_454 : ListRow := ⟨cache_454_A, cache_454_H, 19⟩ + +def cache_455_A_part0 : List Cell := [(-3, -1), (-3, 0), (-3, 1), (-2, 1), (-1, 1)] + +def cache_455_A : List Cell := cache_455_A_part0 + +def cache_455_H_part0 : List Cell := [(-5, 2), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-3, -1), (-3, 0), (-3, 1), (-2, 1), (-1, 0), (-1, 1), (0, 0), (0, 1), (1, 0), (2, 0)] + +def cache_455_H : List Cell := cache_455_H_part0 + +def cache_455 : ListRow := ⟨cache_455_A, cache_455_H, 5⟩ + +def cache_456_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0)] + +def cache_456_A : List Cell := cache_456_A_part0 + +def cache_456_H_part0 : List Cell := [(-4, 1), (-4, 3), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-1, -1), (-1, 0), (-1, 2), (-1, 3), (-1, 4), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -1), (1, 0), (1, 1)] + +def cache_456_H_part1 : List Cell := [(1, 2), (1, 3), (1, 4), (2, -1), (2, 1)] + +def cache_456_H : List Cell := (cache_456_H_part0 ++ cache_456_H_part1) + +def cache_456 : ListRow := ⟨cache_456_A, cache_456_H, 12⟩ + +def cache_457_A_part0 : List Cell := [(-1, -3), (-1, -1), (0, -1), (1, -1), (2, -1)] + +def cache_457_A : List Cell := cache_457_A_part0 + +def cache_457_H_part0 : List Cell := [(-4, 1), (-4, 3), (-3, 1), (-3, 2), (-3, 3), (-2, -2), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6)] + +def cache_457_H_part1 : List Cell := [(-1, 7), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (2, -1), (2, 0), (2, 1), (2, 2)] + +def cache_457_H_part2 : List Cell := [(2, 3), (2, 4), (2, 5), (2, 6), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (5, 1), (5, 2), (5, 3), (6, 1)] + +def cache_457_H_part3 : List Cell := [(6, 3)] + +def cache_457_H : List Cell := ((cache_457_H_part0 ++ cache_457_H_part1) ++ (cache_457_H_part2 ++ cache_457_H_part3)) + +def cache_457 : ListRow := ⟨cache_457_A, cache_457_H, 20⟩ + +def cache_458_A_part0 : List Cell := [(-3, -3), (-3, -2), (-3, -1), (-2, -3), (-2, 0), (-1, -3), (0, -3)] + +def cache_458_A : List Cell := cache_458_A_part0 + +def cache_458_H_part0 : List Cell := [(-5, 4), (-4, -1), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-2, -3), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-1, -4), (-1, -3)] + +def cache_458_H_part1 : List Cell := [(-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (1, -2), (1, -1), (1, 0)] + +def cache_458_H_part2 : List Cell := [(1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, 1), (4, 2)] + +def cache_458_H_part3 : List Cell := [(4, 3), (4, 4)] + +def cache_458_H : List Cell := ((cache_458_H_part0 ++ cache_458_H_part1) ++ (cache_458_H_part2 ++ cache_458_H_part3)) + +def cache_458 : ListRow := ⟨cache_458_A, cache_458_H, 17⟩ + +def cache_459_A_part0 : List Cell := [(-1, -1), (0, -2), (0, -1), (1, -1), (2, -1)] + +def cache_459_A : List Cell := cache_459_A_part0 + +def cache_459_H_part0 : List Cell := [(-4, 1), (-4, 3), (-3, -1), (-3, 1), (-3, 2), (-3, 3), (-2, -1), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7)] + +def cache_459_H_part1 : List Cell := [(0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (2, -1), (2, 0), (2, 1), (2, 2)] + +def cache_459_H_part2 : List Cell := [(2, 3), (2, 4), (2, 5), (2, 6), (3, -2), (3, -1), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (4, -2), (4, -1), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (5, -2), (5, 1), (5, 2), (5, 3)] + +def cache_459_H_part3 : List Cell := [(6, 1), (6, 3)] + +def cache_459_H : List Cell := ((cache_459_H_part0 ++ cache_459_H_part1) ++ (cache_459_H_part2 ++ cache_459_H_part3)) + +def cache_459 : ListRow := ⟨cache_459_A, cache_459_H, 20⟩ + +def cache_460_A_part0 : List Cell := [(-2, 0), (-1, 0)] + +def cache_460_A : List Cell := cache_460_A_part0 + +def cache_460_H_part0 : List Cell := [(-5, 1), (-4, 0), (-4, 1), (-3, 0), (-3, 1), (-2, 0), (-2, 1), (-2, 2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -1), (1, 0), (1, 1), (1, 2)] + +def cache_460_H_part1 : List Cell := [(1, 3), (1, 4), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1)] + +def cache_460_H : List Cell := (cache_460_H_part0 ++ cache_460_H_part1) + +def cache_460 : ListRow := ⟨cache_460_A, cache_460_H, 11⟩ + +def cache_461_A_part0 : List Cell := [(-1, -4), (-1, -3), (-1, -2), (-1, -1), (0, -3), (1, -3), (2, -3)] + +def cache_461_A : List Cell := cache_461_A_part0 + +def cache_461_H_part0 : List Cell := [(-3, 4), (-2, -1), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -3), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5)] + +def cache_461_H_part1 : List Cell := [(1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (3, -2)] + +def cache_461_H_part2 : List Cell := [(3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4)] + +def cache_461_H_part3 : List Cell := [(6, 1), (6, 2), (6, 3), (6, 4)] + +def cache_461_H : List Cell := ((cache_461_H_part0 ++ cache_461_H_part1) ++ (cache_461_H_part2 ++ cache_461_H_part3)) + +def cache_461 : ListRow := ⟨cache_461_A, cache_461_H, 18⟩ + +def cache_462_A_part0 : List Cell := [(-2, -1), (-2, 0), (-1, -1), (-1, 0)] + +def cache_462_A : List Cell := cache_462_A_part0 + +def cache_462_H_part0 : List Cell := [(-5, 3), (-5, 5), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-1, -3)] + +def cache_462_H_part1 : List Cell := [(-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (1, -3), (1, -2), (1, -1), (1, 0)] + +def cache_462_H_part2 : List Cell := [(1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, -1), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (4, 1), (4, 2)] + +def cache_462_H_part3 : List Cell := [(4, 3), (4, 4), (4, 5), (5, 3)] + +def cache_462_H : List Cell := ((cache_462_H_part0 ++ cache_462_H_part1) ++ (cache_462_H_part2 ++ cache_462_H_part3)) + +def cache_462 : ListRow := ⟨cache_462_A, cache_462_H, 19⟩ + +def cache_463_A_part0 : List Cell := [(-2, -2), (-2, -1), (-1, -3), (-1, -1), (0, -1), (1, -1)] + +def cache_463_A : List Cell := cache_463_A_part0 + +def cache_463_H_part0 : List Cell := [(-5, 1), (-5, 3), (-4, 1), (-4, 2), (-4, 3), (-3, -1), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-2, -2), (-2, -1), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-1, -3), (-1, -2), (-1, -1), (-1, 1)] + +def cache_463_H_part1 : List Cell := [(-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8)] + +def cache_463_H_part2 : List Cell := [(2, -2), (2, -1), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (4, -2), (4, -1), (4, 0), (4, 1)] + +def cache_463_H_part3 : List Cell := [(4, 2), (4, 3), (5, 0), (5, 1), (5, 3)] + +def cache_463_H : List Cell := ((cache_463_H_part0 ++ cache_463_H_part1) ++ (cache_463_H_part2 ++ cache_463_H_part3)) + +def cache_463 : ListRow := ⟨cache_463_A, cache_463_H, 20⟩ + +def cache_464_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1), (1, -2), (2, -2), (3, -2)] + +def cache_464_A : List Cell := cache_464_A_part0 + +def cache_464_H_part0 : List Cell := [(-2, 5), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, -2), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5)] + +def cache_464_H_part1 : List Cell := [(1, 6), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7)] + +def cache_464_H_part2 : List Cell := [(3, 8), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8), (6, 0), (6, 1), (6, 2), (6, 3)] + +def cache_464_H_part3 : List Cell := [(6, 4), (6, 5), (7, 2), (7, 3), (7, 4), (7, 5)] + +def cache_464_H : List Cell := ((cache_464_H_part0 ++ cache_464_H_part1) ++ (cache_464_H_part2 ++ cache_464_H_part3)) + +def cache_464 : ListRow := ⟨cache_464_A, cache_464_H, 19⟩ + +def cache_465_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1)] + +def cache_465_A : List Cell := cache_465_A_part0 + +def cache_465_H_part0 : List Cell := [(-3, 0), (-2, 0), (-1, -4), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (-1, 2), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (3, -1)] + +def cache_465_H_part1 : List Cell := [(3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1)] + +def cache_465_H : List Cell := (cache_465_H_part0 ++ cache_465_H_part1) + +def cache_465 : ListRow := ⟨cache_465_A, cache_465_H, 10⟩ + +def cache_466_A_part0 : List Cell := [(-2, -2), (-2, -1), (-2, 0), (-2, 1), (-1, -2)] + +def cache_466_A : List Cell := cache_466_A_part0 + +def cache_466_H_part0 : List Cell := [(-7, -1), (-7, 0), (-7, 1), (-6, -1), (-6, 0), (-6, 1), (-6, 2), (-5, -1), (-5, 0), (-5, 1), (-5, 2), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-3, -1), (-3, 0), (-3, 1), (-3, 3), (-3, 4), (-3, 5), (-2, -2), (-2, -1), (-2, 0)] + +def cache_466_H_part1 : List Cell := [(-2, 1), (-2, 2), (-2, 3), (-2, 4), (-1, -2), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, -5), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -5), (1, -4), (1, -3)] + +def cache_466_H_part2 : List Cell := [(1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (4, -1)] + +def cache_466_H_part3 : List Cell := [(4, 0), (4, 1), (4, 2), (5, -1), (5, 0), (5, 1), (5, 2)] + +def cache_466_H : List Cell := ((cache_466_H_part0 ++ cache_466_H_part1) ++ (cache_466_H_part2 ++ cache_466_H_part3)) + +def cache_466 : ListRow := ⟨cache_466_A, cache_466_H, 14⟩ + +def cache_467_A_part0 : List Cell := [(0, 1), (0, 2), (0, 3)] + +def cache_467_A : List Cell := cache_467_A_part0 + +def cache_467_H_part0 : List Cell := [(-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -1), (1, 0), (1, 2), (1, 3), (1, 4)] + +def cache_467_H_part1 : List Cell := [(2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3)] + +def cache_467_H_part2 : List Cell := [(4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4)] + +def cache_467_H_part3 : List Cell := [(7, 5), (7, 6), (8, 0), (8, 1), (8, 2), (9, 0), (9, 2)] + +def cache_467_H : List Cell := ((cache_467_H_part0 ++ cache_467_H_part1) ++ (cache_467_H_part2 ++ cache_467_H_part3)) + +def cache_467 : ListRow := ⟨cache_467_A, cache_467_H, 21⟩ + +def cache_468_A_part0 : List Cell := [(0, 1), (0, 2), (1, 1), (2, 1), (3, 1)] + +def cache_468_A : List Cell := cache_468_A_part0 + +def cache_468_H_part0 : List Cell := [(-2, 8), (-1, 0), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (1, 1), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7)] + +def cache_468_H_part1 : List Cell := [(1, 8), (1, 9), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (2, 11), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9)] + +def cache_468_H_part2 : List Cell := [(3, 10), (3, 11), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (4, 10), (4, 11), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8), (5, 9), (5, 10), (5, 11), (6, 3), (6, 4), (6, 5)] + +def cache_468_H_part3 : List Cell := [(6, 6), (6, 7), (6, 8), (7, 5), (7, 6), (7, 7), (7, 8)] + +def cache_468_H : List Cell := ((cache_468_H_part0 ++ cache_468_H_part1) ++ (cache_468_H_part2 ++ cache_468_H_part3)) + +def cache_468 : ListRow := ⟨cache_468_A, cache_468_H, 20⟩ + +def cache_469_A_part0 : List Cell := [(0, 1), (0, 2), (0, 3)] + +def cache_469_A : List Cell := cache_469_A_part0 + +def cache_469_H_part0 : List Cell := [(-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -2), (1, -1), (1, 0), (1, 2), (1, 3), (1, 4)] + +def cache_469_H_part1 : List Cell := [(2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3)] + +def cache_469_H_part2 : List Cell := [(4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4)] + +def cache_469_H_part3 : List Cell := [(7, 5), (7, 6), (8, 0), (8, 1), (8, 2), (9, 0), (9, 2)] + +def cache_469_H : List Cell := ((cache_469_H_part0 ++ cache_469_H_part1) ++ (cache_469_H_part2 ++ cache_469_H_part3)) + +def cache_469 : ListRow := ⟨cache_469_A, cache_469_H, 21⟩ + +def cache_470_A_part0 : List Cell := [(0, -1), (1, -1), (2, -1), (3, -1)] + +def cache_470_A : List Cell := cache_470_A_part0 + +def cache_470_H_part0 : List Cell := [(-2, 6), (-1, -2), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (1, -1), (1, 1), (1, 2), (1, 3), (1, 4)] + +def cache_470_H_part1 : List Cell := [(1, 5), (1, 6), (1, 7), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6)] + +def cache_470_H_part2 : List Cell := [(3, 7), (3, 8), (3, 9), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8), (5, 9), (6, 1), (6, 2)] + +def cache_470_H_part3 : List Cell := [(6, 3), (6, 4), (6, 5), (6, 6), (7, 3), (7, 4), (7, 5), (7, 6)] + +def cache_470_H : List Cell := ((cache_470_H_part0 ++ cache_470_H_part1) ++ (cache_470_H_part2 ++ cache_470_H_part3)) + +def cache_470 : ListRow := ⟨cache_470_A, cache_470_H, 21⟩ + +def cache_471_A_part0 : List Cell := [(-1, 0), (-1, 1), (-1, 2), (-1, 3)] + +def cache_471_A : List Cell := cache_471_A_part0 + +def cache_471_H_part0 : List Cell := [(-6, 1), (-6, 2), (-6, 3), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-2, 1), (-2, 2), (-2, 3), (-2, 5), (-2, 6), (-2, 7), (-1, 0), (-1, 1), (-1, 2)] + +def cache_471_H_part1 : List Cell := [(-1, 3), (-1, 4), (-1, 5), (-1, 6), (0, -1), (0, 0), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (2, -3), (2, -2)] + +def cache_471_H_part2 : List Cell := [(2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4)] + +def cache_471_H_part3 : List Cell := [(5, 1), (5, 2), (5, 3), (5, 4), (6, 1), (6, 2), (6, 3), (6, 4)] + +def cache_471_H : List Cell := ((cache_471_H_part0 ++ cache_471_H_part1) ++ (cache_471_H_part2 ++ cache_471_H_part3)) + +def cache_471 : ListRow := ⟨cache_471_A, cache_471_H, 15⟩ + +def cache_472_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1), (1, -3)] + +def cache_472_A : List Cell := cache_472_A_part0 + +def cache_472_H_part0 : List Cell := [(-5, -2), (-5, -1), (-5, 0), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-1, -2), (-1, -1), (-1, 0), (-1, 2), (-1, 3), (-1, 4), (0, -3), (0, -2), (0, -1)] + +def cache_472_H_part1 : List Cell := [(0, 0), (0, 1), (0, 2), (0, 3), (1, -4), (1, -3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -6), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (3, -6), (3, -5)] + +def cache_472_H_part2 : List Cell := [(3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (4, -6), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (5, -4), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1)] + +def cache_472_H_part3 : List Cell := [(6, -2), (6, -1), (6, 0), (6, 1), (7, -2), (7, -1), (7, 0), (7, 1)] + +def cache_472_H : List Cell := ((cache_472_H_part0 ++ cache_472_H_part1) ++ (cache_472_H_part2 ++ cache_472_H_part3)) + +def cache_472 : ListRow := ⟨cache_472_A, cache_472_H, 15⟩ + +def cache_473_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0), (-1, 1), (0, 1)] + +def cache_473_A : List Cell := cache_473_A_part0 + +def cache_473_H_part0 : List Cell := [(-6, 2), (-6, 4), (-5, 2), (-5, 3), (-5, 4), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7), (-3, 0), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8), (-3, 9), (-2, 0), (-2, 1), (-2, 2), (-2, 3)] + +def cache_473_H_part1 : List Cell := [(-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7)] + +def cache_473_H_part2 : List Cell := [(0, 8), (0, 9), (1, -1), (1, 0), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (2, -1), (2, 0), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (3, 0), (3, 2), (3, 3)] + +def cache_473_H_part3 : List Cell := [(3, 4), (3, 5), (3, 6), (3, 7), (4, 2), (4, 3), (4, 4), (5, 2), (5, 4)] + +def cache_473_H : List Cell := ((cache_473_H_part0 ++ cache_473_H_part1) ++ (cache_473_H_part2 ++ cache_473_H_part3)) + +def cache_473 : ListRow := ⟨cache_473_A, cache_473_H, 20⟩ + +def cache_474_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1), (1, -2), (1, 0), (2, 0), (3, 0)] + +def cache_474_A : List Cell := cache_474_A_part0 + +def cache_474_H_part0 : List Cell := [(-3, 2), (-3, 4), (-2, 2), (-2, 3), (-2, 4), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7)] + +def cache_474_H_part1 : List Cell := [(1, -2), (1, -1), (1, 0), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5)] + +def cache_474_H_part2 : List Cell := [(3, 6), (3, 7), (3, 8), (3, 9), (4, -1), (4, 0), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8), (5, 9)] + +def cache_474_H_part3 : List Cell := [(6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (7, 1), (7, 2), (7, 4)] + +def cache_474_H : List Cell := ((cache_474_H_part0 ++ cache_474_H_part1) ++ (cache_474_H_part2 ++ cache_474_H_part3)) + +def cache_474 : ListRow := ⟨cache_474_A, cache_474_H, 21⟩ + +def cache_475_A_part0 : List Cell := [(-3, -2), (-3, 0), (-2, 0), (-1, 0)] + +def cache_475_A : List Cell := cache_475_A_part0 + +def cache_475_H_part0 : List Cell := [(-6, 2), (-6, 4), (-5, 2), (-5, 3), (-5, 4), (-4, -1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7), (-4, 8), (-4, 9), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7)] + +def cache_475_H_part1 : List Cell := [(-3, 8), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (0, -2), (0, -1), (0, 0), (0, 1)] + +def cache_475_H_part2 : List Cell := [(0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7)] + +def cache_475_H_part3 : List Cell := [(3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -1), (4, 1), (4, 2), (4, 4)] + +def cache_475_H : List Cell := ((cache_475_H_part0 ++ cache_475_H_part1) ++ (cache_475_H_part2 ++ cache_475_H_part3)) + +def cache_475 : ListRow := ⟨cache_475_A, cache_475_H, 21⟩ + +def cache_476_A_part0 : List Cell := [(-2, -1), (-1, -1), (0, -1), (1, 0)] + +def cache_476_A : List Cell := cache_476_A_part0 + +def cache_476_H_part0 : List Cell := [(-5, 1), (-5, 3), (-4, 1), (-4, 2), (-4, 3), (-3, -1), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-2, -1), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-1, -1), (-1, 0), (-1, 1)] + +def cache_476_H_part1 : List Cell := [(-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5)] + +def cache_476_H_part2 : List Cell := [(1, 6), (1, 7), (1, 8), (2, -2), (2, -1), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (3, -2), (3, -1), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (4, -1), (4, 1)] + +def cache_476_H_part3 : List Cell := [(4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (5, 1), (5, 2), (5, 3), (6, 1), (6, 3)] + +def cache_476_H : List Cell := ((cache_476_H_part0 ++ cache_476_H_part1) ++ (cache_476_H_part2 ++ cache_476_H_part3)) + +def cache_476 : ListRow := ⟨cache_476_A, cache_476_H, 21⟩ + +def cache_477_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1)] + +def cache_477_A : List Cell := cache_477_A_part0 + +def cache_477_H_part0 : List Cell := [(-5, -3), (-5, -2), (-5, -1), (-4, -4), (-4, -3), (-4, -2), (-4, -1), (-3, -4), (-3, -3), (-3, -2), (-3, -1), (-2, -4), (-2, -3), (-2, -2), (-2, -1), (-1, -7), (-1, -6), (-1, -5), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -6), (0, -5)] + +def cache_477_H_part1 : List Cell := [(0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -7), (1, -6), (1, -5), (1, -4), (1, -3), (1, -2), (1, 0), (1, 1), (1, 2), (2, -6), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1)] + +def cache_477_H_part2 : List Cell := [(2, 2), (2, 3), (3, -6), (3, -5), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (4, -6), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (5, -4), (5, -3)] + +def cache_477_H_part3 : List Cell := [(5, -2), (5, -1), (5, 0), (5, 1), (6, -4), (6, -3), (6, -2), (6, -1), (7, -4), (7, -3), (7, -2), (7, -1)] + +def cache_477_H : List Cell := ((cache_477_H_part0 ++ cache_477_H_part1) ++ (cache_477_H_part2 ++ cache_477_H_part3)) + +def cache_477 : ListRow := ⟨cache_477_A, cache_477_H, 16⟩ + +def cache_478_A_part0 : List Cell := [(1, -2), (1, -1), (1, 0), (2, 0)] + +def cache_478_A : List Cell := cache_478_A_part0 + +def cache_478_H_part0 : List Cell := [(-1, 0), (-1, 1), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -3), (1, -2), (1, -1), (1, 0), (2, -2), (2, -1), (2, 0), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (4, -1), (4, 0), (4, 1), (5, -1), (5, 0)] + +def cache_478_H_part1 : List Cell := [(5, 1)] + +def cache_478_H : List Cell := (cache_478_H_part0 ++ cache_478_H_part1) + +def cache_478 : ListRow := ⟨cache_478_A, cache_478_H, 8⟩ + +def cache_479_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0)] + +def cache_479_A : List Cell := cache_479_A_part0 + +def cache_479_H_part0 : List Cell := [(-8, 2), (-8, 4), (-7, 2), (-7, 3), (-7, 4), (-6, 2), (-6, 3), (-6, 4), (-6, 5), (-6, 6), (-6, 7), (-5, 2), (-5, 3), (-5, 4), (-5, 5), (-5, 6), (-5, 7), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6)] + +def cache_479_H_part1 : List Cell := [(-4, 7), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8), (-3, 9), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-1, -1), (-1, 0)] + +def cache_479_H_part2 : List Cell := [(-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4)] + +def cache_479_H_part3 : List Cell := [(1, 5), (1, 6), (1, 7), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (4, 2), (4, 3), (4, 4), (5, 2), (5, 4)] + +def cache_479_H : List Cell := ((cache_479_H_part0 ++ cache_479_H_part1) ++ (cache_479_H_part2 ++ cache_479_H_part3)) + +def cache_479 : ListRow := ⟨cache_479_A, cache_479_H, 21⟩ + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/CacheData12.lean b/lean/OAI/Combinatorics/SnakyCertificate/CacheData12.lean new file mode 100644 index 0000000000000000000000000000000000000000..634fbcf7811569c55d953916c639eb60918647b6 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/CacheData12.lean @@ -0,0 +1,517 @@ +import OAI.Combinatorics.SnakyCertificate.Lists + +namespace OAI + +namespace SnakyCertificate.Check + +def cache_480_A_part0 : List Cell := [(-1, -3), (0, -3), (0, -2), (0, -1), (1, 1)] + +def cache_480_A : List Cell := cache_480_A_part0 + +def cache_480_H_part0 : List Cell := [(-1, -3), (-1, -2), (-1, 1), (-1, 2), (-1, 3), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (1, 3)] + +def cache_480_H : List Cell := cache_480_H_part0 + +def cache_480 : ListRow := ⟨cache_480_A, cache_480_H, 7⟩ + +def cache_481_A_part0 : List Cell := [(-3, -2), (-2, 0), (-2, 1), (-1, 0)] + +def cache_481_A : List Cell := cache_481_A_part0 + +def cache_481_H_part0 : List Cell := [(-5, 0), (-4, -1), (-4, 0), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-2, 0), (-2, 1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -2), (1, -1), (1, 0), (1, 1)] + +def cache_481_H_part1 : List Cell := [(1, 2), (1, 3), (1, 4), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -1), (3, 1), (3, 2), (4, 2)] + +def cache_481_H : List Cell := (cache_481_H_part0 ++ cache_481_H_part1) + +def cache_481 : ListRow := ⟨cache_481_A, cache_481_H, 11⟩ + +def cache_482_A_part0 : List Cell := [(-1, -3), (-1, -2), (-1, -1), (-1, 0), (1, -3)] + +def cache_482_A : List Cell := cache_482_A_part0 + +def cache_482_H_part0 : List Cell := [(-3, -1), (-2, -2), (-2, -1), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -1), (0, 0), (0, 1), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (2, -2), (2, -1), (2, 0), (3, -1)] + +def cache_482_H : List Cell := cache_482_H_part0 + +def cache_482 : ListRow := ⟨cache_482_A, cache_482_H, 7⟩ + +def cache_483_A_part0 : List Cell := [(-2, -3), (-2, -2), (-2, -1), (0, -2), (0, -1)] + +def cache_483_A : List Cell := cache_483_A_part0 + +def cache_483_H_part0 : List Cell := [(-7, -1), (-6, -2), (-6, -1), (-5, -2), (-5, -1), (-4, -2), (-4, -1), (-3, -2), (-3, -1), (-2, -3), (-2, -2), (-2, -1), (-2, 1), (-1, -5), (-1, -4), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, -4)] + +def cache_483_H_part1 : List Cell := [(0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -5), (1, -4), (1, -3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0)] + +def cache_483_H_part2 : List Cell := [(2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4)] + +def cache_483_H_part3 : List Cell := [(4, 5), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (8, -3), (8, -2)] + +def cache_483_H_part4 : List Cell := [(8, -1), (9, -3), (9, -1)] + +def cache_483_H : List Cell := ((cache_483_H_part0 ++ cache_483_H_part1) ++ (cache_483_H_part2 ++ (cache_483_H_part3 ++ cache_483_H_part4))) + +def cache_483 : ListRow := ⟨cache_483_A, cache_483_H, 22⟩ + +def cache_484_A_part0 : List Cell := [(-2, 0), (-2, 1), (-1, 0)] + +def cache_484_A : List Cell := cache_484_A_part0 + +def cache_484_H_part0 : List Cell := [(-5, 1), (-4, -1), (-4, 1), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-2, 0), (-2, 1), (-2, 2), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4)] + +def cache_484_H_part1 : List Cell := [(0, 5), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, -1), (2, 0), (2, 1), (3, -1), (3, 1)] + +def cache_484_H : List Cell := (cache_484_H_part0 ++ cache_484_H_part1) + +def cache_484 : ListRow := ⟨cache_484_A, cache_484_H, 12⟩ + +def cache_485_A_part0 : List Cell := [(-1, 0), (-1, 1), (0, -3), (0, -2)] + +def cache_485_A : List Cell := cache_485_A_part0 + +def cache_485_H_part0 : List Cell := [(-4, 1), (-3, -1), (-3, 1), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-1, 0), (-1, 1), (-1, 2), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (1, -1), (1, 0), (1, 1)] + +def cache_485_H_part1 : List Cell := [(1, 2), (1, 3), (1, 4), (1, 5), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (3, -1), (3, 0), (3, 1), (4, -1), (4, 1)] + +def cache_485_H : List Cell := (cache_485_H_part0 ++ cache_485_H_part1) + +def cache_485 : ListRow := ⟨cache_485_A, cache_485_H, 13⟩ + +def cache_486_A_part0 : List Cell := [(0, -3), (0, -1), (1, -4), (1, -3)] + +def cache_486_A : List Cell := cache_486_A_part0 + +def cache_486_H_part0 : List Cell := [(-3, 0), (-2, -2), (-2, 0), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, -2)] + +def cache_486_H_part1 : List Cell := [(2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -2), (4, -1), (4, 0), (5, -2), (5, 0)] + +def cache_486_H : List Cell := (cache_486_H_part0 ++ cache_486_H_part1) + +def cache_486 : ListRow := ⟨cache_486_A, cache_486_H, 14⟩ + +def cache_487_A_part0 : List Cell := [(-2, -2), (-1, 0), (-1, 1), (0, -3), (0, -2)] + +def cache_487_A : List Cell := cache_487_A_part0 + +def cache_487_H_part0 : List Cell := [(-4, 0), (-3, -1), (-3, 0), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-1, 0), (-1, 1), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -2)] + +def cache_487_H_part1 : List Cell := [(2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -1), (4, 1), (4, 2), (5, 2)] + +def cache_487_H : List Cell := (cache_487_H_part0 ++ cache_487_H_part1) + +def cache_487 : ListRow := ⟨cache_487_A, cache_487_H, 12⟩ + +def cache_488_A_part0 : List Cell := [(-2, -1), (-2, 0), (-1, -1), (-1, 0), (1, 0)] + +def cache_488_A : List Cell := cache_488_A_part0 + +def cache_488_H_part0 : List Cell := [(-3, 1), (-3, 2), (-3, 3), (-3, 4), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (2, 0), (2, 1)] + +def cache_488_H : List Cell := cache_488_H_part0 + +def cache_488 : ListRow := ⟨cache_488_A, cache_488_H, 9⟩ + +def cache_489_A_part0 : List Cell := [(-2, -2), (-2, 0), (-1, -2), (-1, 0)] + +def cache_489_A : List Cell := cache_489_A_part0 + +def cache_489_H_part0 : List Cell := [(-5, -1), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, -5), (-2, -4), (-2, -3), (-2, -2), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1)] + +def cache_489_H_part1 : List Cell := [(-1, 2), (-1, 3), (-1, 4), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1), (2, 1)] + +def cache_489_H : List Cell := (cache_489_H_part0 ++ cache_489_H_part1) + +def cache_489 : ListRow := ⟨cache_489_A, cache_489_H, 9⟩ + +def cache_490_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1)] + +def cache_490_A : List Cell := cache_490_A_part0 + +def cache_490_H_part0 : List Cell := [(-5, -2), (-5, -1), (-5, 0), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 2), (-1, 3), (-1, 4), (0, -3)] + +def cache_490_H_part1 : List Cell := [(0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -4), (1, -3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -6), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3)] + +def cache_490_H_part2 : List Cell := [(3, -6), (3, -5), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (4, -6), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (5, -4), (5, -3), (5, -2)] + +def cache_490_H_part3 : List Cell := [(5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (6, -4), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (7, -5), (7, -4), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3)] + +def cache_490_H_part4 : List Cell := [(7, 4), (8, -4), (8, -2), (8, -1), (8, 0), (8, 1), (8, 2), (9, -1), (9, 0), (9, 1), (9, 2), (10, -1), (10, 0), (10, 1), (10, 2)] + +def cache_490_H : List Cell := ((cache_490_H_part0 ++ cache_490_H_part1) ++ (cache_490_H_part2 ++ (cache_490_H_part3 ++ cache_490_H_part4))) + +def cache_490 : ListRow := ⟨cache_490_A, cache_490_H, 22⟩ + +def cache_491_A_part0 : List Cell := [(-1, 0), (0, -3), (0, -2), (0, -1)] + +def cache_491_A : List Cell := cache_491_A_part0 + +def cache_491_H_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0), (-1, 1), (0, -3), (0, -2), (0, -1), (0, 0), (1, -2), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1)] + +def cache_491_H : List Cell := cache_491_H_part0 + +def cache_491 : ListRow := ⟨cache_491_A, cache_491_H, 9⟩ + +def cache_492_A_part0 : List Cell := [(1, 0), (1, 2), (1, 3), (2, -1), (2, 0)] + +def cache_492_A : List Cell := cache_492_A_part0 + +def cache_492_H_part0 : List Cell := [(-3, -1), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (0, -1), (0, 0), (0, 1), (0, 2), (1, 0), (1, 2), (1, 3), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5)] + +def cache_492_H_part1 : List Cell := [(2, 6), (3, -1), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (6, 1), (6, 3), (6, 4)] + +def cache_492_H_part2 : List Cell := [(7, 4)] + +def cache_492_H : List Cell := (cache_492_H_part0 ++ (cache_492_H_part1 ++ cache_492_H_part2)) + +def cache_492 : ListRow := ⟨cache_492_A, cache_492_H, 13⟩ + +def cache_493_A_part0 : List Cell := [(-2, -2), (-2, -1), (-2, 0), (-1, 0)] + +def cache_493_A : List Cell := cache_493_A_part0 + +def cache_493_H_part0 : List Cell := [(-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-2, -2), (-2, -1), (-2, 0), (-1, 0), (-1, 1), (-1, 2), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3)] + +def cache_493_H_part1 : List Cell := [(1, 4), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, 1)] + +def cache_493_H : List Cell := (cache_493_H_part0 ++ cache_493_H_part1) + +def cache_493 : ListRow := ⟨cache_493_A, cache_493_H, 8⟩ + +def cache_494_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0), (-1, 1)] + +def cache_494_A : List Cell := cache_494_A_part0 + +def cache_494_H_part0 : List Cell := [(-6, 2), (-5, 2), (-4, -1), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-1, 0), (-1, 1)] + +def cache_494_H_part1 : List Cell := [(0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, 1)] + +def cache_494_H : List Cell := (cache_494_H_part0 ++ cache_494_H_part1) + +def cache_494 : ListRow := ⟨cache_494_A, cache_494_H, 11⟩ + +def cache_495_A_part0 : List Cell := [(-2, -1), (-2, 0), (-1, -1), (-1, 0)] + +def cache_495_A : List Cell := cache_495_A_part0 + +def cache_495_H_part0 : List Cell := [(-5, -1), (-5, 0), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-2, -1), (-2, 0), (-2, 2), (-2, 3), (-2, 4), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3)] + +def cache_495_H_part1 : List Cell := [(0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 3), (2, 0), (2, 1)] + +def cache_495_H : List Cell := (cache_495_H_part0 ++ cache_495_H_part1) + +def cache_495 : ListRow := ⟨cache_495_A, cache_495_H, 13⟩ + +def cache_496_A_part0 : List Cell := [(1, 0), (2, 0), (2, 1)] + +def cache_496_A : List Cell := cache_496_A_part0 + +def cache_496_H_part0 : List Cell := [(-3, -1), (-3, 1), (-3, 2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, 0), (1, 1), (1, 2)] + +def cache_496_H_part1 : List Cell := [(1, 3), (1, 4), (1, 5), (1, 6), (2, 0), (2, 1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1), (5, 0), (5, 1), (6, -1), (6, 0), (6, 1), (7, 1)] + +def cache_496_H : List Cell := (cache_496_H_part0 ++ cache_496_H_part1) + +def cache_496 : ListRow := ⟨cache_496_A, cache_496_H, 12⟩ + +def cache_497_A_part0 : List Cell := [(1, -1), (1, 0), (2, -1), (2, 0)] + +def cache_497_A : List Cell := cache_497_A_part0 + +def cache_497_H_part0 : List Cell := [(-3, 1), (-3, 3), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3)] + +def cache_497_H_part1 : List Cell := [(1, 4), (1, 5), (1, 6), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (5, 0), (5, 1), (5, 2), (5, 3), (6, 1), (6, 2)] + +def cache_497_H_part2 : List Cell := [(6, 3), (7, 1)] + +def cache_497_H : List Cell := (cache_497_H_part0 ++ (cache_497_H_part1 ++ cache_497_H_part2)) + +def cache_497 : ListRow := ⟨cache_497_A, cache_497_H, 15⟩ + +def cache_498_A_part0 : List Cell := [(-2, 1), (-1, -2), (-1, -1), (-1, 0), (0, 1)] + +def cache_498_A : List Cell := cache_498_A_part0 + +def cache_498_H_part0 : List Cell := [(-5, -1), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, 0), (-2, 1), (-1, -2), (-1, -1), (-1, 0), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, -1)] + +def cache_498_H_part1 : List Cell := [(3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, 1)] + +def cache_498_H : List Cell := (cache_498_H_part0 ++ cache_498_H_part1) + +def cache_498 : ListRow := ⟨cache_498_A, cache_498_H, 9⟩ + +def cache_499_A_part0 : List Cell := [(-1, -2), (-1, -1), (-1, 0)] + +def cache_499_A : List Cell := cache_499_A_part0 + +def cache_499_H_part0 : List Cell := [(-3, 0), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3)] + +def cache_499_H_part1 : List Cell := [(2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1), (5, 0), (5, 1), (6, 1)] + +def cache_499_H : List Cell := (cache_499_H_part0 ++ cache_499_H_part1) + +def cache_499 : ListRow := ⟨cache_499_A, cache_499_H, 9⟩ + +def cache_500_A_part0 : List Cell := [(-1, -1), (-1, 0), (-1, 1), (-1, 3), (0, -1)] + +def cache_500_A : List Cell := cache_500_A_part0 + +def cache_500_H_part0 : List Cell := [(-4, 1), (-3, 0), (-3, 1), (-2, 0), (-2, 1), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -1), (0, 0), (0, 1), (0, 3), (0, 4), (0, 5), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -1), (2, 0)] + +def cache_500_H_part1 : List Cell := [(2, 1), (2, 2), (2, 3), (2, 4), (3, -1), (3, 0), (3, 1), (4, -1), (4, 1)] + +def cache_500_H : List Cell := (cache_500_H_part0 ++ cache_500_H_part1) + +def cache_500 : ListRow := ⟨cache_500_A, cache_500_H, 12⟩ + +def cache_501_A_part0 : List Cell := [(-3, 0), (-3, 1), (-3, 2), (-2, 0), (-1, 0)] + +def cache_501_A : List Cell := cache_501_A_part0 + +def cache_501_H_part0 : List Cell := [(-4, -1), (-4, 1), (-4, 3), (-4, 4), (-4, 5), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-2, 0), (-2, 2), (-2, 3), (-2, 4), (-1, -1), (-1, 0), (-1, 1), (-1, 3), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4)] + +def cache_501_H_part1 : List Cell := [(1, 1), (1, 3), (1, 4), (1, 5)] + +def cache_501_H : List Cell := (cache_501_H_part0 ++ cache_501_H_part1) + +def cache_501 : ListRow := ⟨cache_501_A, cache_501_H, 10⟩ + +def cache_502_A_part0 : List Cell := [(-2, -2), (-2, 0), (-1, -2), (-1, 0), (0, -2)] + +def cache_502_A : List Cell := cache_502_A_part0 + +def cache_502_H_part0 : List Cell := [(-5, -1), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -5), (-3, -4), (-3, -3), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-2, -4), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-1, -5), (-1, -4), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (-1, 2)] + +def cache_502_H_part1 : List Cell := [(-1, 3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, -1), (2, 0), (2, 1), (3, -1), (3, 1)] + +def cache_502_H : List Cell := (cache_502_H_part0 ++ cache_502_H_part1) + +def cache_502 : ListRow := ⟨cache_502_A, cache_502_H, 8⟩ + +def cache_503_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1), (1, -2)] + +def cache_503_A : List Cell := cache_503_A_part0 + +def cache_503_H_part0 : List Cell := [(-1, -5), (-1, -4), (-1, -3), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -2), (1, 0), (1, 1), (1, 2), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1)] + +def cache_503_H_part1 : List Cell := [(2, 2), (2, 3), (2, 4), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (5, -2), (5, -1)] + +def cache_503_H_part2 : List Cell := [(5, 0), (5, 1), (5, 2), (6, -1), (6, 0), (6, 1), (6, 2), (7, -1), (7, 0), (7, 1), (7, 2)] + +def cache_503_H : List Cell := (cache_503_H_part0 ++ (cache_503_H_part1 ++ cache_503_H_part2)) + +def cache_503 : ListRow := ⟨cache_503_A, cache_503_H, 14⟩ + +def cache_504_A_part0 : List Cell := [(1, -2), (1, -1), (1, 0), (1, 1)] + +def cache_504_A : List Cell := cache_504_A_part0 + +def cache_504_H_part0 : List Cell := [(-4, -1), (-4, 1), (-4, 2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, -1), (0, 0), (0, 1)] + +def cache_504_H_part1 : List Cell := [(0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, 0), (2, 1), (2, 3), (2, 4), (2, 5), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1)] + +def cache_504_H_part2 : List Cell := [(5, 0), (5, 1), (6, 1)] + +def cache_504_H : List Cell := (cache_504_H_part0 ++ (cache_504_H_part1 ++ cache_504_H_part2)) + +def cache_504 : ListRow := ⟨cache_504_A, cache_504_H, 13⟩ + +def cache_505_A_part0 : List Cell := [(0, -2), (0, -1)] + +def cache_505_A : List Cell := cache_505_A_part0 + +def cache_505_H_part0 : List Cell := [(-2, 0), (-2, 1), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3)] + +def cache_505_H_part1 : List Cell := [(2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -3), (4, -1), (4, 0), (4, 1), (5, -1), (5, 0), (5, 1), (6, -1), (6, 0)] + +def cache_505_H_part2 : List Cell := [(6, 1), (7, 1)] + +def cache_505_H : List Cell := (cache_505_H_part0 ++ (cache_505_H_part1 ++ cache_505_H_part2)) + +def cache_505 : ListRow := ⟨cache_505_A, cache_505_H, 11⟩ + +def cache_506_A_part0 : List Cell := [(-2, -2), (-2, 0), (-1, -3), (-1, -2), (-1, 0)] + +def cache_506_A : List Cell := cache_506_A_part0 + +def cache_506_H_part0 : List Cell := [(-5, -1), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -4), (1, -3)] + +def cache_506_H_part1 : List Cell := [(1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (3, -2), (3, -1), (3, 1), (4, -2)] + +def cache_506_H : List Cell := (cache_506_H_part0 ++ cache_506_H_part1) + +def cache_506 : ListRow := ⟨cache_506_A, cache_506_H, 11⟩ + +def cache_507_A_part0 : List Cell := [(-2, -3), (-2, -2), (-1, 0), (-1, 1), (0, -2)] + +def cache_507_A : List Cell := cache_507_A_part0 + +def cache_507_H_part0 : List Cell := [(-4, 0), (-3, -1), (-3, 0), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3)] + +def cache_507_H_part1 : List Cell := [(1, 4), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -1), (4, 1), (4, 2), (5, 2)] + +def cache_507_H : List Cell := (cache_507_H_part0 ++ cache_507_H_part1) + +def cache_507 : ListRow := ⟨cache_507_A, cache_507_H, 12⟩ + +def cache_508_A_part0 : List Cell := [(-3, -1), (-3, 0), (-2, -1), (-1, -2), (-1, -1), (0, -1)] + +def cache_508_A : List Cell := cache_508_A_part0 + +def cache_508_H_part0 : List Cell := [(-5, 2), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4)] + +def cache_508_H_part1 : List Cell := [(-1, 5), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (3, 0), (3, 1), (3, 2)] + +def cache_508_H : List Cell := (cache_508_H_part0 ++ cache_508_H_part1) + +def cache_508 : ListRow := ⟨cache_508_A, cache_508_H, 13⟩ + +def cache_509_A_part0 : List Cell := [(-1, -2), (-1, -1), (-1, 0), (1, 0)] + +def cache_509_A : List Cell := cache_509_A_part0 + +def cache_509_H_part0 : List Cell := [(-6, 1), (-5, -1), (-5, 0), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-1, -2), (-1, -1), (-1, 0), (0, -1), (0, 0), (1, -2), (1, -1), (1, 0), (2, -1)] + +def cache_509_H_part1 : List Cell := [(2, 0), (2, 1), (2, 2), (2, 3), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1)] + +def cache_509_H : List Cell := (cache_509_H_part0 ++ cache_509_H_part1) + +def cache_509 : ListRow := ⟨cache_509_A, cache_509_H, 8⟩ + +def cache_510_A_part0 : List Cell := [(0, -1), (1, -1), (2, -2), (2, -1), (3, -1)] + +def cache_510_A : List Cell := cache_510_A_part0 + +def cache_510_H_part0 : List Cell := [(-2, 2), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3)] + +def cache_510_H_part1 : List Cell := [(2, 4), (2, 5), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (4, 0), (4, 1), (4, 2), (4, 3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (6, 0), (6, 1), (6, 2)] + +def cache_510_H : List Cell := (cache_510_H_part0 ++ cache_510_H_part1) + +def cache_510 : ListRow := ⟨cache_510_A, cache_510_H, 14⟩ + +def cache_511_A_part0 : List Cell := [(-3, -2), (-2, -2), (-1, -2), (-1, -1), (-1, 0), (0, 2)] + +def cache_511_A : List Cell := cache_511_A_part0 + +def cache_511_H_part0 : List Cell := [(-6, -1), (-5, -1), (-5, 0), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-2, -2), (-2, -1), (-2, 0), (-1, -2), (-1, -1), (-1, 0), (-1, 3), (-1, 4), (-1, 5), (0, -1), (0, 0)] + +def cache_511_H_part1 : List Cell := [(0, 1), (0, 2), (0, 3), (0, 4), (1, -2), (1, -1), (1, 0), (1, 1), (1, 3), (1, 4), (1, 5), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, -1), (4, 1)] + +def cache_511_H : List Cell := (cache_511_H_part0 ++ cache_511_H_part1) + +def cache_511 : ListRow := ⟨cache_511_A, cache_511_H, 10⟩ + +def cache_512_A_part0 : List Cell := [(-2, -1), (-2, 0), (-1, 0), (-1, 2), (-1, 3)] + +def cache_512_A : List Cell := cache_512_A_part0 + +def cache_512_H_part0 : List Cell := [(-4, 2), (-3, -1), (-3, 1), (-3, 2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-1, 0), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (1, -1), (1, 0), (1, 1)] + +def cache_512_H_part1 : List Cell := [(1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, -1), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (4, 1), (4, 3), (4, 4), (5, 4)] + +def cache_512_H : List Cell := (cache_512_H_part0 ++ cache_512_H_part1) + +def cache_512 : ListRow := ⟨cache_512_A, cache_512_H, 13⟩ + +def cache_513_A_part0 : List Cell := [(0, -1), (1, -1), (2, -1), (3, -1)] + +def cache_513_A : List Cell := cache_513_A_part0 + +def cache_513_H_part0 : List Cell := [(-2, 2), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2)] + +def cache_513_H_part1 : List Cell := [(2, 3), (2, 4), (2, 5), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (4, 0), (4, 1), (4, 2), (4, 3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (6, 0), (6, 1), (6, 2)] + +def cache_513_H : List Cell := (cache_513_H_part0 ++ cache_513_H_part1) + +def cache_513 : ListRow := ⟨cache_513_A, cache_513_H, 14⟩ + +def cache_514_A_part0 : List Cell := [(-3, 0), (-2, -1), (-2, 0), (-1, -1), (-1, 0)] + +def cache_514_A : List Cell := cache_514_A_part0 + +def cache_514_H_part0 : List Cell := [(-8, 2), (-8, 4), (-7, 2), (-7, 3), (-7, 4), (-6, 2), (-6, 3), (-6, 4), (-6, 5), (-6, 6), (-6, 7), (-5, 2), (-5, 3), (-5, 4), (-5, 5), (-5, 6), (-5, 7), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7)] + +def cache_514_H_part1 : List Cell := [(-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3)] + +def cache_514_H_part2 : List Cell := [(-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -1), (2, 0), (2, 1), (2, 2)] + +def cache_514_H_part3 : List Cell := [(2, 3), (3, 1), (3, 2), (3, 3)] + +def cache_514_H : List Cell := ((cache_514_H_part0 ++ cache_514_H_part1) ++ (cache_514_H_part2 ++ cache_514_H_part3)) + +def cache_514 : ListRow := ⟨cache_514_A, cache_514_H, 21⟩ + +def cache_515_A_part0 : List Cell := [(-4, -1), (-3, -1), (-3, 0), (-1, 0)] + +def cache_515_A : List Cell := cache_515_A_part0 + +def cache_515_H_part0 : List Cell := [(-4, -2), (-4, -1), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1)] + +def cache_515_H_part1 : List Cell := [(-1, 2), (-1, 3), (-1, 4), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, 1), (3, 2), (3, 3)] + +def cache_515_H_part2 : List Cell := [(3, 4)] + +def cache_515_H : List Cell := (cache_515_H_part0 ++ (cache_515_H_part1 ++ cache_515_H_part2)) + +def cache_515 : ListRow := ⟨cache_515_A, cache_515_H, 14⟩ + +def cache_516_A_part0 : List Cell := [(-1, -3), (-1, -2), (-1, 0), (0, -3), (0, -2)] + +def cache_516_A : List Cell := cache_516_A_part0 + +def cache_516_H_part0 : List Cell := [(-6, -2), (-5, -2), (-5, -1), (-5, 1), (-4, -4), (-4, -3), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-3, -4), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-1, -3), (-1, -2)] + +def cache_516_H_part1 : List Cell := [(-1, -1), (-1, 0), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (1, 2), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (4, -1), (4, 0), (4, 1), (5, -1)] + +def cache_516_H : List Cell := (cache_516_H_part0 ++ cache_516_H_part1) + +def cache_516 : ListRow := ⟨cache_516_A, cache_516_H, 12⟩ + +def cache_517_A_part0 : List Cell := [(-1, -3), (-1, -1), (0, -3), (0, -1)] + +def cache_517_A : List Cell := cache_517_A_part0 + +def cache_517_H_part0 : List Cell := [(-5, -2), (-5, 0), (-5, 1), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-1, -4), (-1, -3), (-1, -1)] + +def cache_517_H_part1 : List Cell := [(-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, -2), (2, -1), (2, 0), (3, -2), (3, -1), (3, 0)] + +def cache_517_H_part2 : List Cell := [(4, -2), (4, -1), (4, 0), (5, 0)] + +def cache_517_H : List Cell := (cache_517_H_part0 ++ (cache_517_H_part1 ++ cache_517_H_part2)) + +def cache_517 : ListRow := ⟨cache_517_A, cache_517_H, 13⟩ + +def cache_518_A_part0 : List Cell := [(1, -1), (1, 0), (2, -1), (2, 0)] + +def cache_518_A : List Cell := cache_518_A_part0 + +def cache_518_H_part0 : List Cell := [(-5, 2), (-5, 4), (-4, 2), (-4, 3), (-4, 4), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-2, 0), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5)] + +def cache_518_H_part1 : List Cell := [(-1, 6), (-1, 7), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (2, -1), (2, 0), (2, 1)] + +def cache_518_H_part2 : List Cell := [(2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (5, -1)] + +def cache_518_H_part3 : List Cell := [(5, 0), (5, 1), (5, 2), (5, 3), (6, 1), (6, 2), (6, 3)] + +def cache_518_H : List Cell := ((cache_518_H_part0 ++ cache_518_H_part1) ++ (cache_518_H_part2 ++ cache_518_H_part3)) + +def cache_518 : ListRow := ⟨cache_518_A, cache_518_H, 22⟩ + +def cache_519_A_part0 : List Cell := [(-2, 0), (-1, -3), (-1, -2), (-1, -1)] + +def cache_519_A : List Cell := cache_519_A_part0 + +def cache_519_H_part0 : List Cell := [(-6, -1), (-5, -2), (-5, -1), (-5, 0), (-5, 1), (-4, -3), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-2, -4), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-1, -3), (-1, -2)] + +def cache_519_H_part1 : List Cell := [(-1, -1), (-1, 0), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -2), (3, -1)] + +def cache_519_H_part2 : List Cell := [(3, 0), (3, 1), (4, -2), (4, -1), (4, 0), (5, 0)] + +def cache_519_H : List Cell := (cache_519_H_part0 ++ (cache_519_H_part1 ++ cache_519_H_part2)) + +def cache_519 : ListRow := ⟨cache_519_A, cache_519_H, 12⟩ + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/CacheData13.lean b/lean/OAI/Combinatorics/SnakyCertificate/CacheData13.lean new file mode 100644 index 0000000000000000000000000000000000000000..6930a630e9e46866c82bd0b0013a6dd0997ada7d --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/CacheData13.lean @@ -0,0 +1,611 @@ +import OAI.Combinatorics.SnakyCertificate.Lists + +namespace OAI + +namespace SnakyCertificate.Check + +def cache_520_A_part0 : List Cell := [(-2, -3), (-1, 0), (1, -2), (1, 0)] + +def cache_520_A : List Cell := cache_520_A_part0 + +def cache_520_H_part0 : List Cell := [(-5, -1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-1, -2), (-1, -1), (-1, 0), (0, -5), (0, -4), (0, -3), (0, -1), (0, 0), (0, 1), (1, -4)] + +def cache_520_H_part1 : List Cell := [(1, -3), (1, -2), (1, -1), (1, 0), (2, -5), (2, -4), (2, -3), (2, -1), (2, 0), (2, 1), (2, 2), (3, -1), (3, 0), (3, 1), (4, -1), (4, 1)] + +def cache_520_H : List Cell := (cache_520_H_part0 ++ cache_520_H_part1) + +def cache_520 : ListRow := ⟨cache_520_A, cache_520_H, 8⟩ + +def cache_521_A_part0 : List Cell := [(-1, -4), (-1, -3), (0, -3), (0, -1)] + +def cache_521_A : List Cell := cache_521_A_part0 + +def cache_521_H_part0 : List Cell := [(-6, 1), (-5, -2), (-5, 0), (-5, 1), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-2, -4), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3)] + +def cache_521_H_part1 : List Cell := [(-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -3), (0, -2), (0, -1), (0, 0), (1, -4), (1, -3), (1, -2), (1, -1), (2, -4), (2, -3), (2, -2), (2, -1), (3, -4), (3, -3), (3, -2), (3, -1)] + +def cache_521_H_part2 : List Cell := [(4, -4), (4, -2)] + +def cache_521_H : List Cell := (cache_521_H_part0 ++ (cache_521_H_part1 ++ cache_521_H_part2)) + +def cache_521 : ListRow := ⟨cache_521_A, cache_521_H, 14⟩ + +def cache_522_A_part0 : List Cell := [(-2, -1), (0, -1), (0, 1)] + +def cache_522_A : List Cell := cache_522_A_part0 + +def cache_522_H_part0 : List Cell := [(-5, -2), (-5, 0), (-4, -2), (-4, -1), (-4, 0), (-3, -2), (-3, -1), (-3, 0), (-2, -2), (-2, -1), (-2, 1), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2)] + +def cache_522_H_part1 : List Cell := [(0, 3), (0, 4), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 2), (1, 3), (1, 4), (2, -2), (2, -1), (2, 0), (2, 2), (3, -2), (3, -1), (3, 0), (3, 2), (4, -2), (4, -1), (4, 0), (5, -2)] + +def cache_522_H : List Cell := (cache_522_H_part0 ++ cache_522_H_part1) + +def cache_522 : ListRow := ⟨cache_522_A, cache_522_H, 9⟩ + +def cache_523_A_part0 : List Cell := [(-3, 4), (-2, 0), (-2, 1), (-2, 2), (-1, 0)] + +def cache_523_A : List Cell := cache_523_A_part0 + +def cache_523_H_part0 : List Cell := [(-7, 1), (-7, 3), (-6, 1), (-6, 2), (-6, 3), (-5, 1), (-5, 2), (-5, 3), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 5), (-4, 6), (-4, 7), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-2, 0), (-2, 1), (-2, 2)] + +def cache_523_H_part1 : List Cell := [(-2, 5), (-2, 6), (-2, 7), (-1, 0), (-1, 1), (-1, 2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -1), (2, 0), (2, 1), (2, 2)] + +def cache_523_H_part2 : List Cell := [(2, 3), (2, 4), (3, -1), (3, 1), (3, 2), (4, 2)] + +def cache_523_H : List Cell := (cache_523_H_part0 ++ (cache_523_H_part1 ++ cache_523_H_part2)) + +def cache_523 : ListRow := ⟨cache_523_A, cache_523_H, 11⟩ + +def cache_524_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1)] + +def cache_524_A : List Cell := cache_524_A_part0 + +def cache_524_H_part0 : List Cell := [(-5, -2), (-5, 0), (-5, 1), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-1, -2), (-1, -1), (-1, 0)] + +def cache_524_H_part1 : List Cell := [(-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, -2), (2, -1), (2, 0), (2, 1)] + +def cache_524_H_part2 : List Cell := [(2, 2), (2, 3), (2, 4), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -2), (4, -1), (4, 0), (4, 1), (5, -2), (5, 0), (5, 1)] + +def cache_524_H : List Cell := (cache_524_H_part0 ++ (cache_524_H_part1 ++ cache_524_H_part2)) + +def cache_524 : ListRow := ⟨cache_524_A, cache_524_H, 14⟩ + +def cache_525_A_part0 : List Cell := [(-2, 0), (-2, 1), (-2, 2), (-1, 0)] + +def cache_525_A : List Cell := cache_525_A_part0 + +def cache_525_H_part0 : List Cell := [(-7, 1), (-7, 3), (-6, 1), (-6, 2), (-6, 3), (-5, 1), (-5, 2), (-5, 3), (-4, 1), (-4, 2), (-4, 3), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-2, 0), (-2, 1), (-2, 2), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0)] + +def cache_525_H_part1 : List Cell := [(-1, 1), (-1, 2), (-1, 4), (-1, 5), (-1, 6), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6)] + +def cache_525_H_part2 : List Cell := [(2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -1), (3, 1), (3, 2), (3, 3), (4, 1), (4, 2), (4, 3), (5, 1)] + +def cache_525_H : List Cell := (cache_525_H_part0 ++ (cache_525_H_part1 ++ cache_525_H_part2)) + +def cache_525 : ListRow := ⟨cache_525_A, cache_525_H, 11⟩ + +def cache_526_A_part0 : List Cell := [(-1, -2), (-1, 0), (0, -2)] + +def cache_526_A : List Cell := cache_526_A_part0 + +def cache_526_H_part0 : List Cell := [(-6, 1), (-6, 2), (-5, -1), (-5, 0), (-5, 1), (-5, 2), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3)] + +def cache_526_H_part1 : List Cell := [(-2, 4), (-1, -7), (-1, -6), (-1, -5), (-1, -4), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, -6), (0, -5), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4)] + +def cache_526_H_part2 : List Cell := [(0, 5), (0, 6), (1, -6), (1, -5), (1, -4), (1, -3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, -1), (3, 0), (3, 1)] + +def cache_526_H_part3 : List Cell := [(4, -1), (4, 0), (4, 1), (5, -1)] + +def cache_526_H : List Cell := ((cache_526_H_part0 ++ cache_526_H_part1) ++ (cache_526_H_part2 ++ cache_526_H_part3)) + +def cache_526 : ListRow := ⟨cache_526_A, cache_526_H, 17⟩ + +def cache_527_A_part0 : List Cell := [(1, -3), (1, -2), (1, -1)] + +def cache_527_A : List Cell := cache_527_A_part0 + +def cache_527_H_part0 : List Cell := [(-5, 1), (-4, -2), (-4, -1), (-4, 1), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3)] + +def cache_527_H_part1 : List Cell := [(0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -3), (1, -2), (1, -1), (1, 0), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3)] + +def cache_527_H_part2 : List Cell := [(4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (5, -2), (5, -1), (5, 0), (5, 1), (6, -2), (6, -1), (6, 0), (7, 0)] + +def cache_527_H : List Cell := (cache_527_H_part0 ++ (cache_527_H_part1 ++ cache_527_H_part2)) + +def cache_527 : ListRow := ⟨cache_527_A, cache_527_H, 13⟩ + +def cache_528_A_part0 : List Cell := [(-2, -1), (-2, 0), (-2, 1), (0, 1)] + +def cache_528_A : List Cell := cache_528_A_part0 + +def cache_528_H_part0 : List Cell := [(-7, 0), (-7, 2), (-6, 0), (-6, 1), (-6, 2), (-5, 0), (-5, 1), (-5, 2), (-4, 0), (-4, 1), (-4, 2), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-2, -1), (-2, 0), (-2, 1), (-1, -5), (-1, -4), (-1, -3), (-1, -2), (-1, -1)] + +def cache_528_H_part1 : List Cell := [(-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 2), (1, 3)] + +def cache_528_H_part2 : List Cell := [(1, 4), (1, 5), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 3)] + +def cache_528_H : List Cell := (cache_528_H_part0 ++ (cache_528_H_part1 ++ cache_528_H_part2)) + +def cache_528 : ListRow := ⟨cache_528_A, cache_528_H, 12⟩ + +def cache_529_A_part0 : List Cell := [(1, 0), (2, 0), (3, 0)] + +def cache_529_A : List Cell := cache_529_A_part0 + +def cache_529_H_part0 : List Cell := [(-2, -1), (-2, 1), (-2, 4), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, 0), (1, 2), (1, 3), (1, 4), (1, 5), (2, -1), (2, 0), (2, 1)] + +def cache_529_H_part1 : List Cell := [(2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (5, -1)] + +def cache_529_H_part2 : List Cell := [(5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (7, 1), (7, 2), (7, 3), (7, 4)] + +def cache_529_H : List Cell := (cache_529_H_part0 ++ (cache_529_H_part1 ++ cache_529_H_part2)) + +def cache_529 : ListRow := ⟨cache_529_A, cache_529_H, 16⟩ + +def cache_530_A_part0 : List Cell := [(0, -1), (0, 1), (2, -1), (2, 1)] + +def cache_530_A : List Cell := cache_530_A_part0 + +def cache_530_H_part0 : List Cell := [(-4, -3), (-4, -1), (-4, 0), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-1, -4), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -3)] + +def cache_530_H_part1 : List Cell := [(0, -2), (0, -1), (0, 0), (0, 1), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (2, -1), (2, 1), (2, 2), (3, 0), (3, 1), (3, 2), (4, 0), (4, 1), (4, 2), (5, 0), (5, 1), (5, 2), (6, 0)] + +def cache_530_H_part2 : List Cell := [(6, 2)] + +def cache_530_H : List Cell := (cache_530_H_part0 ++ (cache_530_H_part1 ++ cache_530_H_part2)) + +def cache_530 : ListRow := ⟨cache_530_A, cache_530_H, 13⟩ + +def cache_531_A_part0 : List Cell := [(0, -2), (1, -2)] + +def cache_531_A : List Cell := cache_531_A_part0 + +def cache_531_H_part0 : List Cell := [(-5, -1), (-5, 1), (-5, 2), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-3, -3), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-1, -7), (-1, -6)] + +def cache_531_H_part1 : List Cell := [(-1, -5), (-1, -4), (-1, -3), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, -7), (0, -6), (0, -5), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, -7)] + +def cache_531_H_part2 : List Cell := [(1, -6), (1, -5), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (2, -7), (2, -6), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3)] + +def cache_531_H_part3 : List Cell := [(2, 4), (2, 5), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (5, -1), (5, 0), (5, 1), (6, -1)] + +def cache_531_H : List Cell := ((cache_531_H_part0 ++ cache_531_H_part1) ++ (cache_531_H_part2 ++ cache_531_H_part3)) + +def cache_531 : ListRow := ⟨cache_531_A, cache_531_H, 18⟩ + +def cache_532_A_part0 : List Cell := [(-1, -3), (0, -3), (0, -2), (0, -1)] + +def cache_532_A : List Cell := cache_532_A_part0 + +def cache_532_H_part0 : List Cell := [(-5, 0), (-4, -2), (-4, -1), (-4, 0), (-3, -2), (-3, -1), (-3, 0), (-2, -2), (-2, -1), (-2, 0), (-1, -4), (-1, -3), (-1, -1), (-1, 0), (-1, 2), (-1, 3), (-1, 4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3)] + +def cache_532_H_part1 : List Cell := [(1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -2), (4, -1)] + +def cache_532_H_part2 : List Cell := [(4, 0), (4, 1), (5, -2), (5, 0), (5, 1)] + +def cache_532_H : List Cell := (cache_532_H_part0 ++ (cache_532_H_part1 ++ cache_532_H_part2)) + +def cache_532 : ListRow := ⟨cache_532_A, cache_532_H, 14⟩ + +def cache_533_A_part0 : List Cell := [(0, -2), (0, -1)] + +def cache_533_A : List Cell := cache_533_A_part0 + +def cache_533_H_part0 : List Cell := [(-5, -1), (-4, -4), (-4, -3), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-3, -4), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-2, -6), (-2, -5), (-2, -4), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2)] + +def cache_533_H_part1 : List Cell := [(-2, 3), (-2, 4), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -5), (1, -4), (1, -3), (1, -2), (1, 0), (1, 1), (1, 2), (1, 3)] + +def cache_533_H_part2 : List Cell := [(2, -4), (2, -3), (2, -2), (2, 0), (2, 1), (3, -4), (3, -3), (3, -2), (3, 0), (4, -4), (4, -3), (4, -2), (5, -2)] + +def cache_533_H : List Cell := (cache_533_H_part0 ++ (cache_533_H_part1 ++ cache_533_H_part2)) + +def cache_533 : ListRow := ⟨cache_533_A, cache_533_H, 11⟩ + +def cache_534_A_part0 : List Cell := [(-2, -1), (-2, 0), (-2, 2), (-1, -1), (-1, 0), (-1, 2)] + +def cache_534_A : List Cell := cache_534_A_part0 + +def cache_534_H_part0 : List Cell := [(-5, 3), (-5, 5), (-4, -1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-3, -1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8), (-2, -1), (-2, 0), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-1, -1)] + +def cache_534_H_part1 : List Cell := [(-1, 0), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7)] + +def cache_534_H_part2 : List Cell := [(1, 8), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (5, 3)] + +def cache_534_H : List Cell := (cache_534_H_part0 ++ (cache_534_H_part1 ++ cache_534_H_part2)) + +def cache_534 : ListRow := ⟨cache_534_A, cache_534_H, 16⟩ + +def cache_535_A_part0 : List Cell := [(-2, -1), (-1, -1), (0, -1)] + +def cache_535_A : List Cell := cache_535_A_part0 + +def cache_535_H_part0 : List Cell := [(-5, -2), (-5, 0), (-5, 1), (-5, 2), (-5, 3), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4)] + +def cache_535_H_part1 : List Cell := [(-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, -4), (1, -3), (1, -2), (1, 0), (1, 1), (1, 2)] + +def cache_535_H_part2 : List Cell := [(1, 3), (1, 4), (1, 5), (1, 6), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (4, 0), (4, 1), (4, 2), (4, 3), (5, 0), (5, 1), (5, 3)] + +def cache_535_H : List Cell := (cache_535_H_part0 ++ (cache_535_H_part1 ++ cache_535_H_part2)) + +def cache_535 : ListRow := ⟨cache_535_A, cache_535_H, 15⟩ + +def cache_536_A_part0 : List Cell := [(-1, -3), (-1, -2), (-1, 0), (0, -3), (0, -2)] + +def cache_536_A : List Cell := cache_536_A_part0 + +def cache_536_H_part0 : List Cell := [(-4, 1), (-4, 3), (-3, -3), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-2, -3), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, -3)] + +def cache_536_H_part1 : List Cell := [(0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4)] + +def cache_536_H_part2 : List Cell := [(2, 5), (2, 6), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (6, 1)] + +def cache_536_H : List Cell := (cache_536_H_part0 ++ (cache_536_H_part1 ++ cache_536_H_part2)) + +def cache_536 : ListRow := ⟨cache_536_A, cache_536_H, 17⟩ + +def cache_537_A_part0 : List Cell := [(-3, 1), (-2, -1), (-2, 1), (0, -1), (0, 1)] + +def cache_537_A : List Cell := cache_537_A_part0 + +def cache_537_H_part0 : List Cell := [(-7, -2), (-7, 0), (-6, -2), (-6, -1), (-6, 0), (-5, -2), (-5, -1), (-5, 0), (-4, -2), (-4, -1), (-4, 0), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 2), (-1, 3)] + +def cache_537_H_part1 : List Cell := [(-1, 4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5)] + +def cache_537_H_part2 : List Cell := [(3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (5, 0)] + +def cache_537_H : List Cell := (cache_537_H_part0 ++ (cache_537_H_part1 ++ cache_537_H_part2)) + +def cache_537 : ListRow := ⟨cache_537_A, cache_537_H, 11⟩ + +def cache_538_A_part0 : List Cell := [(1, 0), (2, 0), (3, 0)] + +def cache_538_A : List Cell := cache_538_A_part0 + +def cache_538_H_part0 : List Cell := [(-2, -1), (-2, 1), (-2, 7), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (1, 0), (1, 2)] + +def cache_538_H_part1 : List Cell := [(1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4)] + +def cache_538_H_part2 : List Cell := [(3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (4, 10), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8), (5, 9)] + +def cache_538_H_part3 : List Cell := [(5, 10), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (7, 4), (7, 5), (7, 6), (7, 7)] + +def cache_538_H : List Cell := ((cache_538_H_part0 ++ cache_538_H_part1) ++ (cache_538_H_part2 ++ cache_538_H_part3)) + +def cache_538 : ListRow := ⟨cache_538_A, cache_538_H, 22⟩ + +def cache_539_A_part0 : List Cell := [(0, -3), (0, -2), (1, -3), (1, -2)] + +def cache_539_A : List Cell := cache_539_A_part0 + +def cache_539_H_part0 : List Cell := [(-5, -2), (-4, -4), (-4, -2), (-4, -1), (-4, 1), (-3, -4), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-2, -4), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-1, -4), (-1, -3)] + +def cache_539_H_part1 : List Cell := [(-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2)] + +def cache_539_H_part2 : List Cell := [(1, 3), (1, 4), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (5, -1), (5, 0), (5, 1), (6, -1)] + +def cache_539_H_part3 : List Cell := [(6, 1)] + +def cache_539_H : List Cell := ((cache_539_H_part0 ++ cache_539_H_part1) ++ (cache_539_H_part2 ++ cache_539_H_part3)) + +def cache_539 : ListRow := ⟨cache_539_A, cache_539_H, 18⟩ + +def cache_540_A_part0 : List Cell := [(0, -3), (0, -2), (1, -3), (1, -2)] + +def cache_540_A : List Cell := cache_540_A_part0 + +def cache_540_H_part0 : List Cell := [(-3, -3), (-3, 1), (-3, 3), (-2, -3), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-1, -4), (-1, -3), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3)] + +def cache_540_H_part1 : List Cell := [(0, 4), (0, 5), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (3, -2), (3, -1), (3, 0), (3, 1)] + +def cache_540_H_part2 : List Cell := [(3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (7, 1)] + +def cache_540_H : List Cell := (cache_540_H_part0 ++ (cache_540_H_part1 ++ cache_540_H_part2)) + +def cache_540 : ListRow := ⟨cache_540_A, cache_540_H, 18⟩ + +def cache_541_A_part0 : List Cell := [(-2, -2), (-1, -2), (0, -2), (0, -1)] + +def cache_541_A : List Cell := cache_541_A_part0 + +def cache_541_H_part0 : List Cell := [(-5, 0), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-1, -2), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5)] + +def cache_541_H_part1 : List Cell := [(0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -5), (1, -4), (1, -3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3)] + +def cache_541_H_part2 : List Cell := [(2, 4), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (4, 0), (4, 1), (4, 2), (5, 0), (5, 2)] + +def cache_541_H : List Cell := (cache_541_H_part0 ++ (cache_541_H_part1 ++ cache_541_H_part2)) + +def cache_541 : ListRow := ⟨cache_541_A, cache_541_H, 14⟩ + +def cache_542_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1), (1, -3)] + +def cache_542_A : List Cell := cache_542_A_part0 + +def cache_542_H_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -2), (-1, -1), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -4), (1, -3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3)] + +def cache_542_H_part1 : List Cell := [(1, 4), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2)] + +def cache_542_H_part2 : List Cell := [(4, 3), (4, 4), (4, 5), (4, 6), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (6, 1), (6, 2), (6, 3), (6, 4), (7, 1), (7, 2), (7, 3), (7, 4)] + +def cache_542_H : List Cell := (cache_542_H_part0 ++ (cache_542_H_part1 ++ cache_542_H_part2)) + +def cache_542 : ListRow := ⟨cache_542_A, cache_542_H, 17⟩ + +def cache_543_A_part0 : List Cell := [(-2, 0), (-2, 1), (-1, 0)] + +def cache_543_A : List Cell := cache_543_A_part0 + +def cache_543_H_part0 : List Cell := [(-6, 3), (-5, -1), (-5, 3), (-4, -1), (-4, 1), (-4, 2), (-4, 3), (-3, -2), (-3, -1), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5)] + +def cache_543_H_part1 : List Cell := [(-2, 6), (-1, -1), (-1, 0), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (2, -4), (2, -3), (2, -2)] + +def cache_543_H_part2 : List Cell := [(2, -1), (2, 0), (2, 1), (3, -2), (3, -1), (3, 1), (4, -2)] + +def cache_543_H : List Cell := (cache_543_H_part0 ++ (cache_543_H_part1 ++ cache_543_H_part2)) + +def cache_543 : ListRow := ⟨cache_543_A, cache_543_H, 11⟩ + +def cache_544_A_part0 : List Cell := [(1, -1), (1, 0), (2, -1), (2, 0)] + +def cache_544_A : List Cell := cache_544_A_part0 + +def cache_544_H_part0 : List Cell := [(-3, 1), (-2, 0), (-2, 1), (-1, 0), (-1, 1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (2, -1), (2, 0), (2, 1), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (4, -3), (4, -2), (4, -1), (4, 0)] + +def cache_544_H_part1 : List Cell := [(4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (5, -4), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4)] + +def cache_544_H_part2 : List Cell := [(6, 5), (7, -4), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (8, -2), (8, -1), (8, 0), (8, 1), (8, 2), (8, 3), (9, -2), (9, -1), (9, 0), (9, 1), (9, 2), (10, -2), (10, 0)] + +def cache_544_H_part3 : List Cell := [(10, 2)] + +def cache_544_H : List Cell := ((cache_544_H_part0 ++ cache_544_H_part1) ++ (cache_544_H_part2 ++ cache_544_H_part3)) + +def cache_544 : ListRow := ⟨cache_544_A, cache_544_H, 18⟩ + +def cache_545_A_part0 : List Cell := [(-1, -1), (0, -2), (0, -1), (1, -2), (1, -1)] + +def cache_545_A : List Cell := cache_545_A_part0 + +def cache_545_H_part0 : List Cell := [(-4, 1), (-4, 3), (-3, -1), (-3, 1), (-3, 2), (-3, 3), (-2, -1), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7)] + +def cache_545_H_part1 : List Cell := [(0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (2, -1), (2, 0), (2, 1), (2, 2)] + +def cache_545_H_part2 : List Cell := [(2, 3), (2, 4), (2, 5), (2, 6), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (5, 0), (5, 1), (5, 2), (5, 3)] + +def cache_545_H_part3 : List Cell := [(6, 1), (6, 3)] + +def cache_545_H : List Cell := ((cache_545_H_part0 ++ cache_545_H_part1) ++ (cache_545_H_part2 ++ cache_545_H_part3)) + +def cache_545 : ListRow := ⟨cache_545_A, cache_545_H, 20⟩ + +def cache_546_A_part0 : List Cell := [(1, 0), (2, 0), (3, -2), (3, 0)] + +def cache_546_A : List Cell := cache_546_A_part0 + +def cache_546_H_part0 : List Cell := [(-2, -1), (-1, -1), (-1, 0), (-1, 2), (-1, 3), (-1, 4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1)] + +def cache_546_H_part1 : List Cell := [(1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (2, -3), (2, -2), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (3, -2), (3, 0), (3, 1), (3, 2), (3, 3)] + +def cache_546_H_part2 : List Cell := [(3, 4), (3, 5), (3, 6), (3, 7), (4, -2), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (6, 2), (6, 3), (6, 4), (6, 5)] + +def cache_546_H_part3 : List Cell := [(6, 6), (6, 7), (7, 2), (7, 3), (7, 4), (8, 2), (8, 4)] + +def cache_546_H : List Cell := ((cache_546_H_part0 ++ cache_546_H_part1) ++ (cache_546_H_part2 ++ cache_546_H_part3)) + +def cache_546 : ListRow := ⟨cache_546_A, cache_546_H, 21⟩ + +def cache_547_A_part0 : List Cell := [(1, -1), (1, 0), (2, 0), (3, 0)] + +def cache_547_A : List Cell := cache_547_A_part0 + +def cache_547_H_part0 : List Cell := [(-3, -1), (-3, 1), (-3, 2), (-3, 3), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8)] + +def cache_547_H_part1 : List Cell := [(0, 9), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (3, 0), (3, 1)] + +def cache_547_H_part2 : List Cell := [(3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6)] + +def cache_547_H_part3 : List Cell := [(6, 7), (7, 2), (7, 3), (7, 4), (8, 2), (8, 4)] + +def cache_547_H : List Cell := ((cache_547_H_part0 ++ cache_547_H_part1) ++ (cache_547_H_part2 ++ cache_547_H_part3)) + +def cache_547 : ListRow := ⟨cache_547_A, cache_547_H, 21⟩ + +def cache_548_A_part0 : List Cell := [(-2, -1), (-1, -1), (0, -1)] + +def cache_548_A : List Cell := cache_548_A_part0 + +def cache_548_H_part0 : List Cell := [(-5, 0), (-5, 1), (-5, 2), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-1, -1)] + +def cache_548_H_part1 : List Cell := [(-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, -4), (1, -3), (1, -2), (1, 0), (1, 1), (1, 2), (1, 3)] + +def cache_548_H_part2 : List Cell := [(1, 4), (1, 5), (1, 6), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (4, 0), (4, 1), (4, 2), (4, 3), (5, 0), (5, 1), (5, 3)] + +def cache_548_H : List Cell := (cache_548_H_part0 ++ (cache_548_H_part1 ++ cache_548_H_part2)) + +def cache_548 : ListRow := ⟨cache_548_A, cache_548_H, 15⟩ + +def cache_549_A_part0 : List Cell := [(-2, -3), (-1, 0), (1, 0)] + +def cache_549_A : List Cell := cache_549_A_part0 + +def cache_549_H_part0 : List Cell := [(-5, 1), (-4, -4), (-4, -3), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-4, 4), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-2, -4), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1)] + +def cache_549_H_part1 : List Cell := [(-2, 2), (-2, 3), (-2, 4), (-2, 5), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (1, 0), (1, 1), (1, 2), (1, 3)] + +def cache_549_H_part2 : List Cell := [(1, 4), (1, 5), (1, 6), (1, 7), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (4, -1), (4, 0)] + +def cache_549_H_part3 : List Cell := [(4, 1), (4, 2), (4, 3), (4, 4), (5, 1), (5, 2), (5, 3), (5, 4)] + +def cache_549_H : List Cell := ((cache_549_H_part0 ++ cache_549_H_part1) ++ (cache_549_H_part2 ++ cache_549_H_part3)) + +def cache_549 : ListRow := ⟨cache_549_A, cache_549_H, 17⟩ + +def cache_550_A_part0 : List Cell := [(0, -1), (0, 1), (2, 1)] + +def cache_550_A : List Cell := cache_550_A_part0 + +def cache_550_H_part0 : List Cell := [(-5, 0), (-5, 1), (-5, 2), (-5, 3), (-4, -3), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3)] + +def cache_550_H_part1 : List Cell := [(-1, -4), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (-1, 2), (-1, 4), (-1, 5), (-1, 6), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1)] + +def cache_550_H_part2 : List Cell := [(1, 2), (1, 3), (1, 4), (1, 5), (2, 1), (2, 2), (3, 0), (3, 1), (3, 2), (4, 0), (4, 1), (4, 2), (4, 3), (5, 0), (5, 1), (5, 2), (5, 3), (6, 0), (6, 1), (6, 2), (6, 3), (7, 0), (7, 1), (7, 2)] + +def cache_550_H_part3 : List Cell := [(7, 3)] + +def cache_550_H : List Cell := ((cache_550_H_part0 ++ cache_550_H_part1) ++ (cache_550_H_part2 ++ cache_550_H_part3)) + +def cache_550 : ListRow := ⟨cache_550_A, cache_550_H, 13⟩ + +def cache_551_A_part0 : List Cell := [(0, 1), (0, 2)] + +def cache_551_A : List Cell := cache_551_A_part0 + +def cache_551_H_part0 : List Cell := [(-6, 3), (-5, 1), (-5, 2), (-5, 3), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-1, -3), (-1, -2), (-1, -1)] + +def cache_551_H_part1 : List Cell := [(-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, 0), (2, 1)] + +def cache_551_H_part2 : List Cell := [(2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (5, 1), (5, 2), (5, 4), (6, 4)] + +def cache_551_H : List Cell := (cache_551_H_part0 ++ (cache_551_H_part1 ++ cache_551_H_part2)) + +def cache_551 : ListRow := ⟨cache_551_A, cache_551_H, 14⟩ + +def cache_552_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0)] + +def cache_552_A : List Cell := cache_552_A_part0 + +def cache_552_H_part0 : List Cell := [(-8, 2), (-8, 4), (-7, 2), (-7, 3), (-7, 4), (-6, 2), (-6, 3), (-6, 4), (-6, 5), (-6, 6), (-6, 7), (-5, 2), (-5, 3), (-5, 4), (-5, 5), (-5, 6), (-5, 7), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7)] + +def cache_552_H_part1 : List Cell := [(-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-2, -5), (-2, -4), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-1, -5)] + +def cache_552_H_part2 : List Cell := [(-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (0, -5), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5)] + +def cache_552_H_part3 : List Cell := [(0, 6), (0, 7), (0, 8), (0, 9), (1, -5), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 2), (1, 3), (1, 4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (4, -3)] + +def cache_552_H_part4 : List Cell := [(4, -2), (4, -1), (4, 1), (5, -1)] + +def cache_552_H : List Cell := ((cache_552_H_part0 ++ cache_552_H_part1) ++ (cache_552_H_part2 ++ (cache_552_H_part3 ++ cache_552_H_part4))) + +def cache_552 : ListRow := ⟨cache_552_A, cache_552_H, 21⟩ + +def cache_553_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1)] + +def cache_553_A : List Cell := cache_553_A_part0 + +def cache_553_H_part0 : List Cell := [(-5, -2), (-5, -1), (-5, 0), (-5, 1), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-1, -2), (-1, -1)] + +def cache_553_H_part1 : List Cell := [(-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -4), (1, -3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -6), (2, -5)] + +def cache_553_H_part2 : List Cell := [(2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, -6), (3, -5), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6)] + +def cache_553_H_part3 : List Cell := [(4, -6), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (5, -4), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (6, -2), (6, -1)] + +def cache_553_H_part4 : List Cell := [(6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4)] + +def cache_553_H : List Cell := ((cache_553_H_part0 ++ cache_553_H_part1) ++ (cache_553_H_part2 ++ (cache_553_H_part3 ++ cache_553_H_part4))) + +def cache_553 : ListRow := ⟨cache_553_A, cache_553_H, 17⟩ + +def cache_554_A_part0 : List Cell := [(0, -2), (0, -1), (1, -1), (1, 1), (2, 1), (3, 1)] + +def cache_554_A : List Cell := cache_554_A_part0 + +def cache_554_H_part0 : List Cell := [(-3, 3), (-3, 5), (-2, 0), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5)] + +def cache_554_H_part1 : List Cell := [(0, 6), (0, 7), (0, 8), (1, -1), (1, 0), (1, 1), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (3, 1), (3, 2), (3, 3)] + +def cache_554_H_part2 : List Cell := [(3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (4, 0), (4, 1), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7)] + +def cache_554_H_part3 : List Cell := [(5, 8), (5, 9), (5, 10), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (7, 2), (7, 3), (7, 5)] + +def cache_554_H : List Cell := ((cache_554_H_part0 ++ cache_554_H_part1) ++ (cache_554_H_part2 ++ cache_554_H_part3)) + +def cache_554 : ListRow := ⟨cache_554_A, cache_554_H, 22⟩ + +def cache_555_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0)] + +def cache_555_A : List Cell := cache_555_A_part0 + +def cache_555_H_part0 : List Cell := [(-8, 2), (-8, 4), (-7, 2), (-7, 3), (-7, 4), (-6, 2), (-6, 3), (-6, 4), (-6, 5), (-6, 6), (-6, 7), (-5, 2), (-5, 3), (-5, 4), (-5, 5), (-5, 6), (-5, 7), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7)] + +def cache_555_H_part1 : List Cell := [(-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-2, -5), (-2, -4), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-1, -5)] + +def cache_555_H_part2 : List Cell := [(-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (0, -5), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5)] + +def cache_555_H_part3 : List Cell := [(0, 6), (0, 7), (0, 8), (0, 9), (1, -4), (1, -3), (1, -2), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (3, -1), (3, 0), (3, 1)] + +def cache_555_H_part4 : List Cell := [(3, 2), (3, 3), (3, 4), (4, -1), (4, 1), (4, 2), (4, 3), (5, 1)] + +def cache_555_H : List Cell := ((cache_555_H_part0 ++ cache_555_H_part1) ++ (cache_555_H_part2 ++ (cache_555_H_part3 ++ cache_555_H_part4))) + +def cache_555 : ListRow := ⟨cache_555_A, cache_555_H, 21⟩ + +def cache_556_A_part0 : List Cell := [(-3, -3), (-2, -3), (-2, 0), (-1, -4), (-1, -3), (0, -3)] + +def cache_556_A : List Cell := cache_556_A_part0 + +def cache_556_H_part0 : List Cell := [(-6, 1), (-5, -4), (-5, -3), (-5, -2), (-5, -1), (-5, 0), (-5, 1), (-5, 4), (-4, -3), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-3, -4), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1)] + +def cache_556_H_part1 : List Cell := [(-3, 2), (-3, 3), (-3, 4), (-3, 5), (-2, -3), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-1, -4), (-1, -3), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (0, -3)] + +def cache_556_H_part2 : List Cell := [(0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (2, -1), (2, 0), (2, 1), (2, 2)] + +def cache_556_H_part3 : List Cell := [(2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, 1), (4, 2), (4, 3), (4, 4)] + +def cache_556_H : List Cell := ((cache_556_H_part0 ++ cache_556_H_part1) ++ (cache_556_H_part2 ++ cache_556_H_part3)) + +def cache_556 : ListRow := ⟨cache_556_A, cache_556_H, 18⟩ + +def cache_557_A_part0 : List Cell := [(-1, 0)] + +def cache_557_A : List Cell := cache_557_A_part0 + +def cache_557_H_part0 : List Cell := [(-6, -1), (-6, 0), (-6, 1), (-6, 3), (-6, 4), (-5, -1), (-5, 0), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3)] + +def cache_557_H_part1 : List Cell := [(-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8), (-2, -5), (-2, -4), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-1, -5), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0)] + +def cache_557_H_part2 : List Cell := [(-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (0, -5), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (1, -5), (1, -4)] + +def cache_557_H_part3 : List Cell := [(1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8)] + +def cache_557_H_part4 : List Cell := [(3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (5, -1), (5, 0), (5, 1), (5, 3), (5, 4)] + +def cache_557_H : List Cell := ((cache_557_H_part0 ++ cache_557_H_part1) ++ (cache_557_H_part2 ++ (cache_557_H_part3 ++ cache_557_H_part4))) + +def cache_557 : ListRow := ⟨cache_557_A, cache_557_H, 19⟩ + +def cache_558_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0)] + +def cache_558_A : List Cell := cache_558_A_part0 + +def cache_558_H_part0 : List Cell := [(-8, 2), (-8, 4), (-7, 2), (-7, 3), (-7, 4), (-6, 2), (-6, 3), (-6, 4), (-6, 5), (-6, 6), (-6, 7), (-5, 2), (-5, 3), (-5, 4), (-5, 5), (-5, 6), (-5, 7), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7)] + +def cache_558_H_part1 : List Cell := [(-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1)] + +def cache_558_H_part2 : List Cell := [(-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5)] + +def cache_558_H_part3 : List Cell := [(1, 6), (1, 7), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (4, -1), (4, 0), (4, 1), (4, 2)] + +def cache_558_H_part4 : List Cell := [(4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (5, -1), (5, 2), (5, 3), (5, 4), (6, 2), (6, 3), (6, 4)] + +def cache_558_H : List Cell := ((cache_558_H_part0 ++ cache_558_H_part1) ++ (cache_558_H_part2 ++ (cache_558_H_part3 ++ cache_558_H_part4))) + +def cache_558 : ListRow := ⟨cache_558_A, cache_558_H, 21⟩ + +def cache_559_A_part0 : List Cell := [(0, -4), (0, -3), (0, -2), (0, -1)] + +def cache_559_A : List Cell := cache_559_A_part0 + +def cache_559_H_part0 : List Cell := [(-3, -1), (-2, -1), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -3), (1, -2), (1, -1), (1, 1), (1, 2), (1, 3), (2, -5), (2, -4), (2, -3)] + +def cache_559_H_part1 : List Cell := [(2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (3, -5), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (4, -6), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (5, -6), (5, -5)] + +def cache_559_H_part2 : List Cell := [(5, -4), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (6, -6), (6, -5), (6, -4), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (7, -6), (7, -5), (7, -4), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1)] + +def cache_559_H_part3 : List Cell := [(7, 2), (7, 3), (8, -4), (8, -3), (8, -2), (8, -1), (8, 0), (8, 2), (9, -4), (9, -3), (9, -2), (9, -1), (10, -4), (10, -3), (10, -2), (10, -1)] + +def cache_559_H : List Cell := ((cache_559_H_part0 ++ cache_559_H_part1) ++ (cache_559_H_part2 ++ cache_559_H_part3)) + +def cache_559 : ListRow := ⟨cache_559_A, cache_559_H, 23⟩ + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/CacheData14.lean b/lean/OAI/Combinatorics/SnakyCertificate/CacheData14.lean new file mode 100644 index 0000000000000000000000000000000000000000..c241a5fa549f8f3a82f1f9c8043f983e6a0e7d28 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/CacheData14.lean @@ -0,0 +1,891 @@ +import OAI.Combinatorics.SnakyCertificate.Lists + +namespace OAI + +namespace SnakyCertificate.Check + +def cache_560_A_part0 : List Cell := [(-2, -1), (-2, 0), (-2, 1), (0, 1)] + +def cache_560_A : List Cell := cache_560_A_part0 + +def cache_560_H_part0 : List Cell := [(-7, 1), (-6, 0), (-6, 1), (-5, 0), (-5, 1), (-4, 0), (-4, 1), (-3, 0), (-3, 1), (-2, -1), (-2, 0), (-2, 1), (-2, 3), (-1, -5), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6)] + +def cache_560_H_part1 : List Cell := [(-1, 7), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (1, -5), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6)] + +def cache_560_H_part2 : List Cell := [(1, 7), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (4, -3), (4, -2)] + +def cache_560_H_part3 : List Cell := [(4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (7, -1)] + +def cache_560_H_part4 : List Cell := [(7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (8, -1), (8, 0), (8, 1), (9, -1), (9, 1)] + +def cache_560_H : List Cell := ((cache_560_H_part0 ++ cache_560_H_part1) ++ (cache_560_H_part2 ++ (cache_560_H_part3 ++ cache_560_H_part4))) + +def cache_560 : ListRow := ⟨cache_560_A, cache_560_H, 23⟩ + +def cache_561_A_part0 : List Cell := [(-2, -2), (-2, 0), (-1, 0)] + +def cache_561_A : List Cell := cache_561_A_part0 + +def cache_561_H_part0 : List Cell := [(-7, 2), (-7, 4), (-6, -1), (-6, 0), (-6, 1), (-6, 2), (-6, 3), (-6, 4), (-5, -1), (-5, 0), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-5, 5), (-5, 6), (-5, 7), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5)] + +def cache_561_H_part1 : List Cell := [(-4, 6), (-4, 7), (-3, -2), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-2, -2), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-1, -3), (-1, -2), (-1, 0), (-1, 1)] + +def cache_561_H_part2 : List Cell := [(-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (1, -3), (1, -2), (1, -1)] + +def cache_561_H_part3 : List Cell := [(1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, -1), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5)] + +def cache_561_H_part4 : List Cell := [(3, 6), (3, 7), (4, 1), (4, 2), (4, 3), (4, 4), (5, 1), (5, 2), (5, 4)] + +def cache_561_H : List Cell := ((cache_561_H_part0 ++ cache_561_H_part1) ++ (cache_561_H_part2 ++ (cache_561_H_part3 ++ cache_561_H_part4))) + +def cache_561 : ListRow := ⟨cache_561_A, cache_561_H, 22⟩ + +def cache_562_A_part0 : List Cell := [(-1, -3), (0, -3), (0, -2), (0, -1)] + +def cache_562_A : List Cell := cache_562_A_part0 + +def cache_562_H_part0 : List Cell := [(-3, 0), (-2, 0), (-1, -4), (-1, -3), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -2), (1, -1), (1, 0), (1, 2), (1, 3), (1, 4), (2, -4)] + +def cache_562_H_part1 : List Cell := [(2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3)] + +def cache_562_H_part2 : List Cell := [(5, -5), (5, -4), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (6, -5), (6, -4), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (7, -5), (7, -4), (7, -3), (7, -2), (7, -1), (7, 0)] + +def cache_562_H_part3 : List Cell := [(7, 1), (7, 2), (7, 3), (7, 4), (8, -3), (8, -2), (8, -1), (8, 0), (8, 1), (8, 3), (9, -3), (9, -2), (9, -1), (9, 0), (10, -3), (10, -2), (10, -1), (10, 0)] + +def cache_562_H : List Cell := ((cache_562_H_part0 ++ cache_562_H_part1) ++ (cache_562_H_part2 ++ cache_562_H_part3)) + +def cache_562 : ListRow := ⟨cache_562_A, cache_562_H, 24⟩ + +def cache_563_A_part0 : List Cell := [(1, -1), (1, 0), (2, -1), (2, 0)] + +def cache_563_A : List Cell := cache_563_A_part0 + +def cache_563_H_part0 : List Cell := [(-5, 2), (-5, 4), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7)] + +def cache_563_H_part1 : List Cell := [(-2, 8), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (1, -1), (1, 0), (1, 1)] + +def cache_563_H_part2 : List Cell := [(1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (3, 0), (3, 1), (3, 2)] + +def cache_563_H_part3 : List Cell := [(3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (4, 10), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3)] + +def cache_563_H_part4 : List Cell := [(5, 4), (5, 5), (5, 6), (5, 7), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (7, 2), (7, 4)] + +def cache_563_H : List Cell := ((cache_563_H_part0 ++ cache_563_H_part1) ++ (cache_563_H_part2 ++ (cache_563_H_part3 ++ cache_563_H_part4))) + +def cache_563 : ListRow := ⟨cache_563_A, cache_563_H, 23⟩ + +def cache_564_A_part0 : List Cell := [(-2, -2), (-2, -1), (-2, 0)] + +def cache_564_A : List Cell := cache_564_A_part0 + +def cache_564_H_part0 : List Cell := [(-7, -1), (-7, 0), (-7, 1), (-6, -1), (-6, 0), (-6, 1), (-5, -1), (-5, 0), (-5, 1), (-4, -1), (-4, 0), (-4, 1), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-2, -2), (-2, -1), (-2, 0), (-2, 2), (-1, -6), (-1, -5), (-1, -4)] + +def cache_564_H_part1 : List Cell := [(-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (0, -5), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (1, -6), (1, -5), (1, -4)] + +def cache_564_H_part2 : List Cell := [(1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, -4), (3, -3), (3, -2)] + +def cache_564_H_part3 : List Cell := [(3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3)] + +def cache_564_H_part4 : List Cell := [(5, 4), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (8, -2), (8, -1), (8, 0), (9, -2), (9, 0)] + +def cache_564_H : List Cell := ((cache_564_H_part0 ++ cache_564_H_part1) ++ (cache_564_H_part2 ++ (cache_564_H_part3 ++ cache_564_H_part4))) + +def cache_564 : ListRow := ⟨cache_564_A, cache_564_H, 24⟩ + +def cache_565_A_part0 : List Cell := [(1, -1), (1, 0), (2, 0), (3, 0)] + +def cache_565_A : List Cell := cache_565_A_part0 + +def cache_565_H_part0 : List Cell := [(-5, 2), (-5, 4), (-4, 2), (-4, 3), (-4, 4), (-3, -1), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-1, -1)] + +def cache_565_H_part1 : List Cell := [(-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3)] + +def cache_565_H_part2 : List Cell := [(1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4)] + +def cache_565_H_part3 : List Cell := [(3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (4, -1), (4, 0), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (4, 10), (5, -1), (5, 0), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6)] + +def cache_565_H_part4 : List Cell := [(5, 7), (6, -1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (7, 2), (7, 4)] + +def cache_565_H : List Cell := ((cache_565_H_part0 ++ cache_565_H_part1) ++ (cache_565_H_part2 ++ (cache_565_H_part3 ++ cache_565_H_part4))) + +def cache_565 : ListRow := ⟨cache_565_A, cache_565_H, 23⟩ + +def cache_566_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1), (1, -3)] + +def cache_566_A : List Cell := cache_566_A_part0 + +def cache_566_H_part0 : List Cell := [(-5, -2), (-5, -1), (-5, 0), (-5, 1), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-1, -2), (-1, -1)] + +def cache_566_H_part1 : List Cell := [(-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -6), (2, -5), (2, -4)] + +def cache_566_H_part2 : List Cell := [(2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, -6), (3, -5), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (4, -6)] + +def cache_566_H_part3 : List Cell := [(4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (5, -4), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (6, -2), (6, -1), (6, 0)] + +def cache_566_H_part4 : List Cell := [(6, 1), (6, 2), (6, 3), (6, 4), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4)] + +def cache_566_H : List Cell := ((cache_566_H_part0 ++ cache_566_H_part1) ++ (cache_566_H_part2 ++ (cache_566_H_part3 ++ cache_566_H_part4))) + +def cache_566 : ListRow := ⟨cache_566_A, cache_566_H, 17⟩ + +def cache_567_A_part0 : List Cell := [(-1, -4), (0, -4), (0, -3), (0, -2), (1, 0)] + +def cache_567_A : List Cell := cache_567_A_part0 + +def cache_567_H_part0 : List Cell := [(-5, -4), (-5, -2), (-5, 2), (-5, 4), (-4, -4), (-4, -3), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-3, -4), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6)] + +def cache_567_H_part1 : List Cell := [(-3, 7), (-2, -4), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-1, -4), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7)] + +def cache_567_H_part2 : List Cell := [(0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (1, -3), (1, -2), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9)] + +def cache_567_H_part3 : List Cell := [(2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7)] + +def cache_567_H_part4 : List Cell := [(3, 8), (3, 9), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (5, -1), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (6, 1), (6, 2), (6, 3), (6, 4), (7, 1), (7, 2)] + +def cache_567_H_part5 : List Cell := [(7, 4)] + +def cache_567_H : List Cell := ((cache_567_H_part0 ++ (cache_567_H_part1 ++ cache_567_H_part2)) ++ (cache_567_H_part3 ++ (cache_567_H_part4 ++ cache_567_H_part5))) + +def cache_567 : ListRow := ⟨cache_567_A, cache_567_H, 23⟩ + +def cache_568_A_part0 : List Cell := [(-1, -1), (-1, 0), (1, 0)] + +def cache_568_A : List Cell := cache_568_A_part0 + +def cache_568_H_part0 : List Cell := [(-7, 2), (-7, 4), (-6, 2), (-6, 3), (-6, 4), (-5, -1), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-5, 5), (-5, 6), (-5, 7), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7), (-4, 8), (-3, -1)] + +def cache_568_H_part1 : List Cell := [(-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8), (-3, 9), (-3, 10), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-1, -1), (-1, 0)] + +def cache_568_H_part2 : List Cell := [(-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (-1, 10), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (1, 0), (1, 1)] + +def cache_568_H_part3 : List Cell := [(1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (3, -1), (3, 0), (3, 1)] + +def cache_568_H_part4 : List Cell := [(3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (5, 1), (5, 2), (5, 3), (5, 4), (6, 2), (6, 4)] + +def cache_568_H : List Cell := ((cache_568_H_part0 ++ cache_568_H_part1) ++ (cache_568_H_part2 ++ (cache_568_H_part3 ++ cache_568_H_part4))) + +def cache_568 : ListRow := ⟨cache_568_A, cache_568_H, 24⟩ + +def cache_569_A_part0 : List Cell := [(0, -3), (1, -4), (1, -3), (2, -3), (2, -1), (2, 0), (3, -3)] + +def cache_569_A : List Cell := cache_569_A_part0 + +def cache_569_H_part0 : List Cell := [(-5, 2), (-5, 4), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7)] + +def cache_569_H_part1 : List Cell := [(-2, 8), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (-1, 10), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6)] + +def cache_569_H_part2 : List Cell := [(0, 7), (0, 8), (0, 9), (0, 10), (1, -4), (1, -3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10), (2, -3), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3)] + +def cache_569_H_part3 : List Cell := [(2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (3, -3), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3)] + +def cache_569_H_part4 : List Cell := [(4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (4, 10), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8), (6, -1), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6)] + +def cache_569_H_part5 : List Cell := [(6, 7), (7, 2), (7, 3), (7, 4), (8, 2), (8, 4)] + +def cache_569_H : List Cell := ((cache_569_H_part0 ++ (cache_569_H_part1 ++ cache_569_H_part2)) ++ (cache_569_H_part3 ++ (cache_569_H_part4 ++ cache_569_H_part5))) + +def cache_569 : ListRow := ⟨cache_569_A, cache_569_H, 25⟩ + +def cache_570_A_part0 : List Cell := [(-2, -2), (-1, -3), (-1, -2), (0, -2), (0, 1), (1, -2)] + +def cache_570_A : List Cell := cache_570_A_part0 + +def cache_570_H_part0 : List Cell := [(-7, 3), (-7, 5), (-6, 2), (-6, 3), (-6, 4), (-6, 5), (-5, 0), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-5, 5), (-5, 6), (-5, 7), (-5, 8), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7), (-4, 8)] + +def cache_570_H_part1 : List Cell := [(-4, 9), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8), (-3, 9), (-3, 10), (-3, 11), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7)] + +def cache_570_H_part2 : List Cell := [(-2, 8), (-2, 9), (-2, 10), (-2, 11), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (-1, 10), (-1, 11), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3)] + +def cache_570_H_part3 : List Cell := [(0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (0, 11), (1, -2), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10), (1, 11), (2, 0), (2, 1), (2, 2), (2, 3)] + +def cache_570_H_part4 : List Cell := [(2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (2, 11), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (4, 0), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6)] + +def cache_570_H_part5 : List Cell := [(4, 7), (4, 8), (5, 3), (5, 4), (5, 5), (6, 3), (6, 5)] + +def cache_570_H : List Cell := ((cache_570_H_part0 ++ (cache_570_H_part1 ++ cache_570_H_part2)) ++ (cache_570_H_part3 ++ (cache_570_H_part4 ++ cache_570_H_part5))) + +def cache_570 : ListRow := ⟨cache_570_A, cache_570_H, 26⟩ + +def cache_571_A_part0 : List Cell := [(-2, -3), (-1, -4), (-1, -3), (0, -3), (1, -3)] + +def cache_571_A : List Cell := cache_571_A_part0 + +def cache_571_H_part0 : List Cell := [(-7, 2), (-7, 4), (-6, 1), (-6, 2), (-6, 3), (-6, 4), (-5, -1), (-5, 0), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-5, 5), (-5, 6), (-5, 7), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7)] + +def cache_571_H_part1 : List Cell := [(-4, 8), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8), (-3, 9), (-3, 10), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6)] + +def cache_571_H_part2 : List Cell := [(-2, 7), (-2, 8), (-2, 9), (-2, 10), (-1, -4), (-1, -3), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (-1, 10), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2)] + +def cache_571_H_part3 : List Cell := [(0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10), (2, -3)] + +def cache_571_H_part4 : List Cell := [(2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6)] + +def cache_571_H_part5 : List Cell := [(3, 7), (3, 8), (4, -2), (4, -1), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (5, 2), (5, 3), (5, 4), (6, 2), (6, 4)] + +def cache_571_H : List Cell := ((cache_571_H_part0 ++ (cache_571_H_part1 ++ cache_571_H_part2)) ++ (cache_571_H_part3 ++ (cache_571_H_part4 ++ cache_571_H_part5))) + +def cache_571 : ListRow := ⟨cache_571_A, cache_571_H, 27⟩ + +def cache_572_A_part0 : List Cell := [(1, 0), (2, 0)] + +def cache_572_A : List Cell := cache_572_A_part0 + +def cache_572_H_part0 : List Cell := [(-4, 1), (-4, 2), (-4, 3), (-3, -1), (-3, 1), (-3, 2), (-3, 3), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5)] + +def cache_572_H_part1 : List Cell := [(-1, 6), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (0, 11), (1, -5), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5)] + +def cache_572_H_part2 : List Cell := [(1, 6), (1, 7), (1, 8), (1, 9), (1, 10), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (2, 11), (3, -5), (3, -4)] + +def cache_572_H_part3 : List Cell := [(3, -3), (3, -2), (3, -1), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (5, -1)] + +def cache_572_H_part4 : List Cell := [(5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8), (5, 9), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (6, 8), (6, 9), (7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (7, 6)] + +def cache_572_H_part5 : List Cell := [(8, 1), (8, 3), (8, 4), (8, 6)] + +def cache_572_H : List Cell := ((cache_572_H_part0 ++ (cache_572_H_part1 ++ cache_572_H_part2)) ++ (cache_572_H_part3 ++ (cache_572_H_part4 ++ cache_572_H_part5))) + +def cache_572 : ListRow := ⟨cache_572_A, cache_572_H, 25⟩ + +def cache_573_A_part0 : List Cell := [(0, -2), (0, -1)] + +def cache_573_A : List Cell := cache_573_A_part0 + +def cache_573_H_part0 : List Cell := [(-8, -3), (-8, -1), (-7, -3), (-7, -2), (-7, -1), (-7, 0), (-7, 1), (-6, -4), (-6, -3), (-6, -2), (-6, -1), (-6, 0), (-6, 1), (-6, 2), (-6, 3), (-5, -4), (-5, -3), (-5, -2), (-5, -1), (-5, 0), (-5, 1), (-5, 2), (-5, 3), (-4, -6)] + +def cache_573_H_part1 : List Cell := [(-4, -5), (-4, -4), (-4, -3), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-3, -7), (-3, -6), (-3, -5), (-3, -4), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5)] + +def cache_573_H_part2 : List Cell := [(-2, -6), (-2, -5), (-2, -4), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-1, -7), (-1, -6), (-1, -5), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5)] + +def cache_573_H_part3 : List Cell := [(0, -3), (0, -2), (0, -1), (0, 0), (0, 2), (1, -7), (1, -6), (1, -5), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, -6), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1)] + +def cache_573_H_part4 : List Cell := [(2, 2), (2, 3), (3, -7), (3, -6), (3, -5), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -6), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (5, -4), (5, -3)] + +def cache_573_H_part5 : List Cell := [(5, -2), (5, -1), (5, 0), (5, 1), (6, -4), (6, -3), (6, -1), (6, 0), (6, 1), (7, 1)] + +def cache_573_H : List Cell := ((cache_573_H_part0 ++ (cache_573_H_part1 ++ cache_573_H_part2)) ++ (cache_573_H_part3 ++ (cache_573_H_part4 ++ cache_573_H_part5))) + +def cache_573 : ListRow := ⟨cache_573_A, cache_573_H, 19⟩ + +def cache_574_A_part0 : List Cell := [(-1, -1), (-1, 0), (0, -1)] + +def cache_574_A : List Cell := cache_574_A_part0 + +def cache_574_H_part0 : List Cell := [(-7, 2), (-7, 3), (-7, 4), (-6, 1), (-6, 2), (-6, 3), (-6, 4), (-6, 5), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-5, 5), (-5, 6), (-5, 7), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7)] + +def cache_574_H_part1 : List Cell := [(-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8), (-3, 9), (-3, 10), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-1, -1), (-1, 0)] + +def cache_574_H_part2 : List Cell := [(-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (-1, 10), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (1, -2), (1, -1)] + +def cache_574_H_part3 : List Cell := [(1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (3, -4)] + +def cache_574_H_part4 : List Cell := [(3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (5, -4)] + +def cache_574_H_part5 : List Cell := [(5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (8, -2), (8, 0), (8, 2)] + +def cache_574_H : List Cell := ((cache_574_H_part0 ++ (cache_574_H_part1 ++ cache_574_H_part2)) ++ (cache_574_H_part3 ++ (cache_574_H_part4 ++ cache_574_H_part5))) + +def cache_574 : ListRow := ⟨cache_574_A, cache_574_H, 24⟩ + +def cache_575_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1)] + +def cache_575_A : List Cell := cache_575_A_part0 + +def cache_575_H_part0 : List Cell := [(-7, 1), (-7, 2), (-7, 3), (-7, 4), (-6, 1), (-6, 2), (-6, 3), (-6, 4), (-5, -1), (-5, 0), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-4, -3), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6)] + +def cache_575_H_part1 : List Cell := [(-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4)] + +def cache_575_H_part2 : List Cell := [(0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3)] + +def cache_575_H_part3 : List Cell := [(2, 4), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (5, -5), (5, -4), (5, -3), (5, -2), (5, -1)] + +def cache_575_H_part4 : List Cell := [(5, 0), (5, 1), (5, 2), (5, 3), (6, -5), (6, -4), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (7, -5), (7, -4), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (8, -3)] + +def cache_575_H_part5 : List Cell := [(8, -2), (8, -1), (8, 0), (8, 1), (8, 3), (9, -3), (9, -2), (9, -1), (9, 0), (10, -3), (10, -2), (10, -1), (10, 0)] + +def cache_575_H : List Cell := ((cache_575_H_part0 ++ (cache_575_H_part1 ++ cache_575_H_part2)) ++ (cache_575_H_part3 ++ (cache_575_H_part4 ++ cache_575_H_part5))) + +def cache_575 : ListRow := ⟨cache_575_A, cache_575_H, 24⟩ + +def cache_576_A_part0 : List Cell := [(-1, -1), (-1, 0), (0, -1)] + +def cache_576_A : List Cell := cache_576_A_part0 + +def cache_576_H_part0 : List Cell := [(-9, -2), (-9, 0), (-9, 2), (-8, -2), (-8, -1), (-8, 0), (-8, 1), (-8, 2), (-7, -2), (-7, -1), (-7, 0), (-7, 1), (-7, 2), (-7, 3), (-7, 4), (-6, -4), (-6, -3), (-6, -2), (-6, -1), (-6, 0), (-6, 1), (-6, 2), (-6, 3), (-6, 4)] + +def cache_576_H_part1 : List Cell := [(-6, 5), (-5, -3), (-5, -2), (-5, -1), (-5, 0), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-5, 5), (-5, 6), (-5, 7), (-4, -4), (-4, -3), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7)] + +def cache_576_H_part2 : List Cell := [(-4, 8), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8), (-3, 9), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7)] + +def cache_576_H_part3 : List Cell := [(-2, 8), (-2, 9), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (-1, 10), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8)] + +def cache_576_H_part4 : List Cell := [(0, 9), (0, 10), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10)] + +def cache_576_H_part5 : List Cell := [(3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (6, 2), (6, 3), (6, 4)] + +def cache_576_H : List Cell := ((cache_576_H_part0 ++ (cache_576_H_part1 ++ cache_576_H_part2)) ++ (cache_576_H_part3 ++ (cache_576_H_part4 ++ cache_576_H_part5))) + +def cache_576 : ListRow := ⟨cache_576_A, cache_576_H, 24⟩ + +def cache_577_A_part0 : List Cell := [(0, -3), (0, -2), (0, -1)] + +def cache_577_A : List Cell := cache_577_A_part0 + +def cache_577_H_part0 : List Cell := [(-9, -2), (-9, 0), (-8, -2), (-8, -1), (-8, 0), (-7, -6), (-7, -5), (-7, -4), (-7, -3), (-7, -2), (-7, -1), (-7, 0), (-6, -6), (-6, -5), (-6, -4), (-6, -3), (-6, -2), (-6, -1), (-6, 0), (-5, -6), (-5, -5), (-5, -4), (-5, -3), (-5, -2)] + +def cache_577_H_part1 : List Cell := [(-5, -1), (-5, 0), (-4, -8), (-4, -7), (-4, -6), (-4, -5), (-4, -4), (-4, -3), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-3, -7), (-3, -6), (-3, -5), (-3, -4), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-2, -8), (-2, -7), (-2, -6)] + +def cache_577_H_part2 : List Cell := [(-2, -5), (-2, -4), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-1, -5), (-1, -4), (-1, -3), (-1, -2), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1), (1, 2), (2, -4), (2, -3), (2, -2)] + +def cache_577_H_part3 : List Cell := [(2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3)] + +def cache_577_H_part4 : List Cell := [(4, 4), (4, 5), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (8, -3)] + +def cache_577_H_part5 : List Cell := [(8, -2), (8, -1), (9, -3), (9, -1)] + +def cache_577_H : List Cell := ((cache_577_H_part0 ++ (cache_577_H_part1 ++ cache_577_H_part2)) ++ (cache_577_H_part3 ++ (cache_577_H_part4 ++ cache_577_H_part5))) + +def cache_577 : ListRow := ⟨cache_577_A, cache_577_H, 21⟩ + +def cache_578_A_part0 : List Cell := [(0, -3), (0, -2), (1, 0), (1, 1)] + +def cache_578_A : List Cell := cache_578_A_part0 + +def cache_578_H_part0 : List Cell := [(-8, -1), (-8, 1), (-8, 3), (-7, -1), (-7, 0), (-7, 1), (-7, 2), (-7, 3), (-6, -1), (-6, 0), (-6, 1), (-6, 2), (-6, 3), (-6, 4), (-6, 5), (-5, -3), (-5, -2), (-5, -1), (-5, 0), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-5, 5)] + +def cache_578_H_part1 : List Cell := [(-5, 6), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7), (-4, 8), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8)] + +def cache_578_H_part2 : List Cell := [(-3, 9), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8)] + +def cache_578_H_part3 : List Cell := [(-1, 9), (-1, 10), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (0, 11), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6)] + +def cache_578_H_part4 : List Cell := [(1, 7), (1, 8), (1, 9), (1, 10), (1, 11), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (2, 11), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8)] + +def cache_578_H_part5 : List Cell := [(3, 9), (3, 10), (3, 11), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6)] + +def cache_578_H_part6 : List Cell := [(7, 3), (7, 4), (7, 5)] + +def cache_578_H : List Cell := ((cache_578_H_part0 ++ (cache_578_H_part1 ++ cache_578_H_part2)) ++ ((cache_578_H_part3 ++ cache_578_H_part4) ++ (cache_578_H_part5 ++ cache_578_H_part6))) + +def cache_578 : ListRow := ⟨cache_578_A, cache_578_H, 25⟩ + +def cache_579_A_part0 : List Cell := [(0, -3), (0, -2), (1, 0), (1, 1)] + +def cache_579_A : List Cell := cache_579_A_part0 + +def cache_579_H_part0 : List Cell := [(-6, 3), (-6, 4), (-6, 5), (-5, 2), (-5, 3), (-5, 4), (-5, 5), (-5, 6), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7), (-4, 8), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8)] + +def cache_579_H_part1 : List Cell := [(-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-2, 11), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (-1, 10), (-1, 11), (0, -3), (0, -2)] + +def cache_579_H_part2 : List Cell := [(0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (0, 11), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10)] + +def cache_579_H_part3 : List Cell := [(1, 11), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8)] + +def cache_579_H_part4 : List Cell := [(3, 9), (3, 10), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6)] + +def cache_579_H_part5 : List Cell := [(5, 7), (5, 8), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (8, -1), (8, 0), (8, 1), (8, 2), (8, 3)] + +def cache_579_H_part6 : List Cell := [(9, -1), (9, 1), (9, 3)] + +def cache_579_H : List Cell := ((cache_579_H_part0 ++ (cache_579_H_part1 ++ cache_579_H_part2)) ++ ((cache_579_H_part3 ++ cache_579_H_part4) ++ (cache_579_H_part5 ++ cache_579_H_part6))) + +def cache_579 : ListRow := ⟨cache_579_A, cache_579_H, 25⟩ + +def cache_580_A_part0 : List Cell := [(-1, -4), (-1, -3), (0, -3), (0, -1)] + +def cache_580_A : List Cell := cache_580_A_part0 + +def cache_580_H_part0 : List Cell := [(-7, 2), (-7, 3), (-7, 4), (-6, 1), (-6, 2), (-6, 3), (-6, 4), (-6, 5), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-5, 5), (-5, 6), (-5, 7), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7)] + +def cache_580_H_part1 : List Cell := [(-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8), (-3, 9), (-3, 10), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-1, -4), (-1, -3)] + +def cache_580_H_part2 : List Cell := [(-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (-1, 10), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7)] + +def cache_580_H_part3 : List Cell := [(0, 8), (0, 9), (0, 10), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5)] + +def cache_580_H_part4 : List Cell := [(2, 6), (2, 7), (2, 8), (2, 9), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3)] + +def cache_580_H_part5 : List Cell := [(4, 4), (4, 5), (4, 6), (4, 7), (5, -4), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (7, -2), (7, -1), (7, 0)] + +def cache_580_H_part6 : List Cell := [(7, 1), (7, 2), (8, -2), (8, 0), (8, 2)] + +def cache_580_H : List Cell := ((cache_580_H_part0 ++ (cache_580_H_part1 ++ cache_580_H_part2)) ++ ((cache_580_H_part3 ++ cache_580_H_part4) ++ (cache_580_H_part5 ++ cache_580_H_part6))) + +def cache_580 : ListRow := ⟨cache_580_A, cache_580_H, 26⟩ + +def cache_581_A_part0 : List Cell := [(0, -3), (0, -1), (1, -4), (1, -3)] + +def cache_581_A : List Cell := cache_581_A_part0 + +def cache_581_H_part0 : List Cell := [(-6, 2), (-6, 3), (-6, 4), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-5, 5), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7)] + +def cache_581_H_part1 : List Cell := [(-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (-1, 10), (0, -3), (0, -2)] + +def cache_581_H_part2 : List Cell := [(0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7)] + +def cache_581_H_part3 : List Cell := [(1, 8), (1, 9), (1, 10), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5)] + +def cache_581_H_part4 : List Cell := [(3, 6), (3, 7), (3, 8), (3, 9), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3)] + +def cache_581_H_part5 : List Cell := [(5, 4), (5, 5), (5, 6), (5, 7), (6, -4), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (8, -2), (8, -1), (8, 0)] + +def cache_581_H_part6 : List Cell := [(8, 1), (8, 2), (9, -2), (9, 0), (9, 2)] + +def cache_581_H : List Cell := ((cache_581_H_part0 ++ (cache_581_H_part1 ++ cache_581_H_part2)) ++ ((cache_581_H_part3 ++ cache_581_H_part4) ++ (cache_581_H_part5 ++ cache_581_H_part6))) + +def cache_581 : ListRow := ⟨cache_581_A, cache_581_H, 26⟩ + +def cache_582_A_part0 : List Cell := [(1, -4), (1, -3), (1, -2), (2, -4)] + +def cache_582_A : List Cell := cache_582_A_part0 + +def cache_582_H_part0 : List Cell := [(-6, 1), (-6, 2), (-6, 4), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-4, -3), (-4, -1), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4)] + +def cache_582_H_part1 : List Cell := [(-3, 5), (-3, 6), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4)] + +def cache_582_H_part2 : List Cell := [(-1, 5), (-1, 6), (-1, 7), (-1, 8), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2)] + +def cache_582_H_part3 : List Cell := [(1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (2, -4), (2, -3), (2, -2), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (3, -9), (3, -8), (3, -7), (3, -6), (3, -5), (3, -4), (3, -3), (3, -2)] + +def cache_582_H_part4 : List Cell := [(3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (4, -8), (4, -7), (4, -6), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6)] + +def cache_582_H_part5 : List Cell := [(4, 7), (5, -9), (5, -8), (5, -7), (5, -6), (5, -5), (5, -4), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (6, -7), (6, -6), (6, -5), (6, -4), (6, -3), (6, -2), (6, -1), (6, 2), (6, 4)] + +def cache_582_H_part6 : List Cell := [(7, -7), (7, -6), (7, -5), (7, -4), (7, -3), (7, -2), (7, -1), (8, -7), (8, -6), (8, -5), (8, -4), (8, -3), (8, -2), (8, -1), (9, -3), (9, -2), (9, -1), (10, -3), (10, -1)] + +def cache_582_H : List Cell := ((cache_582_H_part0 ++ (cache_582_H_part1 ++ cache_582_H_part2)) ++ ((cache_582_H_part3 ++ cache_582_H_part4) ++ (cache_582_H_part5 ++ cache_582_H_part6))) + +def cache_582 : ListRow := ⟨cache_582_A, cache_582_H, 24⟩ + +def cache_583_A_part0 : List Cell := [(-1, 0), (-1, 1), (-1, 2)] + +def cache_583_A : List Cell := cache_583_A_part0 + +def cache_583_H_part0 : List Cell := [(-8, 5), (-8, 6), (-8, 8), (-7, 5), (-7, 6), (-7, 7), (-7, 8), (-6, 1), (-6, 3), (-6, 5), (-6, 6), (-6, 7), (-6, 8), (-6, 9), (-6, 10), (-6, 11), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-5, 5), (-5, 6), (-5, 7), (-5, 8)] + +def cache_583_H_part1 : List Cell := [(-5, 9), (-5, 10), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7), (-4, 8), (-4, 9), (-4, 10), (-4, 11), (-4, 12), (-4, 13), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8)] + +def cache_583_H_part2 : List Cell := [(-3, 9), (-3, 10), (-3, 11), (-3, 12), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-2, 11), (-2, 12), (-2, 13), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6)] + +def cache_583_H_part3 : List Cell := [(-1, 7), (-1, 8), (-1, 9), (-1, 10), (-1, 11), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (0, 11), (1, -5), (1, -4), (1, -3), (1, -2)] + +def cache_583_H_part4 : List Cell := [(1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10), (1, 11), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6)] + +def cache_583_H_part5 : List Cell := [(2, 7), (2, 8), (2, 9), (2, 10), (2, 11), (3, -5), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1)] + +def cache_583_H_part6 : List Cell := [(4, 2), (4, 3), (4, 6), (4, 8), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (7, 1), (7, 2), (7, 3), (8, 1), (8, 3)] + +def cache_583_H : List Cell := ((cache_583_H_part0 ++ (cache_583_H_part1 ++ cache_583_H_part2)) ++ ((cache_583_H_part3 ++ cache_583_H_part4) ++ (cache_583_H_part5 ++ cache_583_H_part6))) + +def cache_583 : ListRow := ⟨cache_583_A, cache_583_H, 25⟩ + +def cache_584_A_part0 : List Cell := [(0, -2), (0, -1)] + +def cache_584_A : List Cell := cache_584_A_part0 + +def cache_584_H_part0 : List Cell := [(-9, -1), (-9, 1), (-8, -1), (-8, 0), (-8, 1), (-7, -5), (-7, -4), (-7, -3), (-7, -2), (-7, -1), (-7, 0), (-7, 1), (-7, 3), (-6, -5), (-6, -4), (-6, -3), (-6, -2), (-6, -1), (-6, 0), (-6, 1), (-6, 2), (-6, 3), (-5, -5), (-5, -4)] + +def cache_584_H_part1 : List Cell := [(-5, -3), (-5, -2), (-5, -1), (-5, 0), (-5, 1), (-5, 2), (-5, 3), (-4, -7), (-4, -6), (-4, -5), (-4, -4), (-4, -3), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-3, -6), (-3, -5), (-3, -4), (-3, -3)] + +def cache_584_H_part2 : List Cell := [(-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-2, -7), (-2, -6), (-2, -5), (-2, -4), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-1, -5), (-1, -4), (-1, -3), (-1, -2)] + +def cache_584_H_part3 : List Cell := [(-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -2), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -3), (2, -2)] + +def cache_584_H_part4 : List Cell := [(2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3)] + +def cache_584_H_part5 : List Cell := [(4, 4), (4, 5), (4, 6), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4)] + +def cache_584_H_part6 : List Cell := [(8, -2), (8, -1), (8, 0), (9, -2), (9, 0)] + +def cache_584_H : List Cell := ((cache_584_H_part0 ++ (cache_584_H_part1 ++ cache_584_H_part2)) ++ ((cache_584_H_part3 ++ cache_584_H_part4) ++ (cache_584_H_part5 ++ cache_584_H_part6))) + +def cache_584 : ListRow := ⟨cache_584_A, cache_584_H, 22⟩ + +def cache_585_A_part0 : List Cell := [(0, -2), (0, -1)] + +def cache_585_A : List Cell := cache_585_A_part0 + +def cache_585_H_part0 : List Cell := [(-9, -1), (-9, 1), (-8, -1), (-8, 0), (-8, 1), (-7, -5), (-7, -4), (-7, -3), (-7, -2), (-7, -1), (-7, 0), (-7, 1), (-6, -5), (-6, -4), (-6, -3), (-6, -2), (-6, -1), (-6, 0), (-6, 1), (-5, -5), (-5, -4), (-5, -3), (-5, -2), (-5, -1)] + +def cache_585_H_part1 : List Cell := [(-5, 0), (-5, 1), (-4, -7), (-4, -6), (-4, -5), (-4, -4), (-4, -3), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-3, -7), (-3, -6), (-3, -5), (-3, -4), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-2, -7), (-2, -6)] + +def cache_585_H_part2 : List Cell := [(-2, -5), (-2, -4), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-1, -7), (-1, -6), (-1, -5), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (1, -5), (1, -4)] + +def cache_585_H_part3 : List Cell := [(1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (2, -7), (2, -6), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, -6), (3, -5), (3, -4)] + +def cache_585_H_part4 : List Cell := [(3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (4, -7), (4, -6), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (5, -5)] + +def cache_585_H_part5 : List Cell := [(5, -4), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (6, -5), (6, -4), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (7, -5), (7, -4), (7, -3), (7, -2), (7, -1)] + +def cache_585_H_part6 : List Cell := [(7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (8, -2), (8, -1), (8, 0), (8, 1), (9, -2), (9, -1), (9, 0), (9, 1)] + +def cache_585_H : List Cell := ((cache_585_H_part0 ++ (cache_585_H_part1 ++ cache_585_H_part2)) ++ ((cache_585_H_part3 ++ cache_585_H_part4) ++ (cache_585_H_part5 ++ cache_585_H_part6))) + +def cache_585 : ListRow := ⟨cache_585_A, cache_585_H, 22⟩ + +def cache_586_A_part0 : List Cell := [(0, -2), (0, -1)] + +def cache_586_A : List Cell := cache_586_A_part0 + +def cache_586_H_part0 : List Cell := [(-7, 3), (-7, 4), (-7, 6), (-6, 1), (-6, 3), (-6, 4), (-6, 5), (-6, 6), (-5, -1), (-5, 0), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-5, 5), (-5, 6), (-5, 7), (-5, 8), (-5, 9), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3)] + +def cache_586_H_part1 : List Cell := [(-4, 4), (-4, 5), (-4, 6), (-4, 7), (-4, 8), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8), (-3, 9), (-3, 10), (-3, 11), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3)] + +def cache_586_H_part2 : List Cell := [(-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (-1, 10), (-1, 11), (0, -2), (0, -1), (0, 0), (0, 1)] + +def cache_586_H_part3 : List Cell := [(0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (1, -6), (1, -5), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9)] + +def cache_586_H_part4 : List Cell := [(2, -7), (2, -6), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (3, -6), (3, -5), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0)] + +def cache_586_H_part5 : List Cell := [(3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (4, -7), (4, -6), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7)] + +def cache_586_H_part6 : List Cell := [(5, -5), (5, -4), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (6, -5), (6, -4), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6)] + +def cache_586_H_part7 : List Cell := [(7, -5), (7, -4), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (8, -2), (8, -1), (8, 0), (8, 1), (8, 2), (8, 3), (8, 4), (9, -2), (9, -1), (9, 0), (9, 1), (9, 2), (9, 3)] + +def cache_586_H_part8 : List Cell := [(9, 4), (10, -2), (10, -1), (10, 0), (11, -2), (11, 0)] + +def cache_586_H : List Cell := (((cache_586_H_part0 ++ cache_586_H_part1) ++ (cache_586_H_part2 ++ cache_586_H_part3)) ++ ((cache_586_H_part4 ++ cache_586_H_part5) ++ (cache_586_H_part6 ++ (cache_586_H_part7 ++ cache_586_H_part8)))) + +def cache_586 : ListRow := ⟨cache_586_A, cache_586_H, 26⟩ + +def cache_587_A_part0 : List Cell := [(0, -2), (0, -1)] + +def cache_587_A : List Cell := cache_587_A_part0 + +def cache_587_H_part0 : List Cell := [(-7, -2), (-7, -1), (-7, 0), (-7, 1), (-6, -2), (-6, -1), (-6, 0), (-6, 1), (-5, -4), (-5, -3), (-5, -2), (-5, -1), (-5, 0), (-5, 1), (-4, -6), (-4, -5), (-4, -4), (-4, -3), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3)] + +def cache_587_H_part1 : List Cell := [(-3, -6), (-3, -5), (-3, -4), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-2, -6), (-2, -5), (-2, -4), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-1, -5), (-1, -4), (-1, -3)] + +def cache_587_H_part2 : List Cell := [(-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (0, -5), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (2, -7)] + +def cache_587_H_part3 : List Cell := [(2, -6), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, -6), (3, -5), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4)] + +def cache_587_H_part4 : List Cell := [(3, 5), (4, -7), (4, -6), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (5, -5), (5, -4), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3)] + +def cache_587_H_part5 : List Cell := [(5, 4), (6, -5), (6, -4), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (7, -5), (7, -4), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (8, -2), (8, -1), (8, 0)] + +def cache_587_H_part6 : List Cell := [(8, 1), (9, -2), (9, -1), (9, 0), (9, 1)] + +def cache_587_H : List Cell := ((cache_587_H_part0 ++ (cache_587_H_part1 ++ cache_587_H_part2)) ++ ((cache_587_H_part3 ++ cache_587_H_part4) ++ (cache_587_H_part5 ++ cache_587_H_part6))) + +def cache_587 : ListRow := ⟨cache_587_A, cache_587_H, 22⟩ + +def cache_588_A_part0 : List Cell := [(-1, -4), (-1, -3), (-1, -2), (0, -1)] + +def cache_588_A : List Cell := cache_588_A_part0 + +def cache_588_H_part0 : List Cell := [(-7, 4), (-7, 5), (-7, 7), (-6, 2), (-6, 4), (-6, 5), (-6, 6), (-6, 7), (-5, 0), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-5, 5), (-5, 6), (-5, 7), (-5, 8), (-5, 9), (-5, 10), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4)] + +def cache_588_H_part1 : List Cell := [(-4, 5), (-4, 6), (-4, 7), (-4, 8), (-4, 9), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8), (-3, 9), (-3, 10), (-3, 11), (-3, 12), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4)] + +def cache_588_H_part2 : List Cell := [(-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-2, 11), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (-1, 10), (-1, 11), (-1, 12)] + +def cache_588_H_part3 : List Cell := [(0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (1, -5), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6)] + +def cache_588_H_part4 : List Cell := [(1, 7), (1, 8), (1, 9), (1, 10), (2, -6), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (3, -5), (3, -4), (3, -3)] + +def cache_588_H_part5 : List Cell := [(3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (4, -6), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4)] + +def cache_588_H_part6 : List Cell := [(4, 5), (4, 6), (4, 7), (4, 8), (5, -4), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (6, -4), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3)] + +def cache_588_H_part7 : List Cell := [(6, 4), (6, 5), (6, 6), (6, 7), (7, -4), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (7, 6), (8, -1), (8, 0), (8, 1), (8, 2), (8, 3), (8, 4), (8, 5), (9, -1), (9, 0)] + +def cache_588_H_part8 : List Cell := [(9, 1), (9, 2), (9, 3), (9, 4), (9, 5), (10, -1), (10, 0), (10, 1), (11, -1), (11, 1)] + +def cache_588_H : List Cell := (((cache_588_H_part0 ++ cache_588_H_part1) ++ (cache_588_H_part2 ++ cache_588_H_part3)) ++ ((cache_588_H_part4 ++ cache_588_H_part5) ++ (cache_588_H_part6 ++ (cache_588_H_part7 ++ cache_588_H_part8)))) + +def cache_588 : ListRow := ⟨cache_588_A, cache_588_H, 27⟩ + +def cache_589_A_part0 : List Cell := [(-1, -4), (-1, -3), (-1, -2), (-1, -1)] + +def cache_589_A : List Cell := cache_589_A_part0 + +def cache_589_H_part0 : List Cell := [(-7, 5), (-7, 6), (-7, 8), (-6, 3), (-6, 5), (-6, 6), (-6, 7), (-6, 8), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-5, 5), (-5, 6), (-5, 7), (-5, 8), (-5, 9), (-5, 10), (-5, 11), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5)] + +def cache_589_H_part1 : List Cell := [(-4, 6), (-4, 7), (-4, 8), (-4, 9), (-4, 10), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8), (-3, 9), (-3, 10), (-3, 11), (-3, 12), (-3, 13), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5)] + +def cache_589_H_part2 : List Cell := [(-2, 6), (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-2, 11), (-2, 12), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (-1, 10), (-1, 11), (-1, 12)] + +def cache_589_H_part3 : List Cell := [(-1, 13), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (0, 11), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5)] + +def cache_589_H_part4 : List Cell := [(1, 6), (1, 7), (1, 8), (1, 9), (1, 10), (1, 11), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (2, 11), (3, -4)] + +def cache_589_H_part5 : List Cell := [(3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (3, 11), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3)] + +def cache_589_H_part6 : List Cell := [(4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2)] + +def cache_589_H_part7 : List Cell := [(6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (6, 8), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (7, 6), (7, 7), (8, 0), (8, 1), (8, 2), (8, 3), (8, 4), (8, 5), (8, 6)] + +def cache_589_H_part8 : List Cell := [(9, 0), (9, 1), (9, 2), (9, 3), (9, 4), (9, 5), (9, 6), (10, 0), (10, 1), (10, 2), (11, 0), (11, 2)] + +def cache_589_H : List Cell := (((cache_589_H_part0 ++ cache_589_H_part1) ++ (cache_589_H_part2 ++ cache_589_H_part3)) ++ ((cache_589_H_part4 ++ cache_589_H_part5) ++ (cache_589_H_part6 ++ (cache_589_H_part7 ++ cache_589_H_part8)))) + +def cache_589 : ListRow := ⟨cache_589_A, cache_589_H, 28⟩ + +def cache_590_A_part0 : List Cell := [(0, 1), (0, 2)] + +def cache_590_A : List Cell := cache_590_A_part0 + +def cache_590_H_part0 : List Cell := [(-9, 1), (-9, 3), (-8, 1), (-8, 2), (-8, 3), (-7, -3), (-7, -2), (-7, -1), (-7, 0), (-7, 1), (-7, 2), (-7, 3), (-6, -3), (-6, -2), (-6, -1), (-6, 0), (-6, 1), (-6, 2), (-6, 3), (-5, -3), (-5, -2), (-5, -1), (-5, 0), (-5, 1)] + +def cache_590_H_part1 : List Cell := [(-5, 2), (-5, 3), (-4, -5), (-4, -4), (-4, -3), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-3, -4), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-2, -5), (-2, -4), (-2, -3)] + +def cache_590_H_part2 : List Cell := [(-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 5), (-1, 6), (-1, 7), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4)] + +def cache_590_H_part3 : List Cell := [(0, 5), (0, 6), (1, -3), (1, -2), (1, -1), (1, 0), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8)] + +def cache_590_H_part4 : List Cell := [(3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (5, -1)] + +def cache_590_H_part5 : List Cell := [(5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4)] + +def cache_590_H_part6 : List Cell := [(7, 5), (7, 6), (7, 7), (8, -1), (8, 0), (8, 1), (8, 2), (8, 3), (8, 4), (8, 5), (9, 0), (9, 2), (9, 3), (9, 4), (9, 5), (10, 2), (10, 3), (10, 4), (10, 5)] + +def cache_590_H : List Cell := ((cache_590_H_part0 ++ (cache_590_H_part1 ++ cache_590_H_part2)) ++ ((cache_590_H_part3 ++ cache_590_H_part4) ++ (cache_590_H_part5 ++ cache_590_H_part6))) + +def cache_590 : ListRow := ⟨cache_590_A, cache_590_H, 23⟩ + +def cache_591_A_part0 : List Cell := [(0, -2), (0, -1)] + +def cache_591_A : List Cell := cache_591_A_part0 + +def cache_591_H_part0 : List Cell := [(-10, -1), (-10, 0), (-10, 1), (-10, 2), (-9, -1), (-9, 0), (-9, 1), (-9, 2), (-8, -4), (-8, -2), (-8, -1), (-8, 0), (-8, 1), (-8, 2), (-7, -5), (-7, -4), (-7, -3), (-7, -2), (-7, -1), (-7, 0), (-7, 1), (-7, 2), (-7, 3), (-7, 4)] + +def cache_591_H_part1 : List Cell := [(-6, -4), (-6, -3), (-6, -2), (-6, -1), (-6, 0), (-6, 1), (-6, 2), (-6, 3), (-6, 4), (-5, -4), (-5, -3), (-5, -2), (-5, -1), (-5, 0), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-4, -5), (-4, -4), (-4, -3), (-4, -2), (-4, -1), (-4, 0)] + +def cache_591_H_part2 : List Cell := [(-4, 1), (-4, 2), (-4, 3), (-4, 4), (-3, -4), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-2, -4), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5)] + +def cache_591_H_part3 : List Cell := [(-1, -5), (-1, -4), (-1, -3), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (1, -5), (1, -4), (1, -3), (1, -1)] + +def cache_591_H_part4 : List Cell := [(1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2)] + +def cache_591_H_part5 : List Cell := [(3, 3), (3, 4), (3, 5), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (5, -4), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (6, -4), (6, -3)] + +def cache_591_H_part6 : List Cell := [(6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (7, -5), (7, -4), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (8, -4), (8, -2), (8, -1), (8, 0), (8, 1), (8, 2), (9, -1)] + +def cache_591_H_part7 : List Cell := [(9, 0), (9, 1), (9, 2), (10, -1), (10, 0), (10, 1), (10, 2)] + +def cache_591_H : List Cell := (((cache_591_H_part0 ++ cache_591_H_part1) ++ (cache_591_H_part2 ++ cache_591_H_part3)) ++ ((cache_591_H_part4 ++ cache_591_H_part5) ++ (cache_591_H_part6 ++ cache_591_H_part7))) + +def cache_591 : ListRow := ⟨cache_591_A, cache_591_H, 23⟩ + +def cache_592_A_part0 : List Cell := [(-1, -3), (-1, -2), (-1, -1)] + +def cache_592_A : List Cell := cache_592_A_part0 + +def cache_592_H_part0 : List Cell := [(-7, 5), (-7, 6), (-7, 8), (-6, 3), (-6, 5), (-6, 6), (-6, 7), (-6, 8), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-5, 5), (-5, 6), (-5, 7), (-5, 8), (-5, 9), (-5, 10), (-5, 11), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5)] + +def cache_592_H_part1 : List Cell := [(-4, 6), (-4, 7), (-4, 8), (-4, 9), (-4, 10), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8), (-3, 9), (-3, 10), (-3, 11), (-3, 12), (-3, 13), (-2, -6), (-2, -5), (-2, -4), (-2, 0), (-2, 1), (-2, 2)] + +def cache_592_H_part2 : List Cell := [(-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-2, 11), (-2, 12), (-1, -5), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8)] + +def cache_592_H_part3 : List Cell := [(-1, 9), (-1, 10), (-1, 11), (-1, 12), (-1, 13), (0, -6), (0, -5), (0, -4), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (0, 11), (1, -4), (1, -3), (1, -2)] + +def cache_592_H_part4 : List Cell := [(1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10), (1, 11), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5)] + +def cache_592_H_part5 : List Cell := [(2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (2, 11), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (3, 11), (4, -5), (4, -4)] + +def cache_592_H_part6 : List Cell := [(4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7)] + +def cache_592_H_part7 : List Cell := [(5, 8), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (6, 8), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (7, 6), (7, 7)] + +def cache_592_H_part8 : List Cell := [(8, 0), (8, 1), (8, 2), (8, 3), (8, 4), (8, 5), (8, 6), (9, 0), (9, 1), (9, 2), (9, 3), (9, 4), (9, 5), (9, 6), (10, 0), (10, 1), (10, 2), (11, 0), (11, 2)] + +def cache_592_H : List Cell := (((cache_592_H_part0 ++ cache_592_H_part1) ++ (cache_592_H_part2 ++ cache_592_H_part3)) ++ ((cache_592_H_part4 ++ cache_592_H_part5) ++ (cache_592_H_part6 ++ (cache_592_H_part7 ++ cache_592_H_part8)))) + +def cache_592 : ListRow := ⟨cache_592_A, cache_592_H, 28⟩ + +def cache_593_A_part0 : List Cell := [(-1, -4), (-1, -3), (0, -3), (0, -1)] + +def cache_593_A : List Cell := cache_593_A_part0 + +def cache_593_H_part0 : List Cell := [(-7, 4), (-7, 5), (-7, 7), (-6, 2), (-6, 4), (-6, 5), (-6, 6), (-6, 7), (-5, 0), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-5, 5), (-5, 6), (-5, 7), (-5, 8), (-5, 9), (-5, 10), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4)] + +def cache_593_H_part1 : List Cell := [(-4, 5), (-4, 6), (-4, 7), (-4, 8), (-4, 9), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8), (-3, 9), (-3, 10), (-3, 11), (-3, 12), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4)] + +def cache_593_H_part2 : List Cell := [(-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-2, 11), (-1, -4), (-1, -3), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (-1, 10), (-1, 11), (-1, 12), (0, -3), (0, -2)] + +def cache_593_H_part3 : List Cell := [(0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (1, -5), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6)] + +def cache_593_H_part4 : List Cell := [(1, 7), (1, 8), (1, 9), (1, 10), (2, -6), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (3, -5), (3, -4), (3, -3)] + +def cache_593_H_part5 : List Cell := [(3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (4, -6), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4)] + +def cache_593_H_part6 : List Cell := [(4, 5), (4, 6), (4, 7), (4, 8), (5, -4), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (6, -4), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3)] + +def cache_593_H_part7 : List Cell := [(6, 4), (6, 5), (6, 6), (6, 7), (7, -4), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (7, 6), (8, -1), (8, 0), (8, 1), (8, 2), (8, 3), (8, 4), (8, 5), (9, -1), (9, 0)] + +def cache_593_H_part8 : List Cell := [(9, 1), (9, 2), (9, 3), (9, 4), (9, 5), (10, -1), (10, 0), (10, 1), (11, -1), (11, 1)] + +def cache_593_H : List Cell := (((cache_593_H_part0 ++ cache_593_H_part1) ++ (cache_593_H_part2 ++ cache_593_H_part3)) ++ ((cache_593_H_part4 ++ cache_593_H_part5) ++ (cache_593_H_part6 ++ (cache_593_H_part7 ++ cache_593_H_part8)))) + +def cache_593 : ListRow := ⟨cache_593_A, cache_593_H, 27⟩ + +def cache_594_A_part0 : List Cell := [(-1, -3), (-1, -2), (-1, -1)] + +def cache_594_A : List Cell := cache_594_A_part0 + +def cache_594_H_part0 : List Cell := [(-7, 5), (-7, 6), (-7, 8), (-6, 3), (-6, 5), (-6, 6), (-6, 7), (-6, 8), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-5, 5), (-5, 6), (-5, 7), (-5, 8), (-5, 9), (-5, 10), (-5, 11), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5)] + +def cache_594_H_part1 : List Cell := [(-4, 6), (-4, 7), (-4, 8), (-4, 9), (-4, 10), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8), (-3, 9), (-3, 10), (-3, 11), (-3, 12), (-3, 13), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5)] + +def cache_594_H_part2 : List Cell := [(-2, 6), (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-2, 11), (-2, 12), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (-1, 10), (-1, 11), (-1, 12)] + +def cache_594_H_part3 : List Cell := [(-1, 13), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (0, 11), (1, -6), (1, -5), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2)] + +def cache_594_H_part4 : List Cell := [(1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10), (1, 11), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9)] + +def cache_594_H_part5 : List Cell := [(2, 10), (2, 11), (3, -6), (3, -5), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (3, 11), (4, -5), (4, -4), (4, -3), (4, -2)] + +def cache_594_H_part6 : List Cell := [(4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (5, -4), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8)] + +def cache_594_H_part7 : List Cell := [(6, -4), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (6, 8), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (7, 6), (7, 7)] + +def cache_594_H_part8 : List Cell := [(8, -3), (8, -1), (8, 0), (8, 1), (8, 2), (8, 3), (8, 4), (8, 5), (8, 6), (9, 0), (9, 1), (9, 2), (9, 3), (9, 4), (9, 5), (9, 6), (10, 0), (10, 1), (10, 2), (11, 0), (11, 2)] + +def cache_594_H : List Cell := (((cache_594_H_part0 ++ cache_594_H_part1) ++ (cache_594_H_part2 ++ cache_594_H_part3)) ++ ((cache_594_H_part4 ++ cache_594_H_part5) ++ (cache_594_H_part6 ++ (cache_594_H_part7 ++ cache_594_H_part8)))) + +def cache_594 : ListRow := ⟨cache_594_A, cache_594_H, 28⟩ + +def cache_595_A_part0 : List Cell := [(-1, 0)] + +def cache_595_A : List Cell := cache_595_A_part0 + +def cache_595_H_part0 : List Cell := [(-6, -1), (-6, 0), (-6, 1), (-6, 2), (-6, 3), (-6, 4), (-5, -1), (-5, 0), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7), (-3, -3), (-3, -2), (-3, -1)] + +def cache_595_H_part1 : List Cell := [(-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-2, 11), (-1, -5), (-1, -4), (-1, -3)] + +def cache_595_H_part2 : List Cell := [(-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (-1, 10), (-1, 11), (0, -5), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4)] + +def cache_595_H_part3 : List Cell := [(0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (0, 11), (1, -6), (1, -5), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10)] + +def cache_595_H_part4 : List Cell := [(1, 11), (2, -6), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (3, -5), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1)] + +def cache_595_H_part5 : List Cell := [(3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (4, -7), (4, -6), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8)] + +def cache_595_H_part6 : List Cell := [(4, 9), (5, -7), (5, -6), (5, -5), (5, -4), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8), (5, 9), (6, -6), (6, -5), (6, -4), (6, -3), (6, -2), (6, -1)] + +def cache_595_H_part7 : List Cell := [(6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (7, -7), (7, -6), (7, -5), (7, -4), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (7, 6), (8, -5), (8, -4)] + +def cache_595_H_part8 : List Cell := [(8, -3), (8, -2), (8, -1), (8, 0), (8, 1), (8, 2), (8, 3), (8, 4), (9, -5), (9, -4), (9, -3), (9, -2), (9, -1), (9, 0), (9, 1), (9, 2), (9, 3), (10, -5), (10, -3), (10, -2), (10, -1), (10, 0), (10, 1), (10, 2)] + +def cache_595_H_part9 : List Cell := [(10, 3), (11, -3), (11, -2), (11, -1), (12, -3), (12, -1)] + +def cache_595_H : List Cell := (((cache_595_H_part0 ++ cache_595_H_part1) ++ (cache_595_H_part2 ++ (cache_595_H_part3 ++ cache_595_H_part4))) ++ ((cache_595_H_part5 ++ cache_595_H_part6) ++ (cache_595_H_part7 ++ (cache_595_H_part8 ++ cache_595_H_part9)))) + +def cache_595 : ListRow := ⟨cache_595_A, cache_595_H, 27⟩ + +def cache_596_A_part0 : List Cell := [(0, -1), (0, 1)] + +def cache_596_A : List Cell := cache_596_A_part0 + +def cache_596_H_part0 : List Cell := [(-6, 7), (-6, 8), (-6, 10), (-5, 5), (-5, 7), (-5, 8), (-5, 9), (-5, 10), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7), (-4, 8), (-4, 9), (-4, 10), (-4, 11), (-4, 12), (-4, 13), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7)] + +def cache_596_H_part1 : List Cell := [(-3, 8), (-3, 9), (-3, 10), (-3, 11), (-3, 12), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-2, 11), (-2, 12), (-2, 13), (-2, 14), (-2, 15), (-1, -4), (-1, -3), (-1, -2), (-1, 0), (-1, 2), (-1, 3)] + +def cache_596_H_part2 : List Cell := [(-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (-1, 10), (-1, 11), (-1, 12), (-1, 13), (-1, 14), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8)] + +def cache_596_H_part3 : List Cell := [(0, 9), (0, 10), (0, 11), (0, 12), (0, 13), (0, 14), (0, 15), (1, -5), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10), (1, 11)] + +def cache_596_H_part4 : List Cell := [(1, 12), (1, 13), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (2, 11), (2, 12), (2, 13), (3, -5), (3, -4), (3, -3)] + +def cache_596_H_part5 : List Cell := [(3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (3, 11), (3, 12), (3, 13), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2)] + +def cache_596_H_part6 : List Cell := [(4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (4, 10), (4, 11), (4, 12), (4, 13), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8), (5, 9)] + +def cache_596_H_part7 : List Cell := [(5, 10), (5, 11), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (6, 8), (6, 9), (6, 10), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4)] + +def cache_596_H_part8 : List Cell := [(7, 5), (7, 6), (7, 7), (7, 8), (7, 9), (7, 10), (8, -1), (8, 0), (8, 1), (8, 2), (8, 3), (8, 4), (8, 5), (8, 6), (8, 7), (8, 8), (8, 9), (9, 2), (9, 3), (9, 4), (9, 5), (9, 6), (9, 7), (9, 8)] + +def cache_596_H_part9 : List Cell := [(10, 2), (10, 3), (10, 4), (10, 5), (10, 6), (10, 7), (10, 8), (11, 2), (11, 3), (11, 4), (12, 2), (12, 4)] + +def cache_596_H : List Cell := (((cache_596_H_part0 ++ cache_596_H_part1) ++ (cache_596_H_part2 ++ (cache_596_H_part3 ++ cache_596_H_part4))) ++ ((cache_596_H_part5 ++ cache_596_H_part6) ++ (cache_596_H_part7 ++ (cache_596_H_part8 ++ cache_596_H_part9)))) + +def cache_596 : ListRow := ⟨cache_596_A, cache_596_H, 29⟩ + +def cache_597_A_part0 : List Cell := [(-1, -1), (-1, 0), (1, 0)] + +def cache_597_A : List Cell := cache_597_A_part0 + +def cache_597_H_part0 : List Cell := [(-4, -1), (-4, 1), (-4, 2), (-4, 4), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-1, -2), (-1, -1), (-1, 0), (-1, 2)] + +def cache_597_H_part1 : List Cell := [(-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7)] + +def cache_597_H_part2 : List Cell := [(1, 8), (1, 9), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (2, 11), (2, 12), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3)] + +def cache_597_H_part3 : List Cell := [(3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (3, 11), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (4, 10), (4, 11)] + +def cache_597_H_part4 : List Cell := [(4, 12), (5, -5), (5, -4), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8), (5, 9), (5, 10), (6, -4), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2)] + +def cache_597_H_part5 : List Cell := [(6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (6, 8), (6, 9), (6, 10), (7, -6), (7, -5), (7, -4), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (7, 6), (7, 7), (7, 8), (7, 9)] + +def cache_597_H_part6 : List Cell := [(7, 10), (8, -6), (8, -5), (8, -4), (8, -3), (8, -2), (8, -1), (8, 0), (8, 1), (8, 2), (8, 3), (8, 4), (8, 5), (8, 6), (8, 7), (8, 8), (8, 9), (8, 10), (9, -5), (9, -4), (9, -3), (9, -2), (9, -1), (9, 0)] + +def cache_597_H_part7 : List Cell := [(9, 1), (9, 2), (9, 3), (9, 4), (9, 5), (9, 6), (9, 7), (9, 8), (10, -6), (10, -5), (10, -4), (10, -3), (10, -2), (10, -1), (10, 0), (10, 1), (10, 2), (10, 3), (10, 4), (10, 5), (10, 6), (10, 7), (11, -4), (11, -3)] + +def cache_597_H_part8 : List Cell := [(11, -2), (11, -1), (11, 0), (11, 1), (11, 2), (11, 3), (11, 4), (11, 5), (12, -4), (12, -3), (12, -2), (12, -1), (12, 0), (12, 1), (12, 2), (12, 3), (12, 4), (13, -4), (13, -2), (13, -1), (13, 0), (13, 1), (13, 2), (13, 3)] + +def cache_597_H_part9 : List Cell := [(13, 4), (14, -2), (14, -1), (14, 0), (15, -2), (15, 0)] + +def cache_597_H : List Cell := (((cache_597_H_part0 ++ cache_597_H_part1) ++ (cache_597_H_part2 ++ (cache_597_H_part3 ++ cache_597_H_part4))) ++ ((cache_597_H_part5 ++ cache_597_H_part6) ++ (cache_597_H_part7 ++ (cache_597_H_part8 ++ cache_597_H_part9)))) + +def cache_597 : ListRow := ⟨cache_597_A, cache_597_H, 29⟩ + +def cache_598_A_part0 : List Cell := [(-3, -2), (-2, -2), (-2, -1), (0, -1), (0, 1)] + +def cache_598_A : List Cell := cache_598_A_part0 + +def cache_598_H_part0 : List Cell := [(-6, 7), (-6, 8), (-6, 10), (-5, 5), (-5, 7), (-5, 8), (-5, 9), (-5, 10), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7), (-4, 8), (-4, 9), (-4, 10), (-4, 11), (-4, 12), (-4, 13), (-3, -2), (-3, 2), (-3, 3), (-3, 4), (-3, 5)] + +def cache_598_H_part1 : List Cell := [(-3, 6), (-3, 7), (-3, 8), (-3, 9), (-3, 10), (-3, 11), (-3, 12), (-2, -2), (-2, -1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-2, 11), (-2, 12), (-2, 13), (-2, 14), (-2, 15), (-1, -4)] + +def cache_598_H_part2 : List Cell := [(-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (-1, 10), (-1, 11), (-1, 12), (-1, 13), (-1, 14), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3)] + +def cache_598_H_part3 : List Cell := [(0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (0, 11), (0, 12), (0, 13), (0, 14), (0, 15), (1, -4), (1, -3), (1, -2), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8)] + +def cache_598_H_part4 : List Cell := [(1, 9), (1, 10), (1, 11), (1, 12), (1, 13), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (2, 11), (2, 12), (2, 13)] + +def cache_598_H_part5 : List Cell := [(3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (3, 11), (3, 12), (3, 13), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0)] + +def cache_598_H_part6 : List Cell := [(4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (4, 10), (4, 11), (4, 12), (4, 13), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7)] + +def cache_598_H_part7 : List Cell := [(5, 8), (5, 9), (5, 10), (5, 11), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (6, 8), (6, 9), (6, 10), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2)] + +def cache_598_H_part8 : List Cell := [(7, 3), (7, 4), (7, 5), (7, 6), (7, 7), (7, 8), (7, 9), (7, 10), (8, -1), (8, 0), (8, 1), (8, 2), (8, 3), (8, 4), (8, 5), (8, 6), (8, 7), (8, 8), (8, 9), (9, -1), (9, 1), (9, 2), (9, 3), (9, 4)] + +def cache_598_H_part9 : List Cell := [(9, 5), (9, 6), (9, 7), (9, 8), (10, 2), (10, 3), (10, 4), (10, 5), (10, 6), (10, 7), (10, 8), (11, 2), (11, 3), (11, 4), (12, 2), (12, 4)] + +def cache_598_H : List Cell := (((cache_598_H_part0 ++ cache_598_H_part1) ++ (cache_598_H_part2 ++ (cache_598_H_part3 ++ cache_598_H_part4))) ++ ((cache_598_H_part5 ++ cache_598_H_part6) ++ (cache_598_H_part7 ++ (cache_598_H_part8 ++ cache_598_H_part9)))) + +def cache_598 : ListRow := ⟨cache_598_A, cache_598_H, 29⟩ + +def cache_599_A_part0 : List Cell := [(0, -3), (0, -1), (1, -4), (1, -3)] + +def cache_599_A : List Cell := cache_599_A_part0 + +def cache_599_H_part0 : List Cell := [(-11, -1), (-11, 1), (-10, -1), (-10, 0), (-10, 1), (-9, -1), (-9, 0), (-9, 1), (-9, 2), (-9, 3), (-9, 4), (-9, 5), (-8, -2), (-8, -1), (-8, 0), (-8, 1), (-8, 2), (-8, 3), (-8, 4), (-8, 5), (-7, -4), (-7, -3), (-7, -2), (-7, -1)] + +def cache_599_H_part1 : List Cell := [(-7, 0), (-7, 1), (-7, 2), (-7, 3), (-7, 4), (-7, 5), (-7, 6), (-6, -4), (-6, -3), (-6, -2), (-6, -1), (-6, 0), (-6, 1), (-6, 2), (-6, 3), (-6, 4), (-6, 5), (-6, 6), (-6, 7), (-5, -4), (-5, -3), (-5, -2), (-5, -1), (-5, 0)] + +def cache_599_H_part2 : List Cell := [(-5, 1), (-5, 2), (-5, 3), (-5, 4), (-5, 5), (-5, 6), (-5, 7), (-4, -6), (-4, -5), (-4, -4), (-4, -3), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7), (-4, 8), (-3, -5), (-3, -4)] + +def cache_599_H_part3 : List Cell := [(-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8), (-3, 9), (-3, 10), (-2, -6), (-2, -5), (-2, -4), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3)] + +def cache_599_H_part4 : List Cell := [(-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-1, -5), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (-1, 10), (0, -3)] + +def cache_599_H_part5 : List Cell := [(0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7)] + +def cache_599_H_part6 : List Cell := [(1, 8), (1, 9), (1, 10), (1, 11), (1, 12), (2, -4), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (2, 11), (3, -3), (3, -2), (3, -1), (3, 0)] + +def cache_599_H_part7 : List Cell := [(3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (3, 11), (3, 12), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7)] + +def cache_599_H_part8 : List Cell := [(4, 8), (4, 9), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8), (5, 9), (5, 10), (6, -4), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3)] + +def cache_599_H_part9 : List Cell := [(6, 4), (6, 5), (6, 6), (6, 7), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (7, 7), (8, -2), (8, -1), (8, 0), (8, 1), (8, 2), (9, -2), (9, 0), (9, 2)] + +def cache_599_H : List Cell := (((cache_599_H_part0 ++ cache_599_H_part1) ++ (cache_599_H_part2 ++ (cache_599_H_part3 ++ cache_599_H_part4))) ++ ((cache_599_H_part5 ++ cache_599_H_part6) ++ (cache_599_H_part7 ++ (cache_599_H_part8 ++ cache_599_H_part9)))) + +def cache_599 : ListRow := ⟨cache_599_A, cache_599_H, 27⟩ + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/CacheData15.lean b/lean/OAI/Combinatorics/SnakyCertificate/CacheData15.lean new file mode 100644 index 0000000000000000000000000000000000000000..d280f70465d1522dc905516217ef7a32b1459e70 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/CacheData15.lean @@ -0,0 +1,655 @@ +import OAI.Combinatorics.SnakyCertificate.Lists + +namespace OAI + +namespace SnakyCertificate.Check + +def cache_600_A_part0 : List Cell := [(-2, 0), (-1, 0), (-1, 1)] + +def cache_600_A : List Cell := cache_600_A_part0 + +def cache_600_H_part0 : List Cell := [(-5, -1), (-5, 1), (-5, 2), (-5, 4), (-4, -5), (-4, -3), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-3, -5), (-3, -4), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6)] + +def cache_600_H_part1 : List Cell := [(-3, 7), (-3, 8), (-3, 9), (-2, -8), (-2, -7), (-2, -6), (-2, -5), (-2, -4), (-2, -3), (-2, -2), (-2, 0), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-1, -8), (-1, -7), (-1, -6), (-1, -5), (-1, -4), (-1, -3)] + +def cache_600_H_part2 : List Cell := [(-1, -2), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (0, -8), (0, -7), (0, -6), (0, -5), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4)] + +def cache_600_H_part3 : List Cell := [(0, 5), (0, 6), (0, 7), (1, -12), (1, -11), (1, -10), (1, -9), (1, -8), (1, -7), (1, -6), (1, -5), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (2, -11)] + +def cache_600_H_part4 : List Cell := [(2, -10), (2, -9), (2, -8), (2, -7), (2, -6), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (3, -12), (3, -11), (3, -10), (3, -9), (3, -8), (3, -7)] + +def cache_600_H_part5 : List Cell := [(3, -6), (3, -5), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (4, -10), (4, -9), (4, -8), (4, -7), (4, -6), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1)] + +def cache_600_H_part6 : List Cell := [(4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (5, -10), (5, -9), (5, -8), (5, -7), (5, -6), (5, -5), (5, -4), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (6, -10), (6, -9), (6, -8)] + +def cache_600_H_part7 : List Cell := [(6, -7), (6, -6), (6, -5), (6, -4), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (7, -10), (7, -9), (7, -8), (7, -7), (7, -6), (7, -5), (7, -4), (7, -3), (7, -2), (7, -1)] + +def cache_600_H_part8 : List Cell := [(7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (7, 6), (8, -8), (8, -7), (8, -6), (8, -5), (8, -4), (8, -3), (8, -2), (8, -1), (8, 0), (8, 1), (8, 2), (8, 3), (8, 4), (8, 5), (9, -7), (9, -6), (9, -5)] + +def cache_600_H_part9 : List Cell := [(9, -4), (9, -3), (9, -2), (9, -1), (9, 0), (9, 1), (9, 2), (9, 3), (9, 4), (9, 5), (9, 6), (10, -5), (10, -4), (10, -3), (10, -2), (10, -1), (10, 0), (10, 1), (10, 2), (10, 3), (10, 4), (11, -4), (11, -3), (11, -2)] + +def cache_600_H_part10 : List Cell := [(11, -1), (11, 0), (11, 1), (11, 2), (11, 3), (11, 4), (12, -4), (12, -3), (12, -2), (12, -1), (12, 0), (12, 1), (12, 2), (12, 4), (13, 0), (13, 1), (13, 2), (14, 0), (14, 2)] + +def cache_600_H : List Cell := (((cache_600_H_part0 ++ cache_600_H_part1) ++ (cache_600_H_part2 ++ (cache_600_H_part3 ++ cache_600_H_part4))) ++ ((cache_600_H_part5 ++ (cache_600_H_part6 ++ cache_600_H_part7)) ++ (cache_600_H_part8 ++ (cache_600_H_part9 ++ cache_600_H_part10)))) + +def cache_600 : ListRow := ⟨cache_600_A, cache_600_H, 29⟩ + +def cache_601_A_part0 : List Cell := [(0, -2), (0, -1)] + +def cache_601_A : List Cell := cache_601_A_part0 + +def cache_601_H_part0 : List Cell := [(-9, -3), (-9, -1), (-8, -3), (-8, -2), (-8, -1), (-7, -5), (-7, -4), (-7, -3), (-7, -2), (-7, -1), (-7, 0), (-7, 1), (-7, 2), (-7, 3), (-6, -5), (-6, -4), (-6, -3), (-6, -2), (-6, -1), (-6, 0), (-6, 1), (-6, 2), (-6, 3), (-6, 6)] + +def cache_601_H_part1 : List Cell := [(-6, 7), (-6, 9), (-5, -5), (-5, -4), (-5, -3), (-5, -2), (-5, -1), (-5, 0), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-5, 6), (-5, 7), (-5, 8), (-5, 9), (-4, -7), (-4, -6), (-4, -5), (-4, -4), (-4, -3), (-4, -2), (-4, -1), (-4, 0)] + +def cache_601_H_part2 : List Cell := [(-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7), (-4, 8), (-4, 9), (-4, 10), (-4, 11), (-4, 12), (-3, -7), (-3, -6), (-3, -5), (-3, -4), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4)] + +def cache_601_H_part3 : List Cell := [(-3, 5), (-3, 6), (-3, 7), (-3, 8), (-3, 9), (-3, 10), (-3, 11), (-2, -7), (-2, -6), (-2, -5), (-2, -4), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9)] + +def cache_601_H_part4 : List Cell := [(-2, 10), (-2, 11), (-2, 12), (-2, 13), (-2, 14), (-1, -5), (-1, -4), (-1, -3), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (-1, 10), (-1, 11), (-1, 12), (-1, 13), (0, -5)] + +def cache_601_H_part5 : List Cell := [(0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (0, 11), (0, 12), (0, 13), (0, 14), (1, -6), (1, -5), (1, -4), (1, -3), (1, -2)] + +def cache_601_H_part6 : List Cell := [(1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10), (1, 11), (1, 12), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5)] + +def cache_601_H_part7 : List Cell := [(2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (2, 11), (2, 12), (3, -5), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (3, 11)] + +def cache_601_H_part8 : List Cell := [(3, 12), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (4, 10), (4, 11), (4, 12), (5, -4), (5, -3), (5, -2), (5, -1), (5, 0)] + +def cache_601_H_part9 : List Cell := [(5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8), (5, 9), (5, 10), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (6, 8), (6, 9), (7, -2), (7, -1)] + +def cache_601_H_part10 : List Cell := [(7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (7, 6), (7, 7), (7, 8), (7, 9), (8, -2), (8, -1), (8, 0), (8, 1), (8, 2), (8, 3), (8, 4), (8, 5), (8, 6), (8, 7), (8, 8), (9, 1), (9, 2), (9, 3)] + +def cache_601_H_part11 : List Cell := [(9, 4), (9, 5), (9, 6), (9, 7), (10, 1), (10, 2), (10, 3), (10, 4), (10, 5), (10, 6), (10, 7), (11, 1), (11, 2), (11, 3), (12, 1), (12, 3)] + +def cache_601_H : List Cell := (((cache_601_H_part0 ++ (cache_601_H_part1 ++ cache_601_H_part2)) ++ (cache_601_H_part3 ++ (cache_601_H_part4 ++ cache_601_H_part5))) ++ ((cache_601_H_part6 ++ (cache_601_H_part7 ++ cache_601_H_part8)) ++ (cache_601_H_part9 ++ (cache_601_H_part10 ++ cache_601_H_part11)))) + +def cache_601 : ListRow := ⟨cache_601_A, cache_601_H, 29⟩ + +def cache_602_A_part0 : List Cell := [(0, 1), (0, 2)] + +def cache_602_A : List Cell := cache_602_A_part0 + +def cache_602_H_part0 : List Cell := [(-9, -1), (-9, 1), (-8, -1), (-8, 0), (-8, 1), (-7, -3), (-7, -2), (-7, -1), (-7, 0), (-7, 1), (-7, 2), (-7, 3), (-7, 4), (-7, 5), (-6, -3), (-6, -2), (-6, -1), (-6, 0), (-6, 1), (-6, 2), (-6, 3), (-6, 4), (-6, 5), (-6, 8)] + +def cache_602_H_part1 : List Cell := [(-6, 9), (-6, 11), (-5, -3), (-5, -2), (-5, -1), (-5, 0), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-5, 5), (-5, 6), (-5, 8), (-5, 9), (-5, 10), (-5, 11), (-4, -5), (-4, -4), (-4, -3), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-4, 2)] + +def cache_602_H_part2 : List Cell := [(-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7), (-4, 8), (-4, 9), (-4, 10), (-4, 11), (-4, 12), (-4, 13), (-4, 14), (-3, -5), (-3, -4), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6)] + +def cache_602_H_part3 : List Cell := [(-3, 7), (-3, 8), (-3, 9), (-3, 10), (-3, 11), (-3, 12), (-3, 13), (-2, -5), (-2, -4), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-2, 11)] + +def cache_602_H_part4 : List Cell := [(-2, 12), (-2, 13), (-2, 14), (-2, 15), (-2, 16), (-1, -3), (-1, -2), (-1, -1), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (-1, 10), (-1, 11), (-1, 12), (-1, 13), (-1, 14), (-1, 15), (0, -3)] + +def cache_602_H_part5 : List Cell := [(0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (0, 11), (0, 12), (0, 13), (0, 14), (0, 15), (0, 16), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0)] + +def cache_602_H_part6 : List Cell := [(1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10), (1, 11), (1, 12), (1, 13), (1, 14), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7)] + +def cache_602_H_part7 : List Cell := [(2, 8), (2, 9), (2, 10), (2, 11), (2, 12), (2, 13), (2, 14), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (3, 11), (3, 12), (3, 13)] + +def cache_602_H_part8 : List Cell := [(3, 14), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (4, 10), (4, 11), (4, 12), (4, 13), (4, 14), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2)] + +def cache_602_H_part9 : List Cell := [(5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8), (5, 9), (5, 10), (5, 11), (5, 12), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (6, 8), (6, 9), (6, 10), (6, 11), (7, 0), (7, 1)] + +def cache_602_H_part10 : List Cell := [(7, 2), (7, 3), (7, 4), (7, 5), (7, 6), (7, 7), (7, 8), (7, 9), (7, 10), (7, 11), (8, 0), (8, 1), (8, 2), (8, 3), (8, 4), (8, 5), (8, 6), (8, 7), (8, 8), (8, 9), (8, 10), (9, 3), (9, 4), (9, 5)] + +def cache_602_H_part11 : List Cell := [(9, 6), (9, 7), (9, 8), (9, 9), (10, 3), (10, 4), (10, 5), (10, 6), (10, 7), (10, 8), (10, 9), (11, 3), (11, 4), (11, 5), (12, 3), (12, 5)] + +def cache_602_H : List Cell := (((cache_602_H_part0 ++ (cache_602_H_part1 ++ cache_602_H_part2)) ++ (cache_602_H_part3 ++ (cache_602_H_part4 ++ cache_602_H_part5))) ++ ((cache_602_H_part6 ++ (cache_602_H_part7 ++ cache_602_H_part8)) ++ (cache_602_H_part9 ++ (cache_602_H_part10 ++ cache_602_H_part11)))) + +def cache_602 : ListRow := ⟨cache_602_A, cache_602_H, 29⟩ + +def cache_603_A_part0 : List Cell := [(-1, 0)] + +def cache_603_A : List Cell := cache_603_A_part0 + +def cache_603_H_part0 : List Cell := [(-6, -4), (-6, -3), (-6, -2), (-6, -1), (-6, 1), (-6, 2), (-6, 3), (-6, 4), (-5, -4), (-5, -3), (-5, -2), (-5, -1), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-4, -7), (-4, -6), (-4, -5), (-4, -4), (-4, -3), (-4, -2), (-4, -1), (-4, 1)] + +def cache_603_H_part1 : List Cell := [(-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7), (-3, -8), (-3, -7), (-3, -6), (-3, -5), (-3, -4), (-3, -3), (-3, -2), (-3, -1), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-2, -8), (-2, -7), (-2, -6)] + +def cache_603_H_part2 : List Cell := [(-2, -5), (-2, -4), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-1, -11), (-1, -10), (-1, -9), (-1, -8), (-1, -7), (-1, -6), (-1, -5), (-1, -4), (-1, -3), (-1, -2), (-1, -1)] + +def cache_603_H_part3 : List Cell := [(-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (-1, 10), (-1, 11), (0, -10), (0, -9), (0, -8), (0, -7), (0, -6), (0, -5), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1)] + +def cache_603_H_part4 : List Cell := [(0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (1, -11), (1, -10), (1, -9), (1, -8), (1, -7), (1, -6), (1, -5), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3)] + +def cache_603_H_part5 : List Cell := [(1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10), (1, 11), (2, -9), (2, -8), (2, -7), (2, -6), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6)] + +def cache_603_H_part6 : List Cell := [(2, 7), (2, 8), (2, 9), (3, -9), (3, -8), (3, -7), (3, -6), (3, -5), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (4, -9), (4, -8)] + +def cache_603_H_part7 : List Cell := [(4, -7), (4, -6), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (5, -9), (5, -8), (5, -7), (5, -6), (5, -5), (5, -4), (5, -3)] + +def cache_603_H_part8 : List Cell := [(5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8), (5, 9), (6, -7), (6, -6), (6, -5), (6, -4), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4)] + +def cache_603_H_part9 : List Cell := [(6, 5), (6, 6), (6, 7), (7, -7), (7, -6), (7, -5), (7, -4), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (7, 6), (7, 7), (8, -5), (8, -4), (8, -3), (8, -2), (8, -1), (8, 0)] + +def cache_603_H_part10 : List Cell := [(8, 1), (8, 2), (8, 3), (8, 4), (8, 5), (9, -5), (9, -4), (9, -3), (9, -2), (9, -1), (9, 0), (9, 1), (9, 2), (9, 3), (9, 4), (9, 5), (10, -5), (10, -3), (10, -2), (10, -1), (10, 0), (10, 1), (10, 2), (10, 3)] + +def cache_603_H_part11 : List Cell := [(10, 5), (11, -3), (11, -2), (11, -1), (11, 1), (11, 2), (11, 3), (12, -3), (12, -1), (12, 1), (12, 3)] + +def cache_603_H : List Cell := (((cache_603_H_part0 ++ (cache_603_H_part1 ++ cache_603_H_part2)) ++ (cache_603_H_part3 ++ (cache_603_H_part4 ++ cache_603_H_part5))) ++ ((cache_603_H_part6 ++ (cache_603_H_part7 ++ cache_603_H_part8)) ++ (cache_603_H_part9 ++ (cache_603_H_part10 ++ cache_603_H_part11)))) + +def cache_603 : ListRow := ⟨cache_603_A, cache_603_H, 27⟩ + +def cache_604_A_part0 : List Cell := [(-2, -1), (-2, 0), (-1, -2), (0, -2)] + +def cache_604_A : List Cell := cache_604_A_part0 + +def cache_604_H_part0 : List Cell := [(-7, -1), (-6, -1), (-6, 0), (-6, 1), (-6, 6), (-6, 7), (-6, 9), (-5, -1), (-5, 0), (-5, 1), (-5, 2), (-5, 4), (-5, 6), (-5, 7), (-5, 8), (-5, 9), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6)] + +def cache_604_H_part1 : List Cell := [(-4, 7), (-4, 8), (-4, 9), (-4, 10), (-4, 11), (-4, 12), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8), (-3, 9), (-3, 10), (-3, 11), (-2, -2), (-2, -1), (-2, 0), (-2, 2), (-2, 3)] + +def cache_604_H_part2 : List Cell := [(-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-2, 11), (-2, 12), (-2, 13), (-2, 14), (-1, -7), (-1, -6), (-1, -5), (-1, -4), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6)] + +def cache_604_H_part3 : List Cell := [(-1, 7), (-1, 8), (-1, 9), (-1, 10), (-1, 11), (-1, 12), (-1, 13), (0, -6), (0, -5), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10)] + +def cache_604_H_part4 : List Cell := [(0, 11), (0, 12), (0, 13), (0, 14), (1, -6), (1, -5), (1, -4), (1, -3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10), (1, 11), (1, 12), (2, -5), (2, -4)] + +def cache_604_H_part5 : List Cell := [(2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (2, 11), (2, 12), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3)] + +def cache_604_H_part6 : List Cell := [(3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (3, 11), (3, 12), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9)] + +def cache_604_H_part7 : List Cell := [(4, 10), (4, 11), (4, 12), (5, -4), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8), (5, 9), (5, 10), (6, -6), (6, -5), (6, -4), (6, -3), (6, -2), (6, -1)] + +def cache_604_H_part8 : List Cell := [(6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (6, 8), (6, 9), (6, 10), (7, -6), (7, -5), (7, -4), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (7, 6)] + +def cache_604_H_part9 : List Cell := [(7, 7), (7, 8), (7, 9), (7, 10), (8, -5), (8, -4), (8, -3), (8, -2), (8, -1), (8, 0), (8, 1), (8, 2), (8, 3), (8, 4), (8, 5), (8, 6), (8, 7), (8, 8), (9, -6), (9, -5), (9, -4), (9, -3), (9, -2), (9, -1)] + +def cache_604_H_part10 : List Cell := [(9, 0), (9, 1), (9, 2), (9, 3), (9, 4), (9, 5), (9, 6), (9, 7), (10, -4), (10, -3), (10, -2), (10, -1), (10, 0), (10, 1), (10, 2), (10, 3), (10, 4), (10, 5), (10, 6), (10, 7), (11, -4), (11, -3), (11, -2), (11, -1)] + +def cache_604_H_part11 : List Cell := [(11, 0), (11, 1), (11, 2), (11, 3), (11, 4), (12, -4), (12, -2), (12, -1), (12, 0), (12, 1), (12, 2), (12, 3), (12, 4), (13, -2), (13, -1), (13, 0), (14, -2), (14, 0)] + +def cache_604_H : List Cell := (((cache_604_H_part0 ++ (cache_604_H_part1 ++ cache_604_H_part2)) ++ (cache_604_H_part3 ++ (cache_604_H_part4 ++ cache_604_H_part5))) ++ ((cache_604_H_part6 ++ (cache_604_H_part7 ++ cache_604_H_part8)) ++ (cache_604_H_part9 ++ (cache_604_H_part10 ++ cache_604_H_part11)))) + +def cache_604 : ListRow := ⟨cache_604_A, cache_604_H, 30⟩ + +def cache_605_A_part0 : List Cell := [(-3, -3), (-2, -3), (-2, -2), (-2, 0), (0, -2)] + +def cache_605_A : List Cell := cache_605_A_part0 + +def cache_605_H_part0 : List Cell := [(-7, -1), (-7, 0), (-7, 1), (-7, 2), (-6, -1), (-6, 0), (-6, 1), (-6, 2), (-6, 3), (-6, 4), (-6, 6), (-6, 7), (-6, 9), (-5, -1), (-5, 0), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-5, 6), (-5, 7), (-5, 8), (-5, 9), (-4, -1)] + +def cache_605_H_part1 : List Cell := [(-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7), (-4, 8), (-4, 9), (-4, 10), (-4, 11), (-4, 12), (-3, -3), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8)] + +def cache_605_H_part2 : List Cell := [(-3, 9), (-3, 10), (-3, 11), (-2, -3), (-2, -2), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-2, 11), (-2, 12), (-2, 13), (-2, 14), (-1, -7), (-1, -6), (-1, -5), (-1, -4)] + +def cache_605_H_part3 : List Cell := [(-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (-1, 10), (-1, 11), (-1, 12), (-1, 13), (0, -6), (0, -5), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0)] + +def cache_605_H_part4 : List Cell := [(0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (0, 11), (0, 12), (0, 13), (0, 14), (1, -7), (1, -6), (1, -5), (1, -4), (1, -3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3)] + +def cache_605_H_part5 : List Cell := [(1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10), (1, 11), (1, 12), (2, -6), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8)] + +def cache_605_H_part6 : List Cell := [(2, 9), (2, 10), (2, 11), (2, 12), (3, -5), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (3, 11), (3, 12), (4, -6), (4, -5)] + +def cache_605_H_part7 : List Cell := [(4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (4, 10), (4, 11), (4, 12), (5, -4), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2)] + +def cache_605_H_part8 : List Cell := [(5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8), (5, 9), (5, 10), (6, -6), (6, -5), (6, -4), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (6, 8), (6, 9)] + +def cache_605_H_part9 : List Cell := [(6, 10), (7, -6), (7, -5), (7, -4), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (7, 6), (7, 7), (7, 8), (7, 9), (7, 10), (8, -5), (8, -4), (8, -3), (8, -2), (8, -1), (8, 0)] + +def cache_605_H_part10 : List Cell := [(8, 1), (8, 2), (8, 3), (8, 4), (8, 5), (8, 6), (8, 7), (8, 8), (9, -6), (9, -5), (9, -4), (9, -3), (9, -2), (9, -1), (9, 0), (9, 1), (9, 2), (9, 3), (9, 4), (9, 5), (9, 6), (9, 7), (10, -4), (10, -3)] + +def cache_605_H_part11 : List Cell := [(10, -2), (10, -1), (10, 0), (10, 1), (10, 2), (10, 3), (10, 4), (10, 5), (10, 6), (10, 7), (11, -4), (11, -3), (11, -2), (11, -1), (11, 0), (11, 1), (11, 2), (11, 3), (11, 4), (12, -4), (12, -2), (12, -1), (12, 0), (12, 1)] + +def cache_605_H_part12 : List Cell := [(12, 2), (12, 3), (12, 4), (13, -2), (13, -1), (13, 0), (14, -2), (14, 0)] + +def cache_605_H : List Cell := (((cache_605_H_part0 ++ (cache_605_H_part1 ++ cache_605_H_part2)) ++ (cache_605_H_part3 ++ (cache_605_H_part4 ++ cache_605_H_part5))) ++ ((cache_605_H_part6 ++ (cache_605_H_part7 ++ cache_605_H_part8)) ++ ((cache_605_H_part9 ++ cache_605_H_part10) ++ (cache_605_H_part11 ++ cache_605_H_part12)))) + +def cache_605 : ListRow := ⟨cache_605_A, cache_605_H, 30⟩ + +def cache_606_A_part0 : List Cell := [(-1, -3), (0, -3), (0, -2), (2, -2)] + +def cache_606_A : List Cell := cache_606_A_part0 + +def cache_606_H_part0 : List Cell := [(-5, -1), (-5, 0), (-5, 1), (-5, 2), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 6), (-4, 7), (-4, 9), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 6), (-3, 7), (-3, 8), (-3, 9), (-2, -1)] + +def cache_606_H_part1 : List Cell := [(-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-2, 11), (-2, 12), (-1, -4), (-1, -3), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7)] + +def cache_606_H_part2 : List Cell := [(-1, 8), (-1, 9), (-1, 10), (-1, 11), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (0, 11), (0, 12), (0, 13), (0, 14), (1, -7), (1, -6)] + +def cache_606_H_part3 : List Cell := [(1, -5), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10), (1, 11), (1, 12), (1, 13), (2, -6), (2, -5), (2, -4), (2, -3), (2, -2)] + +def cache_606_H_part4 : List Cell := [(2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (2, 11), (2, 12), (2, 13), (2, 14), (3, -7), (3, -6), (3, -5), (3, -4), (3, -3), (3, -1), (3, 0), (3, 1)] + +def cache_606_H_part5 : List Cell := [(3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (3, 11), (3, 12), (4, -6), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6)] + +def cache_606_H_part6 : List Cell := [(4, 7), (4, 8), (4, 9), (4, 10), (4, 11), (4, 12), (5, -5), (5, -4), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8), (5, 9), (5, 10), (5, 11), (5, 12)] + +def cache_606_H_part7 : List Cell := [(6, -6), (6, -5), (6, -4), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (6, 8), (6, 9), (6, 10), (6, 11), (6, 12), (7, -4), (7, -3), (7, -2), (7, -1), (7, 0)] + +def cache_606_H_part8 : List Cell := [(7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (7, 6), (7, 7), (7, 8), (7, 9), (7, 10), (8, -6), (8, -5), (8, -4), (8, -3), (8, -2), (8, -1), (8, 0), (8, 1), (8, 2), (8, 3), (8, 4), (8, 5), (8, 6), (8, 7)] + +def cache_606_H_part9 : List Cell := [(8, 8), (8, 9), (8, 10), (9, -6), (9, -5), (9, -4), (9, -3), (9, -2), (9, -1), (9, 0), (9, 1), (9, 2), (9, 3), (9, 4), (9, 5), (9, 6), (9, 7), (9, 8), (9, 9), (9, 10), (10, -5), (10, -4), (10, -3), (10, -2)] + +def cache_606_H_part10 : List Cell := [(10, -1), (10, 0), (10, 1), (10, 2), (10, 3), (10, 4), (10, 5), (10, 6), (10, 7), (10, 8), (11, -6), (11, -5), (11, -4), (11, -3), (11, -2), (11, -1), (11, 0), (11, 1), (11, 2), (11, 3), (11, 4), (11, 5), (11, 6), (11, 7)] + +def cache_606_H_part11 : List Cell := [(12, -4), (12, -3), (12, -2), (12, -1), (12, 0), (12, 1), (12, 2), (12, 3), (12, 4), (12, 5), (12, 6), (12, 7), (13, -4), (13, -3), (13, -2), (13, -1), (13, 0), (13, 1), (13, 2), (13, 3), (13, 4), (14, -4), (14, -2), (14, -1)] + +def cache_606_H_part12 : List Cell := [(14, 0), (14, 1), (14, 2), (14, 3), (14, 4), (15, -2), (15, -1), (15, 0), (16, -2), (16, 0)] + +def cache_606_H : List Cell := (((cache_606_H_part0 ++ (cache_606_H_part1 ++ cache_606_H_part2)) ++ (cache_606_H_part3 ++ (cache_606_H_part4 ++ cache_606_H_part5))) ++ ((cache_606_H_part6 ++ (cache_606_H_part7 ++ cache_606_H_part8)) ++ ((cache_606_H_part9 ++ cache_606_H_part10) ++ (cache_606_H_part11 ++ cache_606_H_part12)))) + +def cache_606 : ListRow := ⟨cache_606_A, cache_606_H, 31⟩ + +def cache_607_A_part0 : List Cell := [(-1, -2), (0, -3), (0, -2), (0, -1)] + +def cache_607_A : List Cell := cache_607_A_part0 + +def cache_607_H_part0 : List Cell := [(-7, -1), (-7, 0), (-7, 1), (-7, 2), (-6, -1), (-6, 0), (-6, 1), (-6, 2), (-6, 6), (-6, 7), (-6, 9), (-5, -2), (-5, -1), (-5, 0), (-5, 1), (-5, 2), (-5, 4), (-5, 6), (-5, 7), (-5, 8), (-5, 9), (-4, -5), (-4, -4), (-4, -3)] + +def cache_607_H_part1 : List Cell := [(-4, -2), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7), (-4, 8), (-4, 9), (-4, 10), (-4, 11), (-4, 12), (-3, -4), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4)] + +def cache_607_H_part2 : List Cell := [(-3, 5), (-3, 6), (-3, 7), (-3, 8), (-3, 9), (-3, 10), (-3, 11), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-2, 11), (-2, 12), (-2, 13)] + +def cache_607_H_part3 : List Cell := [(-2, 14), (-1, -2), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (-1, 10), (-1, 11), (-1, 12), (-1, 13), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4)] + +def cache_607_H_part4 : List Cell := [(0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (0, 11), (0, 12), (0, 13), (0, 14), (1, -4), (1, -3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10)] + +def cache_607_H_part5 : List Cell := [(1, 11), (1, 12), (2, -6), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (2, 11), (2, 12), (3, -6), (3, -5), (3, -4)] + +def cache_607_H_part6 : List Cell := [(3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (3, 11), (3, 12), (4, -7), (4, -6), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0)] + +def cache_607_H_part7 : List Cell := [(4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (4, 10), (4, 11), (4, 12), (5, -8), (5, -7), (5, -6), (5, -5), (5, -4), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3)] + +def cache_607_H_part8 : List Cell := [(5, 4), (5, 5), (5, 6), (5, 7), (5, 8), (5, 9), (5, 10), (6, -7), (6, -6), (6, -5), (6, -4), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (6, 8), (6, 9)] + +def cache_607_H_part9 : List Cell := [(7, -8), (7, -7), (7, -6), (7, -5), (7, -4), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (7, 6), (7, 7), (7, 8), (7, 9), (8, -6), (8, -5), (8, -4), (8, -3), (8, -2), (8, -1)] + +def cache_607_H_part10 : List Cell := [(8, 0), (8, 1), (8, 2), (8, 3), (8, 4), (8, 5), (8, 6), (8, 7), (8, 8), (9, -6), (9, -5), (9, -4), (9, -3), (9, -2), (9, -1), (9, 0), (9, 1), (9, 2), (9, 3), (9, 4), (9, 5), (9, 6), (9, 7), (10, -6)] + +def cache_607_H_part11 : List Cell := [(10, -5), (10, -4), (10, -3), (10, -2), (10, -1), (10, 0), (10, 1), (10, 2), (10, 3), (10, 4), (10, 5), (10, 6), (10, 7), (11, -5), (11, -4), (11, -3), (11, -2), (11, -1), (11, 0), (11, 1), (11, 2), (11, 3), (12, -4), (12, -3)] + +def cache_607_H_part12 : List Cell := [(12, -2), (12, -1), (12, 0), (12, 1), (12, 3), (13, -4), (13, -3), (13, -2), (13, -1), (13, 0), (13, 1)] + +def cache_607_H : List Cell := (((cache_607_H_part0 ++ (cache_607_H_part1 ++ cache_607_H_part2)) ++ (cache_607_H_part3 ++ (cache_607_H_part4 ++ cache_607_H_part5))) ++ ((cache_607_H_part6 ++ (cache_607_H_part7 ++ cache_607_H_part8)) ++ ((cache_607_H_part9 ++ cache_607_H_part10) ++ (cache_607_H_part11 ++ cache_607_H_part12)))) + +def cache_607 : ListRow := ⟨cache_607_A, cache_607_H, 29⟩ + +def cache_608_A_part0 : List Cell := [(-1, -3), (-1, -2), (0, -2)] + +def cache_608_A : List Cell := cache_608_A_part0 + +def cache_608_H_part0 : List Cell := [(-9, -1), (-9, 1), (-9, 3), (-8, -1), (-8, 0), (-8, 1), (-8, 2), (-8, 3), (-7, -1), (-7, 0), (-7, 1), (-7, 2), (-7, 3), (-7, 4), (-7, 5), (-7, 6), (-7, 8), (-6, -3), (-6, -2), (-6, -1), (-6, 0), (-6, 1), (-6, 2), (-6, 3)] + +def cache_608_H_part1 : List Cell := [(-6, 4), (-6, 5), (-6, 6), (-6, 7), (-6, 8), (-5, -2), (-5, -1), (-5, 0), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-5, 5), (-5, 6), (-5, 7), (-5, 8), (-5, 9), (-5, 10), (-5, 11), (-4, -3), (-4, -2), (-4, -1), (-4, 0), (-4, 1)] + +def cache_608_H_part2 : List Cell := [(-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7), (-4, 8), (-4, 9), (-4, 10), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8), (-3, 9), (-3, 10), (-3, 11), (-3, 12)] + +def cache_608_H_part3 : List Cell := [(-3, 13), (-2, -3), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-2, 11), (-2, 12), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4)] + +def cache_608_H_part4 : List Cell := [(-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (-1, 10), (-1, 11), (-1, 12), (-1, 13), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (0, 11), (0, 12)] + +def cache_608_H_part5 : List Cell := [(0, 13), (0, 14), (1, -7), (1, -6), (1, -5), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10), (1, 11), (1, 12), (1, 13), (2, -7)] + +def cache_608_H_part6 : List Cell := [(2, -6), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (2, 11), (2, 12), (2, 13), (2, 14), (3, -7), (3, -6), (3, -5)] + +def cache_608_H_part7 : List Cell := [(3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (3, 11), (3, 12), (4, -7), (4, -6), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1)] + +def cache_608_H_part8 : List Cell := [(4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (4, 10), (4, 11), (4, 12), (5, -6), (5, -5), (5, -4), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4)] + +def cache_608_H_part9 : List Cell := [(5, 5), (5, 6), (5, 7), (5, 8), (5, 9), (5, 10), (5, 11), (5, 12), (6, -6), (6, -5), (6, -4), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (6, 8), (6, 9)] + +def cache_608_H_part10 : List Cell := [(6, 10), (6, 11), (6, 12), (7, -4), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (7, 6), (7, 7), (7, 8), (7, 9), (7, 10), (8, -6), (8, -5), (8, -4), (8, -3), (8, -2), (8, -1)] + +def cache_608_H_part11 : List Cell := [(8, 0), (8, 1), (8, 2), (8, 3), (8, 4), (8, 5), (8, 6), (8, 7), (8, 8), (8, 9), (8, 10), (9, -6), (9, -5), (9, -4), (9, -3), (9, -2), (9, -1), (9, 0), (9, 1), (9, 2), (9, 3), (9, 4), (9, 5), (9, 6)] + +def cache_608_H_part12 : List Cell := [(9, 7), (9, 8), (9, 9), (9, 10), (10, -5), (10, -4), (10, -3), (10, -2), (10, -1), (10, 0), (10, 1), (10, 2), (10, 3), (10, 4), (10, 5), (10, 6), (10, 7), (10, 8), (11, -6), (11, -5), (11, -4), (11, -3), (11, -2), (11, -1)] + +def cache_608_H_part13 : List Cell := [(11, 0), (11, 1), (11, 2), (11, 3), (11, 4), (11, 5), (11, 6), (11, 7), (12, -4), (12, -3), (12, -2), (12, -1), (12, 0), (12, 1), (12, 2), (12, 3), (12, 4), (12, 5), (12, 6), (12, 7), (13, -4), (13, -3), (13, -2), (13, -1)] + +def cache_608_H_part14 : List Cell := [(13, 0), (13, 1), (13, 2), (13, 3), (13, 4), (14, -4), (14, -2), (14, -1), (14, 0), (14, 1), (14, 2), (14, 3), (14, 4), (15, -2), (15, -1), (15, 0), (16, -2), (16, 0)] + +def cache_608_H : List Cell := (((cache_608_H_part0 ++ (cache_608_H_part1 ++ cache_608_H_part2)) ++ ((cache_608_H_part3 ++ cache_608_H_part4) ++ (cache_608_H_part5 ++ cache_608_H_part6))) ++ (((cache_608_H_part7 ++ cache_608_H_part8) ++ (cache_608_H_part9 ++ cache_608_H_part10)) ++ ((cache_608_H_part11 ++ cache_608_H_part12) ++ (cache_608_H_part13 ++ cache_608_H_part14)))) + +def cache_608 : ListRow := ⟨cache_608_A, cache_608_H, 32⟩ + +def cache_609_A_part0 : List Cell := [(0, -2), (0, -1), (1, -2), (2, -2)] + +def cache_609_A : List Cell := cache_609_A_part0 + +def cache_609_H_part0 : List Cell := [(-10, -2), (-10, -1), (-10, 0), (-10, 1), (-9, -2), (-9, -1), (-9, 0), (-9, 1), (-8, -2), (-8, -1), (-8, 0), (-8, 1), (-8, 2), (-8, 4), (-7, -4), (-7, -3), (-7, -2), (-7, -1), (-7, 0), (-7, 1), (-7, 2), (-7, 3), (-7, 4), (-7, 5)] + +def cache_609_H_part1 : List Cell := [(-6, -4), (-6, -3), (-6, -2), (-6, -1), (-6, 0), (-6, 1), (-6, 2), (-6, 3), (-6, 4), (-5, -4), (-5, -3), (-5, -2), (-5, -1), (-5, 0), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-4, -4), (-4, -3), (-4, -2), (-4, -1), (-4, 0), (-4, 1)] + +def cache_609_H_part2 : List Cell := [(-4, 2), (-4, 3), (-4, 4), (-4, 6), (-4, 7), (-4, 9), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8), (-3, 9), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 1)] + +def cache_609_H_part3 : List Cell := [(-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-2, 11), (-2, 12), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (-1, 10), (-1, 11)] + +def cache_609_H_part4 : List Cell := [(0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (0, 11), (0, 12), (0, 13), (0, 14), (1, -7), (1, -6), (1, -5), (1, -4), (1, -3), (1, -2), (1, 0)] + +def cache_609_H_part5 : List Cell := [(1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10), (1, 11), (1, 12), (1, 13), (2, -6), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4)] + +def cache_609_H_part6 : List Cell := [(2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (2, 11), (2, 12), (2, 13), (2, 14), (3, -6), (3, -5), (3, -4), (3, -3), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8)] + +def cache_609_H_part7 : List Cell := [(3, 9), (3, 10), (3, 11), (3, 12), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (4, 10), (4, 11), (4, 12), (5, -4), (5, -3)] + +def cache_609_H_part8 : List Cell := [(5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8), (5, 9), (5, 10), (5, 11), (5, 12), (6, -5), (6, -4), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3)] + +def cache_609_H_part9 : List Cell := [(6, 4), (6, 5), (6, 6), (6, 7), (6, 8), (6, 9), (6, 10), (6, 11), (6, 12), (7, -4), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (7, 6), (7, 7), (7, 8), (7, 9), (7, 10)] + +def cache_609_H_part10 : List Cell := [(8, -6), (8, -5), (8, -4), (8, -3), (8, -2), (8, -1), (8, 0), (8, 1), (8, 2), (8, 3), (8, 4), (8, 5), (8, 6), (8, 7), (8, 8), (8, 9), (8, 10), (9, -6), (9, -5), (9, -4), (9, -3), (9, -2), (9, -1), (9, 0)] + +def cache_609_H_part11 : List Cell := [(9, 1), (9, 2), (9, 3), (9, 4), (9, 5), (9, 6), (9, 7), (9, 8), (9, 9), (9, 10), (10, -5), (10, -4), (10, -3), (10, -2), (10, -1), (10, 0), (10, 1), (10, 2), (10, 3), (10, 4), (10, 5), (10, 6), (10, 7), (10, 8)] + +def cache_609_H_part12 : List Cell := [(11, -6), (11, -5), (11, -4), (11, -3), (11, -2), (11, -1), (11, 0), (11, 1), (11, 2), (11, 3), (11, 4), (11, 5), (11, 6), (11, 7), (12, -4), (12, -3), (12, -2), (12, -1), (12, 0), (12, 1), (12, 2), (12, 3), (12, 4), (12, 5)] + +def cache_609_H_part13 : List Cell := [(12, 6), (12, 7), (13, -4), (13, -3), (13, -2), (13, -1), (13, 0), (13, 1), (13, 2), (13, 3), (13, 4), (14, -4), (14, -2), (14, -1), (14, 0), (14, 1), (14, 2), (14, 3), (14, 4), (15, -2), (15, -1), (15, 0), (16, -2), (16, 0)] + +def cache_609_H : List Cell := (((cache_609_H_part0 ++ (cache_609_H_part1 ++ cache_609_H_part2)) ++ ((cache_609_H_part3 ++ cache_609_H_part4) ++ (cache_609_H_part5 ++ cache_609_H_part6))) ++ ((cache_609_H_part7 ++ (cache_609_H_part8 ++ cache_609_H_part9)) ++ ((cache_609_H_part10 ++ cache_609_H_part11) ++ (cache_609_H_part12 ++ cache_609_H_part13)))) + +def cache_609 : ListRow := ⟨cache_609_A, cache_609_H, 31⟩ + +def cache_610_A_part0 : List Cell := [(-2, 0), (-2, 1), (-1, 0)] + +def cache_610_A : List Cell := cache_610_A_part0 + +def cache_610_H_part0 : List Cell := [(-12, 0), (-12, 1), (-12, 2), (-12, 3), (-11, 0), (-11, 1), (-11, 2), (-11, 3), (-10, 0), (-10, 1), (-10, 2), (-10, 3), (-10, 4), (-10, 6), (-9, -2), (-9, -1), (-9, 0), (-9, 1), (-9, 2), (-9, 3), (-9, 4), (-9, 5), (-9, 6), (-9, 7)] + +def cache_610_H_part1 : List Cell := [(-8, -2), (-8, -1), (-8, 0), (-8, 1), (-8, 2), (-8, 3), (-8, 4), (-8, 5), (-8, 6), (-7, -2), (-7, -1), (-7, 0), (-7, 1), (-7, 2), (-7, 3), (-7, 4), (-7, 5), (-7, 6), (-6, -2), (-6, -1), (-6, 0), (-6, 1), (-6, 2), (-6, 3)] + +def cache_610_H_part2 : List Cell := [(-6, 4), (-6, 5), (-6, 6), (-6, 8), (-6, 9), (-6, 11), (-5, -1), (-5, 0), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-5, 5), (-5, 6), (-5, 7), (-5, 8), (-5, 9), (-5, 10), (-5, 11), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3)] + +def cache_610_H_part3 : List Cell := [(-4, 4), (-4, 5), (-4, 6), (-4, 7), (-4, 8), (-4, 9), (-4, 10), (-4, 11), (-4, 12), (-4, 13), (-4, 14), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8), (-3, 9), (-3, 10), (-3, 11), (-3, 12), (-3, 13)] + +def cache_610_H_part4 : List Cell := [(-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-2, 11), (-2, 12), (-2, 13), (-2, 14), (-2, 15), (-2, 16), (-1, -5), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 2)] + +def cache_610_H_part5 : List Cell := [(-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (-1, 10), (-1, 11), (-1, 12), (-1, 13), (-1, 14), (-1, 15), (0, -5), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5)] + +def cache_610_H_part6 : List Cell := [(0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (0, 11), (0, 12), (0, 13), (0, 14), (0, 15), (0, 16), (1, -5), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7)] + +def cache_610_H_part7 : List Cell := [(1, 8), (1, 9), (1, 10), (1, 11), (1, 12), (1, 13), (1, 14), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (2, 11)] + +def cache_610_H_part8 : List Cell := [(2, 12), (2, 13), (2, 14), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (3, 11), (3, 12), (3, 13), (3, 14), (4, -3), (4, -2), (4, -1)] + +def cache_610_H_part9 : List Cell := [(4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (4, 10), (4, 11), (4, 12), (4, 13), (4, 14), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5)] + +def cache_610_H_part10 : List Cell := [(5, 6), (5, 7), (5, 8), (5, 9), (5, 10), (5, 11), (5, 12), (6, -4), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (6, 8), (6, 9), (6, 10), (6, 11), (6, 12)] + +def cache_610_H_part11 : List Cell := [(7, -4), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (7, 6), (7, 7), (7, 8), (7, 9), (7, 10), (7, 11), (7, 12), (8, -3), (8, -2), (8, -1), (8, 0), (8, 1), (8, 2), (8, 3)] + +def cache_610_H_part12 : List Cell := [(8, 4), (8, 5), (8, 6), (8, 7), (8, 8), (8, 9), (8, 10), (9, -4), (9, -3), (9, -2), (9, -1), (9, 0), (9, 1), (9, 2), (9, 3), (9, 4), (9, 5), (9, 6), (9, 7), (9, 8), (9, 9), (10, -2), (10, -1), (10, 0)] + +def cache_610_H_part13 : List Cell := [(10, 1), (10, 2), (10, 3), (10, 4), (10, 5), (10, 6), (10, 7), (10, 8), (10, 9), (11, -2), (11, -1), (11, 0), (11, 1), (11, 2), (11, 3), (11, 4), (11, 5), (11, 6), (12, -2), (12, 0), (12, 1), (12, 2), (12, 3), (12, 4)] + +def cache_610_H_part14 : List Cell := [(12, 5), (12, 6), (13, 0), (13, 1), (13, 2), (14, 0), (14, 2)] + +def cache_610_H : List Cell := (((cache_610_H_part0 ++ (cache_610_H_part1 ++ cache_610_H_part2)) ++ ((cache_610_H_part3 ++ cache_610_H_part4) ++ (cache_610_H_part5 ++ cache_610_H_part6))) ++ (((cache_610_H_part7 ++ cache_610_H_part8) ++ (cache_610_H_part9 ++ cache_610_H_part10)) ++ ((cache_610_H_part11 ++ cache_610_H_part12) ++ (cache_610_H_part13 ++ cache_610_H_part14)))) + +def cache_610 : ListRow := ⟨cache_610_A, cache_610_H, 32⟩ + +def cache_611_A_part0 : List Cell := [(-2, 0), (-1, 0)] + +def cache_611_A : List Cell := cache_611_A_part0 + +def cache_611_H_part0 : List Cell := [(-16, 0), (-16, 2), (-15, 0), (-15, 1), (-15, 2), (-14, -4), (-14, -3), (-14, -2), (-14, -1), (-14, 0), (-14, 1), (-14, 2), (-14, 4), (-13, -4), (-13, -3), (-13, -2), (-13, -1), (-13, 0), (-13, 1), (-13, 2), (-13, 3), (-13, 4), (-12, -5), (-12, -4)] + +def cache_611_H_part1 : List Cell := [(-12, -3), (-12, -2), (-12, -1), (-12, 0), (-12, 1), (-12, 2), (-12, 3), (-12, 4), (-11, -7), (-11, -6), (-11, -5), (-11, -4), (-11, -3), (-11, -2), (-11, -1), (-11, 0), (-11, 1), (-11, 2), (-11, 3), (-11, 4), (-11, 5), (-11, 6), (-10, -8), (-10, -7)] + +def cache_611_H_part2 : List Cell := [(-10, -6), (-10, -5), (-10, -4), (-10, -3), (-10, -2), (-10, -1), (-10, 0), (-10, 1), (-10, 2), (-10, 3), (-10, 4), (-10, 5), (-9, -10), (-9, -9), (-9, -8), (-9, -7), (-9, -6), (-9, -5), (-9, -4), (-9, -3), (-9, -2), (-9, -1), (-9, 0), (-9, 1)] + +def cache_611_H_part3 : List Cell := [(-9, 2), (-9, 3), (-9, 4), (-9, 5), (-9, 6), (-8, -10), (-8, -9), (-8, -8), (-8, -7), (-8, -6), (-8, -5), (-8, -4), (-8, -3), (-8, -2), (-8, -1), (-8, 0), (-8, 1), (-8, 2), (-8, 3), (-8, 4), (-8, 5), (-8, 6), (-7, -10), (-7, -9)] + +def cache_611_H_part4 : List Cell := [(-7, -8), (-7, -7), (-7, -6), (-7, -5), (-7, -4), (-7, -3), (-7, -2), (-7, -1), (-7, 0), (-7, 1), (-7, 2), (-7, 3), (-7, 4), (-6, -10), (-6, -9), (-6, -8), (-6, -7), (-6, -6), (-6, -5), (-6, -4), (-6, -3), (-6, -2), (-6, -1), (-6, 0)] + +def cache_611_H_part5 : List Cell := [(-6, 1), (-6, 2), (-6, 3), (-6, 4), (-6, 5), (-5, -12), (-5, -11), (-5, -10), (-5, -9), (-5, -8), (-5, -7), (-5, -6), (-5, -5), (-5, -4), (-5, -3), (-5, -2), (-5, -1), (-5, 0), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-4, -11), (-4, -10)] + +def cache_611_H_part6 : List Cell := [(-4, -9), (-4, -8), (-4, -7), (-4, -6), (-4, -5), (-4, -4), (-4, -3), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-3, -12), (-3, -11), (-3, -10), (-3, -9), (-3, -8), (-3, -7), (-3, -6), (-3, -5), (-3, -4)] + +def cache_611_H_part7 : List Cell := [(-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-2, -9), (-2, -8), (-2, -7), (-2, -6), (-2, -5), (-2, -4), (-2, -3), (-2, -2), (-2, -1), (-2, 0), (-2, 2), (-2, 3), (-2, 4)] + +def cache_611_H_part8 : List Cell := [(-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-1, -8), (-1, -7), (-1, -6), (-1, -5), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (0, -9), (0, -8)] + +def cache_611_H_part9 : List Cell := [(0, -7), (0, -6), (0, -5), (0, -4), (0, -3), (0, -2), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (1, -7), (1, -6), (1, -5), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0)] + +def cache_611_H_part10 : List Cell := [(1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10), (1, 11), (1, 12), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6)] + +def cache_611_H_part11 : List Cell := [(2, 7), (2, 8), (2, 9), (2, 10), (2, 11), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (3, 11), (3, 12), (4, -5), (4, -4)] + +def cache_611_H_part12 : List Cell := [(4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (4, 10), (5, -4), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5)] + +def cache_611_H_part13 : List Cell := [(5, 6), (5, 7), (5, 8), (5, 9), (5, 10), (6, -6), (6, -5), (6, -4), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (6, 8), (6, 9), (6, 10), (7, -6), (7, -5)] + +def cache_611_H_part14 : List Cell := [(7, -4), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (7, 6), (7, 7), (7, 8), (7, 9), (7, 10), (8, -5), (8, -4), (8, -3), (8, -2), (8, -1), (8, 0), (8, 1), (8, 2), (8, 3)] + +def cache_611_H_part15 : List Cell := [(8, 4), (8, 5), (8, 6), (8, 7), (8, 8), (9, -6), (9, -5), (9, -4), (9, -3), (9, -2), (9, -1), (9, 0), (9, 1), (9, 2), (9, 3), (9, 4), (9, 5), (9, 6), (9, 7), (10, -4), (10, -3), (10, -2), (10, -1), (10, 0)] + +def cache_611_H_part16 : List Cell := [(10, 1), (10, 2), (10, 3), (10, 4), (10, 5), (11, -4), (11, -3), (11, -2), (11, -1), (11, 0), (11, 1), (11, 2), (11, 3), (11, 4), (12, -4), (12, -2), (12, -1), (12, 0), (12, 1), (12, 2), (12, 3), (12, 4), (13, -2), (13, -1)] + +def cache_611_H_part17 : List Cell := [(13, 0), (14, -2), (14, 0)] + +def cache_611_H : List Cell := ((((cache_611_H_part0 ++ cache_611_H_part1) ++ (cache_611_H_part2 ++ cache_611_H_part3)) ++ ((cache_611_H_part4 ++ cache_611_H_part5) ++ (cache_611_H_part6 ++ (cache_611_H_part7 ++ cache_611_H_part8)))) ++ (((cache_611_H_part9 ++ cache_611_H_part10) ++ (cache_611_H_part11 ++ cache_611_H_part12)) ++ ((cache_611_H_part13 ++ cache_611_H_part14) ++ (cache_611_H_part15 ++ (cache_611_H_part16 ++ cache_611_H_part17))))) + +def cache_611 : ListRow := ⟨cache_611_A, cache_611_H, 29⟩ + +def cache_612_A_part0 : List Cell := [(-3, 0), (-2, 0), (-1, 0)] + +def cache_612_A : List Cell := cache_612_A_part0 + +def cache_612_H_part0 : List Cell := [(-17, 0), (-17, 2), (-16, 0), (-16, 1), (-16, 2), (-15, -4), (-15, -3), (-15, -2), (-15, -1), (-15, 0), (-15, 1), (-15, 2), (-15, 4), (-14, -4), (-14, -3), (-14, -2), (-14, -1), (-14, 0), (-14, 1), (-14, 2), (-14, 3), (-14, 4), (-13, -5), (-13, -4)] + +def cache_612_H_part1 : List Cell := [(-13, -3), (-13, -2), (-13, -1), (-13, 0), (-13, 1), (-13, 2), (-13, 3), (-13, 4), (-12, -7), (-12, -6), (-12, -5), (-12, -4), (-12, -3), (-12, -2), (-12, -1), (-12, 0), (-12, 1), (-12, 2), (-12, 3), (-12, 4), (-12, 5), (-12, 6), (-11, -8), (-11, -7)] + +def cache_612_H_part2 : List Cell := [(-11, -6), (-11, -5), (-11, -4), (-11, -3), (-11, -2), (-11, -1), (-11, 0), (-11, 1), (-11, 2), (-11, 3), (-11, 4), (-11, 5), (-10, -10), (-10, -9), (-10, -8), (-10, -7), (-10, -6), (-10, -5), (-10, -4), (-10, -3), (-10, -2), (-10, -1), (-10, 0), (-10, 1)] + +def cache_612_H_part3 : List Cell := [(-10, 2), (-10, 3), (-10, 4), (-10, 5), (-10, 6), (-9, -10), (-9, -9), (-9, -8), (-9, -7), (-9, -6), (-9, -5), (-9, -4), (-9, -3), (-9, -2), (-9, -1), (-9, 0), (-9, 1), (-9, 2), (-9, 3), (-9, 4), (-9, 5), (-9, 6), (-8, -10), (-8, -9)] + +def cache_612_H_part4 : List Cell := [(-8, -8), (-8, -7), (-8, -6), (-8, -5), (-8, -4), (-8, -3), (-8, -2), (-8, -1), (-8, 0), (-8, 1), (-8, 2), (-8, 3), (-8, 4), (-7, -10), (-7, -9), (-7, -8), (-7, -7), (-7, -6), (-7, -5), (-7, -4), (-7, -3), (-7, -2), (-7, -1), (-7, 0)] + +def cache_612_H_part5 : List Cell := [(-7, 1), (-7, 2), (-7, 3), (-7, 4), (-7, 5), (-6, -12), (-6, -11), (-6, -10), (-6, -9), (-6, -8), (-6, -7), (-6, -6), (-6, -5), (-6, -4), (-6, -3), (-6, -2), (-6, -1), (-6, 0), (-6, 1), (-6, 2), (-6, 3), (-6, 4), (-5, -11), (-5, -10)] + +def cache_612_H_part6 : List Cell := [(-5, -9), (-5, -8), (-5, -7), (-5, -6), (-5, -5), (-5, -4), (-5, -3), (-5, -2), (-5, -1), (-5, 0), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-4, -12), (-4, -11), (-4, -10), (-4, -9), (-4, -8), (-4, -7), (-4, -6), (-4, -5), (-4, -4), (-4, -3)] + +def cache_612_H_part7 : List Cell := [(-4, -2), (-4, -1), (-4, 0), (-4, 1), (-4, 3), (-4, 5), (-3, -8), (-3, -7), (-3, -6), (-3, -5), (-3, -4), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-2, -8), (-2, -7), (-2, -6), (-2, -5), (-2, -4)] + +def cache_612_H_part8 : List Cell := [(-2, -3), (-2, -2), (-2, 0), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-1, -8), (-1, -7), (-1, -6), (-1, -5), (-1, -4), (-1, -3), (-1, -2), (-1, 0), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7)] + +def cache_612_H_part9 : List Cell := [(-1, 8), (0, -5), (0, -4), (0, -3), (0, -2), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (1, -5), (1, -3), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6)] + +def cache_612_H_part10 : List Cell := [(1, 7), (1, 8), (1, 9), (1, 10), (1, 11), (1, 12), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (2, 11), (3, -4), (3, -3)] + +def cache_612_H_part11 : List Cell := [(3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (3, 11), (3, 12), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3)] + +def cache_612_H_part12 : List Cell := [(4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (4, 10), (5, -4), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8), (5, 9), (5, 10), (6, -6), (6, -5)] + +def cache_612_H_part13 : List Cell := [(6, -4), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (6, 8), (6, 9), (6, 10), (7, -6), (7, -5), (7, -4), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2)] + +def cache_612_H_part14 : List Cell := [(7, 3), (7, 4), (7, 5), (7, 6), (7, 7), (7, 8), (7, 9), (7, 10), (8, -5), (8, -4), (8, -3), (8, -2), (8, -1), (8, 0), (8, 1), (8, 2), (8, 3), (8, 4), (8, 5), (8, 6), (8, 7), (8, 8), (9, -6), (9, -5)] + +def cache_612_H_part15 : List Cell := [(9, -4), (9, -3), (9, -2), (9, -1), (9, 0), (9, 1), (9, 2), (9, 3), (9, 4), (9, 5), (9, 6), (9, 7), (10, -4), (10, -3), (10, -2), (10, -1), (10, 0), (10, 1), (10, 2), (10, 3), (10, 4), (10, 5), (11, -4), (11, -3)] + +def cache_612_H_part16 : List Cell := [(11, -2), (11, -1), (11, 0), (11, 1), (11, 2), (11, 3), (11, 4), (12, -4), (12, -2), (12, -1), (12, 0), (12, 1), (12, 2), (12, 3), (12, 4), (13, -2), (13, -1), (13, 0), (14, -2), (14, 0)] + +def cache_612_H : List Cell := ((((cache_612_H_part0 ++ cache_612_H_part1) ++ (cache_612_H_part2 ++ cache_612_H_part3)) ++ ((cache_612_H_part4 ++ cache_612_H_part5) ++ (cache_612_H_part6 ++ cache_612_H_part7))) ++ (((cache_612_H_part8 ++ cache_612_H_part9) ++ (cache_612_H_part10 ++ cache_612_H_part11)) ++ ((cache_612_H_part12 ++ cache_612_H_part13) ++ (cache_612_H_part14 ++ (cache_612_H_part15 ++ cache_612_H_part16))))) + +def cache_612 : ListRow := ⟨cache_612_A, cache_612_H, 29⟩ + +def cache_613_A_part0 : List Cell := [(-2, 0), (-1, 0), (-1, 1)] + +def cache_613_A : List Cell := cache_613_A_part0 + +def cache_613_H_part0 : List Cell := [(-17, -2), (-17, 0), (-17, 2), (-16, -2), (-16, -1), (-16, 0), (-16, 1), (-16, 2), (-15, -4), (-15, -3), (-15, -2), (-15, -1), (-15, 0), (-15, 1), (-15, 2), (-15, 3), (-15, 4), (-14, -4), (-14, -3), (-14, -2), (-14, -1), (-14, 0), (-14, 1), (-14, 2)] + +def cache_613_H_part1 : List Cell := [(-14, 3), (-14, 4), (-13, -5), (-13, -4), (-13, -3), (-13, -2), (-13, -1), (-13, 0), (-13, 1), (-13, 2), (-13, 3), (-13, 4), (-13, 5), (-12, -7), (-12, -6), (-12, -5), (-12, -4), (-12, -3), (-12, -2), (-12, -1), (-12, 0), (-12, 1), (-12, 2), (-12, 3)] + +def cache_613_H_part2 : List Cell := [(-12, 4), (-12, 5), (-12, 6), (-12, 7), (-11, -8), (-11, -7), (-11, -6), (-11, -5), (-11, -4), (-11, -3), (-11, -2), (-11, -1), (-11, 0), (-11, 1), (-11, 2), (-11, 3), (-11, 4), (-11, 5), (-11, 6), (-11, 7), (-11, 8), (-10, -10), (-10, -9), (-10, -8)] + +def cache_613_H_part3 : List Cell := [(-10, -7), (-10, -6), (-10, -5), (-10, -4), (-10, -3), (-10, -2), (-10, -1), (-10, 0), (-10, 1), (-10, 2), (-10, 3), (-10, 4), (-10, 5), (-10, 6), (-10, 7), (-10, 8), (-10, 9), (-10, 10), (-9, -10), (-9, -9), (-9, -8), (-9, -7), (-9, -6), (-9, -5)] + +def cache_613_H_part4 : List Cell := [(-9, -4), (-9, -3), (-9, -2), (-9, -1), (-9, 0), (-9, 1), (-9, 2), (-9, 3), (-9, 4), (-9, 5), (-9, 6), (-9, 7), (-9, 8), (-9, 9), (-9, 10), (-8, -10), (-8, -9), (-8, -8), (-8, -7), (-8, -6), (-8, -5), (-8, -4), (-8, -3), (-8, -2)] + +def cache_613_H_part5 : List Cell := [(-8, -1), (-8, 0), (-8, 1), (-8, 2), (-8, 3), (-8, 4), (-8, 5), (-8, 6), (-8, 7), (-8, 8), (-8, 9), (-8, 10), (-7, -10), (-7, -9), (-7, -8), (-7, -7), (-7, -6), (-7, -5), (-7, -4), (-7, -3), (-7, -2), (-7, -1), (-7, 0), (-7, 1)] + +def cache_613_H_part6 : List Cell := [(-7, 2), (-7, 3), (-7, 4), (-7, 5), (-7, 6), (-7, 7), (-7, 8), (-7, 9), (-7, 10), (-6, -12), (-6, -11), (-6, -10), (-6, -9), (-6, -8), (-6, -7), (-6, -6), (-6, -5), (-6, -4), (-6, -3), (-6, -2), (-6, -1), (-6, 0), (-6, 1), (-6, 2)] + +def cache_613_H_part7 : List Cell := [(-6, 3), (-6, 4), (-6, 5), (-6, 6), (-6, 7), (-6, 8), (-6, 9), (-6, 10), (-6, 11), (-6, 12), (-5, -12), (-5, -11), (-5, -10), (-5, -9), (-5, -8), (-5, -7), (-5, -6), (-5, -5), (-5, -4), (-5, -3), (-5, -2), (-5, -1), (-5, 0), (-5, 1)] + +def cache_613_H_part8 : List Cell := [(-5, 2), (-5, 3), (-5, 4), (-5, 5), (-5, 6), (-5, 7), (-5, 8), (-5, 9), (-5, 10), (-5, 11), (-4, -13), (-4, -12), (-4, -11), (-4, -10), (-4, -9), (-4, -8), (-4, -7), (-4, -6), (-4, -5), (-4, -4), (-4, -3), (-4, -2), (-4, -1), (-4, 0)] + +def cache_613_H_part9 : List Cell := [(-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7), (-4, 8), (-4, 9), (-4, 10), (-4, 11), (-4, 12), (-3, -13), (-3, -12), (-3, -11), (-3, -10), (-3, -9), (-3, -8), (-3, -7), (-3, -6), (-3, -5), (-3, -4), (-3, -3), (-3, -2)] + +def cache_613_H_part10 : List Cell := [(-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8), (-2, -13), (-2, -12), (-2, -11), (-2, -10), (-2, -9), (-2, -8), (-2, -7), (-2, -6), (-2, -5), (-2, -4), (-2, -3), (-2, -2), (-2, -1), (-2, 0)] + +def cache_613_H_part11 : List Cell := [(-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-1, -13), (-1, -12), (-1, -11), (-1, -10), (-1, -9), (-1, -8), (-1, -7), (-1, -6), (-1, -5), (-1, -4), (-1, -3), (-1, -2), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4)] + +def cache_613_H_part12 : List Cell := [(-1, 5), (-1, 6), (-1, 7), (-1, 8), (0, -13), (0, -12), (0, -11), (0, -10), (0, -9), (0, -8), (0, -7), (0, -6), (0, -5), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7)] + +def cache_613_H_part13 : List Cell := [(0, 8), (1, -13), (1, -12), (1, -11), (1, -10), (1, -9), (1, -8), (1, -7), (1, -6), (1, -5), (1, -4), (1, -3), (1, -2), (1, -1), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (2, -13)] + +def cache_613_H_part14 : List Cell := [(2, -12), (2, -11), (2, -10), (2, -9), (2, -8), (2, -7), (2, -6), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (2, 11)] + +def cache_613_H_part15 : List Cell := [(2, 12), (3, -12), (3, -11), (3, -10), (3, -9), (3, -8), (3, -7), (3, -6), (3, -5), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10)] + +def cache_613_H_part16 : List Cell := [(3, 11), (4, -12), (4, -11), (4, -10), (4, -9), (4, -8), (4, -7), (4, -6), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (4, 10)] + +def cache_613_H_part17 : List Cell := [(4, 11), (4, 12), (5, -10), (5, -9), (5, -8), (5, -7), (5, -6), (5, -5), (5, -4), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8), (5, 9), (5, 10), (6, -10)] + +def cache_613_H_part18 : List Cell := [(6, -9), (6, -8), (6, -7), (6, -6), (6, -5), (6, -4), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (6, 8), (6, 9), (6, 10), (7, -10), (7, -9), (7, -8), (7, -7)] + +def cache_613_H_part19 : List Cell := [(7, -6), (7, -5), (7, -4), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (7, 6), (7, 7), (7, 8), (7, 9), (7, 10), (8, -10), (8, -9), (8, -8), (8, -7), (8, -6), (8, -5), (8, -4)] + +def cache_613_H_part20 : List Cell := [(8, -3), (8, -2), (8, -1), (8, 0), (8, 1), (8, 2), (8, 3), (8, 4), (8, 5), (8, 6), (8, 7), (8, 8), (8, 9), (8, 10), (9, -8), (9, -7), (9, -6), (9, -5), (9, -4), (9, -3), (9, -2), (9, -1), (9, 0), (9, 1)] + +def cache_613_H_part21 : List Cell := [(9, 2), (9, 3), (9, 4), (9, 5), (9, 6), (9, 7), (9, 8), (10, -7), (10, -6), (10, -5), (10, -4), (10, -3), (10, -2), (10, -1), (10, 0), (10, 1), (10, 2), (10, 3), (10, 4), (10, 5), (10, 6), (10, 7), (11, -5), (11, -4)] + +def cache_613_H_part22 : List Cell := [(11, -3), (11, -2), (11, -1), (11, 0), (11, 1), (11, 2), (11, 3), (11, 4), (11, 5), (12, -4), (12, -3), (12, -2), (12, -1), (12, 0), (12, 1), (12, 2), (12, 3), (12, 4), (13, -4), (13, -3), (13, -2), (13, -1), (13, 0), (13, 1)] + +def cache_613_H_part23 : List Cell := [(13, 2), (13, 3), (13, 4), (14, -2), (14, -1), (14, 0), (14, 1), (14, 2), (15, -2), (15, 0), (15, 2)] + +def cache_613_H : List Cell := ((((cache_613_H_part0 ++ (cache_613_H_part1 ++ cache_613_H_part2)) ++ (cache_613_H_part3 ++ (cache_613_H_part4 ++ cache_613_H_part5))) ++ ((cache_613_H_part6 ++ (cache_613_H_part7 ++ cache_613_H_part8)) ++ (cache_613_H_part9 ++ (cache_613_H_part10 ++ cache_613_H_part11)))) ++ (((cache_613_H_part12 ++ (cache_613_H_part13 ++ cache_613_H_part14)) ++ (cache_613_H_part15 ++ (cache_613_H_part16 ++ cache_613_H_part17))) ++ ((cache_613_H_part18 ++ (cache_613_H_part19 ++ cache_613_H_part20)) ++ (cache_613_H_part21 ++ (cache_613_H_part22 ++ cache_613_H_part23))))) + +def cache_613 : ListRow := ⟨cache_613_A, cache_613_H, 30⟩ + +def cache_614_A_part0 : List Cell := [(1, 0), (1, 1)] + +def cache_614_A : List Cell := cache_614_A_part0 + +def cache_614_H_part0 : List Cell := [(-15, -2), (-15, 0), (-15, 2), (-14, -2), (-14, -1), (-14, 0), (-14, 1), (-14, 2), (-13, -4), (-13, -3), (-13, -2), (-13, -1), (-13, 0), (-13, 1), (-13, 2), (-13, 3), (-13, 4), (-13, 5), (-13, 6), (-12, -4), (-12, -3), (-12, -2), (-12, -1), (-12, 0)] + +def cache_614_H_part1 : List Cell := [(-12, 1), (-12, 2), (-12, 3), (-12, 4), (-12, 5), (-12, 6), (-11, -5), (-11, -4), (-11, -3), (-11, -2), (-11, -1), (-11, 0), (-11, 1), (-11, 2), (-11, 3), (-11, 4), (-11, 5), (-11, 6), (-11, 7), (-11, 8), (-11, 9), (-10, -7), (-10, -6), (-10, -5)] + +def cache_614_H_part2 : List Cell := [(-10, -4), (-10, -3), (-10, -2), (-10, -1), (-10, 0), (-10, 1), (-10, 2), (-10, 3), (-10, 4), (-10, 5), (-10, 6), (-10, 7), (-10, 8), (-10, 9), (-9, -8), (-9, -7), (-9, -6), (-9, -5), (-9, -4), (-9, -3), (-9, -2), (-9, -1), (-9, 0), (-9, 1)] + +def cache_614_H_part3 : List Cell := [(-9, 2), (-9, 3), (-9, 4), (-9, 5), (-9, 6), (-9, 7), (-9, 8), (-9, 9), (-9, 10), (-8, -10), (-8, -9), (-8, -8), (-8, -7), (-8, -6), (-8, -5), (-8, -4), (-8, -3), (-8, -2), (-8, -1), (-8, 0), (-8, 1), (-8, 2), (-8, 3), (-8, 4)] + +def cache_614_H_part4 : List Cell := [(-8, 5), (-8, 6), (-8, 7), (-8, 8), (-8, 9), (-8, 10), (-8, 11), (-8, 12), (-7, -10), (-7, -9), (-7, -8), (-7, -7), (-7, -6), (-7, -5), (-7, -4), (-7, -3), (-7, -2), (-7, -1), (-7, 0), (-7, 1), (-7, 2), (-7, 3), (-7, 4), (-7, 5)] + +def cache_614_H_part5 : List Cell := [(-7, 6), (-7, 7), (-7, 8), (-7, 9), (-7, 10), (-7, 11), (-7, 12), (-6, -10), (-6, -9), (-6, -8), (-6, -7), (-6, -6), (-6, -5), (-6, -4), (-6, -3), (-6, -2), (-6, -1), (-6, 0), (-6, 1), (-6, 2), (-6, 3), (-6, 4), (-6, 5), (-6, 6)] + +def cache_614_H_part6 : List Cell := [(-6, 7), (-6, 8), (-6, 9), (-6, 10), (-6, 11), (-6, 12), (-5, -10), (-5, -9), (-5, -8), (-5, -7), (-5, -6), (-5, -5), (-5, -4), (-5, -3), (-5, -2), (-5, -1), (-5, 0), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-5, 5), (-5, 6), (-5, 7)] + +def cache_614_H_part7 : List Cell := [(-5, 8), (-5, 9), (-5, 10), (-5, 11), (-5, 12), (-5, 13), (-5, 14), (-4, -12), (-4, -11), (-4, -10), (-4, -9), (-4, -8), (-4, -7), (-4, -6), (-4, -5), (-4, -4), (-4, -3), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4)] + +def cache_614_H_part8 : List Cell := [(-4, 5), (-4, 6), (-4, 7), (-4, 8), (-4, 9), (-4, 10), (-4, 11), (-4, 12), (-4, 13), (-4, 14), (-3, -12), (-3, -11), (-3, -10), (-3, -9), (-3, -8), (-3, -7), (-3, -6), (-3, -5), (-3, -4), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1)] + +def cache_614_H_part9 : List Cell := [(-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6), (-3, 7), (-3, 8), (-3, 9), (-3, 10), (-3, 11), (-3, 12), (-3, 13), (-3, 14), (-2, -13), (-2, -12), (-2, -11), (-2, -10), (-2, -9), (-2, -8), (-2, -7), (-2, -6), (-2, -5), (-2, -4), (-2, -3)] + +def cache_614_H_part10 : List Cell := [(-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-2, 11), (-2, 12), (-2, 13), (-2, 14), (-1, -13), (-1, -12), (-1, -11), (-1, -10), (-1, -9), (-1, -8), (-1, -7)] + +def cache_614_H_part11 : List Cell := [(-1, -6), (-1, -5), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (-1, 10), (-1, 11), (-1, 12), (-1, 13), (-1, 14), (-1, 15), (-1, 16), (0, -13)] + +def cache_614_H_part12 : List Cell := [(0, -12), (0, -11), (0, -10), (0, -9), (0, -8), (0, -7), (0, -6), (0, -5), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (0, 11), (0, 12)] + +def cache_614_H_part13 : List Cell := [(0, 13), (0, 14), (0, 15), (1, -13), (1, -12), (1, -11), (1, -10), (1, -9), (1, -8), (1, -7), (1, -6), (1, -5), (1, -4), (1, -3), (1, -2), (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8)] + +def cache_614_H_part14 : List Cell := [(1, 9), (1, 10), (1, 11), (1, 12), (1, 13), (1, 14), (1, 15), (1, 16), (1, 17), (2, -13), (2, -12), (2, -11), (2, -10), (2, -9), (2, -8), (2, -7), (2, -6), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1)] + +def cache_614_H_part15 : List Cell := [(2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (2, 11), (2, 12), (2, 13), (2, 14), (2, 15), (2, 16), (3, -13), (3, -12), (3, -11), (3, -10), (3, -9), (3, -8), (3, -7), (3, -6), (3, -5)] + +def cache_614_H_part16 : List Cell := [(3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 10), (3, 11), (3, 12), (3, 13), (3, 14), (3, 15), (3, 16), (3, 17), (4, -13), (4, -12)] + +def cache_614_H_part17 : List Cell := [(4, -11), (4, -10), (4, -9), (4, -8), (4, -7), (4, -6), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (4, 10), (4, 11), (4, 12)] + +def cache_614_H_part18 : List Cell := [(4, 13), (4, 14), (4, 15), (5, -12), (5, -11), (5, -10), (5, -9), (5, -8), (5, -7), (5, -6), (5, -5), (5, -4), (5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8)] + +def cache_614_H_part19 : List Cell := [(5, 9), (5, 10), (5, 11), (5, 12), (5, 13), (5, 14), (5, 15), (6, -12), (6, -11), (6, -10), (6, -9), (6, -8), (6, -7), (6, -6), (6, -5), (6, -4), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4)] + +def cache_614_H_part20 : List Cell := [(6, 5), (6, 6), (6, 7), (6, 8), (6, 9), (6, 10), (6, 11), (6, 12), (6, 13), (6, 14), (6, 15), (7, -10), (7, -9), (7, -8), (7, -7), (7, -6), (7, -5), (7, -4), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2)] + +def cache_614_H_part21 : List Cell := [(7, 3), (7, 4), (7, 5), (7, 6), (7, 7), (7, 8), (7, 9), (7, 10), (7, 11), (7, 12), (7, 13), (7, 14), (7, 15), (8, -10), (8, -9), (8, -8), (8, -7), (8, -6), (8, -5), (8, -4), (8, -3), (8, -2), (8, -1), (8, 0)] + +def cache_614_H_part22 : List Cell := [(8, 1), (8, 2), (8, 3), (8, 4), (8, 5), (8, 6), (8, 7), (8, 8), (8, 9), (8, 10), (8, 11), (8, 12), (8, 13), (9, -10), (9, -9), (9, -8), (9, -7), (9, -6), (9, -5), (9, -4), (9, -3), (9, -2), (9, -1), (9, 0)] + +def cache_614_H_part23 : List Cell := [(9, 1), (9, 2), (9, 3), (9, 4), (9, 5), (9, 6), (9, 7), (9, 8), (9, 9), (9, 10), (9, 11), (9, 12), (9, 13), (10, -10), (10, -9), (10, -8), (10, -7), (10, -6), (10, -5), (10, -4), (10, -3), (10, -2), (10, -1), (10, 0)] + +def cache_614_H_part24 : List Cell := [(10, 1), (10, 2), (10, 3), (10, 4), (10, 5), (10, 6), (10, 7), (10, 8), (10, 9), (10, 10), (10, 11), (10, 12), (10, 13), (11, -8), (11, -7), (11, -6), (11, -5), (11, -4), (11, -3), (11, -2), (11, -1), (11, 0), (11, 1), (11, 2)] + +def cache_614_H_part25 : List Cell := [(11, 3), (11, 4), (11, 5), (11, 6), (11, 7), (11, 8), (11, 9), (11, 10), (11, 11), (12, -7), (12, -6), (12, -5), (12, -4), (12, -3), (12, -2), (12, -1), (12, 0), (12, 1), (12, 2), (12, 3), (12, 4), (12, 5), (12, 6), (12, 7)] + +def cache_614_H_part26 : List Cell := [(12, 8), (12, 9), (12, 10), (13, -5), (13, -4), (13, -3), (13, -2), (13, -1), (13, 0), (13, 1), (13, 2), (13, 3), (13, 4), (13, 5), (13, 6), (13, 7), (13, 8), (13, 9), (13, 10), (14, -4), (14, -3), (14, -2), (14, -1), (14, 0)] + +def cache_614_H_part27 : List Cell := [(14, 1), (14, 2), (14, 3), (14, 4), (14, 5), (14, 6), (14, 7), (15, -4), (15, -3), (15, -2), (15, -1), (15, 0), (15, 1), (15, 2), (15, 3), (15, 4), (15, 5), (15, 6), (15, 7), (16, -2), (16, -1), (16, 0), (16, 1), (16, 2)] + +def cache_614_H_part28 : List Cell := [(16, 3), (17, -2), (17, 0), (17, 1), (17, 2), (17, 3)] + +def cache_614_H : List Cell := ((((cache_614_H_part0 ++ (cache_614_H_part1 ++ cache_614_H_part2)) ++ ((cache_614_H_part3 ++ cache_614_H_part4) ++ (cache_614_H_part5 ++ cache_614_H_part6))) ++ ((cache_614_H_part7 ++ (cache_614_H_part8 ++ cache_614_H_part9)) ++ ((cache_614_H_part10 ++ cache_614_H_part11) ++ (cache_614_H_part12 ++ cache_614_H_part13)))) ++ (((cache_614_H_part14 ++ (cache_614_H_part15 ++ cache_614_H_part16)) ++ ((cache_614_H_part17 ++ cache_614_H_part18) ++ (cache_614_H_part19 ++ cache_614_H_part20))) ++ (((cache_614_H_part21 ++ cache_614_H_part22) ++ (cache_614_H_part23 ++ cache_614_H_part24)) ++ ((cache_614_H_part25 ++ cache_614_H_part26) ++ (cache_614_H_part27 ++ cache_614_H_part28))))) + +def cache_614 : ListRow := ⟨cache_614_A, cache_614_H, 33⟩ + +def cache_615_A_part0 : List Cell := [(1, 0)] + +def cache_615_A : List Cell := cache_615_A_part0 + +def cache_615_H_part0 : List Cell := [(-15, 0), (-15, 2), (-14, 0), (-14, 1), (-14, 2), (-13, -4), (-13, -3), (-13, -2), (-13, -1), (-13, 0), (-13, 1), (-13, 2), (-13, 3), (-13, 4), (-12, -5), (-12, -4), (-12, -3), (-12, -2), (-12, -1), (-12, 0), (-12, 1), (-12, 2), (-12, 3), (-12, 4)] + +def cache_615_H_part1 : List Cell := [(-12, 5), (-11, -5), (-11, -4), (-11, -3), (-11, -2), (-11, -1), (-11, 0), (-11, 1), (-11, 2), (-11, 3), (-11, 4), (-11, 5), (-10, -9), (-10, -8), (-10, -7), (-10, -6), (-10, -5), (-10, -4), (-10, -3), (-10, -2), (-10, -1), (-10, 0), (-10, 1), (-10, 2)] + +def cache_615_H_part2 : List Cell := [(-10, 3), (-10, 4), (-10, 5), (-10, 6), (-10, 7), (-10, 8), (-10, 9), (-9, -9), (-9, -8), (-9, -7), (-9, -6), (-9, -5), (-9, -4), (-9, -3), (-9, -2), (-9, -1), (-9, 0), (-9, 1), (-9, 2), (-9, 3), (-9, 4), (-9, 5), (-9, 6), (-9, 7)] + +def cache_615_H_part3 : List Cell := [(-9, 8), (-9, 9), (-8, -10), (-8, -9), (-8, -8), (-8, -7), (-8, -6), (-8, -5), (-8, -4), (-8, -3), (-8, -2), (-8, -1), (-8, 0), (-8, 1), (-8, 2), (-8, 3), (-8, 4), (-8, 5), (-8, 6), (-8, 7), (-8, 8), (-8, 9), (-8, 10), (-7, -11)] + +def cache_615_H_part4 : List Cell := [(-7, -10), (-7, -9), (-7, -8), (-7, -7), (-7, -6), (-7, -5), (-7, -4), (-7, -3), (-7, -2), (-7, -1), (-7, 0), (-7, 1), (-7, 2), (-7, 3), (-7, 4), (-7, 5), (-7, 6), (-7, 7), (-7, 8), (-7, 9), (-7, 10), (-7, 11), (-6, -11), (-6, -10)] + +def cache_615_H_part5 : List Cell := [(-6, -9), (-6, -8), (-6, -7), (-6, -6), (-6, -5), (-6, -4), (-6, -3), (-6, -2), (-6, -1), (-6, 0), (-6, 1), (-6, 2), (-6, 3), (-6, 4), (-6, 5), (-6, 6), (-6, 7), (-6, 8), (-6, 9), (-6, 10), (-6, 11), (-5, -12), (-5, -11), (-5, -10)] + +def cache_615_H_part6 : List Cell := [(-5, -9), (-5, -8), (-5, -7), (-5, -6), (-5, -5), (-5, -4), (-5, -3), (-5, -2), (-5, -1), (-5, 0), (-5, 1), (-5, 2), (-5, 3), (-5, 4), (-5, 5), (-5, 6), (-5, 7), (-5, 8), (-5, 9), (-5, 10), (-5, 11), (-5, 12), (-4, -14), (-4, -13)] + +def cache_615_H_part7 : List Cell := [(-4, -12), (-4, -11), (-4, -10), (-4, -9), (-4, -8), (-4, -7), (-4, -6), (-4, -5), (-4, -4), (-4, -3), (-4, -2), (-4, -1), (-4, 0), (-4, 1), (-4, 2), (-4, 3), (-4, 4), (-4, 5), (-4, 6), (-4, 7), (-4, 8), (-4, 9), (-4, 10), (-4, 11)] + +def cache_615_H_part8 : List Cell := [(-4, 12), (-4, 13), (-4, 14), (-3, -14), (-3, -13), (-3, -12), (-3, -11), (-3, -10), (-3, -9), (-3, -8), (-3, -7), (-3, -6), (-3, -5), (-3, -4), (-3, -3), (-3, -2), (-3, -1), (-3, 0), (-3, 1), (-3, 2), (-3, 3), (-3, 4), (-3, 5), (-3, 6)] + +def cache_615_H_part9 : List Cell := [(-3, 7), (-3, 8), (-3, 9), (-3, 10), (-3, 11), (-3, 12), (-3, 13), (-3, 14), (-2, -16), (-2, -15), (-2, -14), (-2, -13), (-2, -12), (-2, -11), (-2, -10), (-2, -9), (-2, -8), (-2, -7), (-2, -6), (-2, -5), (-2, -4), (-2, -3), (-2, -2), (-2, -1)] + +def cache_615_H_part10 : List Cell := [(-2, 0), (-2, 1), (-2, 2), (-2, 3), (-2, 4), (-2, 5), (-2, 6), (-2, 7), (-2, 8), (-2, 9), (-2, 10), (-2, 11), (-2, 12), (-2, 13), (-2, 14), (-2, 15), (-2, 16), (-1, -15), (-1, -14), (-1, -13), (-1, -12), (-1, -11), (-1, -10), (-1, -9)] + +def cache_615_H_part11 : List Cell := [(-1, -8), (-1, -7), (-1, -6), (-1, -5), (-1, -4), (-1, -3), (-1, -2), (-1, -1), (-1, 0), (-1, 1), (-1, 2), (-1, 3), (-1, 4), (-1, 5), (-1, 6), (-1, 7), (-1, 8), (-1, 9), (-1, 10), (-1, 11), (-1, 12), (-1, 13), (-1, 14), (-1, 15)] + +def cache_615_H_part12 : List Cell := [(0, -16), (0, -15), (0, -14), (0, -13), (0, -12), (0, -11), (0, -10), (0, -9), (0, -8), (0, -7), (0, -6), (0, -5), (0, -4), (0, -3), (0, -2), (0, -1), (0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7)] + +def cache_615_H_part13 : List Cell := [(0, 8), (0, 9), (0, 10), (0, 11), (0, 12), (0, 13), (0, 14), (0, 15), (0, 16), (1, -15), (1, -14), (1, -13), (1, -12), (1, -11), (1, -10), (1, -9), (1, -8), (1, -7), (1, -6), (1, -5), (1, -4), (1, -3), (1, -2), (1, 0)] + +def cache_615_H_part14 : List Cell := [(1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (1, 10), (1, 11), (1, 12), (1, 13), (1, 14), (1, 15), (1, 16), (2, -16), (2, -15), (2, -14), (2, -13), (2, -12), (2, -11), (2, -10), (2, -9)] + +def cache_615_H_part15 : List Cell := [(2, -8), (2, -7), (2, -6), (2, -5), (2, -4), (2, -3), (2, -2), (2, -1), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7), (2, 8), (2, 9), (2, 10), (2, 11), (2, 12), (2, 13), (2, 14), (2, 15)] + +def cache_615_H_part16 : List Cell := [(2, 16), (3, -14), (3, -13), (3, -12), (3, -11), (3, -10), (3, -9), (3, -8), (3, -7), (3, -6), (3, -5), (3, -4), (3, -3), (3, -2), (3, -1), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (3, 8)] + +def cache_615_H_part17 : List Cell := [(3, 9), (3, 10), (3, 11), (3, 12), (3, 13), (3, 14), (3, 15), (3, 16), (4, -14), (4, -13), (4, -12), (4, -11), (4, -10), (4, -9), (4, -8), (4, -7), (4, -6), (4, -5), (4, -4), (4, -3), (4, -2), (4, -1), (4, 0), (4, 1)] + +def cache_615_H_part18 : List Cell := [(4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (4, 8), (4, 9), (4, 10), (4, 11), (4, 12), (4, 13), (4, 14), (5, -14), (5, -13), (5, -12), (5, -11), (5, -10), (5, -9), (5, -8), (5, -7), (5, -6), (5, -5), (5, -4)] + +def cache_615_H_part19 : List Cell := [(5, -3), (5, -2), (5, -1), (5, 0), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7), (5, 8), (5, 9), (5, 10), (5, 11), (5, 12), (5, 13), (5, 14), (6, -14), (6, -13), (6, -12), (6, -11), (6, -10), (6, -9)] + +def cache_615_H_part20 : List Cell := [(6, -8), (6, -7), (6, -6), (6, -5), (6, -4), (6, -3), (6, -2), (6, -1), (6, 0), (6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7), (6, 8), (6, 9), (6, 10), (6, 11), (6, 12), (6, 13), (6, 14), (7, -12)] + +def cache_615_H_part21 : List Cell := [(7, -11), (7, -10), (7, -9), (7, -8), (7, -7), (7, -6), (7, -5), (7, -4), (7, -3), (7, -2), (7, -1), (7, 0), (7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (7, 6), (7, 7), (7, 8), (7, 9), (7, 10), (7, 11), (7, 12)] + +def cache_615_H_part22 : List Cell := [(7, 13), (7, 14), (8, -12), (8, -11), (8, -10), (8, -9), (8, -8), (8, -7), (8, -6), (8, -5), (8, -4), (8, -3), (8, -2), (8, -1), (8, 0), (8, 1), (8, 2), (8, 3), (8, 4), (8, 5), (8, 6), (8, 7), (8, 8), (8, 9)] + +def cache_615_H_part23 : List Cell := [(8, 10), (8, 11), (8, 12), (9, -12), (9, -11), (9, -10), (9, -9), (9, -8), (9, -7), (9, -6), (9, -5), (9, -4), (9, -3), (9, -2), (9, -1), (9, 0), (9, 1), (9, 2), (9, 3), (9, 4), (9, 5), (9, 6), (9, 7), (9, 8)] + +def cache_615_H_part24 : List Cell := [(9, 9), (9, 10), (9, 11), (9, 12), (10, -10), (10, -9), (10, -8), (10, -7), (10, -6), (10, -5), (10, -4), (10, -3), (10, -2), (10, -1), (10, 0), (10, 1), (10, 2), (10, 3), (10, 4), (10, 5), (10, 6), (10, 7), (10, 8), (10, 9)] + +def cache_615_H_part25 : List Cell := [(10, 10), (10, 11), (10, 12), (11, -9), (11, -8), (11, -7), (11, -6), (11, -5), (11, -4), (11, -3), (11, -2), (11, -1), (11, 0), (11, 1), (11, 2), (11, 3), (11, 4), (11, 5), (11, 6), (11, 7), (11, 8), (11, 9), (11, 10), (12, -9)] + +def cache_615_H_part26 : List Cell := [(12, -8), (12, -7), (12, -6), (12, -5), (12, -4), (12, -3), (12, -2), (12, -1), (12, 0), (12, 1), (12, 2), (12, 3), (12, 4), (12, 5), (12, 6), (12, 7), (12, 8), (12, 9), (13, -6), (13, -5), (13, -4), (13, -3), (13, -2), (13, -1)] + +def cache_615_H_part27 : List Cell := [(13, 0), (13, 1), (13, 2), (13, 3), (13, 4), (13, 5), (13, 6), (13, 7), (13, 8), (13, 9), (14, -6), (14, -5), (14, -4), (14, -3), (14, -2), (14, -1), (14, 0), (14, 1), (14, 2), (14, 3), (14, 4), (14, 5), (14, 6), (15, -2)] + +def cache_615_H_part28 : List Cell := [(15, -1), (15, 0), (15, 1), (15, 2), (15, 3), (15, 4), (15, 5), (15, 6), (16, -2), (16, 0), (16, 1), (16, 2), (17, 0), (17, 2)] + +def cache_615_H : List Cell := ((((cache_615_H_part0 ++ (cache_615_H_part1 ++ cache_615_H_part2)) ++ ((cache_615_H_part3 ++ cache_615_H_part4) ++ (cache_615_H_part5 ++ cache_615_H_part6))) ++ ((cache_615_H_part7 ++ (cache_615_H_part8 ++ cache_615_H_part9)) ++ ((cache_615_H_part10 ++ cache_615_H_part11) ++ (cache_615_H_part12 ++ cache_615_H_part13)))) ++ (((cache_615_H_part14 ++ (cache_615_H_part15 ++ cache_615_H_part16)) ++ ((cache_615_H_part17 ++ cache_615_H_part18) ++ (cache_615_H_part19 ++ cache_615_H_part20))) ++ (((cache_615_H_part21 ++ cache_615_H_part22) ++ (cache_615_H_part23 ++ cache_615_H_part24)) ++ ((cache_615_H_part25 ++ cache_615_H_part26) ++ (cache_615_H_part27 ++ cache_615_H_part28))))) + +def cache_615 : ListRow := ⟨cache_615_A, cache_615_H, 34⟩ + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Entries00.lean b/lean/OAI/Combinatorics/SnakyCertificate/Entries00.lean new file mode 100644 index 0000000000000000000000000000000000000000..f4c093a88dad26ebec50c78e72ed28da0b79cb2f --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Entries00.lean @@ -0,0 +1,209 @@ +import OAI.Combinatorics.SnakyCertificate.Basic + +namespace OAI + +namespace SnakyCertificate + +def entry_6 : Entry := ⟨6, [⟨0, 0, 0, 3⟩]⟩ + +def entry_7 : Entry := ⟨7, [⟨4, 0, 3, 4⟩, ⟨6, 0, 5, 4⟩]⟩ + +def entry_8 : Entry := ⟨8, [⟨0, 4, 8, 3⟩, ⟨6, 4, 3, 4⟩]⟩ + +def entry_9 : Entry := ⟨9, [⟨0, 4, 5, 4⟩, ⟨6, 4, 0, 5⟩]⟩ + +def entry_10 : Entry := ⟨10, [⟨2, 0, 2, 3⟩, ⟨2, 6, 2, 4⟩]⟩ + +def entry_11 : Entry := ⟨11, [⟨6, 4, 2, 5⟩, ⟨6, 6, 2, 3⟩]⟩ + +def entry_12 : Entry := ⟨12, [⟨0, 6, 5, 4⟩, ⟨0, 0, 0, 3⟩]⟩ + +def entry_13 : Entry := ⟨13, [⟨6, 6, 0, 3⟩, ⟨6, 4, 0, 5⟩]⟩ + +def entry_14 : Entry := ⟨14, [⟨0, 6, 5, 4⟩, ⟨3, 6, 1, 4⟩]⟩ + +def entry_15 : Entry := ⟨15, [⟨0, 6, 6, 4⟩, ⟨3, 6, 2, 4⟩]⟩ + +def entry_16 : Entry := ⟨16, [⟨3, 6, 3, 4⟩, ⟨0, 6, 7, 4⟩]⟩ + +def entry_17 : Entry := ⟨17, [⟨0, 6, 5, 4⟩, ⟨3, 0, 3, 3⟩]⟩ + +def entry_18 : Entry := ⟨18, [⟨3, 6, 2, 4⟩, ⟨3, 0, 4, 3⟩]⟩ + +def entry_19 : Entry := ⟨19, [⟨6, 4, 1, 5⟩, ⟨6, 0, 6, 5⟩]⟩ + +def entry_20 : Entry := ⟨20, [⟨6, 4, 0, 5⟩, ⟨6, 0, 5, 5⟩]⟩ + +def entry_21 : Entry := ⟨21, [⟨4, 6, 2, 3⟩, ⟨6, 0, 6, 5⟩]⟩ + +def entry_22 : Entry := ⟨22, [⟨0, 6, 7, 5⟩, ⟨3, 0, 5, 4⟩]⟩ + +def entry_23 : Entry := ⟨23, [⟨0, 6, 6, 4⟩, ⟨0, 0, 1, 3⟩]⟩ + +def entry_24 : Entry := ⟨24, [⟨0, 0, 0, 3⟩, ⟨17, 0, 5, 4⟩]⟩ + +def entry_25 : Entry := ⟨25, [⟨0, 0, 0, 3⟩, ⟨14, 0, 5, 4⟩]⟩ + +def entry_26 : Entry := ⟨26, [⟨0, 4, 6, 4⟩, ⟨6, 0, 6, 5⟩]⟩ + +def entry_27 : Entry := ⟨27, [⟨0, 6, 5, 4⟩, ⟨6, 4, 0, 5⟩]⟩ + +def entry_28 : Entry := ⟨28, [⟨6, 1, 4, 5⟩, ⟨0, 6, 6, 4⟩]⟩ + +def entry_29 : Entry := ⟨29, [⟨1, 4, 7, 3⟩, ⟨6, 3, 4, 5⟩]⟩ + +def entry_30 : Entry := ⟨30, [⟨0, 0, 1, 3⟩, ⟨14, 0, 6, 4⟩]⟩ + +def entry_31 : Entry := ⟨31, [⟨0, 0, 1, 4⟩, ⟨17, 0, 6, 5⟩]⟩ + +def entry_32 : Entry := ⟨32, [⟨0, 4, 8, 3⟩, ⟨6, 3, 4, 5⟩]⟩ + +def entry_33 : Entry := ⟨33, [⟨0, 0, 2, 4⟩, ⟨17, 0, 7, 5⟩]⟩ + +def entry_34 : Entry := ⟨34, [⟨6, 1, 4, 5⟩, ⟨1, 6, 5, 4⟩]⟩ + +def entry_35 : Entry := ⟨35, [⟨0, 0, 2, 4⟩, ⟨14, 0, 7, 5⟩]⟩ + +def entry_36 : Entry := ⟨36, [⟨0, 0, 3, 4⟩, ⟨17, 0, 8, 5⟩]⟩ + +def entry_37 : Entry := ⟨37, [⟨6, 3, 4, 5⟩, ⟨2, 4, 6, 3⟩]⟩ + +def entry_38 : Entry := ⟨38, [⟨3, 0, 3, 3⟩, ⟨16, 0, 2, 4⟩]⟩ + +def entry_39 : Entry := ⟨39, [⟨0, 0, 1, 3⟩, ⟨17, 0, 6, 4⟩]⟩ + +def entry_40 : Entry := ⟨40, [⟨3, 0, 4, 3⟩, ⟨16, 0, 3, 4⟩]⟩ + +def entry_41 : Entry := ⟨41, [⟨6, 3, 3, 5⟩, ⟨1, 4, 6, 3⟩]⟩ + +def entry_42 : Entry := ⟨42, [⟨0, 6, 6, 4⟩, ⟨6, 4, 1, 5⟩]⟩ + +def entry_43 : Entry := ⟨43, [⟨2, 4, 5, 3⟩, ⟨6, 3, 3, 5⟩]⟩ + +def entry_44 : Entry := ⟨44, [⟨4, 4, 1, 5⟩, ⟨7, 0, 4, 5⟩]⟩ + +def entry_45 : Entry := ⟨45, [⟨6, 4, 0, 5⟩, ⟨7, 0, 4, 5⟩]⟩ + +def entry_46 : Entry := ⟨46, [⟨6, 6, 0, 3⟩, ⟨7, 0, 4, 5⟩]⟩ + +def entry_47 : Entry := ⟨47, [⟨6, 3, 3, 5⟩, ⟨6, 2, 7, 3⟩]⟩ + +def entry_48 : Entry := ⟨48, [⟨6, 3, 4, 5⟩, ⟨6, 2, 8, 3⟩]⟩ + +def entry_49 : Entry := ⟨49, [⟨4, 7, 3, 1⟩, ⟨7, 1, 5, 4⟩]⟩ + +def entry_50 : Entry := ⟨50, [⟨6, 3, 3, 5⟩, ⟨7, 1, 5, 4⟩]⟩ + +def entry_51 : Entry := ⟨51, [⟨10, 2, 5, 3⟩, ⟨10, 0, 5, 4⟩, ⟨26, 2, 3, 4⟩, ⟨26, 0, 3, 3⟩]⟩ + +def entry_52 : Entry := ⟨52, [⟨0, 0, 0, 3⟩, ⟨0, 4, 7, 3⟩]⟩ + +def entry_53 : Entry := ⟨53, [⟨6, 4, 3, 4⟩, ⟨3, 1, 4, 5⟩]⟩ + +def entry_54 : Entry := ⟨54, [⟨22, 0, 2, 3⟩, ⟨3, 6, 1, 4⟩]⟩ + +def entry_55 : Entry := ⟨55, [⟨7, 4, 0, 5⟩, ⟨7, 0, 4, 5⟩]⟩ + +def entry_56 : Entry := ⟨56, [⟨7, 4, 0, 5⟩, ⟨7, 6, 0, 3⟩]⟩ + +def entry_57 : Entry := ⟨57, [⟨0, 6, 5, 4⟩, ⟨7, 0, 4, 5⟩]⟩ + +def entry_58 : Entry := ⟨58, [⟨0, 4, 5, 4⟩, ⟨7, 0, 4, 5⟩]⟩ + +def entry_59 : Entry := ⟨59, [⟨0, 6, 5, 4⟩, ⟨7, 4, 0, 5⟩]⟩ + +def entry_60 : Entry := ⟨60, [⟨6, 6, 1, 3⟩, ⟨49, 1, 6, 4⟩]⟩ + +def entry_61 : Entry := ⟨61, [⟨6, 0, 5, 4⟩, ⟨14, 1, 4, 5⟩]⟩ + +def entry_62 : Entry := ⟨62, [⟨6, 6, 0, 3⟩, ⟨53, 0, 1, 5⟩]⟩ + +def entry_63 : Entry := ⟨63, [⟨4, 3, 4, 3⟩, ⟨50, 0, 5, 4⟩]⟩ + +def entry_64 : Entry := ⟨64, [⟨6, 6, 3, 4⟩, ⟨49, 1, 8, 5⟩]⟩ + +def entry_65 : Entry := ⟨65, [⟨6, 6, 0, 3⟩, ⟨49, 1, 5, 4⟩]⟩ + +def entry_66 : Entry := ⟨66, [⟨6, 3, 4, 5⟩, ⟨53, 5, 6, 4⟩]⟩ + +def entry_67 : Entry := ⟨67, [⟨6, 1, 4, 5⟩, ⟨9, 2, 5, 4⟩]⟩ + +def entry_68 : Entry := ⟨68, [⟨6, 4, 0, 5⟩, ⟨44, 0, 5, 4⟩]⟩ + +def entry_69 : Entry := ⟨69, [⟨6, 3, 4, 5⟩, ⟨34, 0, 6, 5⟩]⟩ + +def entry_70 : Entry := ⟨70, [⟨4, 3, 4, 3⟩, ⟨41, 0, 5, 4⟩]⟩ + +def entry_71 : Entry := ⟨71, [⟨6, 1, 4, 5⟩, ⟨23, 2, 4, 3⟩]⟩ + +def entry_72 : Entry := ⟨72, [⟨0, 5, 3, 8⟩, ⟨8, 6, 5, 4⟩]⟩ + +def entry_73 : Entry := ⟨73, [⟨4, 3, 3, 4⟩, ⟨50, 0, 4, 5⟩]⟩ + +def entry_74 : Entry := ⟨74, [⟨2, 7, 4, 3⟩, ⟨53, 0, 3, 3⟩]⟩ + +def entry_75 : Entry := ⟨75, [⟨0, 0, 1, 3⟩, ⟨9, 0, 7, 3⟩]⟩ + +def entry_76 : Entry := ⟨76, [⟨0, 7, 5, 7⟩, ⟨14, 0, 7, 5⟩]⟩ + +def entry_77 : Entry := ⟨77, [⟨0, 5, 3, 7⟩, ⟨12, 0, 5, 4⟩]⟩ + +def entry_78 : Entry := ⟨78, [⟨6, 4, 3, 4⟩, ⟨52, 0, 5, 4⟩]⟩ + +def entry_79 : Entry := ⟨79, [⟨6, 1, 5, 5⟩, ⟨48, 0, 3, 4⟩]⟩ + +def entry_80 : Entry := ⟨80, [⟨0, 6, 6, 4⟩, ⟨13, 4, 2, 4⟩]⟩ + +def entry_81 : Entry := ⟨81, [⟨4, 3, 4, 3⟩, ⟨43, 0, 5, 4⟩]⟩ + +def entry_82 : Entry := ⟨82, [⟨6, 1, 4, 5⟩, ⟨36, 0, 1, 3⟩]⟩ + +def entry_83 : Entry := ⟨83, [⟨0, 7, 5, 7⟩, ⟨67, 2, 6, 3⟩]⟩ + +def entry_84 : Entry := ⟨84, [⟨6, 3, 4, 5⟩, ⟨67, 0, 6, 4⟩]⟩ + +def entry_85 : Entry := ⟨85, [⟨9, 0, 6, 3⟩, ⟨8, 4, 5, 4⟩]⟩ + +def entry_86 : Entry := ⟨86, [⟨0, 6, 5, 4⟩, ⟨67, 3, 1, 5⟩]⟩ + +def entry_87 : Entry := ⟨87, [⟨0, 5, 3, 7⟩, ⟨24, 2, 5, 3⟩]⟩ + +def entry_88 : Entry := ⟨88, [⟨0, 6, 6, 4⟩, ⟨67, 3, 2, 5⟩]⟩ + +def entry_89 : Entry := ⟨89, [⟨8, 3, 3, 1⟩, ⟨7, 1, 5, 4⟩]⟩ + +def entry_90 : Entry := ⟨90, [⟨31, 0, 3, 3⟩, ⟨54, 6, 0, 3⟩, ⟨54, 0, 5, 4⟩, ⟨31, 6, 2, 4⟩]⟩ + +def entry_91 : Entry := ⟨91, [⟨6, 3, 4, 5⟩, ⟨74, 5, 7, 3⟩]⟩ + +def entry_92 : Entry := ⟨92, [⟨6, 1, 4, 5⟩, ⟨33, 0, 2, 3⟩]⟩ + +def entry_93 : Entry := ⟨93, [⟨4, 3, 4, 3⟩, ⟨47, 0, 5, 4⟩]⟩ + +def entry_94 : Entry := ⟨94, [⟨6, 1, 4, 5⟩, ⟨27, 3, 3, 6⟩]⟩ + +def entry_95 : Entry := ⟨95, [⟨0, 5, 3, 7⟩, ⟨29, 0, 2, 5⟩]⟩ + +def entry_96 : Entry := ⟨96, [⟨6, 1, 5, 5⟩, ⟨70, 0, 3, 5⟩]⟩ + +def entry_97 : Entry := ⟨97, [⟨6, 6, 0, 3⟩, ⟨44, 0, 5, 4⟩]⟩ + +def entry_98 : Entry := ⟨98, [⟨6, 6, 2, 3⟩, ⟨44, 0, 7, 4⟩]⟩ + +def entry_99 : Entry := ⟨99, [⟨2, 1, 3, 2⟩, ⟨24, 0, 5, 4⟩]⟩ + +def entry_100 : Entry := ⟨100, [⟨0, 6, 5, 4⟩, ⟨48, 0, 1, 4⟩]⟩ + +def entry_101 : Entry := ⟨101, [⟨0, 7, 4, 6⟩, ⟨24, 0, 5, 4⟩]⟩ + +def entry_102 : Entry := ⟨102, [⟨6, 3, 4, 5⟩, ⟨25, 2, 6, 3⟩]⟩ + +def entry_103 : Entry := ⟨103, [⟨6, 3, 4, 5⟩, ⟨71, 0, 6, 4⟩]⟩ + +def entry_104 : Entry := ⟨104, [⟨6, 0, 5, 4⟩, ⟨75, 0, 3, 4⟩]⟩ + +def entry_105 : Entry := ⟨105, [⟨6, 5, 4, 3⟩, ⟨77, 0, 4, 5⟩]⟩ + +end SnakyCertificate + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Entries01.lean b/lean/OAI/Combinatorics/SnakyCertificate/Entries01.lean new file mode 100644 index 0000000000000000000000000000000000000000..e6418480441d9d909240a14b383d832fb6455e68 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Entries01.lean @@ -0,0 +1,209 @@ +import OAI.Combinatorics.SnakyCertificate.Basic + +namespace OAI + +namespace SnakyCertificate + +def entry_106 : Entry := ⟨106, [⟨6, 1, 4, 5⟩, ⟨36, 6, 5, 4⟩]⟩ + +def entry_107 : Entry := ⟨107, [⟨6, 6, 0, 3⟩, ⟨63, 1, 5, 3⟩]⟩ + +def entry_108 : Entry := ⟨108, [⟨4, 6, 1, 3⟩, ⟨63, 1, 5, 3⟩]⟩ + +def entry_109 : Entry := ⟨109, [⟨4, 6, 1, 3⟩, ⟨55, 0, 5, 4⟩]⟩ + +def entry_110 : Entry := ⟨110, [⟨6, 6, 1, 3⟩, ⟨63, 1, 6, 3⟩]⟩ + +def entry_111 : Entry := ⟨111, [⟨6, 7, 4, 3⟩, ⟨83, 0, 4, 5⟩]⟩ + +def entry_112 : Entry := ⟨112, [⟨4, 1, 5, 4⟩, ⟨93, 0, 3, 5⟩]⟩ + +def entry_113 : Entry := ⟨113, [⟨1, 6, 6, 4⟩, ⟨36, 6, 7, 5⟩]⟩ + +def entry_114 : Entry := ⟨114, [⟨6, 0, 6, 5⟩, ⟨67, 3, 2, 5⟩]⟩ + +def entry_115 : Entry := ⟨115, [⟨6, 2, 7, 3⟩, ⟨70, 7, 2, 5⟩]⟩ + +def entry_116 : Entry := ⟨116, [⟨0, 7, 4, 6⟩, ⟨24, 2, 5, 4⟩]⟩ + +def entry_117 : Entry := ⟨117, [⟨6, 1, 4, 5⟩, ⟨100, 0, 5, 4⟩]⟩ + +def entry_118 : Entry := ⟨118, [⟨4, 7, 3, 1⟩, ⟨61, 1, 5, 4⟩]⟩ + +def entry_119 : Entry := ⟨119, [⟨6, 6, 1, 3⟩, ⟨55, 0, 6, 4⟩]⟩ + +def entry_120 : Entry := ⟨120, [⟨4, 0, 4, 5⟩, ⟨58, 2, 5, 4⟩]⟩ + +def entry_121 : Entry := ⟨121, [⟨9, 3, 4, 5⟩, ⟨7, 1, 5, 4⟩]⟩ + +def entry_122 : Entry := ⟨122, [⟨6, 6, 3, 3⟩, ⟨105, 1, 4, 5⟩]⟩ + +def entry_123 : Entry := ⟨123, [⟨6, 6, 1, 3⟩, ⟨64, 2, 2, 5⟩]⟩ + +def entry_124 : Entry := ⟨124, [⟨6, 1, 4, 5⟩, ⟨31, 2, 5, 4⟩]⟩ + +def entry_125 : Entry := ⟨125, [⟨3, 0, 4, 3⟩, ⟨31, 2, 4, 5⟩]⟩ + +def entry_126 : Entry := ⟨126, [⟨6, 3, 4, 5⟩, ⟨46, 1, 5, 7⟩]⟩ + +def entry_127 : Entry := ⟨127, [⟨7, 0, 4, 5⟩, ⟨44, 2, 5, 4⟩]⟩ + +def entry_128 : Entry := ⟨128, [⟨9, 6, 1, 5⟩, ⟨57, 0, 6, 5⟩]⟩ + +def entry_129 : Entry := ⟨129, [⟨6, 4, 2, 5⟩, ⟨58, 1, 3, 6⟩]⟩ + +def entry_130 : Entry := ⟨130, [⟨6, 1, 4, 5⟩, ⟨60, 0, 5, 4⟩]⟩ + +def entry_131 : Entry := ⟨131, [⟨45, 3, 4, 5⟩, ⟨7, 1, 5, 4⟩]⟩ + +def entry_132 : Entry := ⟨132, [⟨6, 3, 4, 5⟩, ⟨89, 0, 5, 6⟩]⟩ + +def entry_133 : Entry := ⟨133, [⟨6, 7, 3, 1⟩, ⟨92, 0, 5, 5⟩]⟩ + +def entry_134 : Entry := ⟨134, [⟨6, 7, 3, 0⟩, ⟨82, 0, 5, 4⟩]⟩ + +def entry_135 : Entry := ⟨135, [⟨7, 0, 4, 5⟩, ⟨75, 4, 2, 5⟩, ⟨44, 0, 5, 4⟩]⟩ + +def entry_136 : Entry := ⟨136, [⟨6, 3, 3, 7⟩, ⟨102, 2, 3, 3⟩]⟩ + +def entry_137 : Entry := ⟨137, [⟨4, 1, 4, 3⟩, ⟨96, 0, 3, 4⟩]⟩ + +def entry_138 : Entry := ⟨138, [⟨27, 0, 5, 4⟩, ⟨10, 1, 4, 7⟩]⟩ + +def entry_139 : Entry := ⟨139, [⟨28, 1, 4, 5⟩, ⟨27, 0, 5, 4⟩]⟩ + +def entry_140 : Entry := ⟨140, [⟨6, 7, 3, 2⟩, ⟨82, 0, 5, 6⟩]⟩ + +def entry_141 : Entry := ⟨141, [⟨7, 0, 4, 5⟩, ⟨78, 2, 1, 3⟩]⟩ + +def entry_142 : Entry := ⟨142, [⟨72, 4, 2, 3⟩, ⟨32, 1, 4, 3⟩, ⟨55, 2, 5, 4⟩]⟩ + +def entry_143 : Entry := ⟨143, [⟨6, 6, 3, 4⟩, ⟨108, 0, 8, 5⟩]⟩ + +def entry_144 : Entry := ⟨144, [⟨7, 0, 4, 5⟩, ⟨104, 4, 1, 5⟩, ⟨55, 0, 5, 4⟩]⟩ + +def entry_145 : Entry := ⟨145, [⟨0, 5, 4, 5⟩, ⟨91, 0, 3, 4⟩]⟩ + +def entry_146 : Entry := ⟨146, [⟨36, 6, 5, 4⟩, ⟨24, 1, 4, 5⟩]⟩ + +def entry_147 : Entry := ⟨147, [⟨53, 0, 1, 5⟩, ⟨44, 2, 5, 4⟩]⟩ + +def entry_148 : Entry := ⟨148, [⟨7, 1, 5, 4⟩, ⟨46, 1, 4, 5⟩, ⟨94, 0, 5, 3⟩, ⟨97, 1, 4, 5⟩]⟩ + +def entry_149 : Entry := ⟨149, [⟨16, 1, 4, 3⟩, ⟨24, 2, 5, 4⟩]⟩ + +def entry_150 : Entry := ⟨150, [⟨4, 6, 1, 3⟩, ⟨126, 5, 2, 5⟩]⟩ + +def entry_151 : Entry := ⟨151, [⟨2, 1, 4, 3⟩, ⟨101, 2, 6, 3⟩]⟩ + +def entry_152 : Entry := ⟨152, [⟨6, 3, 4, 5⟩, ⟨73, 1, 7, 4⟩]⟩ + +def entry_153 : Entry := ⟨153, [⟨59, 4, 0, 4⟩, ⟨27, 0, 5, 4⟩]⟩ + +def entry_154 : Entry := ⟨154, [⟨7, 6, 4, 3⟩, ⟨104, 0, 7, 5⟩]⟩ + +def entry_155 : Entry := ⟨155, [⟨7, 1, 5, 4⟩, ⟨55, 3, 4, 5⟩]⟩ + +def entry_156 : Entry := ⟨156, [⟨11, 0, 2, 4⟩, ⟨98, 2, 2, 4⟩, ⟨33, 0, 2, 3⟩]⟩ + +def entry_157 : Entry := ⟨157, [⟨6, 3, 4, 5⟩, ⟨57, 1, 5, 6⟩]⟩ + +def entry_158 : Entry := ⟨158, [⟨66, 0, 3, 4⟩, ⟨45, 1, 4, 5⟩, ⟨46, 3, 4, 5⟩]⟩ + +def entry_159 : Entry := ⟨159, [⟨45, 3, 4, 5⟩, ⟨65, 1, 4, 5⟩, ⟨7, 3, 3, 4⟩]⟩ + +def entry_160 : Entry := ⟨160, [⟨63, 1, 8, 3⟩, ⟨32, 3, 4, 3⟩]⟩ + +def entry_161 : Entry := ⟨161, [⟨15, 1, 4, 5⟩, ⟨86, 0, 5, 4⟩]⟩ + +def entry_162 : Entry := ⟨162, [⟨7, 3, 3, 4⟩, ⟨127, 1, 4, 5⟩, ⟨63, 0, 3, 5⟩, ⟨157, 0, 3, 3⟩]⟩ + +def entry_163 : Entry := ⟨163, [⟨44, 2, 5, 4⟩, ⟨49, 1, 5, 4⟩, ⟨56, 4, 0, 4⟩]⟩ + +def entry_164 : Entry := ⟨164, [⟨6, 1, 4, 5⟩, ⟨110, 0, 5, 4⟩]⟩ + +def entry_165 : Entry := ⟨165, [⟨0, 7, 5, 8⟩, ⟨107, 0, 7, 5⟩]⟩ + +def entry_166 : Entry := ⟨166, [⟨2, 7, 4, 5⟩, ⟨107, 0, 6, 4⟩]⟩ + +def entry_167 : Entry := ⟨167, [⟨57, 0, 5, 4⟩, ⟨57, 4, 0, 4⟩]⟩ + +def entry_168 : Entry := ⟨168, [⟨6, 1, 5, 5⟩, ⟨152, 0, 3, 4⟩]⟩ + +def entry_169 : Entry := ⟨169, [⟨28, 3, 4, 5⟩, ⟨63, 1, 8, 3⟩]⟩ + +def entry_170 : Entry := ⟨170, [⟨4, 6, 1, 3⟩, ⟨127, 2, 5, 4⟩]⟩ + +def entry_171 : Entry := ⟨171, [⟨6, 0, 5, 4⟩, ⟨91, 0, 0, 5⟩]⟩ + +def entry_172 : Entry := ⟨172, [⟨63, 1, 5, 3⟩, ⟨55, 6, 0, 4⟩, ⟨64, 0, 1, 3⟩]⟩ + +def entry_173 : Entry := ⟨173, [⟨63, 1, 5, 3⟩, ⟨64, 6, 4, 5⟩, ⟨55, 6, 0, 4⟩]⟩ + +def entry_174 : Entry := ⟨174, [⟨58, 3, 4, 5⟩, ⟨57, 1, 4, 5⟩, ⟨84, 0, 3, 4⟩]⟩ + +def entry_175 : Entry := ⟨175, [⟨141, 0, 5, 4⟩, ⟨7, 2, 4, 3⟩, ⟨63, 1, 5, 3⟩]⟩ + +def entry_176 : Entry := ⟨176, [⟨63, 1, 5, 3⟩, ⟨64, 6, 4, 5⟩, ⟨55, 2, 5, 4⟩]⟩ + +def entry_177 : Entry := ⟨177, [⟨6, 1, 4, 5⟩, ⟨136, 3, 5, 4⟩]⟩ + +def entry_178 : Entry := ⟨178, [⟨37, 0, 3, 4⟩, ⟨68, 1, 4, 5⟩, ⟨46, 3, 4, 5⟩]⟩ + +def entry_179 : Entry := ⟨179, [⟨6, 6, 0, 3⟩, ⟨148, 5, 5, 4⟩]⟩ + +def entry_180 : Entry := ⟨180, [⟨7, 3, 3, 4⟩, ⟨63, 0, 3, 5⟩, ⟨155, 0, 4, 5⟩, ⟨132, 0, 3, 3⟩]⟩ + +def entry_181 : Entry := ⟨181, [⟨24, 3, 4, 5⟩, ⟨87, 2, 6, 4⟩, ⟨90, 0, 7, 5⟩]⟩ + +def entry_182 : Entry := ⟨182, [⟨12, 2, 7, 3⟩, ⟨139, 0, 7, 4⟩]⟩ + +def entry_183 : Entry := ⟨183, [⟨64, 2, 1, 5⟩, ⟨63, 3, 0, 3⟩, ⟨55, 2, 5, 4⟩]⟩ + +def entry_184 : Entry := ⟨184, [⟨34, 3, 4, 2⟩, ⟨35, 2, 5, 4⟩]⟩ + +def entry_185 : Entry := ⟨185, [⟨44, 3, 4, 5⟩, ⟨49, 0, 4, 5⟩, ⟨84, 0, 3, 4⟩]⟩ + +def entry_186 : Entry := ⟨186, [⟨7, 6, 0, 3⟩, ⟨141, 2, 5, 4⟩]⟩ + +def entry_187 : Entry := ⟨187, [⟨6, 4, 3, 4⟩, ⟨108, 3, 4, 5⟩]⟩ + +def entry_188 : Entry := ⟨188, [⟨6, 3, 4, 5⟩, ⟨112, 5, 7, 4⟩]⟩ + +def entry_189 : Entry := ⟨189, [⟨12, 0, 5, 4⟩, ⟨86, 4, 1, 4⟩]⟩ + +def entry_190 : Entry := ⟨190, [⟨46, 0, 5, 4⟩, ⟨85, 2, 3, 3⟩, ⟨111, 3, 4, 3⟩]⟩ + +def entry_191 : Entry := ⟨191, [⟨6, 4, 3, 4⟩, ⟨145, 0, 4, 5⟩]⟩ + +def entry_192 : Entry := ⟨192, [⟨64, 1, 3, 1⟩, ⟨103, 0, 3, 4⟩, ⟨55, 3, 4, 5⟩]⟩ + +def entry_193 : Entry := ⟨193, [⟨6, 6, 2, 3⟩, ⟨162, 1, 7, 4⟩]⟩ + +def entry_194 : Entry := ⟨194, [⟨0, 0, 0, 3⟩, ⟨146, 4, 2, 5⟩]⟩ + +def entry_195 : Entry := ⟨195, [⟨6, 6, 0, 3⟩, ⟨162, 1, 5, 4⟩]⟩ + +def entry_196 : Entry := ⟨196, [⟨6, 3, 4, 5⟩, ⟨187, 5, 6, 4⟩]⟩ + +def entry_197 : Entry := ⟨197, [⟨63, 3, 0, 3⟩, ⟨63, 1, 5, 3⟩]⟩ + +def entry_198 : Entry := ⟨198, [⟨7, 4, 0, 5⟩, ⟨131, 1, 5, 4⟩]⟩ + +def entry_199 : Entry := ⟨199, [⟨55, 1, 4, 5⟩, ⟨64, 3, 5, 1⟩, ⟨84, 0, 3, 4⟩]⟩ + +def entry_200 : Entry := ⟨200, [⟨103, 0, 3, 4⟩, ⟨64, 3, 5, 1⟩, ⟨55, 1, 4, 5⟩]⟩ + +def entry_201 : Entry := ⟨201, [⟨45, 3, 5, 7⟩, ⟨82, 0, 6, 5⟩]⟩ + +def entry_202 : Entry := ⟨202, [⟨150, 0, 5, 4⟩, ⟨7, 0, 4, 5⟩, ⟨108, 0, 5, 4⟩]⟩ + +def entry_203 : Entry := ⟨203, [⟨18, 6, 1, 3⟩, ⟨107, 0, 5, 4⟩, ⟨163, 0, 5, 4⟩]⟩ + +def entry_204 : Entry := ⟨204, [⟨2, 5, 4, 2⟩, ⟨166, 2, 5, 3⟩]⟩ + +def entry_205 : Entry := ⟨205, [⟨4, 1, 4, 3⟩, ⟨168, 0, 3, 4⟩]⟩ + +end SnakyCertificate + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Entries02.lean b/lean/OAI/Combinatorics/SnakyCertificate/Entries02.lean new file mode 100644 index 0000000000000000000000000000000000000000..99ca31859b9a798262b7b10e7f97c02c30fce6ce --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Entries02.lean @@ -0,0 +1,209 @@ +import OAI.Combinatorics.SnakyCertificate.Basic + +namespace OAI + +namespace SnakyCertificate + +def entry_206 : Entry := ⟨206, [⟨28, 3, 4, 5⟩, ⟨135, 2, 8, 4⟩]⟩ + +def entry_207 : Entry := ⟨207, [⟨28, 3, 4, 5⟩, ⟨127, 0, 8, 4⟩]⟩ + +def entry_208 : Entry := ⟨208, [⟨7, 4, 0, 5⟩, ⟨127, 0, 5, 4⟩]⟩ + +def entry_209 : Entry := ⟨209, [⟨25, 0, 5, 4⟩, ⟨81, 5, 5, 7⟩]⟩ + +def entry_210 : Entry := ⟨210, [⟨58, 2, 5, 4⟩, ⟨57, 0, 5, 4⟩, ⟨117, 1, 4, 5⟩]⟩ + +def entry_211 : Entry := ⟨211, [⟨49, 5, 5, 4⟩, ⟨6, 6, 0, 3⟩]⟩ + +def entry_212 : Entry := ⟨212, [⟨6, 0, 5, 4⟩, ⟨188, 0, 0, 5⟩]⟩ + +def entry_213 : Entry := ⟨213, [⟨6, 0, 7, 5⟩, ⟨191, 0, 3, 5⟩]⟩ + +def entry_214 : Entry := ⟨214, [⟨7, 3, 3, 4⟩, ⟨108, 3, 4, 5⟩, ⟨95, 0, 5, 2⟩]⟩ + +def entry_215 : Entry := ⟨215, [⟨107, 1, 4, 6⟩, ⟨24, 0, 5, 4⟩]⟩ + +def entry_216 : Entry := ⟨216, [⟨7, 6, 0, 3⟩, ⟨155, 5, 5, 4⟩]⟩ + +def entry_217 : Entry := ⟨217, [⟨111, 1, 1, 3⟩, ⟨55, 4, 0, 4⟩, ⟨64, 0, 1, 3⟩]⟩ + +def entry_218 : Entry := ⟨218, [⟨0, 5, 3, 7⟩, ⟨182, 0, 2, 4⟩]⟩ + +def entry_219 : Entry := ⟨219, [⟨0, 5, 3, 7⟩, ⟨179, 2, 6, 4⟩]⟩ + +def entry_220 : Entry := ⟨220, [⟨56, 4, 0, 4⟩, ⟨63, 1, 5, 3⟩, ⟨144, 2, 5, 4⟩, ⟨154, 6, 5, 4⟩, ⟨155, 1, 5, 4⟩]⟩ + +def entry_221 : Entry := ⟨221, [⟨6, 6, 0, 3⟩, ⟨180, 5, 5, 4⟩]⟩ + +def entry_222 : Entry := ⟨222, [⟨6, 1, 4, 5⟩, ⟨158, 5, 5, 4⟩]⟩ + +def entry_223 : Entry := ⟨223, [⟨63, 1, 5, 3⟩, ⟨135, 2, 5, 4⟩, ⟨128, 0, 3, 3⟩, ⟨111, 3, 4, 3⟩, ⟨127, 0, 5, 4⟩]⟩ + +def entry_224 : Entry := ⟨224, [⟨6, 1, 4, 5⟩, ⟨212, 0, 6, 3⟩]⟩ + +def entry_225 : Entry := ⟨225, [⟨111, 7, 7, 5⟩, ⟨61, 4, 4, 5⟩]⟩ + +def entry_226 : Entry := ⟨226, [⟨10, 6, 0, 3⟩, ⟨203, 0, 5, 4⟩, ⟨33, 0, 2, 3⟩, ⟨193, 0, 2, 4⟩]⟩ + +def entry_227 : Entry := ⟨227, [⟨6, 1, 5, 5⟩, ⟨212, 0, 7, 3⟩]⟩ + +def entry_228 : Entry := ⟨228, [⟨82, 0, 6, 5⟩, ⟨68, 3, 5, 7⟩]⟩ + +def entry_229 : Entry := ⟨229, [⟨171, 0, 7, 3⟩, ⟨45, 1, 4, 5⟩, ⟨46, 3, 4, 5⟩]⟩ + +def entry_230 : Entry := ⟨230, [⟨10, 6, 3, 4⟩, ⟨193, 0, 5, 5⟩, ⟨203, 0, 8, 5⟩, ⟨33, 0, 5, 4⟩]⟩ + +def entry_231 : Entry := ⟨231, [⟨6, 3, 4, 5⟩, ⟨222, 0, 6, 4⟩]⟩ + +def entry_232 : Entry := ⟨232, [⟨24, 2, 5, 4⟩, ⟨107, 1, 4, 6⟩]⟩ + +def entry_233 : Entry := ⟨233, [⟨32, 3, 3, 1⟩, ⟨133, 0, 6, 4⟩]⟩ + +def entry_234 : Entry := ⟨234, [⟨180, 4, 4, 5⟩, ⟨37, 0, 3, 4⟩, ⟨129, 0, 5, 3⟩, ⟨63, 0, 3, 5⟩]⟩ + +def entry_235 : Entry := ⟨235, [⟨7, 3, 3, 4⟩, ⟨110, 0, 6, 4⟩, ⟨70, 0, 3, 5⟩]⟩ + +def entry_236 : Entry := ⟨236, [⟨38, 1, 4, 5⟩, ⟨122, 7, 3, 4⟩, ⟨181, 0, 2, 3⟩, ⟨30, 1, 4, 3⟩]⟩ + +def entry_237 : Entry := ⟨237, [⟨6, 3, 4, 5⟩, ⟨172, 0, 7, 4⟩]⟩ + +def entry_238 : Entry := ⟨238, [⟨6, 3, 4, 5⟩, ⟨178, 5, 7, 4⟩]⟩ + +def entry_239 : Entry := ⟨239, [⟨0, 4, 7, 3⟩, ⟨174, 4, 3, 5⟩]⟩ + +def entry_240 : Entry := ⟨240, [⟨6, 1, 4, 5⟩, ⟨237, 0, 2, 4⟩]⟩ + +def entry_241 : Entry := ⟨241, [⟨131, 1, 5, 4⟩, ⟨159, 1, 5, 4⟩, ⟨61, 0, 4, 5⟩]⟩ + +def entry_242 : Entry := ⟨242, [⟨6, 1, 4, 5⟩, ⟨190, 0, 5, 4⟩]⟩ + +def entry_243 : Entry := ⟨243, [⟨6, 0, 5, 4⟩, ⟨233, 0, 2, 5⟩]⟩ + +def entry_244 : Entry := ⟨244, [⟨99, 4, 2, 5⟩, ⟨99, 0, 4, 5⟩, ⟨11, 7, 3, 3⟩, ⟨173, 2, 5, 4⟩]⟩ + +def entry_245 : Entry := ⟨245, [⟨64, 0, 1, 3⟩, ⟨175, 4, 0, 4⟩, ⟨143, 6, 4, 5⟩, ⟨186, 6, 0, 4⟩]⟩ + +def entry_246 : Entry := ⟨246, [⟨64, 6, 4, 5⟩, ⟨175, 2, 5, 4⟩, ⟨186, 0, 5, 4⟩, ⟨143, 0, 1, 3⟩]⟩ + +def entry_247 : Entry := ⟨247, [⟨6, 4, 3, 4⟩, ⟨229, 0, 4, 5⟩]⟩ + +def entry_248 : Entry := ⟨248, [⟨186, 0, 7, 4⟩, ⟨143, 0, 3, 3⟩, ⟨175, 2, 7, 4⟩, ⟨64, 6, 6, 5⟩]⟩ + +def entry_249 : Entry := ⟨249, [⟨0, 7, 4, 5⟩, ⟨225, 1, 4, 1⟩]⟩ + +def entry_250 : Entry := ⟨250, [⟨6, 1, 4, 5⟩, ⟨238, 0, 2, 4⟩]⟩ + +def entry_251 : Entry := ⟨251, [⟨6, 2, 5, 4⟩, ⟨239, 4, 3, 6⟩]⟩ + +def entry_252 : Entry := ⟨252, [⟨111, 3, 4, 3⟩, ⟨154, 6, 5, 4⟩, ⟨144, 2, 5, 4⟩, ⟨63, 1, 5, 3⟩, ⟨155, 1, 5, 4⟩]⟩ + +def entry_253 : Entry := ⟨253, [⟨29, 3, 3, 0⟩, ⟨177, 1, 6, 2⟩]⟩ + +def entry_254 : Entry := ⟨254, [⟨96, 7, 4, 5⟩, ⟨108, 0, 8, 5⟩]⟩ + +def entry_255 : Entry := ⟨255, [⟨69, 0, 3, 3⟩, ⟨205, 0, 5, 5⟩, ⟨7, 3, 3, 4⟩]⟩ + +def entry_256 : Entry := ⟨256, [⟨0, 5, 4, 5⟩, ⟨231, 0, 3, 4⟩]⟩ + +def entry_257 : Entry := ⟨257, [⟨4, 1, 5, 4⟩, ⟨235, 0, 4, 5⟩]⟩ + +def entry_258 : Entry := ⟨258, [⟨6, 4, 3, 4⟩, ⟨227, 0, 4, 5⟩]⟩ + +def entry_259 : Entry := ⟨259, [⟨6, 4, 3, 4⟩, ⟨231, 1, 7, 2⟩]⟩ + +def entry_260 : Entry := ⟨260, [⟨0, 5, 4, 6⟩, ⟨231, 0, 3, 5⟩]⟩ + +def entry_261 : Entry := ⟨261, [⟨6, 3, 4, 5⟩, ⟨242, 0, 6, 4⟩]⟩ + +def entry_262 : Entry := ⟨262, [⟨0, 7, 5, 7⟩, ⟨213, 0, 3, 4⟩]⟩ + +def entry_263 : Entry := ⟨263, [⟨144, 6, 0, 4⟩, ⟨143, 0, 1, 3⟩, ⟨175, 0, 5, 4⟩, ⟨55, 6, 0, 4⟩]⟩ + +def entry_264 : Entry := ⟨264, [⟨6, 4, 3, 4⟩, ⟨250, 1, 7, 4⟩]⟩ + +def entry_265 : Entry := ⟨265, [⟨6, 6, 3, 4⟩, ⟨247, 0, 4, 6⟩]⟩ + +def entry_266 : Entry := ⟨266, [⟨6, 3, 3, 5⟩, ⟨242, 0, 5, 4⟩]⟩ + +def entry_267 : Entry := ⟨267, [⟨175, 4, 1, 4⟩, ⟨144, 2, 6, 4⟩, ⟨55, 2, 6, 4⟩, ⟨143, 4, 5, 3⟩]⟩ + +def entry_268 : Entry := ⟨268, [⟨6, 0, 5, 4⟩, ⟨251, 0, 4, 2⟩]⟩ + +def entry_269 : Entry := ⟨269, [⟨28, 3, 3, 6⟩, ⟨202, 0, 7, 5⟩]⟩ + +def entry_270 : Entry := ⟨270, [⟨63, 0, 3, 7⟩, ⟨6, 7, 3, 2⟩]⟩ + +def entry_271 : Entry := ⟨271, [⟨107, 2, 7, 3⟩, ⟨107, 3, 4, 6⟩]⟩ + +def entry_272 : Entry := ⟨272, [⟨1, 1, 3, 1⟩, ⟨249, 0, 4, 5⟩]⟩ + +def entry_273 : Entry := ⟨273, [⟨6, 1, 4, 5⟩, ⟨223, 0, 5, 4⟩]⟩ + +def entry_274 : Entry := ⟨274, [⟨6, 7, 3, 1⟩, ⟨240, 0, 5, 5⟩]⟩ + +def entry_275 : Entry := ⟨275, [⟨63, 1, 5, 3⟩, ⟨198, 4, 0, 4⟩, ⟨44, 2, 5, 4⟩]⟩ + +def entry_276 : Entry := ⟨276, [⟨7, 3, 3, 4⟩, ⟨177, 0, 5, 4⟩, ⟨63, 0, 3, 5⟩]⟩ + +def entry_277 : Entry := ⟨277, [⟨14, 3, 4, 5⟩, ⟨204, 2, 3, 0⟩, ⟨33, 1, 3, 2⟩]⟩ + +def entry_278 : Entry := ⟨278, [⟨63, 3, 3, 3⟩, ⟨162, 1, 8, 4⟩]⟩ + +def entry_279 : Entry := ⟨279, [⟨6, 3, 4, 5⟩, ⟨234, 5, 7, 4⟩]⟩ + +def entry_280 : Entry := ⟨280, [⟨184, 0, 1, 5⟩, ⟨116, 2, 4, 3⟩]⟩ + +def entry_281 : Entry := ⟨281, [⟨36, 4, 5, 4⟩, ⟨163, 2, 5, 4⟩, ⟨189, 0, 4, 5⟩]⟩ + +def entry_282 : Entry := ⟨282, [⟨56, 0, 5, 4⟩, ⟨64, 0, 1, 3⟩, ⟨55, 0, 5, 4⟩, ⟨265, 0, 1, 3⟩]⟩ + +def entry_283 : Entry := ⟨283, [⟨64, 0, 1, 3⟩, ⟨196, 1, 4, 3⟩, ⟨55, 2, 5, 4⟩]⟩ + +def entry_284 : Entry := ⟨284, [⟨45, 1, 4, 5⟩, ⟨224, 0, 5, 4⟩, ⟨46, 3, 4, 5⟩]⟩ + +def entry_285 : Entry := ⟨285, [⟨6, 3, 4, 5⟩, ⟨273, 0, 6, 4⟩]⟩ + +def entry_286 : Entry := ⟨286, [⟨6, 7, 3, 0⟩, ⟨261, 0, 3, 4⟩]⟩ + +def entry_287 : Entry := ⟨287, [⟨64, 0, 1, 3⟩, ⟨55, 0, 5, 4⟩, ⟨56, 0, 5, 4⟩, ⟨264, 4, 4, 5⟩]⟩ + +def entry_288 : Entry := ⟨288, [⟨130, 1, 4, 2⟩, ⟨96, 0, 1, 4⟩]⟩ + +def entry_289 : Entry := ⟨289, [⟨6, 1, 4, 5⟩, ⟨279, 0, 2, 4⟩]⟩ + +def entry_290 : Entry := ⟨290, [⟨67, 2, 5, 2⟩, ⟨231, 4, 5, 5⟩]⟩ + +def entry_291 : Entry := ⟨291, [⟨89, 3, 3, 4⟩, ⟨202, 0, 8, 4⟩, ⟨55, 4, 3, 4⟩]⟩ + +def entry_292 : Entry := ⟨292, [⟨39, 0, 3, 4⟩, ⟨219, 3, 3, 4⟩, ⟨79, 1, 4, 3⟩]⟩ + +def entry_293 : Entry := ⟨293, [⟨2, 7, 4, 3⟩, ⟨280, 0, 5, 4⟩]⟩ + +def entry_294 : Entry := ⟨294, [⟨63, 1, 5, 3⟩, ⟨196, 3, 1, 3⟩]⟩ + +def entry_295 : Entry := ⟨295, [⟨63, 1, 5, 3⟩, ⟨64, 2, 1, 5⟩, ⟨55, 0, 5, 4⟩, ⟨265, 4, 4, 3⟩]⟩ + +def entry_296 : Entry := ⟨296, [⟨107, 1, 4, 5⟩, ⟨209, 3, 3, 4⟩, ⟨65, 1, 4, 5⟩]⟩ + +def entry_297 : Entry := ⟨297, [⟨6, 4, 3, 4⟩, ⟨289, 1, 7, 4⟩]⟩ + +def entry_298 : Entry := ⟨298, [⟨24, 2, 7, 3⟩, ⟨24, 6, 3, 3⟩, ⟨107, 4, 3, 4⟩, ⟨195, 0, 7, 4⟩]⟩ + +def entry_299 : Entry := ⟨299, [⟨6, 4, 3, 4⟩, ⟨284, 0, 4, 5⟩]⟩ + +def entry_300 : Entry := ⟨300, [⟨64, 3, 5, 1⟩, ⟨240, 2, 5, 1⟩, ⟨55, 3, 4, 5⟩]⟩ + +def entry_301 : Entry := ⟨301, [⟨59, 0, 5, 4⟩, ⟨57, 0, 5, 4⟩, ⟨258, 4, 4, 5⟩]⟩ + +def entry_302 : Entry := ⟨302, [⟨125, 0, 5, 3⟩, ⟨162, 4, 3, 6⟩]⟩ + +def entry_303 : Entry := ⟨303, [⟨49, 4, 4, 5⟩, ⟨44, 1, 4, 5⟩, ⟨63, 0, 3, 5⟩, ⟨261, 0, 3, 4⟩]⟩ + +def entry_304 : Entry := ⟨304, [⟨55, 4, 3, 4⟩, ⟨202, 0, 8, 4⟩, ⟨131, 3, 3, 4⟩]⟩ + +def entry_305 : Entry := ⟨305, [⟨6, 1, 4, 5⟩, ⟨278, 0, 1, 4⟩]⟩ + +end SnakyCertificate + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Entries03.lean b/lean/OAI/Combinatorics/SnakyCertificate/Entries03.lean new file mode 100644 index 0000000000000000000000000000000000000000..8aabc0650a803b29590ef0d27070de3d9b60ca1c --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Entries03.lean @@ -0,0 +1,209 @@ +import OAI.Combinatorics.SnakyCertificate.Basic + +namespace OAI + +namespace SnakyCertificate + +def entry_306 : Entry := ⟨306, [⟨4, 1, 4, 3⟩, ⟨288, 0, 6, 4⟩]⟩ + +def entry_307 : Entry := ⟨307, [⟨0, 7, 4, 6⟩, ⟨273, 0, 5, 5⟩]⟩ + +def entry_308 : Entry := ⟨308, [⟨6, 6, 3, 4⟩, ⟨299, 0, 4, 6⟩]⟩ + +def entry_309 : Entry := ⟨309, [⟨28, 6, 3, 4⟩, ⟨268, 1, 5, 7⟩]⟩ + +def entry_310 : Entry := ⟨310, [⟨6, 1, 4, 5⟩, ⟨281, 0, 5, 3⟩]⟩ + +def entry_311 : Entry := ⟨311, [⟨6, 3, 3, 5⟩, ⟨278, 0, 2, 4⟩]⟩ + +def entry_312 : Entry := ⟨312, [⟨9, 2, 5, 4⟩, ⟨272, 0, 4, 5⟩]⟩ + +def entry_313 : Entry := ⟨313, [⟨162, 4, 4, 5⟩, ⟨148, 5, 6, 3⟩]⟩ + +def entry_314 : Entry := ⟨314, [⟨6, 3, 4, 5⟩, ⟨305, 0, 6, 4⟩]⟩ + +def entry_315 : Entry := ⟨315, [⟨6, 0, 5, 4⟩, ⟨296, 0, 4, 5⟩]⟩ + +def entry_316 : Entry := ⟨316, [⟨6, 6, 3, 4⟩, ⟨306, 0, 5, 8⟩]⟩ + +def entry_317 : Entry := ⟨317, [⟨263, 2, 6, 4⟩, ⟨26, 3, 4, 3⟩, ⟨99, 0, 5, 5⟩]⟩ + +def entry_318 : Entry := ⟨318, [⟨64, 3, 5, 1⟩, ⟨63, 0, 3, 5⟩, ⟨261, 0, 3, 4⟩, ⟨55, 1, 4, 5⟩]⟩ + +def entry_319 : Entry := ⟨319, [⟨39, 2, 3, 4⟩, ⟨109, 4, 0, 5⟩, ⟨266, 1, 4, 5⟩, ⟨122, 4, 4, 5⟩]⟩ + +def entry_320 : Entry := ⟨320, [⟨19, 1, 4, 3⟩, ⟨267, 2, 6, 4⟩, ⟨115, 7, 4, 3⟩]⟩ + +def entry_321 : Entry := ⟨321, [⟨165, 1, 3, 4⟩, ⟨97, 0, 7, 5⟩, ⟨223, 3, 4, 7⟩]⟩ + +def entry_322 : Entry := ⟨322, [⟨96, 0, 1, 4⟩, ⟨205, 1, 5, 2⟩]⟩ + +def entry_323 : Entry := ⟨323, [⟨165, 6, 4, 5⟩, ⟨278, 0, 1, 4⟩, ⟨25, 1, 4, 5⟩]⟩ + +def entry_324 : Entry := ⟨324, [⟨6, 3, 4, 5⟩, ⟨298, 0, 3, 4⟩]⟩ + +def entry_325 : Entry := ⟨325, [⟨25, 0, 6, 5⟩, ⟨313, 1, 6, 4⟩, ⟨24, 2, 6, 3⟩]⟩ + +def entry_326 : Entry := ⟨326, [⟨63, 1, 5, 3⟩, ⟨255, 7, 0, 4⟩]⟩ + +def entry_327 : Entry := ⟨327, [⟨24, 2, 6, 3⟩, ⟨195, 4, 2, 4⟩, ⟨195, 0, 6, 4⟩, ⟨24, 6, 2, 3⟩]⟩ + +def entry_328 : Entry := ⟨328, [⟨49, 0, 4, 5⟩, ⟨44, 3, 4, 5⟩, ⟨285, 0, 3, 4⟩]⟩ + +def entry_329 : Entry := ⟨329, [⟨0, 7, 4, 6⟩, ⟨305, 0, 5, 5⟩]⟩ + +def entry_330 : Entry := ⟨330, [⟨63, 1, 5, 3⟩, ⟨268, 0, 4, 5⟩, ⟨144, 0, 5, 4⟩, ⟨154, 4, 5, 4⟩, ⟨155, 5, 5, 4⟩]⟩ + +def entry_331 : Entry := ⟨331, [⟨113, 0, 1, 4⟩, ⟨15, 0, 3, 4⟩, ⟨298, 4, 4, 5⟩, ⟨90, 2, 5, 4⟩]⟩ + +def entry_332 : Entry := ⟨332, [⟨67, 4, 3, 4⟩, ⟨289, 2, 5, 1⟩]⟩ + +def entry_333 : Entry := ⟨333, [⟨317, 0, 5, 4⟩, ⟨1, 5, 4, 3⟩]⟩ + +def entry_334 : Entry := ⟨334, [⟨67, 6, 3, 2⟩, ⟨289, 0, 5, 5⟩]⟩ + +def entry_335 : Entry := ⟨335, [⟨196, 3, 1, 3⟩, ⟨162, 1, 5, 4⟩]⟩ + +def entry_336 : Entry := ⟨336, [⟨25, 6, 2, 3⟩, ⟨199, 3, 2, 4⟩, ⟨65, 0, 6, 4⟩, ⟨304, 0, 2, 4⟩]⟩ + +def entry_337 : Entry := ⟨337, [⟨107, 3, 3, 7⟩, ⟨230, 2, 1, 5⟩]⟩ + +def entry_338 : Entry := ⟨338, [⟨241, 0, 6, 4⟩, ⟨275, 4, 2, 4⟩, ⟨107, 4, 2, 4⟩]⟩ + +def entry_339 : Entry := ⟨339, [⟨4, 1, 4, 3⟩, ⟨322, 0, 6, 4⟩]⟩ + +def entry_340 : Entry := ⟨340, [⟨25, 3, 3, 6⟩, ⟨300, 4, 4, 6⟩, ⟨24, 3, 3, 6⟩]⟩ + +def entry_341 : Entry := ⟨341, [⟨162, 5, 5, 4⟩, ⟨259, 4, 4, 5⟩, ⟨208, 2, 5, 4⟩, ⟨143, 0, 1, 3⟩]⟩ + +def entry_342 : Entry := ⟨342, [⟨210, 0, 5, 2⟩, ⟨88, 1, 4, 3⟩, ⟨260, 4, 4, 3⟩, ⟨290, 0, 4, 3⟩]⟩ + +def entry_343 : Entry := ⟨343, [⟨0, 5, 4, 5⟩, ⟨250, 0, 5, 4⟩]⟩ + +def entry_344 : Entry := ⟨344, [⟨7, 1, 5, 4⟩, ⟨108, 3, 4, 5⟩, ⟨262, 4, 5, 2⟩]⟩ + +def entry_345 : Entry := ⟨345, [⟨6, 0, 5, 5⟩, ⟨320, 4, 4, 7⟩]⟩ + +def entry_346 : Entry := ⟨346, [⟨60, 1, 4, 3⟩, ⟨255, 0, 1, 4⟩, ⟨276, 0, 1, 4⟩]⟩ + +def entry_347 : Entry := ⟨347, [⟨6, 6, 3, 4⟩, ⟨339, 0, 5, 8⟩]⟩ + +def entry_348 : Entry := ⟨348, [⟨312, 1, 5, 5⟩, ⟨114, 4, 3, 4⟩, ⟨139, 3, 4, 5⟩]⟩ + +def entry_349 : Entry := ⟨349, [⟨14, 1, 4, 5⟩, ⟨17, 1, 4, 5⟩, ⟨332, 0, 3, 4⟩]⟩ + +def entry_350 : Entry := ⟨350, [⟨24, 4, 2, 5⟩, ⟨107, 2, 6, 4⟩, ⟨271, 4, 5, 5⟩, ⟨215, 0, 5, 5⟩]⟩ + +def entry_351 : Entry := ⟨351, [⟨163, 0, 5, 4⟩, ⟨287, 4, 1, 4⟩, ⟨25, 4, 1, 5⟩]⟩ + +def entry_352 : Entry := ⟨352, [⟨214, 0, 4, 5⟩, ⟨91, 0, 3, 4⟩, ⟨63, 0, 3, 5⟩, ⟨344, 0, 4, 5⟩, ⟨180, 4, 4, 5⟩]⟩ + +def entry_353 : Entry := ⟨353, [⟨6, 4, 0, 5⟩, ⟨347, 0, 1, 3⟩]⟩ + +def entry_354 : Entry := ⟨354, [⟨138, 2, 5, 4⟩, ⟨114, 5, 4, 3⟩, ⟨312, 0, 5, 5⟩, ⟨182, 2, 2, 4⟩]⟩ + +def entry_355 : Entry := ⟨355, [⟨12, 2, 7, 3⟩, ⟨167, 0, 7, 4⟩, ⟨342, 0, 6, 6⟩]⟩ + +def entry_356 : Entry := ⟨356, [⟨24, 2, 6, 3⟩, ⟨24, 6, 2, 3⟩, ⟨211, 4, 2, 4⟩, ⟨179, 0, 6, 4⟩]⟩ + +def entry_357 : Entry := ⟨357, [⟨82, 6, 2, 3⟩, ⟨283, 0, 5, 6⟩]⟩ + +def entry_358 : Entry := ⟨358, [⟨6, 0, 5, 4⟩, ⟨346, 0, 4, 6⟩]⟩ + +def entry_359 : Entry := ⟨359, [⟨134, 0, 4, 6⟩, ⟨24, 7, 3, 2⟩, ⟨323, 0, 5, 5⟩]⟩ + +def entry_360 : Entry := ⟨360, [⟨155, 4, 4, 5⟩, ⟨7, 3, 3, 4⟩, ⟨337, 0, 5, 2⟩, ⟨228, 4, 5, 2⟩]⟩ + +def entry_361 : Entry := ⟨361, [⟨6, 4, 3, 4⟩, ⟨352, 0, 4, 5⟩]⟩ + +def entry_362 : Entry := ⟨362, [⟨4, 0, 3, 4⟩, ⟨345, 0, 4, 3⟩]⟩ + +def entry_363 : Entry := ⟨363, [⟨137, 1, 4, 2⟩, ⟨248, 0, 2, 4⟩]⟩ + +def entry_364 : Entry := ⟨364, [⟨63, 0, 3, 5⟩, ⟨314, 2, 3, 1⟩]⟩ + +def entry_365 : Entry := ⟨365, [⟨6, 1, 4, 5⟩, ⟨354, 0, 4, 3⟩]⟩ + +def entry_366 : Entry := ⟨366, [⟨6, 3, 4, 5⟩, ⟨357, 0, 6, 2⟩]⟩ + +def entry_367 : Entry := ⟨367, [⟨6, 2, 5, 4⟩, ⟨361, 4, 4, 6⟩]⟩ + +def entry_368 : Entry := ⟨368, [⟨6, 1, 4, 5⟩, ⟨366, 0, 2, 4⟩]⟩ + +def entry_369 : Entry := ⟨369, [⟨6, 0, 5, 4⟩, ⟨367, 4, 1, 2⟩]⟩ + +def entry_370 : Entry := ⟨370, [⟨199, 3, 1, 4⟩, ⟨286, 1, 5, 4⟩, ⟨24, 6, 1, 3⟩, ⟨319, 0, 5, 3⟩]⟩ + +def entry_371 : Entry := ⟨371, [⟨267, 6, 2, 4⟩, ⟨137, 1, 4, 2⟩]⟩ + +def entry_372 : Entry := ⟨372, [⟨40, 1, 4, 3⟩, ⟨333, 0, 2, 4⟩, ⟨120, 1, 3, 3⟩, ⟨161, 0, 4, 2⟩]⟩ + +def entry_373 : Entry := ⟨373, [⟨156, 2, 7, 4⟩, ⟨226, 4, 3, 5⟩, ⟨80, 0, 5, 4⟩, ⟨327, 0, 5, 5⟩, ⟨156, 6, 3, 4⟩]⟩ + +def entry_374 : Entry := ⟨374, [⟨65, 4, 3, 4⟩, ⟨335, 0, 7, 4⟩, ⟨24, 2, 7, 3⟩, ⟨163, 4, 3, 4⟩]⟩ + +def entry_375 : Entry := ⟨375, [⟨24, 3, 3, 6⟩, ⟨327, 6, 3, 3⟩]⟩ + +def entry_376 : Entry := ⟨376, [⟨162, 1, 5, 4⟩, ⟨285, 3, 1, 3⟩]⟩ + +def entry_377 : Entry := ⟨377, [⟨29, 3, 3, 0⟩, ⟨362, 0, 7, 2⟩]⟩ + +def entry_378 : Entry := ⟨378, [⟨295, 0, 5, 4⟩, ⟨176, 4, 1, 4⟩, ⟨183, 4, 1, 4⟩, ⟨172, 6, 1, 4⟩, ⟨294, 4, 1, 4⟩]⟩ + +def entry_379 : Entry := ⟨379, [⟨63, 0, 3, 5⟩, ⟨64, 1, 3, 1⟩, ⟨55, 3, 4, 5⟩, ⟨368, 0, 5, 4⟩]⟩ + +def entry_380 : Entry := ⟨380, [⟨101, 4, 2, 5⟩, ⟨271, 0, 2, 5⟩, ⟨223, 0, 5, 4⟩, ⟨192, 3, 1, 4⟩]⟩ + +def entry_381 : Entry := ⟨381, [⟨211, 6, 3, 4⟩, ⟨24, 0, 7, 5⟩, ⟨163, 4, 3, 4⟩, ⟨341, 0, 7, 4⟩]⟩ + +def entry_382 : Entry := ⟨382, [⟨124, 1, 5, 3⟩, ⟨2, 7, 4, 3⟩]⟩ + +def entry_383 : Entry := ⟨383, [⟨192, 3, 2, 4⟩, ⟨271, 0, 3, 5⟩, ⟨197, 0, 6, 4⟩, ⟨172, 0, 6, 4⟩, ⟨215, 4, 3, 5⟩]⟩ + +def entry_384 : Entry := ⟨384, [⟨173, 2, 6, 4⟩, ⟨282, 4, 2, 4⟩, ⟨220, 2, 6, 4⟩, ⟨246, 2, 6, 4⟩, ⟨263, 2, 6, 4⟩, ⟨183, 6, 2, 4⟩, ⟨295, 0, 6, 4⟩]⟩ + +def entry_385 : Entry := ⟨385, [⟨63, 1, 5, 3⟩, ⟨64, 2, 1, 5⟩, ⟨55, 0, 5, 4⟩, ⟨369, 4, 1, 5⟩]⟩ + +def entry_386 : Entry := ⟨386, [⟨217, 4, 1, 4⟩, ⟨172, 0, 5, 4⟩, ⟨173, 4, 1, 4⟩, ⟨217, 0, 5, 4⟩, ⟨294, 0, 5, 4⟩, ⟨294, 4, 1, 4⟩]⟩ + +def entry_387 : Entry := ⟨387, [⟨14, 1, 4, 6⟩, ⟨370, 0, 5, 4⟩]⟩ + +def entry_388 : Entry := ⟨388, [⟨6, 3, 4, 5⟩, ⟨374, 0, 3, 4⟩]⟩ + +def entry_389 : Entry := ⟨389, [⟨197, 5, 4, 1⟩, ⟨215, 7, 3, 2⟩, ⟨271, 3, 3, 2⟩, ⟨236, 0, 5, 5⟩, ⟨192, 6, 4, 1⟩]⟩ + +def entry_390 : Entry := ⟨390, [⟨372, 2, 5, 0⟩, ⟨167, 5, 4, 1⟩, ⟨12, 7, 3, 1⟩]⟩ + +def entry_391 : Entry := ⟨391, [⟨6, 5, 5, 1⟩, ⟨388, 0, 3, 5⟩]⟩ + +def entry_392 : Entry := ⟨392, [⟨24, 7, 3, 1⟩, ⟨107, 1, 4, 5⟩, ⟨236, 0, 5, 5⟩, ⟨364, 2, 4, 1⟩]⟩ + +def entry_393 : Entry := ⟨393, [⟨107, 3, 4, 5⟩, ⟨348, 0, 6, 3⟩, ⟨65, 3, 4, 5⟩, ⟨303, 0, 4, 5⟩]⟩ + +def entry_394 : Entry := ⟨394, [⟨226, 4, 1, 4⟩, ⟨226, 0, 5, 4⟩, ⟨327, 4, 3, 4⟩, ⟨327, 6, 3, 3⟩, ⟨226, 6, 1, 3⟩, ⟨226, 2, 5, 3⟩]⟩ + +def entry_395 : Entry := ⟨395, [⟨211, 4, 2, 4⟩, ⟨376, 0, 6, 4⟩, ⟨24, 2, 6, 3⟩, ⟨236, 3, 2, 5⟩]⟩ + +def entry_396 : Entry := ⟨396, [⟨107, 3, 4, 5⟩, ⟨365, 1, 7, 3⟩, ⟨303, 0, 4, 5⟩, ⟨65, 3, 4, 5⟩]⟩ + +def entry_397 : Entry := ⟨397, [⟨24, 3, 4, 5⟩, ⟨374, 0, 3, 4⟩, ⟨65, 5, 5, 1⟩]⟩ + +def entry_398 : Entry := ⟨398, [⟨257, 0, 1, 3⟩, ⟨363, 0, 5, 4⟩, ⟨130, 1, 4, 2⟩, ⟨177, 1, 4, 2⟩]⟩ + +def entry_399 : Entry := ⟨399, [⟨192, 6, 4, 1⟩, ⟨271, 3, 3, 2⟩, ⟨173, 1, 4, 5⟩, ⟨319, 1, 3, 5⟩, ⟨215, 7, 3, 2⟩]⟩ + +def entry_400 : Entry := ⟨400, [⟨283, 4, 2, 4⟩, ⟨252, 4, 2, 4⟩, ⟨176, 4, 2, 4⟩, ⟨197, 0, 6, 4⟩, ⟨283, 0, 6, 4⟩, ⟨245, 4, 2, 4⟩]⟩ + +def entry_401 : Entry := ⟨401, [⟨24, 7, 3, 2⟩, ⟨286, 0, 4, 6⟩, ⟨364, 2, 4, 2⟩, ⟨319, 1, 3, 6⟩]⟩ + +def entry_402 : Entry := ⟨402, [⟨29, 3, 3, 0⟩, ⟨384, 0, 5, 4⟩]⟩ + +def entry_403 : Entry := ⟨403, [⟨202, 1, 4, 5⟩, ⟨180, 0, 4, 5⟩, ⟨314, 4, 5, 4⟩, ⟨63, 0, 3, 5⟩, ⟨388, 0, 3, 4⟩]⟩ + +def entry_404 : Entry := ⟨404, [⟨82, 6, 2, 3⟩, ⟨388, 4, 4, 6⟩]⟩ + +def entry_405 : Entry := ⟨405, [⟨391, 0, 4, 3⟩, ⟨301, 0, 5, 2⟩, ⟨42, 1, 4, 3⟩]⟩ + +end SnakyCertificate + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Entries04.lean b/lean/OAI/Combinatorics/SnakyCertificate/Entries04.lean new file mode 100644 index 0000000000000000000000000000000000000000..ae94ebfb4ec07d53afc8111ddd9667993cc9977c --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Entries04.lean @@ -0,0 +1,209 @@ +import OAI.Combinatorics.SnakyCertificate.Basic + +namespace OAI + +namespace SnakyCertificate + +def entry_406 : Entry := ⟨406, [⟨295, 1, 4, 5⟩, ⟨172, 7, 4, 1⟩, ⟨245, 3, 4, 5⟩, ⟨197, 5, 4, 1⟩, ⟨236, 0, 5, 5⟩, ⟨176, 3, 4, 5⟩, ⟨364, 2, 4, 1⟩]⟩ + +def entry_407 : Entry := ⟨407, [⟨285, 0, 3, 7⟩, ⟨314, 6, 5, 4⟩]⟩ + +def entry_408 : Entry := ⟨408, [⟨357, 0, 5, 2⟩, ⟨229, 7, 2, 4⟩, ⟨223, 4, 2, 4⟩, ⟨223, 0, 6, 4⟩]⟩ + +def entry_409 : Entry := ⟨409, [⟨136, 6, 4, 3⟩, ⟨384, 0, 5, 4⟩, ⟨133, 4, 4, 3⟩, ⟨110, 3, 4, 3⟩]⟩ + +def entry_410 : Entry := ⟨410, [⟨0, 4, 5, 4⟩, ⟨405, 0, 3, 7⟩]⟩ + +def entry_411 : Entry := ⟨411, [⟨252, 0, 7, 4⟩, ⟨263, 0, 7, 4⟩, ⟨300, 3, 3, 4⟩, ⟨379, 1, 7, 4⟩, ⟨173, 0, 7, 4⟩, ⟨246, 0, 7, 4⟩]⟩ + +def entry_412 : Entry := ⟨412, [⟨0, 0, 0, 3⟩, ⟨403, 4, 3, 6⟩]⟩ + +def entry_413 : Entry := ⟨413, [⟨3, 7, 4, 3⟩, ⟨403, 0, 4, 7⟩]⟩ + +def entry_414 : Entry := ⟨414, [⟨374, 0, 2, 5⟩, ⟨199, 2, 4, 2⟩, ⟨185, 2, 4, 2⟩]⟩ + +def entry_415 : Entry := ⟨415, [⟨177, 1, 4, 2⟩, ⟨164, 1, 4, 2⟩, ⟨205, 1, 5, 2⟩, ⟨384, 0, 3, 4⟩, ⟨371, 0, 5, 4⟩]⟩ + +def entry_416 : Entry := ⟨416, [⟨176, 2, 5, 4⟩, ⟨385, 4, 1, 4⟩, ⟨197, 4, 1, 4⟩, ⟨295, 0, 5, 4⟩, ⟨245, 2, 5, 4⟩, ⟨220, 2, 5, 4⟩]⟩ + +def entry_417 : Entry := ⟨417, [⟨409, 0, 2, 4⟩, ⟨11, 1, 4, 2⟩, ⟨270, 4, 4, 2⟩]⟩ + +def entry_418 : Entry := ⟨418, [⟨68, 4, 1, 3⟩, ⟨62, 6, 1, 3⟩, ⟨147, 6, 1, 3⟩, ⟨413, 0, 4, 2⟩]⟩ + +def entry_419 : Entry := ⟨419, [⟨243, 0, 4, 2⟩, ⟨164, 1, 4, 2⟩, ⟨402, 0, 2, 4⟩, ⟨253, 0, 2, 4⟩, ⟨377, 0, 2, 4⟩]⟩ + +def entry_420 : Entry := ⟨420, [⟨29, 3, 3, 0⟩, ⟨415, 0, 6, 4⟩]⟩ + +def entry_421 : Entry := ⟨421, [⟨24, 6, 2, 3⟩, ⟨397, 1, 5, 3⟩, ⟨25, 6, 2, 3⟩, ⟨241, 4, 2, 4⟩]⟩ + +def entry_422 : Entry := ⟨422, [⟨45, 1, 3, 7⟩, ⟨106, 6, 2, 3⟩, ⟨419, 1, 6, 6⟩]⟩ + +def entry_423 : Entry := ⟨423, [⟨378, 4, 2, 4⟩, ⟨386, 0, 5, 4⟩, ⟨226, 3, 3, 5⟩, ⟨386, 4, 2, 4⟩, ⟨378, 0, 5, 4⟩]⟩ + +def entry_424 : Entry := ⟨424, [⟨55, 1, 4, 5⟩, ⟨394, 0, 6, 4⟩, ⟨216, 3, 4, 5⟩]⟩ + +def entry_425 : Entry := ⟨425, [⟨386, 0, 5, 4⟩, ⟨226, 1, 4, 5⟩, ⟨378, 4, 2, 4⟩, ⟨378, 0, 5, 4⟩, ⟨386, 4, 2, 4⟩]⟩ + +def entry_426 : Entry := ⟨426, [⟨300, 6, 4, 1⟩, ⟨252, 1, 4, 5⟩, ⟨397, 0, 3, 4⟩, ⟨291, 1, 4, 1⟩, ⟨328, 0, 4, 5⟩, ⟨319, 1, 3, 5⟩]⟩ + +def entry_427 : Entry := ⟨427, [⟨45, 1, 3, 7⟩, ⟨106, 6, 2, 3⟩, ⟨420, 1, 6, 4⟩]⟩ + +def entry_428 : Entry := ⟨428, [⟨26, 3, 4, 3⟩, ⟨416, 0, 5, 4⟩, ⟨244, 0, 5, 4⟩, ⟨329, 0, 4, 3⟩]⟩ + +def entry_429 : Entry := ⟨429, [⟨128, 0, 6, 3⟩, ⟨28, 3, 4, 5⟩]⟩ + +def entry_430 : Entry := ⟨430, [⟨277, 7, 1, 3⟩, ⟨338, 4, 3, 4⟩, ⟨336, 1, 4, 3⟩, ⟨375, 2, 4, 3⟩, ⟨277, 6, 3, 1⟩]⟩ + +def entry_431 : Entry := ⟨431, [⟨73, 4, 3, 3⟩, ⟨302, 1, 5, 2⟩, ⟨415, 0, 6, 4⟩, ⟨398, 0, 6, 4⟩]⟩ + +def entry_432 : Entry := ⟨432, [⟨42, 3, 4, 3⟩, ⟨428, 0, 5, 4⟩, ⟨274, 0, 4, 3⟩]⟩ + +def entry_433 : Entry := ⟨433, [⟨63, 0, 3, 5⟩, ⟨7, 3, 3, 4⟩, ⟨427, 0, 5, 2⟩, ⟨422, 0, 5, 2⟩]⟩ + +def entry_434 : Entry := ⟨434, [⟨418, 0, 4, 5⟩, ⟨263, 2, 5, 4⟩, ⟨295, 0, 5, 4⟩, ⟨176, 2, 5, 4⟩, ⟨116, 0, 4, 3⟩]⟩ + +def entry_435 : Entry := ⟨435, [⟨6, 4, 3, 4⟩, ⟨431, 0, 5, 6⟩]⟩ + +def entry_436 : Entry := ⟨436, [⟨51, 1, 5, 4⟩, ⟨60, 3, 4, 3⟩, ⟨274, 4, 4, 3⟩, ⟨428, 0, 5, 4⟩]⟩ + +def entry_437 : Entry := ⟨437, [⟨55, 7, 4, 0⟩, ⟨427, 0, 5, 2⟩, ⟨63, 0, 3, 5⟩, ⟨422, 0, 5, 2⟩]⟩ + +def entry_438 : Entry := ⟨438, [⟨0, 0, 1, 3⟩, ⟨432, 0, 4, 6⟩]⟩ + +def entry_439 : Entry := ⟨439, [⟨176, 2, 5, 4⟩, ⟨295, 0, 5, 4⟩, ⟨263, 2, 5, 4⟩, ⟨418, 0, 4, 5⟩, ⟨149, 0, 4, 3⟩]⟩ + +def entry_440 : Entry := ⟨440, [⟨6, 6, 1, 3⟩, ⟨435, 0, 2, 5⟩]⟩ + +def entry_441 : Entry := ⟨441, [⟨6, 6, 3, 4⟩, ⟨435, 0, 4, 6⟩]⟩ + +def entry_442 : Entry := ⟨442, [⟨63, 0, 3, 5⟩, ⟨7, 1, 5, 4⟩, ⟨433, 0, 4, 5⟩, ⟨201, 0, 3, 2⟩]⟩ + +def entry_443 : Entry := ⟨443, [⟨6, 0, 5, 4⟩, ⟨438, 0, 3, 4⟩]⟩ + +def entry_444 : Entry := ⟨444, [⟨194, 0, 5, 3⟩, ⟨160, 3, 4, 1⟩, ⟨142, 7, 4, 1⟩, ⟨236, 0, 5, 5⟩, ⟨353, 4, 1, 2⟩, ⟨412, 0, 5, 3⟩]⟩ + +def entry_445 : Entry := ⟨445, [⟨9, 4, 3, 4⟩, ⟨432, 0, 5, 7⟩]⟩ + +def entry_446 : Entry := ⟨446, [⟨4, 6, 4, 3⟩, ⟨438, 0, 6, 5⟩]⟩ + +def entry_447 : Entry := ⟨447, [⟨0, 0, 0, 3⟩, ⟨436, 4, 4, 6⟩]⟩ + +def entry_448 : Entry := ⟨448, [⟨9, 4, 1, 3⟩, ⟨436, 0, 3, 6⟩]⟩ + +def entry_449 : Entry := ⟨449, [⟨26, 3, 4, 3⟩, ⟨244, 0, 5, 4⟩, ⟨439, 0, 5, 4⟩, ⟨307, 0, 4, 3⟩]⟩ + +def entry_450 : Entry := ⟨450, [⟨6, 1, 5, 5⟩, ⟨440, 0, 6, 4⟩]⟩ + +def entry_451 : Entry := ⟨451, [⟨1, 5, 4, 3⟩, ⟨449, 0, 5, 4⟩]⟩ + +def entry_452 : Entry := ⟨452, [⟨24, 1, 5, 7⟩, ⟨451, 0, 3, 8⟩, ⟨25, 3, 3, 7⟩]⟩ + +def entry_453 : Entry := ⟨453, [⟨359, 0, 4, 3⟩, ⟨226, 7, 3, 1⟩, ⟨386, 4, 2, 4⟩, ⟨389, 1, 5, 4⟩, ⟨414, 4, 3, 3⟩]⟩ + +def entry_454 : Entry := ⟨454, [⟨58, 0, 6, 3⟩, ⟨436, 0, 3, 6⟩]⟩ + +def entry_455 : Entry := ⟨455, [⟨20, 2, 4, 5⟩, ⟨118, 3, 0, 5⟩, ⟨39, 2, 3, 4⟩]⟩ + +def entry_456 : Entry := ⟨456, [⟨308, 4, 4, 3⟩, ⟨64, 2, 1, 5⟩, ⟨63, 1, 5, 3⟩, ⟨55, 0, 5, 4⟩]⟩ + +def entry_457 : Entry := ⟨457, [⟨28, 7, 3, 2⟩, ⟨454, 0, 5, 4⟩]⟩ + +def entry_458 : Entry := ⟨458, [⟨130, 1, 4, 2⟩, ⟨177, 1, 4, 2⟩, ⟨450, 0, 1, 4⟩]⟩ + +def entry_459 : Entry := ⟨459, [⟨97, 2, 7, 3⟩, ⟨448, 0, 5, 4⟩, ⟨65, 2, 7, 3⟩]⟩ + +def entry_460 : Entry := ⟨460, [⟨183, 6, 1, 4⟩, ⟨173, 2, 5, 4⟩, ⟨295, 0, 5, 4⟩, ⟨282, 4, 1, 4⟩, ⟨246, 2, 5, 4⟩, ⟨263, 2, 5, 4⟩, ⟨220, 2, 5, 4⟩]⟩ + +def entry_461 : Entry := ⟨461, [⟨4, 1, 4, 3⟩, ⟨458, 0, 6, 4⟩]⟩ + +def entry_462 : Entry := ⟨462, [⟨452, 0, 3, 2⟩, ⟨86, 0, 5, 4⟩, ⟨328, 1, 5, 4⟩]⟩ + +def entry_463 : Entry := ⟨463, [⟨170, 0, 6, 3⟩, ⟨76, 1, 3, 2⟩, ⟨447, 0, 5, 4⟩]⟩ + +def entry_464 : Entry := ⟨464, [⟨63, 0, 3, 5⟩, ⟨224, 0, 5, 4⟩, ⟨315, 0, 7, 3⟩, ⟨306, 0, 5, 5⟩, ⟨358, 0, 7, 3⟩, ⟨461, 0, 5, 5⟩]⟩ + +def entry_465 : Entry := ⟨465, [⟨55, 3, 4, 5⟩, ⟨285, 0, 3, 4⟩, ⟨64, 1, 3, 1⟩]⟩ + +def entry_466 : Entry := ⟨466, [⟨395, 4, 3, 4⟩, ⟨360, 4, 2, 6⟩, ⟨417, 1, 5, 4⟩, ⟨325, 4, 3, 4⟩, ⟨324, 4, 3, 5⟩]⟩ + +def entry_467 : Entry := ⟨467, [⟨64, 7, 5, 7⟩, ⟨314, 6, 5, 4⟩, ⟨443, 1, 5, 7⟩]⟩ + +def entry_468 : Entry := ⟨468, [⟨6, 6, 3, 4⟩, ⟨464, 0, 4, 7⟩]⟩ + +def entry_469 : Entry := ⟨469, [⟨55, 5, 4, 3⟩, ⟨443, 1, 5, 7⟩, ⟨314, 6, 5, 4⟩]⟩ + +def entry_470 : Entry := ⟨470, [⟨6, 4, 3, 4⟩, ⟨468, 0, 4, 2⟩]⟩ + +def entry_471 : Entry := ⟨471, [⟨6, 5, 4, 3⟩, ⟨466, 0, 5, 6⟩]⟩ + +def entry_472 : Entry := ⟨472, [⟨6, 5, 5, 0⟩, ⟨466, 0, 6, 3⟩]⟩ + +def entry_473 : Entry := ⟨473, [⟨121, 5, 5, 4⟩, ⟨436, 0, 3, 7⟩, ⟨445, 4, 5, 4⟩]⟩ + +def entry_474 : Entry := ⟨474, [⟨463, 0, 6, 5⟩, ⟨70, 0, 3, 5⟩, ⟨83, 1, 5, 3⟩]⟩ + +def entry_475 : Entry := ⟨475, [⟨63, 1, 5, 3⟩, ⟨261, 1, 4, 3⟩, ⟨457, 0, 2, 5⟩, ⟨269, 2, 2, 5⟩]⟩ + +def entry_476 : Entry := ⟨476, [⟨0, 0, 1, 3⟩, ⟨473, 0, 5, 3⟩]⟩ + +def entry_477 : Entry := ⟨477, [⟨55, 1, 4, 5⟩, ⟨154, 7, 4, 5⟩, ⟨154, 3, 4, 0⟩, ⟨471, 2, 5, 4⟩]⟩ + +def entry_478 : Entry := ⟨478, [⟨25, 3, 4, 5⟩, ⟨165, 2, 4, 5⟩, ⟨190, 0, 7, 4⟩]⟩ + +def entry_479 : Entry := ⟨479, [⟨55, 0, 5, 4⟩, ⟨443, 0, 4, 5⟩, ⟨443, 4, 1, 5⟩]⟩ + +def entry_480 : Entry := ⟨480, [⟨108, 1, 4, 5⟩, ⟨4, 1, 5, 4⟩]⟩ + +def entry_481 : Entry := ⟨481, [⟨303, 1, 5, 4⟩, ⟨429, 2, 1, 4⟩, ⟨309, 1, 1, 4⟩, ⟨206, 2, 1, 4⟩, ⟨169, 2, 1, 4⟩, ⟨207, 2, 1, 4⟩]⟩ + +def entry_482 : Entry := ⟨482, [⟨6, 1, 4, 5⟩, ⟨218, 2, 4, 3⟩]⟩ + +def entry_483 : Entry := ⟨483, [⟨173, 1, 4, 5⟩, ⟨292, 7, 3, 1⟩, ⟨319, 1, 3, 5⟩, ⟨192, 6, 4, 1⟩, ⟨475, 1, 4, 5⟩]⟩ + +def entry_484 : Entry := ⟨484, [⟨25, 4, 1, 5⟩, ⟨107, 2, 5, 4⟩, ⟨349, 3, 1, 5⟩, ⟨163, 2, 5, 4⟩]⟩ + +def entry_485 : Entry := ⟨485, [⟨484, 0, 5, 4⟩, ⟨2, 3, 4, 3⟩]⟩ + +def entry_486 : Entry := ⟨486, [⟨2, 5, 4, 2⟩, ⟨485, 0, 5, 3⟩]⟩ + +def entry_487 : Entry := ⟨487, [⟨2, 3, 4, 3⟩, ⟨481, 0, 5, 4⟩]⟩ + +def entry_488 : Entry := ⟨488, [⟨0, 6, 6, 4⟩, ⟨247, 0, 2, 5⟩]⟩ + +def entry_489 : Entry := ⟨489, [⟨356, 1, 3, 3⟩, ⟨197, 4, 1, 4⟩, ⟨172, 6, 1, 4⟩]⟩ + +def entry_490 : Entry := ⟨490, [⟨64, 1, 3, 1⟩, ⟨471, 0, 5, 1⟩, ⟨470, 1, 5, 1⟩, ⟨111, 0, 3, 1⟩]⟩ + +def entry_491 : Entry := ⟨491, [⟨6, 3, 3, 5⟩, ⟨273, 0, 5, 4⟩]⟩ + +def entry_492 : Entry := ⟨492, [⟨62, 4, 3, 4⟩, ⟨107, 4, 3, 4⟩, ⟨487, 0, 6, 6⟩]⟩ + +def entry_493 : Entry := ⟨493, [⟨225, 0, 1, 4⟩, ⟨455, 0, 5, 3⟩, ⟨236, 1, 5, 5⟩, ⟨221, 0, 5, 4⟩]⟩ + +def entry_494 : Entry := ⟨494, [⟨297, 4, 4, 5⟩, ⟨268, 4, 1, 5⟩, ⟨162, 5, 5, 4⟩]⟩ + +def entry_495 : Entry := ⟨495, [⟨25, 6, 1, 3⟩, ⟨167, 4, 1, 4⟩, ⟨456, 4, 1, 4⟩]⟩ + +def entry_496 : Entry := ⟨496, [⟨25, 0, 7, 5⟩, ⟨107, 6, 3, 4⟩, ⟨163, 6, 3, 4⟩, ⟨494, 0, 7, 4⟩]⟩ + +def entry_497 : Entry := ⟨497, [⟨36, 2, 3, 4⟩, ⟨167, 0, 7, 4⟩, ⟨410, 0, 7, 3⟩]⟩ + +def entry_498 : Entry := ⟨498, [⟨14, 1, 4, 6⟩, ⟨298, 2, 2, 4⟩]⟩ + +def entry_499 : Entry := ⟨499, [⟨493, 0, 5, 4⟩, ⟨25, 1, 4, 5⟩, ⟨478, 0, 2, 4⟩]⟩ + +def entry_500 : Entry := ⟨500, [⟨1, 5, 3, 6⟩, ⟨351, 0, 5, 4⟩]⟩ + +def entry_501 : Entry := ⟨501, [⟨6, 4, 0, 5⟩, ⟨316, 0, 1, 3⟩]⟩ + +def entry_502 : Entry := ⟨502, [⟨215, 6, 2, 3⟩, ⟨232, 0, 4, 3⟩, ⟨192, 7, 1, 4⟩, ⟨173, 0, 5, 4⟩, ⟨271, 2, 2, 3⟩]⟩ + +def entry_503 : Entry := ⟨503, [⟨63, 0, 3, 5⟩, ⟨55, 7, 4, 0⟩, ⟨420, 1, 7, 2⟩, ⟨419, 1, 7, 4⟩]⟩ + +def entry_504 : Entry := ⟨504, [⟨381, 0, 3, 4⟩, ⟨310, 4, 4, 5⟩, ⟨159, 0, 5, 6⟩, ⟨351, 4, 3, 4⟩, ⟨496, 0, 3, 4⟩]⟩ + +def entry_505 : Entry := ⟨505, [⟨173, 1, 4, 5⟩, ⟨499, 0, 5, 4⟩, ⟨183, 1, 4, 5⟩, ⟨282, 1, 4, 5⟩]⟩ + +end SnakyCertificate + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Entries05.lean b/lean/OAI/Combinatorics/SnakyCertificate/Entries05.lean new file mode 100644 index 0000000000000000000000000000000000000000..fdcbe52efef4dd305383ce83da229d2ace876ad3 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Entries05.lean @@ -0,0 +1,209 @@ +import OAI.Combinatorics.SnakyCertificate.Basic + +namespace OAI + +namespace SnakyCertificate + +def entry_506 : Entry := ⟨506, [⟨99, 0, 4, 5⟩, ⟨200, 7, 1, 4⟩, ⟨318, 5, 5, 4⟩, ⟨173, 0, 5, 4⟩]⟩ + +def entry_507 : Entry := ⟨507, [⟨151, 0, 2, 4⟩, ⟨33, 3, 4, 3⟩, ⟨481, 0, 5, 4⟩]⟩ + +def entry_508 : Entry := ⟨508, [⟨6, 0, 5, 4⟩, ⟨393, 0, 1, 5⟩]⟩ + +def entry_509 : Entry := ⟨509, [⟨252, 0, 6, 4⟩, ⟨241, 4, 2, 4⟩, ⟨455, 0, 6, 3⟩, ⟨68, 2, 6, 4⟩]⟩ + +def entry_510 : Entry := ⟨510, [⟨6, 4, 3, 4⟩, ⟨508, 0, 7, 4⟩]⟩ + +def entry_511 : Entry := ⟨511, [⟨15, 1, 4, 5⟩, ⟨331, 0, 5, 3⟩, ⟨380, 4, 2, 4⟩]⟩ + +def entry_512 : Entry := ⟨512, [⟨62, 0, 5, 4⟩, ⟨107, 0, 5, 4⟩, ⟨507, 0, 4, 6⟩]⟩ + +def entry_513 : Entry := ⟨513, [⟨6, 4, 3, 4⟩, ⟨396, 0, 4, 5⟩]⟩ + +def entry_514 : Entry := ⟨514, [⟨57, 0, 5, 4⟩, ⟨443, 4, 1, 5⟩, ⟨510, 0, 1, 5⟩]⟩ + +def entry_515 : Entry := ⟨515, [⟨2, 6, 2, 4⟩, ⟨512, 1, 1, 5⟩]⟩ + +def entry_516 : Entry := ⟨516, [⟨329, 0, 4, 3⟩, ⟨244, 4, 2, 4⟩, ⟨10, 1, 4, 5⟩, ⟨506, 4, 2, 4⟩]⟩ + +def entry_517 : Entry := ⟨517, [⟨496, 0, 2, 3⟩, ⟨140, 0, 4, 2⟩, ⟨193, 1, 4, 2⟩]⟩ + +def entry_518 : Entry := ⟨518, [⟨9, 6, 3, 4⟩, ⟨514, 0, 7, 4⟩]⟩ + +def entry_519 : Entry := ⟨519, [⟨498, 0, 4, 3⟩, ⟨311, 4, 3, 4⟩, ⟨38, 1, 4, 5⟩, ⟨408, 0, 3, 4⟩]⟩ + +def entry_520 : Entry := ⟨520, [⟨254, 0, 2, 3⟩, ⟨200, 5, 6, 4⟩, ⟨271, 6, 5, 3⟩, ⟨215, 2, 5, 3⟩, ⟨252, 4, 2, 4⟩]⟩ + +def entry_521 : Entry := ⟨521, [⟨492, 4, 5, 1⟩, ⟨2, 7, 4, 2⟩]⟩ + +def entry_522 : Entry := ⟨522, [⟨176, 3, 4, 6⟩, ⟨338, 2, 3, 3⟩, ⟨252, 1, 4, 6⟩]⟩ + +def entry_523 : Entry := ⟨523, [⟨303, 1, 5, 4⟩, ⟨25, 4, 1, 5⟩, ⟨107, 2, 5, 4⟩, ⟨511, 4, 1, 6⟩]⟩ + +def entry_524 : Entry := ⟨524, [⟨504, 4, 5, 3⟩, ⟨504, 0, 3, 3⟩, ⟨180, 0, 4, 5⟩, ⟨180, 4, 4, 5⟩, ⟨261, 0, 3, 4⟩]⟩ + +def entry_525 : Entry := ⟨525, [⟨303, 1, 5, 4⟩, ⟨25, 4, 1, 5⟩, ⟨430, 0, 4, 6⟩, ⟨107, 2, 5, 4⟩]⟩ + +def entry_526 : Entry := ⟨526, [⟨359, 0, 4, 3⟩, ⟨416, 4, 2, 4⟩, ⟨327, 5, 4, 3⟩, ⟨489, 0, 5, 4⟩, ⟨399, 3, 2, 4⟩]⟩ + +def entry_527 : Entry := ⟨527, [⟨387, 4, 4, 3⟩, ⟨38, 3, 4, 5⟩, ⟨491, 0, 5, 4⟩, ⟨519, 0, 6, 4⟩]⟩ + +def entry_528 : Entry := ⟨528, [⟨414, 1, 3, 5⟩, ⟨386, 1, 4, 6⟩, ⟨502, 5, 4, 3⟩, ⟨226, 4, 1, 5⟩, ⟨359, 5, 3, 4⟩]⟩ + +def entry_529 : Entry := ⟨529, [⟨55, 4, 3, 4⟩, ⟨441, 0, 4, 3⟩, ⟨63, 3, 3, 3⟩, ⟨64, 6, 7, 5⟩]⟩ + +def entry_530 : Entry := ⟨530, [⟨456, 7, 4, 2⟩, ⟨336, 0, 5, 5⟩, ⟨283, 7, 4, 2⟩, ⟨271, 5, 5, 5⟩]⟩ + +def entry_531 : Entry := ⟨531, [⟨425, 0, 5, 4⟩, ⟨336, 3, 4, 3⟩, ⟨340, 6, 4, 3⟩, ⟨394, 1, 5, 4⟩, ⟨423, 0, 5, 4⟩, ⟨526, 0, 5, 4⟩, ⟨401, 4, 4, 3⟩, ⟨453, 0, 5, 4⟩]⟩ + +def entry_532 : Entry := ⟨532, [⟨504, 4, 5, 3⟩, ⟨6, 7, 3, 0⟩]⟩ + +def entry_533 : Entry := ⟨533, [⟨318, 4, 4, 5⟩, ⟨319, 7, 5, 1⟩, ⟨407, 4, 4, 1⟩, ⟨173, 3, 4, 5⟩, ⟨217, 1, 4, 5⟩]⟩ + +def entry_534 : Entry := ⟨534, [⟨434, 0, 4, 6⟩, ⟨12, 6, 1, 3⟩]⟩ + +def entry_535 : Entry := ⟨535, [⟨444, 0, 4, 5⟩, ⟨426, 0, 4, 5⟩, ⟨25, 0, 5, 4⟩, ⟨321, 4, 4, 2⟩]⟩ + +def entry_536 : Entry := ⟨536, [⟨307, 0, 4, 3⟩, ⟨244, 0, 5, 4⟩, ⟨26, 3, 4, 3⟩, ⟨534, 0, 5, 2⟩]⟩ + +def entry_537 : Entry := ⟨537, [⟨373, 2, 2, 4⟩, ⟨271, 3, 3, 3⟩, ⟨176, 1, 4, 6⟩, ⟨330, 1, 4, 6⟩]⟩ + +def entry_538 : Entry := ⟨538, [⟨63, 3, 3, 3⟩, ⟨470, 0, 4, 5⟩, ⟨64, 6, 7, 5⟩, ⟨55, 4, 3, 4⟩]⟩ + +def entry_539 : Entry := ⟨539, [⟨51, 1, 5, 4⟩, ⟨488, 3, 4, 3⟩, ⟨428, 0, 5, 4⟩, ⟨516, 0, 5, 4⟩]⟩ + +def entry_540 : Entry := ⟨540, [⟨334, 0, 4, 3⟩, ⟨51, 1, 5, 4⟩, ⟨88, 3, 4, 3⟩, ⟨536, 0, 5, 4⟩]⟩ + +def entry_541 : Entry := ⟨541, [⟨236, 0, 5, 5⟩, ⟨142, 7, 4, 1⟩, ⟨160, 3, 4, 1⟩, ⟨194, 0, 5, 3⟩, ⟨501, 4, 1, 2⟩, ⟨412, 0, 5, 3⟩]⟩ + +def entry_542 : Entry := ⟨542, [⟨6, 5, 5, 0⟩, ⟨442, 0, 4, 5⟩]⟩ + +def entry_543 : Entry := ⟨543, [⟨493, 3, 2, 6⟩, ⟨107, 2, 5, 4⟩, ⟨318, 5, 5, 4⟩]⟩ + +def entry_544 : Entry := ⟨544, [⟨263, 2, 7, 4⟩, ⟨9, 6, 3, 4⟩, ⟨451, 1, 8, 3⟩]⟩ + +def entry_545 : Entry := ⟨545, [⟨256, 0, 4, 5⟩, ⟨448, 0, 5, 4⟩, ⟨153, 0, 6, 3⟩, ⟨343, 0, 4, 5⟩]⟩ + +def entry_546 : Entry := ⟨546, [⟨64, 0, 4, 3⟩, ⟨482, 7, 4, 3⟩, ⟨443, 0, 7, 5⟩, ⟨64, 6, 7, 5⟩]⟩ + +def entry_547 : Entry := ⟨547, [⟨443, 0, 7, 5⟩, ⟨510, 4, 7, 5⟩, ⟨131, 3, 3, 4⟩]⟩ + +def entry_548 : Entry := ⟨548, [⟨426, 0, 4, 5⟩, ⟨541, 0, 4, 5⟩, ⟨25, 0, 5, 4⟩, ⟨321, 4, 4, 2⟩]⟩ + +def entry_549 : Entry := ⟨549, [⟨385, 0, 6, 4⟩, ⟨385, 4, 2, 4⟩, ⟨330, 0, 6, 4⟩, ⟨252, 6, 2, 4⟩, ⟨326, 0, 6, 4⟩, ⟨529, 0, 2, 4⟩]⟩ + +def entry_550 : Entry := ⟨550, [⟨424, 0, 4, 6⟩, ⟨172, 7, 4, 2⟩, ⟨215, 1, 5, 5⟩, ⟨456, 7, 4, 2⟩]⟩ + +def entry_551 : Entry := ⟨551, [⟨300, 6, 4, 3⟩, ⟨172, 7, 4, 3⟩, ⟨319, 3, 5, 7⟩, ⟨527, 4, 5, 7⟩, ⟨176, 5, 4, 3⟩]⟩ + +def entry_552 : Entry := ⟨552, [⟨443, 4, 1, 5⟩, ⟨64, 2, 1, 5⟩, ⟨504, 1, 3, 3⟩, ⟨404, 5, 2, 3⟩]⟩ + +def entry_553 : Entry := ⟨553, [⟨63, 0, 3, 5⟩, ⟨261, 4, 5, 4⟩, ⟨471, 0, 5, 1⟩, ⟨442, 0, 4, 5⟩, ⟨504, 0, 3, 3⟩, ⟨180, 0, 4, 5⟩]⟩ + +def entry_554 : Entry := ⟨554, [⟨30, 6, 5, 4⟩, ⟨96, 7, 4, 5⟩, ⟨474, 0, 4, 5⟩]⟩ + +def entry_555 : Entry := ⟨555, [⟨504, 5, 3, 5⟩, ⟨513, 0, 1, 5⟩, ⟨55, 0, 5, 4⟩, ⟨443, 4, 1, 5⟩, ⟨471, 1, 1, 5⟩]⟩ + +def entry_556 : Entry := ⟨556, [⟨34, 1, 4, 2⟩, ⟨549, 0, 3, 4⟩]⟩ + +def entry_557 : Entry := ⟨557, [⟨460, 0, 5, 4⟩, ⟨460, 4, 2, 4⟩, ⟨460, 2, 5, 4⟩, ⟨411, 4, 5, 4⟩, ⟨531, 0, 3, 6⟩, ⟨531, 4, 4, 6⟩, ⟨406, 5, 5, 4⟩]⟩ + +def entry_558 : Entry := ⟨558, [⟨180, 5, 5, 4⟩, ⟨443, 4, 1, 5⟩, ⟨513, 0, 1, 5⟩, ⟨442, 1, 5, 4⟩]⟩ + +def entry_559 : Entry := ⟨559, [⟨228, 4, 5, 2⟩, ⟨7, 3, 3, 4⟩, ⟨155, 4, 4, 5⟩, ⟨538, 5, 4, 5⟩]⟩ + +def entry_560 : Entry := ⟨560, [⟨517, 5, 5, 4⟩, ⟨416, 5, 4, 3⟩, ⟨359, 5, 3, 4⟩, ⟨356, 6, 3, 4⟩, ⟨483, 0, 4, 6⟩]⟩ + +def entry_561 : Entry := ⟨561, [⟨295, 0, 5, 4⟩, ⟨173, 2, 5, 4⟩, ⟨263, 6, 1, 4⟩, ⟨236, 1, 5, 5⟩, ⟨546, 4, 5, 4⟩, ⟨176, 2, 5, 4⟩, ⟨535, 0, 4, 5⟩]⟩ + +def entry_562 : Entry := ⟨562, [⟨6, 7, 3, 0⟩, ⟨559, 0, 4, 5⟩]⟩ + +def entry_563 : Entry := ⟨563, [⟨167, 0, 7, 4⟩, ⟨538, 0, 3, 4⟩, ⟨514, 0, 7, 4⟩, ⟨330, 4, 3, 4⟩, ⟨545, 0, 5, 5⟩]⟩ + +def entry_564 : Entry := ⟨564, [⟨560, 0, 4, 3⟩, ⟨421, 0, 3, 4⟩, ⟨401, 1, 3, 4⟩, ⟨340, 3, 3, 4⟩, ⟨509, 0, 3, 4⟩, ⟨528, 0, 4, 3⟩, ⟨423, 5, 4, 3⟩, ⟨425, 5, 4, 3⟩, ⟨336, 0, 3, 4⟩]⟩ + +def entry_565 : Entry := ⟨565, [⟨443, 4, 4, 5⟩, ⟨131, 3, 3, 4⟩, ⟨538, 0, 3, 4⟩, ⟨459, 0, 5, 5⟩, ⟨144, 4, 3, 4⟩]⟩ + +def entry_566 : Entry := ⟨566, [⟨314, 0, 3, 4⟩, ⟨180, 0, 4, 5⟩, ⟨442, 0, 4, 5⟩, ⟨466, 0, 6, 3⟩, ⟨504, 0, 3, 3⟩]⟩ + +def entry_567 : Entry := ⟨567, [⟨21, 1, 4, 3⟩, ⟨561, 0, 6, 4⟩, ⟨500, 4, 3, 1⟩]⟩ + +def entry_568 : Entry := ⟨568, [⟨538, 4, 6, 4⟩, ⟨547, 0, 2, 4⟩, ⟨275, 0, 6, 4⟩, ⟨565, 0, 2, 4⟩, ⟨330, 0, 6, 4⟩]⟩ + +def entry_569 : Entry := ⟨569, [⟨34, 3, 4, 2⟩, ⟨568, 4, 5, 4⟩]⟩ + +def entry_570 : Entry := ⟨570, [⟨569, 0, 2, 5⟩, ⟨2, 7, 4, 3⟩]⟩ + +def entry_571 : Entry := ⟨571, [⟨293, 0, 4, 3⟩, ⟨570, 0, 4, 3⟩, ⟨382, 0, 4, 3⟩, ⟨556, 4, 2, 4⟩]⟩ + +def entry_572 : Entry := ⟨572, [⟨564, 1, 6, 6⟩, ⟨465, 3, 3, 4⟩, ⟨385, 4, 3, 4⟩, ⟨364, 7, 3, 4⟩, ⟨499, 1, 6, 5⟩]⟩ + +def entry_573 : Entry := ⟨573, [⟨527, 2, 3, 1⟩, ⟨499, 4, 3, 4⟩, ⟨527, 6, 5, 1⟩, ⟨499, 0, 5, 4⟩, ⟨407, 4, 4, 1⟩, ⟨531, 7, 2, 4⟩, ⟨407, 0, 4, 1⟩]⟩ + +def entry_574 : Entry := ⟨574, [⟨497, 0, 2, 4⟩, ⟨539, 4, 4, 6⟩, ⟨355, 0, 2, 4⟩, ⟨390, 3, 2, 4⟩, ⟨544, 0, 2, 4⟩, ⟨462, 1, 4, 5⟩, ⟨563, 4, 5, 4⟩, ⟨540, 4, 4, 6⟩, ⟨518, 0, 2, 4⟩, ⟨495, 4, 2, 4⟩]⟩ + +def entry_575 : Entry := ⟨575, [⟨314, 4, 5, 4⟩, ⟨504, 4, 5, 3⟩, ⟨180, 4, 4, 5⟩, ⟨442, 4, 4, 5⟩, ⟨559, 0, 4, 5⟩]⟩ + +def entry_576 : Entry := ⟨576, [⟨495, 0, 5, 4⟩, ⟨544, 4, 5, 4⟩, ⟨462, 3, 3, 5⟩, ⟨540, 0, 3, 6⟩, ⟨355, 4, 5, 4⟩, ⟨539, 0, 3, 6⟩, ⟨497, 4, 5, 4⟩, ⟨390, 1, 5, 4⟩, ⟨563, 0, 2, 4⟩, ⟨518, 4, 5, 4⟩]⟩ + +def entry_577 : Entry := ⟨577, [⟨64, 7, 5, 4⟩, ⟨64, 1, 3, 1⟩, ⟨443, 1, 5, 4⟩, ⟨443, 7, 3, 1⟩]⟩ + +def entry_578 : Entry := ⟨578, [⟨574, 4, 4, 5⟩, ⟨2, 1, 4, 3⟩]⟩ + +def entry_579 : Entry := ⟨579, [⟨2, 1, 4, 3⟩, ⟨576, 4, 4, 5⟩]⟩ + +def entry_580 : Entry := ⟨580, [⟨2, 7, 4, 2⟩, ⟨579, 0, 3, 3⟩]⟩ + +def entry_581 : Entry := ⟨581, [⟨578, 4, 5, 3⟩, ⟨2, 5, 4, 2⟩]⟩ + +def entry_582 : Entry := ⟨582, [⟨40, 3, 4, 3⟩, ⟨446, 5, 5, 3⟩, ⟨523, 0, 7, 0⟩, ⟨480, 4, 5, 3⟩, ⟨567, 4, 5, 4⟩]⟩ + +def entry_583 : Entry := ⟨583, [⟨25, 5, 4, 3⟩, ⟨525, 0, 5, 4⟩, ⟨582, 0, 2, 8⟩, ⟨221, 3, 3, 7⟩]⟩ + +def entry_584 : Entry := ⟨584, [⟨263, 1, 4, 5⟩, ⟨236, 4, 3, 5⟩, ⟨548, 3, 3, 4⟩, ⟨295, 3, 4, 5⟩, ⟨577, 0, 4, 5⟩, ⟨173, 1, 4, 5⟩]⟩ + +def entry_585 : Entry := ⟨585, [⟨236, 2, 5, 1⟩, ⟨300, 4, 4, 5⟩, ⟨479, 1, 4, 5⟩, ⟨577, 0, 4, 5⟩, ⟨183, 3, 4, 5⟩, ⟨527, 6, 5, 1⟩]⟩ + +def entry_586 : Entry := ⟨586, [⟨465, 4, 4, 5⟩, ⟨558, 1, 4, 5⟩, ⟨385, 1, 4, 5⟩, ⟨379, 4, 4, 5⟩, ⟨524, 0, 4, 5⟩, ⟨469, 2, 4, 5⟩, ⟨467, 2, 4, 5⟩, ⟨527, 4, 5, 5⟩, ⟨553, 0, 4, 5⟩, ⟨552, 1, 4, 5⟩, ⟨555, 1, 4, 5⟩, ⟨564, 0, 6, 4⟩, ⟨583, 0, 5, 2⟩]⟩ + +def entry_587 : Entry := ⟨587, [⟨300, 2, 4, 1⟩, ⟨479, 1, 4, 5⟩, ⟨319, 3, 5, 5⟩, ⟨477, 6, 4, 1⟩, ⟨252, 3, 4, 5⟩, ⟨467, 2, 4, 5⟩]⟩ + +def entry_588 : Entry := ⟨588, [⟨3, 1, 3, 3⟩, ⟨586, 0, 4, 5⟩]⟩ + +def entry_589 : Entry := ⟨589, [⟨4, 1, 4, 3⟩, ⟨588, 0, 4, 5⟩]⟩ + +def entry_590 : Entry := ⟨590, [⟨295, 7, 4, 3⟩, ⟨173, 7, 4, 3⟩, ⟨577, 0, 4, 7⟩, ⟨490, 0, 4, 7⟩, ⟨217, 5, 4, 3⟩]⟩ + +def entry_591 : Entry := ⟨591, [⟨524, 0, 4, 5⟩, ⟨529, 1, 4, 1⟩, ⟨529, 3, 4, 1⟩, ⟨538, 1, 4, 1⟩, ⟨538, 3, 4, 1⟩, ⟨197, 5, 4, 1⟩]⟩ + +def entry_592 : Entry := ⟨592, [⟨588, 0, 4, 5⟩, ⟨108, 7, 3, 0⟩]⟩ + +def entry_593 : Entry := ⟨593, [⟨2, 7, 4, 2⟩, ⟨586, 0, 4, 5⟩]⟩ + +def entry_594 : Entry := ⟨594, [⟨30, 1, 4, 3⟩, ⟨476, 1, 4, 3⟩, ⟨588, 0, 4, 5⟩]⟩ + +def entry_595 : Entry := ⟨595, [⟨460, 4, 2, 4⟩, ⟨460, 2, 5, 4⟩, ⟨586, 1, 5, 4⟩, ⟨411, 4, 5, 4⟩, ⟨551, 1, 2, 4⟩, ⟨406, 5, 5, 4⟩, ⟨572, 0, 2, 4⟩]⟩ + +def entry_596 : Entry := ⟨596, [⟨385, 5, 4, 2⟩, ⟨592, 0, 5, 6⟩, ⟨330, 1, 4, 6⟩, ⟨529, 5, 4, 6⟩, ⟨385, 1, 4, 6⟩, ⟨330, 5, 4, 2⟩]⟩ + +def entry_597 : Entry := ⟨597, [⟨24, 6, 2, 3⟩, ⟨221, 0, 6, 4⟩, ⟨199, 3, 2, 4⟩, ⟨594, 1, 6, 5⟩]⟩ + +def entry_598 : Entry := ⟨598, [⟨594, 0, 5, 6⟩, ⟨456, 5, 4, 2⟩, ⟨254, 1, 3, 2⟩, ⟨554, 1, 3, 2⟩, ⟨465, 0, 4, 6⟩]⟩ + +def entry_599 : Entry := ⟨599, [⟨578, 4, 5, 3⟩, ⟨492, 0, 3, 1⟩, ⟨512, 4, 3, 1⟩, ⟨586, 4, 4, 5⟩, ⟨485, 0, 5, 3⟩, ⟨579, 4, 5, 3⟩]⟩ + +def entry_600 : Entry := ⟨600, [⟨448, 0, 4, 5⟩, ⟨278, 2, 1, 4⟩, ⟨592, 5, 5, 3⟩, ⟨403, 5, 5, 4⟩, ⟨146, 5, 4, 3⟩]⟩ + +def entry_601 : Entry := ⟨601, [⟨437, 6, 4, 1⟩, ⟨553, 0, 4, 5⟩, ⟨592, 0, 5, 5⟩, ⟨236, 4, 3, 5⟩, ⟨469, 4, 4, 1⟩]⟩ + +def entry_602 : Entry := ⟨602, [⟨553, 0, 4, 7⟩, ⟨467, 4, 4, 3⟩, ⟨592, 0, 5, 7⟩, ⟨437, 6, 4, 3⟩, ⟨236, 4, 3, 7⟩]⟩ + +def entry_603 : Entry := ⟨603, [⟨505, 1, 5, 4⟩, ⟨505, 5, 5, 4⟩, ⟨586, 5, 5, 4⟩, ⟨551, 7, 5, 4⟩, ⟨531, 6, 4, 2⟩, ⟨586, 1, 5, 4⟩, ⟨585, 1, 5, 4⟩, ⟨585, 5, 5, 4⟩, ⟨551, 3, 5, 4⟩, ⟨573, 1, 5, 4⟩, ⟨533, 5, 5, 4⟩, ⟨533, 1, 5, 4⟩]⟩ + +def entry_604 : Entry := ⟨604, [⟨597, 0, 3, 4⟩, ⟨375, 2, 4, 3⟩, ⟨597, 1, 4, 3⟩, ⟨375, 3, 3, 4⟩, ⟨350, 3, 4, 3⟩, ⟨350, 2, 3, 4⟩]⟩ + +def entry_605 : Entry := ⟨605, [⟨400, 5, 4, 3⟩, ⟨383, 6, 3, 4⟩, ⟨530, 4, 4, 3⟩, ⟨596, 1, 3, 4⟩, ⟨522, 2, 4, 3⟩, ⟨598, 0, 4, 3⟩, ⟨537, 3, 3, 4⟩, ⟨520, 1, 4, 3⟩, ⟨550, 4, 4, 3⟩]⟩ + +end SnakyCertificate + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Entries06.lean b/lean/OAI/Combinatorics/SnakyCertificate/Entries06.lean new file mode 100644 index 0000000000000000000000000000000000000000..65ed60b5030079fcc85cb53a20d232b78e10d5ea --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Entries06.lean @@ -0,0 +1,29 @@ +import OAI.Combinatorics.SnakyCertificate.Basic + +namespace OAI + +namespace SnakyCertificate + +def entry_606 : Entry := ⟨606, [⟨123, 1, 4, 3⟩, ⟨274, 0, 4, 3⟩, ⟨605, 0, 6, 4⟩, ⟨119, 1, 4, 3⟩]⟩ + +def entry_607 : Entry := ⟨607, [⟨420, 3, 1, 2⟩, ⟨419, 3, 1, 4⟩, ⟨589, 0, 5, 5⟩, ⟨314, 0, 3, 4⟩, ⟨571, 1, 7, 3⟩]⟩ + +def entry_608 : Entry := ⟨608, [⟨486, 4, 4, 5⟩, ⟨515, 1, 4, 5⟩, ⟨580, 0, 4, 5⟩, ⟨521, 0, 4, 5⟩, ⟨581, 4, 4, 5⟩, ⟨593, 0, 4, 5⟩, ⟨599, 4, 4, 5⟩, ⟨606, 1, 6, 2⟩]⟩ + +def entry_609 : Entry := ⟨609, [⟨286, 4, 4, 5⟩, ⟨107, 3, 4, 5⟩, ⟨532, 4, 4, 5⟩, ⟨542, 0, 4, 5⟩, ⟨221, 3, 4, 5⟩, ⟨562, 4, 4, 5⟩, ⟨575, 4, 4, 5⟩, ⟨604, 1, 6, 4⟩]⟩ + +def entry_610 : Entry := ⟨610, [⟨221, 2, 5, 4⟩, ⟨286, 5, 5, 4⟩, ⟨107, 2, 5, 4⟩, ⟨472, 1, 5, 4⟩, ⟨566, 1, 5, 4⟩, ⟨532, 5, 5, 4⟩, ⟨542, 1, 5, 4⟩, ⟨609, 0, 2, 6⟩]⟩ + +def entry_611 : Entry := ⟨611, [⟨456, 2, 5, 4⟩, ⟨456, 4, 1, 4⟩, ⟨594, 7, 1, 3⟩, ⟨594, 1, 5, 5⟩]⟩ + +def entry_612 : Entry := ⟨612, [⟨589, 1, 5, 5⟩, ⟨589, 7, 0, 3⟩]⟩ + +def entry_613 : Entry := ⟨613, [⟨607, 5, 5, 4⟩, ⟨503, 3, 1, 4⟩, ⟨592, 7, 1, 3⟩, ⟨592, 5, 5, 3⟩, ⟨607, 7, 1, 4⟩, ⟨612, 4, 1, 4⟩, ⟨612, 0, 5, 4⟩]⟩ + +def entry_614 : Entry := ⟨614, [⟨608, 1, 7, 5⟩, ⟨543, 3, 5, 6⟩, ⟨370, 6, 3, 4⟩, ⟨392, 7, 3, 4⟩, ⟨610, 3, 5, 6⟩, ⟨600, 0, 6, 4⟩, ⟨613, 0, 6, 4⟩]⟩ + +def entry_615 : Entry := ⟨615, [⟨602, 7, 6, 4⟩, ⟨614, 1, 4, 3⟩, ⟨533, 5, 6, 4⟩, ⟨590, 7, 6, 4⟩, ⟨611, 6, 3, 4⟩, ⟨587, 3, 3, 4⟩, ⟨601, 5, 6, 4⟩, ⟨406, 1, 6, 4⟩, ⟨591, 3, 3, 4⟩, ⟨586, 3, 3, 4⟩, ⟨584, 5, 6, 4⟩, ⟨406, 3, 3, 4⟩]⟩ + +end SnakyCertificate + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Equations00.lean b/lean/OAI/Combinatorics/SnakyCertificate/Equations00.lean new file mode 100644 index 0000000000000000000000000000000000000000..20016ff1b0456917c368c3a59367f196b0caccb4 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Equations00.lean @@ -0,0 +1,476 @@ +import OAI.Combinatorics.SnakyCertificate.Cache +import OAI.Combinatorics.SnakyCertificate.TableList + +namespace OAI + +namespace SnakyCertificate.Check + +theorem cache_equation_0 : CacheEquation 0 := by + unfold CacheEquation + decide +kernel + +theorem cache_equation_1 : CacheEquation 1 := by + unfold CacheEquation + decide +kernel + +theorem cache_equation_2 : CacheEquation 2 := by + unfold CacheEquation + decide +kernel + +theorem cache_equation_3 : CacheEquation 3 := by + unfold CacheEquation + decide +kernel + +theorem cache_equation_4 : CacheEquation 4 := by + unfold CacheEquation + decide +kernel + +theorem cache_equation_5 : CacheEquation 5 := by + unfold CacheEquation + decide +kernel + +theorem verified_row_6 : fork [place ⟨0, 0, 0, 3⟩ cache_0] = cache_6 := by + decide +kernel + +theorem load_entry_6 : entryAt 6 = entry_6 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_6 : CacheEquation 6 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(6 < 6)), load_entry_6] + change forkRow [placeRow ⟨0, 0, 0, 3⟩ (denote cache_0)] = denote cache_6 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_6 + +theorem verified_row_7 : fork [place ⟨4, 0, 3, 4⟩ cache_4, place ⟨6, 0, 5, 4⟩ cache_6] = cache_7 := by + decide +kernel + +theorem load_entry_7 : entryAt 7 = entry_7 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_7 : CacheEquation 7 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(7 < 6)), load_entry_7] + change forkRow [placeRow ⟨4, 0, 3, 4⟩ (denote cache_4), placeRow ⟨6, 0, 5, 4⟩ (denote cache_6)] = denote cache_7 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_7 + +theorem verified_row_8 : fork [place ⟨0, 4, 8, 3⟩ cache_0, place ⟨6, 4, 3, 4⟩ cache_6] = cache_8 := by + decide +kernel + +theorem load_entry_8 : entryAt 8 = entry_8 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_8 : CacheEquation 8 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(8 < 6)), load_entry_8] + change forkRow [placeRow ⟨0, 4, 8, 3⟩ (denote cache_0), placeRow ⟨6, 4, 3, 4⟩ (denote cache_6)] = denote cache_8 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_8 + +theorem verified_row_9 : fork [place ⟨0, 4, 5, 4⟩ cache_0, place ⟨6, 4, 0, 5⟩ cache_6] = cache_9 := by + decide +kernel + +theorem load_entry_9 : entryAt 9 = entry_9 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_9 : CacheEquation 9 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(9 < 6)), load_entry_9] + change forkRow [placeRow ⟨0, 4, 5, 4⟩ (denote cache_0), placeRow ⟨6, 4, 0, 5⟩ (denote cache_6)] = denote cache_9 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_9 + +theorem verified_row_10 : fork [place ⟨2, 0, 2, 3⟩ cache_2, place ⟨2, 6, 2, 4⟩ cache_2] = cache_10 := by + decide +kernel + +theorem load_entry_10 : entryAt 10 = entry_10 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_10 : CacheEquation 10 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(10 < 6)), load_entry_10] + change forkRow [placeRow ⟨2, 0, 2, 3⟩ (denote cache_2), placeRow ⟨2, 6, 2, 4⟩ (denote cache_2)] = denote cache_10 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_10 + +theorem verified_row_11 : fork [place ⟨6, 4, 2, 5⟩ cache_6, place ⟨6, 6, 2, 3⟩ cache_6] = cache_11 := by + decide +kernel + +theorem load_entry_11 : entryAt 11 = entry_11 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_11 : CacheEquation 11 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(11 < 6)), load_entry_11] + change forkRow [placeRow ⟨6, 4, 2, 5⟩ (denote cache_6), placeRow ⟨6, 6, 2, 3⟩ (denote cache_6)] = denote cache_11 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_11 + +theorem verified_row_12 : fork [place ⟨0, 6, 5, 4⟩ cache_0, place ⟨0, 0, 0, 3⟩ cache_0] = cache_12 := by + decide +kernel + +theorem load_entry_12 : entryAt 12 = entry_12 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_12 : CacheEquation 12 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(12 < 6)), load_entry_12] + change forkRow [placeRow ⟨0, 6, 5, 4⟩ (denote cache_0), placeRow ⟨0, 0, 0, 3⟩ (denote cache_0)] = denote cache_12 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_12 + +theorem verified_row_13 : fork [place ⟨6, 6, 0, 3⟩ cache_6, place ⟨6, 4, 0, 5⟩ cache_6] = cache_13 := by + decide +kernel + +theorem load_entry_13 : entryAt 13 = entry_13 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_13 : CacheEquation 13 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(13 < 6)), load_entry_13] + change forkRow [placeRow ⟨6, 6, 0, 3⟩ (denote cache_6), placeRow ⟨6, 4, 0, 5⟩ (denote cache_6)] = denote cache_13 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_13 + +theorem verified_row_14 : fork [place ⟨0, 6, 5, 4⟩ cache_0, place ⟨3, 6, 1, 4⟩ cache_3] = cache_14 := by + decide +kernel + +theorem load_entry_14 : entryAt 14 = entry_14 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_14 : CacheEquation 14 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(14 < 6)), load_entry_14] + change forkRow [placeRow ⟨0, 6, 5, 4⟩ (denote cache_0), placeRow ⟨3, 6, 1, 4⟩ (denote cache_3)] = denote cache_14 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_14 + +theorem verified_row_15 : fork [place ⟨0, 6, 6, 4⟩ cache_0, place ⟨3, 6, 2, 4⟩ cache_3] = cache_15 := by + decide +kernel + +theorem load_entry_15 : entryAt 15 = entry_15 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_15 : CacheEquation 15 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(15 < 6)), load_entry_15] + change forkRow [placeRow ⟨0, 6, 6, 4⟩ (denote cache_0), placeRow ⟨3, 6, 2, 4⟩ (denote cache_3)] = denote cache_15 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_15 + +theorem verified_row_16 : fork [place ⟨3, 6, 3, 4⟩ cache_3, place ⟨0, 6, 7, 4⟩ cache_0] = cache_16 := by + decide +kernel + +theorem load_entry_16 : entryAt 16 = entry_16 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_16 : CacheEquation 16 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(16 < 6)), load_entry_16] + change forkRow [placeRow ⟨3, 6, 3, 4⟩ (denote cache_3), placeRow ⟨0, 6, 7, 4⟩ (denote cache_0)] = denote cache_16 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_16 + +theorem verified_row_17 : fork [place ⟨0, 6, 5, 4⟩ cache_0, place ⟨3, 0, 3, 3⟩ cache_3] = cache_17 := by + decide +kernel + +theorem load_entry_17 : entryAt 17 = entry_17 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_17 : CacheEquation 17 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(17 < 6)), load_entry_17] + change forkRow [placeRow ⟨0, 6, 5, 4⟩ (denote cache_0), placeRow ⟨3, 0, 3, 3⟩ (denote cache_3)] = denote cache_17 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_17 + +theorem verified_row_18 : fork [place ⟨3, 6, 2, 4⟩ cache_3, place ⟨3, 0, 4, 3⟩ cache_3] = cache_18 := by + decide +kernel + +theorem load_entry_18 : entryAt 18 = entry_18 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_18 : CacheEquation 18 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(18 < 6)), load_entry_18] + change forkRow [placeRow ⟨3, 6, 2, 4⟩ (denote cache_3), placeRow ⟨3, 0, 4, 3⟩ (denote cache_3)] = denote cache_18 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_18 + +theorem verified_row_19 : fork [place ⟨6, 4, 1, 5⟩ cache_6, place ⟨6, 0, 6, 5⟩ cache_6] = cache_19 := by + decide +kernel + +theorem load_entry_19 : entryAt 19 = entry_19 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_19 : CacheEquation 19 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(19 < 6)), load_entry_19] + change forkRow [placeRow ⟨6, 4, 1, 5⟩ (denote cache_6), placeRow ⟨6, 0, 6, 5⟩ (denote cache_6)] = denote cache_19 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_19 + +theorem verified_row_20 : fork [place ⟨6, 4, 0, 5⟩ cache_6, place ⟨6, 0, 5, 5⟩ cache_6] = cache_20 := by + decide +kernel + +theorem load_entry_20 : entryAt 20 = entry_20 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_20 : CacheEquation 20 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(20 < 6)), load_entry_20] + change forkRow [placeRow ⟨6, 4, 0, 5⟩ (denote cache_6), placeRow ⟨6, 0, 5, 5⟩ (denote cache_6)] = denote cache_20 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_20 + +theorem verified_row_21 : fork [place ⟨4, 6, 2, 3⟩ cache_4, place ⟨6, 0, 6, 5⟩ cache_6] = cache_21 := by + decide +kernel + +theorem load_entry_21 : entryAt 21 = entry_21 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_21 : CacheEquation 21 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(21 < 6)), load_entry_21] + change forkRow [placeRow ⟨4, 6, 2, 3⟩ (denote cache_4), placeRow ⟨6, 0, 6, 5⟩ (denote cache_6)] = denote cache_21 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_21 + +theorem verified_row_22 : fork [place ⟨0, 6, 7, 5⟩ cache_0, place ⟨3, 0, 5, 4⟩ cache_3] = cache_22 := by + decide +kernel + +theorem load_entry_22 : entryAt 22 = entry_22 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_22 : CacheEquation 22 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(22 < 6)), load_entry_22] + change forkRow [placeRow ⟨0, 6, 7, 5⟩ (denote cache_0), placeRow ⟨3, 0, 5, 4⟩ (denote cache_3)] = denote cache_22 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_22 + +theorem verified_row_23 : fork [place ⟨0, 6, 6, 4⟩ cache_0, place ⟨0, 0, 1, 3⟩ cache_0] = cache_23 := by + decide +kernel + +theorem load_entry_23 : entryAt 23 = entry_23 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_23 : CacheEquation 23 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(23 < 6)), load_entry_23] + change forkRow [placeRow ⟨0, 6, 6, 4⟩ (denote cache_0), placeRow ⟨0, 0, 1, 3⟩ (denote cache_0)] = denote cache_23 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_23 + +theorem verified_row_24 : fork [place ⟨0, 0, 0, 3⟩ cache_0, place ⟨17, 0, 5, 4⟩ cache_17] = cache_24 := by + decide +kernel + +theorem load_entry_24 : entryAt 24 = entry_24 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_24 : CacheEquation 24 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(24 < 6)), load_entry_24] + change forkRow [placeRow ⟨0, 0, 0, 3⟩ (denote cache_0), placeRow ⟨17, 0, 5, 4⟩ (denote cache_17)] = denote cache_24 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_24 + +theorem verified_row_25 : fork [place ⟨0, 0, 0, 3⟩ cache_0, place ⟨14, 0, 5, 4⟩ cache_14] = cache_25 := by + decide +kernel + +theorem load_entry_25 : entryAt 25 = entry_25 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_25 : CacheEquation 25 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(25 < 6)), load_entry_25] + change forkRow [placeRow ⟨0, 0, 0, 3⟩ (denote cache_0), placeRow ⟨14, 0, 5, 4⟩ (denote cache_14)] = denote cache_25 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_25 + +theorem verified_row_26 : fork [place ⟨0, 4, 6, 4⟩ cache_0, place ⟨6, 0, 6, 5⟩ cache_6] = cache_26 := by + decide +kernel + +theorem load_entry_26 : entryAt 26 = entry_26 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_26 : CacheEquation 26 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(26 < 6)), load_entry_26] + change forkRow [placeRow ⟨0, 4, 6, 4⟩ (denote cache_0), placeRow ⟨6, 0, 6, 5⟩ (denote cache_6)] = denote cache_26 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_26 + +theorem verified_row_27 : fork [place ⟨0, 6, 5, 4⟩ cache_0, place ⟨6, 4, 0, 5⟩ cache_6] = cache_27 := by + decide +kernel + +theorem load_entry_27 : entryAt 27 = entry_27 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_27 : CacheEquation 27 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(27 < 6)), load_entry_27] + change forkRow [placeRow ⟨0, 6, 5, 4⟩ (denote cache_0), placeRow ⟨6, 4, 0, 5⟩ (denote cache_6)] = denote cache_27 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_27 + +theorem verified_row_28 : fork [place ⟨6, 1, 4, 5⟩ cache_6, place ⟨0, 6, 6, 4⟩ cache_0] = cache_28 := by + decide +kernel + +theorem load_entry_28 : entryAt 28 = entry_28 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_28 : CacheEquation 28 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(28 < 6)), load_entry_28] + change forkRow [placeRow ⟨6, 1, 4, 5⟩ (denote cache_6), placeRow ⟨0, 6, 6, 4⟩ (denote cache_0)] = denote cache_28 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_28 + +theorem verified_row_29 : fork [place ⟨1, 4, 7, 3⟩ cache_1, place ⟨6, 3, 4, 5⟩ cache_6] = cache_29 := by + decide +kernel + +theorem load_entry_29 : entryAt 29 = entry_29 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_29 : CacheEquation 29 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(29 < 6)), load_entry_29] + change forkRow [placeRow ⟨1, 4, 7, 3⟩ (denote cache_1), placeRow ⟨6, 3, 4, 5⟩ (denote cache_6)] = denote cache_29 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_29 + +theorem verified_row_30 : fork [place ⟨0, 0, 1, 3⟩ cache_0, place ⟨14, 0, 6, 4⟩ cache_14] = cache_30 := by + decide +kernel + +theorem load_entry_30 : entryAt 30 = entry_30 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_30 : CacheEquation 30 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(30 < 6)), load_entry_30] + change forkRow [placeRow ⟨0, 0, 1, 3⟩ (denote cache_0), placeRow ⟨14, 0, 6, 4⟩ (denote cache_14)] = denote cache_30 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_30 + +theorem verified_row_31 : fork [place ⟨0, 0, 1, 4⟩ cache_0, place ⟨17, 0, 6, 5⟩ cache_17] = cache_31 := by + decide +kernel + +theorem load_entry_31 : entryAt 31 = entry_31 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_31 : CacheEquation 31 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(31 < 6)), load_entry_31] + change forkRow [placeRow ⟨0, 0, 1, 4⟩ (denote cache_0), placeRow ⟨17, 0, 6, 5⟩ (denote cache_17)] = denote cache_31 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_31 + +theorem verified_row_32 : fork [place ⟨0, 4, 8, 3⟩ cache_0, place ⟨6, 3, 4, 5⟩ cache_6] = cache_32 := by + decide +kernel + +theorem load_entry_32 : entryAt 32 = entry_32 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_32 : CacheEquation 32 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(32 < 6)), load_entry_32] + change forkRow [placeRow ⟨0, 4, 8, 3⟩ (denote cache_0), placeRow ⟨6, 3, 4, 5⟩ (denote cache_6)] = denote cache_32 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_32 + +theorem verified_row_33 : fork [place ⟨0, 0, 2, 4⟩ cache_0, place ⟨17, 0, 7, 5⟩ cache_17] = cache_33 := by + decide +kernel + +theorem load_entry_33 : entryAt 33 = entry_33 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_33 : CacheEquation 33 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(33 < 6)), load_entry_33] + change forkRow [placeRow ⟨0, 0, 2, 4⟩ (denote cache_0), placeRow ⟨17, 0, 7, 5⟩ (denote cache_17)] = denote cache_33 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_33 + +theorem verified_row_34 : fork [place ⟨6, 1, 4, 5⟩ cache_6, place ⟨1, 6, 5, 4⟩ cache_1] = cache_34 := by + decide +kernel + +theorem load_entry_34 : entryAt 34 = entry_34 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_34 : CacheEquation 34 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(34 < 6)), load_entry_34] + change forkRow [placeRow ⟨6, 1, 4, 5⟩ (denote cache_6), placeRow ⟨1, 6, 5, 4⟩ (denote cache_1)] = denote cache_34 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_34 + +theorem verified_row_35 : fork [place ⟨0, 0, 2, 4⟩ cache_0, place ⟨14, 0, 7, 5⟩ cache_14] = cache_35 := by + decide +kernel + +theorem load_entry_35 : entryAt 35 = entry_35 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_35 : CacheEquation 35 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(35 < 6)), load_entry_35] + change forkRow [placeRow ⟨0, 0, 2, 4⟩ (denote cache_0), placeRow ⟨14, 0, 7, 5⟩ (denote cache_14)] = denote cache_35 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_35 + +theorem verified_row_36 : fork [place ⟨0, 0, 3, 4⟩ cache_0, place ⟨17, 0, 8, 5⟩ cache_17] = cache_36 := by + decide +kernel + +theorem load_entry_36 : entryAt 36 = entry_36 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_36 : CacheEquation 36 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(36 < 6)), load_entry_36] + change forkRow [placeRow ⟨0, 0, 3, 4⟩ (denote cache_0), placeRow ⟨17, 0, 8, 5⟩ (denote cache_17)] = denote cache_36 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_36 + +theorem verified_row_37 : fork [place ⟨6, 3, 4, 5⟩ cache_6, place ⟨2, 4, 6, 3⟩ cache_2] = cache_37 := by + decide +kernel + +theorem load_entry_37 : entryAt 37 = entry_37 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_37 : CacheEquation 37 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(37 < 6)), load_entry_37] + change forkRow [placeRow ⟨6, 3, 4, 5⟩ (denote cache_6), placeRow ⟨2, 4, 6, 3⟩ (denote cache_2)] = denote cache_37 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_37 + +theorem verified_row_38 : fork [place ⟨3, 0, 3, 3⟩ cache_3, place ⟨16, 0, 2, 4⟩ cache_16] = cache_38 := by + decide +kernel + +theorem load_entry_38 : entryAt 38 = entry_38 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_38 : CacheEquation 38 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(38 < 6)), load_entry_38] + change forkRow [placeRow ⟨3, 0, 3, 3⟩ (denote cache_3), placeRow ⟨16, 0, 2, 4⟩ (denote cache_16)] = denote cache_38 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_38 + +theorem verified_row_39 : fork [place ⟨0, 0, 1, 3⟩ cache_0, place ⟨17, 0, 6, 4⟩ cache_17] = cache_39 := by + decide +kernel + +theorem load_entry_39 : entryAt 39 = entry_39 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_39 : CacheEquation 39 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(39 < 6)), load_entry_39] + change forkRow [placeRow ⟨0, 0, 1, 3⟩ (denote cache_0), placeRow ⟨17, 0, 6, 4⟩ (denote cache_17)] = denote cache_39 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_39 + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Equations01.lean b/lean/OAI/Combinatorics/SnakyCertificate/Equations01.lean new file mode 100644 index 0000000000000000000000000000000000000000..a7da19fb6f56d82219e8bbdf35bc6133ff266caf --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Equations01.lean @@ -0,0 +1,530 @@ +import OAI.Combinatorics.SnakyCertificate.Cache +import OAI.Combinatorics.SnakyCertificate.TableList + +namespace OAI + +namespace SnakyCertificate.Check + +theorem verified_row_40 : fork [place ⟨3, 0, 4, 3⟩ cache_3, place ⟨16, 0, 3, 4⟩ cache_16] = cache_40 := by + decide +kernel + +theorem load_entry_40 : entryAt 40 = entry_40 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_40 : CacheEquation 40 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(40 < 6)), load_entry_40] + change forkRow [placeRow ⟨3, 0, 4, 3⟩ (denote cache_3), placeRow ⟨16, 0, 3, 4⟩ (denote cache_16)] = denote cache_40 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_40 + +theorem verified_row_41 : fork [place ⟨6, 3, 3, 5⟩ cache_6, place ⟨1, 4, 6, 3⟩ cache_1] = cache_41 := by + decide +kernel + +theorem load_entry_41 : entryAt 41 = entry_41 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_41 : CacheEquation 41 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(41 < 6)), load_entry_41] + change forkRow [placeRow ⟨6, 3, 3, 5⟩ (denote cache_6), placeRow ⟨1, 4, 6, 3⟩ (denote cache_1)] = denote cache_41 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_41 + +theorem verified_row_42 : fork [place ⟨0, 6, 6, 4⟩ cache_0, place ⟨6, 4, 1, 5⟩ cache_6] = cache_42 := by + decide +kernel + +theorem load_entry_42 : entryAt 42 = entry_42 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_42 : CacheEquation 42 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(42 < 6)), load_entry_42] + change forkRow [placeRow ⟨0, 6, 6, 4⟩ (denote cache_0), placeRow ⟨6, 4, 1, 5⟩ (denote cache_6)] = denote cache_42 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_42 + +theorem verified_row_43 : fork [place ⟨2, 4, 5, 3⟩ cache_2, place ⟨6, 3, 3, 5⟩ cache_6] = cache_43 := by + decide +kernel + +theorem load_entry_43 : entryAt 43 = entry_43 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_43 : CacheEquation 43 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(43 < 6)), load_entry_43] + change forkRow [placeRow ⟨2, 4, 5, 3⟩ (denote cache_2), placeRow ⟨6, 3, 3, 5⟩ (denote cache_6)] = denote cache_43 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_43 + +theorem verified_row_44 : fork [place ⟨4, 4, 1, 5⟩ cache_4, place ⟨7, 0, 4, 5⟩ cache_7] = cache_44 := by + decide +kernel + +theorem load_entry_44 : entryAt 44 = entry_44 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_44 : CacheEquation 44 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(44 < 6)), load_entry_44] + change forkRow [placeRow ⟨4, 4, 1, 5⟩ (denote cache_4), placeRow ⟨7, 0, 4, 5⟩ (denote cache_7)] = denote cache_44 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_44 + +theorem verified_row_45 : fork [place ⟨6, 4, 0, 5⟩ cache_6, place ⟨7, 0, 4, 5⟩ cache_7] = cache_45 := by + decide +kernel + +theorem load_entry_45 : entryAt 45 = entry_45 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_45 : CacheEquation 45 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(45 < 6)), load_entry_45] + change forkRow [placeRow ⟨6, 4, 0, 5⟩ (denote cache_6), placeRow ⟨7, 0, 4, 5⟩ (denote cache_7)] = denote cache_45 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_45 + +theorem verified_row_46 : fork [place ⟨6, 6, 0, 3⟩ cache_6, place ⟨7, 0, 4, 5⟩ cache_7] = cache_46 := by + decide +kernel + +theorem load_entry_46 : entryAt 46 = entry_46 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_46 : CacheEquation 46 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(46 < 6)), load_entry_46] + change forkRow [placeRow ⟨6, 6, 0, 3⟩ (denote cache_6), placeRow ⟨7, 0, 4, 5⟩ (denote cache_7)] = denote cache_46 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_46 + +theorem verified_row_47 : fork [place ⟨6, 3, 3, 5⟩ cache_6, place ⟨6, 2, 7, 3⟩ cache_6] = cache_47 := by + decide +kernel + +theorem load_entry_47 : entryAt 47 = entry_47 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_47 : CacheEquation 47 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(47 < 6)), load_entry_47] + change forkRow [placeRow ⟨6, 3, 3, 5⟩ (denote cache_6), placeRow ⟨6, 2, 7, 3⟩ (denote cache_6)] = denote cache_47 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_47 + +theorem verified_row_48 : fork [place ⟨6, 3, 4, 5⟩ cache_6, place ⟨6, 2, 8, 3⟩ cache_6] = cache_48 := by + decide +kernel + +theorem load_entry_48 : entryAt 48 = entry_48 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_48 : CacheEquation 48 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(48 < 6)), load_entry_48] + change forkRow [placeRow ⟨6, 3, 4, 5⟩ (denote cache_6), placeRow ⟨6, 2, 8, 3⟩ (denote cache_6)] = denote cache_48 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_48 + +theorem verified_row_49 : fork [place ⟨4, 7, 3, 1⟩ cache_4, place ⟨7, 1, 5, 4⟩ cache_7] = cache_49 := by + decide +kernel + +theorem load_entry_49 : entryAt 49 = entry_49 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_49 : CacheEquation 49 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(49 < 6)), load_entry_49] + change forkRow [placeRow ⟨4, 7, 3, 1⟩ (denote cache_4), placeRow ⟨7, 1, 5, 4⟩ (denote cache_7)] = denote cache_49 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_49 + +theorem verified_row_50 : fork [place ⟨6, 3, 3, 5⟩ cache_6, place ⟨7, 1, 5, 4⟩ cache_7] = cache_50 := by + decide +kernel + +theorem load_entry_50 : entryAt 50 = entry_50 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_50 : CacheEquation 50 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(50 < 6)), load_entry_50] + change forkRow [placeRow ⟨6, 3, 3, 5⟩ (denote cache_6), placeRow ⟨7, 1, 5, 4⟩ (denote cache_7)] = denote cache_50 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_50 + +theorem verified_row_51 : fork [place ⟨10, 2, 5, 3⟩ cache_10, place ⟨10, 0, 5, 4⟩ cache_10, place ⟨26, 2, 3, 4⟩ cache_26, place ⟨26, 0, 3, 3⟩ cache_26] = cache_51 := by + decide +kernel + +theorem load_entry_51 : entryAt 51 = entry_51 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_51 : CacheEquation 51 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(51 < 6)), load_entry_51] + change forkRow [placeRow ⟨10, 2, 5, 3⟩ (denote cache_10), placeRow ⟨10, 0, 5, 4⟩ (denote cache_10), placeRow ⟨26, 2, 3, 4⟩ (denote cache_26), placeRow ⟨26, 0, 3, 3⟩ (denote cache_26)] = denote cache_51 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_51 + +theorem verified_row_52 : fork [place ⟨0, 0, 0, 3⟩ cache_0, place ⟨0, 4, 7, 3⟩ cache_0] = cache_52 := by + decide +kernel + +theorem load_entry_52 : entryAt 52 = entry_52 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_52 : CacheEquation 52 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(52 < 6)), load_entry_52] + change forkRow [placeRow ⟨0, 0, 0, 3⟩ (denote cache_0), placeRow ⟨0, 4, 7, 3⟩ (denote cache_0)] = denote cache_52 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_52 + +theorem verified_row_53 : fork [place ⟨6, 4, 3, 4⟩ cache_6, place ⟨3, 1, 4, 5⟩ cache_3] = cache_53 := by + decide +kernel + +theorem load_entry_53 : entryAt 53 = entry_53 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_53 : CacheEquation 53 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(53 < 6)), load_entry_53] + change forkRow [placeRow ⟨6, 4, 3, 4⟩ (denote cache_6), placeRow ⟨3, 1, 4, 5⟩ (denote cache_3)] = denote cache_53 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_53 + +theorem verified_row_54 : fork [place ⟨22, 0, 2, 3⟩ cache_22, place ⟨3, 6, 1, 4⟩ cache_3] = cache_54 := by + decide +kernel + +theorem load_entry_54 : entryAt 54 = entry_54 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_54 : CacheEquation 54 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(54 < 6)), load_entry_54] + change forkRow [placeRow ⟨22, 0, 2, 3⟩ (denote cache_22), placeRow ⟨3, 6, 1, 4⟩ (denote cache_3)] = denote cache_54 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_54 + +theorem verified_row_55 : fork [place ⟨7, 4, 0, 5⟩ cache_7, place ⟨7, 0, 4, 5⟩ cache_7] = cache_55 := by + decide +kernel + +theorem load_entry_55 : entryAt 55 = entry_55 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_55 : CacheEquation 55 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(55 < 6)), load_entry_55] + change forkRow [placeRow ⟨7, 4, 0, 5⟩ (denote cache_7), placeRow ⟨7, 0, 4, 5⟩ (denote cache_7)] = denote cache_55 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_55 + +theorem verified_row_56 : fork [place ⟨7, 4, 0, 5⟩ cache_7, place ⟨7, 6, 0, 3⟩ cache_7] = cache_56 := by + decide +kernel + +theorem load_entry_56 : entryAt 56 = entry_56 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_56 : CacheEquation 56 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(56 < 6)), load_entry_56] + change forkRow [placeRow ⟨7, 4, 0, 5⟩ (denote cache_7), placeRow ⟨7, 6, 0, 3⟩ (denote cache_7)] = denote cache_56 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_56 + +theorem verified_row_57 : fork [place ⟨0, 6, 5, 4⟩ cache_0, place ⟨7, 0, 4, 5⟩ cache_7] = cache_57 := by + decide +kernel + +theorem load_entry_57 : entryAt 57 = entry_57 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_57 : CacheEquation 57 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(57 < 6)), load_entry_57] + change forkRow [placeRow ⟨0, 6, 5, 4⟩ (denote cache_0), placeRow ⟨7, 0, 4, 5⟩ (denote cache_7)] = denote cache_57 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_57 + +theorem verified_row_58 : fork [place ⟨0, 4, 5, 4⟩ cache_0, place ⟨7, 0, 4, 5⟩ cache_7] = cache_58 := by + decide +kernel + +theorem load_entry_58 : entryAt 58 = entry_58 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_58 : CacheEquation 58 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(58 < 6)), load_entry_58] + change forkRow [placeRow ⟨0, 4, 5, 4⟩ (denote cache_0), placeRow ⟨7, 0, 4, 5⟩ (denote cache_7)] = denote cache_58 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_58 + +theorem verified_row_59 : fork [place ⟨0, 6, 5, 4⟩ cache_0, place ⟨7, 4, 0, 5⟩ cache_7] = cache_59 := by + decide +kernel + +theorem load_entry_59 : entryAt 59 = entry_59 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_59 : CacheEquation 59 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(59 < 6)), load_entry_59] + change forkRow [placeRow ⟨0, 6, 5, 4⟩ (denote cache_0), placeRow ⟨7, 4, 0, 5⟩ (denote cache_7)] = denote cache_59 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_59 + +theorem verified_row_60 : fork [place ⟨6, 6, 1, 3⟩ cache_6, place ⟨49, 1, 6, 4⟩ cache_49] = cache_60 := by + decide +kernel + +theorem load_entry_60 : entryAt 60 = entry_60 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_60 : CacheEquation 60 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(60 < 6)), load_entry_60] + change forkRow [placeRow ⟨6, 6, 1, 3⟩ (denote cache_6), placeRow ⟨49, 1, 6, 4⟩ (denote cache_49)] = denote cache_60 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_60 + +theorem verified_row_61 : fork [place ⟨6, 0, 5, 4⟩ cache_6, place ⟨14, 1, 4, 5⟩ cache_14] = cache_61 := by + decide +kernel + +theorem load_entry_61 : entryAt 61 = entry_61 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_61 : CacheEquation 61 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(61 < 6)), load_entry_61] + change forkRow [placeRow ⟨6, 0, 5, 4⟩ (denote cache_6), placeRow ⟨14, 1, 4, 5⟩ (denote cache_14)] = denote cache_61 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_61 + +theorem verified_row_62 : fork [place ⟨6, 6, 0, 3⟩ cache_6, place ⟨53, 0, 1, 5⟩ cache_53] = cache_62 := by + decide +kernel + +theorem load_entry_62 : entryAt 62 = entry_62 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_62 : CacheEquation 62 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(62 < 6)), load_entry_62] + change forkRow [placeRow ⟨6, 6, 0, 3⟩ (denote cache_6), placeRow ⟨53, 0, 1, 5⟩ (denote cache_53)] = denote cache_62 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_62 + +theorem verified_row_63 : fork [place ⟨4, 3, 4, 3⟩ cache_4, place ⟨50, 0, 5, 4⟩ cache_50] = cache_63 := by + decide +kernel + +theorem load_entry_63 : entryAt 63 = entry_63 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_63 : CacheEquation 63 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(63 < 6)), load_entry_63] + change forkRow [placeRow ⟨4, 3, 4, 3⟩ (denote cache_4), placeRow ⟨50, 0, 5, 4⟩ (denote cache_50)] = denote cache_63 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_63 + +theorem verified_row_64 : fork [place ⟨6, 6, 3, 4⟩ cache_6, place ⟨49, 1, 8, 5⟩ cache_49] = cache_64 := by + decide +kernel + +theorem load_entry_64 : entryAt 64 = entry_64 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_64 : CacheEquation 64 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(64 < 6)), load_entry_64] + change forkRow [placeRow ⟨6, 6, 3, 4⟩ (denote cache_6), placeRow ⟨49, 1, 8, 5⟩ (denote cache_49)] = denote cache_64 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_64 + +theorem verified_row_65 : fork [place ⟨6, 6, 0, 3⟩ cache_6, place ⟨49, 1, 5, 4⟩ cache_49] = cache_65 := by + decide +kernel + +theorem load_entry_65 : entryAt 65 = entry_65 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_65 : CacheEquation 65 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(65 < 6)), load_entry_65] + change forkRow [placeRow ⟨6, 6, 0, 3⟩ (denote cache_6), placeRow ⟨49, 1, 5, 4⟩ (denote cache_49)] = denote cache_65 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_65 + +theorem verified_row_66 : fork [place ⟨6, 3, 4, 5⟩ cache_6, place ⟨53, 5, 6, 4⟩ cache_53] = cache_66 := by + decide +kernel + +theorem load_entry_66 : entryAt 66 = entry_66 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_66 : CacheEquation 66 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(66 < 6)), load_entry_66] + change forkRow [placeRow ⟨6, 3, 4, 5⟩ (denote cache_6), placeRow ⟨53, 5, 6, 4⟩ (denote cache_53)] = denote cache_66 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_66 + +theorem verified_row_67 : fork [place ⟨6, 1, 4, 5⟩ cache_6, place ⟨9, 2, 5, 4⟩ cache_9] = cache_67 := by + decide +kernel + +theorem load_entry_67 : entryAt 67 = entry_67 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_67 : CacheEquation 67 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(67 < 6)), load_entry_67] + change forkRow [placeRow ⟨6, 1, 4, 5⟩ (denote cache_6), placeRow ⟨9, 2, 5, 4⟩ (denote cache_9)] = denote cache_67 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_67 + +theorem verified_row_68 : fork [place ⟨6, 4, 0, 5⟩ cache_6, place ⟨44, 0, 5, 4⟩ cache_44] = cache_68 := by + decide +kernel + +theorem load_entry_68 : entryAt 68 = entry_68 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_68 : CacheEquation 68 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(68 < 6)), load_entry_68] + change forkRow [placeRow ⟨6, 4, 0, 5⟩ (denote cache_6), placeRow ⟨44, 0, 5, 4⟩ (denote cache_44)] = denote cache_68 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_68 + +theorem verified_row_69 : fork [place ⟨6, 3, 4, 5⟩ cache_6, place ⟨34, 0, 6, 5⟩ cache_34] = cache_69 := by + decide +kernel + +theorem load_entry_69 : entryAt 69 = entry_69 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_69 : CacheEquation 69 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(69 < 6)), load_entry_69] + change forkRow [placeRow ⟨6, 3, 4, 5⟩ (denote cache_6), placeRow ⟨34, 0, 6, 5⟩ (denote cache_34)] = denote cache_69 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_69 + +theorem verified_row_70 : fork [place ⟨4, 3, 4, 3⟩ cache_4, place ⟨41, 0, 5, 4⟩ cache_41] = cache_70 := by + decide +kernel + +theorem load_entry_70 : entryAt 70 = entry_70 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_70 : CacheEquation 70 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(70 < 6)), load_entry_70] + change forkRow [placeRow ⟨4, 3, 4, 3⟩ (denote cache_4), placeRow ⟨41, 0, 5, 4⟩ (denote cache_41)] = denote cache_70 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_70 + +theorem verified_row_71 : fork [place ⟨6, 1, 4, 5⟩ cache_6, place ⟨23, 2, 4, 3⟩ cache_23] = cache_71 := by + decide +kernel + +theorem load_entry_71 : entryAt 71 = entry_71 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_71 : CacheEquation 71 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(71 < 6)), load_entry_71] + change forkRow [placeRow ⟨6, 1, 4, 5⟩ (denote cache_6), placeRow ⟨23, 2, 4, 3⟩ (denote cache_23)] = denote cache_71 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_71 + +theorem verified_row_72 : fork [place ⟨0, 5, 3, 8⟩ cache_0, place ⟨8, 6, 5, 4⟩ cache_8] = cache_72 := by + decide +kernel + +theorem load_entry_72 : entryAt 72 = entry_72 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_72 : CacheEquation 72 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(72 < 6)), load_entry_72] + change forkRow [placeRow ⟨0, 5, 3, 8⟩ (denote cache_0), placeRow ⟨8, 6, 5, 4⟩ (denote cache_8)] = denote cache_72 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_72 + +theorem verified_row_73 : fork [place ⟨4, 3, 3, 4⟩ cache_4, place ⟨50, 0, 4, 5⟩ cache_50] = cache_73 := by + decide +kernel + +theorem load_entry_73 : entryAt 73 = entry_73 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_73 : CacheEquation 73 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(73 < 6)), load_entry_73] + change forkRow [placeRow ⟨4, 3, 3, 4⟩ (denote cache_4), placeRow ⟨50, 0, 4, 5⟩ (denote cache_50)] = denote cache_73 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_73 + +theorem verified_row_74 : fork [place ⟨2, 7, 4, 3⟩ cache_2, place ⟨53, 0, 3, 3⟩ cache_53] = cache_74 := by + decide +kernel + +theorem load_entry_74 : entryAt 74 = entry_74 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_74 : CacheEquation 74 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(74 < 6)), load_entry_74] + change forkRow [placeRow ⟨2, 7, 4, 3⟩ (denote cache_2), placeRow ⟨53, 0, 3, 3⟩ (denote cache_53)] = denote cache_74 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_74 + +theorem verified_row_75 : fork [place ⟨0, 0, 1, 3⟩ cache_0, place ⟨9, 0, 7, 3⟩ cache_9] = cache_75 := by + decide +kernel + +theorem load_entry_75 : entryAt 75 = entry_75 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_75 : CacheEquation 75 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(75 < 6)), load_entry_75] + change forkRow [placeRow ⟨0, 0, 1, 3⟩ (denote cache_0), placeRow ⟨9, 0, 7, 3⟩ (denote cache_9)] = denote cache_75 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_75 + +theorem verified_row_76 : fork [place ⟨0, 7, 5, 7⟩ cache_0, place ⟨14, 0, 7, 5⟩ cache_14] = cache_76 := by + decide +kernel + +theorem load_entry_76 : entryAt 76 = entry_76 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_76 : CacheEquation 76 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(76 < 6)), load_entry_76] + change forkRow [placeRow ⟨0, 7, 5, 7⟩ (denote cache_0), placeRow ⟨14, 0, 7, 5⟩ (denote cache_14)] = denote cache_76 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_76 + +theorem verified_row_77 : fork [place ⟨0, 5, 3, 7⟩ cache_0, place ⟨12, 0, 5, 4⟩ cache_12] = cache_77 := by + decide +kernel + +theorem load_entry_77 : entryAt 77 = entry_77 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_77 : CacheEquation 77 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(77 < 6)), load_entry_77] + change forkRow [placeRow ⟨0, 5, 3, 7⟩ (denote cache_0), placeRow ⟨12, 0, 5, 4⟩ (denote cache_12)] = denote cache_77 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_77 + +theorem verified_row_78 : fork [place ⟨6, 4, 3, 4⟩ cache_6, place ⟨52, 0, 5, 4⟩ cache_52] = cache_78 := by + decide +kernel + +theorem load_entry_78 : entryAt 78 = entry_78 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_78 : CacheEquation 78 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(78 < 6)), load_entry_78] + change forkRow [placeRow ⟨6, 4, 3, 4⟩ (denote cache_6), placeRow ⟨52, 0, 5, 4⟩ (denote cache_52)] = denote cache_78 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_78 + +theorem verified_row_79 : fork [place ⟨6, 1, 5, 5⟩ cache_6, place ⟨48, 0, 3, 4⟩ cache_48] = cache_79 := by + decide +kernel + +theorem load_entry_79 : entryAt 79 = entry_79 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_79 : CacheEquation 79 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(79 < 6)), load_entry_79] + change forkRow [placeRow ⟨6, 1, 5, 5⟩ (denote cache_6), placeRow ⟨48, 0, 3, 4⟩ (denote cache_48)] = denote cache_79 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_79 + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Equations02.lean b/lean/OAI/Combinatorics/SnakyCertificate/Equations02.lean new file mode 100644 index 0000000000000000000000000000000000000000..e50ef2564b9367efc708652e7aa3fc163ee1194e --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Equations02.lean @@ -0,0 +1,530 @@ +import OAI.Combinatorics.SnakyCertificate.Cache +import OAI.Combinatorics.SnakyCertificate.TableList + +namespace OAI + +namespace SnakyCertificate.Check + +theorem verified_row_80 : fork [place ⟨0, 6, 6, 4⟩ cache_0, place ⟨13, 4, 2, 4⟩ cache_13] = cache_80 := by + decide +kernel + +theorem load_entry_80 : entryAt 80 = entry_80 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_80 : CacheEquation 80 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(80 < 6)), load_entry_80] + change forkRow [placeRow ⟨0, 6, 6, 4⟩ (denote cache_0), placeRow ⟨13, 4, 2, 4⟩ (denote cache_13)] = denote cache_80 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_80 + +theorem verified_row_81 : fork [place ⟨4, 3, 4, 3⟩ cache_4, place ⟨43, 0, 5, 4⟩ cache_43] = cache_81 := by + decide +kernel + +theorem load_entry_81 : entryAt 81 = entry_81 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_81 : CacheEquation 81 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(81 < 6)), load_entry_81] + change forkRow [placeRow ⟨4, 3, 4, 3⟩ (denote cache_4), placeRow ⟨43, 0, 5, 4⟩ (denote cache_43)] = denote cache_81 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_81 + +theorem verified_row_82 : fork [place ⟨6, 1, 4, 5⟩ cache_6, place ⟨36, 0, 1, 3⟩ cache_36] = cache_82 := by + decide +kernel + +theorem load_entry_82 : entryAt 82 = entry_82 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_82 : CacheEquation 82 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(82 < 6)), load_entry_82] + change forkRow [placeRow ⟨6, 1, 4, 5⟩ (denote cache_6), placeRow ⟨36, 0, 1, 3⟩ (denote cache_36)] = denote cache_82 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_82 + +theorem verified_row_83 : fork [place ⟨0, 7, 5, 7⟩ cache_0, place ⟨67, 2, 6, 3⟩ cache_67] = cache_83 := by + decide +kernel + +theorem load_entry_83 : entryAt 83 = entry_83 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_83 : CacheEquation 83 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(83 < 6)), load_entry_83] + change forkRow [placeRow ⟨0, 7, 5, 7⟩ (denote cache_0), placeRow ⟨67, 2, 6, 3⟩ (denote cache_67)] = denote cache_83 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_83 + +theorem verified_row_84 : fork [place ⟨6, 3, 4, 5⟩ cache_6, place ⟨67, 0, 6, 4⟩ cache_67] = cache_84 := by + decide +kernel + +theorem load_entry_84 : entryAt 84 = entry_84 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_84 : CacheEquation 84 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(84 < 6)), load_entry_84] + change forkRow [placeRow ⟨6, 3, 4, 5⟩ (denote cache_6), placeRow ⟨67, 0, 6, 4⟩ (denote cache_67)] = denote cache_84 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_84 + +theorem verified_row_85 : fork [place ⟨9, 0, 6, 3⟩ cache_9, place ⟨8, 4, 5, 4⟩ cache_8] = cache_85 := by + decide +kernel + +theorem load_entry_85 : entryAt 85 = entry_85 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_85 : CacheEquation 85 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(85 < 6)), load_entry_85] + change forkRow [placeRow ⟨9, 0, 6, 3⟩ (denote cache_9), placeRow ⟨8, 4, 5, 4⟩ (denote cache_8)] = denote cache_85 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_85 + +theorem verified_row_86 : fork [place ⟨0, 6, 5, 4⟩ cache_0, place ⟨67, 3, 1, 5⟩ cache_67] = cache_86 := by + decide +kernel + +theorem load_entry_86 : entryAt 86 = entry_86 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_86 : CacheEquation 86 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(86 < 6)), load_entry_86] + change forkRow [placeRow ⟨0, 6, 5, 4⟩ (denote cache_0), placeRow ⟨67, 3, 1, 5⟩ (denote cache_67)] = denote cache_86 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_86 + +theorem verified_row_87 : fork [place ⟨0, 5, 3, 7⟩ cache_0, place ⟨24, 2, 5, 3⟩ cache_24] = cache_87 := by + decide +kernel + +theorem load_entry_87 : entryAt 87 = entry_87 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_87 : CacheEquation 87 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(87 < 6)), load_entry_87] + change forkRow [placeRow ⟨0, 5, 3, 7⟩ (denote cache_0), placeRow ⟨24, 2, 5, 3⟩ (denote cache_24)] = denote cache_87 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_87 + +theorem verified_row_88 : fork [place ⟨0, 6, 6, 4⟩ cache_0, place ⟨67, 3, 2, 5⟩ cache_67] = cache_88 := by + decide +kernel + +theorem load_entry_88 : entryAt 88 = entry_88 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_88 : CacheEquation 88 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(88 < 6)), load_entry_88] + change forkRow [placeRow ⟨0, 6, 6, 4⟩ (denote cache_0), placeRow ⟨67, 3, 2, 5⟩ (denote cache_67)] = denote cache_88 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_88 + +theorem verified_row_89 : fork [place ⟨8, 3, 3, 1⟩ cache_8, place ⟨7, 1, 5, 4⟩ cache_7] = cache_89 := by + decide +kernel + +theorem load_entry_89 : entryAt 89 = entry_89 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_89 : CacheEquation 89 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(89 < 6)), load_entry_89] + change forkRow [placeRow ⟨8, 3, 3, 1⟩ (denote cache_8), placeRow ⟨7, 1, 5, 4⟩ (denote cache_7)] = denote cache_89 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_89 + +theorem verified_row_90 : fork [place ⟨31, 0, 3, 3⟩ cache_31, place ⟨54, 6, 0, 3⟩ cache_54, place ⟨54, 0, 5, 4⟩ cache_54, place ⟨31, 6, 2, 4⟩ cache_31] = cache_90 := by + decide +kernel + +theorem load_entry_90 : entryAt 90 = entry_90 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_90 : CacheEquation 90 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(90 < 6)), load_entry_90] + change forkRow [placeRow ⟨31, 0, 3, 3⟩ (denote cache_31), placeRow ⟨54, 6, 0, 3⟩ (denote cache_54), placeRow ⟨54, 0, 5, 4⟩ (denote cache_54), placeRow ⟨31, 6, 2, 4⟩ (denote cache_31)] = denote cache_90 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_90 + +theorem verified_row_91 : fork [place ⟨6, 3, 4, 5⟩ cache_6, place ⟨74, 5, 7, 3⟩ cache_74] = cache_91 := by + decide +kernel + +theorem load_entry_91 : entryAt 91 = entry_91 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_91 : CacheEquation 91 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(91 < 6)), load_entry_91] + change forkRow [placeRow ⟨6, 3, 4, 5⟩ (denote cache_6), placeRow ⟨74, 5, 7, 3⟩ (denote cache_74)] = denote cache_91 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_91 + +theorem verified_row_92 : fork [place ⟨6, 1, 4, 5⟩ cache_6, place ⟨33, 0, 2, 3⟩ cache_33] = cache_92 := by + decide +kernel + +theorem load_entry_92 : entryAt 92 = entry_92 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_92 : CacheEquation 92 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(92 < 6)), load_entry_92] + change forkRow [placeRow ⟨6, 1, 4, 5⟩ (denote cache_6), placeRow ⟨33, 0, 2, 3⟩ (denote cache_33)] = denote cache_92 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_92 + +theorem verified_row_93 : fork [place ⟨4, 3, 4, 3⟩ cache_4, place ⟨47, 0, 5, 4⟩ cache_47] = cache_93 := by + decide +kernel + +theorem load_entry_93 : entryAt 93 = entry_93 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_93 : CacheEquation 93 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(93 < 6)), load_entry_93] + change forkRow [placeRow ⟨4, 3, 4, 3⟩ (denote cache_4), placeRow ⟨47, 0, 5, 4⟩ (denote cache_47)] = denote cache_93 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_93 + +theorem verified_row_94 : fork [place ⟨6, 1, 4, 5⟩ cache_6, place ⟨27, 3, 3, 6⟩ cache_27] = cache_94 := by + decide +kernel + +theorem load_entry_94 : entryAt 94 = entry_94 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_94 : CacheEquation 94 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(94 < 6)), load_entry_94] + change forkRow [placeRow ⟨6, 1, 4, 5⟩ (denote cache_6), placeRow ⟨27, 3, 3, 6⟩ (denote cache_27)] = denote cache_94 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_94 + +theorem verified_row_95 : fork [place ⟨0, 5, 3, 7⟩ cache_0, place ⟨29, 0, 2, 5⟩ cache_29] = cache_95 := by + decide +kernel + +theorem load_entry_95 : entryAt 95 = entry_95 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_95 : CacheEquation 95 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(95 < 6)), load_entry_95] + change forkRow [placeRow ⟨0, 5, 3, 7⟩ (denote cache_0), placeRow ⟨29, 0, 2, 5⟩ (denote cache_29)] = denote cache_95 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_95 + +theorem verified_row_96 : fork [place ⟨6, 1, 5, 5⟩ cache_6, place ⟨70, 0, 3, 5⟩ cache_70] = cache_96 := by + decide +kernel + +theorem load_entry_96 : entryAt 96 = entry_96 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_96 : CacheEquation 96 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(96 < 6)), load_entry_96] + change forkRow [placeRow ⟨6, 1, 5, 5⟩ (denote cache_6), placeRow ⟨70, 0, 3, 5⟩ (denote cache_70)] = denote cache_96 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_96 + +theorem verified_row_97 : fork [place ⟨6, 6, 0, 3⟩ cache_6, place ⟨44, 0, 5, 4⟩ cache_44] = cache_97 := by + decide +kernel + +theorem load_entry_97 : entryAt 97 = entry_97 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_97 : CacheEquation 97 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(97 < 6)), load_entry_97] + change forkRow [placeRow ⟨6, 6, 0, 3⟩ (denote cache_6), placeRow ⟨44, 0, 5, 4⟩ (denote cache_44)] = denote cache_97 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_97 + +theorem verified_row_98 : fork [place ⟨6, 6, 2, 3⟩ cache_6, place ⟨44, 0, 7, 4⟩ cache_44] = cache_98 := by + decide +kernel + +theorem load_entry_98 : entryAt 98 = entry_98 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_98 : CacheEquation 98 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(98 < 6)), load_entry_98] + change forkRow [placeRow ⟨6, 6, 2, 3⟩ (denote cache_6), placeRow ⟨44, 0, 7, 4⟩ (denote cache_44)] = denote cache_98 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_98 + +theorem verified_row_99 : fork [place ⟨2, 1, 3, 2⟩ cache_2, place ⟨24, 0, 5, 4⟩ cache_24] = cache_99 := by + decide +kernel + +theorem load_entry_99 : entryAt 99 = entry_99 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_99 : CacheEquation 99 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(99 < 6)), load_entry_99] + change forkRow [placeRow ⟨2, 1, 3, 2⟩ (denote cache_2), placeRow ⟨24, 0, 5, 4⟩ (denote cache_24)] = denote cache_99 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_99 + +theorem verified_row_100 : fork [place ⟨0, 6, 5, 4⟩ cache_0, place ⟨48, 0, 1, 4⟩ cache_48] = cache_100 := by + decide +kernel + +theorem load_entry_100 : entryAt 100 = entry_100 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_100 : CacheEquation 100 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(100 < 6)), load_entry_100] + change forkRow [placeRow ⟨0, 6, 5, 4⟩ (denote cache_0), placeRow ⟨48, 0, 1, 4⟩ (denote cache_48)] = denote cache_100 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_100 + +theorem verified_row_101 : fork [place ⟨0, 7, 4, 6⟩ cache_0, place ⟨24, 0, 5, 4⟩ cache_24] = cache_101 := by + decide +kernel + +theorem load_entry_101 : entryAt 101 = entry_101 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_101 : CacheEquation 101 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(101 < 6)), load_entry_101] + change forkRow [placeRow ⟨0, 7, 4, 6⟩ (denote cache_0), placeRow ⟨24, 0, 5, 4⟩ (denote cache_24)] = denote cache_101 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_101 + +theorem verified_row_102 : fork [place ⟨6, 3, 4, 5⟩ cache_6, place ⟨25, 2, 6, 3⟩ cache_25] = cache_102 := by + decide +kernel + +theorem load_entry_102 : entryAt 102 = entry_102 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_102 : CacheEquation 102 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(102 < 6)), load_entry_102] + change forkRow [placeRow ⟨6, 3, 4, 5⟩ (denote cache_6), placeRow ⟨25, 2, 6, 3⟩ (denote cache_25)] = denote cache_102 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_102 + +theorem verified_row_103 : fork [place ⟨6, 3, 4, 5⟩ cache_6, place ⟨71, 0, 6, 4⟩ cache_71] = cache_103 := by + decide +kernel + +theorem load_entry_103 : entryAt 103 = entry_103 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_103 : CacheEquation 103 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(103 < 6)), load_entry_103] + change forkRow [placeRow ⟨6, 3, 4, 5⟩ (denote cache_6), placeRow ⟨71, 0, 6, 4⟩ (denote cache_71)] = denote cache_103 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_103 + +theorem verified_row_104 : fork [place ⟨6, 0, 5, 4⟩ cache_6, place ⟨75, 0, 3, 4⟩ cache_75] = cache_104 := by + decide +kernel + +theorem load_entry_104 : entryAt 104 = entry_104 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_104 : CacheEquation 104 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(104 < 6)), load_entry_104] + change forkRow [placeRow ⟨6, 0, 5, 4⟩ (denote cache_6), placeRow ⟨75, 0, 3, 4⟩ (denote cache_75)] = denote cache_104 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_104 + +theorem verified_row_105 : fork [place ⟨6, 5, 4, 3⟩ cache_6, place ⟨77, 0, 4, 5⟩ cache_77] = cache_105 := by + decide +kernel + +theorem load_entry_105 : entryAt 105 = entry_105 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_105 : CacheEquation 105 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(105 < 6)), load_entry_105] + change forkRow [placeRow ⟨6, 5, 4, 3⟩ (denote cache_6), placeRow ⟨77, 0, 4, 5⟩ (denote cache_77)] = denote cache_105 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_105 + +theorem verified_row_106 : fork [place ⟨6, 1, 4, 5⟩ cache_6, place ⟨36, 6, 5, 4⟩ cache_36] = cache_106 := by + decide +kernel + +theorem load_entry_106 : entryAt 106 = entry_106 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_106 : CacheEquation 106 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(106 < 6)), load_entry_106] + change forkRow [placeRow ⟨6, 1, 4, 5⟩ (denote cache_6), placeRow ⟨36, 6, 5, 4⟩ (denote cache_36)] = denote cache_106 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_106 + +theorem verified_row_107 : fork [place ⟨6, 6, 0, 3⟩ cache_6, place ⟨63, 1, 5, 3⟩ cache_63] = cache_107 := by + decide +kernel + +theorem load_entry_107 : entryAt 107 = entry_107 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_107 : CacheEquation 107 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(107 < 6)), load_entry_107] + change forkRow [placeRow ⟨6, 6, 0, 3⟩ (denote cache_6), placeRow ⟨63, 1, 5, 3⟩ (denote cache_63)] = denote cache_107 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_107 + +theorem verified_row_108 : fork [place ⟨4, 6, 1, 3⟩ cache_4, place ⟨63, 1, 5, 3⟩ cache_63] = cache_108 := by + decide +kernel + +theorem load_entry_108 : entryAt 108 = entry_108 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_108 : CacheEquation 108 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(108 < 6)), load_entry_108] + change forkRow [placeRow ⟨4, 6, 1, 3⟩ (denote cache_4), placeRow ⟨63, 1, 5, 3⟩ (denote cache_63)] = denote cache_108 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_108 + +theorem verified_row_109 : fork [place ⟨4, 6, 1, 3⟩ cache_4, place ⟨55, 0, 5, 4⟩ cache_55] = cache_109 := by + decide +kernel + +theorem load_entry_109 : entryAt 109 = entry_109 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_109 : CacheEquation 109 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(109 < 6)), load_entry_109] + change forkRow [placeRow ⟨4, 6, 1, 3⟩ (denote cache_4), placeRow ⟨55, 0, 5, 4⟩ (denote cache_55)] = denote cache_109 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_109 + +theorem verified_row_110 : fork [place ⟨6, 6, 1, 3⟩ cache_6, place ⟨63, 1, 6, 3⟩ cache_63] = cache_110 := by + decide +kernel + +theorem load_entry_110 : entryAt 110 = entry_110 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_110 : CacheEquation 110 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(110 < 6)), load_entry_110] + change forkRow [placeRow ⟨6, 6, 1, 3⟩ (denote cache_6), placeRow ⟨63, 1, 6, 3⟩ (denote cache_63)] = denote cache_110 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_110 + +theorem verified_row_111 : fork [place ⟨6, 7, 4, 3⟩ cache_6, place ⟨83, 0, 4, 5⟩ cache_83] = cache_111 := by + decide +kernel + +theorem load_entry_111 : entryAt 111 = entry_111 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_111 : CacheEquation 111 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(111 < 6)), load_entry_111] + change forkRow [placeRow ⟨6, 7, 4, 3⟩ (denote cache_6), placeRow ⟨83, 0, 4, 5⟩ (denote cache_83)] = denote cache_111 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_111 + +theorem verified_row_112 : fork [place ⟨4, 1, 5, 4⟩ cache_4, place ⟨93, 0, 3, 5⟩ cache_93] = cache_112 := by + decide +kernel + +theorem load_entry_112 : entryAt 112 = entry_112 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_112 : CacheEquation 112 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(112 < 6)), load_entry_112] + change forkRow [placeRow ⟨4, 1, 5, 4⟩ (denote cache_4), placeRow ⟨93, 0, 3, 5⟩ (denote cache_93)] = denote cache_112 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_112 + +theorem verified_row_113 : fork [place ⟨1, 6, 6, 4⟩ cache_1, place ⟨36, 6, 7, 5⟩ cache_36] = cache_113 := by + decide +kernel + +theorem load_entry_113 : entryAt 113 = entry_113 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_113 : CacheEquation 113 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(113 < 6)), load_entry_113] + change forkRow [placeRow ⟨1, 6, 6, 4⟩ (denote cache_1), placeRow ⟨36, 6, 7, 5⟩ (denote cache_36)] = denote cache_113 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_113 + +theorem verified_row_114 : fork [place ⟨6, 0, 6, 5⟩ cache_6, place ⟨67, 3, 2, 5⟩ cache_67] = cache_114 := by + decide +kernel + +theorem load_entry_114 : entryAt 114 = entry_114 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_114 : CacheEquation 114 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(114 < 6)), load_entry_114] + change forkRow [placeRow ⟨6, 0, 6, 5⟩ (denote cache_6), placeRow ⟨67, 3, 2, 5⟩ (denote cache_67)] = denote cache_114 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_114 + +theorem verified_row_115 : fork [place ⟨6, 2, 7, 3⟩ cache_6, place ⟨70, 7, 2, 5⟩ cache_70] = cache_115 := by + decide +kernel + +theorem load_entry_115 : entryAt 115 = entry_115 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_115 : CacheEquation 115 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(115 < 6)), load_entry_115] + change forkRow [placeRow ⟨6, 2, 7, 3⟩ (denote cache_6), placeRow ⟨70, 7, 2, 5⟩ (denote cache_70)] = denote cache_115 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_115 + +theorem verified_row_116 : fork [place ⟨0, 7, 4, 6⟩ cache_0, place ⟨24, 2, 5, 4⟩ cache_24] = cache_116 := by + decide +kernel + +theorem load_entry_116 : entryAt 116 = entry_116 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_116 : CacheEquation 116 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(116 < 6)), load_entry_116] + change forkRow [placeRow ⟨0, 7, 4, 6⟩ (denote cache_0), placeRow ⟨24, 2, 5, 4⟩ (denote cache_24)] = denote cache_116 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_116 + +theorem verified_row_117 : fork [place ⟨6, 1, 4, 5⟩ cache_6, place ⟨100, 0, 5, 4⟩ cache_100] = cache_117 := by + decide +kernel + +theorem load_entry_117 : entryAt 117 = entry_117 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_117 : CacheEquation 117 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(117 < 6)), load_entry_117] + change forkRow [placeRow ⟨6, 1, 4, 5⟩ (denote cache_6), placeRow ⟨100, 0, 5, 4⟩ (denote cache_100)] = denote cache_117 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_117 + +theorem verified_row_118 : fork [place ⟨4, 7, 3, 1⟩ cache_4, place ⟨61, 1, 5, 4⟩ cache_61] = cache_118 := by + decide +kernel + +theorem load_entry_118 : entryAt 118 = entry_118 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_118 : CacheEquation 118 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(118 < 6)), load_entry_118] + change forkRow [placeRow ⟨4, 7, 3, 1⟩ (denote cache_4), placeRow ⟨61, 1, 5, 4⟩ (denote cache_61)] = denote cache_118 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_118 + +theorem verified_row_119 : fork [place ⟨6, 6, 1, 3⟩ cache_6, place ⟨55, 0, 6, 4⟩ cache_55] = cache_119 := by + decide +kernel + +theorem load_entry_119 : entryAt 119 = entry_119 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_119 : CacheEquation 119 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(119 < 6)), load_entry_119] + change forkRow [placeRow ⟨6, 6, 1, 3⟩ (denote cache_6), placeRow ⟨55, 0, 6, 4⟩ (denote cache_55)] = denote cache_119 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_119 + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Equations03.lean b/lean/OAI/Combinatorics/SnakyCertificate/Equations03.lean new file mode 100644 index 0000000000000000000000000000000000000000..e3f339621b10c24b26d83adda42cd0fb97869782 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Equations03.lean @@ -0,0 +1,530 @@ +import OAI.Combinatorics.SnakyCertificate.Cache +import OAI.Combinatorics.SnakyCertificate.TableList + +namespace OAI + +namespace SnakyCertificate.Check + +theorem verified_row_120 : fork [place ⟨4, 0, 4, 5⟩ cache_4, place ⟨58, 2, 5, 4⟩ cache_58] = cache_120 := by + decide +kernel + +theorem load_entry_120 : entryAt 120 = entry_120 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_120 : CacheEquation 120 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(120 < 6)), load_entry_120] + change forkRow [placeRow ⟨4, 0, 4, 5⟩ (denote cache_4), placeRow ⟨58, 2, 5, 4⟩ (denote cache_58)] = denote cache_120 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_120 + +theorem verified_row_121 : fork [place ⟨9, 3, 4, 5⟩ cache_9, place ⟨7, 1, 5, 4⟩ cache_7] = cache_121 := by + decide +kernel + +theorem load_entry_121 : entryAt 121 = entry_121 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_121 : CacheEquation 121 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(121 < 6)), load_entry_121] + change forkRow [placeRow ⟨9, 3, 4, 5⟩ (denote cache_9), placeRow ⟨7, 1, 5, 4⟩ (denote cache_7)] = denote cache_121 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_121 + +theorem verified_row_122 : fork [place ⟨6, 6, 3, 3⟩ cache_6, place ⟨105, 1, 4, 5⟩ cache_105] = cache_122 := by + decide +kernel + +theorem load_entry_122 : entryAt 122 = entry_122 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_122 : CacheEquation 122 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(122 < 6)), load_entry_122] + change forkRow [placeRow ⟨6, 6, 3, 3⟩ (denote cache_6), placeRow ⟨105, 1, 4, 5⟩ (denote cache_105)] = denote cache_122 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_122 + +theorem verified_row_123 : fork [place ⟨6, 6, 1, 3⟩ cache_6, place ⟨64, 2, 2, 5⟩ cache_64] = cache_123 := by + decide +kernel + +theorem load_entry_123 : entryAt 123 = entry_123 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_123 : CacheEquation 123 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(123 < 6)), load_entry_123] + change forkRow [placeRow ⟨6, 6, 1, 3⟩ (denote cache_6), placeRow ⟨64, 2, 2, 5⟩ (denote cache_64)] = denote cache_123 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_123 + +theorem verified_row_124 : fork [place ⟨6, 1, 4, 5⟩ cache_6, place ⟨31, 2, 5, 4⟩ cache_31] = cache_124 := by + decide +kernel + +theorem load_entry_124 : entryAt 124 = entry_124 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_124 : CacheEquation 124 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(124 < 6)), load_entry_124] + change forkRow [placeRow ⟨6, 1, 4, 5⟩ (denote cache_6), placeRow ⟨31, 2, 5, 4⟩ (denote cache_31)] = denote cache_124 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_124 + +theorem verified_row_125 : fork [place ⟨3, 0, 4, 3⟩ cache_3, place ⟨31, 2, 4, 5⟩ cache_31] = cache_125 := by + decide +kernel + +theorem load_entry_125 : entryAt 125 = entry_125 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_125 : CacheEquation 125 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(125 < 6)), load_entry_125] + change forkRow [placeRow ⟨3, 0, 4, 3⟩ (denote cache_3), placeRow ⟨31, 2, 4, 5⟩ (denote cache_31)] = denote cache_125 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_125 + +theorem verified_row_126 : fork [place ⟨6, 3, 4, 5⟩ cache_6, place ⟨46, 1, 5, 7⟩ cache_46] = cache_126 := by + decide +kernel + +theorem load_entry_126 : entryAt 126 = entry_126 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_126 : CacheEquation 126 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(126 < 6)), load_entry_126] + change forkRow [placeRow ⟨6, 3, 4, 5⟩ (denote cache_6), placeRow ⟨46, 1, 5, 7⟩ (denote cache_46)] = denote cache_126 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_126 + +theorem verified_row_127 : fork [place ⟨7, 0, 4, 5⟩ cache_7, place ⟨44, 2, 5, 4⟩ cache_44] = cache_127 := by + decide +kernel + +theorem load_entry_127 : entryAt 127 = entry_127 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_127 : CacheEquation 127 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(127 < 6)), load_entry_127] + change forkRow [placeRow ⟨7, 0, 4, 5⟩ (denote cache_7), placeRow ⟨44, 2, 5, 4⟩ (denote cache_44)] = denote cache_127 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_127 + +theorem verified_row_128 : fork [place ⟨9, 6, 1, 5⟩ cache_9, place ⟨57, 0, 6, 5⟩ cache_57] = cache_128 := by + decide +kernel + +theorem load_entry_128 : entryAt 128 = entry_128 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_128 : CacheEquation 128 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(128 < 6)), load_entry_128] + change forkRow [placeRow ⟨9, 6, 1, 5⟩ (denote cache_9), placeRow ⟨57, 0, 6, 5⟩ (denote cache_57)] = denote cache_128 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_128 + +theorem verified_row_129 : fork [place ⟨6, 4, 2, 5⟩ cache_6, place ⟨58, 1, 3, 6⟩ cache_58] = cache_129 := by + decide +kernel + +theorem load_entry_129 : entryAt 129 = entry_129 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_129 : CacheEquation 129 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(129 < 6)), load_entry_129] + change forkRow [placeRow ⟨6, 4, 2, 5⟩ (denote cache_6), placeRow ⟨58, 1, 3, 6⟩ (denote cache_58)] = denote cache_129 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_129 + +theorem verified_row_130 : fork [place ⟨6, 1, 4, 5⟩ cache_6, place ⟨60, 0, 5, 4⟩ cache_60] = cache_130 := by + decide +kernel + +theorem load_entry_130 : entryAt 130 = entry_130 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_130 : CacheEquation 130 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(130 < 6)), load_entry_130] + change forkRow [placeRow ⟨6, 1, 4, 5⟩ (denote cache_6), placeRow ⟨60, 0, 5, 4⟩ (denote cache_60)] = denote cache_130 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_130 + +theorem verified_row_131 : fork [place ⟨45, 3, 4, 5⟩ cache_45, place ⟨7, 1, 5, 4⟩ cache_7] = cache_131 := by + decide +kernel + +theorem load_entry_131 : entryAt 131 = entry_131 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_131 : CacheEquation 131 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(131 < 6)), load_entry_131] + change forkRow [placeRow ⟨45, 3, 4, 5⟩ (denote cache_45), placeRow ⟨7, 1, 5, 4⟩ (denote cache_7)] = denote cache_131 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_131 + +theorem verified_row_132 : fork [place ⟨6, 3, 4, 5⟩ cache_6, place ⟨89, 0, 5, 6⟩ cache_89] = cache_132 := by + decide +kernel + +theorem load_entry_132 : entryAt 132 = entry_132 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_132 : CacheEquation 132 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(132 < 6)), load_entry_132] + change forkRow [placeRow ⟨6, 3, 4, 5⟩ (denote cache_6), placeRow ⟨89, 0, 5, 6⟩ (denote cache_89)] = denote cache_132 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_132 + +theorem verified_row_133 : fork [place ⟨6, 7, 3, 1⟩ cache_6, place ⟨92, 0, 5, 5⟩ cache_92] = cache_133 := by + decide +kernel + +theorem load_entry_133 : entryAt 133 = entry_133 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_133 : CacheEquation 133 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(133 < 6)), load_entry_133] + change forkRow [placeRow ⟨6, 7, 3, 1⟩ (denote cache_6), placeRow ⟨92, 0, 5, 5⟩ (denote cache_92)] = denote cache_133 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_133 + +theorem verified_row_134 : fork [place ⟨6, 7, 3, 0⟩ cache_6, place ⟨82, 0, 5, 4⟩ cache_82] = cache_134 := by + decide +kernel + +theorem load_entry_134 : entryAt 134 = entry_134 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_134 : CacheEquation 134 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(134 < 6)), load_entry_134] + change forkRow [placeRow ⟨6, 7, 3, 0⟩ (denote cache_6), placeRow ⟨82, 0, 5, 4⟩ (denote cache_82)] = denote cache_134 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_134 + +theorem verified_row_135 : fork [place ⟨7, 0, 4, 5⟩ cache_7, place ⟨75, 4, 2, 5⟩ cache_75, place ⟨44, 0, 5, 4⟩ cache_44] = cache_135 := by + decide +kernel + +theorem load_entry_135 : entryAt 135 = entry_135 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_135 : CacheEquation 135 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(135 < 6)), load_entry_135] + change forkRow [placeRow ⟨7, 0, 4, 5⟩ (denote cache_7), placeRow ⟨75, 4, 2, 5⟩ (denote cache_75), placeRow ⟨44, 0, 5, 4⟩ (denote cache_44)] = denote cache_135 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_135 + +theorem verified_row_136 : fork [place ⟨6, 3, 3, 7⟩ cache_6, place ⟨102, 2, 3, 3⟩ cache_102] = cache_136 := by + decide +kernel + +theorem load_entry_136 : entryAt 136 = entry_136 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_136 : CacheEquation 136 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(136 < 6)), load_entry_136] + change forkRow [placeRow ⟨6, 3, 3, 7⟩ (denote cache_6), placeRow ⟨102, 2, 3, 3⟩ (denote cache_102)] = denote cache_136 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_136 + +theorem verified_row_137 : fork [place ⟨4, 1, 4, 3⟩ cache_4, place ⟨96, 0, 3, 4⟩ cache_96] = cache_137 := by + decide +kernel + +theorem load_entry_137 : entryAt 137 = entry_137 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_137 : CacheEquation 137 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(137 < 6)), load_entry_137] + change forkRow [placeRow ⟨4, 1, 4, 3⟩ (denote cache_4), placeRow ⟨96, 0, 3, 4⟩ (denote cache_96)] = denote cache_137 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_137 + +theorem verified_row_138 : fork [place ⟨27, 0, 5, 4⟩ cache_27, place ⟨10, 1, 4, 7⟩ cache_10] = cache_138 := by + decide +kernel + +theorem load_entry_138 : entryAt 138 = entry_138 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_138 : CacheEquation 138 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(138 < 6)), load_entry_138] + change forkRow [placeRow ⟨27, 0, 5, 4⟩ (denote cache_27), placeRow ⟨10, 1, 4, 7⟩ (denote cache_10)] = denote cache_138 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_138 + +theorem verified_row_139 : fork [place ⟨28, 1, 4, 5⟩ cache_28, place ⟨27, 0, 5, 4⟩ cache_27] = cache_139 := by + decide +kernel + +theorem load_entry_139 : entryAt 139 = entry_139 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_139 : CacheEquation 139 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(139 < 6)), load_entry_139] + change forkRow [placeRow ⟨28, 1, 4, 5⟩ (denote cache_28), placeRow ⟨27, 0, 5, 4⟩ (denote cache_27)] = denote cache_139 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_139 + +theorem verified_row_140 : fork [place ⟨6, 7, 3, 2⟩ cache_6, place ⟨82, 0, 5, 6⟩ cache_82] = cache_140 := by + decide +kernel + +theorem load_entry_140 : entryAt 140 = entry_140 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_140 : CacheEquation 140 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(140 < 6)), load_entry_140] + change forkRow [placeRow ⟨6, 7, 3, 2⟩ (denote cache_6), placeRow ⟨82, 0, 5, 6⟩ (denote cache_82)] = denote cache_140 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_140 + +theorem verified_row_141 : fork [place ⟨7, 0, 4, 5⟩ cache_7, place ⟨78, 2, 1, 3⟩ cache_78] = cache_141 := by + decide +kernel + +theorem load_entry_141 : entryAt 141 = entry_141 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_141 : CacheEquation 141 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(141 < 6)), load_entry_141] + change forkRow [placeRow ⟨7, 0, 4, 5⟩ (denote cache_7), placeRow ⟨78, 2, 1, 3⟩ (denote cache_78)] = denote cache_141 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_141 + +theorem verified_row_142 : fork [place ⟨72, 4, 2, 3⟩ cache_72, place ⟨32, 1, 4, 3⟩ cache_32, place ⟨55, 2, 5, 4⟩ cache_55] = cache_142 := by + decide +kernel + +theorem load_entry_142 : entryAt 142 = entry_142 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_142 : CacheEquation 142 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(142 < 6)), load_entry_142] + change forkRow [placeRow ⟨72, 4, 2, 3⟩ (denote cache_72), placeRow ⟨32, 1, 4, 3⟩ (denote cache_32), placeRow ⟨55, 2, 5, 4⟩ (denote cache_55)] = denote cache_142 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_142 + +theorem verified_row_143 : fork [place ⟨6, 6, 3, 4⟩ cache_6, place ⟨108, 0, 8, 5⟩ cache_108] = cache_143 := by + decide +kernel + +theorem load_entry_143 : entryAt 143 = entry_143 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_143 : CacheEquation 143 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(143 < 6)), load_entry_143] + change forkRow [placeRow ⟨6, 6, 3, 4⟩ (denote cache_6), placeRow ⟨108, 0, 8, 5⟩ (denote cache_108)] = denote cache_143 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_143 + +theorem verified_row_144 : fork [place ⟨7, 0, 4, 5⟩ cache_7, place ⟨104, 4, 1, 5⟩ cache_104, place ⟨55, 0, 5, 4⟩ cache_55] = cache_144 := by + decide +kernel + +theorem load_entry_144 : entryAt 144 = entry_144 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_144 : CacheEquation 144 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(144 < 6)), load_entry_144] + change forkRow [placeRow ⟨7, 0, 4, 5⟩ (denote cache_7), placeRow ⟨104, 4, 1, 5⟩ (denote cache_104), placeRow ⟨55, 0, 5, 4⟩ (denote cache_55)] = denote cache_144 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_144 + +theorem verified_row_145 : fork [place ⟨0, 5, 4, 5⟩ cache_0, place ⟨91, 0, 3, 4⟩ cache_91] = cache_145 := by + decide +kernel + +theorem load_entry_145 : entryAt 145 = entry_145 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_145 : CacheEquation 145 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(145 < 6)), load_entry_145] + change forkRow [placeRow ⟨0, 5, 4, 5⟩ (denote cache_0), placeRow ⟨91, 0, 3, 4⟩ (denote cache_91)] = denote cache_145 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_145 + +theorem verified_row_146 : fork [place ⟨36, 6, 5, 4⟩ cache_36, place ⟨24, 1, 4, 5⟩ cache_24] = cache_146 := by + decide +kernel + +theorem load_entry_146 : entryAt 146 = entry_146 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_146 : CacheEquation 146 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(146 < 6)), load_entry_146] + change forkRow [placeRow ⟨36, 6, 5, 4⟩ (denote cache_36), placeRow ⟨24, 1, 4, 5⟩ (denote cache_24)] = denote cache_146 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_146 + +theorem verified_row_147 : fork [place ⟨53, 0, 1, 5⟩ cache_53, place ⟨44, 2, 5, 4⟩ cache_44] = cache_147 := by + decide +kernel + +theorem load_entry_147 : entryAt 147 = entry_147 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_147 : CacheEquation 147 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(147 < 6)), load_entry_147] + change forkRow [placeRow ⟨53, 0, 1, 5⟩ (denote cache_53), placeRow ⟨44, 2, 5, 4⟩ (denote cache_44)] = denote cache_147 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_147 + +theorem verified_row_148 : fork [place ⟨7, 1, 5, 4⟩ cache_7, place ⟨46, 1, 4, 5⟩ cache_46, place ⟨94, 0, 5, 3⟩ cache_94, place ⟨97, 1, 4, 5⟩ cache_97] = cache_148 := by + decide +kernel + +theorem load_entry_148 : entryAt 148 = entry_148 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_148 : CacheEquation 148 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(148 < 6)), load_entry_148] + change forkRow [placeRow ⟨7, 1, 5, 4⟩ (denote cache_7), placeRow ⟨46, 1, 4, 5⟩ (denote cache_46), placeRow ⟨94, 0, 5, 3⟩ (denote cache_94), placeRow ⟨97, 1, 4, 5⟩ (denote cache_97)] = denote cache_148 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_148 + +theorem verified_row_149 : fork [place ⟨16, 1, 4, 3⟩ cache_16, place ⟨24, 2, 5, 4⟩ cache_24] = cache_149 := by + decide +kernel + +theorem load_entry_149 : entryAt 149 = entry_149 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_149 : CacheEquation 149 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(149 < 6)), load_entry_149] + change forkRow [placeRow ⟨16, 1, 4, 3⟩ (denote cache_16), placeRow ⟨24, 2, 5, 4⟩ (denote cache_24)] = denote cache_149 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_149 + +theorem verified_row_150 : fork [place ⟨4, 6, 1, 3⟩ cache_4, place ⟨126, 5, 2, 5⟩ cache_126] = cache_150 := by + decide +kernel + +theorem load_entry_150 : entryAt 150 = entry_150 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_150 : CacheEquation 150 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(150 < 6)), load_entry_150] + change forkRow [placeRow ⟨4, 6, 1, 3⟩ (denote cache_4), placeRow ⟨126, 5, 2, 5⟩ (denote cache_126)] = denote cache_150 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_150 + +theorem verified_row_151 : fork [place ⟨2, 1, 4, 3⟩ cache_2, place ⟨101, 2, 6, 3⟩ cache_101] = cache_151 := by + decide +kernel + +theorem load_entry_151 : entryAt 151 = entry_151 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_151 : CacheEquation 151 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(151 < 6)), load_entry_151] + change forkRow [placeRow ⟨2, 1, 4, 3⟩ (denote cache_2), placeRow ⟨101, 2, 6, 3⟩ (denote cache_101)] = denote cache_151 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_151 + +theorem verified_row_152 : fork [place ⟨6, 3, 4, 5⟩ cache_6, place ⟨73, 1, 7, 4⟩ cache_73] = cache_152 := by + decide +kernel + +theorem load_entry_152 : entryAt 152 = entry_152 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_152 : CacheEquation 152 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(152 < 6)), load_entry_152] + change forkRow [placeRow ⟨6, 3, 4, 5⟩ (denote cache_6), placeRow ⟨73, 1, 7, 4⟩ (denote cache_73)] = denote cache_152 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_152 + +theorem verified_row_153 : fork [place ⟨59, 4, 0, 4⟩ cache_59, place ⟨27, 0, 5, 4⟩ cache_27] = cache_153 := by + decide +kernel + +theorem load_entry_153 : entryAt 153 = entry_153 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_153 : CacheEquation 153 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(153 < 6)), load_entry_153] + change forkRow [placeRow ⟨59, 4, 0, 4⟩ (denote cache_59), placeRow ⟨27, 0, 5, 4⟩ (denote cache_27)] = denote cache_153 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_153 + +theorem verified_row_154 : fork [place ⟨7, 6, 4, 3⟩ cache_7, place ⟨104, 0, 7, 5⟩ cache_104] = cache_154 := by + decide +kernel + +theorem load_entry_154 : entryAt 154 = entry_154 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_154 : CacheEquation 154 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(154 < 6)), load_entry_154] + change forkRow [placeRow ⟨7, 6, 4, 3⟩ (denote cache_7), placeRow ⟨104, 0, 7, 5⟩ (denote cache_104)] = denote cache_154 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_154 + +theorem verified_row_155 : fork [place ⟨7, 1, 5, 4⟩ cache_7, place ⟨55, 3, 4, 5⟩ cache_55] = cache_155 := by + decide +kernel + +theorem load_entry_155 : entryAt 155 = entry_155 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_155 : CacheEquation 155 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(155 < 6)), load_entry_155] + change forkRow [placeRow ⟨7, 1, 5, 4⟩ (denote cache_7), placeRow ⟨55, 3, 4, 5⟩ (denote cache_55)] = denote cache_155 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_155 + +theorem verified_row_156 : fork [place ⟨11, 0, 2, 4⟩ cache_11, place ⟨98, 2, 2, 4⟩ cache_98, place ⟨33, 0, 2, 3⟩ cache_33] = cache_156 := by + decide +kernel + +theorem load_entry_156 : entryAt 156 = entry_156 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_156 : CacheEquation 156 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(156 < 6)), load_entry_156] + change forkRow [placeRow ⟨11, 0, 2, 4⟩ (denote cache_11), placeRow ⟨98, 2, 2, 4⟩ (denote cache_98), placeRow ⟨33, 0, 2, 3⟩ (denote cache_33)] = denote cache_156 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_156 + +theorem verified_row_157 : fork [place ⟨6, 3, 4, 5⟩ cache_6, place ⟨57, 1, 5, 6⟩ cache_57] = cache_157 := by + decide +kernel + +theorem load_entry_157 : entryAt 157 = entry_157 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_157 : CacheEquation 157 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(157 < 6)), load_entry_157] + change forkRow [placeRow ⟨6, 3, 4, 5⟩ (denote cache_6), placeRow ⟨57, 1, 5, 6⟩ (denote cache_57)] = denote cache_157 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_157 + +theorem verified_row_158 : fork [place ⟨66, 0, 3, 4⟩ cache_66, place ⟨45, 1, 4, 5⟩ cache_45, place ⟨46, 3, 4, 5⟩ cache_46] = cache_158 := by + decide +kernel + +theorem load_entry_158 : entryAt 158 = entry_158 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_158 : CacheEquation 158 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(158 < 6)), load_entry_158] + change forkRow [placeRow ⟨66, 0, 3, 4⟩ (denote cache_66), placeRow ⟨45, 1, 4, 5⟩ (denote cache_45), placeRow ⟨46, 3, 4, 5⟩ (denote cache_46)] = denote cache_158 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_158 + +theorem verified_row_159 : fork [place ⟨45, 3, 4, 5⟩ cache_45, place ⟨65, 1, 4, 5⟩ cache_65, place ⟨7, 3, 3, 4⟩ cache_7] = cache_159 := by + decide +kernel + +theorem load_entry_159 : entryAt 159 = entry_159 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_159 : CacheEquation 159 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(159 < 6)), load_entry_159] + change forkRow [placeRow ⟨45, 3, 4, 5⟩ (denote cache_45), placeRow ⟨65, 1, 4, 5⟩ (denote cache_65), placeRow ⟨7, 3, 3, 4⟩ (denote cache_7)] = denote cache_159 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_159 + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Equations04.lean b/lean/OAI/Combinatorics/SnakyCertificate/Equations04.lean new file mode 100644 index 0000000000000000000000000000000000000000..4f577137f5003f1cca41daf5065e355529b45b5e --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Equations04.lean @@ -0,0 +1,530 @@ +import OAI.Combinatorics.SnakyCertificate.Cache +import OAI.Combinatorics.SnakyCertificate.TableList + +namespace OAI + +namespace SnakyCertificate.Check + +theorem verified_row_160 : fork [place ⟨63, 1, 8, 3⟩ cache_63, place ⟨32, 3, 4, 3⟩ cache_32] = cache_160 := by + decide +kernel + +theorem load_entry_160 : entryAt 160 = entry_160 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_160 : CacheEquation 160 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(160 < 6)), load_entry_160] + change forkRow [placeRow ⟨63, 1, 8, 3⟩ (denote cache_63), placeRow ⟨32, 3, 4, 3⟩ (denote cache_32)] = denote cache_160 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_160 + +theorem verified_row_161 : fork [place ⟨15, 1, 4, 5⟩ cache_15, place ⟨86, 0, 5, 4⟩ cache_86] = cache_161 := by + decide +kernel + +theorem load_entry_161 : entryAt 161 = entry_161 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_161 : CacheEquation 161 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(161 < 6)), load_entry_161] + change forkRow [placeRow ⟨15, 1, 4, 5⟩ (denote cache_15), placeRow ⟨86, 0, 5, 4⟩ (denote cache_86)] = denote cache_161 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_161 + +theorem verified_row_162 : fork [place ⟨7, 3, 3, 4⟩ cache_7, place ⟨127, 1, 4, 5⟩ cache_127, place ⟨63, 0, 3, 5⟩ cache_63, place ⟨157, 0, 3, 3⟩ cache_157] = cache_162 := by + decide +kernel + +theorem load_entry_162 : entryAt 162 = entry_162 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_162 : CacheEquation 162 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(162 < 6)), load_entry_162] + change forkRow [placeRow ⟨7, 3, 3, 4⟩ (denote cache_7), placeRow ⟨127, 1, 4, 5⟩ (denote cache_127), placeRow ⟨63, 0, 3, 5⟩ (denote cache_63), placeRow ⟨157, 0, 3, 3⟩ (denote cache_157)] = denote cache_162 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_162 + +theorem verified_row_163 : fork [place ⟨44, 2, 5, 4⟩ cache_44, place ⟨49, 1, 5, 4⟩ cache_49, place ⟨56, 4, 0, 4⟩ cache_56] = cache_163 := by + decide +kernel + +theorem load_entry_163 : entryAt 163 = entry_163 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_163 : CacheEquation 163 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(163 < 6)), load_entry_163] + change forkRow [placeRow ⟨44, 2, 5, 4⟩ (denote cache_44), placeRow ⟨49, 1, 5, 4⟩ (denote cache_49), placeRow ⟨56, 4, 0, 4⟩ (denote cache_56)] = denote cache_163 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_163 + +theorem verified_row_164 : fork [place ⟨6, 1, 4, 5⟩ cache_6, place ⟨110, 0, 5, 4⟩ cache_110] = cache_164 := by + decide +kernel + +theorem load_entry_164 : entryAt 164 = entry_164 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_164 : CacheEquation 164 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(164 < 6)), load_entry_164] + change forkRow [placeRow ⟨6, 1, 4, 5⟩ (denote cache_6), placeRow ⟨110, 0, 5, 4⟩ (denote cache_110)] = denote cache_164 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_164 + +theorem verified_row_165 : fork [place ⟨0, 7, 5, 8⟩ cache_0, place ⟨107, 0, 7, 5⟩ cache_107] = cache_165 := by + decide +kernel + +theorem load_entry_165 : entryAt 165 = entry_165 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_165 : CacheEquation 165 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(165 < 6)), load_entry_165] + change forkRow [placeRow ⟨0, 7, 5, 8⟩ (denote cache_0), placeRow ⟨107, 0, 7, 5⟩ (denote cache_107)] = denote cache_165 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_165 + +theorem verified_row_166 : fork [place ⟨2, 7, 4, 5⟩ cache_2, place ⟨107, 0, 6, 4⟩ cache_107] = cache_166 := by + decide +kernel + +theorem load_entry_166 : entryAt 166 = entry_166 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_166 : CacheEquation 166 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(166 < 6)), load_entry_166] + change forkRow [placeRow ⟨2, 7, 4, 5⟩ (denote cache_2), placeRow ⟨107, 0, 6, 4⟩ (denote cache_107)] = denote cache_166 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_166 + +theorem verified_row_167 : fork [place ⟨57, 0, 5, 4⟩ cache_57, place ⟨57, 4, 0, 4⟩ cache_57] = cache_167 := by + decide +kernel + +theorem load_entry_167 : entryAt 167 = entry_167 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_167 : CacheEquation 167 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(167 < 6)), load_entry_167] + change forkRow [placeRow ⟨57, 0, 5, 4⟩ (denote cache_57), placeRow ⟨57, 4, 0, 4⟩ (denote cache_57)] = denote cache_167 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_167 + +theorem verified_row_168 : fork [place ⟨6, 1, 5, 5⟩ cache_6, place ⟨152, 0, 3, 4⟩ cache_152] = cache_168 := by + decide +kernel + +theorem load_entry_168 : entryAt 168 = entry_168 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_168 : CacheEquation 168 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(168 < 6)), load_entry_168] + change forkRow [placeRow ⟨6, 1, 5, 5⟩ (denote cache_6), placeRow ⟨152, 0, 3, 4⟩ (denote cache_152)] = denote cache_168 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_168 + +theorem verified_row_169 : fork [place ⟨28, 3, 4, 5⟩ cache_28, place ⟨63, 1, 8, 3⟩ cache_63] = cache_169 := by + decide +kernel + +theorem load_entry_169 : entryAt 169 = entry_169 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_169 : CacheEquation 169 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(169 < 6)), load_entry_169] + change forkRow [placeRow ⟨28, 3, 4, 5⟩ (denote cache_28), placeRow ⟨63, 1, 8, 3⟩ (denote cache_63)] = denote cache_169 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_169 + +theorem verified_row_170 : fork [place ⟨4, 6, 1, 3⟩ cache_4, place ⟨127, 2, 5, 4⟩ cache_127] = cache_170 := by + decide +kernel + +theorem load_entry_170 : entryAt 170 = entry_170 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_170 : CacheEquation 170 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(170 < 6)), load_entry_170] + change forkRow [placeRow ⟨4, 6, 1, 3⟩ (denote cache_4), placeRow ⟨127, 2, 5, 4⟩ (denote cache_127)] = denote cache_170 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_170 + +theorem verified_row_171 : fork [place ⟨6, 0, 5, 4⟩ cache_6, place ⟨91, 0, 0, 5⟩ cache_91] = cache_171 := by + decide +kernel + +theorem load_entry_171 : entryAt 171 = entry_171 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_171 : CacheEquation 171 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(171 < 6)), load_entry_171] + change forkRow [placeRow ⟨6, 0, 5, 4⟩ (denote cache_6), placeRow ⟨91, 0, 0, 5⟩ (denote cache_91)] = denote cache_171 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_171 + +theorem verified_row_172 : fork [place ⟨63, 1, 5, 3⟩ cache_63, place ⟨55, 6, 0, 4⟩ cache_55, place ⟨64, 0, 1, 3⟩ cache_64] = cache_172 := by + decide +kernel + +theorem load_entry_172 : entryAt 172 = entry_172 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_172 : CacheEquation 172 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(172 < 6)), load_entry_172] + change forkRow [placeRow ⟨63, 1, 5, 3⟩ (denote cache_63), placeRow ⟨55, 6, 0, 4⟩ (denote cache_55), placeRow ⟨64, 0, 1, 3⟩ (denote cache_64)] = denote cache_172 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_172 + +theorem verified_row_173 : fork [place ⟨63, 1, 5, 3⟩ cache_63, place ⟨64, 6, 4, 5⟩ cache_64, place ⟨55, 6, 0, 4⟩ cache_55] = cache_173 := by + decide +kernel + +theorem load_entry_173 : entryAt 173 = entry_173 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_173 : CacheEquation 173 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(173 < 6)), load_entry_173] + change forkRow [placeRow ⟨63, 1, 5, 3⟩ (denote cache_63), placeRow ⟨64, 6, 4, 5⟩ (denote cache_64), placeRow ⟨55, 6, 0, 4⟩ (denote cache_55)] = denote cache_173 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_173 + +theorem verified_row_174 : fork [place ⟨58, 3, 4, 5⟩ cache_58, place ⟨57, 1, 4, 5⟩ cache_57, place ⟨84, 0, 3, 4⟩ cache_84] = cache_174 := by + decide +kernel + +theorem load_entry_174 : entryAt 174 = entry_174 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_174 : CacheEquation 174 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(174 < 6)), load_entry_174] + change forkRow [placeRow ⟨58, 3, 4, 5⟩ (denote cache_58), placeRow ⟨57, 1, 4, 5⟩ (denote cache_57), placeRow ⟨84, 0, 3, 4⟩ (denote cache_84)] = denote cache_174 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_174 + +theorem verified_row_175 : fork [place ⟨141, 0, 5, 4⟩ cache_141, place ⟨7, 2, 4, 3⟩ cache_7, place ⟨63, 1, 5, 3⟩ cache_63] = cache_175 := by + decide +kernel + +theorem load_entry_175 : entryAt 175 = entry_175 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_175 : CacheEquation 175 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(175 < 6)), load_entry_175] + change forkRow [placeRow ⟨141, 0, 5, 4⟩ (denote cache_141), placeRow ⟨7, 2, 4, 3⟩ (denote cache_7), placeRow ⟨63, 1, 5, 3⟩ (denote cache_63)] = denote cache_175 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_175 + +theorem verified_row_176 : fork [place ⟨63, 1, 5, 3⟩ cache_63, place ⟨64, 6, 4, 5⟩ cache_64, place ⟨55, 2, 5, 4⟩ cache_55] = cache_176 := by + decide +kernel + +theorem load_entry_176 : entryAt 176 = entry_176 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_176 : CacheEquation 176 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(176 < 6)), load_entry_176] + change forkRow [placeRow ⟨63, 1, 5, 3⟩ (denote cache_63), placeRow ⟨64, 6, 4, 5⟩ (denote cache_64), placeRow ⟨55, 2, 5, 4⟩ (denote cache_55)] = denote cache_176 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_176 + +theorem verified_row_177 : fork [place ⟨6, 1, 4, 5⟩ cache_6, place ⟨136, 3, 5, 4⟩ cache_136] = cache_177 := by + decide +kernel + +theorem load_entry_177 : entryAt 177 = entry_177 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_177 : CacheEquation 177 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(177 < 6)), load_entry_177] + change forkRow [placeRow ⟨6, 1, 4, 5⟩ (denote cache_6), placeRow ⟨136, 3, 5, 4⟩ (denote cache_136)] = denote cache_177 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_177 + +theorem verified_row_178 : fork [place ⟨37, 0, 3, 4⟩ cache_37, place ⟨68, 1, 4, 5⟩ cache_68, place ⟨46, 3, 4, 5⟩ cache_46] = cache_178 := by + decide +kernel + +theorem load_entry_178 : entryAt 178 = entry_178 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_178 : CacheEquation 178 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(178 < 6)), load_entry_178] + change forkRow [placeRow ⟨37, 0, 3, 4⟩ (denote cache_37), placeRow ⟨68, 1, 4, 5⟩ (denote cache_68), placeRow ⟨46, 3, 4, 5⟩ (denote cache_46)] = denote cache_178 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_178 + +theorem verified_row_179 : fork [place ⟨6, 6, 0, 3⟩ cache_6, place ⟨148, 5, 5, 4⟩ cache_148] = cache_179 := by + decide +kernel + +theorem load_entry_179 : entryAt 179 = entry_179 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_179 : CacheEquation 179 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(179 < 6)), load_entry_179] + change forkRow [placeRow ⟨6, 6, 0, 3⟩ (denote cache_6), placeRow ⟨148, 5, 5, 4⟩ (denote cache_148)] = denote cache_179 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_179 + +theorem verified_row_180 : fork [place ⟨7, 3, 3, 4⟩ cache_7, place ⟨63, 0, 3, 5⟩ cache_63, place ⟨155, 0, 4, 5⟩ cache_155, place ⟨132, 0, 3, 3⟩ cache_132] = cache_180 := by + decide +kernel + +theorem load_entry_180 : entryAt 180 = entry_180 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_180 : CacheEquation 180 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(180 < 6)), load_entry_180] + change forkRow [placeRow ⟨7, 3, 3, 4⟩ (denote cache_7), placeRow ⟨63, 0, 3, 5⟩ (denote cache_63), placeRow ⟨155, 0, 4, 5⟩ (denote cache_155), placeRow ⟨132, 0, 3, 3⟩ (denote cache_132)] = denote cache_180 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_180 + +theorem verified_row_181 : fork [place ⟨24, 3, 4, 5⟩ cache_24, place ⟨87, 2, 6, 4⟩ cache_87, place ⟨90, 0, 7, 5⟩ cache_90] = cache_181 := by + decide +kernel + +theorem load_entry_181 : entryAt 181 = entry_181 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_181 : CacheEquation 181 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(181 < 6)), load_entry_181] + change forkRow [placeRow ⟨24, 3, 4, 5⟩ (denote cache_24), placeRow ⟨87, 2, 6, 4⟩ (denote cache_87), placeRow ⟨90, 0, 7, 5⟩ (denote cache_90)] = denote cache_181 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_181 + +theorem verified_row_182 : fork [place ⟨12, 2, 7, 3⟩ cache_12, place ⟨139, 0, 7, 4⟩ cache_139] = cache_182 := by + decide +kernel + +theorem load_entry_182 : entryAt 182 = entry_182 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_182 : CacheEquation 182 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(182 < 6)), load_entry_182] + change forkRow [placeRow ⟨12, 2, 7, 3⟩ (denote cache_12), placeRow ⟨139, 0, 7, 4⟩ (denote cache_139)] = denote cache_182 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_182 + +theorem verified_row_183 : fork [place ⟨64, 2, 1, 5⟩ cache_64, place ⟨63, 3, 0, 3⟩ cache_63, place ⟨55, 2, 5, 4⟩ cache_55] = cache_183 := by + decide +kernel + +theorem load_entry_183 : entryAt 183 = entry_183 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_183 : CacheEquation 183 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(183 < 6)), load_entry_183] + change forkRow [placeRow ⟨64, 2, 1, 5⟩ (denote cache_64), placeRow ⟨63, 3, 0, 3⟩ (denote cache_63), placeRow ⟨55, 2, 5, 4⟩ (denote cache_55)] = denote cache_183 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_183 + +theorem verified_row_184 : fork [place ⟨34, 3, 4, 2⟩ cache_34, place ⟨35, 2, 5, 4⟩ cache_35] = cache_184 := by + decide +kernel + +theorem load_entry_184 : entryAt 184 = entry_184 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_184 : CacheEquation 184 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(184 < 6)), load_entry_184] + change forkRow [placeRow ⟨34, 3, 4, 2⟩ (denote cache_34), placeRow ⟨35, 2, 5, 4⟩ (denote cache_35)] = denote cache_184 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_184 + +theorem verified_row_185 : fork [place ⟨44, 3, 4, 5⟩ cache_44, place ⟨49, 0, 4, 5⟩ cache_49, place ⟨84, 0, 3, 4⟩ cache_84] = cache_185 := by + decide +kernel + +theorem load_entry_185 : entryAt 185 = entry_185 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_185 : CacheEquation 185 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(185 < 6)), load_entry_185] + change forkRow [placeRow ⟨44, 3, 4, 5⟩ (denote cache_44), placeRow ⟨49, 0, 4, 5⟩ (denote cache_49), placeRow ⟨84, 0, 3, 4⟩ (denote cache_84)] = denote cache_185 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_185 + +theorem verified_row_186 : fork [place ⟨7, 6, 0, 3⟩ cache_7, place ⟨141, 2, 5, 4⟩ cache_141] = cache_186 := by + decide +kernel + +theorem load_entry_186 : entryAt 186 = entry_186 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_186 : CacheEquation 186 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(186 < 6)), load_entry_186] + change forkRow [placeRow ⟨7, 6, 0, 3⟩ (denote cache_7), placeRow ⟨141, 2, 5, 4⟩ (denote cache_141)] = denote cache_186 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_186 + +theorem verified_row_187 : fork [place ⟨6, 4, 3, 4⟩ cache_6, place ⟨108, 3, 4, 5⟩ cache_108] = cache_187 := by + decide +kernel + +theorem load_entry_187 : entryAt 187 = entry_187 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_187 : CacheEquation 187 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(187 < 6)), load_entry_187] + change forkRow [placeRow ⟨6, 4, 3, 4⟩ (denote cache_6), placeRow ⟨108, 3, 4, 5⟩ (denote cache_108)] = denote cache_187 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_187 + +theorem verified_row_188 : fork [place ⟨6, 3, 4, 5⟩ cache_6, place ⟨112, 5, 7, 4⟩ cache_112] = cache_188 := by + decide +kernel + +theorem load_entry_188 : entryAt 188 = entry_188 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_188 : CacheEquation 188 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(188 < 6)), load_entry_188] + change forkRow [placeRow ⟨6, 3, 4, 5⟩ (denote cache_6), placeRow ⟨112, 5, 7, 4⟩ (denote cache_112)] = denote cache_188 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_188 + +theorem verified_row_189 : fork [place ⟨12, 0, 5, 4⟩ cache_12, place ⟨86, 4, 1, 4⟩ cache_86] = cache_189 := by + decide +kernel + +theorem load_entry_189 : entryAt 189 = entry_189 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_189 : CacheEquation 189 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(189 < 6)), load_entry_189] + change forkRow [placeRow ⟨12, 0, 5, 4⟩ (denote cache_12), placeRow ⟨86, 4, 1, 4⟩ (denote cache_86)] = denote cache_189 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_189 + +theorem verified_row_190 : fork [place ⟨46, 0, 5, 4⟩ cache_46, place ⟨85, 2, 3, 3⟩ cache_85, place ⟨111, 3, 4, 3⟩ cache_111] = cache_190 := by + decide +kernel + +theorem load_entry_190 : entryAt 190 = entry_190 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_190 : CacheEquation 190 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(190 < 6)), load_entry_190] + change forkRow [placeRow ⟨46, 0, 5, 4⟩ (denote cache_46), placeRow ⟨85, 2, 3, 3⟩ (denote cache_85), placeRow ⟨111, 3, 4, 3⟩ (denote cache_111)] = denote cache_190 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_190 + +theorem verified_row_191 : fork [place ⟨6, 4, 3, 4⟩ cache_6, place ⟨145, 0, 4, 5⟩ cache_145] = cache_191 := by + decide +kernel + +theorem load_entry_191 : entryAt 191 = entry_191 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_191 : CacheEquation 191 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(191 < 6)), load_entry_191] + change forkRow [placeRow ⟨6, 4, 3, 4⟩ (denote cache_6), placeRow ⟨145, 0, 4, 5⟩ (denote cache_145)] = denote cache_191 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_191 + +theorem verified_row_192 : fork [place ⟨64, 1, 3, 1⟩ cache_64, place ⟨103, 0, 3, 4⟩ cache_103, place ⟨55, 3, 4, 5⟩ cache_55] = cache_192 := by + decide +kernel + +theorem load_entry_192 : entryAt 192 = entry_192 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_192 : CacheEquation 192 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(192 < 6)), load_entry_192] + change forkRow [placeRow ⟨64, 1, 3, 1⟩ (denote cache_64), placeRow ⟨103, 0, 3, 4⟩ (denote cache_103), placeRow ⟨55, 3, 4, 5⟩ (denote cache_55)] = denote cache_192 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_192 + +theorem verified_row_193 : fork [place ⟨6, 6, 2, 3⟩ cache_6, place ⟨162, 1, 7, 4⟩ cache_162] = cache_193 := by + decide +kernel + +theorem load_entry_193 : entryAt 193 = entry_193 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_193 : CacheEquation 193 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(193 < 6)), load_entry_193] + change forkRow [placeRow ⟨6, 6, 2, 3⟩ (denote cache_6), placeRow ⟨162, 1, 7, 4⟩ (denote cache_162)] = denote cache_193 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_193 + +theorem verified_row_194 : fork [place ⟨0, 0, 0, 3⟩ cache_0, place ⟨146, 4, 2, 5⟩ cache_146] = cache_194 := by + decide +kernel + +theorem load_entry_194 : entryAt 194 = entry_194 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_194 : CacheEquation 194 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(194 < 6)), load_entry_194] + change forkRow [placeRow ⟨0, 0, 0, 3⟩ (denote cache_0), placeRow ⟨146, 4, 2, 5⟩ (denote cache_146)] = denote cache_194 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_194 + +theorem verified_row_195 : fork [place ⟨6, 6, 0, 3⟩ cache_6, place ⟨162, 1, 5, 4⟩ cache_162] = cache_195 := by + decide +kernel + +theorem load_entry_195 : entryAt 195 = entry_195 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_195 : CacheEquation 195 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(195 < 6)), load_entry_195] + change forkRow [placeRow ⟨6, 6, 0, 3⟩ (denote cache_6), placeRow ⟨162, 1, 5, 4⟩ (denote cache_162)] = denote cache_195 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_195 + +theorem verified_row_196 : fork [place ⟨6, 3, 4, 5⟩ cache_6, place ⟨187, 5, 6, 4⟩ cache_187] = cache_196 := by + decide +kernel + +theorem load_entry_196 : entryAt 196 = entry_196 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_196 : CacheEquation 196 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(196 < 6)), load_entry_196] + change forkRow [placeRow ⟨6, 3, 4, 5⟩ (denote cache_6), placeRow ⟨187, 5, 6, 4⟩ (denote cache_187)] = denote cache_196 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_196 + +theorem verified_row_197 : fork [place ⟨63, 3, 0, 3⟩ cache_63, place ⟨63, 1, 5, 3⟩ cache_63] = cache_197 := by + decide +kernel + +theorem load_entry_197 : entryAt 197 = entry_197 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_197 : CacheEquation 197 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(197 < 6)), load_entry_197] + change forkRow [placeRow ⟨63, 3, 0, 3⟩ (denote cache_63), placeRow ⟨63, 1, 5, 3⟩ (denote cache_63)] = denote cache_197 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_197 + +theorem verified_row_198 : fork [place ⟨7, 4, 0, 5⟩ cache_7, place ⟨131, 1, 5, 4⟩ cache_131] = cache_198 := by + decide +kernel + +theorem load_entry_198 : entryAt 198 = entry_198 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_198 : CacheEquation 198 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(198 < 6)), load_entry_198] + change forkRow [placeRow ⟨7, 4, 0, 5⟩ (denote cache_7), placeRow ⟨131, 1, 5, 4⟩ (denote cache_131)] = denote cache_198 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_198 + +theorem verified_row_199 : fork [place ⟨55, 1, 4, 5⟩ cache_55, place ⟨64, 3, 5, 1⟩ cache_64, place ⟨84, 0, 3, 4⟩ cache_84] = cache_199 := by + decide +kernel + +theorem load_entry_199 : entryAt 199 = entry_199 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_199 : CacheEquation 199 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(199 < 6)), load_entry_199] + change forkRow [placeRow ⟨55, 1, 4, 5⟩ (denote cache_55), placeRow ⟨64, 3, 5, 1⟩ (denote cache_64), placeRow ⟨84, 0, 3, 4⟩ (denote cache_84)] = denote cache_199 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_199 + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Equations05.lean b/lean/OAI/Combinatorics/SnakyCertificate/Equations05.lean new file mode 100644 index 0000000000000000000000000000000000000000..5701ea462f32f41f93e5e62db533a12843ca93bc --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Equations05.lean @@ -0,0 +1,530 @@ +import OAI.Combinatorics.SnakyCertificate.Cache +import OAI.Combinatorics.SnakyCertificate.TableList + +namespace OAI + +namespace SnakyCertificate.Check + +theorem verified_row_200 : fork [place ⟨103, 0, 3, 4⟩ cache_103, place ⟨64, 3, 5, 1⟩ cache_64, place ⟨55, 1, 4, 5⟩ cache_55] = cache_200 := by + decide +kernel + +theorem load_entry_200 : entryAt 200 = entry_200 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_200 : CacheEquation 200 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(200 < 6)), load_entry_200] + change forkRow [placeRow ⟨103, 0, 3, 4⟩ (denote cache_103), placeRow ⟨64, 3, 5, 1⟩ (denote cache_64), placeRow ⟨55, 1, 4, 5⟩ (denote cache_55)] = denote cache_200 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_200 + +theorem verified_row_201 : fork [place ⟨45, 3, 5, 7⟩ cache_45, place ⟨82, 0, 6, 5⟩ cache_82] = cache_201 := by + decide +kernel + +theorem load_entry_201 : entryAt 201 = entry_201 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_201 : CacheEquation 201 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(201 < 6)), load_entry_201] + change forkRow [placeRow ⟨45, 3, 5, 7⟩ (denote cache_45), placeRow ⟨82, 0, 6, 5⟩ (denote cache_82)] = denote cache_201 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_201 + +theorem verified_row_202 : fork [place ⟨150, 0, 5, 4⟩ cache_150, place ⟨7, 0, 4, 5⟩ cache_7, place ⟨108, 0, 5, 4⟩ cache_108] = cache_202 := by + decide +kernel + +theorem load_entry_202 : entryAt 202 = entry_202 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_202 : CacheEquation 202 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(202 < 6)), load_entry_202] + change forkRow [placeRow ⟨150, 0, 5, 4⟩ (denote cache_150), placeRow ⟨7, 0, 4, 5⟩ (denote cache_7), placeRow ⟨108, 0, 5, 4⟩ (denote cache_108)] = denote cache_202 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_202 + +theorem verified_row_203 : fork [place ⟨18, 6, 1, 3⟩ cache_18, place ⟨107, 0, 5, 4⟩ cache_107, place ⟨163, 0, 5, 4⟩ cache_163] = cache_203 := by + decide +kernel + +theorem load_entry_203 : entryAt 203 = entry_203 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_203 : CacheEquation 203 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(203 < 6)), load_entry_203] + change forkRow [placeRow ⟨18, 6, 1, 3⟩ (denote cache_18), placeRow ⟨107, 0, 5, 4⟩ (denote cache_107), placeRow ⟨163, 0, 5, 4⟩ (denote cache_163)] = denote cache_203 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_203 + +theorem verified_row_204 : fork [place ⟨2, 5, 4, 2⟩ cache_2, place ⟨166, 2, 5, 3⟩ cache_166] = cache_204 := by + decide +kernel + +theorem load_entry_204 : entryAt 204 = entry_204 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_204 : CacheEquation 204 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(204 < 6)), load_entry_204] + change forkRow [placeRow ⟨2, 5, 4, 2⟩ (denote cache_2), placeRow ⟨166, 2, 5, 3⟩ (denote cache_166)] = denote cache_204 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_204 + +theorem verified_row_205 : fork [place ⟨4, 1, 4, 3⟩ cache_4, place ⟨168, 0, 3, 4⟩ cache_168] = cache_205 := by + decide +kernel + +theorem load_entry_205 : entryAt 205 = entry_205 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_205 : CacheEquation 205 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(205 < 6)), load_entry_205] + change forkRow [placeRow ⟨4, 1, 4, 3⟩ (denote cache_4), placeRow ⟨168, 0, 3, 4⟩ (denote cache_168)] = denote cache_205 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_205 + +theorem verified_row_206 : fork [place ⟨28, 3, 4, 5⟩ cache_28, place ⟨135, 2, 8, 4⟩ cache_135] = cache_206 := by + decide +kernel + +theorem load_entry_206 : entryAt 206 = entry_206 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_206 : CacheEquation 206 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(206 < 6)), load_entry_206] + change forkRow [placeRow ⟨28, 3, 4, 5⟩ (denote cache_28), placeRow ⟨135, 2, 8, 4⟩ (denote cache_135)] = denote cache_206 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_206 + +theorem verified_row_207 : fork [place ⟨28, 3, 4, 5⟩ cache_28, place ⟨127, 0, 8, 4⟩ cache_127] = cache_207 := by + decide +kernel + +theorem load_entry_207 : entryAt 207 = entry_207 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_207 : CacheEquation 207 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(207 < 6)), load_entry_207] + change forkRow [placeRow ⟨28, 3, 4, 5⟩ (denote cache_28), placeRow ⟨127, 0, 8, 4⟩ (denote cache_127)] = denote cache_207 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_207 + +theorem verified_row_208 : fork [place ⟨7, 4, 0, 5⟩ cache_7, place ⟨127, 0, 5, 4⟩ cache_127] = cache_208 := by + decide +kernel + +theorem load_entry_208 : entryAt 208 = entry_208 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_208 : CacheEquation 208 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(208 < 6)), load_entry_208] + change forkRow [placeRow ⟨7, 4, 0, 5⟩ (denote cache_7), placeRow ⟨127, 0, 5, 4⟩ (denote cache_127)] = denote cache_208 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_208 + +theorem verified_row_209 : fork [place ⟨25, 0, 5, 4⟩ cache_25, place ⟨81, 5, 5, 7⟩ cache_81] = cache_209 := by + decide +kernel + +theorem load_entry_209 : entryAt 209 = entry_209 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_209 : CacheEquation 209 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(209 < 6)), load_entry_209] + change forkRow [placeRow ⟨25, 0, 5, 4⟩ (denote cache_25), placeRow ⟨81, 5, 5, 7⟩ (denote cache_81)] = denote cache_209 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_209 + +theorem verified_row_210 : fork [place ⟨58, 2, 5, 4⟩ cache_58, place ⟨57, 0, 5, 4⟩ cache_57, place ⟨117, 1, 4, 5⟩ cache_117] = cache_210 := by + decide +kernel + +theorem load_entry_210 : entryAt 210 = entry_210 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_210 : CacheEquation 210 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(210 < 6)), load_entry_210] + change forkRow [placeRow ⟨58, 2, 5, 4⟩ (denote cache_58), placeRow ⟨57, 0, 5, 4⟩ (denote cache_57), placeRow ⟨117, 1, 4, 5⟩ (denote cache_117)] = denote cache_210 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_210 + +theorem verified_row_211 : fork [place ⟨49, 5, 5, 4⟩ cache_49, place ⟨6, 6, 0, 3⟩ cache_6] = cache_211 := by + decide +kernel + +theorem load_entry_211 : entryAt 211 = entry_211 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_211 : CacheEquation 211 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(211 < 6)), load_entry_211] + change forkRow [placeRow ⟨49, 5, 5, 4⟩ (denote cache_49), placeRow ⟨6, 6, 0, 3⟩ (denote cache_6)] = denote cache_211 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_211 + +theorem verified_row_212 : fork [place ⟨6, 0, 5, 4⟩ cache_6, place ⟨188, 0, 0, 5⟩ cache_188] = cache_212 := by + decide +kernel + +theorem load_entry_212 : entryAt 212 = entry_212 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_212 : CacheEquation 212 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(212 < 6)), load_entry_212] + change forkRow [placeRow ⟨6, 0, 5, 4⟩ (denote cache_6), placeRow ⟨188, 0, 0, 5⟩ (denote cache_188)] = denote cache_212 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_212 + +theorem verified_row_213 : fork [place ⟨6, 0, 7, 5⟩ cache_6, place ⟨191, 0, 3, 5⟩ cache_191] = cache_213 := by + decide +kernel + +theorem load_entry_213 : entryAt 213 = entry_213 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_213 : CacheEquation 213 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(213 < 6)), load_entry_213] + change forkRow [placeRow ⟨6, 0, 7, 5⟩ (denote cache_6), placeRow ⟨191, 0, 3, 5⟩ (denote cache_191)] = denote cache_213 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_213 + +theorem verified_row_214 : fork [place ⟨7, 3, 3, 4⟩ cache_7, place ⟨108, 3, 4, 5⟩ cache_108, place ⟨95, 0, 5, 2⟩ cache_95] = cache_214 := by + decide +kernel + +theorem load_entry_214 : entryAt 214 = entry_214 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_214 : CacheEquation 214 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(214 < 6)), load_entry_214] + change forkRow [placeRow ⟨7, 3, 3, 4⟩ (denote cache_7), placeRow ⟨108, 3, 4, 5⟩ (denote cache_108), placeRow ⟨95, 0, 5, 2⟩ (denote cache_95)] = denote cache_214 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_214 + +theorem verified_row_215 : fork [place ⟨107, 1, 4, 6⟩ cache_107, place ⟨24, 0, 5, 4⟩ cache_24] = cache_215 := by + decide +kernel + +theorem load_entry_215 : entryAt 215 = entry_215 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_215 : CacheEquation 215 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(215 < 6)), load_entry_215] + change forkRow [placeRow ⟨107, 1, 4, 6⟩ (denote cache_107), placeRow ⟨24, 0, 5, 4⟩ (denote cache_24)] = denote cache_215 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_215 + +theorem verified_row_216 : fork [place ⟨7, 6, 0, 3⟩ cache_7, place ⟨155, 5, 5, 4⟩ cache_155] = cache_216 := by + decide +kernel + +theorem load_entry_216 : entryAt 216 = entry_216 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_216 : CacheEquation 216 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(216 < 6)), load_entry_216] + change forkRow [placeRow ⟨7, 6, 0, 3⟩ (denote cache_7), placeRow ⟨155, 5, 5, 4⟩ (denote cache_155)] = denote cache_216 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_216 + +theorem verified_row_217 : fork [place ⟨111, 1, 1, 3⟩ cache_111, place ⟨55, 4, 0, 4⟩ cache_55, place ⟨64, 0, 1, 3⟩ cache_64] = cache_217 := by + decide +kernel + +theorem load_entry_217 : entryAt 217 = entry_217 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_217 : CacheEquation 217 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(217 < 6)), load_entry_217] + change forkRow [placeRow ⟨111, 1, 1, 3⟩ (denote cache_111), placeRow ⟨55, 4, 0, 4⟩ (denote cache_55), placeRow ⟨64, 0, 1, 3⟩ (denote cache_64)] = denote cache_217 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_217 + +theorem verified_row_218 : fork [place ⟨0, 5, 3, 7⟩ cache_0, place ⟨182, 0, 2, 4⟩ cache_182] = cache_218 := by + decide +kernel + +theorem load_entry_218 : entryAt 218 = entry_218 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_218 : CacheEquation 218 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(218 < 6)), load_entry_218] + change forkRow [placeRow ⟨0, 5, 3, 7⟩ (denote cache_0), placeRow ⟨182, 0, 2, 4⟩ (denote cache_182)] = denote cache_218 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_218 + +theorem verified_row_219 : fork [place ⟨0, 5, 3, 7⟩ cache_0, place ⟨179, 2, 6, 4⟩ cache_179] = cache_219 := by + decide +kernel + +theorem load_entry_219 : entryAt 219 = entry_219 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_219 : CacheEquation 219 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(219 < 6)), load_entry_219] + change forkRow [placeRow ⟨0, 5, 3, 7⟩ (denote cache_0), placeRow ⟨179, 2, 6, 4⟩ (denote cache_179)] = denote cache_219 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_219 + +theorem verified_row_220 : fork [place ⟨56, 4, 0, 4⟩ cache_56, place ⟨63, 1, 5, 3⟩ cache_63, place ⟨144, 2, 5, 4⟩ cache_144, place ⟨154, 6, 5, 4⟩ cache_154, place ⟨155, 1, 5, 4⟩ cache_155] = cache_220 := by + decide +kernel + +theorem load_entry_220 : entryAt 220 = entry_220 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_220 : CacheEquation 220 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(220 < 6)), load_entry_220] + change forkRow [placeRow ⟨56, 4, 0, 4⟩ (denote cache_56), placeRow ⟨63, 1, 5, 3⟩ (denote cache_63), placeRow ⟨144, 2, 5, 4⟩ (denote cache_144), placeRow ⟨154, 6, 5, 4⟩ (denote cache_154), placeRow ⟨155, 1, 5, 4⟩ (denote cache_155)] = denote cache_220 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_220 + +theorem verified_row_221 : fork [place ⟨6, 6, 0, 3⟩ cache_6, place ⟨180, 5, 5, 4⟩ cache_180] = cache_221 := by + decide +kernel + +theorem load_entry_221 : entryAt 221 = entry_221 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_221 : CacheEquation 221 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(221 < 6)), load_entry_221] + change forkRow [placeRow ⟨6, 6, 0, 3⟩ (denote cache_6), placeRow ⟨180, 5, 5, 4⟩ (denote cache_180)] = denote cache_221 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_221 + +theorem verified_row_222 : fork [place ⟨6, 1, 4, 5⟩ cache_6, place ⟨158, 5, 5, 4⟩ cache_158] = cache_222 := by + decide +kernel + +theorem load_entry_222 : entryAt 222 = entry_222 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_222 : CacheEquation 222 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(222 < 6)), load_entry_222] + change forkRow [placeRow ⟨6, 1, 4, 5⟩ (denote cache_6), placeRow ⟨158, 5, 5, 4⟩ (denote cache_158)] = denote cache_222 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_222 + +theorem verified_row_223 : fork [place ⟨63, 1, 5, 3⟩ cache_63, place ⟨135, 2, 5, 4⟩ cache_135, place ⟨128, 0, 3, 3⟩ cache_128, place ⟨111, 3, 4, 3⟩ cache_111, place ⟨127, 0, 5, 4⟩ cache_127] = cache_223 := by + decide +kernel + +theorem load_entry_223 : entryAt 223 = entry_223 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_223 : CacheEquation 223 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(223 < 6)), load_entry_223] + change forkRow [placeRow ⟨63, 1, 5, 3⟩ (denote cache_63), placeRow ⟨135, 2, 5, 4⟩ (denote cache_135), placeRow ⟨128, 0, 3, 3⟩ (denote cache_128), placeRow ⟨111, 3, 4, 3⟩ (denote cache_111), placeRow ⟨127, 0, 5, 4⟩ (denote cache_127)] = denote cache_223 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_223 + +theorem verified_row_224 : fork [place ⟨6, 1, 4, 5⟩ cache_6, place ⟨212, 0, 6, 3⟩ cache_212] = cache_224 := by + decide +kernel + +theorem load_entry_224 : entryAt 224 = entry_224 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_224 : CacheEquation 224 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(224 < 6)), load_entry_224] + change forkRow [placeRow ⟨6, 1, 4, 5⟩ (denote cache_6), placeRow ⟨212, 0, 6, 3⟩ (denote cache_212)] = denote cache_224 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_224 + +theorem verified_row_225 : fork [place ⟨111, 7, 7, 5⟩ cache_111, place ⟨61, 4, 4, 5⟩ cache_61] = cache_225 := by + decide +kernel + +theorem load_entry_225 : entryAt 225 = entry_225 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_225 : CacheEquation 225 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(225 < 6)), load_entry_225] + change forkRow [placeRow ⟨111, 7, 7, 5⟩ (denote cache_111), placeRow ⟨61, 4, 4, 5⟩ (denote cache_61)] = denote cache_225 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_225 + +theorem verified_row_226 : fork [place ⟨10, 6, 0, 3⟩ cache_10, place ⟨203, 0, 5, 4⟩ cache_203, place ⟨33, 0, 2, 3⟩ cache_33, place ⟨193, 0, 2, 4⟩ cache_193] = cache_226 := by + decide +kernel + +theorem load_entry_226 : entryAt 226 = entry_226 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_226 : CacheEquation 226 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(226 < 6)), load_entry_226] + change forkRow [placeRow ⟨10, 6, 0, 3⟩ (denote cache_10), placeRow ⟨203, 0, 5, 4⟩ (denote cache_203), placeRow ⟨33, 0, 2, 3⟩ (denote cache_33), placeRow ⟨193, 0, 2, 4⟩ (denote cache_193)] = denote cache_226 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_226 + +theorem verified_row_227 : fork [place ⟨6, 1, 5, 5⟩ cache_6, place ⟨212, 0, 7, 3⟩ cache_212] = cache_227 := by + decide +kernel + +theorem load_entry_227 : entryAt 227 = entry_227 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_227 : CacheEquation 227 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(227 < 6)), load_entry_227] + change forkRow [placeRow ⟨6, 1, 5, 5⟩ (denote cache_6), placeRow ⟨212, 0, 7, 3⟩ (denote cache_212)] = denote cache_227 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_227 + +theorem verified_row_228 : fork [place ⟨82, 0, 6, 5⟩ cache_82, place ⟨68, 3, 5, 7⟩ cache_68] = cache_228 := by + decide +kernel + +theorem load_entry_228 : entryAt 228 = entry_228 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_228 : CacheEquation 228 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(228 < 6)), load_entry_228] + change forkRow [placeRow ⟨82, 0, 6, 5⟩ (denote cache_82), placeRow ⟨68, 3, 5, 7⟩ (denote cache_68)] = denote cache_228 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_228 + +theorem verified_row_229 : fork [place ⟨171, 0, 7, 3⟩ cache_171, place ⟨45, 1, 4, 5⟩ cache_45, place ⟨46, 3, 4, 5⟩ cache_46] = cache_229 := by + decide +kernel + +theorem load_entry_229 : entryAt 229 = entry_229 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_229 : CacheEquation 229 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(229 < 6)), load_entry_229] + change forkRow [placeRow ⟨171, 0, 7, 3⟩ (denote cache_171), placeRow ⟨45, 1, 4, 5⟩ (denote cache_45), placeRow ⟨46, 3, 4, 5⟩ (denote cache_46)] = denote cache_229 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_229 + +theorem verified_row_230 : fork [place ⟨10, 6, 3, 4⟩ cache_10, place ⟨193, 0, 5, 5⟩ cache_193, place ⟨203, 0, 8, 5⟩ cache_203, place ⟨33, 0, 5, 4⟩ cache_33] = cache_230 := by + decide +kernel + +theorem load_entry_230 : entryAt 230 = entry_230 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_230 : CacheEquation 230 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(230 < 6)), load_entry_230] + change forkRow [placeRow ⟨10, 6, 3, 4⟩ (denote cache_10), placeRow ⟨193, 0, 5, 5⟩ (denote cache_193), placeRow ⟨203, 0, 8, 5⟩ (denote cache_203), placeRow ⟨33, 0, 5, 4⟩ (denote cache_33)] = denote cache_230 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_230 + +theorem verified_row_231 : fork [place ⟨6, 3, 4, 5⟩ cache_6, place ⟨222, 0, 6, 4⟩ cache_222] = cache_231 := by + decide +kernel + +theorem load_entry_231 : entryAt 231 = entry_231 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_231 : CacheEquation 231 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(231 < 6)), load_entry_231] + change forkRow [placeRow ⟨6, 3, 4, 5⟩ (denote cache_6), placeRow ⟨222, 0, 6, 4⟩ (denote cache_222)] = denote cache_231 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_231 + +theorem verified_row_232 : fork [place ⟨24, 2, 5, 4⟩ cache_24, place ⟨107, 1, 4, 6⟩ cache_107] = cache_232 := by + decide +kernel + +theorem load_entry_232 : entryAt 232 = entry_232 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_232 : CacheEquation 232 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(232 < 6)), load_entry_232] + change forkRow [placeRow ⟨24, 2, 5, 4⟩ (denote cache_24), placeRow ⟨107, 1, 4, 6⟩ (denote cache_107)] = denote cache_232 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_232 + +theorem verified_row_233 : fork [place ⟨32, 3, 3, 1⟩ cache_32, place ⟨133, 0, 6, 4⟩ cache_133] = cache_233 := by + decide +kernel + +theorem load_entry_233 : entryAt 233 = entry_233 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_233 : CacheEquation 233 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(233 < 6)), load_entry_233] + change forkRow [placeRow ⟨32, 3, 3, 1⟩ (denote cache_32), placeRow ⟨133, 0, 6, 4⟩ (denote cache_133)] = denote cache_233 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_233 + +theorem verified_row_234 : fork [place ⟨180, 4, 4, 5⟩ cache_180, place ⟨37, 0, 3, 4⟩ cache_37, place ⟨129, 0, 5, 3⟩ cache_129, place ⟨63, 0, 3, 5⟩ cache_63] = cache_234 := by + decide +kernel + +theorem load_entry_234 : entryAt 234 = entry_234 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_234 : CacheEquation 234 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(234 < 6)), load_entry_234] + change forkRow [placeRow ⟨180, 4, 4, 5⟩ (denote cache_180), placeRow ⟨37, 0, 3, 4⟩ (denote cache_37), placeRow ⟨129, 0, 5, 3⟩ (denote cache_129), placeRow ⟨63, 0, 3, 5⟩ (denote cache_63)] = denote cache_234 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_234 + +theorem verified_row_235 : fork [place ⟨7, 3, 3, 4⟩ cache_7, place ⟨110, 0, 6, 4⟩ cache_110, place ⟨70, 0, 3, 5⟩ cache_70] = cache_235 := by + decide +kernel + +theorem load_entry_235 : entryAt 235 = entry_235 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_235 : CacheEquation 235 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(235 < 6)), load_entry_235] + change forkRow [placeRow ⟨7, 3, 3, 4⟩ (denote cache_7), placeRow ⟨110, 0, 6, 4⟩ (denote cache_110), placeRow ⟨70, 0, 3, 5⟩ (denote cache_70)] = denote cache_235 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_235 + +theorem verified_row_236 : fork [place ⟨38, 1, 4, 5⟩ cache_38, place ⟨122, 7, 3, 4⟩ cache_122, place ⟨181, 0, 2, 3⟩ cache_181, place ⟨30, 1, 4, 3⟩ cache_30] = cache_236 := by + decide +kernel + +theorem load_entry_236 : entryAt 236 = entry_236 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_236 : CacheEquation 236 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(236 < 6)), load_entry_236] + change forkRow [placeRow ⟨38, 1, 4, 5⟩ (denote cache_38), placeRow ⟨122, 7, 3, 4⟩ (denote cache_122), placeRow ⟨181, 0, 2, 3⟩ (denote cache_181), placeRow ⟨30, 1, 4, 3⟩ (denote cache_30)] = denote cache_236 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_236 + +theorem verified_row_237 : fork [place ⟨6, 3, 4, 5⟩ cache_6, place ⟨172, 0, 7, 4⟩ cache_172] = cache_237 := by + decide +kernel + +theorem load_entry_237 : entryAt 237 = entry_237 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_237 : CacheEquation 237 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(237 < 6)), load_entry_237] + change forkRow [placeRow ⟨6, 3, 4, 5⟩ (denote cache_6), placeRow ⟨172, 0, 7, 4⟩ (denote cache_172)] = denote cache_237 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_237 + +theorem verified_row_238 : fork [place ⟨6, 3, 4, 5⟩ cache_6, place ⟨178, 5, 7, 4⟩ cache_178] = cache_238 := by + decide +kernel + +theorem load_entry_238 : entryAt 238 = entry_238 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_238 : CacheEquation 238 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(238 < 6)), load_entry_238] + change forkRow [placeRow ⟨6, 3, 4, 5⟩ (denote cache_6), placeRow ⟨178, 5, 7, 4⟩ (denote cache_178)] = denote cache_238 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_238 + +theorem verified_row_239 : fork [place ⟨0, 4, 7, 3⟩ cache_0, place ⟨174, 4, 3, 5⟩ cache_174] = cache_239 := by + decide +kernel + +theorem load_entry_239 : entryAt 239 = entry_239 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_239 : CacheEquation 239 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(239 < 6)), load_entry_239] + change forkRow [placeRow ⟨0, 4, 7, 3⟩ (denote cache_0), placeRow ⟨174, 4, 3, 5⟩ (denote cache_174)] = denote cache_239 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_239 + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Equations06.lean b/lean/OAI/Combinatorics/SnakyCertificate/Equations06.lean new file mode 100644 index 0000000000000000000000000000000000000000..8722466b6b956a7d9d9316c735936cfe1805f66c --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Equations06.lean @@ -0,0 +1,530 @@ +import OAI.Combinatorics.SnakyCertificate.Cache +import OAI.Combinatorics.SnakyCertificate.TableList + +namespace OAI + +namespace SnakyCertificate.Check + +theorem verified_row_240 : fork [place ⟨6, 1, 4, 5⟩ cache_6, place ⟨237, 0, 2, 4⟩ cache_237] = cache_240 := by + decide +kernel + +theorem load_entry_240 : entryAt 240 = entry_240 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_240 : CacheEquation 240 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(240 < 6)), load_entry_240] + change forkRow [placeRow ⟨6, 1, 4, 5⟩ (denote cache_6), placeRow ⟨237, 0, 2, 4⟩ (denote cache_237)] = denote cache_240 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_240 + +theorem verified_row_241 : fork [place ⟨131, 1, 5, 4⟩ cache_131, place ⟨159, 1, 5, 4⟩ cache_159, place ⟨61, 0, 4, 5⟩ cache_61] = cache_241 := by + decide +kernel + +theorem load_entry_241 : entryAt 241 = entry_241 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_241 : CacheEquation 241 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(241 < 6)), load_entry_241] + change forkRow [placeRow ⟨131, 1, 5, 4⟩ (denote cache_131), placeRow ⟨159, 1, 5, 4⟩ (denote cache_159), placeRow ⟨61, 0, 4, 5⟩ (denote cache_61)] = denote cache_241 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_241 + +theorem verified_row_242 : fork [place ⟨6, 1, 4, 5⟩ cache_6, place ⟨190, 0, 5, 4⟩ cache_190] = cache_242 := by + decide +kernel + +theorem load_entry_242 : entryAt 242 = entry_242 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_242 : CacheEquation 242 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(242 < 6)), load_entry_242] + change forkRow [placeRow ⟨6, 1, 4, 5⟩ (denote cache_6), placeRow ⟨190, 0, 5, 4⟩ (denote cache_190)] = denote cache_242 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_242 + +theorem verified_row_243 : fork [place ⟨6, 0, 5, 4⟩ cache_6, place ⟨233, 0, 2, 5⟩ cache_233] = cache_243 := by + decide +kernel + +theorem load_entry_243 : entryAt 243 = entry_243 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_243 : CacheEquation 243 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(243 < 6)), load_entry_243] + change forkRow [placeRow ⟨6, 0, 5, 4⟩ (denote cache_6), placeRow ⟨233, 0, 2, 5⟩ (denote cache_233)] = denote cache_243 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_243 + +theorem verified_row_244 : fork [place ⟨99, 4, 2, 5⟩ cache_99, place ⟨99, 0, 4, 5⟩ cache_99, place ⟨11, 7, 3, 3⟩ cache_11, place ⟨173, 2, 5, 4⟩ cache_173] = cache_244 := by + decide +kernel + +theorem load_entry_244 : entryAt 244 = entry_244 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_244 : CacheEquation 244 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(244 < 6)), load_entry_244] + change forkRow [placeRow ⟨99, 4, 2, 5⟩ (denote cache_99), placeRow ⟨99, 0, 4, 5⟩ (denote cache_99), placeRow ⟨11, 7, 3, 3⟩ (denote cache_11), placeRow ⟨173, 2, 5, 4⟩ (denote cache_173)] = denote cache_244 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_244 + +theorem verified_row_245 : fork [place ⟨64, 0, 1, 3⟩ cache_64, place ⟨175, 4, 0, 4⟩ cache_175, place ⟨143, 6, 4, 5⟩ cache_143, place ⟨186, 6, 0, 4⟩ cache_186] = cache_245 := by + decide +kernel + +theorem load_entry_245 : entryAt 245 = entry_245 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_245 : CacheEquation 245 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(245 < 6)), load_entry_245] + change forkRow [placeRow ⟨64, 0, 1, 3⟩ (denote cache_64), placeRow ⟨175, 4, 0, 4⟩ (denote cache_175), placeRow ⟨143, 6, 4, 5⟩ (denote cache_143), placeRow ⟨186, 6, 0, 4⟩ (denote cache_186)] = denote cache_245 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_245 + +theorem verified_row_246 : fork [place ⟨64, 6, 4, 5⟩ cache_64, place ⟨175, 2, 5, 4⟩ cache_175, place ⟨186, 0, 5, 4⟩ cache_186, place ⟨143, 0, 1, 3⟩ cache_143] = cache_246 := by + decide +kernel + +theorem load_entry_246 : entryAt 246 = entry_246 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_246 : CacheEquation 246 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(246 < 6)), load_entry_246] + change forkRow [placeRow ⟨64, 6, 4, 5⟩ (denote cache_64), placeRow ⟨175, 2, 5, 4⟩ (denote cache_175), placeRow ⟨186, 0, 5, 4⟩ (denote cache_186), placeRow ⟨143, 0, 1, 3⟩ (denote cache_143)] = denote cache_246 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_246 + +theorem verified_row_247 : fork [place ⟨6, 4, 3, 4⟩ cache_6, place ⟨229, 0, 4, 5⟩ cache_229] = cache_247 := by + decide +kernel + +theorem load_entry_247 : entryAt 247 = entry_247 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_247 : CacheEquation 247 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(247 < 6)), load_entry_247] + change forkRow [placeRow ⟨6, 4, 3, 4⟩ (denote cache_6), placeRow ⟨229, 0, 4, 5⟩ (denote cache_229)] = denote cache_247 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_247 + +theorem verified_row_248 : fork [place ⟨186, 0, 7, 4⟩ cache_186, place ⟨143, 0, 3, 3⟩ cache_143, place ⟨175, 2, 7, 4⟩ cache_175, place ⟨64, 6, 6, 5⟩ cache_64] = cache_248 := by + decide +kernel + +theorem load_entry_248 : entryAt 248 = entry_248 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_248 : CacheEquation 248 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(248 < 6)), load_entry_248] + change forkRow [placeRow ⟨186, 0, 7, 4⟩ (denote cache_186), placeRow ⟨143, 0, 3, 3⟩ (denote cache_143), placeRow ⟨175, 2, 7, 4⟩ (denote cache_175), placeRow ⟨64, 6, 6, 5⟩ (denote cache_64)] = denote cache_248 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_248 + +theorem verified_row_249 : fork [place ⟨0, 7, 4, 5⟩ cache_0, place ⟨225, 1, 4, 1⟩ cache_225] = cache_249 := by + decide +kernel + +theorem load_entry_249 : entryAt 249 = entry_249 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_249 : CacheEquation 249 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(249 < 6)), load_entry_249] + change forkRow [placeRow ⟨0, 7, 4, 5⟩ (denote cache_0), placeRow ⟨225, 1, 4, 1⟩ (denote cache_225)] = denote cache_249 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_249 + +theorem verified_row_250 : fork [place ⟨6, 1, 4, 5⟩ cache_6, place ⟨238, 0, 2, 4⟩ cache_238] = cache_250 := by + decide +kernel + +theorem load_entry_250 : entryAt 250 = entry_250 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_250 : CacheEquation 250 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(250 < 6)), load_entry_250] + change forkRow [placeRow ⟨6, 1, 4, 5⟩ (denote cache_6), placeRow ⟨238, 0, 2, 4⟩ (denote cache_238)] = denote cache_250 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_250 + +theorem verified_row_251 : fork [place ⟨6, 2, 5, 4⟩ cache_6, place ⟨239, 4, 3, 6⟩ cache_239] = cache_251 := by + decide +kernel + +theorem load_entry_251 : entryAt 251 = entry_251 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_251 : CacheEquation 251 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(251 < 6)), load_entry_251] + change forkRow [placeRow ⟨6, 2, 5, 4⟩ (denote cache_6), placeRow ⟨239, 4, 3, 6⟩ (denote cache_239)] = denote cache_251 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_251 + +theorem verified_row_252 : fork [place ⟨111, 3, 4, 3⟩ cache_111, place ⟨154, 6, 5, 4⟩ cache_154, place ⟨144, 2, 5, 4⟩ cache_144, place ⟨63, 1, 5, 3⟩ cache_63, place ⟨155, 1, 5, 4⟩ cache_155] = cache_252 := by + decide +kernel + +theorem load_entry_252 : entryAt 252 = entry_252 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_252 : CacheEquation 252 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(252 < 6)), load_entry_252] + change forkRow [placeRow ⟨111, 3, 4, 3⟩ (denote cache_111), placeRow ⟨154, 6, 5, 4⟩ (denote cache_154), placeRow ⟨144, 2, 5, 4⟩ (denote cache_144), placeRow ⟨63, 1, 5, 3⟩ (denote cache_63), placeRow ⟨155, 1, 5, 4⟩ (denote cache_155)] = denote cache_252 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_252 + +theorem verified_row_253 : fork [place ⟨29, 3, 3, 0⟩ cache_29, place ⟨177, 1, 6, 2⟩ cache_177] = cache_253 := by + decide +kernel + +theorem load_entry_253 : entryAt 253 = entry_253 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_253 : CacheEquation 253 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(253 < 6)), load_entry_253] + change forkRow [placeRow ⟨29, 3, 3, 0⟩ (denote cache_29), placeRow ⟨177, 1, 6, 2⟩ (denote cache_177)] = denote cache_253 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_253 + +theorem verified_row_254 : fork [place ⟨96, 7, 4, 5⟩ cache_96, place ⟨108, 0, 8, 5⟩ cache_108] = cache_254 := by + decide +kernel + +theorem load_entry_254 : entryAt 254 = entry_254 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_254 : CacheEquation 254 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(254 < 6)), load_entry_254] + change forkRow [placeRow ⟨96, 7, 4, 5⟩ (denote cache_96), placeRow ⟨108, 0, 8, 5⟩ (denote cache_108)] = denote cache_254 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_254 + +theorem verified_row_255 : fork [place ⟨69, 0, 3, 3⟩ cache_69, place ⟨205, 0, 5, 5⟩ cache_205, place ⟨7, 3, 3, 4⟩ cache_7] = cache_255 := by + decide +kernel + +theorem load_entry_255 : entryAt 255 = entry_255 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_255 : CacheEquation 255 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(255 < 6)), load_entry_255] + change forkRow [placeRow ⟨69, 0, 3, 3⟩ (denote cache_69), placeRow ⟨205, 0, 5, 5⟩ (denote cache_205), placeRow ⟨7, 3, 3, 4⟩ (denote cache_7)] = denote cache_255 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_255 + +theorem verified_row_256 : fork [place ⟨0, 5, 4, 5⟩ cache_0, place ⟨231, 0, 3, 4⟩ cache_231] = cache_256 := by + decide +kernel + +theorem load_entry_256 : entryAt 256 = entry_256 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_256 : CacheEquation 256 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(256 < 6)), load_entry_256] + change forkRow [placeRow ⟨0, 5, 4, 5⟩ (denote cache_0), placeRow ⟨231, 0, 3, 4⟩ (denote cache_231)] = denote cache_256 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_256 + +theorem verified_row_257 : fork [place ⟨4, 1, 5, 4⟩ cache_4, place ⟨235, 0, 4, 5⟩ cache_235] = cache_257 := by + decide +kernel + +theorem load_entry_257 : entryAt 257 = entry_257 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_257 : CacheEquation 257 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(257 < 6)), load_entry_257] + change forkRow [placeRow ⟨4, 1, 5, 4⟩ (denote cache_4), placeRow ⟨235, 0, 4, 5⟩ (denote cache_235)] = denote cache_257 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_257 + +theorem verified_row_258 : fork [place ⟨6, 4, 3, 4⟩ cache_6, place ⟨227, 0, 4, 5⟩ cache_227] = cache_258 := by + decide +kernel + +theorem load_entry_258 : entryAt 258 = entry_258 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_258 : CacheEquation 258 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(258 < 6)), load_entry_258] + change forkRow [placeRow ⟨6, 4, 3, 4⟩ (denote cache_6), placeRow ⟨227, 0, 4, 5⟩ (denote cache_227)] = denote cache_258 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_258 + +theorem verified_row_259 : fork [place ⟨6, 4, 3, 4⟩ cache_6, place ⟨231, 1, 7, 2⟩ cache_231] = cache_259 := by + decide +kernel + +theorem load_entry_259 : entryAt 259 = entry_259 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_259 : CacheEquation 259 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(259 < 6)), load_entry_259] + change forkRow [placeRow ⟨6, 4, 3, 4⟩ (denote cache_6), placeRow ⟨231, 1, 7, 2⟩ (denote cache_231)] = denote cache_259 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_259 + +theorem verified_row_260 : fork [place ⟨0, 5, 4, 6⟩ cache_0, place ⟨231, 0, 3, 5⟩ cache_231] = cache_260 := by + decide +kernel + +theorem load_entry_260 : entryAt 260 = entry_260 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_260 : CacheEquation 260 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(260 < 6)), load_entry_260] + change forkRow [placeRow ⟨0, 5, 4, 6⟩ (denote cache_0), placeRow ⟨231, 0, 3, 5⟩ (denote cache_231)] = denote cache_260 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_260 + +theorem verified_row_261 : fork [place ⟨6, 3, 4, 5⟩ cache_6, place ⟨242, 0, 6, 4⟩ cache_242] = cache_261 := by + decide +kernel + +theorem load_entry_261 : entryAt 261 = entry_261 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_261 : CacheEquation 261 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(261 < 6)), load_entry_261] + change forkRow [placeRow ⟨6, 3, 4, 5⟩ (denote cache_6), placeRow ⟨242, 0, 6, 4⟩ (denote cache_242)] = denote cache_261 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_261 + +theorem verified_row_262 : fork [place ⟨0, 7, 5, 7⟩ cache_0, place ⟨213, 0, 3, 4⟩ cache_213] = cache_262 := by + decide +kernel + +theorem load_entry_262 : entryAt 262 = entry_262 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_262 : CacheEquation 262 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(262 < 6)), load_entry_262] + change forkRow [placeRow ⟨0, 7, 5, 7⟩ (denote cache_0), placeRow ⟨213, 0, 3, 4⟩ (denote cache_213)] = denote cache_262 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_262 + +theorem verified_row_263 : fork [place ⟨144, 6, 0, 4⟩ cache_144, place ⟨143, 0, 1, 3⟩ cache_143, place ⟨175, 0, 5, 4⟩ cache_175, place ⟨55, 6, 0, 4⟩ cache_55] = cache_263 := by + decide +kernel + +theorem load_entry_263 : entryAt 263 = entry_263 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_263 : CacheEquation 263 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(263 < 6)), load_entry_263] + change forkRow [placeRow ⟨144, 6, 0, 4⟩ (denote cache_144), placeRow ⟨143, 0, 1, 3⟩ (denote cache_143), placeRow ⟨175, 0, 5, 4⟩ (denote cache_175), placeRow ⟨55, 6, 0, 4⟩ (denote cache_55)] = denote cache_263 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_263 + +theorem verified_row_264 : fork [place ⟨6, 4, 3, 4⟩ cache_6, place ⟨250, 1, 7, 4⟩ cache_250] = cache_264 := by + decide +kernel + +theorem load_entry_264 : entryAt 264 = entry_264 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_264 : CacheEquation 264 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(264 < 6)), load_entry_264] + change forkRow [placeRow ⟨6, 4, 3, 4⟩ (denote cache_6), placeRow ⟨250, 1, 7, 4⟩ (denote cache_250)] = denote cache_264 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_264 + +theorem verified_row_265 : fork [place ⟨6, 6, 3, 4⟩ cache_6, place ⟨247, 0, 4, 6⟩ cache_247] = cache_265 := by + decide +kernel + +theorem load_entry_265 : entryAt 265 = entry_265 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_265 : CacheEquation 265 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(265 < 6)), load_entry_265] + change forkRow [placeRow ⟨6, 6, 3, 4⟩ (denote cache_6), placeRow ⟨247, 0, 4, 6⟩ (denote cache_247)] = denote cache_265 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_265 + +theorem verified_row_266 : fork [place ⟨6, 3, 3, 5⟩ cache_6, place ⟨242, 0, 5, 4⟩ cache_242] = cache_266 := by + decide +kernel + +theorem load_entry_266 : entryAt 266 = entry_266 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_266 : CacheEquation 266 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(266 < 6)), load_entry_266] + change forkRow [placeRow ⟨6, 3, 3, 5⟩ (denote cache_6), placeRow ⟨242, 0, 5, 4⟩ (denote cache_242)] = denote cache_266 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_266 + +theorem verified_row_267 : fork [place ⟨175, 4, 1, 4⟩ cache_175, place ⟨144, 2, 6, 4⟩ cache_144, place ⟨55, 2, 6, 4⟩ cache_55, place ⟨143, 4, 5, 3⟩ cache_143] = cache_267 := by + decide +kernel + +theorem load_entry_267 : entryAt 267 = entry_267 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_267 : CacheEquation 267 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(267 < 6)), load_entry_267] + change forkRow [placeRow ⟨175, 4, 1, 4⟩ (denote cache_175), placeRow ⟨144, 2, 6, 4⟩ (denote cache_144), placeRow ⟨55, 2, 6, 4⟩ (denote cache_55), placeRow ⟨143, 4, 5, 3⟩ (denote cache_143)] = denote cache_267 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_267 + +theorem verified_row_268 : fork [place ⟨6, 0, 5, 4⟩ cache_6, place ⟨251, 0, 4, 2⟩ cache_251] = cache_268 := by + decide +kernel + +theorem load_entry_268 : entryAt 268 = entry_268 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_268 : CacheEquation 268 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(268 < 6)), load_entry_268] + change forkRow [placeRow ⟨6, 0, 5, 4⟩ (denote cache_6), placeRow ⟨251, 0, 4, 2⟩ (denote cache_251)] = denote cache_268 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_268 + +theorem verified_row_269 : fork [place ⟨28, 3, 3, 6⟩ cache_28, place ⟨202, 0, 7, 5⟩ cache_202] = cache_269 := by + decide +kernel + +theorem load_entry_269 : entryAt 269 = entry_269 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_269 : CacheEquation 269 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(269 < 6)), load_entry_269] + change forkRow [placeRow ⟨28, 3, 3, 6⟩ (denote cache_28), placeRow ⟨202, 0, 7, 5⟩ (denote cache_202)] = denote cache_269 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_269 + +theorem verified_row_270 : fork [place ⟨63, 0, 3, 7⟩ cache_63, place ⟨6, 7, 3, 2⟩ cache_6] = cache_270 := by + decide +kernel + +theorem load_entry_270 : entryAt 270 = entry_270 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_270 : CacheEquation 270 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(270 < 6)), load_entry_270] + change forkRow [placeRow ⟨63, 0, 3, 7⟩ (denote cache_63), placeRow ⟨6, 7, 3, 2⟩ (denote cache_6)] = denote cache_270 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_270 + +theorem verified_row_271 : fork [place ⟨107, 2, 7, 3⟩ cache_107, place ⟨107, 3, 4, 6⟩ cache_107] = cache_271 := by + decide +kernel + +theorem load_entry_271 : entryAt 271 = entry_271 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_271 : CacheEquation 271 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(271 < 6)), load_entry_271] + change forkRow [placeRow ⟨107, 2, 7, 3⟩ (denote cache_107), placeRow ⟨107, 3, 4, 6⟩ (denote cache_107)] = denote cache_271 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_271 + +theorem verified_row_272 : fork [place ⟨1, 1, 3, 1⟩ cache_1, place ⟨249, 0, 4, 5⟩ cache_249] = cache_272 := by + decide +kernel + +theorem load_entry_272 : entryAt 272 = entry_272 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_272 : CacheEquation 272 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(272 < 6)), load_entry_272] + change forkRow [placeRow ⟨1, 1, 3, 1⟩ (denote cache_1), placeRow ⟨249, 0, 4, 5⟩ (denote cache_249)] = denote cache_272 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_272 + +theorem verified_row_273 : fork [place ⟨6, 1, 4, 5⟩ cache_6, place ⟨223, 0, 5, 4⟩ cache_223] = cache_273 := by + decide +kernel + +theorem load_entry_273 : entryAt 273 = entry_273 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_273 : CacheEquation 273 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(273 < 6)), load_entry_273] + change forkRow [placeRow ⟨6, 1, 4, 5⟩ (denote cache_6), placeRow ⟨223, 0, 5, 4⟩ (denote cache_223)] = denote cache_273 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_273 + +theorem verified_row_274 : fork [place ⟨6, 7, 3, 1⟩ cache_6, place ⟨240, 0, 5, 5⟩ cache_240] = cache_274 := by + decide +kernel + +theorem load_entry_274 : entryAt 274 = entry_274 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_274 : CacheEquation 274 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(274 < 6)), load_entry_274] + change forkRow [placeRow ⟨6, 7, 3, 1⟩ (denote cache_6), placeRow ⟨240, 0, 5, 5⟩ (denote cache_240)] = denote cache_274 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_274 + +theorem verified_row_275 : fork [place ⟨63, 1, 5, 3⟩ cache_63, place ⟨198, 4, 0, 4⟩ cache_198, place ⟨44, 2, 5, 4⟩ cache_44] = cache_275 := by + decide +kernel + +theorem load_entry_275 : entryAt 275 = entry_275 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_275 : CacheEquation 275 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(275 < 6)), load_entry_275] + change forkRow [placeRow ⟨63, 1, 5, 3⟩ (denote cache_63), placeRow ⟨198, 4, 0, 4⟩ (denote cache_198), placeRow ⟨44, 2, 5, 4⟩ (denote cache_44)] = denote cache_275 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_275 + +theorem verified_row_276 : fork [place ⟨7, 3, 3, 4⟩ cache_7, place ⟨177, 0, 5, 4⟩ cache_177, place ⟨63, 0, 3, 5⟩ cache_63] = cache_276 := by + decide +kernel + +theorem load_entry_276 : entryAt 276 = entry_276 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_276 : CacheEquation 276 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(276 < 6)), load_entry_276] + change forkRow [placeRow ⟨7, 3, 3, 4⟩ (denote cache_7), placeRow ⟨177, 0, 5, 4⟩ (denote cache_177), placeRow ⟨63, 0, 3, 5⟩ (denote cache_63)] = denote cache_276 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_276 + +theorem verified_row_277 : fork [place ⟨14, 3, 4, 5⟩ cache_14, place ⟨204, 2, 3, 0⟩ cache_204, place ⟨33, 1, 3, 2⟩ cache_33] = cache_277 := by + decide +kernel + +theorem load_entry_277 : entryAt 277 = entry_277 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_277 : CacheEquation 277 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(277 < 6)), load_entry_277] + change forkRow [placeRow ⟨14, 3, 4, 5⟩ (denote cache_14), placeRow ⟨204, 2, 3, 0⟩ (denote cache_204), placeRow ⟨33, 1, 3, 2⟩ (denote cache_33)] = denote cache_277 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_277 + +theorem verified_row_278 : fork [place ⟨63, 3, 3, 3⟩ cache_63, place ⟨162, 1, 8, 4⟩ cache_162] = cache_278 := by + decide +kernel + +theorem load_entry_278 : entryAt 278 = entry_278 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_278 : CacheEquation 278 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(278 < 6)), load_entry_278] + change forkRow [placeRow ⟨63, 3, 3, 3⟩ (denote cache_63), placeRow ⟨162, 1, 8, 4⟩ (denote cache_162)] = denote cache_278 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_278 + +theorem verified_row_279 : fork [place ⟨6, 3, 4, 5⟩ cache_6, place ⟨234, 5, 7, 4⟩ cache_234] = cache_279 := by + decide +kernel + +theorem load_entry_279 : entryAt 279 = entry_279 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_279 : CacheEquation 279 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(279 < 6)), load_entry_279] + change forkRow [placeRow ⟨6, 3, 4, 5⟩ (denote cache_6), placeRow ⟨234, 5, 7, 4⟩ (denote cache_234)] = denote cache_279 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_279 + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Equations07.lean b/lean/OAI/Combinatorics/SnakyCertificate/Equations07.lean new file mode 100644 index 0000000000000000000000000000000000000000..7d47939ecc3a8d37cd332d6f703061b8ae777416 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Equations07.lean @@ -0,0 +1,530 @@ +import OAI.Combinatorics.SnakyCertificate.Cache +import OAI.Combinatorics.SnakyCertificate.TableList + +namespace OAI + +namespace SnakyCertificate.Check + +theorem verified_row_280 : fork [place ⟨184, 0, 1, 5⟩ cache_184, place ⟨116, 2, 4, 3⟩ cache_116] = cache_280 := by + decide +kernel + +theorem load_entry_280 : entryAt 280 = entry_280 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_280 : CacheEquation 280 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(280 < 6)), load_entry_280] + change forkRow [placeRow ⟨184, 0, 1, 5⟩ (denote cache_184), placeRow ⟨116, 2, 4, 3⟩ (denote cache_116)] = denote cache_280 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_280 + +theorem verified_row_281 : fork [place ⟨36, 4, 5, 4⟩ cache_36, place ⟨163, 2, 5, 4⟩ cache_163, place ⟨189, 0, 4, 5⟩ cache_189] = cache_281 := by + decide +kernel + +theorem load_entry_281 : entryAt 281 = entry_281 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_281 : CacheEquation 281 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(281 < 6)), load_entry_281] + change forkRow [placeRow ⟨36, 4, 5, 4⟩ (denote cache_36), placeRow ⟨163, 2, 5, 4⟩ (denote cache_163), placeRow ⟨189, 0, 4, 5⟩ (denote cache_189)] = denote cache_281 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_281 + +theorem verified_row_282 : fork [place ⟨56, 0, 5, 4⟩ cache_56, place ⟨64, 0, 1, 3⟩ cache_64, place ⟨55, 0, 5, 4⟩ cache_55, place ⟨265, 0, 1, 3⟩ cache_265] = cache_282 := by + decide +kernel + +theorem load_entry_282 : entryAt 282 = entry_282 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_282 : CacheEquation 282 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(282 < 6)), load_entry_282] + change forkRow [placeRow ⟨56, 0, 5, 4⟩ (denote cache_56), placeRow ⟨64, 0, 1, 3⟩ (denote cache_64), placeRow ⟨55, 0, 5, 4⟩ (denote cache_55), placeRow ⟨265, 0, 1, 3⟩ (denote cache_265)] = denote cache_282 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_282 + +theorem verified_row_283 : fork [place ⟨64, 0, 1, 3⟩ cache_64, place ⟨196, 1, 4, 3⟩ cache_196, place ⟨55, 2, 5, 4⟩ cache_55] = cache_283 := by + decide +kernel + +theorem load_entry_283 : entryAt 283 = entry_283 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_283 : CacheEquation 283 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(283 < 6)), load_entry_283] + change forkRow [placeRow ⟨64, 0, 1, 3⟩ (denote cache_64), placeRow ⟨196, 1, 4, 3⟩ (denote cache_196), placeRow ⟨55, 2, 5, 4⟩ (denote cache_55)] = denote cache_283 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_283 + +theorem verified_row_284 : fork [place ⟨45, 1, 4, 5⟩ cache_45, place ⟨224, 0, 5, 4⟩ cache_224, place ⟨46, 3, 4, 5⟩ cache_46] = cache_284 := by + decide +kernel + +theorem load_entry_284 : entryAt 284 = entry_284 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_284 : CacheEquation 284 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(284 < 6)), load_entry_284] + change forkRow [placeRow ⟨45, 1, 4, 5⟩ (denote cache_45), placeRow ⟨224, 0, 5, 4⟩ (denote cache_224), placeRow ⟨46, 3, 4, 5⟩ (denote cache_46)] = denote cache_284 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_284 + +theorem verified_row_285 : fork [place ⟨6, 3, 4, 5⟩ cache_6, place ⟨273, 0, 6, 4⟩ cache_273] = cache_285 := by + decide +kernel + +theorem load_entry_285 : entryAt 285 = entry_285 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_285 : CacheEquation 285 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(285 < 6)), load_entry_285] + change forkRow [placeRow ⟨6, 3, 4, 5⟩ (denote cache_6), placeRow ⟨273, 0, 6, 4⟩ (denote cache_273)] = denote cache_285 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_285 + +theorem verified_row_286 : fork [place ⟨6, 7, 3, 0⟩ cache_6, place ⟨261, 0, 3, 4⟩ cache_261] = cache_286 := by + decide +kernel + +theorem load_entry_286 : entryAt 286 = entry_286 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_286 : CacheEquation 286 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(286 < 6)), load_entry_286] + change forkRow [placeRow ⟨6, 7, 3, 0⟩ (denote cache_6), placeRow ⟨261, 0, 3, 4⟩ (denote cache_261)] = denote cache_286 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_286 + +theorem verified_row_287 : fork [place ⟨64, 0, 1, 3⟩ cache_64, place ⟨55, 0, 5, 4⟩ cache_55, place ⟨56, 0, 5, 4⟩ cache_56, place ⟨264, 4, 4, 5⟩ cache_264] = cache_287 := by + decide +kernel + +theorem load_entry_287 : entryAt 287 = entry_287 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_287 : CacheEquation 287 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(287 < 6)), load_entry_287] + change forkRow [placeRow ⟨64, 0, 1, 3⟩ (denote cache_64), placeRow ⟨55, 0, 5, 4⟩ (denote cache_55), placeRow ⟨56, 0, 5, 4⟩ (denote cache_56), placeRow ⟨264, 4, 4, 5⟩ (denote cache_264)] = denote cache_287 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_287 + +theorem verified_row_288 : fork [place ⟨130, 1, 4, 2⟩ cache_130, place ⟨96, 0, 1, 4⟩ cache_96] = cache_288 := by + decide +kernel + +theorem load_entry_288 : entryAt 288 = entry_288 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_288 : CacheEquation 288 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(288 < 6)), load_entry_288] + change forkRow [placeRow ⟨130, 1, 4, 2⟩ (denote cache_130), placeRow ⟨96, 0, 1, 4⟩ (denote cache_96)] = denote cache_288 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_288 + +theorem verified_row_289 : fork [place ⟨6, 1, 4, 5⟩ cache_6, place ⟨279, 0, 2, 4⟩ cache_279] = cache_289 := by + decide +kernel + +theorem load_entry_289 : entryAt 289 = entry_289 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_289 : CacheEquation 289 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(289 < 6)), load_entry_289] + change forkRow [placeRow ⟨6, 1, 4, 5⟩ (denote cache_6), placeRow ⟨279, 0, 2, 4⟩ (denote cache_279)] = denote cache_289 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_289 + +theorem verified_row_290 : fork [place ⟨67, 2, 5, 2⟩ cache_67, place ⟨231, 4, 5, 5⟩ cache_231] = cache_290 := by + decide +kernel + +theorem load_entry_290 : entryAt 290 = entry_290 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_290 : CacheEquation 290 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(290 < 6)), load_entry_290] + change forkRow [placeRow ⟨67, 2, 5, 2⟩ (denote cache_67), placeRow ⟨231, 4, 5, 5⟩ (denote cache_231)] = denote cache_290 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_290 + +theorem verified_row_291 : fork [place ⟨89, 3, 3, 4⟩ cache_89, place ⟨202, 0, 8, 4⟩ cache_202, place ⟨55, 4, 3, 4⟩ cache_55] = cache_291 := by + decide +kernel + +theorem load_entry_291 : entryAt 291 = entry_291 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_291 : CacheEquation 291 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(291 < 6)), load_entry_291] + change forkRow [placeRow ⟨89, 3, 3, 4⟩ (denote cache_89), placeRow ⟨202, 0, 8, 4⟩ (denote cache_202), placeRow ⟨55, 4, 3, 4⟩ (denote cache_55)] = denote cache_291 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_291 + +theorem verified_row_292 : fork [place ⟨39, 0, 3, 4⟩ cache_39, place ⟨219, 3, 3, 4⟩ cache_219, place ⟨79, 1, 4, 3⟩ cache_79] = cache_292 := by + decide +kernel + +theorem load_entry_292 : entryAt 292 = entry_292 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_292 : CacheEquation 292 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(292 < 6)), load_entry_292] + change forkRow [placeRow ⟨39, 0, 3, 4⟩ (denote cache_39), placeRow ⟨219, 3, 3, 4⟩ (denote cache_219), placeRow ⟨79, 1, 4, 3⟩ (denote cache_79)] = denote cache_292 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_292 + +theorem verified_row_293 : fork [place ⟨2, 7, 4, 3⟩ cache_2, place ⟨280, 0, 5, 4⟩ cache_280] = cache_293 := by + decide +kernel + +theorem load_entry_293 : entryAt 293 = entry_293 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_293 : CacheEquation 293 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(293 < 6)), load_entry_293] + change forkRow [placeRow ⟨2, 7, 4, 3⟩ (denote cache_2), placeRow ⟨280, 0, 5, 4⟩ (denote cache_280)] = denote cache_293 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_293 + +theorem verified_row_294 : fork [place ⟨63, 1, 5, 3⟩ cache_63, place ⟨196, 3, 1, 3⟩ cache_196] = cache_294 := by + decide +kernel + +theorem load_entry_294 : entryAt 294 = entry_294 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_294 : CacheEquation 294 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(294 < 6)), load_entry_294] + change forkRow [placeRow ⟨63, 1, 5, 3⟩ (denote cache_63), placeRow ⟨196, 3, 1, 3⟩ (denote cache_196)] = denote cache_294 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_294 + +theorem verified_row_295 : fork [place ⟨63, 1, 5, 3⟩ cache_63, place ⟨64, 2, 1, 5⟩ cache_64, place ⟨55, 0, 5, 4⟩ cache_55, place ⟨265, 4, 4, 3⟩ cache_265] = cache_295 := by + decide +kernel + +theorem load_entry_295 : entryAt 295 = entry_295 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_295 : CacheEquation 295 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(295 < 6)), load_entry_295] + change forkRow [placeRow ⟨63, 1, 5, 3⟩ (denote cache_63), placeRow ⟨64, 2, 1, 5⟩ (denote cache_64), placeRow ⟨55, 0, 5, 4⟩ (denote cache_55), placeRow ⟨265, 4, 4, 3⟩ (denote cache_265)] = denote cache_295 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_295 + +theorem verified_row_296 : fork [place ⟨107, 1, 4, 5⟩ cache_107, place ⟨209, 3, 3, 4⟩ cache_209, place ⟨65, 1, 4, 5⟩ cache_65] = cache_296 := by + decide +kernel + +theorem load_entry_296 : entryAt 296 = entry_296 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_296 : CacheEquation 296 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(296 < 6)), load_entry_296] + change forkRow [placeRow ⟨107, 1, 4, 5⟩ (denote cache_107), placeRow ⟨209, 3, 3, 4⟩ (denote cache_209), placeRow ⟨65, 1, 4, 5⟩ (denote cache_65)] = denote cache_296 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_296 + +theorem verified_row_297 : fork [place ⟨6, 4, 3, 4⟩ cache_6, place ⟨289, 1, 7, 4⟩ cache_289] = cache_297 := by + decide +kernel + +theorem load_entry_297 : entryAt 297 = entry_297 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_297 : CacheEquation 297 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(297 < 6)), load_entry_297] + change forkRow [placeRow ⟨6, 4, 3, 4⟩ (denote cache_6), placeRow ⟨289, 1, 7, 4⟩ (denote cache_289)] = denote cache_297 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_297 + +theorem verified_row_298 : fork [place ⟨24, 2, 7, 3⟩ cache_24, place ⟨24, 6, 3, 3⟩ cache_24, place ⟨107, 4, 3, 4⟩ cache_107, place ⟨195, 0, 7, 4⟩ cache_195] = cache_298 := by + decide +kernel + +theorem load_entry_298 : entryAt 298 = entry_298 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_298 : CacheEquation 298 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(298 < 6)), load_entry_298] + change forkRow [placeRow ⟨24, 2, 7, 3⟩ (denote cache_24), placeRow ⟨24, 6, 3, 3⟩ (denote cache_24), placeRow ⟨107, 4, 3, 4⟩ (denote cache_107), placeRow ⟨195, 0, 7, 4⟩ (denote cache_195)] = denote cache_298 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_298 + +theorem verified_row_299 : fork [place ⟨6, 4, 3, 4⟩ cache_6, place ⟨284, 0, 4, 5⟩ cache_284] = cache_299 := by + decide +kernel + +theorem load_entry_299 : entryAt 299 = entry_299 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_299 : CacheEquation 299 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(299 < 6)), load_entry_299] + change forkRow [placeRow ⟨6, 4, 3, 4⟩ (denote cache_6), placeRow ⟨284, 0, 4, 5⟩ (denote cache_284)] = denote cache_299 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_299 + +theorem verified_row_300 : fork [place ⟨64, 3, 5, 1⟩ cache_64, place ⟨240, 2, 5, 1⟩ cache_240, place ⟨55, 3, 4, 5⟩ cache_55] = cache_300 := by + decide +kernel + +theorem load_entry_300 : entryAt 300 = entry_300 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_300 : CacheEquation 300 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(300 < 6)), load_entry_300] + change forkRow [placeRow ⟨64, 3, 5, 1⟩ (denote cache_64), placeRow ⟨240, 2, 5, 1⟩ (denote cache_240), placeRow ⟨55, 3, 4, 5⟩ (denote cache_55)] = denote cache_300 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_300 + +theorem verified_row_301 : fork [place ⟨59, 0, 5, 4⟩ cache_59, place ⟨57, 0, 5, 4⟩ cache_57, place ⟨258, 4, 4, 5⟩ cache_258] = cache_301 := by + decide +kernel + +theorem load_entry_301 : entryAt 301 = entry_301 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_301 : CacheEquation 301 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(301 < 6)), load_entry_301] + change forkRow [placeRow ⟨59, 0, 5, 4⟩ (denote cache_59), placeRow ⟨57, 0, 5, 4⟩ (denote cache_57), placeRow ⟨258, 4, 4, 5⟩ (denote cache_258)] = denote cache_301 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_301 + +theorem verified_row_302 : fork [place ⟨125, 0, 5, 3⟩ cache_125, place ⟨162, 4, 3, 6⟩ cache_162] = cache_302 := by + decide +kernel + +theorem load_entry_302 : entryAt 302 = entry_302 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_302 : CacheEquation 302 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(302 < 6)), load_entry_302] + change forkRow [placeRow ⟨125, 0, 5, 3⟩ (denote cache_125), placeRow ⟨162, 4, 3, 6⟩ (denote cache_162)] = denote cache_302 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_302 + +theorem verified_row_303 : fork [place ⟨49, 4, 4, 5⟩ cache_49, place ⟨44, 1, 4, 5⟩ cache_44, place ⟨63, 0, 3, 5⟩ cache_63, place ⟨261, 0, 3, 4⟩ cache_261] = cache_303 := by + decide +kernel + +theorem load_entry_303 : entryAt 303 = entry_303 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_303 : CacheEquation 303 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(303 < 6)), load_entry_303] + change forkRow [placeRow ⟨49, 4, 4, 5⟩ (denote cache_49), placeRow ⟨44, 1, 4, 5⟩ (denote cache_44), placeRow ⟨63, 0, 3, 5⟩ (denote cache_63), placeRow ⟨261, 0, 3, 4⟩ (denote cache_261)] = denote cache_303 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_303 + +theorem verified_row_304 : fork [place ⟨55, 4, 3, 4⟩ cache_55, place ⟨202, 0, 8, 4⟩ cache_202, place ⟨131, 3, 3, 4⟩ cache_131] = cache_304 := by + decide +kernel + +theorem load_entry_304 : entryAt 304 = entry_304 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_304 : CacheEquation 304 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(304 < 6)), load_entry_304] + change forkRow [placeRow ⟨55, 4, 3, 4⟩ (denote cache_55), placeRow ⟨202, 0, 8, 4⟩ (denote cache_202), placeRow ⟨131, 3, 3, 4⟩ (denote cache_131)] = denote cache_304 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_304 + +theorem verified_row_305 : fork [place ⟨6, 1, 4, 5⟩ cache_6, place ⟨278, 0, 1, 4⟩ cache_278] = cache_305 := by + decide +kernel + +theorem load_entry_305 : entryAt 305 = entry_305 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_305 : CacheEquation 305 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(305 < 6)), load_entry_305] + change forkRow [placeRow ⟨6, 1, 4, 5⟩ (denote cache_6), placeRow ⟨278, 0, 1, 4⟩ (denote cache_278)] = denote cache_305 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_305 + +theorem verified_row_306 : fork [place ⟨4, 1, 4, 3⟩ cache_4, place ⟨288, 0, 6, 4⟩ cache_288] = cache_306 := by + decide +kernel + +theorem load_entry_306 : entryAt 306 = entry_306 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_306 : CacheEquation 306 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(306 < 6)), load_entry_306] + change forkRow [placeRow ⟨4, 1, 4, 3⟩ (denote cache_4), placeRow ⟨288, 0, 6, 4⟩ (denote cache_288)] = denote cache_306 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_306 + +theorem verified_row_307 : fork [place ⟨0, 7, 4, 6⟩ cache_0, place ⟨273, 0, 5, 5⟩ cache_273] = cache_307 := by + decide +kernel + +theorem load_entry_307 : entryAt 307 = entry_307 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_307 : CacheEquation 307 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(307 < 6)), load_entry_307] + change forkRow [placeRow ⟨0, 7, 4, 6⟩ (denote cache_0), placeRow ⟨273, 0, 5, 5⟩ (denote cache_273)] = denote cache_307 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_307 + +theorem verified_row_308 : fork [place ⟨6, 6, 3, 4⟩ cache_6, place ⟨299, 0, 4, 6⟩ cache_299] = cache_308 := by + decide +kernel + +theorem load_entry_308 : entryAt 308 = entry_308 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_308 : CacheEquation 308 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(308 < 6)), load_entry_308] + change forkRow [placeRow ⟨6, 6, 3, 4⟩ (denote cache_6), placeRow ⟨299, 0, 4, 6⟩ (denote cache_299)] = denote cache_308 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_308 + +theorem verified_row_309 : fork [place ⟨28, 6, 3, 4⟩ cache_28, place ⟨268, 1, 5, 7⟩ cache_268] = cache_309 := by + decide +kernel + +theorem load_entry_309 : entryAt 309 = entry_309 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_309 : CacheEquation 309 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(309 < 6)), load_entry_309] + change forkRow [placeRow ⟨28, 6, 3, 4⟩ (denote cache_28), placeRow ⟨268, 1, 5, 7⟩ (denote cache_268)] = denote cache_309 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_309 + +theorem verified_row_310 : fork [place ⟨6, 1, 4, 5⟩ cache_6, place ⟨281, 0, 5, 3⟩ cache_281] = cache_310 := by + decide +kernel + +theorem load_entry_310 : entryAt 310 = entry_310 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_310 : CacheEquation 310 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(310 < 6)), load_entry_310] + change forkRow [placeRow ⟨6, 1, 4, 5⟩ (denote cache_6), placeRow ⟨281, 0, 5, 3⟩ (denote cache_281)] = denote cache_310 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_310 + +theorem verified_row_311 : fork [place ⟨6, 3, 3, 5⟩ cache_6, place ⟨278, 0, 2, 4⟩ cache_278] = cache_311 := by + decide +kernel + +theorem load_entry_311 : entryAt 311 = entry_311 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_311 : CacheEquation 311 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(311 < 6)), load_entry_311] + change forkRow [placeRow ⟨6, 3, 3, 5⟩ (denote cache_6), placeRow ⟨278, 0, 2, 4⟩ (denote cache_278)] = denote cache_311 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_311 + +theorem verified_row_312 : fork [place ⟨9, 2, 5, 4⟩ cache_9, place ⟨272, 0, 4, 5⟩ cache_272] = cache_312 := by + decide +kernel + +theorem load_entry_312 : entryAt 312 = entry_312 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_312 : CacheEquation 312 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(312 < 6)), load_entry_312] + change forkRow [placeRow ⟨9, 2, 5, 4⟩ (denote cache_9), placeRow ⟨272, 0, 4, 5⟩ (denote cache_272)] = denote cache_312 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_312 + +theorem verified_row_313 : fork [place ⟨162, 4, 4, 5⟩ cache_162, place ⟨148, 5, 6, 3⟩ cache_148] = cache_313 := by + decide +kernel + +theorem load_entry_313 : entryAt 313 = entry_313 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_313 : CacheEquation 313 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(313 < 6)), load_entry_313] + change forkRow [placeRow ⟨162, 4, 4, 5⟩ (denote cache_162), placeRow ⟨148, 5, 6, 3⟩ (denote cache_148)] = denote cache_313 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_313 + +theorem verified_row_314 : fork [place ⟨6, 3, 4, 5⟩ cache_6, place ⟨305, 0, 6, 4⟩ cache_305] = cache_314 := by + decide +kernel + +theorem load_entry_314 : entryAt 314 = entry_314 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_314 : CacheEquation 314 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(314 < 6)), load_entry_314] + change forkRow [placeRow ⟨6, 3, 4, 5⟩ (denote cache_6), placeRow ⟨305, 0, 6, 4⟩ (denote cache_305)] = denote cache_314 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_314 + +theorem verified_row_315 : fork [place ⟨6, 0, 5, 4⟩ cache_6, place ⟨296, 0, 4, 5⟩ cache_296] = cache_315 := by + decide +kernel + +theorem load_entry_315 : entryAt 315 = entry_315 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_315 : CacheEquation 315 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(315 < 6)), load_entry_315] + change forkRow [placeRow ⟨6, 0, 5, 4⟩ (denote cache_6), placeRow ⟨296, 0, 4, 5⟩ (denote cache_296)] = denote cache_315 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_315 + +theorem verified_row_316 : fork [place ⟨6, 6, 3, 4⟩ cache_6, place ⟨306, 0, 5, 8⟩ cache_306] = cache_316 := by + decide +kernel + +theorem load_entry_316 : entryAt 316 = entry_316 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_316 : CacheEquation 316 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(316 < 6)), load_entry_316] + change forkRow [placeRow ⟨6, 6, 3, 4⟩ (denote cache_6), placeRow ⟨306, 0, 5, 8⟩ (denote cache_306)] = denote cache_316 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_316 + +theorem verified_row_317 : fork [place ⟨263, 2, 6, 4⟩ cache_263, place ⟨26, 3, 4, 3⟩ cache_26, place ⟨99, 0, 5, 5⟩ cache_99] = cache_317 := by + decide +kernel + +theorem load_entry_317 : entryAt 317 = entry_317 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_317 : CacheEquation 317 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(317 < 6)), load_entry_317] + change forkRow [placeRow ⟨263, 2, 6, 4⟩ (denote cache_263), placeRow ⟨26, 3, 4, 3⟩ (denote cache_26), placeRow ⟨99, 0, 5, 5⟩ (denote cache_99)] = denote cache_317 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_317 + +theorem verified_row_318 : fork [place ⟨64, 3, 5, 1⟩ cache_64, place ⟨63, 0, 3, 5⟩ cache_63, place ⟨261, 0, 3, 4⟩ cache_261, place ⟨55, 1, 4, 5⟩ cache_55] = cache_318 := by + decide +kernel + +theorem load_entry_318 : entryAt 318 = entry_318 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_318 : CacheEquation 318 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(318 < 6)), load_entry_318] + change forkRow [placeRow ⟨64, 3, 5, 1⟩ (denote cache_64), placeRow ⟨63, 0, 3, 5⟩ (denote cache_63), placeRow ⟨261, 0, 3, 4⟩ (denote cache_261), placeRow ⟨55, 1, 4, 5⟩ (denote cache_55)] = denote cache_318 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_318 + +theorem verified_row_319 : fork [place ⟨39, 2, 3, 4⟩ cache_39, place ⟨109, 4, 0, 5⟩ cache_109, place ⟨266, 1, 4, 5⟩ cache_266, place ⟨122, 4, 4, 5⟩ cache_122] = cache_319 := by + decide +kernel + +theorem load_entry_319 : entryAt 319 = entry_319 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_319 : CacheEquation 319 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(319 < 6)), load_entry_319] + change forkRow [placeRow ⟨39, 2, 3, 4⟩ (denote cache_39), placeRow ⟨109, 4, 0, 5⟩ (denote cache_109), placeRow ⟨266, 1, 4, 5⟩ (denote cache_266), placeRow ⟨122, 4, 4, 5⟩ (denote cache_122)] = denote cache_319 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_319 + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Equations08.lean b/lean/OAI/Combinatorics/SnakyCertificate/Equations08.lean new file mode 100644 index 0000000000000000000000000000000000000000..aa28afd8084268f7b491450d1ddc8766927f5aa3 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Equations08.lean @@ -0,0 +1,530 @@ +import OAI.Combinatorics.SnakyCertificate.Cache +import OAI.Combinatorics.SnakyCertificate.TableList + +namespace OAI + +namespace SnakyCertificate.Check + +theorem verified_row_320 : fork [place ⟨19, 1, 4, 3⟩ cache_19, place ⟨267, 2, 6, 4⟩ cache_267, place ⟨115, 7, 4, 3⟩ cache_115] = cache_320 := by + decide +kernel + +theorem load_entry_320 : entryAt 320 = entry_320 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_320 : CacheEquation 320 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(320 < 6)), load_entry_320] + change forkRow [placeRow ⟨19, 1, 4, 3⟩ (denote cache_19), placeRow ⟨267, 2, 6, 4⟩ (denote cache_267), placeRow ⟨115, 7, 4, 3⟩ (denote cache_115)] = denote cache_320 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_320 + +theorem verified_row_321 : fork [place ⟨165, 1, 3, 4⟩ cache_165, place ⟨97, 0, 7, 5⟩ cache_97, place ⟨223, 3, 4, 7⟩ cache_223] = cache_321 := by + decide +kernel + +theorem load_entry_321 : entryAt 321 = entry_321 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_321 : CacheEquation 321 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(321 < 6)), load_entry_321] + change forkRow [placeRow ⟨165, 1, 3, 4⟩ (denote cache_165), placeRow ⟨97, 0, 7, 5⟩ (denote cache_97), placeRow ⟨223, 3, 4, 7⟩ (denote cache_223)] = denote cache_321 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_321 + +theorem verified_row_322 : fork [place ⟨96, 0, 1, 4⟩ cache_96, place ⟨205, 1, 5, 2⟩ cache_205] = cache_322 := by + decide +kernel + +theorem load_entry_322 : entryAt 322 = entry_322 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_322 : CacheEquation 322 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(322 < 6)), load_entry_322] + change forkRow [placeRow ⟨96, 0, 1, 4⟩ (denote cache_96), placeRow ⟨205, 1, 5, 2⟩ (denote cache_205)] = denote cache_322 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_322 + +theorem verified_row_323 : fork [place ⟨165, 6, 4, 5⟩ cache_165, place ⟨278, 0, 1, 4⟩ cache_278, place ⟨25, 1, 4, 5⟩ cache_25] = cache_323 := by + decide +kernel + +theorem load_entry_323 : entryAt 323 = entry_323 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_323 : CacheEquation 323 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(323 < 6)), load_entry_323] + change forkRow [placeRow ⟨165, 6, 4, 5⟩ (denote cache_165), placeRow ⟨278, 0, 1, 4⟩ (denote cache_278), placeRow ⟨25, 1, 4, 5⟩ (denote cache_25)] = denote cache_323 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_323 + +theorem verified_row_324 : fork [place ⟨6, 3, 4, 5⟩ cache_6, place ⟨298, 0, 3, 4⟩ cache_298] = cache_324 := by + decide +kernel + +theorem load_entry_324 : entryAt 324 = entry_324 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_324 : CacheEquation 324 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(324 < 6)), load_entry_324] + change forkRow [placeRow ⟨6, 3, 4, 5⟩ (denote cache_6), placeRow ⟨298, 0, 3, 4⟩ (denote cache_298)] = denote cache_324 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_324 + +theorem verified_row_325 : fork [place ⟨25, 0, 6, 5⟩ cache_25, place ⟨313, 1, 6, 4⟩ cache_313, place ⟨24, 2, 6, 3⟩ cache_24] = cache_325 := by + decide +kernel + +theorem load_entry_325 : entryAt 325 = entry_325 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_325 : CacheEquation 325 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(325 < 6)), load_entry_325] + change forkRow [placeRow ⟨25, 0, 6, 5⟩ (denote cache_25), placeRow ⟨313, 1, 6, 4⟩ (denote cache_313), placeRow ⟨24, 2, 6, 3⟩ (denote cache_24)] = denote cache_325 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_325 + +theorem verified_row_326 : fork [place ⟨63, 1, 5, 3⟩ cache_63, place ⟨255, 7, 0, 4⟩ cache_255] = cache_326 := by + decide +kernel + +theorem load_entry_326 : entryAt 326 = entry_326 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_326 : CacheEquation 326 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(326 < 6)), load_entry_326] + change forkRow [placeRow ⟨63, 1, 5, 3⟩ (denote cache_63), placeRow ⟨255, 7, 0, 4⟩ (denote cache_255)] = denote cache_326 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_326 + +theorem verified_row_327 : fork [place ⟨24, 2, 6, 3⟩ cache_24, place ⟨195, 4, 2, 4⟩ cache_195, place ⟨195, 0, 6, 4⟩ cache_195, place ⟨24, 6, 2, 3⟩ cache_24] = cache_327 := by + decide +kernel + +theorem load_entry_327 : entryAt 327 = entry_327 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_327 : CacheEquation 327 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(327 < 6)), load_entry_327] + change forkRow [placeRow ⟨24, 2, 6, 3⟩ (denote cache_24), placeRow ⟨195, 4, 2, 4⟩ (denote cache_195), placeRow ⟨195, 0, 6, 4⟩ (denote cache_195), placeRow ⟨24, 6, 2, 3⟩ (denote cache_24)] = denote cache_327 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_327 + +theorem verified_row_328 : fork [place ⟨49, 0, 4, 5⟩ cache_49, place ⟨44, 3, 4, 5⟩ cache_44, place ⟨285, 0, 3, 4⟩ cache_285] = cache_328 := by + decide +kernel + +theorem load_entry_328 : entryAt 328 = entry_328 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_328 : CacheEquation 328 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(328 < 6)), load_entry_328] + change forkRow [placeRow ⟨49, 0, 4, 5⟩ (denote cache_49), placeRow ⟨44, 3, 4, 5⟩ (denote cache_44), placeRow ⟨285, 0, 3, 4⟩ (denote cache_285)] = denote cache_328 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_328 + +theorem verified_row_329 : fork [place ⟨0, 7, 4, 6⟩ cache_0, place ⟨305, 0, 5, 5⟩ cache_305] = cache_329 := by + decide +kernel + +theorem load_entry_329 : entryAt 329 = entry_329 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_329 : CacheEquation 329 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(329 < 6)), load_entry_329] + change forkRow [placeRow ⟨0, 7, 4, 6⟩ (denote cache_0), placeRow ⟨305, 0, 5, 5⟩ (denote cache_305)] = denote cache_329 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_329 + +theorem verified_row_330 : fork [place ⟨63, 1, 5, 3⟩ cache_63, place ⟨268, 0, 4, 5⟩ cache_268, place ⟨144, 0, 5, 4⟩ cache_144, place ⟨154, 4, 5, 4⟩ cache_154, place ⟨155, 5, 5, 4⟩ cache_155] = cache_330 := by + decide +kernel + +theorem load_entry_330 : entryAt 330 = entry_330 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_330 : CacheEquation 330 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(330 < 6)), load_entry_330] + change forkRow [placeRow ⟨63, 1, 5, 3⟩ (denote cache_63), placeRow ⟨268, 0, 4, 5⟩ (denote cache_268), placeRow ⟨144, 0, 5, 4⟩ (denote cache_144), placeRow ⟨154, 4, 5, 4⟩ (denote cache_154), placeRow ⟨155, 5, 5, 4⟩ (denote cache_155)] = denote cache_330 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_330 + +theorem verified_row_331 : fork [place ⟨113, 0, 1, 4⟩ cache_113, place ⟨15, 0, 3, 4⟩ cache_15, place ⟨298, 4, 4, 5⟩ cache_298, place ⟨90, 2, 5, 4⟩ cache_90] = cache_331 := by + decide +kernel + +theorem load_entry_331 : entryAt 331 = entry_331 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_331 : CacheEquation 331 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(331 < 6)), load_entry_331] + change forkRow [placeRow ⟨113, 0, 1, 4⟩ (denote cache_113), placeRow ⟨15, 0, 3, 4⟩ (denote cache_15), placeRow ⟨298, 4, 4, 5⟩ (denote cache_298), placeRow ⟨90, 2, 5, 4⟩ (denote cache_90)] = denote cache_331 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_331 + +theorem verified_row_332 : fork [place ⟨67, 4, 3, 4⟩ cache_67, place ⟨289, 2, 5, 1⟩ cache_289] = cache_332 := by + decide +kernel + +theorem load_entry_332 : entryAt 332 = entry_332 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_332 : CacheEquation 332 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(332 < 6)), load_entry_332] + change forkRow [placeRow ⟨67, 4, 3, 4⟩ (denote cache_67), placeRow ⟨289, 2, 5, 1⟩ (denote cache_289)] = denote cache_332 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_332 + +theorem verified_row_333 : fork [place ⟨317, 0, 5, 4⟩ cache_317, place ⟨1, 5, 4, 3⟩ cache_1] = cache_333 := by + decide +kernel + +theorem load_entry_333 : entryAt 333 = entry_333 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_333 : CacheEquation 333 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(333 < 6)), load_entry_333] + change forkRow [placeRow ⟨317, 0, 5, 4⟩ (denote cache_317), placeRow ⟨1, 5, 4, 3⟩ (denote cache_1)] = denote cache_333 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_333 + +theorem verified_row_334 : fork [place ⟨67, 6, 3, 2⟩ cache_67, place ⟨289, 0, 5, 5⟩ cache_289] = cache_334 := by + decide +kernel + +theorem load_entry_334 : entryAt 334 = entry_334 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_334 : CacheEquation 334 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(334 < 6)), load_entry_334] + change forkRow [placeRow ⟨67, 6, 3, 2⟩ (denote cache_67), placeRow ⟨289, 0, 5, 5⟩ (denote cache_289)] = denote cache_334 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_334 + +theorem verified_row_335 : fork [place ⟨196, 3, 1, 3⟩ cache_196, place ⟨162, 1, 5, 4⟩ cache_162] = cache_335 := by + decide +kernel + +theorem load_entry_335 : entryAt 335 = entry_335 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_335 : CacheEquation 335 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(335 < 6)), load_entry_335] + change forkRow [placeRow ⟨196, 3, 1, 3⟩ (denote cache_196), placeRow ⟨162, 1, 5, 4⟩ (denote cache_162)] = denote cache_335 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_335 + +theorem verified_row_336 : fork [place ⟨25, 6, 2, 3⟩ cache_25, place ⟨199, 3, 2, 4⟩ cache_199, place ⟨65, 0, 6, 4⟩ cache_65, place ⟨304, 0, 2, 4⟩ cache_304] = cache_336 := by + decide +kernel + +theorem load_entry_336 : entryAt 336 = entry_336 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_336 : CacheEquation 336 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(336 < 6)), load_entry_336] + change forkRow [placeRow ⟨25, 6, 2, 3⟩ (denote cache_25), placeRow ⟨199, 3, 2, 4⟩ (denote cache_199), placeRow ⟨65, 0, 6, 4⟩ (denote cache_65), placeRow ⟨304, 0, 2, 4⟩ (denote cache_304)] = denote cache_336 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_336 + +theorem verified_row_337 : fork [place ⟨107, 3, 3, 7⟩ cache_107, place ⟨230, 2, 1, 5⟩ cache_230] = cache_337 := by + decide +kernel + +theorem load_entry_337 : entryAt 337 = entry_337 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_337 : CacheEquation 337 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(337 < 6)), load_entry_337] + change forkRow [placeRow ⟨107, 3, 3, 7⟩ (denote cache_107), placeRow ⟨230, 2, 1, 5⟩ (denote cache_230)] = denote cache_337 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_337 + +theorem verified_row_338 : fork [place ⟨241, 0, 6, 4⟩ cache_241, place ⟨275, 4, 2, 4⟩ cache_275, place ⟨107, 4, 2, 4⟩ cache_107] = cache_338 := by + decide +kernel + +theorem load_entry_338 : entryAt 338 = entry_338 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_338 : CacheEquation 338 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(338 < 6)), load_entry_338] + change forkRow [placeRow ⟨241, 0, 6, 4⟩ (denote cache_241), placeRow ⟨275, 4, 2, 4⟩ (denote cache_275), placeRow ⟨107, 4, 2, 4⟩ (denote cache_107)] = denote cache_338 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_338 + +theorem verified_row_339 : fork [place ⟨4, 1, 4, 3⟩ cache_4, place ⟨322, 0, 6, 4⟩ cache_322] = cache_339 := by + decide +kernel + +theorem load_entry_339 : entryAt 339 = entry_339 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_339 : CacheEquation 339 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(339 < 6)), load_entry_339] + change forkRow [placeRow ⟨4, 1, 4, 3⟩ (denote cache_4), placeRow ⟨322, 0, 6, 4⟩ (denote cache_322)] = denote cache_339 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_339 + +theorem verified_row_340 : fork [place ⟨25, 3, 3, 6⟩ cache_25, place ⟨300, 4, 4, 6⟩ cache_300, place ⟨24, 3, 3, 6⟩ cache_24] = cache_340 := by + decide +kernel + +theorem load_entry_340 : entryAt 340 = entry_340 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_340 : CacheEquation 340 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(340 < 6)), load_entry_340] + change forkRow [placeRow ⟨25, 3, 3, 6⟩ (denote cache_25), placeRow ⟨300, 4, 4, 6⟩ (denote cache_300), placeRow ⟨24, 3, 3, 6⟩ (denote cache_24)] = denote cache_340 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_340 + +theorem verified_row_341 : fork [place ⟨162, 5, 5, 4⟩ cache_162, place ⟨259, 4, 4, 5⟩ cache_259, place ⟨208, 2, 5, 4⟩ cache_208, place ⟨143, 0, 1, 3⟩ cache_143] = cache_341 := by + decide +kernel + +theorem load_entry_341 : entryAt 341 = entry_341 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_341 : CacheEquation 341 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(341 < 6)), load_entry_341] + change forkRow [placeRow ⟨162, 5, 5, 4⟩ (denote cache_162), placeRow ⟨259, 4, 4, 5⟩ (denote cache_259), placeRow ⟨208, 2, 5, 4⟩ (denote cache_208), placeRow ⟨143, 0, 1, 3⟩ (denote cache_143)] = denote cache_341 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_341 + +theorem verified_row_342 : fork [place ⟨210, 0, 5, 2⟩ cache_210, place ⟨88, 1, 4, 3⟩ cache_88, place ⟨260, 4, 4, 3⟩ cache_260, place ⟨290, 0, 4, 3⟩ cache_290] = cache_342 := by + decide +kernel + +theorem load_entry_342 : entryAt 342 = entry_342 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_342 : CacheEquation 342 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(342 < 6)), load_entry_342] + change forkRow [placeRow ⟨210, 0, 5, 2⟩ (denote cache_210), placeRow ⟨88, 1, 4, 3⟩ (denote cache_88), placeRow ⟨260, 4, 4, 3⟩ (denote cache_260), placeRow ⟨290, 0, 4, 3⟩ (denote cache_290)] = denote cache_342 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_342 + +theorem verified_row_343 : fork [place ⟨0, 5, 4, 5⟩ cache_0, place ⟨250, 0, 5, 4⟩ cache_250] = cache_343 := by + decide +kernel + +theorem load_entry_343 : entryAt 343 = entry_343 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_343 : CacheEquation 343 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(343 < 6)), load_entry_343] + change forkRow [placeRow ⟨0, 5, 4, 5⟩ (denote cache_0), placeRow ⟨250, 0, 5, 4⟩ (denote cache_250)] = denote cache_343 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_343 + +theorem verified_row_344 : fork [place ⟨7, 1, 5, 4⟩ cache_7, place ⟨108, 3, 4, 5⟩ cache_108, place ⟨262, 4, 5, 2⟩ cache_262] = cache_344 := by + decide +kernel + +theorem load_entry_344 : entryAt 344 = entry_344 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_344 : CacheEquation 344 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(344 < 6)), load_entry_344] + change forkRow [placeRow ⟨7, 1, 5, 4⟩ (denote cache_7), placeRow ⟨108, 3, 4, 5⟩ (denote cache_108), placeRow ⟨262, 4, 5, 2⟩ (denote cache_262)] = denote cache_344 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_344 + +theorem verified_row_345 : fork [place ⟨6, 0, 5, 5⟩ cache_6, place ⟨320, 4, 4, 7⟩ cache_320] = cache_345 := by + decide +kernel + +theorem load_entry_345 : entryAt 345 = entry_345 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_345 : CacheEquation 345 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(345 < 6)), load_entry_345] + change forkRow [placeRow ⟨6, 0, 5, 5⟩ (denote cache_6), placeRow ⟨320, 4, 4, 7⟩ (denote cache_320)] = denote cache_345 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_345 + +theorem verified_row_346 : fork [place ⟨60, 1, 4, 3⟩ cache_60, place ⟨255, 0, 1, 4⟩ cache_255, place ⟨276, 0, 1, 4⟩ cache_276] = cache_346 := by + decide +kernel + +theorem load_entry_346 : entryAt 346 = entry_346 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_346 : CacheEquation 346 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(346 < 6)), load_entry_346] + change forkRow [placeRow ⟨60, 1, 4, 3⟩ (denote cache_60), placeRow ⟨255, 0, 1, 4⟩ (denote cache_255), placeRow ⟨276, 0, 1, 4⟩ (denote cache_276)] = denote cache_346 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_346 + +theorem verified_row_347 : fork [place ⟨6, 6, 3, 4⟩ cache_6, place ⟨339, 0, 5, 8⟩ cache_339] = cache_347 := by + decide +kernel + +theorem load_entry_347 : entryAt 347 = entry_347 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_347 : CacheEquation 347 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(347 < 6)), load_entry_347] + change forkRow [placeRow ⟨6, 6, 3, 4⟩ (denote cache_6), placeRow ⟨339, 0, 5, 8⟩ (denote cache_339)] = denote cache_347 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_347 + +theorem verified_row_348 : fork [place ⟨312, 1, 5, 5⟩ cache_312, place ⟨114, 4, 3, 4⟩ cache_114, place ⟨139, 3, 4, 5⟩ cache_139] = cache_348 := by + decide +kernel + +theorem load_entry_348 : entryAt 348 = entry_348 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_348 : CacheEquation 348 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(348 < 6)), load_entry_348] + change forkRow [placeRow ⟨312, 1, 5, 5⟩ (denote cache_312), placeRow ⟨114, 4, 3, 4⟩ (denote cache_114), placeRow ⟨139, 3, 4, 5⟩ (denote cache_139)] = denote cache_348 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_348 + +theorem verified_row_349 : fork [place ⟨14, 1, 4, 5⟩ cache_14, place ⟨17, 1, 4, 5⟩ cache_17, place ⟨332, 0, 3, 4⟩ cache_332] = cache_349 := by + decide +kernel + +theorem load_entry_349 : entryAt 349 = entry_349 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_349 : CacheEquation 349 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(349 < 6)), load_entry_349] + change forkRow [placeRow ⟨14, 1, 4, 5⟩ (denote cache_14), placeRow ⟨17, 1, 4, 5⟩ (denote cache_17), placeRow ⟨332, 0, 3, 4⟩ (denote cache_332)] = denote cache_349 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_349 + +theorem verified_row_350 : fork [place ⟨24, 4, 2, 5⟩ cache_24, place ⟨107, 2, 6, 4⟩ cache_107, place ⟨271, 4, 5, 5⟩ cache_271, place ⟨215, 0, 5, 5⟩ cache_215] = cache_350 := by + decide +kernel + +theorem load_entry_350 : entryAt 350 = entry_350 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_350 : CacheEquation 350 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(350 < 6)), load_entry_350] + change forkRow [placeRow ⟨24, 4, 2, 5⟩ (denote cache_24), placeRow ⟨107, 2, 6, 4⟩ (denote cache_107), placeRow ⟨271, 4, 5, 5⟩ (denote cache_271), placeRow ⟨215, 0, 5, 5⟩ (denote cache_215)] = denote cache_350 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_350 + +theorem verified_row_351 : fork [place ⟨163, 0, 5, 4⟩ cache_163, place ⟨287, 4, 1, 4⟩ cache_287, place ⟨25, 4, 1, 5⟩ cache_25] = cache_351 := by + decide +kernel + +theorem load_entry_351 : entryAt 351 = entry_351 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_351 : CacheEquation 351 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(351 < 6)), load_entry_351] + change forkRow [placeRow ⟨163, 0, 5, 4⟩ (denote cache_163), placeRow ⟨287, 4, 1, 4⟩ (denote cache_287), placeRow ⟨25, 4, 1, 5⟩ (denote cache_25)] = denote cache_351 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_351 + +theorem verified_row_352 : fork [place ⟨214, 0, 4, 5⟩ cache_214, place ⟨91, 0, 3, 4⟩ cache_91, place ⟨63, 0, 3, 5⟩ cache_63, place ⟨344, 0, 4, 5⟩ cache_344, place ⟨180, 4, 4, 5⟩ cache_180] = cache_352 := by + decide +kernel + +theorem load_entry_352 : entryAt 352 = entry_352 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_352 : CacheEquation 352 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(352 < 6)), load_entry_352] + change forkRow [placeRow ⟨214, 0, 4, 5⟩ (denote cache_214), placeRow ⟨91, 0, 3, 4⟩ (denote cache_91), placeRow ⟨63, 0, 3, 5⟩ (denote cache_63), placeRow ⟨344, 0, 4, 5⟩ (denote cache_344), placeRow ⟨180, 4, 4, 5⟩ (denote cache_180)] = denote cache_352 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_352 + +theorem verified_row_353 : fork [place ⟨6, 4, 0, 5⟩ cache_6, place ⟨347, 0, 1, 3⟩ cache_347] = cache_353 := by + decide +kernel + +theorem load_entry_353 : entryAt 353 = entry_353 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_353 : CacheEquation 353 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(353 < 6)), load_entry_353] + change forkRow [placeRow ⟨6, 4, 0, 5⟩ (denote cache_6), placeRow ⟨347, 0, 1, 3⟩ (denote cache_347)] = denote cache_353 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_353 + +theorem verified_row_354 : fork [place ⟨138, 2, 5, 4⟩ cache_138, place ⟨114, 5, 4, 3⟩ cache_114, place ⟨312, 0, 5, 5⟩ cache_312, place ⟨182, 2, 2, 4⟩ cache_182] = cache_354 := by + decide +kernel + +theorem load_entry_354 : entryAt 354 = entry_354 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_354 : CacheEquation 354 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(354 < 6)), load_entry_354] + change forkRow [placeRow ⟨138, 2, 5, 4⟩ (denote cache_138), placeRow ⟨114, 5, 4, 3⟩ (denote cache_114), placeRow ⟨312, 0, 5, 5⟩ (denote cache_312), placeRow ⟨182, 2, 2, 4⟩ (denote cache_182)] = denote cache_354 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_354 + +theorem verified_row_355 : fork [place ⟨12, 2, 7, 3⟩ cache_12, place ⟨167, 0, 7, 4⟩ cache_167, place ⟨342, 0, 6, 6⟩ cache_342] = cache_355 := by + decide +kernel + +theorem load_entry_355 : entryAt 355 = entry_355 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_355 : CacheEquation 355 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(355 < 6)), load_entry_355] + change forkRow [placeRow ⟨12, 2, 7, 3⟩ (denote cache_12), placeRow ⟨167, 0, 7, 4⟩ (denote cache_167), placeRow ⟨342, 0, 6, 6⟩ (denote cache_342)] = denote cache_355 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_355 + +theorem verified_row_356 : fork [place ⟨24, 2, 6, 3⟩ cache_24, place ⟨24, 6, 2, 3⟩ cache_24, place ⟨211, 4, 2, 4⟩ cache_211, place ⟨179, 0, 6, 4⟩ cache_179] = cache_356 := by + decide +kernel + +theorem load_entry_356 : entryAt 356 = entry_356 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_356 : CacheEquation 356 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(356 < 6)), load_entry_356] + change forkRow [placeRow ⟨24, 2, 6, 3⟩ (denote cache_24), placeRow ⟨24, 6, 2, 3⟩ (denote cache_24), placeRow ⟨211, 4, 2, 4⟩ (denote cache_211), placeRow ⟨179, 0, 6, 4⟩ (denote cache_179)] = denote cache_356 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_356 + +theorem verified_row_357 : fork [place ⟨82, 6, 2, 3⟩ cache_82, place ⟨283, 0, 5, 6⟩ cache_283] = cache_357 := by + decide +kernel + +theorem load_entry_357 : entryAt 357 = entry_357 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_357 : CacheEquation 357 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(357 < 6)), load_entry_357] + change forkRow [placeRow ⟨82, 6, 2, 3⟩ (denote cache_82), placeRow ⟨283, 0, 5, 6⟩ (denote cache_283)] = denote cache_357 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_357 + +theorem verified_row_358 : fork [place ⟨6, 0, 5, 4⟩ cache_6, place ⟨346, 0, 4, 6⟩ cache_346] = cache_358 := by + decide +kernel + +theorem load_entry_358 : entryAt 358 = entry_358 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_358 : CacheEquation 358 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(358 < 6)), load_entry_358] + change forkRow [placeRow ⟨6, 0, 5, 4⟩ (denote cache_6), placeRow ⟨346, 0, 4, 6⟩ (denote cache_346)] = denote cache_358 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_358 + +theorem verified_row_359 : fork [place ⟨134, 0, 4, 6⟩ cache_134, place ⟨24, 7, 3, 2⟩ cache_24, place ⟨323, 0, 5, 5⟩ cache_323] = cache_359 := by + decide +kernel + +theorem load_entry_359 : entryAt 359 = entry_359 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_359 : CacheEquation 359 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(359 < 6)), load_entry_359] + change forkRow [placeRow ⟨134, 0, 4, 6⟩ (denote cache_134), placeRow ⟨24, 7, 3, 2⟩ (denote cache_24), placeRow ⟨323, 0, 5, 5⟩ (denote cache_323)] = denote cache_359 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_359 + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Equations09.lean b/lean/OAI/Combinatorics/SnakyCertificate/Equations09.lean new file mode 100644 index 0000000000000000000000000000000000000000..9e011070ad2a323756d94adc845560724d9e4ae6 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Equations09.lean @@ -0,0 +1,530 @@ +import OAI.Combinatorics.SnakyCertificate.Cache +import OAI.Combinatorics.SnakyCertificate.TableList + +namespace OAI + +namespace SnakyCertificate.Check + +theorem verified_row_360 : fork [place ⟨155, 4, 4, 5⟩ cache_155, place ⟨7, 3, 3, 4⟩ cache_7, place ⟨337, 0, 5, 2⟩ cache_337, place ⟨228, 4, 5, 2⟩ cache_228] = cache_360 := by + decide +kernel + +theorem load_entry_360 : entryAt 360 = entry_360 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_360 : CacheEquation 360 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(360 < 6)), load_entry_360] + change forkRow [placeRow ⟨155, 4, 4, 5⟩ (denote cache_155), placeRow ⟨7, 3, 3, 4⟩ (denote cache_7), placeRow ⟨337, 0, 5, 2⟩ (denote cache_337), placeRow ⟨228, 4, 5, 2⟩ (denote cache_228)] = denote cache_360 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_360 + +theorem verified_row_361 : fork [place ⟨6, 4, 3, 4⟩ cache_6, place ⟨352, 0, 4, 5⟩ cache_352] = cache_361 := by + decide +kernel + +theorem load_entry_361 : entryAt 361 = entry_361 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_361 : CacheEquation 361 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(361 < 6)), load_entry_361] + change forkRow [placeRow ⟨6, 4, 3, 4⟩ (denote cache_6), placeRow ⟨352, 0, 4, 5⟩ (denote cache_352)] = denote cache_361 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_361 + +theorem verified_row_362 : fork [place ⟨4, 0, 3, 4⟩ cache_4, place ⟨345, 0, 4, 3⟩ cache_345] = cache_362 := by + decide +kernel + +theorem load_entry_362 : entryAt 362 = entry_362 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_362 : CacheEquation 362 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(362 < 6)), load_entry_362] + change forkRow [placeRow ⟨4, 0, 3, 4⟩ (denote cache_4), placeRow ⟨345, 0, 4, 3⟩ (denote cache_345)] = denote cache_362 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_362 + +theorem verified_row_363 : fork [place ⟨137, 1, 4, 2⟩ cache_137, place ⟨248, 0, 2, 4⟩ cache_248] = cache_363 := by + decide +kernel + +theorem load_entry_363 : entryAt 363 = entry_363 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_363 : CacheEquation 363 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(363 < 6)), load_entry_363] + change forkRow [placeRow ⟨137, 1, 4, 2⟩ (denote cache_137), placeRow ⟨248, 0, 2, 4⟩ (denote cache_248)] = denote cache_363 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_363 + +theorem verified_row_364 : fork [place ⟨63, 0, 3, 5⟩ cache_63, place ⟨314, 2, 3, 1⟩ cache_314] = cache_364 := by + decide +kernel + +theorem load_entry_364 : entryAt 364 = entry_364 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_364 : CacheEquation 364 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(364 < 6)), load_entry_364] + change forkRow [placeRow ⟨63, 0, 3, 5⟩ (denote cache_63), placeRow ⟨314, 2, 3, 1⟩ (denote cache_314)] = denote cache_364 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_364 + +theorem verified_row_365 : fork [place ⟨6, 1, 4, 5⟩ cache_6, place ⟨354, 0, 4, 3⟩ cache_354] = cache_365 := by + decide +kernel + +theorem load_entry_365 : entryAt 365 = entry_365 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_365 : CacheEquation 365 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(365 < 6)), load_entry_365] + change forkRow [placeRow ⟨6, 1, 4, 5⟩ (denote cache_6), placeRow ⟨354, 0, 4, 3⟩ (denote cache_354)] = denote cache_365 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_365 + +theorem verified_row_366 : fork [place ⟨6, 3, 4, 5⟩ cache_6, place ⟨357, 0, 6, 2⟩ cache_357] = cache_366 := by + decide +kernel + +theorem load_entry_366 : entryAt 366 = entry_366 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_366 : CacheEquation 366 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(366 < 6)), load_entry_366] + change forkRow [placeRow ⟨6, 3, 4, 5⟩ (denote cache_6), placeRow ⟨357, 0, 6, 2⟩ (denote cache_357)] = denote cache_366 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_366 + +theorem verified_row_367 : fork [place ⟨6, 2, 5, 4⟩ cache_6, place ⟨361, 4, 4, 6⟩ cache_361] = cache_367 := by + decide +kernel + +theorem load_entry_367 : entryAt 367 = entry_367 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_367 : CacheEquation 367 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(367 < 6)), load_entry_367] + change forkRow [placeRow ⟨6, 2, 5, 4⟩ (denote cache_6), placeRow ⟨361, 4, 4, 6⟩ (denote cache_361)] = denote cache_367 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_367 + +theorem verified_row_368 : fork [place ⟨6, 1, 4, 5⟩ cache_6, place ⟨366, 0, 2, 4⟩ cache_366] = cache_368 := by + decide +kernel + +theorem load_entry_368 : entryAt 368 = entry_368 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_368 : CacheEquation 368 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(368 < 6)), load_entry_368] + change forkRow [placeRow ⟨6, 1, 4, 5⟩ (denote cache_6), placeRow ⟨366, 0, 2, 4⟩ (denote cache_366)] = denote cache_368 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_368 + +theorem verified_row_369 : fork [place ⟨6, 0, 5, 4⟩ cache_6, place ⟨367, 4, 1, 2⟩ cache_367] = cache_369 := by + decide +kernel + +theorem load_entry_369 : entryAt 369 = entry_369 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_369 : CacheEquation 369 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(369 < 6)), load_entry_369] + change forkRow [placeRow ⟨6, 0, 5, 4⟩ (denote cache_6), placeRow ⟨367, 4, 1, 2⟩ (denote cache_367)] = denote cache_369 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_369 + +theorem verified_row_370 : fork [place ⟨199, 3, 1, 4⟩ cache_199, place ⟨286, 1, 5, 4⟩ cache_286, place ⟨24, 6, 1, 3⟩ cache_24, place ⟨319, 0, 5, 3⟩ cache_319] = cache_370 := by + decide +kernel + +theorem load_entry_370 : entryAt 370 = entry_370 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_370 : CacheEquation 370 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(370 < 6)), load_entry_370] + change forkRow [placeRow ⟨199, 3, 1, 4⟩ (denote cache_199), placeRow ⟨286, 1, 5, 4⟩ (denote cache_286), placeRow ⟨24, 6, 1, 3⟩ (denote cache_24), placeRow ⟨319, 0, 5, 3⟩ (denote cache_319)] = denote cache_370 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_370 + +theorem verified_row_371 : fork [place ⟨267, 6, 2, 4⟩ cache_267, place ⟨137, 1, 4, 2⟩ cache_137] = cache_371 := by + decide +kernel + +theorem load_entry_371 : entryAt 371 = entry_371 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_371 : CacheEquation 371 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(371 < 6)), load_entry_371] + change forkRow [placeRow ⟨267, 6, 2, 4⟩ (denote cache_267), placeRow ⟨137, 1, 4, 2⟩ (denote cache_137)] = denote cache_371 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_371 + +theorem verified_row_372 : fork [place ⟨40, 1, 4, 3⟩ cache_40, place ⟨333, 0, 2, 4⟩ cache_333, place ⟨120, 1, 3, 3⟩ cache_120, place ⟨161, 0, 4, 2⟩ cache_161] = cache_372 := by + decide +kernel + +theorem load_entry_372 : entryAt 372 = entry_372 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_372 : CacheEquation 372 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(372 < 6)), load_entry_372] + change forkRow [placeRow ⟨40, 1, 4, 3⟩ (denote cache_40), placeRow ⟨333, 0, 2, 4⟩ (denote cache_333), placeRow ⟨120, 1, 3, 3⟩ (denote cache_120), placeRow ⟨161, 0, 4, 2⟩ (denote cache_161)] = denote cache_372 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_372 + +theorem verified_row_373 : fork [place ⟨156, 2, 7, 4⟩ cache_156, place ⟨226, 4, 3, 5⟩ cache_226, place ⟨80, 0, 5, 4⟩ cache_80, place ⟨327, 0, 5, 5⟩ cache_327, place ⟨156, 6, 3, 4⟩ cache_156] = cache_373 := by + decide +kernel + +theorem load_entry_373 : entryAt 373 = entry_373 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_373 : CacheEquation 373 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(373 < 6)), load_entry_373] + change forkRow [placeRow ⟨156, 2, 7, 4⟩ (denote cache_156), placeRow ⟨226, 4, 3, 5⟩ (denote cache_226), placeRow ⟨80, 0, 5, 4⟩ (denote cache_80), placeRow ⟨327, 0, 5, 5⟩ (denote cache_327), placeRow ⟨156, 6, 3, 4⟩ (denote cache_156)] = denote cache_373 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_373 + +theorem verified_row_374 : fork [place ⟨65, 4, 3, 4⟩ cache_65, place ⟨335, 0, 7, 4⟩ cache_335, place ⟨24, 2, 7, 3⟩ cache_24, place ⟨163, 4, 3, 4⟩ cache_163] = cache_374 := by + decide +kernel + +theorem load_entry_374 : entryAt 374 = entry_374 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_374 : CacheEquation 374 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(374 < 6)), load_entry_374] + change forkRow [placeRow ⟨65, 4, 3, 4⟩ (denote cache_65), placeRow ⟨335, 0, 7, 4⟩ (denote cache_335), placeRow ⟨24, 2, 7, 3⟩ (denote cache_24), placeRow ⟨163, 4, 3, 4⟩ (denote cache_163)] = denote cache_374 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_374 + +theorem verified_row_375 : fork [place ⟨24, 3, 3, 6⟩ cache_24, place ⟨327, 6, 3, 3⟩ cache_327] = cache_375 := by + decide +kernel + +theorem load_entry_375 : entryAt 375 = entry_375 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_375 : CacheEquation 375 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(375 < 6)), load_entry_375] + change forkRow [placeRow ⟨24, 3, 3, 6⟩ (denote cache_24), placeRow ⟨327, 6, 3, 3⟩ (denote cache_327)] = denote cache_375 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_375 + +theorem verified_row_376 : fork [place ⟨162, 1, 5, 4⟩ cache_162, place ⟨285, 3, 1, 3⟩ cache_285] = cache_376 := by + decide +kernel + +theorem load_entry_376 : entryAt 376 = entry_376 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_376 : CacheEquation 376 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(376 < 6)), load_entry_376] + change forkRow [placeRow ⟨162, 1, 5, 4⟩ (denote cache_162), placeRow ⟨285, 3, 1, 3⟩ (denote cache_285)] = denote cache_376 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_376 + +theorem verified_row_377 : fork [place ⟨29, 3, 3, 0⟩ cache_29, place ⟨362, 0, 7, 2⟩ cache_362] = cache_377 := by + decide +kernel + +theorem load_entry_377 : entryAt 377 = entry_377 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_377 : CacheEquation 377 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(377 < 6)), load_entry_377] + change forkRow [placeRow ⟨29, 3, 3, 0⟩ (denote cache_29), placeRow ⟨362, 0, 7, 2⟩ (denote cache_362)] = denote cache_377 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_377 + +theorem verified_row_378 : fork [place ⟨295, 0, 5, 4⟩ cache_295, place ⟨176, 4, 1, 4⟩ cache_176, place ⟨183, 4, 1, 4⟩ cache_183, place ⟨172, 6, 1, 4⟩ cache_172, place ⟨294, 4, 1, 4⟩ cache_294] = cache_378 := by + decide +kernel + +theorem load_entry_378 : entryAt 378 = entry_378 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_378 : CacheEquation 378 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(378 < 6)), load_entry_378] + change forkRow [placeRow ⟨295, 0, 5, 4⟩ (denote cache_295), placeRow ⟨176, 4, 1, 4⟩ (denote cache_176), placeRow ⟨183, 4, 1, 4⟩ (denote cache_183), placeRow ⟨172, 6, 1, 4⟩ (denote cache_172), placeRow ⟨294, 4, 1, 4⟩ (denote cache_294)] = denote cache_378 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_378 + +theorem verified_row_379 : fork [place ⟨63, 0, 3, 5⟩ cache_63, place ⟨64, 1, 3, 1⟩ cache_64, place ⟨55, 3, 4, 5⟩ cache_55, place ⟨368, 0, 5, 4⟩ cache_368] = cache_379 := by + decide +kernel + +theorem load_entry_379 : entryAt 379 = entry_379 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_379 : CacheEquation 379 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(379 < 6)), load_entry_379] + change forkRow [placeRow ⟨63, 0, 3, 5⟩ (denote cache_63), placeRow ⟨64, 1, 3, 1⟩ (denote cache_64), placeRow ⟨55, 3, 4, 5⟩ (denote cache_55), placeRow ⟨368, 0, 5, 4⟩ (denote cache_368)] = denote cache_379 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_379 + +theorem verified_row_380 : fork [place ⟨101, 4, 2, 5⟩ cache_101, place ⟨271, 0, 2, 5⟩ cache_271, place ⟨223, 0, 5, 4⟩ cache_223, place ⟨192, 3, 1, 4⟩ cache_192] = cache_380 := by + decide +kernel + +theorem load_entry_380 : entryAt 380 = entry_380 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_380 : CacheEquation 380 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(380 < 6)), load_entry_380] + change forkRow [placeRow ⟨101, 4, 2, 5⟩ (denote cache_101), placeRow ⟨271, 0, 2, 5⟩ (denote cache_271), placeRow ⟨223, 0, 5, 4⟩ (denote cache_223), placeRow ⟨192, 3, 1, 4⟩ (denote cache_192)] = denote cache_380 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_380 + +theorem verified_row_381 : fork [place ⟨211, 6, 3, 4⟩ cache_211, place ⟨24, 0, 7, 5⟩ cache_24, place ⟨163, 4, 3, 4⟩ cache_163, place ⟨341, 0, 7, 4⟩ cache_341] = cache_381 := by + decide +kernel + +theorem load_entry_381 : entryAt 381 = entry_381 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_381 : CacheEquation 381 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(381 < 6)), load_entry_381] + change forkRow [placeRow ⟨211, 6, 3, 4⟩ (denote cache_211), placeRow ⟨24, 0, 7, 5⟩ (denote cache_24), placeRow ⟨163, 4, 3, 4⟩ (denote cache_163), placeRow ⟨341, 0, 7, 4⟩ (denote cache_341)] = denote cache_381 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_381 + +theorem verified_row_382 : fork [place ⟨124, 1, 5, 3⟩ cache_124, place ⟨2, 7, 4, 3⟩ cache_2] = cache_382 := by + decide +kernel + +theorem load_entry_382 : entryAt 382 = entry_382 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_382 : CacheEquation 382 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(382 < 6)), load_entry_382] + change forkRow [placeRow ⟨124, 1, 5, 3⟩ (denote cache_124), placeRow ⟨2, 7, 4, 3⟩ (denote cache_2)] = denote cache_382 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_382 + +theorem verified_row_383 : fork [place ⟨192, 3, 2, 4⟩ cache_192, place ⟨271, 0, 3, 5⟩ cache_271, place ⟨197, 0, 6, 4⟩ cache_197, place ⟨172, 0, 6, 4⟩ cache_172, place ⟨215, 4, 3, 5⟩ cache_215] = cache_383 := by + decide +kernel + +theorem load_entry_383 : entryAt 383 = entry_383 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_383 : CacheEquation 383 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(383 < 6)), load_entry_383] + change forkRow [placeRow ⟨192, 3, 2, 4⟩ (denote cache_192), placeRow ⟨271, 0, 3, 5⟩ (denote cache_271), placeRow ⟨197, 0, 6, 4⟩ (denote cache_197), placeRow ⟨172, 0, 6, 4⟩ (denote cache_172), placeRow ⟨215, 4, 3, 5⟩ (denote cache_215)] = denote cache_383 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_383 + +theorem verified_row_384 : fork [place ⟨173, 2, 6, 4⟩ cache_173, place ⟨282, 4, 2, 4⟩ cache_282, place ⟨220, 2, 6, 4⟩ cache_220, place ⟨246, 2, 6, 4⟩ cache_246, place ⟨263, 2, 6, 4⟩ cache_263, place ⟨183, 6, 2, 4⟩ cache_183, place ⟨295, 0, 6, 4⟩ cache_295] = cache_384 := by + decide +kernel + +theorem load_entry_384 : entryAt 384 = entry_384 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_384 : CacheEquation 384 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(384 < 6)), load_entry_384] + change forkRow [placeRow ⟨173, 2, 6, 4⟩ (denote cache_173), placeRow ⟨282, 4, 2, 4⟩ (denote cache_282), placeRow ⟨220, 2, 6, 4⟩ (denote cache_220), placeRow ⟨246, 2, 6, 4⟩ (denote cache_246), placeRow ⟨263, 2, 6, 4⟩ (denote cache_263), placeRow ⟨183, 6, 2, 4⟩ (denote cache_183), placeRow ⟨295, 0, 6, 4⟩ (denote cache_295)] = denote cache_384 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_384 + +theorem verified_row_385 : fork [place ⟨63, 1, 5, 3⟩ cache_63, place ⟨64, 2, 1, 5⟩ cache_64, place ⟨55, 0, 5, 4⟩ cache_55, place ⟨369, 4, 1, 5⟩ cache_369] = cache_385 := by + decide +kernel + +theorem load_entry_385 : entryAt 385 = entry_385 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_385 : CacheEquation 385 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(385 < 6)), load_entry_385] + change forkRow [placeRow ⟨63, 1, 5, 3⟩ (denote cache_63), placeRow ⟨64, 2, 1, 5⟩ (denote cache_64), placeRow ⟨55, 0, 5, 4⟩ (denote cache_55), placeRow ⟨369, 4, 1, 5⟩ (denote cache_369)] = denote cache_385 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_385 + +theorem verified_row_386 : fork [place ⟨217, 4, 1, 4⟩ cache_217, place ⟨172, 0, 5, 4⟩ cache_172, place ⟨173, 4, 1, 4⟩ cache_173, place ⟨217, 0, 5, 4⟩ cache_217, place ⟨294, 0, 5, 4⟩ cache_294, place ⟨294, 4, 1, 4⟩ cache_294] = cache_386 := by + decide +kernel + +theorem load_entry_386 : entryAt 386 = entry_386 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_386 : CacheEquation 386 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(386 < 6)), load_entry_386] + change forkRow [placeRow ⟨217, 4, 1, 4⟩ (denote cache_217), placeRow ⟨172, 0, 5, 4⟩ (denote cache_172), placeRow ⟨173, 4, 1, 4⟩ (denote cache_173), placeRow ⟨217, 0, 5, 4⟩ (denote cache_217), placeRow ⟨294, 0, 5, 4⟩ (denote cache_294), placeRow ⟨294, 4, 1, 4⟩ (denote cache_294)] = denote cache_386 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_386 + +theorem verified_row_387 : fork [place ⟨14, 1, 4, 6⟩ cache_14, place ⟨370, 0, 5, 4⟩ cache_370] = cache_387 := by + decide +kernel + +theorem load_entry_387 : entryAt 387 = entry_387 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_387 : CacheEquation 387 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(387 < 6)), load_entry_387] + change forkRow [placeRow ⟨14, 1, 4, 6⟩ (denote cache_14), placeRow ⟨370, 0, 5, 4⟩ (denote cache_370)] = denote cache_387 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_387 + +theorem verified_row_388 : fork [place ⟨6, 3, 4, 5⟩ cache_6, place ⟨374, 0, 3, 4⟩ cache_374] = cache_388 := by + decide +kernel + +theorem load_entry_388 : entryAt 388 = entry_388 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_388 : CacheEquation 388 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(388 < 6)), load_entry_388] + change forkRow [placeRow ⟨6, 3, 4, 5⟩ (denote cache_6), placeRow ⟨374, 0, 3, 4⟩ (denote cache_374)] = denote cache_388 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_388 + +theorem verified_row_389 : fork [place ⟨197, 5, 4, 1⟩ cache_197, place ⟨215, 7, 3, 2⟩ cache_215, place ⟨271, 3, 3, 2⟩ cache_271, place ⟨236, 0, 5, 5⟩ cache_236, place ⟨192, 6, 4, 1⟩ cache_192] = cache_389 := by + decide +kernel + +theorem load_entry_389 : entryAt 389 = entry_389 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_389 : CacheEquation 389 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(389 < 6)), load_entry_389] + change forkRow [placeRow ⟨197, 5, 4, 1⟩ (denote cache_197), placeRow ⟨215, 7, 3, 2⟩ (denote cache_215), placeRow ⟨271, 3, 3, 2⟩ (denote cache_271), placeRow ⟨236, 0, 5, 5⟩ (denote cache_236), placeRow ⟨192, 6, 4, 1⟩ (denote cache_192)] = denote cache_389 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_389 + +theorem verified_row_390 : fork [place ⟨372, 2, 5, 0⟩ cache_372, place ⟨167, 5, 4, 1⟩ cache_167, place ⟨12, 7, 3, 1⟩ cache_12] = cache_390 := by + decide +kernel + +theorem load_entry_390 : entryAt 390 = entry_390 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_390 : CacheEquation 390 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(390 < 6)), load_entry_390] + change forkRow [placeRow ⟨372, 2, 5, 0⟩ (denote cache_372), placeRow ⟨167, 5, 4, 1⟩ (denote cache_167), placeRow ⟨12, 7, 3, 1⟩ (denote cache_12)] = denote cache_390 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_390 + +theorem verified_row_391 : fork [place ⟨6, 5, 5, 1⟩ cache_6, place ⟨388, 0, 3, 5⟩ cache_388] = cache_391 := by + decide +kernel + +theorem load_entry_391 : entryAt 391 = entry_391 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_391 : CacheEquation 391 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(391 < 6)), load_entry_391] + change forkRow [placeRow ⟨6, 5, 5, 1⟩ (denote cache_6), placeRow ⟨388, 0, 3, 5⟩ (denote cache_388)] = denote cache_391 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_391 + +theorem verified_row_392 : fork [place ⟨24, 7, 3, 1⟩ cache_24, place ⟨107, 1, 4, 5⟩ cache_107, place ⟨236, 0, 5, 5⟩ cache_236, place ⟨364, 2, 4, 1⟩ cache_364] = cache_392 := by + decide +kernel + +theorem load_entry_392 : entryAt 392 = entry_392 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_392 : CacheEquation 392 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(392 < 6)), load_entry_392] + change forkRow [placeRow ⟨24, 7, 3, 1⟩ (denote cache_24), placeRow ⟨107, 1, 4, 5⟩ (denote cache_107), placeRow ⟨236, 0, 5, 5⟩ (denote cache_236), placeRow ⟨364, 2, 4, 1⟩ (denote cache_364)] = denote cache_392 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_392 + +theorem verified_row_393 : fork [place ⟨107, 3, 4, 5⟩ cache_107, place ⟨348, 0, 6, 3⟩ cache_348, place ⟨65, 3, 4, 5⟩ cache_65, place ⟨303, 0, 4, 5⟩ cache_303] = cache_393 := by + decide +kernel + +theorem load_entry_393 : entryAt 393 = entry_393 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_393 : CacheEquation 393 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(393 < 6)), load_entry_393] + change forkRow [placeRow ⟨107, 3, 4, 5⟩ (denote cache_107), placeRow ⟨348, 0, 6, 3⟩ (denote cache_348), placeRow ⟨65, 3, 4, 5⟩ (denote cache_65), placeRow ⟨303, 0, 4, 5⟩ (denote cache_303)] = denote cache_393 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_393 + +theorem verified_row_394 : fork [place ⟨226, 4, 1, 4⟩ cache_226, place ⟨226, 0, 5, 4⟩ cache_226, place ⟨327, 4, 3, 4⟩ cache_327, place ⟨327, 6, 3, 3⟩ cache_327, place ⟨226, 6, 1, 3⟩ cache_226, place ⟨226, 2, 5, 3⟩ cache_226] = cache_394 := by + decide +kernel + +theorem load_entry_394 : entryAt 394 = entry_394 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_394 : CacheEquation 394 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(394 < 6)), load_entry_394] + change forkRow [placeRow ⟨226, 4, 1, 4⟩ (denote cache_226), placeRow ⟨226, 0, 5, 4⟩ (denote cache_226), placeRow ⟨327, 4, 3, 4⟩ (denote cache_327), placeRow ⟨327, 6, 3, 3⟩ (denote cache_327), placeRow ⟨226, 6, 1, 3⟩ (denote cache_226), placeRow ⟨226, 2, 5, 3⟩ (denote cache_226)] = denote cache_394 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_394 + +theorem verified_row_395 : fork [place ⟨211, 4, 2, 4⟩ cache_211, place ⟨376, 0, 6, 4⟩ cache_376, place ⟨24, 2, 6, 3⟩ cache_24, place ⟨236, 3, 2, 5⟩ cache_236] = cache_395 := by + decide +kernel + +theorem load_entry_395 : entryAt 395 = entry_395 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_395 : CacheEquation 395 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(395 < 6)), load_entry_395] + change forkRow [placeRow ⟨211, 4, 2, 4⟩ (denote cache_211), placeRow ⟨376, 0, 6, 4⟩ (denote cache_376), placeRow ⟨24, 2, 6, 3⟩ (denote cache_24), placeRow ⟨236, 3, 2, 5⟩ (denote cache_236)] = denote cache_395 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_395 + +theorem verified_row_396 : fork [place ⟨107, 3, 4, 5⟩ cache_107, place ⟨365, 1, 7, 3⟩ cache_365, place ⟨303, 0, 4, 5⟩ cache_303, place ⟨65, 3, 4, 5⟩ cache_65] = cache_396 := by + decide +kernel + +theorem load_entry_396 : entryAt 396 = entry_396 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_396 : CacheEquation 396 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(396 < 6)), load_entry_396] + change forkRow [placeRow ⟨107, 3, 4, 5⟩ (denote cache_107), placeRow ⟨365, 1, 7, 3⟩ (denote cache_365), placeRow ⟨303, 0, 4, 5⟩ (denote cache_303), placeRow ⟨65, 3, 4, 5⟩ (denote cache_65)] = denote cache_396 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_396 + +theorem verified_row_397 : fork [place ⟨24, 3, 4, 5⟩ cache_24, place ⟨374, 0, 3, 4⟩ cache_374, place ⟨65, 5, 5, 1⟩ cache_65] = cache_397 := by + decide +kernel + +theorem load_entry_397 : entryAt 397 = entry_397 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_397 : CacheEquation 397 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(397 < 6)), load_entry_397] + change forkRow [placeRow ⟨24, 3, 4, 5⟩ (denote cache_24), placeRow ⟨374, 0, 3, 4⟩ (denote cache_374), placeRow ⟨65, 5, 5, 1⟩ (denote cache_65)] = denote cache_397 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_397 + +theorem verified_row_398 : fork [place ⟨257, 0, 1, 3⟩ cache_257, place ⟨363, 0, 5, 4⟩ cache_363, place ⟨130, 1, 4, 2⟩ cache_130, place ⟨177, 1, 4, 2⟩ cache_177] = cache_398 := by + decide +kernel + +theorem load_entry_398 : entryAt 398 = entry_398 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_398 : CacheEquation 398 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(398 < 6)), load_entry_398] + change forkRow [placeRow ⟨257, 0, 1, 3⟩ (denote cache_257), placeRow ⟨363, 0, 5, 4⟩ (denote cache_363), placeRow ⟨130, 1, 4, 2⟩ (denote cache_130), placeRow ⟨177, 1, 4, 2⟩ (denote cache_177)] = denote cache_398 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_398 + +theorem verified_row_399 : fork [place ⟨192, 6, 4, 1⟩ cache_192, place ⟨271, 3, 3, 2⟩ cache_271, place ⟨173, 1, 4, 5⟩ cache_173, place ⟨319, 1, 3, 5⟩ cache_319, place ⟨215, 7, 3, 2⟩ cache_215] = cache_399 := by + decide +kernel + +theorem load_entry_399 : entryAt 399 = entry_399 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_399 : CacheEquation 399 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(399 < 6)), load_entry_399] + change forkRow [placeRow ⟨192, 6, 4, 1⟩ (denote cache_192), placeRow ⟨271, 3, 3, 2⟩ (denote cache_271), placeRow ⟨173, 1, 4, 5⟩ (denote cache_173), placeRow ⟨319, 1, 3, 5⟩ (denote cache_319), placeRow ⟨215, 7, 3, 2⟩ (denote cache_215)] = denote cache_399 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_399 + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Equations10.lean b/lean/OAI/Combinatorics/SnakyCertificate/Equations10.lean new file mode 100644 index 0000000000000000000000000000000000000000..2d70320fbfe8b06005dc317fc912151d05065330 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Equations10.lean @@ -0,0 +1,530 @@ +import OAI.Combinatorics.SnakyCertificate.Cache +import OAI.Combinatorics.SnakyCertificate.TableList + +namespace OAI + +namespace SnakyCertificate.Check + +theorem verified_row_400 : fork [place ⟨283, 4, 2, 4⟩ cache_283, place ⟨252, 4, 2, 4⟩ cache_252, place ⟨176, 4, 2, 4⟩ cache_176, place ⟨197, 0, 6, 4⟩ cache_197, place ⟨283, 0, 6, 4⟩ cache_283, place ⟨245, 4, 2, 4⟩ cache_245] = cache_400 := by + decide +kernel + +theorem load_entry_400 : entryAt 400 = entry_400 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_400 : CacheEquation 400 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(400 < 6)), load_entry_400] + change forkRow [placeRow ⟨283, 4, 2, 4⟩ (denote cache_283), placeRow ⟨252, 4, 2, 4⟩ (denote cache_252), placeRow ⟨176, 4, 2, 4⟩ (denote cache_176), placeRow ⟨197, 0, 6, 4⟩ (denote cache_197), placeRow ⟨283, 0, 6, 4⟩ (denote cache_283), placeRow ⟨245, 4, 2, 4⟩ (denote cache_245)] = denote cache_400 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_400 + +theorem verified_row_401 : fork [place ⟨24, 7, 3, 2⟩ cache_24, place ⟨286, 0, 4, 6⟩ cache_286, place ⟨364, 2, 4, 2⟩ cache_364, place ⟨319, 1, 3, 6⟩ cache_319] = cache_401 := by + decide +kernel + +theorem load_entry_401 : entryAt 401 = entry_401 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_401 : CacheEquation 401 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(401 < 6)), load_entry_401] + change forkRow [placeRow ⟨24, 7, 3, 2⟩ (denote cache_24), placeRow ⟨286, 0, 4, 6⟩ (denote cache_286), placeRow ⟨364, 2, 4, 2⟩ (denote cache_364), placeRow ⟨319, 1, 3, 6⟩ (denote cache_319)] = denote cache_401 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_401 + +theorem verified_row_402 : fork [place ⟨29, 3, 3, 0⟩ cache_29, place ⟨384, 0, 5, 4⟩ cache_384] = cache_402 := by + decide +kernel + +theorem load_entry_402 : entryAt 402 = entry_402 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_402 : CacheEquation 402 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(402 < 6)), load_entry_402] + change forkRow [placeRow ⟨29, 3, 3, 0⟩ (denote cache_29), placeRow ⟨384, 0, 5, 4⟩ (denote cache_384)] = denote cache_402 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_402 + +theorem verified_row_403 : fork [place ⟨202, 1, 4, 5⟩ cache_202, place ⟨180, 0, 4, 5⟩ cache_180, place ⟨314, 4, 5, 4⟩ cache_314, place ⟨63, 0, 3, 5⟩ cache_63, place ⟨388, 0, 3, 4⟩ cache_388] = cache_403 := by + decide +kernel + +theorem load_entry_403 : entryAt 403 = entry_403 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_403 : CacheEquation 403 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(403 < 6)), load_entry_403] + change forkRow [placeRow ⟨202, 1, 4, 5⟩ (denote cache_202), placeRow ⟨180, 0, 4, 5⟩ (denote cache_180), placeRow ⟨314, 4, 5, 4⟩ (denote cache_314), placeRow ⟨63, 0, 3, 5⟩ (denote cache_63), placeRow ⟨388, 0, 3, 4⟩ (denote cache_388)] = denote cache_403 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_403 + +theorem verified_row_404 : fork [place ⟨82, 6, 2, 3⟩ cache_82, place ⟨388, 4, 4, 6⟩ cache_388] = cache_404 := by + decide +kernel + +theorem load_entry_404 : entryAt 404 = entry_404 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_404 : CacheEquation 404 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(404 < 6)), load_entry_404] + change forkRow [placeRow ⟨82, 6, 2, 3⟩ (denote cache_82), placeRow ⟨388, 4, 4, 6⟩ (denote cache_388)] = denote cache_404 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_404 + +theorem verified_row_405 : fork [place ⟨391, 0, 4, 3⟩ cache_391, place ⟨301, 0, 5, 2⟩ cache_301, place ⟨42, 1, 4, 3⟩ cache_42] = cache_405 := by + decide +kernel + +theorem load_entry_405 : entryAt 405 = entry_405 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_405 : CacheEquation 405 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(405 < 6)), load_entry_405] + change forkRow [placeRow ⟨391, 0, 4, 3⟩ (denote cache_391), placeRow ⟨301, 0, 5, 2⟩ (denote cache_301), placeRow ⟨42, 1, 4, 3⟩ (denote cache_42)] = denote cache_405 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_405 + +theorem verified_row_406 : fork [place ⟨295, 1, 4, 5⟩ cache_295, place ⟨172, 7, 4, 1⟩ cache_172, place ⟨245, 3, 4, 5⟩ cache_245, place ⟨197, 5, 4, 1⟩ cache_197, place ⟨236, 0, 5, 5⟩ cache_236, place ⟨176, 3, 4, 5⟩ cache_176, place ⟨364, 2, 4, 1⟩ cache_364] = cache_406 := by + decide +kernel + +theorem load_entry_406 : entryAt 406 = entry_406 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_406 : CacheEquation 406 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(406 < 6)), load_entry_406] + change forkRow [placeRow ⟨295, 1, 4, 5⟩ (denote cache_295), placeRow ⟨172, 7, 4, 1⟩ (denote cache_172), placeRow ⟨245, 3, 4, 5⟩ (denote cache_245), placeRow ⟨197, 5, 4, 1⟩ (denote cache_197), placeRow ⟨236, 0, 5, 5⟩ (denote cache_236), placeRow ⟨176, 3, 4, 5⟩ (denote cache_176), placeRow ⟨364, 2, 4, 1⟩ (denote cache_364)] = denote cache_406 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_406 + +theorem verified_row_407 : fork [place ⟨285, 0, 3, 7⟩ cache_285, place ⟨314, 6, 5, 4⟩ cache_314] = cache_407 := by + decide +kernel + +theorem load_entry_407 : entryAt 407 = entry_407 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_407 : CacheEquation 407 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(407 < 6)), load_entry_407] + change forkRow [placeRow ⟨285, 0, 3, 7⟩ (denote cache_285), placeRow ⟨314, 6, 5, 4⟩ (denote cache_314)] = denote cache_407 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_407 + +theorem verified_row_408 : fork [place ⟨357, 0, 5, 2⟩ cache_357, place ⟨229, 7, 2, 4⟩ cache_229, place ⟨223, 4, 2, 4⟩ cache_223, place ⟨223, 0, 6, 4⟩ cache_223] = cache_408 := by + decide +kernel + +theorem load_entry_408 : entryAt 408 = entry_408 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_408 : CacheEquation 408 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(408 < 6)), load_entry_408] + change forkRow [placeRow ⟨357, 0, 5, 2⟩ (denote cache_357), placeRow ⟨229, 7, 2, 4⟩ (denote cache_229), placeRow ⟨223, 4, 2, 4⟩ (denote cache_223), placeRow ⟨223, 0, 6, 4⟩ (denote cache_223)] = denote cache_408 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_408 + +theorem verified_row_409 : fork [place ⟨136, 6, 4, 3⟩ cache_136, place ⟨384, 0, 5, 4⟩ cache_384, place ⟨133, 4, 4, 3⟩ cache_133, place ⟨110, 3, 4, 3⟩ cache_110] = cache_409 := by + decide +kernel + +theorem load_entry_409 : entryAt 409 = entry_409 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_409 : CacheEquation 409 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(409 < 6)), load_entry_409] + change forkRow [placeRow ⟨136, 6, 4, 3⟩ (denote cache_136), placeRow ⟨384, 0, 5, 4⟩ (denote cache_384), placeRow ⟨133, 4, 4, 3⟩ (denote cache_133), placeRow ⟨110, 3, 4, 3⟩ (denote cache_110)] = denote cache_409 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_409 + +theorem verified_row_410 : fork [place ⟨0, 4, 5, 4⟩ cache_0, place ⟨405, 0, 3, 7⟩ cache_405] = cache_410 := by + decide +kernel + +theorem load_entry_410 : entryAt 410 = entry_410 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_410 : CacheEquation 410 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(410 < 6)), load_entry_410] + change forkRow [placeRow ⟨0, 4, 5, 4⟩ (denote cache_0), placeRow ⟨405, 0, 3, 7⟩ (denote cache_405)] = denote cache_410 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_410 + +theorem verified_row_411 : fork [place ⟨252, 0, 7, 4⟩ cache_252, place ⟨263, 0, 7, 4⟩ cache_263, place ⟨300, 3, 3, 4⟩ cache_300, place ⟨379, 1, 7, 4⟩ cache_379, place ⟨173, 0, 7, 4⟩ cache_173, place ⟨246, 0, 7, 4⟩ cache_246] = cache_411 := by + decide +kernel + +theorem load_entry_411 : entryAt 411 = entry_411 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_411 : CacheEquation 411 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(411 < 6)), load_entry_411] + change forkRow [placeRow ⟨252, 0, 7, 4⟩ (denote cache_252), placeRow ⟨263, 0, 7, 4⟩ (denote cache_263), placeRow ⟨300, 3, 3, 4⟩ (denote cache_300), placeRow ⟨379, 1, 7, 4⟩ (denote cache_379), placeRow ⟨173, 0, 7, 4⟩ (denote cache_173), placeRow ⟨246, 0, 7, 4⟩ (denote cache_246)] = denote cache_411 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_411 + +theorem verified_row_412 : fork [place ⟨0, 0, 0, 3⟩ cache_0, place ⟨403, 4, 3, 6⟩ cache_403] = cache_412 := by + decide +kernel + +theorem load_entry_412 : entryAt 412 = entry_412 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_412 : CacheEquation 412 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(412 < 6)), load_entry_412] + change forkRow [placeRow ⟨0, 0, 0, 3⟩ (denote cache_0), placeRow ⟨403, 4, 3, 6⟩ (denote cache_403)] = denote cache_412 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_412 + +theorem verified_row_413 : fork [place ⟨3, 7, 4, 3⟩ cache_3, place ⟨403, 0, 4, 7⟩ cache_403] = cache_413 := by + decide +kernel + +theorem load_entry_413 : entryAt 413 = entry_413 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_413 : CacheEquation 413 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(413 < 6)), load_entry_413] + change forkRow [placeRow ⟨3, 7, 4, 3⟩ (denote cache_3), placeRow ⟨403, 0, 4, 7⟩ (denote cache_403)] = denote cache_413 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_413 + +theorem verified_row_414 : fork [place ⟨374, 0, 2, 5⟩ cache_374, place ⟨199, 2, 4, 2⟩ cache_199, place ⟨185, 2, 4, 2⟩ cache_185] = cache_414 := by + decide +kernel + +theorem load_entry_414 : entryAt 414 = entry_414 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_414 : CacheEquation 414 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(414 < 6)), load_entry_414] + change forkRow [placeRow ⟨374, 0, 2, 5⟩ (denote cache_374), placeRow ⟨199, 2, 4, 2⟩ (denote cache_199), placeRow ⟨185, 2, 4, 2⟩ (denote cache_185)] = denote cache_414 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_414 + +theorem verified_row_415 : fork [place ⟨177, 1, 4, 2⟩ cache_177, place ⟨164, 1, 4, 2⟩ cache_164, place ⟨205, 1, 5, 2⟩ cache_205, place ⟨384, 0, 3, 4⟩ cache_384, place ⟨371, 0, 5, 4⟩ cache_371] = cache_415 := by + decide +kernel + +theorem load_entry_415 : entryAt 415 = entry_415 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_415 : CacheEquation 415 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(415 < 6)), load_entry_415] + change forkRow [placeRow ⟨177, 1, 4, 2⟩ (denote cache_177), placeRow ⟨164, 1, 4, 2⟩ (denote cache_164), placeRow ⟨205, 1, 5, 2⟩ (denote cache_205), placeRow ⟨384, 0, 3, 4⟩ (denote cache_384), placeRow ⟨371, 0, 5, 4⟩ (denote cache_371)] = denote cache_415 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_415 + +theorem verified_row_416 : fork [place ⟨176, 2, 5, 4⟩ cache_176, place ⟨385, 4, 1, 4⟩ cache_385, place ⟨197, 4, 1, 4⟩ cache_197, place ⟨295, 0, 5, 4⟩ cache_295, place ⟨245, 2, 5, 4⟩ cache_245, place ⟨220, 2, 5, 4⟩ cache_220] = cache_416 := by + decide +kernel + +theorem load_entry_416 : entryAt 416 = entry_416 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_416 : CacheEquation 416 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(416 < 6)), load_entry_416] + change forkRow [placeRow ⟨176, 2, 5, 4⟩ (denote cache_176), placeRow ⟨385, 4, 1, 4⟩ (denote cache_385), placeRow ⟨197, 4, 1, 4⟩ (denote cache_197), placeRow ⟨295, 0, 5, 4⟩ (denote cache_295), placeRow ⟨245, 2, 5, 4⟩ (denote cache_245), placeRow ⟨220, 2, 5, 4⟩ (denote cache_220)] = denote cache_416 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_416 + +theorem verified_row_417 : fork [place ⟨409, 0, 2, 4⟩ cache_409, place ⟨11, 1, 4, 2⟩ cache_11, place ⟨270, 4, 4, 2⟩ cache_270] = cache_417 := by + decide +kernel + +theorem load_entry_417 : entryAt 417 = entry_417 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_417 : CacheEquation 417 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(417 < 6)), load_entry_417] + change forkRow [placeRow ⟨409, 0, 2, 4⟩ (denote cache_409), placeRow ⟨11, 1, 4, 2⟩ (denote cache_11), placeRow ⟨270, 4, 4, 2⟩ (denote cache_270)] = denote cache_417 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_417 + +theorem verified_row_418 : fork [place ⟨68, 4, 1, 3⟩ cache_68, place ⟨62, 6, 1, 3⟩ cache_62, place ⟨147, 6, 1, 3⟩ cache_147, place ⟨413, 0, 4, 2⟩ cache_413] = cache_418 := by + decide +kernel + +theorem load_entry_418 : entryAt 418 = entry_418 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_418 : CacheEquation 418 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(418 < 6)), load_entry_418] + change forkRow [placeRow ⟨68, 4, 1, 3⟩ (denote cache_68), placeRow ⟨62, 6, 1, 3⟩ (denote cache_62), placeRow ⟨147, 6, 1, 3⟩ (denote cache_147), placeRow ⟨413, 0, 4, 2⟩ (denote cache_413)] = denote cache_418 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_418 + +theorem verified_row_419 : fork [place ⟨243, 0, 4, 2⟩ cache_243, place ⟨164, 1, 4, 2⟩ cache_164, place ⟨402, 0, 2, 4⟩ cache_402, place ⟨253, 0, 2, 4⟩ cache_253, place ⟨377, 0, 2, 4⟩ cache_377] = cache_419 := by + decide +kernel + +theorem load_entry_419 : entryAt 419 = entry_419 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_419 : CacheEquation 419 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(419 < 6)), load_entry_419] + change forkRow [placeRow ⟨243, 0, 4, 2⟩ (denote cache_243), placeRow ⟨164, 1, 4, 2⟩ (denote cache_164), placeRow ⟨402, 0, 2, 4⟩ (denote cache_402), placeRow ⟨253, 0, 2, 4⟩ (denote cache_253), placeRow ⟨377, 0, 2, 4⟩ (denote cache_377)] = denote cache_419 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_419 + +theorem verified_row_420 : fork [place ⟨29, 3, 3, 0⟩ cache_29, place ⟨415, 0, 6, 4⟩ cache_415] = cache_420 := by + decide +kernel + +theorem load_entry_420 : entryAt 420 = entry_420 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_420 : CacheEquation 420 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(420 < 6)), load_entry_420] + change forkRow [placeRow ⟨29, 3, 3, 0⟩ (denote cache_29), placeRow ⟨415, 0, 6, 4⟩ (denote cache_415)] = denote cache_420 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_420 + +theorem verified_row_421 : fork [place ⟨24, 6, 2, 3⟩ cache_24, place ⟨397, 1, 5, 3⟩ cache_397, place ⟨25, 6, 2, 3⟩ cache_25, place ⟨241, 4, 2, 4⟩ cache_241] = cache_421 := by + decide +kernel + +theorem load_entry_421 : entryAt 421 = entry_421 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_421 : CacheEquation 421 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(421 < 6)), load_entry_421] + change forkRow [placeRow ⟨24, 6, 2, 3⟩ (denote cache_24), placeRow ⟨397, 1, 5, 3⟩ (denote cache_397), placeRow ⟨25, 6, 2, 3⟩ (denote cache_25), placeRow ⟨241, 4, 2, 4⟩ (denote cache_241)] = denote cache_421 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_421 + +theorem verified_row_422 : fork [place ⟨45, 1, 3, 7⟩ cache_45, place ⟨106, 6, 2, 3⟩ cache_106, place ⟨419, 1, 6, 6⟩ cache_419] = cache_422 := by + decide +kernel + +theorem load_entry_422 : entryAt 422 = entry_422 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_422 : CacheEquation 422 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(422 < 6)), load_entry_422] + change forkRow [placeRow ⟨45, 1, 3, 7⟩ (denote cache_45), placeRow ⟨106, 6, 2, 3⟩ (denote cache_106), placeRow ⟨419, 1, 6, 6⟩ (denote cache_419)] = denote cache_422 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_422 + +theorem verified_row_423 : fork [place ⟨378, 4, 2, 4⟩ cache_378, place ⟨386, 0, 5, 4⟩ cache_386, place ⟨226, 3, 3, 5⟩ cache_226, place ⟨386, 4, 2, 4⟩ cache_386, place ⟨378, 0, 5, 4⟩ cache_378] = cache_423 := by + decide +kernel + +theorem load_entry_423 : entryAt 423 = entry_423 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_423 : CacheEquation 423 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(423 < 6)), load_entry_423] + change forkRow [placeRow ⟨378, 4, 2, 4⟩ (denote cache_378), placeRow ⟨386, 0, 5, 4⟩ (denote cache_386), placeRow ⟨226, 3, 3, 5⟩ (denote cache_226), placeRow ⟨386, 4, 2, 4⟩ (denote cache_386), placeRow ⟨378, 0, 5, 4⟩ (denote cache_378)] = denote cache_423 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_423 + +theorem verified_row_424 : fork [place ⟨55, 1, 4, 5⟩ cache_55, place ⟨394, 0, 6, 4⟩ cache_394, place ⟨216, 3, 4, 5⟩ cache_216] = cache_424 := by + decide +kernel + +theorem load_entry_424 : entryAt 424 = entry_424 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_424 : CacheEquation 424 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(424 < 6)), load_entry_424] + change forkRow [placeRow ⟨55, 1, 4, 5⟩ (denote cache_55), placeRow ⟨394, 0, 6, 4⟩ (denote cache_394), placeRow ⟨216, 3, 4, 5⟩ (denote cache_216)] = denote cache_424 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_424 + +theorem verified_row_425 : fork [place ⟨386, 0, 5, 4⟩ cache_386, place ⟨226, 1, 4, 5⟩ cache_226, place ⟨378, 4, 2, 4⟩ cache_378, place ⟨378, 0, 5, 4⟩ cache_378, place ⟨386, 4, 2, 4⟩ cache_386] = cache_425 := by + decide +kernel + +theorem load_entry_425 : entryAt 425 = entry_425 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_425 : CacheEquation 425 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(425 < 6)), load_entry_425] + change forkRow [placeRow ⟨386, 0, 5, 4⟩ (denote cache_386), placeRow ⟨226, 1, 4, 5⟩ (denote cache_226), placeRow ⟨378, 4, 2, 4⟩ (denote cache_378), placeRow ⟨378, 0, 5, 4⟩ (denote cache_378), placeRow ⟨386, 4, 2, 4⟩ (denote cache_386)] = denote cache_425 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_425 + +theorem verified_row_426 : fork [place ⟨300, 6, 4, 1⟩ cache_300, place ⟨252, 1, 4, 5⟩ cache_252, place ⟨397, 0, 3, 4⟩ cache_397, place ⟨291, 1, 4, 1⟩ cache_291, place ⟨328, 0, 4, 5⟩ cache_328, place ⟨319, 1, 3, 5⟩ cache_319] = cache_426 := by + decide +kernel + +theorem load_entry_426 : entryAt 426 = entry_426 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_426 : CacheEquation 426 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(426 < 6)), load_entry_426] + change forkRow [placeRow ⟨300, 6, 4, 1⟩ (denote cache_300), placeRow ⟨252, 1, 4, 5⟩ (denote cache_252), placeRow ⟨397, 0, 3, 4⟩ (denote cache_397), placeRow ⟨291, 1, 4, 1⟩ (denote cache_291), placeRow ⟨328, 0, 4, 5⟩ (denote cache_328), placeRow ⟨319, 1, 3, 5⟩ (denote cache_319)] = denote cache_426 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_426 + +theorem verified_row_427 : fork [place ⟨45, 1, 3, 7⟩ cache_45, place ⟨106, 6, 2, 3⟩ cache_106, place ⟨420, 1, 6, 4⟩ cache_420] = cache_427 := by + decide +kernel + +theorem load_entry_427 : entryAt 427 = entry_427 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_427 : CacheEquation 427 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(427 < 6)), load_entry_427] + change forkRow [placeRow ⟨45, 1, 3, 7⟩ (denote cache_45), placeRow ⟨106, 6, 2, 3⟩ (denote cache_106), placeRow ⟨420, 1, 6, 4⟩ (denote cache_420)] = denote cache_427 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_427 + +theorem verified_row_428 : fork [place ⟨26, 3, 4, 3⟩ cache_26, place ⟨416, 0, 5, 4⟩ cache_416, place ⟨244, 0, 5, 4⟩ cache_244, place ⟨329, 0, 4, 3⟩ cache_329] = cache_428 := by + decide +kernel + +theorem load_entry_428 : entryAt 428 = entry_428 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_428 : CacheEquation 428 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(428 < 6)), load_entry_428] + change forkRow [placeRow ⟨26, 3, 4, 3⟩ (denote cache_26), placeRow ⟨416, 0, 5, 4⟩ (denote cache_416), placeRow ⟨244, 0, 5, 4⟩ (denote cache_244), placeRow ⟨329, 0, 4, 3⟩ (denote cache_329)] = denote cache_428 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_428 + +theorem verified_row_429 : fork [place ⟨128, 0, 6, 3⟩ cache_128, place ⟨28, 3, 4, 5⟩ cache_28] = cache_429 := by + decide +kernel + +theorem load_entry_429 : entryAt 429 = entry_429 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_429 : CacheEquation 429 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(429 < 6)), load_entry_429] + change forkRow [placeRow ⟨128, 0, 6, 3⟩ (denote cache_128), placeRow ⟨28, 3, 4, 5⟩ (denote cache_28)] = denote cache_429 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_429 + +theorem verified_row_430 : fork [place ⟨277, 7, 1, 3⟩ cache_277, place ⟨338, 4, 3, 4⟩ cache_338, place ⟨336, 1, 4, 3⟩ cache_336, place ⟨375, 2, 4, 3⟩ cache_375, place ⟨277, 6, 3, 1⟩ cache_277] = cache_430 := by + decide +kernel + +theorem load_entry_430 : entryAt 430 = entry_430 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_430 : CacheEquation 430 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(430 < 6)), load_entry_430] + change forkRow [placeRow ⟨277, 7, 1, 3⟩ (denote cache_277), placeRow ⟨338, 4, 3, 4⟩ (denote cache_338), placeRow ⟨336, 1, 4, 3⟩ (denote cache_336), placeRow ⟨375, 2, 4, 3⟩ (denote cache_375), placeRow ⟨277, 6, 3, 1⟩ (denote cache_277)] = denote cache_430 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_430 + +theorem verified_row_431 : fork [place ⟨73, 4, 3, 3⟩ cache_73, place ⟨302, 1, 5, 2⟩ cache_302, place ⟨415, 0, 6, 4⟩ cache_415, place ⟨398, 0, 6, 4⟩ cache_398] = cache_431 := by + decide +kernel + +theorem load_entry_431 : entryAt 431 = entry_431 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_431 : CacheEquation 431 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(431 < 6)), load_entry_431] + change forkRow [placeRow ⟨73, 4, 3, 3⟩ (denote cache_73), placeRow ⟨302, 1, 5, 2⟩ (denote cache_302), placeRow ⟨415, 0, 6, 4⟩ (denote cache_415), placeRow ⟨398, 0, 6, 4⟩ (denote cache_398)] = denote cache_431 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_431 + +theorem verified_row_432 : fork [place ⟨42, 3, 4, 3⟩ cache_42, place ⟨428, 0, 5, 4⟩ cache_428, place ⟨274, 0, 4, 3⟩ cache_274] = cache_432 := by + decide +kernel + +theorem load_entry_432 : entryAt 432 = entry_432 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_432 : CacheEquation 432 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(432 < 6)), load_entry_432] + change forkRow [placeRow ⟨42, 3, 4, 3⟩ (denote cache_42), placeRow ⟨428, 0, 5, 4⟩ (denote cache_428), placeRow ⟨274, 0, 4, 3⟩ (denote cache_274)] = denote cache_432 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_432 + +theorem verified_row_433 : fork [place ⟨63, 0, 3, 5⟩ cache_63, place ⟨7, 3, 3, 4⟩ cache_7, place ⟨427, 0, 5, 2⟩ cache_427, place ⟨422, 0, 5, 2⟩ cache_422] = cache_433 := by + decide +kernel + +theorem load_entry_433 : entryAt 433 = entry_433 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_433 : CacheEquation 433 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(433 < 6)), load_entry_433] + change forkRow [placeRow ⟨63, 0, 3, 5⟩ (denote cache_63), placeRow ⟨7, 3, 3, 4⟩ (denote cache_7), placeRow ⟨427, 0, 5, 2⟩ (denote cache_427), placeRow ⟨422, 0, 5, 2⟩ (denote cache_422)] = denote cache_433 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_433 + +theorem verified_row_434 : fork [place ⟨418, 0, 4, 5⟩ cache_418, place ⟨263, 2, 5, 4⟩ cache_263, place ⟨295, 0, 5, 4⟩ cache_295, place ⟨176, 2, 5, 4⟩ cache_176, place ⟨116, 0, 4, 3⟩ cache_116] = cache_434 := by + decide +kernel + +theorem load_entry_434 : entryAt 434 = entry_434 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_434 : CacheEquation 434 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(434 < 6)), load_entry_434] + change forkRow [placeRow ⟨418, 0, 4, 5⟩ (denote cache_418), placeRow ⟨263, 2, 5, 4⟩ (denote cache_263), placeRow ⟨295, 0, 5, 4⟩ (denote cache_295), placeRow ⟨176, 2, 5, 4⟩ (denote cache_176), placeRow ⟨116, 0, 4, 3⟩ (denote cache_116)] = denote cache_434 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_434 + +theorem verified_row_435 : fork [place ⟨6, 4, 3, 4⟩ cache_6, place ⟨431, 0, 5, 6⟩ cache_431] = cache_435 := by + decide +kernel + +theorem load_entry_435 : entryAt 435 = entry_435 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_435 : CacheEquation 435 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(435 < 6)), load_entry_435] + change forkRow [placeRow ⟨6, 4, 3, 4⟩ (denote cache_6), placeRow ⟨431, 0, 5, 6⟩ (denote cache_431)] = denote cache_435 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_435 + +theorem verified_row_436 : fork [place ⟨51, 1, 5, 4⟩ cache_51, place ⟨60, 3, 4, 3⟩ cache_60, place ⟨274, 4, 4, 3⟩ cache_274, place ⟨428, 0, 5, 4⟩ cache_428] = cache_436 := by + decide +kernel + +theorem load_entry_436 : entryAt 436 = entry_436 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_436 : CacheEquation 436 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(436 < 6)), load_entry_436] + change forkRow [placeRow ⟨51, 1, 5, 4⟩ (denote cache_51), placeRow ⟨60, 3, 4, 3⟩ (denote cache_60), placeRow ⟨274, 4, 4, 3⟩ (denote cache_274), placeRow ⟨428, 0, 5, 4⟩ (denote cache_428)] = denote cache_436 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_436 + +theorem verified_row_437 : fork [place ⟨55, 7, 4, 0⟩ cache_55, place ⟨427, 0, 5, 2⟩ cache_427, place ⟨63, 0, 3, 5⟩ cache_63, place ⟨422, 0, 5, 2⟩ cache_422] = cache_437 := by + decide +kernel + +theorem load_entry_437 : entryAt 437 = entry_437 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_437 : CacheEquation 437 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(437 < 6)), load_entry_437] + change forkRow [placeRow ⟨55, 7, 4, 0⟩ (denote cache_55), placeRow ⟨427, 0, 5, 2⟩ (denote cache_427), placeRow ⟨63, 0, 3, 5⟩ (denote cache_63), placeRow ⟨422, 0, 5, 2⟩ (denote cache_422)] = denote cache_437 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_437 + +theorem verified_row_438 : fork [place ⟨0, 0, 1, 3⟩ cache_0, place ⟨432, 0, 4, 6⟩ cache_432] = cache_438 := by + decide +kernel + +theorem load_entry_438 : entryAt 438 = entry_438 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_438 : CacheEquation 438 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(438 < 6)), load_entry_438] + change forkRow [placeRow ⟨0, 0, 1, 3⟩ (denote cache_0), placeRow ⟨432, 0, 4, 6⟩ (denote cache_432)] = denote cache_438 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_438 + +theorem verified_row_439 : fork [place ⟨176, 2, 5, 4⟩ cache_176, place ⟨295, 0, 5, 4⟩ cache_295, place ⟨263, 2, 5, 4⟩ cache_263, place ⟨418, 0, 4, 5⟩ cache_418, place ⟨149, 0, 4, 3⟩ cache_149] = cache_439 := by + decide +kernel + +theorem load_entry_439 : entryAt 439 = entry_439 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_439 : CacheEquation 439 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(439 < 6)), load_entry_439] + change forkRow [placeRow ⟨176, 2, 5, 4⟩ (denote cache_176), placeRow ⟨295, 0, 5, 4⟩ (denote cache_295), placeRow ⟨263, 2, 5, 4⟩ (denote cache_263), placeRow ⟨418, 0, 4, 5⟩ (denote cache_418), placeRow ⟨149, 0, 4, 3⟩ (denote cache_149)] = denote cache_439 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_439 + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Equations11.lean b/lean/OAI/Combinatorics/SnakyCertificate/Equations11.lean new file mode 100644 index 0000000000000000000000000000000000000000..0036996984cf7886abe481e0540626a76f213e18 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Equations11.lean @@ -0,0 +1,530 @@ +import OAI.Combinatorics.SnakyCertificate.Cache +import OAI.Combinatorics.SnakyCertificate.TableList + +namespace OAI + +namespace SnakyCertificate.Check + +theorem verified_row_440 : fork [place ⟨6, 6, 1, 3⟩ cache_6, place ⟨435, 0, 2, 5⟩ cache_435] = cache_440 := by + decide +kernel + +theorem load_entry_440 : entryAt 440 = entry_440 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_440 : CacheEquation 440 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(440 < 6)), load_entry_440] + change forkRow [placeRow ⟨6, 6, 1, 3⟩ (denote cache_6), placeRow ⟨435, 0, 2, 5⟩ (denote cache_435)] = denote cache_440 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_440 + +theorem verified_row_441 : fork [place ⟨6, 6, 3, 4⟩ cache_6, place ⟨435, 0, 4, 6⟩ cache_435] = cache_441 := by + decide +kernel + +theorem load_entry_441 : entryAt 441 = entry_441 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_441 : CacheEquation 441 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(441 < 6)), load_entry_441] + change forkRow [placeRow ⟨6, 6, 3, 4⟩ (denote cache_6), placeRow ⟨435, 0, 4, 6⟩ (denote cache_435)] = denote cache_441 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_441 + +theorem verified_row_442 : fork [place ⟨63, 0, 3, 5⟩ cache_63, place ⟨7, 1, 5, 4⟩ cache_7, place ⟨433, 0, 4, 5⟩ cache_433, place ⟨201, 0, 3, 2⟩ cache_201] = cache_442 := by + decide +kernel + +theorem load_entry_442 : entryAt 442 = entry_442 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_442 : CacheEquation 442 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(442 < 6)), load_entry_442] + change forkRow [placeRow ⟨63, 0, 3, 5⟩ (denote cache_63), placeRow ⟨7, 1, 5, 4⟩ (denote cache_7), placeRow ⟨433, 0, 4, 5⟩ (denote cache_433), placeRow ⟨201, 0, 3, 2⟩ (denote cache_201)] = denote cache_442 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_442 + +theorem verified_row_443 : fork [place ⟨6, 0, 5, 4⟩ cache_6, place ⟨438, 0, 3, 4⟩ cache_438] = cache_443 := by + decide +kernel + +theorem load_entry_443 : entryAt 443 = entry_443 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_443 : CacheEquation 443 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(443 < 6)), load_entry_443] + change forkRow [placeRow ⟨6, 0, 5, 4⟩ (denote cache_6), placeRow ⟨438, 0, 3, 4⟩ (denote cache_438)] = denote cache_443 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_443 + +theorem verified_row_444 : fork [place ⟨194, 0, 5, 3⟩ cache_194, place ⟨160, 3, 4, 1⟩ cache_160, place ⟨142, 7, 4, 1⟩ cache_142, place ⟨236, 0, 5, 5⟩ cache_236, place ⟨353, 4, 1, 2⟩ cache_353, place ⟨412, 0, 5, 3⟩ cache_412] = cache_444 := by + decide +kernel + +theorem load_entry_444 : entryAt 444 = entry_444 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_444 : CacheEquation 444 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(444 < 6)), load_entry_444] + change forkRow [placeRow ⟨194, 0, 5, 3⟩ (denote cache_194), placeRow ⟨160, 3, 4, 1⟩ (denote cache_160), placeRow ⟨142, 7, 4, 1⟩ (denote cache_142), placeRow ⟨236, 0, 5, 5⟩ (denote cache_236), placeRow ⟨353, 4, 1, 2⟩ (denote cache_353), placeRow ⟨412, 0, 5, 3⟩ (denote cache_412)] = denote cache_444 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_444 + +theorem verified_row_445 : fork [place ⟨9, 4, 3, 4⟩ cache_9, place ⟨432, 0, 5, 7⟩ cache_432] = cache_445 := by + decide +kernel + +theorem load_entry_445 : entryAt 445 = entry_445 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_445 : CacheEquation 445 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(445 < 6)), load_entry_445] + change forkRow [placeRow ⟨9, 4, 3, 4⟩ (denote cache_9), placeRow ⟨432, 0, 5, 7⟩ (denote cache_432)] = denote cache_445 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_445 + +theorem verified_row_446 : fork [place ⟨4, 6, 4, 3⟩ cache_4, place ⟨438, 0, 6, 5⟩ cache_438] = cache_446 := by + decide +kernel + +theorem load_entry_446 : entryAt 446 = entry_446 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_446 : CacheEquation 446 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(446 < 6)), load_entry_446] + change forkRow [placeRow ⟨4, 6, 4, 3⟩ (denote cache_4), placeRow ⟨438, 0, 6, 5⟩ (denote cache_438)] = denote cache_446 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_446 + +theorem verified_row_447 : fork [place ⟨0, 0, 0, 3⟩ cache_0, place ⟨436, 4, 4, 6⟩ cache_436] = cache_447 := by + decide +kernel + +theorem load_entry_447 : entryAt 447 = entry_447 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_447 : CacheEquation 447 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(447 < 6)), load_entry_447] + change forkRow [placeRow ⟨0, 0, 0, 3⟩ (denote cache_0), placeRow ⟨436, 4, 4, 6⟩ (denote cache_436)] = denote cache_447 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_447 + +theorem verified_row_448 : fork [place ⟨9, 4, 1, 3⟩ cache_9, place ⟨436, 0, 3, 6⟩ cache_436] = cache_448 := by + decide +kernel + +theorem load_entry_448 : entryAt 448 = entry_448 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_448 : CacheEquation 448 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(448 < 6)), load_entry_448] + change forkRow [placeRow ⟨9, 4, 1, 3⟩ (denote cache_9), placeRow ⟨436, 0, 3, 6⟩ (denote cache_436)] = denote cache_448 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_448 + +theorem verified_row_449 : fork [place ⟨26, 3, 4, 3⟩ cache_26, place ⟨244, 0, 5, 4⟩ cache_244, place ⟨439, 0, 5, 4⟩ cache_439, place ⟨307, 0, 4, 3⟩ cache_307] = cache_449 := by + decide +kernel + +theorem load_entry_449 : entryAt 449 = entry_449 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_449 : CacheEquation 449 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(449 < 6)), load_entry_449] + change forkRow [placeRow ⟨26, 3, 4, 3⟩ (denote cache_26), placeRow ⟨244, 0, 5, 4⟩ (denote cache_244), placeRow ⟨439, 0, 5, 4⟩ (denote cache_439), placeRow ⟨307, 0, 4, 3⟩ (denote cache_307)] = denote cache_449 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_449 + +theorem verified_row_450 : fork [place ⟨6, 1, 5, 5⟩ cache_6, place ⟨440, 0, 6, 4⟩ cache_440] = cache_450 := by + decide +kernel + +theorem load_entry_450 : entryAt 450 = entry_450 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_450 : CacheEquation 450 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(450 < 6)), load_entry_450] + change forkRow [placeRow ⟨6, 1, 5, 5⟩ (denote cache_6), placeRow ⟨440, 0, 6, 4⟩ (denote cache_440)] = denote cache_450 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_450 + +theorem verified_row_451 : fork [place ⟨1, 5, 4, 3⟩ cache_1, place ⟨449, 0, 5, 4⟩ cache_449] = cache_451 := by + decide +kernel + +theorem load_entry_451 : entryAt 451 = entry_451 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_451 : CacheEquation 451 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(451 < 6)), load_entry_451] + change forkRow [placeRow ⟨1, 5, 4, 3⟩ (denote cache_1), placeRow ⟨449, 0, 5, 4⟩ (denote cache_449)] = denote cache_451 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_451 + +theorem verified_row_452 : fork [place ⟨24, 1, 5, 7⟩ cache_24, place ⟨451, 0, 3, 8⟩ cache_451, place ⟨25, 3, 3, 7⟩ cache_25] = cache_452 := by + decide +kernel + +theorem load_entry_452 : entryAt 452 = entry_452 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_452 : CacheEquation 452 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(452 < 6)), load_entry_452] + change forkRow [placeRow ⟨24, 1, 5, 7⟩ (denote cache_24), placeRow ⟨451, 0, 3, 8⟩ (denote cache_451), placeRow ⟨25, 3, 3, 7⟩ (denote cache_25)] = denote cache_452 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_452 + +theorem verified_row_453 : fork [place ⟨359, 0, 4, 3⟩ cache_359, place ⟨226, 7, 3, 1⟩ cache_226, place ⟨386, 4, 2, 4⟩ cache_386, place ⟨389, 1, 5, 4⟩ cache_389, place ⟨414, 4, 3, 3⟩ cache_414] = cache_453 := by + decide +kernel + +theorem load_entry_453 : entryAt 453 = entry_453 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_453 : CacheEquation 453 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(453 < 6)), load_entry_453] + change forkRow [placeRow ⟨359, 0, 4, 3⟩ (denote cache_359), placeRow ⟨226, 7, 3, 1⟩ (denote cache_226), placeRow ⟨386, 4, 2, 4⟩ (denote cache_386), placeRow ⟨389, 1, 5, 4⟩ (denote cache_389), placeRow ⟨414, 4, 3, 3⟩ (denote cache_414)] = denote cache_453 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_453 + +theorem verified_row_454 : fork [place ⟨58, 0, 6, 3⟩ cache_58, place ⟨436, 0, 3, 6⟩ cache_436] = cache_454 := by + decide +kernel + +theorem load_entry_454 : entryAt 454 = entry_454 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_454 : CacheEquation 454 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(454 < 6)), load_entry_454] + change forkRow [placeRow ⟨58, 0, 6, 3⟩ (denote cache_58), placeRow ⟨436, 0, 3, 6⟩ (denote cache_436)] = denote cache_454 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_454 + +theorem verified_row_455 : fork [place ⟨20, 2, 4, 5⟩ cache_20, place ⟨118, 3, 0, 5⟩ cache_118, place ⟨39, 2, 3, 4⟩ cache_39] = cache_455 := by + decide +kernel + +theorem load_entry_455 : entryAt 455 = entry_455 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_455 : CacheEquation 455 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(455 < 6)), load_entry_455] + change forkRow [placeRow ⟨20, 2, 4, 5⟩ (denote cache_20), placeRow ⟨118, 3, 0, 5⟩ (denote cache_118), placeRow ⟨39, 2, 3, 4⟩ (denote cache_39)] = denote cache_455 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_455 + +theorem verified_row_456 : fork [place ⟨308, 4, 4, 3⟩ cache_308, place ⟨64, 2, 1, 5⟩ cache_64, place ⟨63, 1, 5, 3⟩ cache_63, place ⟨55, 0, 5, 4⟩ cache_55] = cache_456 := by + decide +kernel + +theorem load_entry_456 : entryAt 456 = entry_456 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_456 : CacheEquation 456 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(456 < 6)), load_entry_456] + change forkRow [placeRow ⟨308, 4, 4, 3⟩ (denote cache_308), placeRow ⟨64, 2, 1, 5⟩ (denote cache_64), placeRow ⟨63, 1, 5, 3⟩ (denote cache_63), placeRow ⟨55, 0, 5, 4⟩ (denote cache_55)] = denote cache_456 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_456 + +theorem verified_row_457 : fork [place ⟨28, 7, 3, 2⟩ cache_28, place ⟨454, 0, 5, 4⟩ cache_454] = cache_457 := by + decide +kernel + +theorem load_entry_457 : entryAt 457 = entry_457 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_457 : CacheEquation 457 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(457 < 6)), load_entry_457] + change forkRow [placeRow ⟨28, 7, 3, 2⟩ (denote cache_28), placeRow ⟨454, 0, 5, 4⟩ (denote cache_454)] = denote cache_457 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_457 + +theorem verified_row_458 : fork [place ⟨130, 1, 4, 2⟩ cache_130, place ⟨177, 1, 4, 2⟩ cache_177, place ⟨450, 0, 1, 4⟩ cache_450] = cache_458 := by + decide +kernel + +theorem load_entry_458 : entryAt 458 = entry_458 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_458 : CacheEquation 458 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(458 < 6)), load_entry_458] + change forkRow [placeRow ⟨130, 1, 4, 2⟩ (denote cache_130), placeRow ⟨177, 1, 4, 2⟩ (denote cache_177), placeRow ⟨450, 0, 1, 4⟩ (denote cache_450)] = denote cache_458 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_458 + +theorem verified_row_459 : fork [place ⟨97, 2, 7, 3⟩ cache_97, place ⟨448, 0, 5, 4⟩ cache_448, place ⟨65, 2, 7, 3⟩ cache_65] = cache_459 := by + decide +kernel + +theorem load_entry_459 : entryAt 459 = entry_459 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_459 : CacheEquation 459 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(459 < 6)), load_entry_459] + change forkRow [placeRow ⟨97, 2, 7, 3⟩ (denote cache_97), placeRow ⟨448, 0, 5, 4⟩ (denote cache_448), placeRow ⟨65, 2, 7, 3⟩ (denote cache_65)] = denote cache_459 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_459 + +theorem verified_row_460 : fork [place ⟨183, 6, 1, 4⟩ cache_183, place ⟨173, 2, 5, 4⟩ cache_173, place ⟨295, 0, 5, 4⟩ cache_295, place ⟨282, 4, 1, 4⟩ cache_282, place ⟨246, 2, 5, 4⟩ cache_246, place ⟨263, 2, 5, 4⟩ cache_263, place ⟨220, 2, 5, 4⟩ cache_220] = cache_460 := by + decide +kernel + +theorem load_entry_460 : entryAt 460 = entry_460 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_460 : CacheEquation 460 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(460 < 6)), load_entry_460] + change forkRow [placeRow ⟨183, 6, 1, 4⟩ (denote cache_183), placeRow ⟨173, 2, 5, 4⟩ (denote cache_173), placeRow ⟨295, 0, 5, 4⟩ (denote cache_295), placeRow ⟨282, 4, 1, 4⟩ (denote cache_282), placeRow ⟨246, 2, 5, 4⟩ (denote cache_246), placeRow ⟨263, 2, 5, 4⟩ (denote cache_263), placeRow ⟨220, 2, 5, 4⟩ (denote cache_220)] = denote cache_460 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_460 + +theorem verified_row_461 : fork [place ⟨4, 1, 4, 3⟩ cache_4, place ⟨458, 0, 6, 4⟩ cache_458] = cache_461 := by + decide +kernel + +theorem load_entry_461 : entryAt 461 = entry_461 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_461 : CacheEquation 461 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(461 < 6)), load_entry_461] + change forkRow [placeRow ⟨4, 1, 4, 3⟩ (denote cache_4), placeRow ⟨458, 0, 6, 4⟩ (denote cache_458)] = denote cache_461 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_461 + +theorem verified_row_462 : fork [place ⟨452, 0, 3, 2⟩ cache_452, place ⟨86, 0, 5, 4⟩ cache_86, place ⟨328, 1, 5, 4⟩ cache_328] = cache_462 := by + decide +kernel + +theorem load_entry_462 : entryAt 462 = entry_462 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_462 : CacheEquation 462 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(462 < 6)), load_entry_462] + change forkRow [placeRow ⟨452, 0, 3, 2⟩ (denote cache_452), placeRow ⟨86, 0, 5, 4⟩ (denote cache_86), placeRow ⟨328, 1, 5, 4⟩ (denote cache_328)] = denote cache_462 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_462 + +theorem verified_row_463 : fork [place ⟨170, 0, 6, 3⟩ cache_170, place ⟨76, 1, 3, 2⟩ cache_76, place ⟨447, 0, 5, 4⟩ cache_447] = cache_463 := by + decide +kernel + +theorem load_entry_463 : entryAt 463 = entry_463 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_463 : CacheEquation 463 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(463 < 6)), load_entry_463] + change forkRow [placeRow ⟨170, 0, 6, 3⟩ (denote cache_170), placeRow ⟨76, 1, 3, 2⟩ (denote cache_76), placeRow ⟨447, 0, 5, 4⟩ (denote cache_447)] = denote cache_463 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_463 + +theorem verified_row_464 : fork [place ⟨63, 0, 3, 5⟩ cache_63, place ⟨224, 0, 5, 4⟩ cache_224, place ⟨315, 0, 7, 3⟩ cache_315, place ⟨306, 0, 5, 5⟩ cache_306, place ⟨358, 0, 7, 3⟩ cache_358, place ⟨461, 0, 5, 5⟩ cache_461] = cache_464 := by + decide +kernel + +theorem load_entry_464 : entryAt 464 = entry_464 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_464 : CacheEquation 464 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(464 < 6)), load_entry_464] + change forkRow [placeRow ⟨63, 0, 3, 5⟩ (denote cache_63), placeRow ⟨224, 0, 5, 4⟩ (denote cache_224), placeRow ⟨315, 0, 7, 3⟩ (denote cache_315), placeRow ⟨306, 0, 5, 5⟩ (denote cache_306), placeRow ⟨358, 0, 7, 3⟩ (denote cache_358), placeRow ⟨461, 0, 5, 5⟩ (denote cache_461)] = denote cache_464 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_464 + +theorem verified_row_465 : fork [place ⟨55, 3, 4, 5⟩ cache_55, place ⟨285, 0, 3, 4⟩ cache_285, place ⟨64, 1, 3, 1⟩ cache_64] = cache_465 := by + decide +kernel + +theorem load_entry_465 : entryAt 465 = entry_465 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_465 : CacheEquation 465 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(465 < 6)), load_entry_465] + change forkRow [placeRow ⟨55, 3, 4, 5⟩ (denote cache_55), placeRow ⟨285, 0, 3, 4⟩ (denote cache_285), placeRow ⟨64, 1, 3, 1⟩ (denote cache_64)] = denote cache_465 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_465 + +theorem verified_row_466 : fork [place ⟨395, 4, 3, 4⟩ cache_395, place ⟨360, 4, 2, 6⟩ cache_360, place ⟨417, 1, 5, 4⟩ cache_417, place ⟨325, 4, 3, 4⟩ cache_325, place ⟨324, 4, 3, 5⟩ cache_324] = cache_466 := by + decide +kernel + +theorem load_entry_466 : entryAt 466 = entry_466 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_466 : CacheEquation 466 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(466 < 6)), load_entry_466] + change forkRow [placeRow ⟨395, 4, 3, 4⟩ (denote cache_395), placeRow ⟨360, 4, 2, 6⟩ (denote cache_360), placeRow ⟨417, 1, 5, 4⟩ (denote cache_417), placeRow ⟨325, 4, 3, 4⟩ (denote cache_325), placeRow ⟨324, 4, 3, 5⟩ (denote cache_324)] = denote cache_466 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_466 + +theorem verified_row_467 : fork [place ⟨64, 7, 5, 7⟩ cache_64, place ⟨314, 6, 5, 4⟩ cache_314, place ⟨443, 1, 5, 7⟩ cache_443] = cache_467 := by + decide +kernel + +theorem load_entry_467 : entryAt 467 = entry_467 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_467 : CacheEquation 467 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(467 < 6)), load_entry_467] + change forkRow [placeRow ⟨64, 7, 5, 7⟩ (denote cache_64), placeRow ⟨314, 6, 5, 4⟩ (denote cache_314), placeRow ⟨443, 1, 5, 7⟩ (denote cache_443)] = denote cache_467 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_467 + +theorem verified_row_468 : fork [place ⟨6, 6, 3, 4⟩ cache_6, place ⟨464, 0, 4, 7⟩ cache_464] = cache_468 := by + decide +kernel + +theorem load_entry_468 : entryAt 468 = entry_468 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_468 : CacheEquation 468 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(468 < 6)), load_entry_468] + change forkRow [placeRow ⟨6, 6, 3, 4⟩ (denote cache_6), placeRow ⟨464, 0, 4, 7⟩ (denote cache_464)] = denote cache_468 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_468 + +theorem verified_row_469 : fork [place ⟨55, 5, 4, 3⟩ cache_55, place ⟨443, 1, 5, 7⟩ cache_443, place ⟨314, 6, 5, 4⟩ cache_314] = cache_469 := by + decide +kernel + +theorem load_entry_469 : entryAt 469 = entry_469 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_469 : CacheEquation 469 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(469 < 6)), load_entry_469] + change forkRow [placeRow ⟨55, 5, 4, 3⟩ (denote cache_55), placeRow ⟨443, 1, 5, 7⟩ (denote cache_443), placeRow ⟨314, 6, 5, 4⟩ (denote cache_314)] = denote cache_469 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_469 + +theorem verified_row_470 : fork [place ⟨6, 4, 3, 4⟩ cache_6, place ⟨468, 0, 4, 2⟩ cache_468] = cache_470 := by + decide +kernel + +theorem load_entry_470 : entryAt 470 = entry_470 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_470 : CacheEquation 470 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(470 < 6)), load_entry_470] + change forkRow [placeRow ⟨6, 4, 3, 4⟩ (denote cache_6), placeRow ⟨468, 0, 4, 2⟩ (denote cache_468)] = denote cache_470 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_470 + +theorem verified_row_471 : fork [place ⟨6, 5, 4, 3⟩ cache_6, place ⟨466, 0, 5, 6⟩ cache_466] = cache_471 := by + decide +kernel + +theorem load_entry_471 : entryAt 471 = entry_471 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_471 : CacheEquation 471 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(471 < 6)), load_entry_471] + change forkRow [placeRow ⟨6, 5, 4, 3⟩ (denote cache_6), placeRow ⟨466, 0, 5, 6⟩ (denote cache_466)] = denote cache_471 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_471 + +theorem verified_row_472 : fork [place ⟨6, 5, 5, 0⟩ cache_6, place ⟨466, 0, 6, 3⟩ cache_466] = cache_472 := by + decide +kernel + +theorem load_entry_472 : entryAt 472 = entry_472 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_472 : CacheEquation 472 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(472 < 6)), load_entry_472] + change forkRow [placeRow ⟨6, 5, 5, 0⟩ (denote cache_6), placeRow ⟨466, 0, 6, 3⟩ (denote cache_466)] = denote cache_472 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_472 + +theorem verified_row_473 : fork [place ⟨121, 5, 5, 4⟩ cache_121, place ⟨436, 0, 3, 7⟩ cache_436, place ⟨445, 4, 5, 4⟩ cache_445] = cache_473 := by + decide +kernel + +theorem load_entry_473 : entryAt 473 = entry_473 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_473 : CacheEquation 473 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(473 < 6)), load_entry_473] + change forkRow [placeRow ⟨121, 5, 5, 4⟩ (denote cache_121), placeRow ⟨436, 0, 3, 7⟩ (denote cache_436), placeRow ⟨445, 4, 5, 4⟩ (denote cache_445)] = denote cache_473 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_473 + +theorem verified_row_474 : fork [place ⟨463, 0, 6, 5⟩ cache_463, place ⟨70, 0, 3, 5⟩ cache_70, place ⟨83, 1, 5, 3⟩ cache_83] = cache_474 := by + decide +kernel + +theorem load_entry_474 : entryAt 474 = entry_474 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_474 : CacheEquation 474 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(474 < 6)), load_entry_474] + change forkRow [placeRow ⟨463, 0, 6, 5⟩ (denote cache_463), placeRow ⟨70, 0, 3, 5⟩ (denote cache_70), placeRow ⟨83, 1, 5, 3⟩ (denote cache_83)] = denote cache_474 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_474 + +theorem verified_row_475 : fork [place ⟨63, 1, 5, 3⟩ cache_63, place ⟨261, 1, 4, 3⟩ cache_261, place ⟨457, 0, 2, 5⟩ cache_457, place ⟨269, 2, 2, 5⟩ cache_269] = cache_475 := by + decide +kernel + +theorem load_entry_475 : entryAt 475 = entry_475 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_475 : CacheEquation 475 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(475 < 6)), load_entry_475] + change forkRow [placeRow ⟨63, 1, 5, 3⟩ (denote cache_63), placeRow ⟨261, 1, 4, 3⟩ (denote cache_261), placeRow ⟨457, 0, 2, 5⟩ (denote cache_457), placeRow ⟨269, 2, 2, 5⟩ (denote cache_269)] = denote cache_475 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_475 + +theorem verified_row_476 : fork [place ⟨0, 0, 1, 3⟩ cache_0, place ⟨473, 0, 5, 3⟩ cache_473] = cache_476 := by + decide +kernel + +theorem load_entry_476 : entryAt 476 = entry_476 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_476 : CacheEquation 476 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(476 < 6)), load_entry_476] + change forkRow [placeRow ⟨0, 0, 1, 3⟩ (denote cache_0), placeRow ⟨473, 0, 5, 3⟩ (denote cache_473)] = denote cache_476 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_476 + +theorem verified_row_477 : fork [place ⟨55, 1, 4, 5⟩ cache_55, place ⟨154, 7, 4, 5⟩ cache_154, place ⟨154, 3, 4, 0⟩ cache_154, place ⟨471, 2, 5, 4⟩ cache_471] = cache_477 := by + decide +kernel + +theorem load_entry_477 : entryAt 477 = entry_477 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_477 : CacheEquation 477 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(477 < 6)), load_entry_477] + change forkRow [placeRow ⟨55, 1, 4, 5⟩ (denote cache_55), placeRow ⟨154, 7, 4, 5⟩ (denote cache_154), placeRow ⟨154, 3, 4, 0⟩ (denote cache_154), placeRow ⟨471, 2, 5, 4⟩ (denote cache_471)] = denote cache_477 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_477 + +theorem verified_row_478 : fork [place ⟨25, 3, 4, 5⟩ cache_25, place ⟨165, 2, 4, 5⟩ cache_165, place ⟨190, 0, 7, 4⟩ cache_190] = cache_478 := by + decide +kernel + +theorem load_entry_478 : entryAt 478 = entry_478 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_478 : CacheEquation 478 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(478 < 6)), load_entry_478] + change forkRow [placeRow ⟨25, 3, 4, 5⟩ (denote cache_25), placeRow ⟨165, 2, 4, 5⟩ (denote cache_165), placeRow ⟨190, 0, 7, 4⟩ (denote cache_190)] = denote cache_478 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_478 + +theorem verified_row_479 : fork [place ⟨55, 0, 5, 4⟩ cache_55, place ⟨443, 0, 4, 5⟩ cache_443, place ⟨443, 4, 1, 5⟩ cache_443] = cache_479 := by + decide +kernel + +theorem load_entry_479 : entryAt 479 = entry_479 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_479 : CacheEquation 479 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(479 < 6)), load_entry_479] + change forkRow [placeRow ⟨55, 0, 5, 4⟩ (denote cache_55), placeRow ⟨443, 0, 4, 5⟩ (denote cache_443), placeRow ⟨443, 4, 1, 5⟩ (denote cache_443)] = denote cache_479 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_479 + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Equations12.lean b/lean/OAI/Combinatorics/SnakyCertificate/Equations12.lean new file mode 100644 index 0000000000000000000000000000000000000000..4ed4e4a13eabe52a47f0ec9f26b435f5b28ccba0 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Equations12.lean @@ -0,0 +1,530 @@ +import OAI.Combinatorics.SnakyCertificate.Cache +import OAI.Combinatorics.SnakyCertificate.TableList + +namespace OAI + +namespace SnakyCertificate.Check + +theorem verified_row_480 : fork [place ⟨108, 1, 4, 5⟩ cache_108, place ⟨4, 1, 5, 4⟩ cache_4] = cache_480 := by + decide +kernel + +theorem load_entry_480 : entryAt 480 = entry_480 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_480 : CacheEquation 480 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(480 < 6)), load_entry_480] + change forkRow [placeRow ⟨108, 1, 4, 5⟩ (denote cache_108), placeRow ⟨4, 1, 5, 4⟩ (denote cache_4)] = denote cache_480 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_480 + +theorem verified_row_481 : fork [place ⟨303, 1, 5, 4⟩ cache_303, place ⟨429, 2, 1, 4⟩ cache_429, place ⟨309, 1, 1, 4⟩ cache_309, place ⟨206, 2, 1, 4⟩ cache_206, place ⟨169, 2, 1, 4⟩ cache_169, place ⟨207, 2, 1, 4⟩ cache_207] = cache_481 := by + decide +kernel + +theorem load_entry_481 : entryAt 481 = entry_481 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_481 : CacheEquation 481 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(481 < 6)), load_entry_481] + change forkRow [placeRow ⟨303, 1, 5, 4⟩ (denote cache_303), placeRow ⟨429, 2, 1, 4⟩ (denote cache_429), placeRow ⟨309, 1, 1, 4⟩ (denote cache_309), placeRow ⟨206, 2, 1, 4⟩ (denote cache_206), placeRow ⟨169, 2, 1, 4⟩ (denote cache_169), placeRow ⟨207, 2, 1, 4⟩ (denote cache_207)] = denote cache_481 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_481 + +theorem verified_row_482 : fork [place ⟨6, 1, 4, 5⟩ cache_6, place ⟨218, 2, 4, 3⟩ cache_218] = cache_482 := by + decide +kernel + +theorem load_entry_482 : entryAt 482 = entry_482 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_482 : CacheEquation 482 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(482 < 6)), load_entry_482] + change forkRow [placeRow ⟨6, 1, 4, 5⟩ (denote cache_6), placeRow ⟨218, 2, 4, 3⟩ (denote cache_218)] = denote cache_482 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_482 + +theorem verified_row_483 : fork [place ⟨173, 1, 4, 5⟩ cache_173, place ⟨292, 7, 3, 1⟩ cache_292, place ⟨319, 1, 3, 5⟩ cache_319, place ⟨192, 6, 4, 1⟩ cache_192, place ⟨475, 1, 4, 5⟩ cache_475] = cache_483 := by + decide +kernel + +theorem load_entry_483 : entryAt 483 = entry_483 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_483 : CacheEquation 483 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(483 < 6)), load_entry_483] + change forkRow [placeRow ⟨173, 1, 4, 5⟩ (denote cache_173), placeRow ⟨292, 7, 3, 1⟩ (denote cache_292), placeRow ⟨319, 1, 3, 5⟩ (denote cache_319), placeRow ⟨192, 6, 4, 1⟩ (denote cache_192), placeRow ⟨475, 1, 4, 5⟩ (denote cache_475)] = denote cache_483 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_483 + +theorem verified_row_484 : fork [place ⟨25, 4, 1, 5⟩ cache_25, place ⟨107, 2, 5, 4⟩ cache_107, place ⟨349, 3, 1, 5⟩ cache_349, place ⟨163, 2, 5, 4⟩ cache_163] = cache_484 := by + decide +kernel + +theorem load_entry_484 : entryAt 484 = entry_484 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_484 : CacheEquation 484 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(484 < 6)), load_entry_484] + change forkRow [placeRow ⟨25, 4, 1, 5⟩ (denote cache_25), placeRow ⟨107, 2, 5, 4⟩ (denote cache_107), placeRow ⟨349, 3, 1, 5⟩ (denote cache_349), placeRow ⟨163, 2, 5, 4⟩ (denote cache_163)] = denote cache_484 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_484 + +theorem verified_row_485 : fork [place ⟨484, 0, 5, 4⟩ cache_484, place ⟨2, 3, 4, 3⟩ cache_2] = cache_485 := by + decide +kernel + +theorem load_entry_485 : entryAt 485 = entry_485 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_485 : CacheEquation 485 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(485 < 6)), load_entry_485] + change forkRow [placeRow ⟨484, 0, 5, 4⟩ (denote cache_484), placeRow ⟨2, 3, 4, 3⟩ (denote cache_2)] = denote cache_485 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_485 + +theorem verified_row_486 : fork [place ⟨2, 5, 4, 2⟩ cache_2, place ⟨485, 0, 5, 3⟩ cache_485] = cache_486 := by + decide +kernel + +theorem load_entry_486 : entryAt 486 = entry_486 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_486 : CacheEquation 486 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(486 < 6)), load_entry_486] + change forkRow [placeRow ⟨2, 5, 4, 2⟩ (denote cache_2), placeRow ⟨485, 0, 5, 3⟩ (denote cache_485)] = denote cache_486 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_486 + +theorem verified_row_487 : fork [place ⟨2, 3, 4, 3⟩ cache_2, place ⟨481, 0, 5, 4⟩ cache_481] = cache_487 := by + decide +kernel + +theorem load_entry_487 : entryAt 487 = entry_487 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_487 : CacheEquation 487 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(487 < 6)), load_entry_487] + change forkRow [placeRow ⟨2, 3, 4, 3⟩ (denote cache_2), placeRow ⟨481, 0, 5, 4⟩ (denote cache_481)] = denote cache_487 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_487 + +theorem verified_row_488 : fork [place ⟨0, 6, 6, 4⟩ cache_0, place ⟨247, 0, 2, 5⟩ cache_247] = cache_488 := by + decide +kernel + +theorem load_entry_488 : entryAt 488 = entry_488 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_488 : CacheEquation 488 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(488 < 6)), load_entry_488] + change forkRow [placeRow ⟨0, 6, 6, 4⟩ (denote cache_0), placeRow ⟨247, 0, 2, 5⟩ (denote cache_247)] = denote cache_488 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_488 + +theorem verified_row_489 : fork [place ⟨356, 1, 3, 3⟩ cache_356, place ⟨197, 4, 1, 4⟩ cache_197, place ⟨172, 6, 1, 4⟩ cache_172] = cache_489 := by + decide +kernel + +theorem load_entry_489 : entryAt 489 = entry_489 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_489 : CacheEquation 489 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(489 < 6)), load_entry_489] + change forkRow [placeRow ⟨356, 1, 3, 3⟩ (denote cache_356), placeRow ⟨197, 4, 1, 4⟩ (denote cache_197), placeRow ⟨172, 6, 1, 4⟩ (denote cache_172)] = denote cache_489 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_489 + +theorem verified_row_490 : fork [place ⟨64, 1, 3, 1⟩ cache_64, place ⟨471, 0, 5, 1⟩ cache_471, place ⟨470, 1, 5, 1⟩ cache_470, place ⟨111, 0, 3, 1⟩ cache_111] = cache_490 := by + decide +kernel + +theorem load_entry_490 : entryAt 490 = entry_490 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_490 : CacheEquation 490 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(490 < 6)), load_entry_490] + change forkRow [placeRow ⟨64, 1, 3, 1⟩ (denote cache_64), placeRow ⟨471, 0, 5, 1⟩ (denote cache_471), placeRow ⟨470, 1, 5, 1⟩ (denote cache_470), placeRow ⟨111, 0, 3, 1⟩ (denote cache_111)] = denote cache_490 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_490 + +theorem verified_row_491 : fork [place ⟨6, 3, 3, 5⟩ cache_6, place ⟨273, 0, 5, 4⟩ cache_273] = cache_491 := by + decide +kernel + +theorem load_entry_491 : entryAt 491 = entry_491 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_491 : CacheEquation 491 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(491 < 6)), load_entry_491] + change forkRow [placeRow ⟨6, 3, 3, 5⟩ (denote cache_6), placeRow ⟨273, 0, 5, 4⟩ (denote cache_273)] = denote cache_491 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_491 + +theorem verified_row_492 : fork [place ⟨62, 4, 3, 4⟩ cache_62, place ⟨107, 4, 3, 4⟩ cache_107, place ⟨487, 0, 6, 6⟩ cache_487] = cache_492 := by + decide +kernel + +theorem load_entry_492 : entryAt 492 = entry_492 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_492 : CacheEquation 492 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(492 < 6)), load_entry_492] + change forkRow [placeRow ⟨62, 4, 3, 4⟩ (denote cache_62), placeRow ⟨107, 4, 3, 4⟩ (denote cache_107), placeRow ⟨487, 0, 6, 6⟩ (denote cache_487)] = denote cache_492 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_492 + +theorem verified_row_493 : fork [place ⟨225, 0, 1, 4⟩ cache_225, place ⟨455, 0, 5, 3⟩ cache_455, place ⟨236, 1, 5, 5⟩ cache_236, place ⟨221, 0, 5, 4⟩ cache_221] = cache_493 := by + decide +kernel + +theorem load_entry_493 : entryAt 493 = entry_493 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_493 : CacheEquation 493 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(493 < 6)), load_entry_493] + change forkRow [placeRow ⟨225, 0, 1, 4⟩ (denote cache_225), placeRow ⟨455, 0, 5, 3⟩ (denote cache_455), placeRow ⟨236, 1, 5, 5⟩ (denote cache_236), placeRow ⟨221, 0, 5, 4⟩ (denote cache_221)] = denote cache_493 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_493 + +theorem verified_row_494 : fork [place ⟨297, 4, 4, 5⟩ cache_297, place ⟨268, 4, 1, 5⟩ cache_268, place ⟨162, 5, 5, 4⟩ cache_162] = cache_494 := by + decide +kernel + +theorem load_entry_494 : entryAt 494 = entry_494 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_494 : CacheEquation 494 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(494 < 6)), load_entry_494] + change forkRow [placeRow ⟨297, 4, 4, 5⟩ (denote cache_297), placeRow ⟨268, 4, 1, 5⟩ (denote cache_268), placeRow ⟨162, 5, 5, 4⟩ (denote cache_162)] = denote cache_494 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_494 + +theorem verified_row_495 : fork [place ⟨25, 6, 1, 3⟩ cache_25, place ⟨167, 4, 1, 4⟩ cache_167, place ⟨456, 4, 1, 4⟩ cache_456] = cache_495 := by + decide +kernel + +theorem load_entry_495 : entryAt 495 = entry_495 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_495 : CacheEquation 495 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(495 < 6)), load_entry_495] + change forkRow [placeRow ⟨25, 6, 1, 3⟩ (denote cache_25), placeRow ⟨167, 4, 1, 4⟩ (denote cache_167), placeRow ⟨456, 4, 1, 4⟩ (denote cache_456)] = denote cache_495 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_495 + +theorem verified_row_496 : fork [place ⟨25, 0, 7, 5⟩ cache_25, place ⟨107, 6, 3, 4⟩ cache_107, place ⟨163, 6, 3, 4⟩ cache_163, place ⟨494, 0, 7, 4⟩ cache_494] = cache_496 := by + decide +kernel + +theorem load_entry_496 : entryAt 496 = entry_496 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_496 : CacheEquation 496 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(496 < 6)), load_entry_496] + change forkRow [placeRow ⟨25, 0, 7, 5⟩ (denote cache_25), placeRow ⟨107, 6, 3, 4⟩ (denote cache_107), placeRow ⟨163, 6, 3, 4⟩ (denote cache_163), placeRow ⟨494, 0, 7, 4⟩ (denote cache_494)] = denote cache_496 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_496 + +theorem verified_row_497 : fork [place ⟨36, 2, 3, 4⟩ cache_36, place ⟨167, 0, 7, 4⟩ cache_167, place ⟨410, 0, 7, 3⟩ cache_410] = cache_497 := by + decide +kernel + +theorem load_entry_497 : entryAt 497 = entry_497 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_497 : CacheEquation 497 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(497 < 6)), load_entry_497] + change forkRow [placeRow ⟨36, 2, 3, 4⟩ (denote cache_36), placeRow ⟨167, 0, 7, 4⟩ (denote cache_167), placeRow ⟨410, 0, 7, 3⟩ (denote cache_410)] = denote cache_497 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_497 + +theorem verified_row_498 : fork [place ⟨14, 1, 4, 6⟩ cache_14, place ⟨298, 2, 2, 4⟩ cache_298] = cache_498 := by + decide +kernel + +theorem load_entry_498 : entryAt 498 = entry_498 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_498 : CacheEquation 498 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(498 < 6)), load_entry_498] + change forkRow [placeRow ⟨14, 1, 4, 6⟩ (denote cache_14), placeRow ⟨298, 2, 2, 4⟩ (denote cache_298)] = denote cache_498 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_498 + +theorem verified_row_499 : fork [place ⟨493, 0, 5, 4⟩ cache_493, place ⟨25, 1, 4, 5⟩ cache_25, place ⟨478, 0, 2, 4⟩ cache_478] = cache_499 := by + decide +kernel + +theorem load_entry_499 : entryAt 499 = entry_499 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_499 : CacheEquation 499 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(499 < 6)), load_entry_499] + change forkRow [placeRow ⟨493, 0, 5, 4⟩ (denote cache_493), placeRow ⟨25, 1, 4, 5⟩ (denote cache_25), placeRow ⟨478, 0, 2, 4⟩ (denote cache_478)] = denote cache_499 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_499 + +theorem verified_row_500 : fork [place ⟨1, 5, 3, 6⟩ cache_1, place ⟨351, 0, 5, 4⟩ cache_351] = cache_500 := by + decide +kernel + +theorem load_entry_500 : entryAt 500 = entry_500 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_500 : CacheEquation 500 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(500 < 6)), load_entry_500] + change forkRow [placeRow ⟨1, 5, 3, 6⟩ (denote cache_1), placeRow ⟨351, 0, 5, 4⟩ (denote cache_351)] = denote cache_500 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_500 + +theorem verified_row_501 : fork [place ⟨6, 4, 0, 5⟩ cache_6, place ⟨316, 0, 1, 3⟩ cache_316] = cache_501 := by + decide +kernel + +theorem load_entry_501 : entryAt 501 = entry_501 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_501 : CacheEquation 501 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(501 < 6)), load_entry_501] + change forkRow [placeRow ⟨6, 4, 0, 5⟩ (denote cache_6), placeRow ⟨316, 0, 1, 3⟩ (denote cache_316)] = denote cache_501 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_501 + +theorem verified_row_502 : fork [place ⟨215, 6, 2, 3⟩ cache_215, place ⟨232, 0, 4, 3⟩ cache_232, place ⟨192, 7, 1, 4⟩ cache_192, place ⟨173, 0, 5, 4⟩ cache_173, place ⟨271, 2, 2, 3⟩ cache_271] = cache_502 := by + decide +kernel + +theorem load_entry_502 : entryAt 502 = entry_502 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_502 : CacheEquation 502 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(502 < 6)), load_entry_502] + change forkRow [placeRow ⟨215, 6, 2, 3⟩ (denote cache_215), placeRow ⟨232, 0, 4, 3⟩ (denote cache_232), placeRow ⟨192, 7, 1, 4⟩ (denote cache_192), placeRow ⟨173, 0, 5, 4⟩ (denote cache_173), placeRow ⟨271, 2, 2, 3⟩ (denote cache_271)] = denote cache_502 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_502 + +theorem verified_row_503 : fork [place ⟨63, 0, 3, 5⟩ cache_63, place ⟨55, 7, 4, 0⟩ cache_55, place ⟨420, 1, 7, 2⟩ cache_420, place ⟨419, 1, 7, 4⟩ cache_419] = cache_503 := by + decide +kernel + +theorem load_entry_503 : entryAt 503 = entry_503 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_503 : CacheEquation 503 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(503 < 6)), load_entry_503] + change forkRow [placeRow ⟨63, 0, 3, 5⟩ (denote cache_63), placeRow ⟨55, 7, 4, 0⟩ (denote cache_55), placeRow ⟨420, 1, 7, 2⟩ (denote cache_420), placeRow ⟨419, 1, 7, 4⟩ (denote cache_419)] = denote cache_503 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_503 + +theorem verified_row_504 : fork [place ⟨381, 0, 3, 4⟩ cache_381, place ⟨310, 4, 4, 5⟩ cache_310, place ⟨159, 0, 5, 6⟩ cache_159, place ⟨351, 4, 3, 4⟩ cache_351, place ⟨496, 0, 3, 4⟩ cache_496] = cache_504 := by + decide +kernel + +theorem load_entry_504 : entryAt 504 = entry_504 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_504 : CacheEquation 504 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(504 < 6)), load_entry_504] + change forkRow [placeRow ⟨381, 0, 3, 4⟩ (denote cache_381), placeRow ⟨310, 4, 4, 5⟩ (denote cache_310), placeRow ⟨159, 0, 5, 6⟩ (denote cache_159), placeRow ⟨351, 4, 3, 4⟩ (denote cache_351), placeRow ⟨496, 0, 3, 4⟩ (denote cache_496)] = denote cache_504 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_504 + +theorem verified_row_505 : fork [place ⟨173, 1, 4, 5⟩ cache_173, place ⟨499, 0, 5, 4⟩ cache_499, place ⟨183, 1, 4, 5⟩ cache_183, place ⟨282, 1, 4, 5⟩ cache_282] = cache_505 := by + decide +kernel + +theorem load_entry_505 : entryAt 505 = entry_505 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_505 : CacheEquation 505 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(505 < 6)), load_entry_505] + change forkRow [placeRow ⟨173, 1, 4, 5⟩ (denote cache_173), placeRow ⟨499, 0, 5, 4⟩ (denote cache_499), placeRow ⟨183, 1, 4, 5⟩ (denote cache_183), placeRow ⟨282, 1, 4, 5⟩ (denote cache_282)] = denote cache_505 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_505 + +theorem verified_row_506 : fork [place ⟨99, 0, 4, 5⟩ cache_99, place ⟨200, 7, 1, 4⟩ cache_200, place ⟨318, 5, 5, 4⟩ cache_318, place ⟨173, 0, 5, 4⟩ cache_173] = cache_506 := by + decide +kernel + +theorem load_entry_506 : entryAt 506 = entry_506 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_506 : CacheEquation 506 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(506 < 6)), load_entry_506] + change forkRow [placeRow ⟨99, 0, 4, 5⟩ (denote cache_99), placeRow ⟨200, 7, 1, 4⟩ (denote cache_200), placeRow ⟨318, 5, 5, 4⟩ (denote cache_318), placeRow ⟨173, 0, 5, 4⟩ (denote cache_173)] = denote cache_506 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_506 + +theorem verified_row_507 : fork [place ⟨151, 0, 2, 4⟩ cache_151, place ⟨33, 3, 4, 3⟩ cache_33, place ⟨481, 0, 5, 4⟩ cache_481] = cache_507 := by + decide +kernel + +theorem load_entry_507 : entryAt 507 = entry_507 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_507 : CacheEquation 507 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(507 < 6)), load_entry_507] + change forkRow [placeRow ⟨151, 0, 2, 4⟩ (denote cache_151), placeRow ⟨33, 3, 4, 3⟩ (denote cache_33), placeRow ⟨481, 0, 5, 4⟩ (denote cache_481)] = denote cache_507 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_507 + +theorem verified_row_508 : fork [place ⟨6, 0, 5, 4⟩ cache_6, place ⟨393, 0, 1, 5⟩ cache_393] = cache_508 := by + decide +kernel + +theorem load_entry_508 : entryAt 508 = entry_508 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_508 : CacheEquation 508 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(508 < 6)), load_entry_508] + change forkRow [placeRow ⟨6, 0, 5, 4⟩ (denote cache_6), placeRow ⟨393, 0, 1, 5⟩ (denote cache_393)] = denote cache_508 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_508 + +theorem verified_row_509 : fork [place ⟨252, 0, 6, 4⟩ cache_252, place ⟨241, 4, 2, 4⟩ cache_241, place ⟨455, 0, 6, 3⟩ cache_455, place ⟨68, 2, 6, 4⟩ cache_68] = cache_509 := by + decide +kernel + +theorem load_entry_509 : entryAt 509 = entry_509 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_509 : CacheEquation 509 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(509 < 6)), load_entry_509] + change forkRow [placeRow ⟨252, 0, 6, 4⟩ (denote cache_252), placeRow ⟨241, 4, 2, 4⟩ (denote cache_241), placeRow ⟨455, 0, 6, 3⟩ (denote cache_455), placeRow ⟨68, 2, 6, 4⟩ (denote cache_68)] = denote cache_509 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_509 + +theorem verified_row_510 : fork [place ⟨6, 4, 3, 4⟩ cache_6, place ⟨508, 0, 7, 4⟩ cache_508] = cache_510 := by + decide +kernel + +theorem load_entry_510 : entryAt 510 = entry_510 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_510 : CacheEquation 510 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(510 < 6)), load_entry_510] + change forkRow [placeRow ⟨6, 4, 3, 4⟩ (denote cache_6), placeRow ⟨508, 0, 7, 4⟩ (denote cache_508)] = denote cache_510 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_510 + +theorem verified_row_511 : fork [place ⟨15, 1, 4, 5⟩ cache_15, place ⟨331, 0, 5, 3⟩ cache_331, place ⟨380, 4, 2, 4⟩ cache_380] = cache_511 := by + decide +kernel + +theorem load_entry_511 : entryAt 511 = entry_511 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_511 : CacheEquation 511 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(511 < 6)), load_entry_511] + change forkRow [placeRow ⟨15, 1, 4, 5⟩ (denote cache_15), placeRow ⟨331, 0, 5, 3⟩ (denote cache_331), placeRow ⟨380, 4, 2, 4⟩ (denote cache_380)] = denote cache_511 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_511 + +theorem verified_row_512 : fork [place ⟨62, 0, 5, 4⟩ cache_62, place ⟨107, 0, 5, 4⟩ cache_107, place ⟨507, 0, 4, 6⟩ cache_507] = cache_512 := by + decide +kernel + +theorem load_entry_512 : entryAt 512 = entry_512 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_512 : CacheEquation 512 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(512 < 6)), load_entry_512] + change forkRow [placeRow ⟨62, 0, 5, 4⟩ (denote cache_62), placeRow ⟨107, 0, 5, 4⟩ (denote cache_107), placeRow ⟨507, 0, 4, 6⟩ (denote cache_507)] = denote cache_512 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_512 + +theorem verified_row_513 : fork [place ⟨6, 4, 3, 4⟩ cache_6, place ⟨396, 0, 4, 5⟩ cache_396] = cache_513 := by + decide +kernel + +theorem load_entry_513 : entryAt 513 = entry_513 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_513 : CacheEquation 513 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(513 < 6)), load_entry_513] + change forkRow [placeRow ⟨6, 4, 3, 4⟩ (denote cache_6), placeRow ⟨396, 0, 4, 5⟩ (denote cache_396)] = denote cache_513 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_513 + +theorem verified_row_514 : fork [place ⟨57, 0, 5, 4⟩ cache_57, place ⟨443, 4, 1, 5⟩ cache_443, place ⟨510, 0, 1, 5⟩ cache_510] = cache_514 := by + decide +kernel + +theorem load_entry_514 : entryAt 514 = entry_514 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_514 : CacheEquation 514 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(514 < 6)), load_entry_514] + change forkRow [placeRow ⟨57, 0, 5, 4⟩ (denote cache_57), placeRow ⟨443, 4, 1, 5⟩ (denote cache_443), placeRow ⟨510, 0, 1, 5⟩ (denote cache_510)] = denote cache_514 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_514 + +theorem verified_row_515 : fork [place ⟨2, 6, 2, 4⟩ cache_2, place ⟨512, 1, 1, 5⟩ cache_512] = cache_515 := by + decide +kernel + +theorem load_entry_515 : entryAt 515 = entry_515 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_515 : CacheEquation 515 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(515 < 6)), load_entry_515] + change forkRow [placeRow ⟨2, 6, 2, 4⟩ (denote cache_2), placeRow ⟨512, 1, 1, 5⟩ (denote cache_512)] = denote cache_515 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_515 + +theorem verified_row_516 : fork [place ⟨329, 0, 4, 3⟩ cache_329, place ⟨244, 4, 2, 4⟩ cache_244, place ⟨10, 1, 4, 5⟩ cache_10, place ⟨506, 4, 2, 4⟩ cache_506] = cache_516 := by + decide +kernel + +theorem load_entry_516 : entryAt 516 = entry_516 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_516 : CacheEquation 516 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(516 < 6)), load_entry_516] + change forkRow [placeRow ⟨329, 0, 4, 3⟩ (denote cache_329), placeRow ⟨244, 4, 2, 4⟩ (denote cache_244), placeRow ⟨10, 1, 4, 5⟩ (denote cache_10), placeRow ⟨506, 4, 2, 4⟩ (denote cache_506)] = denote cache_516 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_516 + +theorem verified_row_517 : fork [place ⟨496, 0, 2, 3⟩ cache_496, place ⟨140, 0, 4, 2⟩ cache_140, place ⟨193, 1, 4, 2⟩ cache_193] = cache_517 := by + decide +kernel + +theorem load_entry_517 : entryAt 517 = entry_517 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_517 : CacheEquation 517 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(517 < 6)), load_entry_517] + change forkRow [placeRow ⟨496, 0, 2, 3⟩ (denote cache_496), placeRow ⟨140, 0, 4, 2⟩ (denote cache_140), placeRow ⟨193, 1, 4, 2⟩ (denote cache_193)] = denote cache_517 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_517 + +theorem verified_row_518 : fork [place ⟨9, 6, 3, 4⟩ cache_9, place ⟨514, 0, 7, 4⟩ cache_514] = cache_518 := by + decide +kernel + +theorem load_entry_518 : entryAt 518 = entry_518 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_518 : CacheEquation 518 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(518 < 6)), load_entry_518] + change forkRow [placeRow ⟨9, 6, 3, 4⟩ (denote cache_9), placeRow ⟨514, 0, 7, 4⟩ (denote cache_514)] = denote cache_518 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_518 + +theorem verified_row_519 : fork [place ⟨498, 0, 4, 3⟩ cache_498, place ⟨311, 4, 3, 4⟩ cache_311, place ⟨38, 1, 4, 5⟩ cache_38, place ⟨408, 0, 3, 4⟩ cache_408] = cache_519 := by + decide +kernel + +theorem load_entry_519 : entryAt 519 = entry_519 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_519 : CacheEquation 519 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(519 < 6)), load_entry_519] + change forkRow [placeRow ⟨498, 0, 4, 3⟩ (denote cache_498), placeRow ⟨311, 4, 3, 4⟩ (denote cache_311), placeRow ⟨38, 1, 4, 5⟩ (denote cache_38), placeRow ⟨408, 0, 3, 4⟩ (denote cache_408)] = denote cache_519 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_519 + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Equations13.lean b/lean/OAI/Combinatorics/SnakyCertificate/Equations13.lean new file mode 100644 index 0000000000000000000000000000000000000000..d18b13941913acef95bb339f502f93e0d2c61f23 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Equations13.lean @@ -0,0 +1,530 @@ +import OAI.Combinatorics.SnakyCertificate.Cache +import OAI.Combinatorics.SnakyCertificate.TableList + +namespace OAI + +namespace SnakyCertificate.Check + +theorem verified_row_520 : fork [place ⟨254, 0, 2, 3⟩ cache_254, place ⟨200, 5, 6, 4⟩ cache_200, place ⟨271, 6, 5, 3⟩ cache_271, place ⟨215, 2, 5, 3⟩ cache_215, place ⟨252, 4, 2, 4⟩ cache_252] = cache_520 := by + decide +kernel + +theorem load_entry_520 : entryAt 520 = entry_520 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_520 : CacheEquation 520 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(520 < 6)), load_entry_520] + change forkRow [placeRow ⟨254, 0, 2, 3⟩ (denote cache_254), placeRow ⟨200, 5, 6, 4⟩ (denote cache_200), placeRow ⟨271, 6, 5, 3⟩ (denote cache_271), placeRow ⟨215, 2, 5, 3⟩ (denote cache_215), placeRow ⟨252, 4, 2, 4⟩ (denote cache_252)] = denote cache_520 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_520 + +theorem verified_row_521 : fork [place ⟨492, 4, 5, 1⟩ cache_492, place ⟨2, 7, 4, 2⟩ cache_2] = cache_521 := by + decide +kernel + +theorem load_entry_521 : entryAt 521 = entry_521 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_521 : CacheEquation 521 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(521 < 6)), load_entry_521] + change forkRow [placeRow ⟨492, 4, 5, 1⟩ (denote cache_492), placeRow ⟨2, 7, 4, 2⟩ (denote cache_2)] = denote cache_521 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_521 + +theorem verified_row_522 : fork [place ⟨176, 3, 4, 6⟩ cache_176, place ⟨338, 2, 3, 3⟩ cache_338, place ⟨252, 1, 4, 6⟩ cache_252] = cache_522 := by + decide +kernel + +theorem load_entry_522 : entryAt 522 = entry_522 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_522 : CacheEquation 522 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(522 < 6)), load_entry_522] + change forkRow [placeRow ⟨176, 3, 4, 6⟩ (denote cache_176), placeRow ⟨338, 2, 3, 3⟩ (denote cache_338), placeRow ⟨252, 1, 4, 6⟩ (denote cache_252)] = denote cache_522 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_522 + +theorem verified_row_523 : fork [place ⟨303, 1, 5, 4⟩ cache_303, place ⟨25, 4, 1, 5⟩ cache_25, place ⟨107, 2, 5, 4⟩ cache_107, place ⟨511, 4, 1, 6⟩ cache_511] = cache_523 := by + decide +kernel + +theorem load_entry_523 : entryAt 523 = entry_523 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_523 : CacheEquation 523 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(523 < 6)), load_entry_523] + change forkRow [placeRow ⟨303, 1, 5, 4⟩ (denote cache_303), placeRow ⟨25, 4, 1, 5⟩ (denote cache_25), placeRow ⟨107, 2, 5, 4⟩ (denote cache_107), placeRow ⟨511, 4, 1, 6⟩ (denote cache_511)] = denote cache_523 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_523 + +theorem verified_row_524 : fork [place ⟨504, 4, 5, 3⟩ cache_504, place ⟨504, 0, 3, 3⟩ cache_504, place ⟨180, 0, 4, 5⟩ cache_180, place ⟨180, 4, 4, 5⟩ cache_180, place ⟨261, 0, 3, 4⟩ cache_261] = cache_524 := by + decide +kernel + +theorem load_entry_524 : entryAt 524 = entry_524 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_524 : CacheEquation 524 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(524 < 6)), load_entry_524] + change forkRow [placeRow ⟨504, 4, 5, 3⟩ (denote cache_504), placeRow ⟨504, 0, 3, 3⟩ (denote cache_504), placeRow ⟨180, 0, 4, 5⟩ (denote cache_180), placeRow ⟨180, 4, 4, 5⟩ (denote cache_180), placeRow ⟨261, 0, 3, 4⟩ (denote cache_261)] = denote cache_524 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_524 + +theorem verified_row_525 : fork [place ⟨303, 1, 5, 4⟩ cache_303, place ⟨25, 4, 1, 5⟩ cache_25, place ⟨430, 0, 4, 6⟩ cache_430, place ⟨107, 2, 5, 4⟩ cache_107] = cache_525 := by + decide +kernel + +theorem load_entry_525 : entryAt 525 = entry_525 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_525 : CacheEquation 525 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(525 < 6)), load_entry_525] + change forkRow [placeRow ⟨303, 1, 5, 4⟩ (denote cache_303), placeRow ⟨25, 4, 1, 5⟩ (denote cache_25), placeRow ⟨430, 0, 4, 6⟩ (denote cache_430), placeRow ⟨107, 2, 5, 4⟩ (denote cache_107)] = denote cache_525 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_525 + +theorem verified_row_526 : fork [place ⟨359, 0, 4, 3⟩ cache_359, place ⟨416, 4, 2, 4⟩ cache_416, place ⟨327, 5, 4, 3⟩ cache_327, place ⟨489, 0, 5, 4⟩ cache_489, place ⟨399, 3, 2, 4⟩ cache_399] = cache_526 := by + decide +kernel + +theorem load_entry_526 : entryAt 526 = entry_526 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_526 : CacheEquation 526 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(526 < 6)), load_entry_526] + change forkRow [placeRow ⟨359, 0, 4, 3⟩ (denote cache_359), placeRow ⟨416, 4, 2, 4⟩ (denote cache_416), placeRow ⟨327, 5, 4, 3⟩ (denote cache_327), placeRow ⟨489, 0, 5, 4⟩ (denote cache_489), placeRow ⟨399, 3, 2, 4⟩ (denote cache_399)] = denote cache_526 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_526 + +theorem verified_row_527 : fork [place ⟨387, 4, 4, 3⟩ cache_387, place ⟨38, 3, 4, 5⟩ cache_38, place ⟨491, 0, 5, 4⟩ cache_491, place ⟨519, 0, 6, 4⟩ cache_519] = cache_527 := by + decide +kernel + +theorem load_entry_527 : entryAt 527 = entry_527 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_527 : CacheEquation 527 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(527 < 6)), load_entry_527] + change forkRow [placeRow ⟨387, 4, 4, 3⟩ (denote cache_387), placeRow ⟨38, 3, 4, 5⟩ (denote cache_38), placeRow ⟨491, 0, 5, 4⟩ (denote cache_491), placeRow ⟨519, 0, 6, 4⟩ (denote cache_519)] = denote cache_527 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_527 + +theorem verified_row_528 : fork [place ⟨414, 1, 3, 5⟩ cache_414, place ⟨386, 1, 4, 6⟩ cache_386, place ⟨502, 5, 4, 3⟩ cache_502, place ⟨226, 4, 1, 5⟩ cache_226, place ⟨359, 5, 3, 4⟩ cache_359] = cache_528 := by + decide +kernel + +theorem load_entry_528 : entryAt 528 = entry_528 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_528 : CacheEquation 528 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(528 < 6)), load_entry_528] + change forkRow [placeRow ⟨414, 1, 3, 5⟩ (denote cache_414), placeRow ⟨386, 1, 4, 6⟩ (denote cache_386), placeRow ⟨502, 5, 4, 3⟩ (denote cache_502), placeRow ⟨226, 4, 1, 5⟩ (denote cache_226), placeRow ⟨359, 5, 3, 4⟩ (denote cache_359)] = denote cache_528 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_528 + +theorem verified_row_529 : fork [place ⟨55, 4, 3, 4⟩ cache_55, place ⟨441, 0, 4, 3⟩ cache_441, place ⟨63, 3, 3, 3⟩ cache_63, place ⟨64, 6, 7, 5⟩ cache_64] = cache_529 := by + decide +kernel + +theorem load_entry_529 : entryAt 529 = entry_529 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_529 : CacheEquation 529 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(529 < 6)), load_entry_529] + change forkRow [placeRow ⟨55, 4, 3, 4⟩ (denote cache_55), placeRow ⟨441, 0, 4, 3⟩ (denote cache_441), placeRow ⟨63, 3, 3, 3⟩ (denote cache_63), placeRow ⟨64, 6, 7, 5⟩ (denote cache_64)] = denote cache_529 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_529 + +theorem verified_row_530 : fork [place ⟨456, 7, 4, 2⟩ cache_456, place ⟨336, 0, 5, 5⟩ cache_336, place ⟨283, 7, 4, 2⟩ cache_283, place ⟨271, 5, 5, 5⟩ cache_271] = cache_530 := by + decide +kernel + +theorem load_entry_530 : entryAt 530 = entry_530 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_530 : CacheEquation 530 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(530 < 6)), load_entry_530] + change forkRow [placeRow ⟨456, 7, 4, 2⟩ (denote cache_456), placeRow ⟨336, 0, 5, 5⟩ (denote cache_336), placeRow ⟨283, 7, 4, 2⟩ (denote cache_283), placeRow ⟨271, 5, 5, 5⟩ (denote cache_271)] = denote cache_530 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_530 + +theorem verified_row_531 : fork [place ⟨425, 0, 5, 4⟩ cache_425, place ⟨336, 3, 4, 3⟩ cache_336, place ⟨340, 6, 4, 3⟩ cache_340, place ⟨394, 1, 5, 4⟩ cache_394, place ⟨423, 0, 5, 4⟩ cache_423, place ⟨526, 0, 5, 4⟩ cache_526, place ⟨401, 4, 4, 3⟩ cache_401, place ⟨453, 0, 5, 4⟩ cache_453] = cache_531 := by + decide +kernel + +theorem load_entry_531 : entryAt 531 = entry_531 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_531 : CacheEquation 531 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(531 < 6)), load_entry_531] + change forkRow [placeRow ⟨425, 0, 5, 4⟩ (denote cache_425), placeRow ⟨336, 3, 4, 3⟩ (denote cache_336), placeRow ⟨340, 6, 4, 3⟩ (denote cache_340), placeRow ⟨394, 1, 5, 4⟩ (denote cache_394), placeRow ⟨423, 0, 5, 4⟩ (denote cache_423), placeRow ⟨526, 0, 5, 4⟩ (denote cache_526), placeRow ⟨401, 4, 4, 3⟩ (denote cache_401), placeRow ⟨453, 0, 5, 4⟩ (denote cache_453)] = denote cache_531 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_531 + +theorem verified_row_532 : fork [place ⟨504, 4, 5, 3⟩ cache_504, place ⟨6, 7, 3, 0⟩ cache_6] = cache_532 := by + decide +kernel + +theorem load_entry_532 : entryAt 532 = entry_532 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_532 : CacheEquation 532 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(532 < 6)), load_entry_532] + change forkRow [placeRow ⟨504, 4, 5, 3⟩ (denote cache_504), placeRow ⟨6, 7, 3, 0⟩ (denote cache_6)] = denote cache_532 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_532 + +theorem verified_row_533 : fork [place ⟨318, 4, 4, 5⟩ cache_318, place ⟨319, 7, 5, 1⟩ cache_319, place ⟨407, 4, 4, 1⟩ cache_407, place ⟨173, 3, 4, 5⟩ cache_173, place ⟨217, 1, 4, 5⟩ cache_217] = cache_533 := by + decide +kernel + +theorem load_entry_533 : entryAt 533 = entry_533 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_533 : CacheEquation 533 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(533 < 6)), load_entry_533] + change forkRow [placeRow ⟨318, 4, 4, 5⟩ (denote cache_318), placeRow ⟨319, 7, 5, 1⟩ (denote cache_319), placeRow ⟨407, 4, 4, 1⟩ (denote cache_407), placeRow ⟨173, 3, 4, 5⟩ (denote cache_173), placeRow ⟨217, 1, 4, 5⟩ (denote cache_217)] = denote cache_533 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_533 + +theorem verified_row_534 : fork [place ⟨434, 0, 4, 6⟩ cache_434, place ⟨12, 6, 1, 3⟩ cache_12] = cache_534 := by + decide +kernel + +theorem load_entry_534 : entryAt 534 = entry_534 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_534 : CacheEquation 534 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(534 < 6)), load_entry_534] + change forkRow [placeRow ⟨434, 0, 4, 6⟩ (denote cache_434), placeRow ⟨12, 6, 1, 3⟩ (denote cache_12)] = denote cache_534 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_534 + +theorem verified_row_535 : fork [place ⟨444, 0, 4, 5⟩ cache_444, place ⟨426, 0, 4, 5⟩ cache_426, place ⟨25, 0, 5, 4⟩ cache_25, place ⟨321, 4, 4, 2⟩ cache_321] = cache_535 := by + decide +kernel + +theorem load_entry_535 : entryAt 535 = entry_535 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_535 : CacheEquation 535 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(535 < 6)), load_entry_535] + change forkRow [placeRow ⟨444, 0, 4, 5⟩ (denote cache_444), placeRow ⟨426, 0, 4, 5⟩ (denote cache_426), placeRow ⟨25, 0, 5, 4⟩ (denote cache_25), placeRow ⟨321, 4, 4, 2⟩ (denote cache_321)] = denote cache_535 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_535 + +theorem verified_row_536 : fork [place ⟨307, 0, 4, 3⟩ cache_307, place ⟨244, 0, 5, 4⟩ cache_244, place ⟨26, 3, 4, 3⟩ cache_26, place ⟨534, 0, 5, 2⟩ cache_534] = cache_536 := by + decide +kernel + +theorem load_entry_536 : entryAt 536 = entry_536 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_536 : CacheEquation 536 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(536 < 6)), load_entry_536] + change forkRow [placeRow ⟨307, 0, 4, 3⟩ (denote cache_307), placeRow ⟨244, 0, 5, 4⟩ (denote cache_244), placeRow ⟨26, 3, 4, 3⟩ (denote cache_26), placeRow ⟨534, 0, 5, 2⟩ (denote cache_534)] = denote cache_536 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_536 + +theorem verified_row_537 : fork [place ⟨373, 2, 2, 4⟩ cache_373, place ⟨271, 3, 3, 3⟩ cache_271, place ⟨176, 1, 4, 6⟩ cache_176, place ⟨330, 1, 4, 6⟩ cache_330] = cache_537 := by + decide +kernel + +theorem load_entry_537 : entryAt 537 = entry_537 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_537 : CacheEquation 537 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(537 < 6)), load_entry_537] + change forkRow [placeRow ⟨373, 2, 2, 4⟩ (denote cache_373), placeRow ⟨271, 3, 3, 3⟩ (denote cache_271), placeRow ⟨176, 1, 4, 6⟩ (denote cache_176), placeRow ⟨330, 1, 4, 6⟩ (denote cache_330)] = denote cache_537 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_537 + +theorem verified_row_538 : fork [place ⟨63, 3, 3, 3⟩ cache_63, place ⟨470, 0, 4, 5⟩ cache_470, place ⟨64, 6, 7, 5⟩ cache_64, place ⟨55, 4, 3, 4⟩ cache_55] = cache_538 := by + decide +kernel + +theorem load_entry_538 : entryAt 538 = entry_538 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_538 : CacheEquation 538 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(538 < 6)), load_entry_538] + change forkRow [placeRow ⟨63, 3, 3, 3⟩ (denote cache_63), placeRow ⟨470, 0, 4, 5⟩ (denote cache_470), placeRow ⟨64, 6, 7, 5⟩ (denote cache_64), placeRow ⟨55, 4, 3, 4⟩ (denote cache_55)] = denote cache_538 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_538 + +theorem verified_row_539 : fork [place ⟨51, 1, 5, 4⟩ cache_51, place ⟨488, 3, 4, 3⟩ cache_488, place ⟨428, 0, 5, 4⟩ cache_428, place ⟨516, 0, 5, 4⟩ cache_516] = cache_539 := by + decide +kernel + +theorem load_entry_539 : entryAt 539 = entry_539 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_539 : CacheEquation 539 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(539 < 6)), load_entry_539] + change forkRow [placeRow ⟨51, 1, 5, 4⟩ (denote cache_51), placeRow ⟨488, 3, 4, 3⟩ (denote cache_488), placeRow ⟨428, 0, 5, 4⟩ (denote cache_428), placeRow ⟨516, 0, 5, 4⟩ (denote cache_516)] = denote cache_539 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_539 + +theorem verified_row_540 : fork [place ⟨334, 0, 4, 3⟩ cache_334, place ⟨51, 1, 5, 4⟩ cache_51, place ⟨88, 3, 4, 3⟩ cache_88, place ⟨536, 0, 5, 4⟩ cache_536] = cache_540 := by + decide +kernel + +theorem load_entry_540 : entryAt 540 = entry_540 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_540 : CacheEquation 540 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(540 < 6)), load_entry_540] + change forkRow [placeRow ⟨334, 0, 4, 3⟩ (denote cache_334), placeRow ⟨51, 1, 5, 4⟩ (denote cache_51), placeRow ⟨88, 3, 4, 3⟩ (denote cache_88), placeRow ⟨536, 0, 5, 4⟩ (denote cache_536)] = denote cache_540 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_540 + +theorem verified_row_541 : fork [place ⟨236, 0, 5, 5⟩ cache_236, place ⟨142, 7, 4, 1⟩ cache_142, place ⟨160, 3, 4, 1⟩ cache_160, place ⟨194, 0, 5, 3⟩ cache_194, place ⟨501, 4, 1, 2⟩ cache_501, place ⟨412, 0, 5, 3⟩ cache_412] = cache_541 := by + decide +kernel + +theorem load_entry_541 : entryAt 541 = entry_541 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_541 : CacheEquation 541 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(541 < 6)), load_entry_541] + change forkRow [placeRow ⟨236, 0, 5, 5⟩ (denote cache_236), placeRow ⟨142, 7, 4, 1⟩ (denote cache_142), placeRow ⟨160, 3, 4, 1⟩ (denote cache_160), placeRow ⟨194, 0, 5, 3⟩ (denote cache_194), placeRow ⟨501, 4, 1, 2⟩ (denote cache_501), placeRow ⟨412, 0, 5, 3⟩ (denote cache_412)] = denote cache_541 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_541 + +theorem verified_row_542 : fork [place ⟨6, 5, 5, 0⟩ cache_6, place ⟨442, 0, 4, 5⟩ cache_442] = cache_542 := by + decide +kernel + +theorem load_entry_542 : entryAt 542 = entry_542 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_542 : CacheEquation 542 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(542 < 6)), load_entry_542] + change forkRow [placeRow ⟨6, 5, 5, 0⟩ (denote cache_6), placeRow ⟨442, 0, 4, 5⟩ (denote cache_442)] = denote cache_542 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_542 + +theorem verified_row_543 : fork [place ⟨493, 3, 2, 6⟩ cache_493, place ⟨107, 2, 5, 4⟩ cache_107, place ⟨318, 5, 5, 4⟩ cache_318] = cache_543 := by + decide +kernel + +theorem load_entry_543 : entryAt 543 = entry_543 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_543 : CacheEquation 543 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(543 < 6)), load_entry_543] + change forkRow [placeRow ⟨493, 3, 2, 6⟩ (denote cache_493), placeRow ⟨107, 2, 5, 4⟩ (denote cache_107), placeRow ⟨318, 5, 5, 4⟩ (denote cache_318)] = denote cache_543 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_543 + +theorem verified_row_544 : fork [place ⟨263, 2, 7, 4⟩ cache_263, place ⟨9, 6, 3, 4⟩ cache_9, place ⟨451, 1, 8, 3⟩ cache_451] = cache_544 := by + decide +kernel + +theorem load_entry_544 : entryAt 544 = entry_544 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_544 : CacheEquation 544 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(544 < 6)), load_entry_544] + change forkRow [placeRow ⟨263, 2, 7, 4⟩ (denote cache_263), placeRow ⟨9, 6, 3, 4⟩ (denote cache_9), placeRow ⟨451, 1, 8, 3⟩ (denote cache_451)] = denote cache_544 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_544 + +theorem verified_row_545 : fork [place ⟨256, 0, 4, 5⟩ cache_256, place ⟨448, 0, 5, 4⟩ cache_448, place ⟨153, 0, 6, 3⟩ cache_153, place ⟨343, 0, 4, 5⟩ cache_343] = cache_545 := by + decide +kernel + +theorem load_entry_545 : entryAt 545 = entry_545 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_545 : CacheEquation 545 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(545 < 6)), load_entry_545] + change forkRow [placeRow ⟨256, 0, 4, 5⟩ (denote cache_256), placeRow ⟨448, 0, 5, 4⟩ (denote cache_448), placeRow ⟨153, 0, 6, 3⟩ (denote cache_153), placeRow ⟨343, 0, 4, 5⟩ (denote cache_343)] = denote cache_545 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_545 + +theorem verified_row_546 : fork [place ⟨64, 0, 4, 3⟩ cache_64, place ⟨482, 7, 4, 3⟩ cache_482, place ⟨443, 0, 7, 5⟩ cache_443, place ⟨64, 6, 7, 5⟩ cache_64] = cache_546 := by + decide +kernel + +theorem load_entry_546 : entryAt 546 = entry_546 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_546 : CacheEquation 546 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(546 < 6)), load_entry_546] + change forkRow [placeRow ⟨64, 0, 4, 3⟩ (denote cache_64), placeRow ⟨482, 7, 4, 3⟩ (denote cache_482), placeRow ⟨443, 0, 7, 5⟩ (denote cache_443), placeRow ⟨64, 6, 7, 5⟩ (denote cache_64)] = denote cache_546 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_546 + +theorem verified_row_547 : fork [place ⟨443, 0, 7, 5⟩ cache_443, place ⟨510, 4, 7, 5⟩ cache_510, place ⟨131, 3, 3, 4⟩ cache_131] = cache_547 := by + decide +kernel + +theorem load_entry_547 : entryAt 547 = entry_547 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_547 : CacheEquation 547 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(547 < 6)), load_entry_547] + change forkRow [placeRow ⟨443, 0, 7, 5⟩ (denote cache_443), placeRow ⟨510, 4, 7, 5⟩ (denote cache_510), placeRow ⟨131, 3, 3, 4⟩ (denote cache_131)] = denote cache_547 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_547 + +theorem verified_row_548 : fork [place ⟨426, 0, 4, 5⟩ cache_426, place ⟨541, 0, 4, 5⟩ cache_541, place ⟨25, 0, 5, 4⟩ cache_25, place ⟨321, 4, 4, 2⟩ cache_321] = cache_548 := by + decide +kernel + +theorem load_entry_548 : entryAt 548 = entry_548 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_548 : CacheEquation 548 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(548 < 6)), load_entry_548] + change forkRow [placeRow ⟨426, 0, 4, 5⟩ (denote cache_426), placeRow ⟨541, 0, 4, 5⟩ (denote cache_541), placeRow ⟨25, 0, 5, 4⟩ (denote cache_25), placeRow ⟨321, 4, 4, 2⟩ (denote cache_321)] = denote cache_548 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_548 + +theorem verified_row_549 : fork [place ⟨385, 0, 6, 4⟩ cache_385, place ⟨385, 4, 2, 4⟩ cache_385, place ⟨330, 0, 6, 4⟩ cache_330, place ⟨252, 6, 2, 4⟩ cache_252, place ⟨326, 0, 6, 4⟩ cache_326, place ⟨529, 0, 2, 4⟩ cache_529] = cache_549 := by + decide +kernel + +theorem load_entry_549 : entryAt 549 = entry_549 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_549 : CacheEquation 549 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(549 < 6)), load_entry_549] + change forkRow [placeRow ⟨385, 0, 6, 4⟩ (denote cache_385), placeRow ⟨385, 4, 2, 4⟩ (denote cache_385), placeRow ⟨330, 0, 6, 4⟩ (denote cache_330), placeRow ⟨252, 6, 2, 4⟩ (denote cache_252), placeRow ⟨326, 0, 6, 4⟩ (denote cache_326), placeRow ⟨529, 0, 2, 4⟩ (denote cache_529)] = denote cache_549 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_549 + +theorem verified_row_550 : fork [place ⟨424, 0, 4, 6⟩ cache_424, place ⟨172, 7, 4, 2⟩ cache_172, place ⟨215, 1, 5, 5⟩ cache_215, place ⟨456, 7, 4, 2⟩ cache_456] = cache_550 := by + decide +kernel + +theorem load_entry_550 : entryAt 550 = entry_550 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_550 : CacheEquation 550 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(550 < 6)), load_entry_550] + change forkRow [placeRow ⟨424, 0, 4, 6⟩ (denote cache_424), placeRow ⟨172, 7, 4, 2⟩ (denote cache_172), placeRow ⟨215, 1, 5, 5⟩ (denote cache_215), placeRow ⟨456, 7, 4, 2⟩ (denote cache_456)] = denote cache_550 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_550 + +theorem verified_row_551 : fork [place ⟨300, 6, 4, 3⟩ cache_300, place ⟨172, 7, 4, 3⟩ cache_172, place ⟨319, 3, 5, 7⟩ cache_319, place ⟨527, 4, 5, 7⟩ cache_527, place ⟨176, 5, 4, 3⟩ cache_176] = cache_551 := by + decide +kernel + +theorem load_entry_551 : entryAt 551 = entry_551 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_551 : CacheEquation 551 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(551 < 6)), load_entry_551] + change forkRow [placeRow ⟨300, 6, 4, 3⟩ (denote cache_300), placeRow ⟨172, 7, 4, 3⟩ (denote cache_172), placeRow ⟨319, 3, 5, 7⟩ (denote cache_319), placeRow ⟨527, 4, 5, 7⟩ (denote cache_527), placeRow ⟨176, 5, 4, 3⟩ (denote cache_176)] = denote cache_551 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_551 + +theorem verified_row_552 : fork [place ⟨443, 4, 1, 5⟩ cache_443, place ⟨64, 2, 1, 5⟩ cache_64, place ⟨504, 1, 3, 3⟩ cache_504, place ⟨404, 5, 2, 3⟩ cache_404] = cache_552 := by + decide +kernel + +theorem load_entry_552 : entryAt 552 = entry_552 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_552 : CacheEquation 552 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(552 < 6)), load_entry_552] + change forkRow [placeRow ⟨443, 4, 1, 5⟩ (denote cache_443), placeRow ⟨64, 2, 1, 5⟩ (denote cache_64), placeRow ⟨504, 1, 3, 3⟩ (denote cache_504), placeRow ⟨404, 5, 2, 3⟩ (denote cache_404)] = denote cache_552 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_552 + +theorem verified_row_553 : fork [place ⟨63, 0, 3, 5⟩ cache_63, place ⟨261, 4, 5, 4⟩ cache_261, place ⟨471, 0, 5, 1⟩ cache_471, place ⟨442, 0, 4, 5⟩ cache_442, place ⟨504, 0, 3, 3⟩ cache_504, place ⟨180, 0, 4, 5⟩ cache_180] = cache_553 := by + decide +kernel + +theorem load_entry_553 : entryAt 553 = entry_553 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_553 : CacheEquation 553 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(553 < 6)), load_entry_553] + change forkRow [placeRow ⟨63, 0, 3, 5⟩ (denote cache_63), placeRow ⟨261, 4, 5, 4⟩ (denote cache_261), placeRow ⟨471, 0, 5, 1⟩ (denote cache_471), placeRow ⟨442, 0, 4, 5⟩ (denote cache_442), placeRow ⟨504, 0, 3, 3⟩ (denote cache_504), placeRow ⟨180, 0, 4, 5⟩ (denote cache_180)] = denote cache_553 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_553 + +theorem verified_row_554 : fork [place ⟨30, 6, 5, 4⟩ cache_30, place ⟨96, 7, 4, 5⟩ cache_96, place ⟨474, 0, 4, 5⟩ cache_474] = cache_554 := by + decide +kernel + +theorem load_entry_554 : entryAt 554 = entry_554 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_554 : CacheEquation 554 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(554 < 6)), load_entry_554] + change forkRow [placeRow ⟨30, 6, 5, 4⟩ (denote cache_30), placeRow ⟨96, 7, 4, 5⟩ (denote cache_96), placeRow ⟨474, 0, 4, 5⟩ (denote cache_474)] = denote cache_554 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_554 + +theorem verified_row_555 : fork [place ⟨504, 5, 3, 5⟩ cache_504, place ⟨513, 0, 1, 5⟩ cache_513, place ⟨55, 0, 5, 4⟩ cache_55, place ⟨443, 4, 1, 5⟩ cache_443, place ⟨471, 1, 1, 5⟩ cache_471] = cache_555 := by + decide +kernel + +theorem load_entry_555 : entryAt 555 = entry_555 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_555 : CacheEquation 555 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(555 < 6)), load_entry_555] + change forkRow [placeRow ⟨504, 5, 3, 5⟩ (denote cache_504), placeRow ⟨513, 0, 1, 5⟩ (denote cache_513), placeRow ⟨55, 0, 5, 4⟩ (denote cache_55), placeRow ⟨443, 4, 1, 5⟩ (denote cache_443), placeRow ⟨471, 1, 1, 5⟩ (denote cache_471)] = denote cache_555 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_555 + +theorem verified_row_556 : fork [place ⟨34, 1, 4, 2⟩ cache_34, place ⟨549, 0, 3, 4⟩ cache_549] = cache_556 := by + decide +kernel + +theorem load_entry_556 : entryAt 556 = entry_556 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_556 : CacheEquation 556 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(556 < 6)), load_entry_556] + change forkRow [placeRow ⟨34, 1, 4, 2⟩ (denote cache_34), placeRow ⟨549, 0, 3, 4⟩ (denote cache_549)] = denote cache_556 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_556 + +theorem verified_row_557 : fork [place ⟨460, 0, 5, 4⟩ cache_460, place ⟨460, 4, 2, 4⟩ cache_460, place ⟨460, 2, 5, 4⟩ cache_460, place ⟨411, 4, 5, 4⟩ cache_411, place ⟨531, 0, 3, 6⟩ cache_531, place ⟨531, 4, 4, 6⟩ cache_531, place ⟨406, 5, 5, 4⟩ cache_406] = cache_557 := by + decide +kernel + +theorem load_entry_557 : entryAt 557 = entry_557 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_557 : CacheEquation 557 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(557 < 6)), load_entry_557] + change forkRow [placeRow ⟨460, 0, 5, 4⟩ (denote cache_460), placeRow ⟨460, 4, 2, 4⟩ (denote cache_460), placeRow ⟨460, 2, 5, 4⟩ (denote cache_460), placeRow ⟨411, 4, 5, 4⟩ (denote cache_411), placeRow ⟨531, 0, 3, 6⟩ (denote cache_531), placeRow ⟨531, 4, 4, 6⟩ (denote cache_531), placeRow ⟨406, 5, 5, 4⟩ (denote cache_406)] = denote cache_557 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_557 + +theorem verified_row_558 : fork [place ⟨180, 5, 5, 4⟩ cache_180, place ⟨443, 4, 1, 5⟩ cache_443, place ⟨513, 0, 1, 5⟩ cache_513, place ⟨442, 1, 5, 4⟩ cache_442] = cache_558 := by + decide +kernel + +theorem load_entry_558 : entryAt 558 = entry_558 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_558 : CacheEquation 558 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(558 < 6)), load_entry_558] + change forkRow [placeRow ⟨180, 5, 5, 4⟩ (denote cache_180), placeRow ⟨443, 4, 1, 5⟩ (denote cache_443), placeRow ⟨513, 0, 1, 5⟩ (denote cache_513), placeRow ⟨442, 1, 5, 4⟩ (denote cache_442)] = denote cache_558 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_558 + +theorem verified_row_559 : fork [place ⟨228, 4, 5, 2⟩ cache_228, place ⟨7, 3, 3, 4⟩ cache_7, place ⟨155, 4, 4, 5⟩ cache_155, place ⟨538, 5, 4, 5⟩ cache_538] = cache_559 := by + decide +kernel + +theorem load_entry_559 : entryAt 559 = entry_559 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_559 : CacheEquation 559 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(559 < 6)), load_entry_559] + change forkRow [placeRow ⟨228, 4, 5, 2⟩ (denote cache_228), placeRow ⟨7, 3, 3, 4⟩ (denote cache_7), placeRow ⟨155, 4, 4, 5⟩ (denote cache_155), placeRow ⟨538, 5, 4, 5⟩ (denote cache_538)] = denote cache_559 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_559 + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Equations14.lean b/lean/OAI/Combinatorics/SnakyCertificate/Equations14.lean new file mode 100644 index 0000000000000000000000000000000000000000..a7c08ba4aab864c7fc22628a27bdf25aa0a9cff5 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Equations14.lean @@ -0,0 +1,530 @@ +import OAI.Combinatorics.SnakyCertificate.Cache +import OAI.Combinatorics.SnakyCertificate.TableList + +namespace OAI + +namespace SnakyCertificate.Check + +theorem verified_row_560 : fork [place ⟨517, 5, 5, 4⟩ cache_517, place ⟨416, 5, 4, 3⟩ cache_416, place ⟨359, 5, 3, 4⟩ cache_359, place ⟨356, 6, 3, 4⟩ cache_356, place ⟨483, 0, 4, 6⟩ cache_483] = cache_560 := by + decide +kernel + +theorem load_entry_560 : entryAt 560 = entry_560 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_560 : CacheEquation 560 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(560 < 6)), load_entry_560] + change forkRow [placeRow ⟨517, 5, 5, 4⟩ (denote cache_517), placeRow ⟨416, 5, 4, 3⟩ (denote cache_416), placeRow ⟨359, 5, 3, 4⟩ (denote cache_359), placeRow ⟨356, 6, 3, 4⟩ (denote cache_356), placeRow ⟨483, 0, 4, 6⟩ (denote cache_483)] = denote cache_560 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_560 + +theorem verified_row_561 : fork [place ⟨295, 0, 5, 4⟩ cache_295, place ⟨173, 2, 5, 4⟩ cache_173, place ⟨263, 6, 1, 4⟩ cache_263, place ⟨236, 1, 5, 5⟩ cache_236, place ⟨546, 4, 5, 4⟩ cache_546, place ⟨176, 2, 5, 4⟩ cache_176, place ⟨535, 0, 4, 5⟩ cache_535] = cache_561 := by + decide +kernel + +theorem load_entry_561 : entryAt 561 = entry_561 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_561 : CacheEquation 561 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(561 < 6)), load_entry_561] + change forkRow [placeRow ⟨295, 0, 5, 4⟩ (denote cache_295), placeRow ⟨173, 2, 5, 4⟩ (denote cache_173), placeRow ⟨263, 6, 1, 4⟩ (denote cache_263), placeRow ⟨236, 1, 5, 5⟩ (denote cache_236), placeRow ⟨546, 4, 5, 4⟩ (denote cache_546), placeRow ⟨176, 2, 5, 4⟩ (denote cache_176), placeRow ⟨535, 0, 4, 5⟩ (denote cache_535)] = denote cache_561 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_561 + +theorem verified_row_562 : fork [place ⟨6, 7, 3, 0⟩ cache_6, place ⟨559, 0, 4, 5⟩ cache_559] = cache_562 := by + decide +kernel + +theorem load_entry_562 : entryAt 562 = entry_562 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_562 : CacheEquation 562 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(562 < 6)), load_entry_562] + change forkRow [placeRow ⟨6, 7, 3, 0⟩ (denote cache_6), placeRow ⟨559, 0, 4, 5⟩ (denote cache_559)] = denote cache_562 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_562 + +theorem verified_row_563 : fork [place ⟨167, 0, 7, 4⟩ cache_167, place ⟨538, 0, 3, 4⟩ cache_538, place ⟨514, 0, 7, 4⟩ cache_514, place ⟨330, 4, 3, 4⟩ cache_330, place ⟨545, 0, 5, 5⟩ cache_545] = cache_563 := by + decide +kernel + +theorem load_entry_563 : entryAt 563 = entry_563 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_563 : CacheEquation 563 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(563 < 6)), load_entry_563] + change forkRow [placeRow ⟨167, 0, 7, 4⟩ (denote cache_167), placeRow ⟨538, 0, 3, 4⟩ (denote cache_538), placeRow ⟨514, 0, 7, 4⟩ (denote cache_514), placeRow ⟨330, 4, 3, 4⟩ (denote cache_330), placeRow ⟨545, 0, 5, 5⟩ (denote cache_545)] = denote cache_563 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_563 + +theorem verified_row_564 : fork [place ⟨560, 0, 4, 3⟩ cache_560, place ⟨421, 0, 3, 4⟩ cache_421, place ⟨401, 1, 3, 4⟩ cache_401, place ⟨340, 3, 3, 4⟩ cache_340, place ⟨509, 0, 3, 4⟩ cache_509, place ⟨528, 0, 4, 3⟩ cache_528, place ⟨423, 5, 4, 3⟩ cache_423, place ⟨425, 5, 4, 3⟩ cache_425, place ⟨336, 0, 3, 4⟩ cache_336] = cache_564 := by + decide +kernel + +theorem load_entry_564 : entryAt 564 = entry_564 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_564 : CacheEquation 564 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(564 < 6)), load_entry_564] + change forkRow [placeRow ⟨560, 0, 4, 3⟩ (denote cache_560), placeRow ⟨421, 0, 3, 4⟩ (denote cache_421), placeRow ⟨401, 1, 3, 4⟩ (denote cache_401), placeRow ⟨340, 3, 3, 4⟩ (denote cache_340), placeRow ⟨509, 0, 3, 4⟩ (denote cache_509), placeRow ⟨528, 0, 4, 3⟩ (denote cache_528), placeRow ⟨423, 5, 4, 3⟩ (denote cache_423), placeRow ⟨425, 5, 4, 3⟩ (denote cache_425), placeRow ⟨336, 0, 3, 4⟩ (denote cache_336)] = denote cache_564 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_564 + +theorem verified_row_565 : fork [place ⟨443, 4, 4, 5⟩ cache_443, place ⟨131, 3, 3, 4⟩ cache_131, place ⟨538, 0, 3, 4⟩ cache_538, place ⟨459, 0, 5, 5⟩ cache_459, place ⟨144, 4, 3, 4⟩ cache_144] = cache_565 := by + decide +kernel + +theorem load_entry_565 : entryAt 565 = entry_565 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_565 : CacheEquation 565 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(565 < 6)), load_entry_565] + change forkRow [placeRow ⟨443, 4, 4, 5⟩ (denote cache_443), placeRow ⟨131, 3, 3, 4⟩ (denote cache_131), placeRow ⟨538, 0, 3, 4⟩ (denote cache_538), placeRow ⟨459, 0, 5, 5⟩ (denote cache_459), placeRow ⟨144, 4, 3, 4⟩ (denote cache_144)] = denote cache_565 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_565 + +theorem verified_row_566 : fork [place ⟨314, 0, 3, 4⟩ cache_314, place ⟨180, 0, 4, 5⟩ cache_180, place ⟨442, 0, 4, 5⟩ cache_442, place ⟨466, 0, 6, 3⟩ cache_466, place ⟨504, 0, 3, 3⟩ cache_504] = cache_566 := by + decide +kernel + +theorem load_entry_566 : entryAt 566 = entry_566 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_566 : CacheEquation 566 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(566 < 6)), load_entry_566] + change forkRow [placeRow ⟨314, 0, 3, 4⟩ (denote cache_314), placeRow ⟨180, 0, 4, 5⟩ (denote cache_180), placeRow ⟨442, 0, 4, 5⟩ (denote cache_442), placeRow ⟨466, 0, 6, 3⟩ (denote cache_466), placeRow ⟨504, 0, 3, 3⟩ (denote cache_504)] = denote cache_566 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_566 + +theorem verified_row_567 : fork [place ⟨21, 1, 4, 3⟩ cache_21, place ⟨561, 0, 6, 4⟩ cache_561, place ⟨500, 4, 3, 1⟩ cache_500] = cache_567 := by + decide +kernel + +theorem load_entry_567 : entryAt 567 = entry_567 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_567 : CacheEquation 567 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(567 < 6)), load_entry_567] + change forkRow [placeRow ⟨21, 1, 4, 3⟩ (denote cache_21), placeRow ⟨561, 0, 6, 4⟩ (denote cache_561), placeRow ⟨500, 4, 3, 1⟩ (denote cache_500)] = denote cache_567 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_567 + +theorem verified_row_568 : fork [place ⟨538, 4, 6, 4⟩ cache_538, place ⟨547, 0, 2, 4⟩ cache_547, place ⟨275, 0, 6, 4⟩ cache_275, place ⟨565, 0, 2, 4⟩ cache_565, place ⟨330, 0, 6, 4⟩ cache_330] = cache_568 := by + decide +kernel + +theorem load_entry_568 : entryAt 568 = entry_568 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_568 : CacheEquation 568 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(568 < 6)), load_entry_568] + change forkRow [placeRow ⟨538, 4, 6, 4⟩ (denote cache_538), placeRow ⟨547, 0, 2, 4⟩ (denote cache_547), placeRow ⟨275, 0, 6, 4⟩ (denote cache_275), placeRow ⟨565, 0, 2, 4⟩ (denote cache_565), placeRow ⟨330, 0, 6, 4⟩ (denote cache_330)] = denote cache_568 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_568 + +theorem verified_row_569 : fork [place ⟨34, 3, 4, 2⟩ cache_34, place ⟨568, 4, 5, 4⟩ cache_568] = cache_569 := by + decide +kernel + +theorem load_entry_569 : entryAt 569 = entry_569 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_569 : CacheEquation 569 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(569 < 6)), load_entry_569] + change forkRow [placeRow ⟨34, 3, 4, 2⟩ (denote cache_34), placeRow ⟨568, 4, 5, 4⟩ (denote cache_568)] = denote cache_569 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_569 + +theorem verified_row_570 : fork [place ⟨569, 0, 2, 5⟩ cache_569, place ⟨2, 7, 4, 3⟩ cache_2] = cache_570 := by + decide +kernel + +theorem load_entry_570 : entryAt 570 = entry_570 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_570 : CacheEquation 570 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(570 < 6)), load_entry_570] + change forkRow [placeRow ⟨569, 0, 2, 5⟩ (denote cache_569), placeRow ⟨2, 7, 4, 3⟩ (denote cache_2)] = denote cache_570 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_570 + +theorem verified_row_571 : fork [place ⟨293, 0, 4, 3⟩ cache_293, place ⟨570, 0, 4, 3⟩ cache_570, place ⟨382, 0, 4, 3⟩ cache_382, place ⟨556, 4, 2, 4⟩ cache_556] = cache_571 := by + decide +kernel + +theorem load_entry_571 : entryAt 571 = entry_571 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_571 : CacheEquation 571 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(571 < 6)), load_entry_571] + change forkRow [placeRow ⟨293, 0, 4, 3⟩ (denote cache_293), placeRow ⟨570, 0, 4, 3⟩ (denote cache_570), placeRow ⟨382, 0, 4, 3⟩ (denote cache_382), placeRow ⟨556, 4, 2, 4⟩ (denote cache_556)] = denote cache_571 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_571 + +theorem verified_row_572 : fork [place ⟨564, 1, 6, 6⟩ cache_564, place ⟨465, 3, 3, 4⟩ cache_465, place ⟨385, 4, 3, 4⟩ cache_385, place ⟨364, 7, 3, 4⟩ cache_364, place ⟨499, 1, 6, 5⟩ cache_499] = cache_572 := by + decide +kernel + +theorem load_entry_572 : entryAt 572 = entry_572 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_572 : CacheEquation 572 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(572 < 6)), load_entry_572] + change forkRow [placeRow ⟨564, 1, 6, 6⟩ (denote cache_564), placeRow ⟨465, 3, 3, 4⟩ (denote cache_465), placeRow ⟨385, 4, 3, 4⟩ (denote cache_385), placeRow ⟨364, 7, 3, 4⟩ (denote cache_364), placeRow ⟨499, 1, 6, 5⟩ (denote cache_499)] = denote cache_572 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_572 + +theorem verified_row_573 : fork [place ⟨527, 2, 3, 1⟩ cache_527, place ⟨499, 4, 3, 4⟩ cache_499, place ⟨527, 6, 5, 1⟩ cache_527, place ⟨499, 0, 5, 4⟩ cache_499, place ⟨407, 4, 4, 1⟩ cache_407, place ⟨531, 7, 2, 4⟩ cache_531, place ⟨407, 0, 4, 1⟩ cache_407] = cache_573 := by + decide +kernel + +theorem load_entry_573 : entryAt 573 = entry_573 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_573 : CacheEquation 573 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(573 < 6)), load_entry_573] + change forkRow [placeRow ⟨527, 2, 3, 1⟩ (denote cache_527), placeRow ⟨499, 4, 3, 4⟩ (denote cache_499), placeRow ⟨527, 6, 5, 1⟩ (denote cache_527), placeRow ⟨499, 0, 5, 4⟩ (denote cache_499), placeRow ⟨407, 4, 4, 1⟩ (denote cache_407), placeRow ⟨531, 7, 2, 4⟩ (denote cache_531), placeRow ⟨407, 0, 4, 1⟩ (denote cache_407)] = denote cache_573 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_573 + +theorem verified_row_574 : fork [place ⟨497, 0, 2, 4⟩ cache_497, place ⟨539, 4, 4, 6⟩ cache_539, place ⟨355, 0, 2, 4⟩ cache_355, place ⟨390, 3, 2, 4⟩ cache_390, place ⟨544, 0, 2, 4⟩ cache_544, place ⟨462, 1, 4, 5⟩ cache_462, place ⟨563, 4, 5, 4⟩ cache_563, place ⟨540, 4, 4, 6⟩ cache_540, place ⟨518, 0, 2, 4⟩ cache_518, place ⟨495, 4, 2, 4⟩ cache_495] = cache_574 := by + decide +kernel + +theorem load_entry_574 : entryAt 574 = entry_574 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_574 : CacheEquation 574 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(574 < 6)), load_entry_574] + change forkRow [placeRow ⟨497, 0, 2, 4⟩ (denote cache_497), placeRow ⟨539, 4, 4, 6⟩ (denote cache_539), placeRow ⟨355, 0, 2, 4⟩ (denote cache_355), placeRow ⟨390, 3, 2, 4⟩ (denote cache_390), placeRow ⟨544, 0, 2, 4⟩ (denote cache_544), placeRow ⟨462, 1, 4, 5⟩ (denote cache_462), placeRow ⟨563, 4, 5, 4⟩ (denote cache_563), placeRow ⟨540, 4, 4, 6⟩ (denote cache_540), placeRow ⟨518, 0, 2, 4⟩ (denote cache_518), placeRow ⟨495, 4, 2, 4⟩ (denote cache_495)] = denote cache_574 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_574 + +theorem verified_row_575 : fork [place ⟨314, 4, 5, 4⟩ cache_314, place ⟨504, 4, 5, 3⟩ cache_504, place ⟨180, 4, 4, 5⟩ cache_180, place ⟨442, 4, 4, 5⟩ cache_442, place ⟨559, 0, 4, 5⟩ cache_559] = cache_575 := by + decide +kernel + +theorem load_entry_575 : entryAt 575 = entry_575 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_575 : CacheEquation 575 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(575 < 6)), load_entry_575] + change forkRow [placeRow ⟨314, 4, 5, 4⟩ (denote cache_314), placeRow ⟨504, 4, 5, 3⟩ (denote cache_504), placeRow ⟨180, 4, 4, 5⟩ (denote cache_180), placeRow ⟨442, 4, 4, 5⟩ (denote cache_442), placeRow ⟨559, 0, 4, 5⟩ (denote cache_559)] = denote cache_575 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_575 + +theorem verified_row_576 : fork [place ⟨495, 0, 5, 4⟩ cache_495, place ⟨544, 4, 5, 4⟩ cache_544, place ⟨462, 3, 3, 5⟩ cache_462, place ⟨540, 0, 3, 6⟩ cache_540, place ⟨355, 4, 5, 4⟩ cache_355, place ⟨539, 0, 3, 6⟩ cache_539, place ⟨497, 4, 5, 4⟩ cache_497, place ⟨390, 1, 5, 4⟩ cache_390, place ⟨563, 0, 2, 4⟩ cache_563, place ⟨518, 4, 5, 4⟩ cache_518] = cache_576 := by + decide +kernel + +theorem load_entry_576 : entryAt 576 = entry_576 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_576 : CacheEquation 576 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(576 < 6)), load_entry_576] + change forkRow [placeRow ⟨495, 0, 5, 4⟩ (denote cache_495), placeRow ⟨544, 4, 5, 4⟩ (denote cache_544), placeRow ⟨462, 3, 3, 5⟩ (denote cache_462), placeRow ⟨540, 0, 3, 6⟩ (denote cache_540), placeRow ⟨355, 4, 5, 4⟩ (denote cache_355), placeRow ⟨539, 0, 3, 6⟩ (denote cache_539), placeRow ⟨497, 4, 5, 4⟩ (denote cache_497), placeRow ⟨390, 1, 5, 4⟩ (denote cache_390), placeRow ⟨563, 0, 2, 4⟩ (denote cache_563), placeRow ⟨518, 4, 5, 4⟩ (denote cache_518)] = denote cache_576 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_576 + +theorem verified_row_577 : fork [place ⟨64, 7, 5, 4⟩ cache_64, place ⟨64, 1, 3, 1⟩ cache_64, place ⟨443, 1, 5, 4⟩ cache_443, place ⟨443, 7, 3, 1⟩ cache_443] = cache_577 := by + decide +kernel + +theorem load_entry_577 : entryAt 577 = entry_577 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_577 : CacheEquation 577 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(577 < 6)), load_entry_577] + change forkRow [placeRow ⟨64, 7, 5, 4⟩ (denote cache_64), placeRow ⟨64, 1, 3, 1⟩ (denote cache_64), placeRow ⟨443, 1, 5, 4⟩ (denote cache_443), placeRow ⟨443, 7, 3, 1⟩ (denote cache_443)] = denote cache_577 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_577 + +theorem verified_row_578 : fork [place ⟨574, 4, 4, 5⟩ cache_574, place ⟨2, 1, 4, 3⟩ cache_2] = cache_578 := by + decide +kernel + +theorem load_entry_578 : entryAt 578 = entry_578 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_578 : CacheEquation 578 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(578 < 6)), load_entry_578] + change forkRow [placeRow ⟨574, 4, 4, 5⟩ (denote cache_574), placeRow ⟨2, 1, 4, 3⟩ (denote cache_2)] = denote cache_578 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_578 + +theorem verified_row_579 : fork [place ⟨2, 1, 4, 3⟩ cache_2, place ⟨576, 4, 4, 5⟩ cache_576] = cache_579 := by + decide +kernel + +theorem load_entry_579 : entryAt 579 = entry_579 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_579 : CacheEquation 579 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(579 < 6)), load_entry_579] + change forkRow [placeRow ⟨2, 1, 4, 3⟩ (denote cache_2), placeRow ⟨576, 4, 4, 5⟩ (denote cache_576)] = denote cache_579 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_579 + +theorem verified_row_580 : fork [place ⟨2, 7, 4, 2⟩ cache_2, place ⟨579, 0, 3, 3⟩ cache_579] = cache_580 := by + decide +kernel + +theorem load_entry_580 : entryAt 580 = entry_580 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_580 : CacheEquation 580 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(580 < 6)), load_entry_580] + change forkRow [placeRow ⟨2, 7, 4, 2⟩ (denote cache_2), placeRow ⟨579, 0, 3, 3⟩ (denote cache_579)] = denote cache_580 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_580 + +theorem verified_row_581 : fork [place ⟨578, 4, 5, 3⟩ cache_578, place ⟨2, 5, 4, 2⟩ cache_2] = cache_581 := by + decide +kernel + +theorem load_entry_581 : entryAt 581 = entry_581 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_581 : CacheEquation 581 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(581 < 6)), load_entry_581] + change forkRow [placeRow ⟨578, 4, 5, 3⟩ (denote cache_578), placeRow ⟨2, 5, 4, 2⟩ (denote cache_2)] = denote cache_581 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_581 + +theorem verified_row_582 : fork [place ⟨40, 3, 4, 3⟩ cache_40, place ⟨446, 5, 5, 3⟩ cache_446, place ⟨523, 0, 7, 0⟩ cache_523, place ⟨480, 4, 5, 3⟩ cache_480, place ⟨567, 4, 5, 4⟩ cache_567] = cache_582 := by + decide +kernel + +theorem load_entry_582 : entryAt 582 = entry_582 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_582 : CacheEquation 582 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(582 < 6)), load_entry_582] + change forkRow [placeRow ⟨40, 3, 4, 3⟩ (denote cache_40), placeRow ⟨446, 5, 5, 3⟩ (denote cache_446), placeRow ⟨523, 0, 7, 0⟩ (denote cache_523), placeRow ⟨480, 4, 5, 3⟩ (denote cache_480), placeRow ⟨567, 4, 5, 4⟩ (denote cache_567)] = denote cache_582 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_582 + +theorem verified_row_583 : fork [place ⟨25, 5, 4, 3⟩ cache_25, place ⟨525, 0, 5, 4⟩ cache_525, place ⟨582, 0, 2, 8⟩ cache_582, place ⟨221, 3, 3, 7⟩ cache_221] = cache_583 := by + decide +kernel + +theorem load_entry_583 : entryAt 583 = entry_583 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_583 : CacheEquation 583 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(583 < 6)), load_entry_583] + change forkRow [placeRow ⟨25, 5, 4, 3⟩ (denote cache_25), placeRow ⟨525, 0, 5, 4⟩ (denote cache_525), placeRow ⟨582, 0, 2, 8⟩ (denote cache_582), placeRow ⟨221, 3, 3, 7⟩ (denote cache_221)] = denote cache_583 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_583 + +theorem verified_row_584 : fork [place ⟨263, 1, 4, 5⟩ cache_263, place ⟨236, 4, 3, 5⟩ cache_236, place ⟨548, 3, 3, 4⟩ cache_548, place ⟨295, 3, 4, 5⟩ cache_295, place ⟨577, 0, 4, 5⟩ cache_577, place ⟨173, 1, 4, 5⟩ cache_173] = cache_584 := by + decide +kernel + +theorem load_entry_584 : entryAt 584 = entry_584 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_584 : CacheEquation 584 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(584 < 6)), load_entry_584] + change forkRow [placeRow ⟨263, 1, 4, 5⟩ (denote cache_263), placeRow ⟨236, 4, 3, 5⟩ (denote cache_236), placeRow ⟨548, 3, 3, 4⟩ (denote cache_548), placeRow ⟨295, 3, 4, 5⟩ (denote cache_295), placeRow ⟨577, 0, 4, 5⟩ (denote cache_577), placeRow ⟨173, 1, 4, 5⟩ (denote cache_173)] = denote cache_584 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_584 + +theorem verified_row_585 : fork [place ⟨236, 2, 5, 1⟩ cache_236, place ⟨300, 4, 4, 5⟩ cache_300, place ⟨479, 1, 4, 5⟩ cache_479, place ⟨577, 0, 4, 5⟩ cache_577, place ⟨183, 3, 4, 5⟩ cache_183, place ⟨527, 6, 5, 1⟩ cache_527] = cache_585 := by + decide +kernel + +theorem load_entry_585 : entryAt 585 = entry_585 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_585 : CacheEquation 585 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(585 < 6)), load_entry_585] + change forkRow [placeRow ⟨236, 2, 5, 1⟩ (denote cache_236), placeRow ⟨300, 4, 4, 5⟩ (denote cache_300), placeRow ⟨479, 1, 4, 5⟩ (denote cache_479), placeRow ⟨577, 0, 4, 5⟩ (denote cache_577), placeRow ⟨183, 3, 4, 5⟩ (denote cache_183), placeRow ⟨527, 6, 5, 1⟩ (denote cache_527)] = denote cache_585 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_585 + +theorem verified_row_586 : fork [place ⟨465, 4, 4, 5⟩ cache_465, place ⟨558, 1, 4, 5⟩ cache_558, place ⟨385, 1, 4, 5⟩ cache_385, place ⟨379, 4, 4, 5⟩ cache_379, place ⟨524, 0, 4, 5⟩ cache_524, place ⟨469, 2, 4, 5⟩ cache_469, place ⟨467, 2, 4, 5⟩ cache_467, place ⟨527, 4, 5, 5⟩ cache_527, place ⟨553, 0, 4, 5⟩ cache_553, place ⟨552, 1, 4, 5⟩ cache_552, place ⟨555, 1, 4, 5⟩ cache_555, place ⟨564, 0, 6, 4⟩ cache_564, place ⟨583, 0, 5, 2⟩ cache_583] = cache_586 := by + decide +kernel + +theorem load_entry_586 : entryAt 586 = entry_586 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_586 : CacheEquation 586 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(586 < 6)), load_entry_586] + change forkRow [placeRow ⟨465, 4, 4, 5⟩ (denote cache_465), placeRow ⟨558, 1, 4, 5⟩ (denote cache_558), placeRow ⟨385, 1, 4, 5⟩ (denote cache_385), placeRow ⟨379, 4, 4, 5⟩ (denote cache_379), placeRow ⟨524, 0, 4, 5⟩ (denote cache_524), placeRow ⟨469, 2, 4, 5⟩ (denote cache_469), placeRow ⟨467, 2, 4, 5⟩ (denote cache_467), placeRow ⟨527, 4, 5, 5⟩ (denote cache_527), placeRow ⟨553, 0, 4, 5⟩ (denote cache_553), placeRow ⟨552, 1, 4, 5⟩ (denote cache_552), placeRow ⟨555, 1, 4, 5⟩ (denote cache_555), placeRow ⟨564, 0, 6, 4⟩ (denote cache_564), placeRow ⟨583, 0, 5, 2⟩ (denote cache_583)] = denote cache_586 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_586 + +theorem verified_row_587 : fork [place ⟨300, 2, 4, 1⟩ cache_300, place ⟨479, 1, 4, 5⟩ cache_479, place ⟨319, 3, 5, 5⟩ cache_319, place ⟨477, 6, 4, 1⟩ cache_477, place ⟨252, 3, 4, 5⟩ cache_252, place ⟨467, 2, 4, 5⟩ cache_467] = cache_587 := by + decide +kernel + +theorem load_entry_587 : entryAt 587 = entry_587 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_587 : CacheEquation 587 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(587 < 6)), load_entry_587] + change forkRow [placeRow ⟨300, 2, 4, 1⟩ (denote cache_300), placeRow ⟨479, 1, 4, 5⟩ (denote cache_479), placeRow ⟨319, 3, 5, 5⟩ (denote cache_319), placeRow ⟨477, 6, 4, 1⟩ (denote cache_477), placeRow ⟨252, 3, 4, 5⟩ (denote cache_252), placeRow ⟨467, 2, 4, 5⟩ (denote cache_467)] = denote cache_587 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_587 + +theorem verified_row_588 : fork [place ⟨3, 1, 3, 3⟩ cache_3, place ⟨586, 0, 4, 5⟩ cache_586] = cache_588 := by + decide +kernel + +theorem load_entry_588 : entryAt 588 = entry_588 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_588 : CacheEquation 588 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(588 < 6)), load_entry_588] + change forkRow [placeRow ⟨3, 1, 3, 3⟩ (denote cache_3), placeRow ⟨586, 0, 4, 5⟩ (denote cache_586)] = denote cache_588 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_588 + +theorem verified_row_589 : fork [place ⟨4, 1, 4, 3⟩ cache_4, place ⟨588, 0, 4, 5⟩ cache_588] = cache_589 := by + decide +kernel + +theorem load_entry_589 : entryAt 589 = entry_589 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_589 : CacheEquation 589 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(589 < 6)), load_entry_589] + change forkRow [placeRow ⟨4, 1, 4, 3⟩ (denote cache_4), placeRow ⟨588, 0, 4, 5⟩ (denote cache_588)] = denote cache_589 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_589 + +theorem verified_row_590 : fork [place ⟨295, 7, 4, 3⟩ cache_295, place ⟨173, 7, 4, 3⟩ cache_173, place ⟨577, 0, 4, 7⟩ cache_577, place ⟨490, 0, 4, 7⟩ cache_490, place ⟨217, 5, 4, 3⟩ cache_217] = cache_590 := by + decide +kernel + +theorem load_entry_590 : entryAt 590 = entry_590 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_590 : CacheEquation 590 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(590 < 6)), load_entry_590] + change forkRow [placeRow ⟨295, 7, 4, 3⟩ (denote cache_295), placeRow ⟨173, 7, 4, 3⟩ (denote cache_173), placeRow ⟨577, 0, 4, 7⟩ (denote cache_577), placeRow ⟨490, 0, 4, 7⟩ (denote cache_490), placeRow ⟨217, 5, 4, 3⟩ (denote cache_217)] = denote cache_590 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_590 + +theorem verified_row_591 : fork [place ⟨524, 0, 4, 5⟩ cache_524, place ⟨529, 1, 4, 1⟩ cache_529, place ⟨529, 3, 4, 1⟩ cache_529, place ⟨538, 1, 4, 1⟩ cache_538, place ⟨538, 3, 4, 1⟩ cache_538, place ⟨197, 5, 4, 1⟩ cache_197] = cache_591 := by + decide +kernel + +theorem load_entry_591 : entryAt 591 = entry_591 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_591 : CacheEquation 591 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(591 < 6)), load_entry_591] + change forkRow [placeRow ⟨524, 0, 4, 5⟩ (denote cache_524), placeRow ⟨529, 1, 4, 1⟩ (denote cache_529), placeRow ⟨529, 3, 4, 1⟩ (denote cache_529), placeRow ⟨538, 1, 4, 1⟩ (denote cache_538), placeRow ⟨538, 3, 4, 1⟩ (denote cache_538), placeRow ⟨197, 5, 4, 1⟩ (denote cache_197)] = denote cache_591 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_591 + +theorem verified_row_592 : fork [place ⟨588, 0, 4, 5⟩ cache_588, place ⟨108, 7, 3, 0⟩ cache_108] = cache_592 := by + decide +kernel + +theorem load_entry_592 : entryAt 592 = entry_592 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_592 : CacheEquation 592 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(592 < 6)), load_entry_592] + change forkRow [placeRow ⟨588, 0, 4, 5⟩ (denote cache_588), placeRow ⟨108, 7, 3, 0⟩ (denote cache_108)] = denote cache_592 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_592 + +theorem verified_row_593 : fork [place ⟨2, 7, 4, 2⟩ cache_2, place ⟨586, 0, 4, 5⟩ cache_586] = cache_593 := by + decide +kernel + +theorem load_entry_593 : entryAt 593 = entry_593 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_593 : CacheEquation 593 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(593 < 6)), load_entry_593] + change forkRow [placeRow ⟨2, 7, 4, 2⟩ (denote cache_2), placeRow ⟨586, 0, 4, 5⟩ (denote cache_586)] = denote cache_593 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_593 + +theorem verified_row_594 : fork [place ⟨30, 1, 4, 3⟩ cache_30, place ⟨476, 1, 4, 3⟩ cache_476, place ⟨588, 0, 4, 5⟩ cache_588] = cache_594 := by + decide +kernel + +theorem load_entry_594 : entryAt 594 = entry_594 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_594 : CacheEquation 594 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(594 < 6)), load_entry_594] + change forkRow [placeRow ⟨30, 1, 4, 3⟩ (denote cache_30), placeRow ⟨476, 1, 4, 3⟩ (denote cache_476), placeRow ⟨588, 0, 4, 5⟩ (denote cache_588)] = denote cache_594 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_594 + +theorem verified_row_595 : fork [place ⟨460, 4, 2, 4⟩ cache_460, place ⟨460, 2, 5, 4⟩ cache_460, place ⟨586, 1, 5, 4⟩ cache_586, place ⟨411, 4, 5, 4⟩ cache_411, place ⟨551, 1, 2, 4⟩ cache_551, place ⟨406, 5, 5, 4⟩ cache_406, place ⟨572, 0, 2, 4⟩ cache_572] = cache_595 := by + decide +kernel + +theorem load_entry_595 : entryAt 595 = entry_595 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_595 : CacheEquation 595 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(595 < 6)), load_entry_595] + change forkRow [placeRow ⟨460, 4, 2, 4⟩ (denote cache_460), placeRow ⟨460, 2, 5, 4⟩ (denote cache_460), placeRow ⟨586, 1, 5, 4⟩ (denote cache_586), placeRow ⟨411, 4, 5, 4⟩ (denote cache_411), placeRow ⟨551, 1, 2, 4⟩ (denote cache_551), placeRow ⟨406, 5, 5, 4⟩ (denote cache_406), placeRow ⟨572, 0, 2, 4⟩ (denote cache_572)] = denote cache_595 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_595 + +theorem verified_row_596 : fork [place ⟨385, 5, 4, 2⟩ cache_385, place ⟨592, 0, 5, 6⟩ cache_592, place ⟨330, 1, 4, 6⟩ cache_330, place ⟨529, 5, 4, 6⟩ cache_529, place ⟨385, 1, 4, 6⟩ cache_385, place ⟨330, 5, 4, 2⟩ cache_330] = cache_596 := by + decide +kernel + +theorem load_entry_596 : entryAt 596 = entry_596 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_596 : CacheEquation 596 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(596 < 6)), load_entry_596] + change forkRow [placeRow ⟨385, 5, 4, 2⟩ (denote cache_385), placeRow ⟨592, 0, 5, 6⟩ (denote cache_592), placeRow ⟨330, 1, 4, 6⟩ (denote cache_330), placeRow ⟨529, 5, 4, 6⟩ (denote cache_529), placeRow ⟨385, 1, 4, 6⟩ (denote cache_385), placeRow ⟨330, 5, 4, 2⟩ (denote cache_330)] = denote cache_596 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_596 + +theorem verified_row_597 : fork [place ⟨24, 6, 2, 3⟩ cache_24, place ⟨221, 0, 6, 4⟩ cache_221, place ⟨199, 3, 2, 4⟩ cache_199, place ⟨594, 1, 6, 5⟩ cache_594] = cache_597 := by + decide +kernel + +theorem load_entry_597 : entryAt 597 = entry_597 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_597 : CacheEquation 597 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(597 < 6)), load_entry_597] + change forkRow [placeRow ⟨24, 6, 2, 3⟩ (denote cache_24), placeRow ⟨221, 0, 6, 4⟩ (denote cache_221), placeRow ⟨199, 3, 2, 4⟩ (denote cache_199), placeRow ⟨594, 1, 6, 5⟩ (denote cache_594)] = denote cache_597 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_597 + +theorem verified_row_598 : fork [place ⟨594, 0, 5, 6⟩ cache_594, place ⟨456, 5, 4, 2⟩ cache_456, place ⟨254, 1, 3, 2⟩ cache_254, place ⟨554, 1, 3, 2⟩ cache_554, place ⟨465, 0, 4, 6⟩ cache_465] = cache_598 := by + decide +kernel + +theorem load_entry_598 : entryAt 598 = entry_598 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_598 : CacheEquation 598 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(598 < 6)), load_entry_598] + change forkRow [placeRow ⟨594, 0, 5, 6⟩ (denote cache_594), placeRow ⟨456, 5, 4, 2⟩ (denote cache_456), placeRow ⟨254, 1, 3, 2⟩ (denote cache_254), placeRow ⟨554, 1, 3, 2⟩ (denote cache_554), placeRow ⟨465, 0, 4, 6⟩ (denote cache_465)] = denote cache_598 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_598 + +theorem verified_row_599 : fork [place ⟨578, 4, 5, 3⟩ cache_578, place ⟨492, 0, 3, 1⟩ cache_492, place ⟨512, 4, 3, 1⟩ cache_512, place ⟨586, 4, 4, 5⟩ cache_586, place ⟨485, 0, 5, 3⟩ cache_485, place ⟨579, 4, 5, 3⟩ cache_579] = cache_599 := by + decide +kernel + +theorem load_entry_599 : entryAt 599 = entry_599 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_599 : CacheEquation 599 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(599 < 6)), load_entry_599] + change forkRow [placeRow ⟨578, 4, 5, 3⟩ (denote cache_578), placeRow ⟨492, 0, 3, 1⟩ (denote cache_492), placeRow ⟨512, 4, 3, 1⟩ (denote cache_512), placeRow ⟨586, 4, 4, 5⟩ (denote cache_586), placeRow ⟨485, 0, 5, 3⟩ (denote cache_485), placeRow ⟨579, 4, 5, 3⟩ (denote cache_579)] = denote cache_599 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_599 + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Equations15.lean b/lean/OAI/Combinatorics/SnakyCertificate/Equations15.lean new file mode 100644 index 0000000000000000000000000000000000000000..e9dccbacefd1bb65b85f2dbb46a7576f117ccf46 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Equations15.lean @@ -0,0 +1,218 @@ +import OAI.Combinatorics.SnakyCertificate.Cache +import OAI.Combinatorics.SnakyCertificate.TableList + +namespace OAI + +namespace SnakyCertificate.Check + +theorem verified_row_600 : fork [place ⟨448, 0, 4, 5⟩ cache_448, place ⟨278, 2, 1, 4⟩ cache_278, place ⟨592, 5, 5, 3⟩ cache_592, place ⟨403, 5, 5, 4⟩ cache_403, place ⟨146, 5, 4, 3⟩ cache_146] = cache_600 := by + decide +kernel + +theorem load_entry_600 : entryAt 600 = entry_600 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_600 : CacheEquation 600 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(600 < 6)), load_entry_600] + change forkRow [placeRow ⟨448, 0, 4, 5⟩ (denote cache_448), placeRow ⟨278, 2, 1, 4⟩ (denote cache_278), placeRow ⟨592, 5, 5, 3⟩ (denote cache_592), placeRow ⟨403, 5, 5, 4⟩ (denote cache_403), placeRow ⟨146, 5, 4, 3⟩ (denote cache_146)] = denote cache_600 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_600 + +theorem verified_row_601 : fork [place ⟨437, 6, 4, 1⟩ cache_437, place ⟨553, 0, 4, 5⟩ cache_553, place ⟨592, 0, 5, 5⟩ cache_592, place ⟨236, 4, 3, 5⟩ cache_236, place ⟨469, 4, 4, 1⟩ cache_469] = cache_601 := by + decide +kernel + +theorem load_entry_601 : entryAt 601 = entry_601 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_601 : CacheEquation 601 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(601 < 6)), load_entry_601] + change forkRow [placeRow ⟨437, 6, 4, 1⟩ (denote cache_437), placeRow ⟨553, 0, 4, 5⟩ (denote cache_553), placeRow ⟨592, 0, 5, 5⟩ (denote cache_592), placeRow ⟨236, 4, 3, 5⟩ (denote cache_236), placeRow ⟨469, 4, 4, 1⟩ (denote cache_469)] = denote cache_601 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_601 + +theorem verified_row_602 : fork [place ⟨553, 0, 4, 7⟩ cache_553, place ⟨467, 4, 4, 3⟩ cache_467, place ⟨592, 0, 5, 7⟩ cache_592, place ⟨437, 6, 4, 3⟩ cache_437, place ⟨236, 4, 3, 7⟩ cache_236] = cache_602 := by + decide +kernel + +theorem load_entry_602 : entryAt 602 = entry_602 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_602 : CacheEquation 602 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(602 < 6)), load_entry_602] + change forkRow [placeRow ⟨553, 0, 4, 7⟩ (denote cache_553), placeRow ⟨467, 4, 4, 3⟩ (denote cache_467), placeRow ⟨592, 0, 5, 7⟩ (denote cache_592), placeRow ⟨437, 6, 4, 3⟩ (denote cache_437), placeRow ⟨236, 4, 3, 7⟩ (denote cache_236)] = denote cache_602 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_602 + +theorem verified_row_603 : fork [place ⟨505, 1, 5, 4⟩ cache_505, place ⟨505, 5, 5, 4⟩ cache_505, place ⟨586, 5, 5, 4⟩ cache_586, place ⟨551, 7, 5, 4⟩ cache_551, place ⟨531, 6, 4, 2⟩ cache_531, place ⟨586, 1, 5, 4⟩ cache_586, place ⟨585, 1, 5, 4⟩ cache_585, place ⟨585, 5, 5, 4⟩ cache_585, place ⟨551, 3, 5, 4⟩ cache_551, place ⟨573, 1, 5, 4⟩ cache_573, place ⟨533, 5, 5, 4⟩ cache_533, place ⟨533, 1, 5, 4⟩ cache_533] = cache_603 := by + decide +kernel + +theorem load_entry_603 : entryAt 603 = entry_603 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_603 : CacheEquation 603 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(603 < 6)), load_entry_603] + change forkRow [placeRow ⟨505, 1, 5, 4⟩ (denote cache_505), placeRow ⟨505, 5, 5, 4⟩ (denote cache_505), placeRow ⟨586, 5, 5, 4⟩ (denote cache_586), placeRow ⟨551, 7, 5, 4⟩ (denote cache_551), placeRow ⟨531, 6, 4, 2⟩ (denote cache_531), placeRow ⟨586, 1, 5, 4⟩ (denote cache_586), placeRow ⟨585, 1, 5, 4⟩ (denote cache_585), placeRow ⟨585, 5, 5, 4⟩ (denote cache_585), placeRow ⟨551, 3, 5, 4⟩ (denote cache_551), placeRow ⟨573, 1, 5, 4⟩ (denote cache_573), placeRow ⟨533, 5, 5, 4⟩ (denote cache_533), placeRow ⟨533, 1, 5, 4⟩ (denote cache_533)] = denote cache_603 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_603 + +theorem verified_row_604 : fork [place ⟨597, 0, 3, 4⟩ cache_597, place ⟨375, 2, 4, 3⟩ cache_375, place ⟨597, 1, 4, 3⟩ cache_597, place ⟨375, 3, 3, 4⟩ cache_375, place ⟨350, 3, 4, 3⟩ cache_350, place ⟨350, 2, 3, 4⟩ cache_350] = cache_604 := by + decide +kernel + +theorem load_entry_604 : entryAt 604 = entry_604 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_604 : CacheEquation 604 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(604 < 6)), load_entry_604] + change forkRow [placeRow ⟨597, 0, 3, 4⟩ (denote cache_597), placeRow ⟨375, 2, 4, 3⟩ (denote cache_375), placeRow ⟨597, 1, 4, 3⟩ (denote cache_597), placeRow ⟨375, 3, 3, 4⟩ (denote cache_375), placeRow ⟨350, 3, 4, 3⟩ (denote cache_350), placeRow ⟨350, 2, 3, 4⟩ (denote cache_350)] = denote cache_604 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_604 + +theorem verified_row_605 : fork [place ⟨400, 5, 4, 3⟩ cache_400, place ⟨383, 6, 3, 4⟩ cache_383, place ⟨530, 4, 4, 3⟩ cache_530, place ⟨596, 1, 3, 4⟩ cache_596, place ⟨522, 2, 4, 3⟩ cache_522, place ⟨598, 0, 4, 3⟩ cache_598, place ⟨537, 3, 3, 4⟩ cache_537, place ⟨520, 1, 4, 3⟩ cache_520, place ⟨550, 4, 4, 3⟩ cache_550] = cache_605 := by + decide +kernel + +theorem load_entry_605 : entryAt 605 = entry_605 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_605 : CacheEquation 605 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(605 < 6)), load_entry_605] + change forkRow [placeRow ⟨400, 5, 4, 3⟩ (denote cache_400), placeRow ⟨383, 6, 3, 4⟩ (denote cache_383), placeRow ⟨530, 4, 4, 3⟩ (denote cache_530), placeRow ⟨596, 1, 3, 4⟩ (denote cache_596), placeRow ⟨522, 2, 4, 3⟩ (denote cache_522), placeRow ⟨598, 0, 4, 3⟩ (denote cache_598), placeRow ⟨537, 3, 3, 4⟩ (denote cache_537), placeRow ⟨520, 1, 4, 3⟩ (denote cache_520), placeRow ⟨550, 4, 4, 3⟩ (denote cache_550)] = denote cache_605 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_605 + +theorem verified_row_606 : fork [place ⟨123, 1, 4, 3⟩ cache_123, place ⟨274, 0, 4, 3⟩ cache_274, place ⟨605, 0, 6, 4⟩ cache_605, place ⟨119, 1, 4, 3⟩ cache_119] = cache_606 := by + decide +kernel + +theorem load_entry_606 : entryAt 606 = entry_606 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_606 : CacheEquation 606 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(606 < 6)), load_entry_606] + change forkRow [placeRow ⟨123, 1, 4, 3⟩ (denote cache_123), placeRow ⟨274, 0, 4, 3⟩ (denote cache_274), placeRow ⟨605, 0, 6, 4⟩ (denote cache_605), placeRow ⟨119, 1, 4, 3⟩ (denote cache_119)] = denote cache_606 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_606 + +theorem verified_row_607 : fork [place ⟨420, 3, 1, 2⟩ cache_420, place ⟨419, 3, 1, 4⟩ cache_419, place ⟨589, 0, 5, 5⟩ cache_589, place ⟨314, 0, 3, 4⟩ cache_314, place ⟨571, 1, 7, 3⟩ cache_571] = cache_607 := by + decide +kernel + +theorem load_entry_607 : entryAt 607 = entry_607 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_607 : CacheEquation 607 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(607 < 6)), load_entry_607] + change forkRow [placeRow ⟨420, 3, 1, 2⟩ (denote cache_420), placeRow ⟨419, 3, 1, 4⟩ (denote cache_419), placeRow ⟨589, 0, 5, 5⟩ (denote cache_589), placeRow ⟨314, 0, 3, 4⟩ (denote cache_314), placeRow ⟨571, 1, 7, 3⟩ (denote cache_571)] = denote cache_607 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_607 + +theorem verified_row_608 : fork [place ⟨486, 4, 4, 5⟩ cache_486, place ⟨515, 1, 4, 5⟩ cache_515, place ⟨580, 0, 4, 5⟩ cache_580, place ⟨521, 0, 4, 5⟩ cache_521, place ⟨581, 4, 4, 5⟩ cache_581, place ⟨593, 0, 4, 5⟩ cache_593, place ⟨599, 4, 4, 5⟩ cache_599, place ⟨606, 1, 6, 2⟩ cache_606] = cache_608 := by + decide +kernel + +theorem load_entry_608 : entryAt 608 = entry_608 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_608 : CacheEquation 608 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(608 < 6)), load_entry_608] + change forkRow [placeRow ⟨486, 4, 4, 5⟩ (denote cache_486), placeRow ⟨515, 1, 4, 5⟩ (denote cache_515), placeRow ⟨580, 0, 4, 5⟩ (denote cache_580), placeRow ⟨521, 0, 4, 5⟩ (denote cache_521), placeRow ⟨581, 4, 4, 5⟩ (denote cache_581), placeRow ⟨593, 0, 4, 5⟩ (denote cache_593), placeRow ⟨599, 4, 4, 5⟩ (denote cache_599), placeRow ⟨606, 1, 6, 2⟩ (denote cache_606)] = denote cache_608 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_608 + +theorem verified_row_609 : fork [place ⟨286, 4, 4, 5⟩ cache_286, place ⟨107, 3, 4, 5⟩ cache_107, place ⟨532, 4, 4, 5⟩ cache_532, place ⟨542, 0, 4, 5⟩ cache_542, place ⟨221, 3, 4, 5⟩ cache_221, place ⟨562, 4, 4, 5⟩ cache_562, place ⟨575, 4, 4, 5⟩ cache_575, place ⟨604, 1, 6, 4⟩ cache_604] = cache_609 := by + decide +kernel + +theorem load_entry_609 : entryAt 609 = entry_609 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_609 : CacheEquation 609 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(609 < 6)), load_entry_609] + change forkRow [placeRow ⟨286, 4, 4, 5⟩ (denote cache_286), placeRow ⟨107, 3, 4, 5⟩ (denote cache_107), placeRow ⟨532, 4, 4, 5⟩ (denote cache_532), placeRow ⟨542, 0, 4, 5⟩ (denote cache_542), placeRow ⟨221, 3, 4, 5⟩ (denote cache_221), placeRow ⟨562, 4, 4, 5⟩ (denote cache_562), placeRow ⟨575, 4, 4, 5⟩ (denote cache_575), placeRow ⟨604, 1, 6, 4⟩ (denote cache_604)] = denote cache_609 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_609 + +theorem verified_row_610 : fork [place ⟨221, 2, 5, 4⟩ cache_221, place ⟨286, 5, 5, 4⟩ cache_286, place ⟨107, 2, 5, 4⟩ cache_107, place ⟨472, 1, 5, 4⟩ cache_472, place ⟨566, 1, 5, 4⟩ cache_566, place ⟨532, 5, 5, 4⟩ cache_532, place ⟨542, 1, 5, 4⟩ cache_542, place ⟨609, 0, 2, 6⟩ cache_609] = cache_610 := by + decide +kernel + +theorem load_entry_610 : entryAt 610 = entry_610 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_610 : CacheEquation 610 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(610 < 6)), load_entry_610] + change forkRow [placeRow ⟨221, 2, 5, 4⟩ (denote cache_221), placeRow ⟨286, 5, 5, 4⟩ (denote cache_286), placeRow ⟨107, 2, 5, 4⟩ (denote cache_107), placeRow ⟨472, 1, 5, 4⟩ (denote cache_472), placeRow ⟨566, 1, 5, 4⟩ (denote cache_566), placeRow ⟨532, 5, 5, 4⟩ (denote cache_532), placeRow ⟨542, 1, 5, 4⟩ (denote cache_542), placeRow ⟨609, 0, 2, 6⟩ (denote cache_609)] = denote cache_610 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_610 + +theorem verified_row_611 : fork [place ⟨456, 2, 5, 4⟩ cache_456, place ⟨456, 4, 1, 4⟩ cache_456, place ⟨594, 7, 1, 3⟩ cache_594, place ⟨594, 1, 5, 5⟩ cache_594] = cache_611 := by + decide +kernel + +theorem load_entry_611 : entryAt 611 = entry_611 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_611 : CacheEquation 611 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(611 < 6)), load_entry_611] + change forkRow [placeRow ⟨456, 2, 5, 4⟩ (denote cache_456), placeRow ⟨456, 4, 1, 4⟩ (denote cache_456), placeRow ⟨594, 7, 1, 3⟩ (denote cache_594), placeRow ⟨594, 1, 5, 5⟩ (denote cache_594)] = denote cache_611 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_611 + +theorem verified_row_612 : fork [place ⟨589, 1, 5, 5⟩ cache_589, place ⟨589, 7, 0, 3⟩ cache_589] = cache_612 := by + decide +kernel + +theorem load_entry_612 : entryAt 612 = entry_612 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_612 : CacheEquation 612 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(612 < 6)), load_entry_612] + change forkRow [placeRow ⟨589, 1, 5, 5⟩ (denote cache_589), placeRow ⟨589, 7, 0, 3⟩ (denote cache_589)] = denote cache_612 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_612 + +theorem verified_row_613 : fork [place ⟨607, 5, 5, 4⟩ cache_607, place ⟨503, 3, 1, 4⟩ cache_503, place ⟨592, 7, 1, 3⟩ cache_592, place ⟨592, 5, 5, 3⟩ cache_592, place ⟨607, 7, 1, 4⟩ cache_607, place ⟨612, 4, 1, 4⟩ cache_612, place ⟨612, 0, 5, 4⟩ cache_612] = cache_613 := by + decide +kernel + +theorem load_entry_613 : entryAt 613 = entry_613 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_613 : CacheEquation 613 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(613 < 6)), load_entry_613] + change forkRow [placeRow ⟨607, 5, 5, 4⟩ (denote cache_607), placeRow ⟨503, 3, 1, 4⟩ (denote cache_503), placeRow ⟨592, 7, 1, 3⟩ (denote cache_592), placeRow ⟨592, 5, 5, 3⟩ (denote cache_592), placeRow ⟨607, 7, 1, 4⟩ (denote cache_607), placeRow ⟨612, 4, 1, 4⟩ (denote cache_612), placeRow ⟨612, 0, 5, 4⟩ (denote cache_612)] = denote cache_613 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_613 + +theorem verified_row_614 : fork [place ⟨608, 1, 7, 5⟩ cache_608, place ⟨543, 3, 5, 6⟩ cache_543, place ⟨370, 6, 3, 4⟩ cache_370, place ⟨392, 7, 3, 4⟩ cache_392, place ⟨610, 3, 5, 6⟩ cache_610, place ⟨600, 0, 6, 4⟩ cache_600, place ⟨613, 0, 6, 4⟩ cache_613] = cache_614 := by + decide +kernel + +theorem load_entry_614 : entryAt 614 = entry_614 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_614 : CacheEquation 614 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(614 < 6)), load_entry_614] + change forkRow [placeRow ⟨608, 1, 7, 5⟩ (denote cache_608), placeRow ⟨543, 3, 5, 6⟩ (denote cache_543), placeRow ⟨370, 6, 3, 4⟩ (denote cache_370), placeRow ⟨392, 7, 3, 4⟩ (denote cache_392), placeRow ⟨610, 3, 5, 6⟩ (denote cache_610), placeRow ⟨600, 0, 6, 4⟩ (denote cache_600), placeRow ⟨613, 0, 6, 4⟩ (denote cache_613)] = denote cache_614 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_614 + +theorem verified_row_615 : fork [place ⟨602, 7, 6, 4⟩ cache_602, place ⟨614, 1, 4, 3⟩ cache_614, place ⟨533, 5, 6, 4⟩ cache_533, place ⟨590, 7, 6, 4⟩ cache_590, place ⟨611, 6, 3, 4⟩ cache_611, place ⟨587, 3, 3, 4⟩ cache_587, place ⟨601, 5, 6, 4⟩ cache_601, place ⟨406, 1, 6, 4⟩ cache_406, place ⟨591, 3, 3, 4⟩ cache_591, place ⟨586, 3, 3, 4⟩ cache_586, place ⟨584, 5, 6, 4⟩ cache_584, place ⟨406, 3, 3, 4⟩ cache_406] = cache_615 := by + decide +kernel + +theorem load_entry_615 : entryAt 615 = entry_615 := by + rw [entryAt, table_getElem?_eq] + decide +kernel + +theorem cache_equation_615 : CacheEquation 615 := by + rw [CacheEquation, dite_eq_right (by decide : ¬(615 < 6)), load_entry_615] + change forkRow [placeRow ⟨602, 7, 6, 4⟩ (denote cache_602), placeRow ⟨614, 1, 4, 3⟩ (denote cache_614), placeRow ⟨533, 5, 6, 4⟩ (denote cache_533), placeRow ⟨590, 7, 6, 4⟩ (denote cache_590), placeRow ⟨611, 6, 3, 4⟩ (denote cache_611), placeRow ⟨587, 3, 3, 4⟩ (denote cache_587), placeRow ⟨601, 5, 6, 4⟩ (denote cache_601), placeRow ⟨406, 1, 6, 4⟩ (denote cache_406), placeRow ⟨591, 3, 3, 4⟩ (denote cache_591), placeRow ⟨586, 3, 3, 4⟩ (denote cache_586), placeRow ⟨584, 5, 6, 4⟩ (denote cache_584), placeRow ⟨406, 3, 3, 4⟩ (denote cache_406)] = denote cache_615 + simpa only [denote_fork, List.map_cons, List.map_nil, denote_place] using + congrArg denote verified_row_615 + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Heights.lean b/lean/OAI/Combinatorics/SnakyCertificate/Heights.lean new file mode 100644 index 0000000000000000000000000000000000000000..64ee3f2395e8140f624f9d5ff484ffdd2d95f611 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Heights.lean @@ -0,0 +1,361 @@ +import OAI.Combinatorics.SnakyCertificate.Cache +import OAI.Combinatorics.SnakyCertificate.TableList + +namespace OAI + +namespace SnakyCertificate.Check + +theorem cache_height_block_0 : ∀ j : Fin 16, (cached (0 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_0 : ∀ i, 0 ≤ i → i < 16 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 0) (n := 16) cache_height_block_0 + +theorem cache_height_block_16 : ∀ j : Fin 16, (cached (16 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_16 : ∀ i, 16 ≤ i → i < 32 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 16) (n := 16) cache_height_block_16 + +theorem cache_height_block_32 : ∀ j : Fin 16, (cached (32 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_32 : ∀ i, 32 ≤ i → i < 48 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 32) (n := 16) cache_height_block_32 + +theorem cache_height_block_48 : ∀ j : Fin 16, (cached (48 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_48 : ∀ i, 48 ≤ i → i < 64 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 48) (n := 16) cache_height_block_48 + +theorem cache_height_block_64 : ∀ j : Fin 16, (cached (64 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_64 : ∀ i, 64 ≤ i → i < 80 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 64) (n := 16) cache_height_block_64 + +theorem cache_height_block_80 : ∀ j : Fin 16, (cached (80 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_80 : ∀ i, 80 ≤ i → i < 96 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 80) (n := 16) cache_height_block_80 + +theorem cache_height_block_96 : ∀ j : Fin 16, (cached (96 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_96 : ∀ i, 96 ≤ i → i < 112 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 96) (n := 16) cache_height_block_96 + +theorem cache_height_block_112 : ∀ j : Fin 16, (cached (112 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_112 : ∀ i, 112 ≤ i → i < 128 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 112) (n := 16) cache_height_block_112 + +theorem cache_height_block_128 : ∀ j : Fin 16, (cached (128 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_128 : ∀ i, 128 ≤ i → i < 144 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 128) (n := 16) cache_height_block_128 + +theorem cache_height_block_144 : ∀ j : Fin 16, (cached (144 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_144 : ∀ i, 144 ≤ i → i < 160 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 144) (n := 16) cache_height_block_144 + +theorem cache_height_block_160 : ∀ j : Fin 16, (cached (160 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_160 : ∀ i, 160 ≤ i → i < 176 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 160) (n := 16) cache_height_block_160 + +theorem cache_height_block_176 : ∀ j : Fin 16, (cached (176 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_176 : ∀ i, 176 ≤ i → i < 192 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 176) (n := 16) cache_height_block_176 + +theorem cache_height_block_192 : ∀ j : Fin 16, (cached (192 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_192 : ∀ i, 192 ≤ i → i < 208 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 192) (n := 16) cache_height_block_192 + +theorem cache_height_block_208 : ∀ j : Fin 16, (cached (208 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_208 : ∀ i, 208 ≤ i → i < 224 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 208) (n := 16) cache_height_block_208 + +theorem cache_height_block_224 : ∀ j : Fin 16, (cached (224 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_224 : ∀ i, 224 ≤ i → i < 240 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 224) (n := 16) cache_height_block_224 + +theorem cache_height_block_240 : ∀ j : Fin 16, (cached (240 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_240 : ∀ i, 240 ≤ i → i < 256 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 240) (n := 16) cache_height_block_240 + +theorem cache_height_block_256 : ∀ j : Fin 16, (cached (256 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_256 : ∀ i, 256 ≤ i → i < 272 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 256) (n := 16) cache_height_block_256 + +theorem cache_height_block_272 : ∀ j : Fin 16, (cached (272 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_272 : ∀ i, 272 ≤ i → i < 288 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 272) (n := 16) cache_height_block_272 + +theorem cache_height_block_288 : ∀ j : Fin 16, (cached (288 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_288 : ∀ i, 288 ≤ i → i < 304 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 288) (n := 16) cache_height_block_288 + +theorem cache_height_block_304 : ∀ j : Fin 16, (cached (304 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_304 : ∀ i, 304 ≤ i → i < 320 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 304) (n := 16) cache_height_block_304 + +theorem cache_height_block_320 : ∀ j : Fin 16, (cached (320 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_320 : ∀ i, 320 ≤ i → i < 336 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 320) (n := 16) cache_height_block_320 + +theorem cache_height_block_336 : ∀ j : Fin 16, (cached (336 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_336 : ∀ i, 336 ≤ i → i < 352 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 336) (n := 16) cache_height_block_336 + +theorem cache_height_block_352 : ∀ j : Fin 16, (cached (352 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_352 : ∀ i, 352 ≤ i → i < 368 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 352) (n := 16) cache_height_block_352 + +theorem cache_height_block_368 : ∀ j : Fin 16, (cached (368 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_368 : ∀ i, 368 ≤ i → i < 384 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 368) (n := 16) cache_height_block_368 + +theorem cache_height_block_384 : ∀ j : Fin 16, (cached (384 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_384 : ∀ i, 384 ≤ i → i < 400 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 384) (n := 16) cache_height_block_384 + +theorem cache_height_block_400 : ∀ j : Fin 16, (cached (400 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_400 : ∀ i, 400 ≤ i → i < 416 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 400) (n := 16) cache_height_block_400 + +theorem cache_height_block_416 : ∀ j : Fin 16, (cached (416 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_416 : ∀ i, 416 ≤ i → i < 432 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 416) (n := 16) cache_height_block_416 + +theorem cache_height_block_432 : ∀ j : Fin 16, (cached (432 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_432 : ∀ i, 432 ≤ i → i < 448 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 432) (n := 16) cache_height_block_432 + +theorem cache_height_block_448 : ∀ j : Fin 16, (cached (448 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_448 : ∀ i, 448 ≤ i → i < 464 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 448) (n := 16) cache_height_block_448 + +theorem cache_height_block_464 : ∀ j : Fin 16, (cached (464 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_464 : ∀ i, 464 ≤ i → i < 480 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 464) (n := 16) cache_height_block_464 + +theorem cache_height_block_480 : ∀ j : Fin 16, (cached (480 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_480 : ∀ i, 480 ≤ i → i < 496 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 480) (n := 16) cache_height_block_480 + +theorem cache_height_block_496 : ∀ j : Fin 16, (cached (496 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_496 : ∀ i, 496 ≤ i → i < 512 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 496) (n := 16) cache_height_block_496 + +theorem cache_height_block_512 : ∀ j : Fin 16, (cached (512 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_512 : ∀ i, 512 ≤ i → i < 528 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 512) (n := 16) cache_height_block_512 + +theorem cache_height_block_528 : ∀ j : Fin 16, (cached (528 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_528 : ∀ i, 528 ≤ i → i < 544 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 528) (n := 16) cache_height_block_528 + +theorem cache_height_block_544 : ∀ j : Fin 16, (cached (544 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_544 : ∀ i, 544 ≤ i → i < 560 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 544) (n := 16) cache_height_block_544 + +theorem cache_height_block_560 : ∀ j : Fin 16, (cached (560 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_560 : ∀ i, 560 ≤ i → i < 576 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 560) (n := 16) cache_height_block_560 + +theorem cache_height_block_576 : ∀ j : Fin 16, (cached (576 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_576 : ∀ i, 576 ≤ i → i < 592 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 576) (n := 16) cache_height_block_576 + +theorem cache_height_block_592 : ∀ j : Fin 16, (cached (592 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_592 : ∀ i, 592 ≤ i → i < 608 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 592) (n := 16) cache_height_block_592 + +theorem cache_height_block_608 : ∀ j : Fin 8, (cached (608 + j.val)).height ≤ 34 := by + decide +kernel + +theorem cache_height_range_608 : ∀ i, 608 ≤ i → i < 616 → (cached i).height ≤ 34 := + fin_block_range (P := fun i => (cached i).height ≤ 34) (a := 608) (n := 8) cache_height_block_608 + +theorem cache_height_range_0_32 : ∀ i, 0 ≤ i → i < 32 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_0 cache_height_range_16 + +theorem cache_height_range_32_64 : ∀ i, 32 ≤ i → i < 64 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_32 cache_height_range_48 + +theorem cache_height_range_0_64 : ∀ i, 0 ≤ i → i < 64 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_0_32 cache_height_range_32_64 + +theorem cache_height_range_64_96 : ∀ i, 64 ≤ i → i < 96 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_64 cache_height_range_80 + +theorem cache_height_range_112_144 : ∀ i, 112 ≤ i → i < 144 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_112 cache_height_range_128 + +theorem cache_height_range_96_144 : ∀ i, 96 ≤ i → i < 144 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_96 cache_height_range_112_144 + +theorem cache_height_range_64_144 : ∀ i, 64 ≤ i → i < 144 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_64_96 cache_height_range_96_144 + +theorem cache_height_range_0_144 : ∀ i, 0 ≤ i → i < 144 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_0_64 cache_height_range_64_144 + +theorem cache_height_range_144_176 : ∀ i, 144 ≤ i → i < 176 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_144 cache_height_range_160 + +theorem cache_height_range_192_224 : ∀ i, 192 ≤ i → i < 224 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_192 cache_height_range_208 + +theorem cache_height_range_176_224 : ∀ i, 176 ≤ i → i < 224 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_176 cache_height_range_192_224 + +theorem cache_height_range_144_224 : ∀ i, 144 ≤ i → i < 224 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_144_176 cache_height_range_176_224 + +theorem cache_height_range_224_256 : ∀ i, 224 ≤ i → i < 256 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_224 cache_height_range_240 + +theorem cache_height_range_272_304 : ∀ i, 272 ≤ i → i < 304 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_272 cache_height_range_288 + +theorem cache_height_range_256_304 : ∀ i, 256 ≤ i → i < 304 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_256 cache_height_range_272_304 + +theorem cache_height_range_224_304 : ∀ i, 224 ≤ i → i < 304 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_224_256 cache_height_range_256_304 + +theorem cache_height_range_144_304 : ∀ i, 144 ≤ i → i < 304 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_144_224 cache_height_range_224_304 + +theorem cache_height_range_0_304 : ∀ i, 0 ≤ i → i < 304 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_0_144 cache_height_range_144_304 + +theorem cache_height_range_304_336 : ∀ i, 304 ≤ i → i < 336 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_304 cache_height_range_320 + +theorem cache_height_range_352_384 : ∀ i, 352 ≤ i → i < 384 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_352 cache_height_range_368 + +theorem cache_height_range_336_384 : ∀ i, 336 ≤ i → i < 384 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_336 cache_height_range_352_384 + +theorem cache_height_range_304_384 : ∀ i, 304 ≤ i → i < 384 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_304_336 cache_height_range_336_384 + +theorem cache_height_range_384_416 : ∀ i, 384 ≤ i → i < 416 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_384 cache_height_range_400 + +theorem cache_height_range_432_464 : ∀ i, 432 ≤ i → i < 464 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_432 cache_height_range_448 + +theorem cache_height_range_416_464 : ∀ i, 416 ≤ i → i < 464 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_416 cache_height_range_432_464 + +theorem cache_height_range_384_464 : ∀ i, 384 ≤ i → i < 464 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_384_416 cache_height_range_416_464 + +theorem cache_height_range_304_464 : ∀ i, 304 ≤ i → i < 464 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_304_384 cache_height_range_384_464 + +theorem cache_height_range_464_496 : ∀ i, 464 ≤ i → i < 496 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_464 cache_height_range_480 + +theorem cache_height_range_512_544 : ∀ i, 512 ≤ i → i < 544 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_512 cache_height_range_528 + +theorem cache_height_range_496_544 : ∀ i, 496 ≤ i → i < 544 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_496 cache_height_range_512_544 + +theorem cache_height_range_464_544 : ∀ i, 464 ≤ i → i < 544 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_464_496 cache_height_range_496_544 + +theorem cache_height_range_544_576 : ∀ i, 544 ≤ i → i < 576 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_544 cache_height_range_560 + +theorem cache_height_range_592_616 : ∀ i, 592 ≤ i → i < 616 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_592 cache_height_range_608 + +theorem cache_height_range_576_616 : ∀ i, 576 ≤ i → i < 616 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_576 cache_height_range_592_616 + +theorem cache_height_range_544_616 : ∀ i, 544 ≤ i → i < 616 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_544_576 cache_height_range_576_616 + +theorem cache_height_range_464_616 : ∀ i, 464 ≤ i → i < 616 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_464_544 cache_height_range_544_616 + +theorem cache_height_range_304_616 : ∀ i, 304 ≤ i → i < 616 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_304_464 cache_height_range_464_616 + +theorem cache_height_range_0_616 : ∀ i, 0 ≤ i → i < 616 → (fun i => (cached i).height ≤ 34) i := + merge_ranges cache_height_range_0_304 cache_height_range_304_616 + +theorem cache_heights (i : ℕ) (hi : i < 616) : (cached i).height ≤ 34 := + cache_height_range_0_616 i (Nat.zero_le _) hi + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Invariants.lean b/lean/OAI/Combinatorics/SnakyCertificate/Invariants.lean new file mode 100644 index 0000000000000000000000000000000000000000..e011599b4442cab88eb4e32627938d643dc60362 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Invariants.lean @@ -0,0 +1,98 @@ +import OAI.Combinatorics.SnakyCertificate.Rows + +namespace OAI + +namespace SnakyCertificate + +theorem unionA_subset_unionH (ds : List RowData) + (h : ∀ d ∈ ds, d.A ⊆ d.H) : unionA ds ⊆ unionH ds := by + induction ds with + | nil => simp [unionA, unionH] + | cons d ds ih => + change d.A ∪ unionA ds ⊆ d.H ∪ unionH ds + exact Finset.union_subset_union (h d (by simp)) + (ih (fun e he => h e (by simp only [List.mem_cons]; exact Or.inr he))) + +theorem fold_inter_subset (ss : List (Finset Cell)) (s : Finset Cell) : + ss.foldr (· ∩ ·) s ⊆ s := by + induction ss with + | nil => exact Finset.Subset.refl s + | cons t ts ih => exact Finset.inter_subset_right.trans ih + +theorem commonH_subset_unionH (ds : List RowData) : commonH ds ⊆ unionH ds := by + cases ds with + | nil => simp [commonH, unionH] + | cons d ds => + change (ds.map RowData.H).foldr (· ∩ ·) d.H ⊆ d.H ∪ unionH ds + exact (fold_inter_subset _ _).trans Finset.subset_union_left + +theorem forkRow_subset (ds : List RowData) (h : ∀ d ∈ ds, d.A ⊆ d.H) : + (forkRow ds).A ⊆ (forkRow ds).H := by + intro p hp + have hp' : p ∈ unionA ds ∪ commonH ds := Finset.mem_of_mem_erase hp + exact Finset.mem_insert_of_mem + ((Finset.union_subset (unionA_subset_unionH ds h) (commonH_subset_unionH ds)) hp') + +def RowSubset (d : RowData) : Prop := d.A ⊆ d.H + +theorem forkRow_RowSubset (ds : List RowData) (h : ∀ d ∈ ds, RowSubset d) : + RowSubset (forkRow ds) := forkRow_subset ds h + +theorem rowAt_RowSubset (i : ℕ) : RowSubset (rowAt i) := by + induction i using Nat.strong_induction_on with + | h i ih => + rw [rowAt] + split + · exact Finset.erase_subset _ _ + · refine forkRow_RowSubset + ((entryAt i).terms.map fun t => + placeRow t (if hc : t.child < i then rowAt t.child else emptyRow)) ?_ + intro d hd + obtain ⟨t, ht, rfl⟩ := List.mem_map.mp hd + change (placeRow t (if hc : t.child < i then rowAt t.child else emptyRow)).A ⊆ + (placeRow t (if hc : t.child < i then rowAt t.child else emptyRow)).H + exact Finset.image_subset_image (by + split + · rename_i hc + exact ih t.child hc + · exact Finset.Subset.refl ∅) + +theorem rowAt_subset (i : ℕ) : (rowAt i).A ⊆ (rowAt i).H := rowAt_RowSubset i + +theorem baseRow_origin (i : Fin 6) : + origin ∈ (baseRow i).H ∧ origin ∉ (baseRow i).A := by + fin_cases i <;> decide + +theorem rowAt_origin (i : ℕ) : origin ∈ (rowAt i).H ∧ origin ∉ (rowAt i).A := by + rw [rowAt] + split + · exact baseRow_origin _ + · simp [forkRow] + +theorem rowAt_unique (f : ℕ → RowData) (bound : ℕ) + (backward : ∀ i, 6 ≤ i → i < bound → + ∀ t ∈ (entryAt i).terms, t.child < i) + (equations : ∀ i, i < bound → + if h : i < 6 then baseRow ⟨i, h⟩ = f i else + forkRow ((entryAt i).terms.map fun t => placeRow t (f t.child)) = f i) : + ∀ i, i < bound → rowAt i = f i := by + intro i + induction i using Nat.strong_induction_on with + | h i ih => + intro hi + rw [rowAt] + by_cases hb : i < 6 + · simpa only [dite_eq_left hb] using equations i hi + · rw [dite_eq_right hb] + have he := equations i hi + rw [dite_eq_right hb] at he + rw [← he] + apply congrArg forkRow + apply List.map_congr_left + intro t ht + have hc := backward i (by omega) hi t ht + rw [dite_eq_left hc, ih t.child hc (hc.trans hi)] + +end SnakyCertificate + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Lists.lean b/lean/OAI/Combinatorics/SnakyCertificate/Lists.lean new file mode 100644 index 0000000000000000000000000000000000000000..92074bf3ae3b284ad1ccce5dc6d9777505d139a3 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Lists.lean @@ -0,0 +1,140 @@ +import OAI.Combinatorics.SnakyCertificate.Rows + +namespace OAI + +namespace SnakyCertificate.Check + +abbrev Key := ℤ ×ₗ ℤ + +def mergeFuel : ℕ → List Cell → List Cell → List Cell + | 0, xs, ys => xs ++ ys + | _ + 1, [], ys => ys + | _ + 1, xs, [] => xs + | n + 1, x :: xs, y :: ys => + if x = y then x :: mergeFuel n xs ys + else if toLex x < toLex y then x :: mergeFuel n xs (y :: ys) + else y :: mergeFuel n (x :: xs) ys + +theorem mem_mergeFuel (z : Cell) (n : ℕ) (xs ys : List Cell) : + z ∈ mergeFuel n xs ys ↔ z ∈ xs ∨ z ∈ ys := by + induction n generalizing xs ys with + | zero => simp [mergeFuel] + | succ n ih => + cases xs with + | nil => simp [mergeFuel] + | cons x xs => + cases ys with + | nil => simp [mergeFuel] + | cons y ys => + simp only [mergeFuel] + split + · rename_i h; subst y + simp only [List.mem_cons, ih] + tauto + · split <;> simp only [List.mem_cons, ih] <;> tauto + +def mergeUnion (xs ys : List Cell) : List Cell := + mergeFuel (xs.length + ys.length) xs ys + +@[simp] theorem mem_mergeUnion (z : Cell) (xs ys : List Cell) : + z ∈ mergeUnion xs ys ↔ z ∈ xs ∨ z ∈ ys := + mem_mergeFuel z _ xs ys + +@[simp] theorem toFinset_mergeUnion (xs ys : List Cell) : + (mergeUnion xs ys).toFinset = xs.toFinset ∪ ys.toFinset := by + ext z; simp + +structure ListRow where + A : List Cell + H : List Cell + height : ℕ + deriving DecidableEq + +def denote (d : ListRow) : RowData := ⟨d.A.toFinset, d.H.toFinset, d.height⟩ + +def keyPlace (t : Term) (p : Cell) : Cell := + placement t.rotation t.shift p + +def sortFuel : ℕ → List Cell → List Cell + | 0, xs => xs + | n + 1, xs => + if xs.length ≤ 1 then xs else + mergeUnion (sortFuel n (xs.take (xs.length / 2))) + (sortFuel n (xs.drop (xs.length / 2))) + +theorem mem_sortFuel (z : Cell) (n : ℕ) (xs : List Cell) : + z ∈ sortFuel n xs ↔ z ∈ xs := by + induction n generalizing xs with + | zero => rfl + | succ n ih => + simp only [sortFuel] + split + · rfl + · rw [mem_mergeUnion, ih, ih, ← List.mem_append, List.take_append_drop] + +def sorted (xs : List Cell) : List Cell := sortFuel xs.length xs + +def place (t : Term) (d : ListRow) : ListRow := + ⟨sorted (d.A.map (keyPlace t)), sorted (d.H.map (keyPlace t)), d.height⟩ + +def unions (xs : List (List Cell)) : List Cell := xs.foldr mergeUnion [] + +def common (xs : List (List Cell)) : List Cell := + match xs with + | [] => [] + | x :: rest => rest.foldr (· ∩ ·) x + +def fork (ds : List ListRow) : ListRow := + ⟨(mergeUnion (unions (ds.map ListRow.A)) (common (ds.map ListRow.H))).filter + (fun p => decide (p ≠ origin)), + mergeUnion [origin] (unions (ds.map ListRow.H)), + 1 + (ds.map ListRow.height).foldr max 0⟩ + +@[simp] theorem toFinset_sorted (xs : List Cell) : (sorted xs).toFinset = xs.toFinset := by + ext z; simp [sorted, mem_sortFuel] + +@[simp] theorem denote_place (t : Term) (d : ListRow) : + denote (place t d) = placeRow t (denote d) := by + have heq (xs : List Cell) : + (sorted (xs.map (keyPlace t))).toFinset = xs.toFinset.image (placement t.rotation t.shift) := by + ext z + simp [keyPlace] + simp only [denote, place, placeRow, heq] + +@[simp] theorem toFinset_unions (xs : List (List Cell)) : + (unions xs).toFinset = (xs.map List.toFinset).foldr (· ∪ ·) ∅ := by + induction xs with + | nil => rfl + | cons x xs ih => simp_all [unions] + +@[simp] theorem toFinset_inter_cell (xs ys : List Cell) : + (xs ∩ ys).toFinset = xs.toFinset ∩ ys.toFinset := by + ext p; simp + +theorem toFinset_inters (xs : List (List Cell)) (a : List Cell) : + (xs.foldr (· ∩ ·) a).toFinset = (xs.map List.toFinset).foldr (· ∩ ·) a.toFinset := by + induction xs with + | nil => rfl + | cons x xs ih => simp_all only [List.foldr_cons, List.map_cons, toFinset_inter_cell] + +@[simp] theorem toFinset_common (ds : List ListRow) : + (common (ds.map ListRow.H)).toFinset = commonH (ds.map denote) := by + cases ds with + | nil => rfl + | cons d ds => simp [common, commonH, toFinset_inters, Function.comp_def, denote] + +theorem denote_fork (ds : List ListRow) : denote (fork ds) = forkRow (ds.map denote) := by + have hA : (unions (ds.map ListRow.A)).toFinset = unionA (ds.map denote) := by + simp [unionA, Function.comp_def, denote] + have hH : (unions (ds.map ListRow.H)).toFinset = unionH (ds.map denote) := by + simp [unionH, Function.comp_def, denote] + have hf (xs : List Cell) : + (xs.filter (fun p => decide (p ≠ origin))).toFinset = xs.toFinset.erase origin := by + ext p; simp [and_comm] + simp only [denote, fork, hf, toFinset_mergeUnion, hA, hH, toFinset_common, + List.toFinset_cons, List.toFinset_nil] + simp [forkRow, denote, Function.comp_def] + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Main.lean b/lean/OAI/Combinatorics/SnakyCertificate/Main.lean new file mode 100644 index 0000000000000000000000000000000000000000..474da7d1b312a0d71a97131281f4cddec2b21fbc --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Main.lean @@ -0,0 +1,62 @@ +import OAI.Combinatorics.SnakyCertificate.TableValidity +import OAI.Combinatorics.SnakyCertificate.Invariants +import OAI.Combinatorics.SnakyCertificate.Reconstruction +import OAI.Combinatorics.SnakyCertificate.Heights +import OAI.Combinatorics.SnakyCertificate.Summaries + +namespace OAI + +namespace SnakyCertificate.Check + +theorem rowAt_eq_cached (i : ℕ) (hi : i < 616) : rowAt i = denote (cached i) := + rowAt_unique (fun j => denote (cached j)) 616 + (fun _ hlo hhi _ ht => entryAt_backward hlo hhi ht) + cache_equations i hi + +theorem output557 : Output 557 (-1, 0) 118 19 {p | p.1 ≤ -3 ∧ p.2 ≤ -2} := by + apply output_of_row_eq 557 cache_557 (-1, 0) 118 19 _ + · exact rowAt_eq_cached 557 (by decide) + · exact cache_summary_557 + · exact cache_omits_557 + +theorem output595 : Output 595 (-1, 0) 222 27 {p | p.1 = -2 ∧ p.2 ≤ -2} := by + apply output_of_row_eq 595 cache_595 (-1, 0) 222 27 _ + · exact rowAt_eq_cached 595 (by decide) + · exact cache_summary_595 + · exact cache_omits_595 + +theorem output603 : Output 603 (-1, 0) 275 27 {p | p.1 ≤ -3 ∧ p.2 = 0} := by + apply output_of_row_eq 603 cache_603 (-1, 0) 275 27 _ + · exact rowAt_eq_cached 603 (by decide) + · exact cache_summary_603 + · exact cache_omits_603 + +theorem output615 : Output 615 (1, 0) 686 34 {(1, -1)} := by + apply output_of_row_eq 615 cache_615 (1, 0) 686 34 _ + · exact rowAt_eq_cached 615 (by decide) + · exact cache_summary_615 + · exact cache_omits_615 + +theorem all_rows : AllRows := by + intro i hi + refine ⟨rowAt_subset i, (rowAt_origin i).1, (rowAt_origin i).2, ?_⟩ + rw [rowAt_eq_cached i hi] + exact cache_heights i hi + +end SnakyCertificate.Check + +namespace SnakyCertificate + +theorem certificate_correct : + TableValid ∧ placementCount = 1837 ∧ + Output 557 (-1, 0) 118 19 {p | p.1 ≤ -3 ∧ p.2 ≤ -2} ∧ + Output 595 (-1, 0) 222 27 {p | p.1 = -2 ∧ p.2 ≤ -2} ∧ + Output 603 (-1, 0) 275 27 {p | p.1 ≤ -3 ∧ p.2 = 0} ∧ + Output 615 (1, 0) 686 34 {(1, -1)} ∧ + AllRows := by + exact ⟨table_valid, placement_count, Check.output557, Check.output595, + Check.output603, Check.output615, Check.all_rows⟩ + +end SnakyCertificate + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Reconstruction.lean b/lean/OAI/Combinatorics/SnakyCertificate/Reconstruction.lean new file mode 100644 index 0000000000000000000000000000000000000000..a5c679ca056196bcb6ca81cefbb031048a1791e7 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Reconstruction.lean @@ -0,0 +1,913 @@ +import OAI.Combinatorics.SnakyCertificate.Equations00 +import OAI.Combinatorics.SnakyCertificate.Equations01 +import OAI.Combinatorics.SnakyCertificate.Equations02 +import OAI.Combinatorics.SnakyCertificate.Equations03 +import OAI.Combinatorics.SnakyCertificate.Equations04 +import OAI.Combinatorics.SnakyCertificate.Equations05 +import OAI.Combinatorics.SnakyCertificate.Equations06 +import OAI.Combinatorics.SnakyCertificate.Equations07 +import OAI.Combinatorics.SnakyCertificate.Equations08 +import OAI.Combinatorics.SnakyCertificate.Equations09 +import OAI.Combinatorics.SnakyCertificate.Equations10 +import OAI.Combinatorics.SnakyCertificate.Equations11 +import OAI.Combinatorics.SnakyCertificate.Equations12 +import OAI.Combinatorics.SnakyCertificate.Equations13 +import OAI.Combinatorics.SnakyCertificate.Equations14 +import OAI.Combinatorics.SnakyCertificate.Equations15 + +namespace OAI + +namespace SnakyCertificate.Check + +theorem cache_equations_range_0 : ∀ i, 0 ≤ i → i < 16 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_0 + · exact cache_equation_1 + · exact cache_equation_2 + · exact cache_equation_3 + · exact cache_equation_4 + · exact cache_equation_5 + · exact cache_equation_6 + · exact cache_equation_7 + · exact cache_equation_8 + · exact cache_equation_9 + · exact cache_equation_10 + · exact cache_equation_11 + · exact cache_equation_12 + · exact cache_equation_13 + · exact cache_equation_14 + · exact cache_equation_15 + +theorem cache_equations_range_16 : ∀ i, 16 ≤ i → i < 32 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_16 + · exact cache_equation_17 + · exact cache_equation_18 + · exact cache_equation_19 + · exact cache_equation_20 + · exact cache_equation_21 + · exact cache_equation_22 + · exact cache_equation_23 + · exact cache_equation_24 + · exact cache_equation_25 + · exact cache_equation_26 + · exact cache_equation_27 + · exact cache_equation_28 + · exact cache_equation_29 + · exact cache_equation_30 + · exact cache_equation_31 + +theorem cache_equations_range_32 : ∀ i, 32 ≤ i → i < 48 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_32 + · exact cache_equation_33 + · exact cache_equation_34 + · exact cache_equation_35 + · exact cache_equation_36 + · exact cache_equation_37 + · exact cache_equation_38 + · exact cache_equation_39 + · exact cache_equation_40 + · exact cache_equation_41 + · exact cache_equation_42 + · exact cache_equation_43 + · exact cache_equation_44 + · exact cache_equation_45 + · exact cache_equation_46 + · exact cache_equation_47 + +theorem cache_equations_range_48 : ∀ i, 48 ≤ i → i < 64 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_48 + · exact cache_equation_49 + · exact cache_equation_50 + · exact cache_equation_51 + · exact cache_equation_52 + · exact cache_equation_53 + · exact cache_equation_54 + · exact cache_equation_55 + · exact cache_equation_56 + · exact cache_equation_57 + · exact cache_equation_58 + · exact cache_equation_59 + · exact cache_equation_60 + · exact cache_equation_61 + · exact cache_equation_62 + · exact cache_equation_63 + +theorem cache_equations_range_64 : ∀ i, 64 ≤ i → i < 80 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_64 + · exact cache_equation_65 + · exact cache_equation_66 + · exact cache_equation_67 + · exact cache_equation_68 + · exact cache_equation_69 + · exact cache_equation_70 + · exact cache_equation_71 + · exact cache_equation_72 + · exact cache_equation_73 + · exact cache_equation_74 + · exact cache_equation_75 + · exact cache_equation_76 + · exact cache_equation_77 + · exact cache_equation_78 + · exact cache_equation_79 + +theorem cache_equations_range_80 : ∀ i, 80 ≤ i → i < 96 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_80 + · exact cache_equation_81 + · exact cache_equation_82 + · exact cache_equation_83 + · exact cache_equation_84 + · exact cache_equation_85 + · exact cache_equation_86 + · exact cache_equation_87 + · exact cache_equation_88 + · exact cache_equation_89 + · exact cache_equation_90 + · exact cache_equation_91 + · exact cache_equation_92 + · exact cache_equation_93 + · exact cache_equation_94 + · exact cache_equation_95 + +theorem cache_equations_range_96 : ∀ i, 96 ≤ i → i < 112 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_96 + · exact cache_equation_97 + · exact cache_equation_98 + · exact cache_equation_99 + · exact cache_equation_100 + · exact cache_equation_101 + · exact cache_equation_102 + · exact cache_equation_103 + · exact cache_equation_104 + · exact cache_equation_105 + · exact cache_equation_106 + · exact cache_equation_107 + · exact cache_equation_108 + · exact cache_equation_109 + · exact cache_equation_110 + · exact cache_equation_111 + +theorem cache_equations_range_112 : ∀ i, 112 ≤ i → i < 128 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_112 + · exact cache_equation_113 + · exact cache_equation_114 + · exact cache_equation_115 + · exact cache_equation_116 + · exact cache_equation_117 + · exact cache_equation_118 + · exact cache_equation_119 + · exact cache_equation_120 + · exact cache_equation_121 + · exact cache_equation_122 + · exact cache_equation_123 + · exact cache_equation_124 + · exact cache_equation_125 + · exact cache_equation_126 + · exact cache_equation_127 + +theorem cache_equations_range_128 : ∀ i, 128 ≤ i → i < 144 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_128 + · exact cache_equation_129 + · exact cache_equation_130 + · exact cache_equation_131 + · exact cache_equation_132 + · exact cache_equation_133 + · exact cache_equation_134 + · exact cache_equation_135 + · exact cache_equation_136 + · exact cache_equation_137 + · exact cache_equation_138 + · exact cache_equation_139 + · exact cache_equation_140 + · exact cache_equation_141 + · exact cache_equation_142 + · exact cache_equation_143 + +theorem cache_equations_range_144 : ∀ i, 144 ≤ i → i < 160 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_144 + · exact cache_equation_145 + · exact cache_equation_146 + · exact cache_equation_147 + · exact cache_equation_148 + · exact cache_equation_149 + · exact cache_equation_150 + · exact cache_equation_151 + · exact cache_equation_152 + · exact cache_equation_153 + · exact cache_equation_154 + · exact cache_equation_155 + · exact cache_equation_156 + · exact cache_equation_157 + · exact cache_equation_158 + · exact cache_equation_159 + +theorem cache_equations_range_160 : ∀ i, 160 ≤ i → i < 176 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_160 + · exact cache_equation_161 + · exact cache_equation_162 + · exact cache_equation_163 + · exact cache_equation_164 + · exact cache_equation_165 + · exact cache_equation_166 + · exact cache_equation_167 + · exact cache_equation_168 + · exact cache_equation_169 + · exact cache_equation_170 + · exact cache_equation_171 + · exact cache_equation_172 + · exact cache_equation_173 + · exact cache_equation_174 + · exact cache_equation_175 + +theorem cache_equations_range_176 : ∀ i, 176 ≤ i → i < 192 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_176 + · exact cache_equation_177 + · exact cache_equation_178 + · exact cache_equation_179 + · exact cache_equation_180 + · exact cache_equation_181 + · exact cache_equation_182 + · exact cache_equation_183 + · exact cache_equation_184 + · exact cache_equation_185 + · exact cache_equation_186 + · exact cache_equation_187 + · exact cache_equation_188 + · exact cache_equation_189 + · exact cache_equation_190 + · exact cache_equation_191 + +theorem cache_equations_range_192 : ∀ i, 192 ≤ i → i < 208 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_192 + · exact cache_equation_193 + · exact cache_equation_194 + · exact cache_equation_195 + · exact cache_equation_196 + · exact cache_equation_197 + · exact cache_equation_198 + · exact cache_equation_199 + · exact cache_equation_200 + · exact cache_equation_201 + · exact cache_equation_202 + · exact cache_equation_203 + · exact cache_equation_204 + · exact cache_equation_205 + · exact cache_equation_206 + · exact cache_equation_207 + +theorem cache_equations_range_208 : ∀ i, 208 ≤ i → i < 224 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_208 + · exact cache_equation_209 + · exact cache_equation_210 + · exact cache_equation_211 + · exact cache_equation_212 + · exact cache_equation_213 + · exact cache_equation_214 + · exact cache_equation_215 + · exact cache_equation_216 + · exact cache_equation_217 + · exact cache_equation_218 + · exact cache_equation_219 + · exact cache_equation_220 + · exact cache_equation_221 + · exact cache_equation_222 + · exact cache_equation_223 + +theorem cache_equations_range_224 : ∀ i, 224 ≤ i → i < 240 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_224 + · exact cache_equation_225 + · exact cache_equation_226 + · exact cache_equation_227 + · exact cache_equation_228 + · exact cache_equation_229 + · exact cache_equation_230 + · exact cache_equation_231 + · exact cache_equation_232 + · exact cache_equation_233 + · exact cache_equation_234 + · exact cache_equation_235 + · exact cache_equation_236 + · exact cache_equation_237 + · exact cache_equation_238 + · exact cache_equation_239 + +theorem cache_equations_range_240 : ∀ i, 240 ≤ i → i < 256 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_240 + · exact cache_equation_241 + · exact cache_equation_242 + · exact cache_equation_243 + · exact cache_equation_244 + · exact cache_equation_245 + · exact cache_equation_246 + · exact cache_equation_247 + · exact cache_equation_248 + · exact cache_equation_249 + · exact cache_equation_250 + · exact cache_equation_251 + · exact cache_equation_252 + · exact cache_equation_253 + · exact cache_equation_254 + · exact cache_equation_255 + +theorem cache_equations_range_256 : ∀ i, 256 ≤ i → i < 272 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_256 + · exact cache_equation_257 + · exact cache_equation_258 + · exact cache_equation_259 + · exact cache_equation_260 + · exact cache_equation_261 + · exact cache_equation_262 + · exact cache_equation_263 + · exact cache_equation_264 + · exact cache_equation_265 + · exact cache_equation_266 + · exact cache_equation_267 + · exact cache_equation_268 + · exact cache_equation_269 + · exact cache_equation_270 + · exact cache_equation_271 + +theorem cache_equations_range_272 : ∀ i, 272 ≤ i → i < 288 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_272 + · exact cache_equation_273 + · exact cache_equation_274 + · exact cache_equation_275 + · exact cache_equation_276 + · exact cache_equation_277 + · exact cache_equation_278 + · exact cache_equation_279 + · exact cache_equation_280 + · exact cache_equation_281 + · exact cache_equation_282 + · exact cache_equation_283 + · exact cache_equation_284 + · exact cache_equation_285 + · exact cache_equation_286 + · exact cache_equation_287 + +theorem cache_equations_range_288 : ∀ i, 288 ≤ i → i < 304 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_288 + · exact cache_equation_289 + · exact cache_equation_290 + · exact cache_equation_291 + · exact cache_equation_292 + · exact cache_equation_293 + · exact cache_equation_294 + · exact cache_equation_295 + · exact cache_equation_296 + · exact cache_equation_297 + · exact cache_equation_298 + · exact cache_equation_299 + · exact cache_equation_300 + · exact cache_equation_301 + · exact cache_equation_302 + · exact cache_equation_303 + +theorem cache_equations_range_304 : ∀ i, 304 ≤ i → i < 320 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_304 + · exact cache_equation_305 + · exact cache_equation_306 + · exact cache_equation_307 + · exact cache_equation_308 + · exact cache_equation_309 + · exact cache_equation_310 + · exact cache_equation_311 + · exact cache_equation_312 + · exact cache_equation_313 + · exact cache_equation_314 + · exact cache_equation_315 + · exact cache_equation_316 + · exact cache_equation_317 + · exact cache_equation_318 + · exact cache_equation_319 + +theorem cache_equations_range_320 : ∀ i, 320 ≤ i → i < 336 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_320 + · exact cache_equation_321 + · exact cache_equation_322 + · exact cache_equation_323 + · exact cache_equation_324 + · exact cache_equation_325 + · exact cache_equation_326 + · exact cache_equation_327 + · exact cache_equation_328 + · exact cache_equation_329 + · exact cache_equation_330 + · exact cache_equation_331 + · exact cache_equation_332 + · exact cache_equation_333 + · exact cache_equation_334 + · exact cache_equation_335 + +theorem cache_equations_range_336 : ∀ i, 336 ≤ i → i < 352 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_336 + · exact cache_equation_337 + · exact cache_equation_338 + · exact cache_equation_339 + · exact cache_equation_340 + · exact cache_equation_341 + · exact cache_equation_342 + · exact cache_equation_343 + · exact cache_equation_344 + · exact cache_equation_345 + · exact cache_equation_346 + · exact cache_equation_347 + · exact cache_equation_348 + · exact cache_equation_349 + · exact cache_equation_350 + · exact cache_equation_351 + +theorem cache_equations_range_352 : ∀ i, 352 ≤ i → i < 368 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_352 + · exact cache_equation_353 + · exact cache_equation_354 + · exact cache_equation_355 + · exact cache_equation_356 + · exact cache_equation_357 + · exact cache_equation_358 + · exact cache_equation_359 + · exact cache_equation_360 + · exact cache_equation_361 + · exact cache_equation_362 + · exact cache_equation_363 + · exact cache_equation_364 + · exact cache_equation_365 + · exact cache_equation_366 + · exact cache_equation_367 + +theorem cache_equations_range_368 : ∀ i, 368 ≤ i → i < 384 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_368 + · exact cache_equation_369 + · exact cache_equation_370 + · exact cache_equation_371 + · exact cache_equation_372 + · exact cache_equation_373 + · exact cache_equation_374 + · exact cache_equation_375 + · exact cache_equation_376 + · exact cache_equation_377 + · exact cache_equation_378 + · exact cache_equation_379 + · exact cache_equation_380 + · exact cache_equation_381 + · exact cache_equation_382 + · exact cache_equation_383 + +theorem cache_equations_range_384 : ∀ i, 384 ≤ i → i < 400 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_384 + · exact cache_equation_385 + · exact cache_equation_386 + · exact cache_equation_387 + · exact cache_equation_388 + · exact cache_equation_389 + · exact cache_equation_390 + · exact cache_equation_391 + · exact cache_equation_392 + · exact cache_equation_393 + · exact cache_equation_394 + · exact cache_equation_395 + · exact cache_equation_396 + · exact cache_equation_397 + · exact cache_equation_398 + · exact cache_equation_399 + +theorem cache_equations_range_400 : ∀ i, 400 ≤ i → i < 416 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_400 + · exact cache_equation_401 + · exact cache_equation_402 + · exact cache_equation_403 + · exact cache_equation_404 + · exact cache_equation_405 + · exact cache_equation_406 + · exact cache_equation_407 + · exact cache_equation_408 + · exact cache_equation_409 + · exact cache_equation_410 + · exact cache_equation_411 + · exact cache_equation_412 + · exact cache_equation_413 + · exact cache_equation_414 + · exact cache_equation_415 + +theorem cache_equations_range_416 : ∀ i, 416 ≤ i → i < 432 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_416 + · exact cache_equation_417 + · exact cache_equation_418 + · exact cache_equation_419 + · exact cache_equation_420 + · exact cache_equation_421 + · exact cache_equation_422 + · exact cache_equation_423 + · exact cache_equation_424 + · exact cache_equation_425 + · exact cache_equation_426 + · exact cache_equation_427 + · exact cache_equation_428 + · exact cache_equation_429 + · exact cache_equation_430 + · exact cache_equation_431 + +theorem cache_equations_range_432 : ∀ i, 432 ≤ i → i < 448 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_432 + · exact cache_equation_433 + · exact cache_equation_434 + · exact cache_equation_435 + · exact cache_equation_436 + · exact cache_equation_437 + · exact cache_equation_438 + · exact cache_equation_439 + · exact cache_equation_440 + · exact cache_equation_441 + · exact cache_equation_442 + · exact cache_equation_443 + · exact cache_equation_444 + · exact cache_equation_445 + · exact cache_equation_446 + · exact cache_equation_447 + +theorem cache_equations_range_448 : ∀ i, 448 ≤ i → i < 464 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_448 + · exact cache_equation_449 + · exact cache_equation_450 + · exact cache_equation_451 + · exact cache_equation_452 + · exact cache_equation_453 + · exact cache_equation_454 + · exact cache_equation_455 + · exact cache_equation_456 + · exact cache_equation_457 + · exact cache_equation_458 + · exact cache_equation_459 + · exact cache_equation_460 + · exact cache_equation_461 + · exact cache_equation_462 + · exact cache_equation_463 + +theorem cache_equations_range_464 : ∀ i, 464 ≤ i → i < 480 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_464 + · exact cache_equation_465 + · exact cache_equation_466 + · exact cache_equation_467 + · exact cache_equation_468 + · exact cache_equation_469 + · exact cache_equation_470 + · exact cache_equation_471 + · exact cache_equation_472 + · exact cache_equation_473 + · exact cache_equation_474 + · exact cache_equation_475 + · exact cache_equation_476 + · exact cache_equation_477 + · exact cache_equation_478 + · exact cache_equation_479 + +theorem cache_equations_range_480 : ∀ i, 480 ≤ i → i < 496 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_480 + · exact cache_equation_481 + · exact cache_equation_482 + · exact cache_equation_483 + · exact cache_equation_484 + · exact cache_equation_485 + · exact cache_equation_486 + · exact cache_equation_487 + · exact cache_equation_488 + · exact cache_equation_489 + · exact cache_equation_490 + · exact cache_equation_491 + · exact cache_equation_492 + · exact cache_equation_493 + · exact cache_equation_494 + · exact cache_equation_495 + +theorem cache_equations_range_496 : ∀ i, 496 ≤ i → i < 512 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_496 + · exact cache_equation_497 + · exact cache_equation_498 + · exact cache_equation_499 + · exact cache_equation_500 + · exact cache_equation_501 + · exact cache_equation_502 + · exact cache_equation_503 + · exact cache_equation_504 + · exact cache_equation_505 + · exact cache_equation_506 + · exact cache_equation_507 + · exact cache_equation_508 + · exact cache_equation_509 + · exact cache_equation_510 + · exact cache_equation_511 + +theorem cache_equations_range_512 : ∀ i, 512 ≤ i → i < 528 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_512 + · exact cache_equation_513 + · exact cache_equation_514 + · exact cache_equation_515 + · exact cache_equation_516 + · exact cache_equation_517 + · exact cache_equation_518 + · exact cache_equation_519 + · exact cache_equation_520 + · exact cache_equation_521 + · exact cache_equation_522 + · exact cache_equation_523 + · exact cache_equation_524 + · exact cache_equation_525 + · exact cache_equation_526 + · exact cache_equation_527 + +theorem cache_equations_range_528 : ∀ i, 528 ≤ i → i < 544 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_528 + · exact cache_equation_529 + · exact cache_equation_530 + · exact cache_equation_531 + · exact cache_equation_532 + · exact cache_equation_533 + · exact cache_equation_534 + · exact cache_equation_535 + · exact cache_equation_536 + · exact cache_equation_537 + · exact cache_equation_538 + · exact cache_equation_539 + · exact cache_equation_540 + · exact cache_equation_541 + · exact cache_equation_542 + · exact cache_equation_543 + +theorem cache_equations_range_544 : ∀ i, 544 ≤ i → i < 560 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_544 + · exact cache_equation_545 + · exact cache_equation_546 + · exact cache_equation_547 + · exact cache_equation_548 + · exact cache_equation_549 + · exact cache_equation_550 + · exact cache_equation_551 + · exact cache_equation_552 + · exact cache_equation_553 + · exact cache_equation_554 + · exact cache_equation_555 + · exact cache_equation_556 + · exact cache_equation_557 + · exact cache_equation_558 + · exact cache_equation_559 + +theorem cache_equations_range_560 : ∀ i, 560 ≤ i → i < 576 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_560 + · exact cache_equation_561 + · exact cache_equation_562 + · exact cache_equation_563 + · exact cache_equation_564 + · exact cache_equation_565 + · exact cache_equation_566 + · exact cache_equation_567 + · exact cache_equation_568 + · exact cache_equation_569 + · exact cache_equation_570 + · exact cache_equation_571 + · exact cache_equation_572 + · exact cache_equation_573 + · exact cache_equation_574 + · exact cache_equation_575 + +theorem cache_equations_range_576 : ∀ i, 576 ≤ i → i < 592 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_576 + · exact cache_equation_577 + · exact cache_equation_578 + · exact cache_equation_579 + · exact cache_equation_580 + · exact cache_equation_581 + · exact cache_equation_582 + · exact cache_equation_583 + · exact cache_equation_584 + · exact cache_equation_585 + · exact cache_equation_586 + · exact cache_equation_587 + · exact cache_equation_588 + · exact cache_equation_589 + · exact cache_equation_590 + · exact cache_equation_591 + +theorem cache_equations_range_592 : ∀ i, 592 ≤ i → i < 608 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_592 + · exact cache_equation_593 + · exact cache_equation_594 + · exact cache_equation_595 + · exact cache_equation_596 + · exact cache_equation_597 + · exact cache_equation_598 + · exact cache_equation_599 + · exact cache_equation_600 + · exact cache_equation_601 + · exact cache_equation_602 + · exact cache_equation_603 + · exact cache_equation_604 + · exact cache_equation_605 + · exact cache_equation_606 + · exact cache_equation_607 + +theorem cache_equations_range_608 : ∀ i, 608 ≤ i → i < 616 → CacheEquation i := by + intro i hlo hhi + interval_cases i + · exact cache_equation_608 + · exact cache_equation_609 + · exact cache_equation_610 + · exact cache_equation_611 + · exact cache_equation_612 + · exact cache_equation_613 + · exact cache_equation_614 + · exact cache_equation_615 + +theorem cache_equations_range_0_32 : ∀ i, 0 ≤ i → i < 32 → CacheEquation i := + merge_ranges cache_equations_range_0 cache_equations_range_16 + +theorem cache_equations_range_32_64 : ∀ i, 32 ≤ i → i < 64 → CacheEquation i := + merge_ranges cache_equations_range_32 cache_equations_range_48 + +theorem cache_equations_range_0_64 : ∀ i, 0 ≤ i → i < 64 → CacheEquation i := + merge_ranges cache_equations_range_0_32 cache_equations_range_32_64 + +theorem cache_equations_range_64_96 : ∀ i, 64 ≤ i → i < 96 → CacheEquation i := + merge_ranges cache_equations_range_64 cache_equations_range_80 + +theorem cache_equations_range_112_144 : ∀ i, 112 ≤ i → i < 144 → CacheEquation i := + merge_ranges cache_equations_range_112 cache_equations_range_128 + +theorem cache_equations_range_96_144 : ∀ i, 96 ≤ i → i < 144 → CacheEquation i := + merge_ranges cache_equations_range_96 cache_equations_range_112_144 + +theorem cache_equations_range_64_144 : ∀ i, 64 ≤ i → i < 144 → CacheEquation i := + merge_ranges cache_equations_range_64_96 cache_equations_range_96_144 + +theorem cache_equations_range_0_144 : ∀ i, 0 ≤ i → i < 144 → CacheEquation i := + merge_ranges cache_equations_range_0_64 cache_equations_range_64_144 + +theorem cache_equations_range_144_176 : ∀ i, 144 ≤ i → i < 176 → CacheEquation i := + merge_ranges cache_equations_range_144 cache_equations_range_160 + +theorem cache_equations_range_192_224 : ∀ i, 192 ≤ i → i < 224 → CacheEquation i := + merge_ranges cache_equations_range_192 cache_equations_range_208 + +theorem cache_equations_range_176_224 : ∀ i, 176 ≤ i → i < 224 → CacheEquation i := + merge_ranges cache_equations_range_176 cache_equations_range_192_224 + +theorem cache_equations_range_144_224 : ∀ i, 144 ≤ i → i < 224 → CacheEquation i := + merge_ranges cache_equations_range_144_176 cache_equations_range_176_224 + +theorem cache_equations_range_224_256 : ∀ i, 224 ≤ i → i < 256 → CacheEquation i := + merge_ranges cache_equations_range_224 cache_equations_range_240 + +theorem cache_equations_range_272_304 : ∀ i, 272 ≤ i → i < 304 → CacheEquation i := + merge_ranges cache_equations_range_272 cache_equations_range_288 + +theorem cache_equations_range_256_304 : ∀ i, 256 ≤ i → i < 304 → CacheEquation i := + merge_ranges cache_equations_range_256 cache_equations_range_272_304 + +theorem cache_equations_range_224_304 : ∀ i, 224 ≤ i → i < 304 → CacheEquation i := + merge_ranges cache_equations_range_224_256 cache_equations_range_256_304 + +theorem cache_equations_range_144_304 : ∀ i, 144 ≤ i → i < 304 → CacheEquation i := + merge_ranges cache_equations_range_144_224 cache_equations_range_224_304 + +theorem cache_equations_range_0_304 : ∀ i, 0 ≤ i → i < 304 → CacheEquation i := + merge_ranges cache_equations_range_0_144 cache_equations_range_144_304 + +theorem cache_equations_range_304_336 : ∀ i, 304 ≤ i → i < 336 → CacheEquation i := + merge_ranges cache_equations_range_304 cache_equations_range_320 + +theorem cache_equations_range_352_384 : ∀ i, 352 ≤ i → i < 384 → CacheEquation i := + merge_ranges cache_equations_range_352 cache_equations_range_368 + +theorem cache_equations_range_336_384 : ∀ i, 336 ≤ i → i < 384 → CacheEquation i := + merge_ranges cache_equations_range_336 cache_equations_range_352_384 + +theorem cache_equations_range_304_384 : ∀ i, 304 ≤ i → i < 384 → CacheEquation i := + merge_ranges cache_equations_range_304_336 cache_equations_range_336_384 + +theorem cache_equations_range_384_416 : ∀ i, 384 ≤ i → i < 416 → CacheEquation i := + merge_ranges cache_equations_range_384 cache_equations_range_400 + +theorem cache_equations_range_432_464 : ∀ i, 432 ≤ i → i < 464 → CacheEquation i := + merge_ranges cache_equations_range_432 cache_equations_range_448 + +theorem cache_equations_range_416_464 : ∀ i, 416 ≤ i → i < 464 → CacheEquation i := + merge_ranges cache_equations_range_416 cache_equations_range_432_464 + +theorem cache_equations_range_384_464 : ∀ i, 384 ≤ i → i < 464 → CacheEquation i := + merge_ranges cache_equations_range_384_416 cache_equations_range_416_464 + +theorem cache_equations_range_304_464 : ∀ i, 304 ≤ i → i < 464 → CacheEquation i := + merge_ranges cache_equations_range_304_384 cache_equations_range_384_464 + +theorem cache_equations_range_464_496 : ∀ i, 464 ≤ i → i < 496 → CacheEquation i := + merge_ranges cache_equations_range_464 cache_equations_range_480 + +theorem cache_equations_range_512_544 : ∀ i, 512 ≤ i → i < 544 → CacheEquation i := + merge_ranges cache_equations_range_512 cache_equations_range_528 + +theorem cache_equations_range_496_544 : ∀ i, 496 ≤ i → i < 544 → CacheEquation i := + merge_ranges cache_equations_range_496 cache_equations_range_512_544 + +theorem cache_equations_range_464_544 : ∀ i, 464 ≤ i → i < 544 → CacheEquation i := + merge_ranges cache_equations_range_464_496 cache_equations_range_496_544 + +theorem cache_equations_range_544_576 : ∀ i, 544 ≤ i → i < 576 → CacheEquation i := + merge_ranges cache_equations_range_544 cache_equations_range_560 + +theorem cache_equations_range_592_616 : ∀ i, 592 ≤ i → i < 616 → CacheEquation i := + merge_ranges cache_equations_range_592 cache_equations_range_608 + +theorem cache_equations_range_576_616 : ∀ i, 576 ≤ i → i < 616 → CacheEquation i := + merge_ranges cache_equations_range_576 cache_equations_range_592_616 + +theorem cache_equations_range_544_616 : ∀ i, 544 ≤ i → i < 616 → CacheEquation i := + merge_ranges cache_equations_range_544_576 cache_equations_range_576_616 + +theorem cache_equations_range_464_616 : ∀ i, 464 ≤ i → i < 616 → CacheEquation i := + merge_ranges cache_equations_range_464_544 cache_equations_range_544_616 + +theorem cache_equations_range_304_616 : ∀ i, 304 ≤ i → i < 616 → CacheEquation i := + merge_ranges cache_equations_range_304_464 cache_equations_range_464_616 + +theorem cache_equations_range_0_616 : ∀ i, 0 ≤ i → i < 616 → CacheEquation i := + merge_ranges cache_equations_range_0_304 cache_equations_range_304_616 + +theorem cache_equations (i : ℕ) (hi : i < 616) : CacheEquation i := + cache_equations_range_0_616 i (Nat.zero_le _) hi + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Rows.lean b/lean/OAI/Combinatorics/SnakyCertificate/Rows.lean new file mode 100644 index 0000000000000000000000000000000000000000..44d9277e472152be780c5ec890700258f7a96ff5 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Rows.lean @@ -0,0 +1,50 @@ +import OAI.Combinatorics.SnakyCertificate.Table + +namespace OAI + +namespace SnakyCertificate + +structure RowData where + A : Finset Cell + H : Finset Cell + height : ℕ + deriving DecidableEq + +def emptyRow : RowData := ⟨∅, ∅, 0⟩ + +def baseRow (i : Fin 6) : RowData := ⟨baseRequired i, baseEnvelope i, 1⟩ + +def placeRow (t : Term) (d : RowData) : RowData := + ⟨d.A.image (placement t.rotation t.shift), + d.H.image (placement t.rotation t.shift), d.height⟩ + +def unionA (ds : List RowData) : Finset Cell := (ds.map RowData.A).foldr (· ∪ ·) ∅ + +def unionH (ds : List RowData) : Finset Cell := (ds.map RowData.H).foldr (· ∪ ·) ∅ + +def commonH (ds : List RowData) : Finset Cell := + match ds with + | [] => ∅ + | d :: rest => (rest.map RowData.H).foldr (· ∩ ·) d.H + +def forkRow (ds : List RowData) : RowData := + ⟨(unionA ds ∪ commonH ds).erase origin, + insert origin (unionH ds), 1 + (ds.map RowData.height).foldr max 0⟩ + +def rowAt (i : ℕ) : RowData := + if h : i < 6 then baseRow ⟨i, h⟩ else + forkRow ((entryAt i).terms.map fun t => + placeRow t (if _ : t.child < i then rowAt t.child else emptyRow)) +termination_by i + +def Output (i : ℕ) (p : Cell) (size height : ℕ) (omitted : Set Cell) : Prop := + (rowAt i).A = {p} ∧ (rowAt i).H.card = size ∧ (rowAt i).height = height ∧ + Disjoint (↑(rowAt i).H : Set Cell) omitted + +def AllRows : Prop := ∀ i, i < 616 → + (rowAt i).A ⊆ (rowAt i).H ∧ origin ∈ (rowAt i).H ∧ + origin ∉ (rowAt i).A ∧ (rowAt i).height ≤ 34 + +end SnakyCertificate + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Summaries.lean b/lean/OAI/Combinatorics/SnakyCertificate/Summaries.lean new file mode 100644 index 0000000000000000000000000000000000000000..65d25a0ee62351f501804f598dff5e473a7605ba --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Summaries.lean @@ -0,0 +1,57 @@ +import OAI.Combinatorics.SnakyCertificate.Cache + +namespace OAI + +namespace SnakyCertificate.Check + +theorem cache_summary_557 : + (denote cache_557).A = {(-1, 0)} ∧ + (denote cache_557).H.card = 118 ∧ + (denote cache_557).height = 19 := by + decide +kernel + +theorem cache_omits_557 : ∀ p ∈ cache_557.H, ¬(p.1 ≤ -3 ∧ p.2 ≤ -2) := by + decide +kernel + +theorem cache_summary_595 : + (denote cache_595).A = {(-1, 0)} ∧ + (denote cache_595).H.card = 222 ∧ + (denote cache_595).height = 27 := by + decide +kernel + +theorem cache_omits_595 : ∀ p ∈ cache_595.H, ¬(p.1 = -2 ∧ p.2 ≤ -2) := by + decide +kernel + +theorem cache_summary_603 : + (denote cache_603).A = {(-1, 0)} ∧ + (denote cache_603).H.card = 275 ∧ + (denote cache_603).height = 27 := by + decide +kernel + +theorem cache_omits_603 : ∀ p ∈ cache_603.H, ¬(p.1 ≤ -3 ∧ p.2 = 0) := by + decide +kernel + +theorem cache_summary_615 : + (denote cache_615).A = {(1, 0)} ∧ + (denote cache_615).H.card = 686 ∧ + (denote cache_615).height = 34 := by + decide +kernel + +theorem cache_omits_615 : ∀ p ∈ cache_615.H, ¬(p = (1, -1)) := by + decide +kernel + +theorem output_of_row_eq (i : ℕ) (d : ListRow) (p : Cell) (size height : ℕ) + (omitted : Set Cell) (he : rowAt i = denote d) + (summary : (denote d).A = {p} ∧ (denote d).H.card = size ∧ + (denote d).height = height) + (omits : ∀ q ∈ d.H, q ∉ omitted) : Output i p size height omitted := by + unfold Output + rw [he] + refine ⟨summary.1, summary.2.1, summary.2.2, ?_⟩ + apply Set.disjoint_left.mpr + intro q hq hq' + exact omits q (List.mem_toFinset.mp hq) hq' + +end SnakyCertificate.Check + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/Table.lean b/lean/OAI/Combinatorics/SnakyCertificate/Table.lean new file mode 100644 index 0000000000000000000000000000000000000000..1ea150649c159c7629a4b7710a9e7be0aaf23ec7 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/Table.lean @@ -0,0 +1,88 @@ +import OAI.Combinatorics.SnakyCertificate.Entries00 +import OAI.Combinatorics.SnakyCertificate.Entries01 +import OAI.Combinatorics.SnakyCertificate.Entries02 +import OAI.Combinatorics.SnakyCertificate.Entries03 +import OAI.Combinatorics.SnakyCertificate.Entries04 +import OAI.Combinatorics.SnakyCertificate.Entries05 +import OAI.Combinatorics.SnakyCertificate.Entries06 + +namespace OAI + +namespace SnakyCertificate + +def tableChunk_0 : Array Entry := #[entry_6, entry_7, entry_8, entry_9, entry_10, entry_11, entry_12, entry_13, entry_14, entry_15, entry_16, entry_17, entry_18, entry_19, entry_20, entry_21, entry_22, entry_23, entry_24, entry_25] + +def tableChunk_1 : Array Entry := #[entry_26, entry_27, entry_28, entry_29, entry_30, entry_31, entry_32, entry_33, entry_34, entry_35, entry_36, entry_37, entry_38, entry_39, entry_40, entry_41, entry_42, entry_43, entry_44, entry_45] + +def tableChunk_2 : Array Entry := #[entry_46, entry_47, entry_48, entry_49, entry_50, entry_51, entry_52, entry_53, entry_54, entry_55, entry_56, entry_57, entry_58, entry_59, entry_60, entry_61, entry_62, entry_63, entry_64, entry_65] + +def tableChunk_3 : Array Entry := #[entry_66, entry_67, entry_68, entry_69, entry_70, entry_71, entry_72, entry_73, entry_74, entry_75, entry_76, entry_77, entry_78, entry_79, entry_80, entry_81, entry_82, entry_83, entry_84, entry_85] + +def tableChunk_4 : Array Entry := #[entry_86, entry_87, entry_88, entry_89, entry_90, entry_91, entry_92, entry_93, entry_94, entry_95, entry_96, entry_97, entry_98, entry_99, entry_100, entry_101, entry_102, entry_103, entry_104, entry_105] + +def tableChunk_5 : Array Entry := #[entry_106, entry_107, entry_108, entry_109, entry_110, entry_111, entry_112, entry_113, entry_114, entry_115, entry_116, entry_117, entry_118, entry_119, entry_120, entry_121, entry_122, entry_123, entry_124, entry_125] + +def tableChunk_6 : Array Entry := #[entry_126, entry_127, entry_128, entry_129, entry_130, entry_131, entry_132, entry_133, entry_134, entry_135, entry_136, entry_137, entry_138, entry_139, entry_140, entry_141, entry_142, entry_143, entry_144, entry_145] + +def tableChunk_7 : Array Entry := #[entry_146, entry_147, entry_148, entry_149, entry_150, entry_151, entry_152, entry_153, entry_154, entry_155, entry_156, entry_157, entry_158, entry_159, entry_160, entry_161, entry_162, entry_163, entry_164, entry_165] + +def tableChunk_8 : Array Entry := #[entry_166, entry_167, entry_168, entry_169, entry_170, entry_171, entry_172, entry_173, entry_174, entry_175, entry_176, entry_177, entry_178, entry_179, entry_180, entry_181, entry_182, entry_183, entry_184, entry_185] + +def tableChunk_9 : Array Entry := #[entry_186, entry_187, entry_188, entry_189, entry_190, entry_191, entry_192, entry_193, entry_194, entry_195, entry_196, entry_197, entry_198, entry_199, entry_200, entry_201, entry_202, entry_203, entry_204, entry_205] + +def tableChunk_10 : Array Entry := #[entry_206, entry_207, entry_208, entry_209, entry_210, entry_211, entry_212, entry_213, entry_214, entry_215, entry_216, entry_217, entry_218, entry_219, entry_220, entry_221, entry_222, entry_223, entry_224, entry_225] + +def tableChunk_11 : Array Entry := #[entry_226, entry_227, entry_228, entry_229, entry_230, entry_231, entry_232, entry_233, entry_234, entry_235, entry_236, entry_237, entry_238, entry_239, entry_240, entry_241, entry_242, entry_243, entry_244, entry_245] + +def tableChunk_12 : Array Entry := #[entry_246, entry_247, entry_248, entry_249, entry_250, entry_251, entry_252, entry_253, entry_254, entry_255, entry_256, entry_257, entry_258, entry_259, entry_260, entry_261, entry_262, entry_263, entry_264, entry_265] + +def tableChunk_13 : Array Entry := #[entry_266, entry_267, entry_268, entry_269, entry_270, entry_271, entry_272, entry_273, entry_274, entry_275, entry_276, entry_277, entry_278, entry_279, entry_280, entry_281, entry_282, entry_283, entry_284, entry_285] + +def tableChunk_14 : Array Entry := #[entry_286, entry_287, entry_288, entry_289, entry_290, entry_291, entry_292, entry_293, entry_294, entry_295, entry_296, entry_297, entry_298, entry_299, entry_300, entry_301, entry_302, entry_303, entry_304, entry_305] + +def tableChunk_15 : Array Entry := #[entry_306, entry_307, entry_308, entry_309, entry_310, entry_311, entry_312, entry_313, entry_314, entry_315, entry_316, entry_317, entry_318, entry_319, entry_320, entry_321, entry_322, entry_323, entry_324, entry_325] + +def tableChunk_16 : Array Entry := #[entry_326, entry_327, entry_328, entry_329, entry_330, entry_331, entry_332, entry_333, entry_334, entry_335, entry_336, entry_337, entry_338, entry_339, entry_340, entry_341, entry_342, entry_343, entry_344, entry_345] + +def tableChunk_17 : Array Entry := #[entry_346, entry_347, entry_348, entry_349, entry_350, entry_351, entry_352, entry_353, entry_354, entry_355, entry_356, entry_357, entry_358, entry_359, entry_360, entry_361, entry_362, entry_363, entry_364, entry_365] + +def tableChunk_18 : Array Entry := #[entry_366, entry_367, entry_368, entry_369, entry_370, entry_371, entry_372, entry_373, entry_374, entry_375, entry_376, entry_377, entry_378, entry_379, entry_380, entry_381, entry_382, entry_383, entry_384, entry_385] + +def tableChunk_19 : Array Entry := #[entry_386, entry_387, entry_388, entry_389, entry_390, entry_391, entry_392, entry_393, entry_394, entry_395, entry_396, entry_397, entry_398, entry_399, entry_400, entry_401, entry_402, entry_403, entry_404, entry_405] + +def tableChunk_20 : Array Entry := #[entry_406, entry_407, entry_408, entry_409, entry_410, entry_411, entry_412, entry_413, entry_414, entry_415, entry_416, entry_417, entry_418, entry_419, entry_420, entry_421, entry_422, entry_423, entry_424, entry_425] + +def tableChunk_21 : Array Entry := #[entry_426, entry_427, entry_428, entry_429, entry_430, entry_431, entry_432, entry_433, entry_434, entry_435, entry_436, entry_437, entry_438, entry_439, entry_440, entry_441, entry_442, entry_443, entry_444, entry_445] + +def tableChunk_22 : Array Entry := #[entry_446, entry_447, entry_448, entry_449, entry_450, entry_451, entry_452, entry_453, entry_454, entry_455, entry_456, entry_457, entry_458, entry_459, entry_460, entry_461, entry_462, entry_463, entry_464, entry_465] + +def tableChunk_23 : Array Entry := #[entry_466, entry_467, entry_468, entry_469, entry_470, entry_471, entry_472, entry_473, entry_474, entry_475, entry_476, entry_477, entry_478, entry_479, entry_480, entry_481, entry_482, entry_483, entry_484, entry_485] + +def tableChunk_24 : Array Entry := #[entry_486, entry_487, entry_488, entry_489, entry_490, entry_491, entry_492, entry_493, entry_494, entry_495, entry_496, entry_497, entry_498, entry_499, entry_500, entry_501, entry_502, entry_503, entry_504, entry_505] + +def tableChunk_25 : Array Entry := #[entry_506, entry_507, entry_508, entry_509, entry_510, entry_511, entry_512, entry_513, entry_514, entry_515, entry_516, entry_517, entry_518, entry_519, entry_520, entry_521, entry_522, entry_523, entry_524, entry_525] + +def tableChunk_26 : Array Entry := #[entry_526, entry_527, entry_528, entry_529, entry_530, entry_531, entry_532, entry_533, entry_534, entry_535, entry_536, entry_537, entry_538, entry_539, entry_540, entry_541, entry_542, entry_543, entry_544, entry_545] + +def tableChunk_27 : Array Entry := #[entry_546, entry_547, entry_548, entry_549, entry_550, entry_551, entry_552, entry_553, entry_554, entry_555, entry_556, entry_557, entry_558, entry_559, entry_560, entry_561, entry_562, entry_563, entry_564, entry_565] + +def tableChunk_28 : Array Entry := #[entry_566, entry_567, entry_568, entry_569, entry_570, entry_571, entry_572, entry_573, entry_574, entry_575, entry_576, entry_577, entry_578, entry_579, entry_580, entry_581, entry_582, entry_583, entry_584, entry_585] + +def tableChunk_29 : Array Entry := #[entry_586, entry_587, entry_588, entry_589, entry_590, entry_591, entry_592, entry_593, entry_594, entry_595, entry_596, entry_597, entry_598, entry_599, entry_600, entry_601, entry_602, entry_603, entry_604, entry_605] + +def tableChunk_30 : Array Entry := #[entry_606, entry_607, entry_608, entry_609, entry_610, entry_611, entry_612, entry_613, entry_614, entry_615] + +def table : Array Entry := ((((tableChunk_0 ++ (tableChunk_1 ++ tableChunk_2)) ++ ((tableChunk_3 ++ tableChunk_4) ++ (tableChunk_5 ++ tableChunk_6))) ++ (((tableChunk_7 ++ tableChunk_8) ++ (tableChunk_9 ++ tableChunk_10)) ++ ((tableChunk_11 ++ tableChunk_12) ++ (tableChunk_13 ++ tableChunk_14)))) ++ ((((tableChunk_15 ++ tableChunk_16) ++ (tableChunk_17 ++ tableChunk_18)) ++ ((tableChunk_19 ++ tableChunk_20) ++ (tableChunk_21 ++ tableChunk_22))) ++ (((tableChunk_23 ++ tableChunk_24) ++ (tableChunk_25 ++ tableChunk_26)) ++ ((tableChunk_27 ++ tableChunk_28) ++ (tableChunk_29 ++ tableChunk_30))))) + +def entryAt (i : ℕ) : Entry := table[i - 6]?.getD emptyEntry + +def TableValid : Prop := + table.size = 610 ∧ ∀ k, k < table.size → + let e := table[k]?.getD emptyEntry + e.index = k + 6 ∧ e.terms ≠ [] ∧ ∀ t ∈ e.terms, t.child < e.index + +def placementCount : ℕ := (table.toList.map fun e => e.terms.length).sum + +end SnakyCertificate + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/TableList.lean b/lean/OAI/Combinatorics/SnakyCertificate/TableList.lean new file mode 100644 index 0000000000000000000000000000000000000000..bd6be1f45c1a482dea7fdc842abbb1dea8057351 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/TableList.lean @@ -0,0 +1,95 @@ +import OAI.Combinatorics.SnakyCertificate.Table + +namespace OAI + +namespace SnakyCertificate + +def tableListChunk_0 : List Entry := [entry_6, entry_7, entry_8, entry_9, entry_10, entry_11, entry_12, entry_13, entry_14, entry_15, entry_16, entry_17, entry_18, entry_19, entry_20, entry_21, entry_22, entry_23, entry_24, entry_25] + +def tableListChunk_1 : List Entry := [entry_26, entry_27, entry_28, entry_29, entry_30, entry_31, entry_32, entry_33, entry_34, entry_35, entry_36, entry_37, entry_38, entry_39, entry_40, entry_41, entry_42, entry_43, entry_44, entry_45] + +def tableListChunk_2 : List Entry := [entry_46, entry_47, entry_48, entry_49, entry_50, entry_51, entry_52, entry_53, entry_54, entry_55, entry_56, entry_57, entry_58, entry_59, entry_60, entry_61, entry_62, entry_63, entry_64, entry_65] + +def tableListChunk_3 : List Entry := [entry_66, entry_67, entry_68, entry_69, entry_70, entry_71, entry_72, entry_73, entry_74, entry_75, entry_76, entry_77, entry_78, entry_79, entry_80, entry_81, entry_82, entry_83, entry_84, entry_85] + +def tableListChunk_4 : List Entry := [entry_86, entry_87, entry_88, entry_89, entry_90, entry_91, entry_92, entry_93, entry_94, entry_95, entry_96, entry_97, entry_98, entry_99, entry_100, entry_101, entry_102, entry_103, entry_104, entry_105] + +def tableListChunk_5 : List Entry := [entry_106, entry_107, entry_108, entry_109, entry_110, entry_111, entry_112, entry_113, entry_114, entry_115, entry_116, entry_117, entry_118, entry_119, entry_120, entry_121, entry_122, entry_123, entry_124, entry_125] + +def tableListChunk_6 : List Entry := [entry_126, entry_127, entry_128, entry_129, entry_130, entry_131, entry_132, entry_133, entry_134, entry_135, entry_136, entry_137, entry_138, entry_139, entry_140, entry_141, entry_142, entry_143, entry_144, entry_145] + +def tableListChunk_7 : List Entry := [entry_146, entry_147, entry_148, entry_149, entry_150, entry_151, entry_152, entry_153, entry_154, entry_155, entry_156, entry_157, entry_158, entry_159, entry_160, entry_161, entry_162, entry_163, entry_164, entry_165] + +def tableListChunk_8 : List Entry := [entry_166, entry_167, entry_168, entry_169, entry_170, entry_171, entry_172, entry_173, entry_174, entry_175, entry_176, entry_177, entry_178, entry_179, entry_180, entry_181, entry_182, entry_183, entry_184, entry_185] + +def tableListChunk_9 : List Entry := [entry_186, entry_187, entry_188, entry_189, entry_190, entry_191, entry_192, entry_193, entry_194, entry_195, entry_196, entry_197, entry_198, entry_199, entry_200, entry_201, entry_202, entry_203, entry_204, entry_205] + +def tableListChunk_10 : List Entry := [entry_206, entry_207, entry_208, entry_209, entry_210, entry_211, entry_212, entry_213, entry_214, entry_215, entry_216, entry_217, entry_218, entry_219, entry_220, entry_221, entry_222, entry_223, entry_224, entry_225] + +def tableListChunk_11 : List Entry := [entry_226, entry_227, entry_228, entry_229, entry_230, entry_231, entry_232, entry_233, entry_234, entry_235, entry_236, entry_237, entry_238, entry_239, entry_240, entry_241, entry_242, entry_243, entry_244, entry_245] + +def tableListChunk_12 : List Entry := [entry_246, entry_247, entry_248, entry_249, entry_250, entry_251, entry_252, entry_253, entry_254, entry_255, entry_256, entry_257, entry_258, entry_259, entry_260, entry_261, entry_262, entry_263, entry_264, entry_265] + +def tableListChunk_13 : List Entry := [entry_266, entry_267, entry_268, entry_269, entry_270, entry_271, entry_272, entry_273, entry_274, entry_275, entry_276, entry_277, entry_278, entry_279, entry_280, entry_281, entry_282, entry_283, entry_284, entry_285] + +def tableListChunk_14 : List Entry := [entry_286, entry_287, entry_288, entry_289, entry_290, entry_291, entry_292, entry_293, entry_294, entry_295, entry_296, entry_297, entry_298, entry_299, entry_300, entry_301, entry_302, entry_303, entry_304, entry_305] + +def tableListChunk_15 : List Entry := [entry_306, entry_307, entry_308, entry_309, entry_310, entry_311, entry_312, entry_313, entry_314, entry_315, entry_316, entry_317, entry_318, entry_319, entry_320, entry_321, entry_322, entry_323, entry_324, entry_325] + +def tableListChunk_16 : List Entry := [entry_326, entry_327, entry_328, entry_329, entry_330, entry_331, entry_332, entry_333, entry_334, entry_335, entry_336, entry_337, entry_338, entry_339, entry_340, entry_341, entry_342, entry_343, entry_344, entry_345] + +def tableListChunk_17 : List Entry := [entry_346, entry_347, entry_348, entry_349, entry_350, entry_351, entry_352, entry_353, entry_354, entry_355, entry_356, entry_357, entry_358, entry_359, entry_360, entry_361, entry_362, entry_363, entry_364, entry_365] + +def tableListChunk_18 : List Entry := [entry_366, entry_367, entry_368, entry_369, entry_370, entry_371, entry_372, entry_373, entry_374, entry_375, entry_376, entry_377, entry_378, entry_379, entry_380, entry_381, entry_382, entry_383, entry_384, entry_385] + +def tableListChunk_19 : List Entry := [entry_386, entry_387, entry_388, entry_389, entry_390, entry_391, entry_392, entry_393, entry_394, entry_395, entry_396, entry_397, entry_398, entry_399, entry_400, entry_401, entry_402, entry_403, entry_404, entry_405] + +def tableListChunk_20 : List Entry := [entry_406, entry_407, entry_408, entry_409, entry_410, entry_411, entry_412, entry_413, entry_414, entry_415, entry_416, entry_417, entry_418, entry_419, entry_420, entry_421, entry_422, entry_423, entry_424, entry_425] + +def tableListChunk_21 : List Entry := [entry_426, entry_427, entry_428, entry_429, entry_430, entry_431, entry_432, entry_433, entry_434, entry_435, entry_436, entry_437, entry_438, entry_439, entry_440, entry_441, entry_442, entry_443, entry_444, entry_445] + +def tableListChunk_22 : List Entry := [entry_446, entry_447, entry_448, entry_449, entry_450, entry_451, entry_452, entry_453, entry_454, entry_455, entry_456, entry_457, entry_458, entry_459, entry_460, entry_461, entry_462, entry_463, entry_464, entry_465] + +def tableListChunk_23 : List Entry := [entry_466, entry_467, entry_468, entry_469, entry_470, entry_471, entry_472, entry_473, entry_474, entry_475, entry_476, entry_477, entry_478, entry_479, entry_480, entry_481, entry_482, entry_483, entry_484, entry_485] + +def tableListChunk_24 : List Entry := [entry_486, entry_487, entry_488, entry_489, entry_490, entry_491, entry_492, entry_493, entry_494, entry_495, entry_496, entry_497, entry_498, entry_499, entry_500, entry_501, entry_502, entry_503, entry_504, entry_505] + +def tableListChunk_25 : List Entry := [entry_506, entry_507, entry_508, entry_509, entry_510, entry_511, entry_512, entry_513, entry_514, entry_515, entry_516, entry_517, entry_518, entry_519, entry_520, entry_521, entry_522, entry_523, entry_524, entry_525] + +def tableListChunk_26 : List Entry := [entry_526, entry_527, entry_528, entry_529, entry_530, entry_531, entry_532, entry_533, entry_534, entry_535, entry_536, entry_537, entry_538, entry_539, entry_540, entry_541, entry_542, entry_543, entry_544, entry_545] + +def tableListChunk_27 : List Entry := [entry_546, entry_547, entry_548, entry_549, entry_550, entry_551, entry_552, entry_553, entry_554, entry_555, entry_556, entry_557, entry_558, entry_559, entry_560, entry_561, entry_562, entry_563, entry_564, entry_565] + +def tableListChunk_28 : List Entry := [entry_566, entry_567, entry_568, entry_569, entry_570, entry_571, entry_572, entry_573, entry_574, entry_575, entry_576, entry_577, entry_578, entry_579, entry_580, entry_581, entry_582, entry_583, entry_584, entry_585] + +def tableListChunk_29 : List Entry := [entry_586, entry_587, entry_588, entry_589, entry_590, entry_591, entry_592, entry_593, entry_594, entry_595, entry_596, entry_597, entry_598, entry_599, entry_600, entry_601, entry_602, entry_603, entry_604, entry_605] + +def tableListChunk_30 : List Entry := [entry_606, entry_607, entry_608, entry_609, entry_610, entry_611, entry_612, entry_613, entry_614, entry_615] + +def tableList : List Entry := ((((tableListChunk_0 ++ (tableListChunk_1 ++ tableListChunk_2)) ++ ((tableListChunk_3 ++ tableListChunk_4) ++ (tableListChunk_5 ++ tableListChunk_6))) ++ (((tableListChunk_7 ++ tableListChunk_8) ++ (tableListChunk_9 ++ tableListChunk_10)) ++ ((tableListChunk_11 ++ tableListChunk_12) ++ (tableListChunk_13 ++ tableListChunk_14)))) ++ ((((tableListChunk_15 ++ tableListChunk_16) ++ (tableListChunk_17 ++ tableListChunk_18)) ++ ((tableListChunk_19 ++ tableListChunk_20) ++ (tableListChunk_21 ++ tableListChunk_22))) ++ (((tableListChunk_23 ++ tableListChunk_24) ++ (tableListChunk_25 ++ tableListChunk_26)) ++ ((tableListChunk_27 ++ tableListChunk_28) ++ (tableListChunk_29 ++ tableListChunk_30))))) + +theorem table_toList : table.toList = tableList := by + simp only [table, Array.toList_append] + rfl + +theorem table_getElem?_eq (k : ℕ) : table[k]? = tableList[k]? := by + rw [← Array.getElem?_toList, table_toList] + +theorem merge_ranges {P : ℕ → Prop} {a b c : ℕ} + (left : ∀ i, a ≤ i → i < b → P i) + (right : ∀ i, b ≤ i → i < c → P i) : + ∀ i, a ≤ i → i < c → P i := by + intro i hlo hhi + by_cases h : i < b + · exact left i hlo h + · exact right i (by omega) hhi + +theorem fin_block_range {P : ℕ → Prop} {a n : ℕ} + (h : ∀ j : Fin n, P (a + j.val)) : ∀ i, a ≤ i → i < a + n → P i := by + intro i hlo hhi + have ht := h ⟨i - a, by omega⟩ + simpa only [Nat.add_sub_of_le hlo] using ht + +end SnakyCertificate + +end OAI diff --git a/lean/OAI/Combinatorics/SnakyCertificate/TableValidity.lean b/lean/OAI/Combinatorics/SnakyCertificate/TableValidity.lean new file mode 100644 index 0000000000000000000000000000000000000000..1eb1ae7fe114b771bd45d94426f36e4337bc8236 --- /dev/null +++ b/lean/OAI/Combinatorics/SnakyCertificate/TableValidity.lean @@ -0,0 +1,715 @@ +import OAI.Combinatorics.SnakyCertificate.TableList + +namespace OAI + +namespace SnakyCertificate + +theorem table_size : table.size = 610 := by + simp only [table, Array.size_append] + decide +kernel + +abbrev TableEntryOk (k : ℕ) : Prop := + let e := table[k]?.getD emptyEntry + e.index = k + 6 ∧ e.terms ≠ [] ∧ ∀ t ∈ e.terms, t.child < e.index + +theorem table_entries_block_0 : ∀ j : Fin 10, TableEntryOk (0 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_0 : ∀ k, 0 ≤ k → k < 10 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 0) (n := 10) table_entries_block_0 + +theorem table_entries_block_10 : ∀ j : Fin 10, TableEntryOk (10 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_10 : ∀ k, 10 ≤ k → k < 20 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 10) (n := 10) table_entries_block_10 + +theorem table_entries_block_20 : ∀ j : Fin 10, TableEntryOk (20 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_20 : ∀ k, 20 ≤ k → k < 30 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 20) (n := 10) table_entries_block_20 + +theorem table_entries_block_30 : ∀ j : Fin 10, TableEntryOk (30 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_30 : ∀ k, 30 ≤ k → k < 40 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 30) (n := 10) table_entries_block_30 + +theorem table_entries_block_40 : ∀ j : Fin 10, TableEntryOk (40 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_40 : ∀ k, 40 ≤ k → k < 50 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 40) (n := 10) table_entries_block_40 + +theorem table_entries_block_50 : ∀ j : Fin 10, TableEntryOk (50 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_50 : ∀ k, 50 ≤ k → k < 60 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 50) (n := 10) table_entries_block_50 + +theorem table_entries_block_60 : ∀ j : Fin 10, TableEntryOk (60 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_60 : ∀ k, 60 ≤ k → k < 70 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 60) (n := 10) table_entries_block_60 + +theorem table_entries_block_70 : ∀ j : Fin 10, TableEntryOk (70 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_70 : ∀ k, 70 ≤ k → k < 80 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 70) (n := 10) table_entries_block_70 + +theorem table_entries_block_80 : ∀ j : Fin 10, TableEntryOk (80 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_80 : ∀ k, 80 ≤ k → k < 90 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 80) (n := 10) table_entries_block_80 + +theorem table_entries_block_90 : ∀ j : Fin 10, TableEntryOk (90 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_90 : ∀ k, 90 ≤ k → k < 100 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 90) (n := 10) table_entries_block_90 + +theorem table_entries_block_100 : ∀ j : Fin 10, TableEntryOk (100 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_100 : ∀ k, 100 ≤ k → k < 110 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 100) (n := 10) table_entries_block_100 + +theorem table_entries_block_110 : ∀ j : Fin 10, TableEntryOk (110 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_110 : ∀ k, 110 ≤ k → k < 120 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 110) (n := 10) table_entries_block_110 + +theorem table_entries_block_120 : ∀ j : Fin 10, TableEntryOk (120 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_120 : ∀ k, 120 ≤ k → k < 130 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 120) (n := 10) table_entries_block_120 + +theorem table_entries_block_130 : ∀ j : Fin 10, TableEntryOk (130 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_130 : ∀ k, 130 ≤ k → k < 140 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 130) (n := 10) table_entries_block_130 + +theorem table_entries_block_140 : ∀ j : Fin 10, TableEntryOk (140 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_140 : ∀ k, 140 ≤ k → k < 150 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 140) (n := 10) table_entries_block_140 + +theorem table_entries_block_150 : ∀ j : Fin 10, TableEntryOk (150 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_150 : ∀ k, 150 ≤ k → k < 160 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 150) (n := 10) table_entries_block_150 + +theorem table_entries_block_160 : ∀ j : Fin 10, TableEntryOk (160 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_160 : ∀ k, 160 ≤ k → k < 170 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 160) (n := 10) table_entries_block_160 + +theorem table_entries_block_170 : ∀ j : Fin 10, TableEntryOk (170 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_170 : ∀ k, 170 ≤ k → k < 180 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 170) (n := 10) table_entries_block_170 + +theorem table_entries_block_180 : ∀ j : Fin 10, TableEntryOk (180 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_180 : ∀ k, 180 ≤ k → k < 190 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 180) (n := 10) table_entries_block_180 + +theorem table_entries_block_190 : ∀ j : Fin 10, TableEntryOk (190 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_190 : ∀ k, 190 ≤ k → k < 200 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 190) (n := 10) table_entries_block_190 + +theorem table_entries_block_200 : ∀ j : Fin 10, TableEntryOk (200 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_200 : ∀ k, 200 ≤ k → k < 210 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 200) (n := 10) table_entries_block_200 + +theorem table_entries_block_210 : ∀ j : Fin 10, TableEntryOk (210 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_210 : ∀ k, 210 ≤ k → k < 220 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 210) (n := 10) table_entries_block_210 + +theorem table_entries_block_220 : ∀ j : Fin 10, TableEntryOk (220 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_220 : ∀ k, 220 ≤ k → k < 230 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 220) (n := 10) table_entries_block_220 + +theorem table_entries_block_230 : ∀ j : Fin 10, TableEntryOk (230 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_230 : ∀ k, 230 ≤ k → k < 240 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 230) (n := 10) table_entries_block_230 + +theorem table_entries_block_240 : ∀ j : Fin 10, TableEntryOk (240 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_240 : ∀ k, 240 ≤ k → k < 250 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 240) (n := 10) table_entries_block_240 + +theorem table_entries_block_250 : ∀ j : Fin 10, TableEntryOk (250 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_250 : ∀ k, 250 ≤ k → k < 260 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 250) (n := 10) table_entries_block_250 + +theorem table_entries_block_260 : ∀ j : Fin 10, TableEntryOk (260 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_260 : ∀ k, 260 ≤ k → k < 270 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 260) (n := 10) table_entries_block_260 + +theorem table_entries_block_270 : ∀ j : Fin 10, TableEntryOk (270 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_270 : ∀ k, 270 ≤ k → k < 280 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 270) (n := 10) table_entries_block_270 + +theorem table_entries_block_280 : ∀ j : Fin 10, TableEntryOk (280 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_280 : ∀ k, 280 ≤ k → k < 290 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 280) (n := 10) table_entries_block_280 + +theorem table_entries_block_290 : ∀ j : Fin 10, TableEntryOk (290 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_290 : ∀ k, 290 ≤ k → k < 300 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 290) (n := 10) table_entries_block_290 + +theorem table_entries_block_300 : ∀ j : Fin 10, TableEntryOk (300 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_300 : ∀ k, 300 ≤ k → k < 310 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 300) (n := 10) table_entries_block_300 + +theorem table_entries_block_310 : ∀ j : Fin 10, TableEntryOk (310 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_310 : ∀ k, 310 ≤ k → k < 320 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 310) (n := 10) table_entries_block_310 + +theorem table_entries_block_320 : ∀ j : Fin 10, TableEntryOk (320 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_320 : ∀ k, 320 ≤ k → k < 330 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 320) (n := 10) table_entries_block_320 + +theorem table_entries_block_330 : ∀ j : Fin 10, TableEntryOk (330 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_330 : ∀ k, 330 ≤ k → k < 340 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 330) (n := 10) table_entries_block_330 + +theorem table_entries_block_340 : ∀ j : Fin 10, TableEntryOk (340 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_340 : ∀ k, 340 ≤ k → k < 350 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 340) (n := 10) table_entries_block_340 + +theorem table_entries_block_350 : ∀ j : Fin 10, TableEntryOk (350 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_350 : ∀ k, 350 ≤ k → k < 360 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 350) (n := 10) table_entries_block_350 + +theorem table_entries_block_360 : ∀ j : Fin 10, TableEntryOk (360 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_360 : ∀ k, 360 ≤ k → k < 370 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 360) (n := 10) table_entries_block_360 + +theorem table_entries_block_370 : ∀ j : Fin 10, TableEntryOk (370 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_370 : ∀ k, 370 ≤ k → k < 380 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 370) (n := 10) table_entries_block_370 + +theorem table_entries_block_380 : ∀ j : Fin 10, TableEntryOk (380 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_380 : ∀ k, 380 ≤ k → k < 390 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 380) (n := 10) table_entries_block_380 + +theorem table_entries_block_390 : ∀ j : Fin 10, TableEntryOk (390 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_390 : ∀ k, 390 ≤ k → k < 400 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 390) (n := 10) table_entries_block_390 + +theorem table_entries_block_400 : ∀ j : Fin 10, TableEntryOk (400 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_400 : ∀ k, 400 ≤ k → k < 410 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 400) (n := 10) table_entries_block_400 + +theorem table_entries_block_410 : ∀ j : Fin 10, TableEntryOk (410 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_410 : ∀ k, 410 ≤ k → k < 420 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 410) (n := 10) table_entries_block_410 + +theorem table_entries_block_420 : ∀ j : Fin 10, TableEntryOk (420 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_420 : ∀ k, 420 ≤ k → k < 430 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 420) (n := 10) table_entries_block_420 + +theorem table_entries_block_430 : ∀ j : Fin 10, TableEntryOk (430 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_430 : ∀ k, 430 ≤ k → k < 440 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 430) (n := 10) table_entries_block_430 + +theorem table_entries_block_440 : ∀ j : Fin 10, TableEntryOk (440 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_440 : ∀ k, 440 ≤ k → k < 450 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 440) (n := 10) table_entries_block_440 + +theorem table_entries_block_450 : ∀ j : Fin 10, TableEntryOk (450 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_450 : ∀ k, 450 ≤ k → k < 460 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 450) (n := 10) table_entries_block_450 + +theorem table_entries_block_460 : ∀ j : Fin 10, TableEntryOk (460 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_460 : ∀ k, 460 ≤ k → k < 470 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 460) (n := 10) table_entries_block_460 + +theorem table_entries_block_470 : ∀ j : Fin 10, TableEntryOk (470 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_470 : ∀ k, 470 ≤ k → k < 480 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 470) (n := 10) table_entries_block_470 + +theorem table_entries_block_480 : ∀ j : Fin 10, TableEntryOk (480 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_480 : ∀ k, 480 ≤ k → k < 490 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 480) (n := 10) table_entries_block_480 + +theorem table_entries_block_490 : ∀ j : Fin 10, TableEntryOk (490 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_490 : ∀ k, 490 ≤ k → k < 500 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 490) (n := 10) table_entries_block_490 + +theorem table_entries_block_500 : ∀ j : Fin 10, TableEntryOk (500 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_500 : ∀ k, 500 ≤ k → k < 510 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 500) (n := 10) table_entries_block_500 + +theorem table_entries_block_510 : ∀ j : Fin 10, TableEntryOk (510 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_510 : ∀ k, 510 ≤ k → k < 520 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 510) (n := 10) table_entries_block_510 + +theorem table_entries_block_520 : ∀ j : Fin 10, TableEntryOk (520 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_520 : ∀ k, 520 ≤ k → k < 530 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 520) (n := 10) table_entries_block_520 + +theorem table_entries_block_530 : ∀ j : Fin 10, TableEntryOk (530 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_530 : ∀ k, 530 ≤ k → k < 540 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 530) (n := 10) table_entries_block_530 + +theorem table_entries_block_540 : ∀ j : Fin 10, TableEntryOk (540 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_540 : ∀ k, 540 ≤ k → k < 550 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 540) (n := 10) table_entries_block_540 + +theorem table_entries_block_550 : ∀ j : Fin 10, TableEntryOk (550 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_550 : ∀ k, 550 ≤ k → k < 560 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 550) (n := 10) table_entries_block_550 + +theorem table_entries_block_560 : ∀ j : Fin 10, TableEntryOk (560 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_560 : ∀ k, 560 ≤ k → k < 570 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 560) (n := 10) table_entries_block_560 + +theorem table_entries_block_570 : ∀ j : Fin 10, TableEntryOk (570 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_570 : ∀ k, 570 ≤ k → k < 580 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 570) (n := 10) table_entries_block_570 + +theorem table_entries_block_580 : ∀ j : Fin 10, TableEntryOk (580 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_580 : ∀ k, 580 ≤ k → k < 590 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 580) (n := 10) table_entries_block_580 + +theorem table_entries_block_590 : ∀ j : Fin 10, TableEntryOk (590 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_590 : ∀ k, 590 ≤ k → k < 600 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 590) (n := 10) table_entries_block_590 + +theorem table_entries_block_600 : ∀ j : Fin 10, TableEntryOk (600 + j.val) := by + unfold TableEntryOk + simp only [table_getElem?_eq] + decide +kernel + +theorem table_entries_range_600 : ∀ k, 600 ≤ k → k < 610 → TableEntryOk k := + fin_block_range (P := TableEntryOk) (a := 600) (n := 10) table_entries_block_600 + +theorem table_entries_range_10_30 : ∀ i, 10 ≤ i → i < 30 → TableEntryOk i := + merge_ranges table_entries_range_10 table_entries_range_20 + +theorem table_entries_range_0_30 : ∀ i, 0 ≤ i → i < 30 → TableEntryOk i := + merge_ranges table_entries_range_0 table_entries_range_10_30 + +theorem table_entries_range_30_50 : ∀ i, 30 ≤ i → i < 50 → TableEntryOk i := + merge_ranges table_entries_range_30 table_entries_range_40 + +theorem table_entries_range_50_70 : ∀ i, 50 ≤ i → i < 70 → TableEntryOk i := + merge_ranges table_entries_range_50 table_entries_range_60 + +theorem table_entries_range_30_70 : ∀ i, 30 ≤ i → i < 70 → TableEntryOk i := + merge_ranges table_entries_range_30_50 table_entries_range_50_70 + +theorem table_entries_range_0_70 : ∀ i, 0 ≤ i → i < 70 → TableEntryOk i := + merge_ranges table_entries_range_0_30 table_entries_range_30_70 + +theorem table_entries_range_70_90 : ∀ i, 70 ≤ i → i < 90 → TableEntryOk i := + merge_ranges table_entries_range_70 table_entries_range_80 + +theorem table_entries_range_90_110 : ∀ i, 90 ≤ i → i < 110 → TableEntryOk i := + merge_ranges table_entries_range_90 table_entries_range_100 + +theorem table_entries_range_70_110 : ∀ i, 70 ≤ i → i < 110 → TableEntryOk i := + merge_ranges table_entries_range_70_90 table_entries_range_90_110 + +theorem table_entries_range_110_130 : ∀ i, 110 ≤ i → i < 130 → TableEntryOk i := + merge_ranges table_entries_range_110 table_entries_range_120 + +theorem table_entries_range_130_150 : ∀ i, 130 ≤ i → i < 150 → TableEntryOk i := + merge_ranges table_entries_range_130 table_entries_range_140 + +theorem table_entries_range_110_150 : ∀ i, 110 ≤ i → i < 150 → TableEntryOk i := + merge_ranges table_entries_range_110_130 table_entries_range_130_150 + +theorem table_entries_range_70_150 : ∀ i, 70 ≤ i → i < 150 → TableEntryOk i := + merge_ranges table_entries_range_70_110 table_entries_range_110_150 + +theorem table_entries_range_0_150 : ∀ i, 0 ≤ i → i < 150 → TableEntryOk i := + merge_ranges table_entries_range_0_70 table_entries_range_70_150 + +theorem table_entries_range_160_180 : ∀ i, 160 ≤ i → i < 180 → TableEntryOk i := + merge_ranges table_entries_range_160 table_entries_range_170 + +theorem table_entries_range_150_180 : ∀ i, 150 ≤ i → i < 180 → TableEntryOk i := + merge_ranges table_entries_range_150 table_entries_range_160_180 + +theorem table_entries_range_180_200 : ∀ i, 180 ≤ i → i < 200 → TableEntryOk i := + merge_ranges table_entries_range_180 table_entries_range_190 + +theorem table_entries_range_200_220 : ∀ i, 200 ≤ i → i < 220 → TableEntryOk i := + merge_ranges table_entries_range_200 table_entries_range_210 + +theorem table_entries_range_180_220 : ∀ i, 180 ≤ i → i < 220 → TableEntryOk i := + merge_ranges table_entries_range_180_200 table_entries_range_200_220 + +theorem table_entries_range_150_220 : ∀ i, 150 ≤ i → i < 220 → TableEntryOk i := + merge_ranges table_entries_range_150_180 table_entries_range_180_220 + +theorem table_entries_range_220_240 : ∀ i, 220 ≤ i → i < 240 → TableEntryOk i := + merge_ranges table_entries_range_220 table_entries_range_230 + +theorem table_entries_range_240_260 : ∀ i, 240 ≤ i → i < 260 → TableEntryOk i := + merge_ranges table_entries_range_240 table_entries_range_250 + +theorem table_entries_range_220_260 : ∀ i, 220 ≤ i → i < 260 → TableEntryOk i := + merge_ranges table_entries_range_220_240 table_entries_range_240_260 + +theorem table_entries_range_260_280 : ∀ i, 260 ≤ i → i < 280 → TableEntryOk i := + merge_ranges table_entries_range_260 table_entries_range_270 + +theorem table_entries_range_280_300 : ∀ i, 280 ≤ i → i < 300 → TableEntryOk i := + merge_ranges table_entries_range_280 table_entries_range_290 + +theorem table_entries_range_260_300 : ∀ i, 260 ≤ i → i < 300 → TableEntryOk i := + merge_ranges table_entries_range_260_280 table_entries_range_280_300 + +theorem table_entries_range_220_300 : ∀ i, 220 ≤ i → i < 300 → TableEntryOk i := + merge_ranges table_entries_range_220_260 table_entries_range_260_300 + +theorem table_entries_range_150_300 : ∀ i, 150 ≤ i → i < 300 → TableEntryOk i := + merge_ranges table_entries_range_150_220 table_entries_range_220_300 + +theorem table_entries_range_0_300 : ∀ i, 0 ≤ i → i < 300 → TableEntryOk i := + merge_ranges table_entries_range_0_150 table_entries_range_150_300 + +theorem table_entries_range_310_330 : ∀ i, 310 ≤ i → i < 330 → TableEntryOk i := + merge_ranges table_entries_range_310 table_entries_range_320 + +theorem table_entries_range_300_330 : ∀ i, 300 ≤ i → i < 330 → TableEntryOk i := + merge_ranges table_entries_range_300 table_entries_range_310_330 + +theorem table_entries_range_330_350 : ∀ i, 330 ≤ i → i < 350 → TableEntryOk i := + merge_ranges table_entries_range_330 table_entries_range_340 + +theorem table_entries_range_350_370 : ∀ i, 350 ≤ i → i < 370 → TableEntryOk i := + merge_ranges table_entries_range_350 table_entries_range_360 + +theorem table_entries_range_330_370 : ∀ i, 330 ≤ i → i < 370 → TableEntryOk i := + merge_ranges table_entries_range_330_350 table_entries_range_350_370 + +theorem table_entries_range_300_370 : ∀ i, 300 ≤ i → i < 370 → TableEntryOk i := + merge_ranges table_entries_range_300_330 table_entries_range_330_370 + +theorem table_entries_range_370_390 : ∀ i, 370 ≤ i → i < 390 → TableEntryOk i := + merge_ranges table_entries_range_370 table_entries_range_380 + +theorem table_entries_range_390_410 : ∀ i, 390 ≤ i → i < 410 → TableEntryOk i := + merge_ranges table_entries_range_390 table_entries_range_400 + +theorem table_entries_range_370_410 : ∀ i, 370 ≤ i → i < 410 → TableEntryOk i := + merge_ranges table_entries_range_370_390 table_entries_range_390_410 + +theorem table_entries_range_410_430 : ∀ i, 410 ≤ i → i < 430 → TableEntryOk i := + merge_ranges table_entries_range_410 table_entries_range_420 + +theorem table_entries_range_430_450 : ∀ i, 430 ≤ i → i < 450 → TableEntryOk i := + merge_ranges table_entries_range_430 table_entries_range_440 + +theorem table_entries_range_410_450 : ∀ i, 410 ≤ i → i < 450 → TableEntryOk i := + merge_ranges table_entries_range_410_430 table_entries_range_430_450 + +theorem table_entries_range_370_450 : ∀ i, 370 ≤ i → i < 450 → TableEntryOk i := + merge_ranges table_entries_range_370_410 table_entries_range_410_450 + +theorem table_entries_range_300_450 : ∀ i, 300 ≤ i → i < 450 → TableEntryOk i := + merge_ranges table_entries_range_300_370 table_entries_range_370_450 + +theorem table_entries_range_450_470 : ∀ i, 450 ≤ i → i < 470 → TableEntryOk i := + merge_ranges table_entries_range_450 table_entries_range_460 + +theorem table_entries_range_470_490 : ∀ i, 470 ≤ i → i < 490 → TableEntryOk i := + merge_ranges table_entries_range_470 table_entries_range_480 + +theorem table_entries_range_450_490 : ∀ i, 450 ≤ i → i < 490 → TableEntryOk i := + merge_ranges table_entries_range_450_470 table_entries_range_470_490 + +theorem table_entries_range_490_510 : ∀ i, 490 ≤ i → i < 510 → TableEntryOk i := + merge_ranges table_entries_range_490 table_entries_range_500 + +theorem table_entries_range_510_530 : ∀ i, 510 ≤ i → i < 530 → TableEntryOk i := + merge_ranges table_entries_range_510 table_entries_range_520 + +theorem table_entries_range_490_530 : ∀ i, 490 ≤ i → i < 530 → TableEntryOk i := + merge_ranges table_entries_range_490_510 table_entries_range_510_530 + +theorem table_entries_range_450_530 : ∀ i, 450 ≤ i → i < 530 → TableEntryOk i := + merge_ranges table_entries_range_450_490 table_entries_range_490_530 + +theorem table_entries_range_530_550 : ∀ i, 530 ≤ i → i < 550 → TableEntryOk i := + merge_ranges table_entries_range_530 table_entries_range_540 + +theorem table_entries_range_550_570 : ∀ i, 550 ≤ i → i < 570 → TableEntryOk i := + merge_ranges table_entries_range_550 table_entries_range_560 + +theorem table_entries_range_530_570 : ∀ i, 530 ≤ i → i < 570 → TableEntryOk i := + merge_ranges table_entries_range_530_550 table_entries_range_550_570 + +theorem table_entries_range_570_590 : ∀ i, 570 ≤ i → i < 590 → TableEntryOk i := + merge_ranges table_entries_range_570 table_entries_range_580 + +theorem table_entries_range_590_610 : ∀ i, 590 ≤ i → i < 610 → TableEntryOk i := + merge_ranges table_entries_range_590 table_entries_range_600 + +theorem table_entries_range_570_610 : ∀ i, 570 ≤ i → i < 610 → TableEntryOk i := + merge_ranges table_entries_range_570_590 table_entries_range_590_610 + +theorem table_entries_range_530_610 : ∀ i, 530 ≤ i → i < 610 → TableEntryOk i := + merge_ranges table_entries_range_530_570 table_entries_range_570_610 + +theorem table_entries_range_450_610 : ∀ i, 450 ≤ i → i < 610 → TableEntryOk i := + merge_ranges table_entries_range_450_530 table_entries_range_530_610 + +theorem table_entries_range_300_610 : ∀ i, 300 ≤ i → i < 610 → TableEntryOk i := + merge_ranges table_entries_range_300_450 table_entries_range_450_610 + +theorem table_entries_range_0_610 : ∀ i, 0 ≤ i → i < 610 → TableEntryOk i := + merge_ranges table_entries_range_0_300 table_entries_range_300_610 + +theorem table_entries_valid : ∀ k : Fin 610, + let e := table[k.val]?.getD emptyEntry + e.index = k.val + 6 ∧ e.terms ≠ [] ∧ ∀ t ∈ e.terms, t.child < e.index := by + intro k + exact table_entries_range_0_610 k.val (Nat.zero_le _) k.isLt + +theorem table_valid : TableValid := by + refine ⟨table_size, ?_⟩ + intro k hk + exact table_entries_valid ⟨k, by simpa only [table_size] using hk⟩ + +theorem placement_count : placementCount = 1837 := by + rw [placementCount, table_toList] + decide +kernel + +theorem entryAt_index {i : ℕ} (hlo : 6 ≤ i) (hhi : i < 616) : + (entryAt i).index = i := by + have h := (table_entries_valid ⟨i - 6, by omega⟩).1 + simpa only [entryAt, Nat.sub_add_cancel hlo] using h + +theorem entryAt_nonempty {i : ℕ} (hlo : 6 ≤ i) (hhi : i < 616) : + (entryAt i).terms ≠ [] := + (table_entries_valid ⟨i - 6, by omega⟩).2.1 + +theorem entryAt_backward {i : ℕ} (hlo : 6 ≤ i) (hhi : i < 616) + {t : Term} (ht : t ∈ (entryAt i).terms) : t.child < i := by + have h := (table_entries_valid ⟨i - 6, by omega⟩).2.2 t ht + change t.child < (entryAt i).index at h + simpa only [entryAt_index hlo hhi] using h + +end SnakyCertificate + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/CellInterface.lean b/lean/OAI/Combinatorics/SparsestCut/CellInterface.lean new file mode 100644 index 0000000000000000000000000000000000000000..508687bb22d8eaa306215a8a8ba378ff51a3818a --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/CellInterface.lean @@ -0,0 +1,363 @@ +import OAI.Combinatorics.SparsestCut.SliceIntegration + +namespace OAI + +universe u1 u2 u3 u4 u5 u6 u7 u8 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.CellInterface +variable {E : Type u1} {I : Type u2} [NormedAddCommGroup E] [NormedSpace ℝ E] + [Fintype I] [DecidableEq I] + +omit [NormedSpace ℝ E] in +lemma floor_locally_constant {f : E → ℝ} {x : E} (hf : ContinuousAt f x) + (hn : ∀ k : ℤ, f x ≠ k) : ∀ᶠ y in 𝓝 x, ⌊f y⌋ = ⌊f x⌋ := by + have hlo : (⌊f x⌋:ℝ) < f x := lt_of_le_of_ne (Int.floor_le _) (Ne.symm (hn _)) + have hu := Int.lt_floor_add_one (f x) + filter_upwards [hf.eventually_lt_const hu, hf.eventually_const_lt hlo] with y hy hy' + exact Int.floor_eq_iff.mpr ⟨hy'.le,hy⟩ + +lemma neighboring_labels (ell : I → E →L[ℝ] ℝ) {τ : ℝ} (hτ : 0<τ) + {U : Set E} (hU : IsOpen U) {x : E} (hx : x∈U) (i : I) (k : ℤ) + (heq : ell i x=(k:ℝ)*τ) + (hother : ∀ j, j≠i → ∀ l : ℤ, ell j x≠(l:ℝ)*τ) + (v : E) (hv : ell i v>0) : + ∃ xp xm : E, xp∈U ∧ xm∈U ∧ + (∀ j (l : ℤ), ell j xp≠(l:ℝ)*τ) ∧ + (∀ j (l : ℤ), ell j xm≠(l:ℝ)*τ) ∧ + (∀ j, j≠i → ⌊ell j xp/τ⌋=⌊ell j x/τ⌋ ∧ ⌊ell j xm/τ⌋=⌊ell j x/τ⌋) ∧ + ⌊ell i xp/τ⌋=k ∧ ⌊ell i xm/τ⌋=k-1 := by + let f (t : ℝ) := x+t • v + have hf : Continuous f := (continuous_const.add (continuous_id.smul continuous_const)) + have h0 : f 0=x := by simp [f] + have hmem : ∀ᶠ t in 𝓝 (0:ℝ), f t∈U := by + have h := hf.continuousAt.eventually (hU.mem_nhds (show f 0∈U by simpa only [h0] using hx)) + exact h + have ho : ∀ᶠ t in 𝓝 (0:ℝ), ∀ j, j≠i → + (∀ l : ℤ, ell j (f t)≠(l:ℝ)*τ) ∧ ⌊ell j (f t)/τ⌋=⌊ell j x/τ⌋ := by + apply eventually_all.mpr + intro j + by_cases hji : j=i + · simp [hji] + have hc : ContinuousAt (fun t => ell j (f t)/τ) (0:ℝ) := + (((ell j).continuous.comp hf).div_const τ).continuousAt + have hn : ∀ l : ℤ, ell j (f 0)/τ≠(l:ℝ) := by + intro l h + apply hother j hji l + simpa only [h0] using (div_eq_iff hτ.ne').mp h + have ha : (⌊ell j (f 0)/τ⌋:ℝ).mem_nhds (by simpa using div_pos hτ hv) + have both := hmem.and (ho.and hsmall) + obtain ⟨d,hd,hdsub⟩ := Metric.mem_nhds_iff.mp both + let t := d/2 + have ht : 0 linarith [hfrac.1,hfrac.2]) + have hfm : ⌊ell i (f (-t))/τ⌋=k-1 := Int.floor_eq_iff.mpr (by rw [hem]; push_cast; constructor <;> linarith [hfrac.1,hfrac.2]) + refine ⟨f t,f (-t),hp.1,hm.1,?_,?_,?_,hfp,hfm⟩ + · intro j l he + by_cases hji : j=i + · subst j + have hl : ell i (f t)/τ=(l:ℝ) := by rw [he,mul_div_cancel_right₀ _ hτ.ne'] + have hkl : l=k := by simpa [hl] using hfp + rw [hl,hkl] at hep + linarith [hfrac.1] + · exact (hp.2.1 j hji).1 l he + · intro j l he + by_cases hji : j=i + · subst j + have hl : ell i (f (-t))/τ=(l:ℝ) := by rw [he,mul_div_cancel_right₀ _ hτ.ne'] + have hkl : l=k-1 := by simpa [hl] using hfm + rw [hl,hkl] at hem + push_cast at hem + linarith [hfrac.2] + · exact (hm.2.1 j hji).1 l he + · intro j hji + exact ⟨(hp.2.1 j hji).2,(hm.2.1 j hji).2⟩ + +end UniformSparsestCut.CellInterface + +namespace UniformSparsestCut.CellInterface +open Filter Set +open scoped Topology BigOperators +noncomputable section +variable {E : Type u3} {I : Type u4} {A : Type u5} [NormedAddCommGroup E] [NormedSpace ℝ E] + [Fintype I] [DecidableEq I] + +def regular (ell : I → E →L[ℝ] ℝ) (τ : ℝ) (x : E) : Prop := + ∀ i (k : ℤ), ell i x≠(k:ℝ)*τ + +def label (ell : I → E →L[ℝ] ℝ) (τ : ℝ) (x : E) : I → ℤ := fun i => ⌊ell i x/τ⌋ + +def LabelVertex (ell : I → E →L[ℝ] ℝ) (τ : ℝ) (U : Set E) := + {l : I → ℤ // ∃ x∈U, regular ell τ x ∧ label ell τ x=l} + +def vertex (ell : I → E →L[ℝ] ℝ) (τ : ℝ) {U : Set E} (x : E) (hx : x∈U) + (hr : regular ell τ x) : LabelVertex ell τ U := ⟨label ell τ x,x,hx,hr,rfl⟩ + +omit [Fintype I] [DecidableEq I] in +lemma regular_floor_le (ell : I → E →L[ℝ] ℝ) {τ : ℝ} (hτ : 0<τ) + {x : E} (hr : regular ell τ x) (i : I) (k : ℤ) : + k≤label ell τ x i ↔ (k:ℝ)*τ lt_of_le_of_ne h (Ne.symm (hr i k)),le_of_lt⟩ +omit [Fintype I] [DecidableEq I] in +lemma floor_lt (ell : I → E →L[ℝ] ℝ) {τ : ℝ} (hτ : 0<τ) (x : E) (i : I) (k : ℤ) : + label ell τ x i (ell p.1 x-(p.2.val:ℝ)*τ)/pivot p.1<0) +def weakPattern (ell : I → E →L[ℝ] ℝ) (pivot : I → ℝ) (τ : ℝ) (s : Finset ℤ) (x : E) : Finset (I × s) := + Finset.univ.filter (fun p => (ell p.1 x-(p.2.val:ℝ)*τ)/pivot p.1≤0) + +omit [DecidableEq I] in +lemma mem_pattern (ell : I → E →L[ℝ] ℝ) (pivot : I → ℝ) (hp : ∀ i, pivot i≠0) + {τ : ℝ} (hτ : 0<τ) (s : Finset ℤ) {x : E} (hr : regular ell τ x) (i : I) (k : s) : + (i,k)∈pattern ell pivot τ s x ↔ if 0 0 + +omit [DecidableEq I] in +lemma extension_eq (ell : I → E →L[ℝ] ℝ) (pivot : I → ℝ) (hp : ∀ i, pivot i≠0) + {τ : ℝ} (hτ : 0<τ) (s : Finset ℤ) (U : Set E) + (hb : ∀ x∈U, regular ell τ x → ∀ i, label ell τ x i∈s) + (F : LabelVertex ell τ U → A → ℝ) (x : E) (hx : x∈U) (hr : regular ell τ x) : + extension ell pivot τ s U F (pattern ell pivot τ s x)=F (vertex ell τ x hx hr) := by + classical + unfold extension + split_ifs with h + · congr 1 + apply Subtype.ext + exact pattern_labels ell pivot hp hτ s h.choose_spec.choose_spec.choose hr + (hb _ h.choose_spec.choose h.choose_spec.choose_spec.choose) (hb x hx hr) + h.choose_spec.choose_spec.choose_spec + · exact False.elim (h ⟨x,hx,hr,rfl⟩) + +omit [DecidableEq I] in +lemma extension_bounded (ell : I → E →L[ℝ] ℝ) (pivot : I → ℝ) (τ : ℝ) (s : Finset ℤ) + (U : Set E) (F : LabelVertex ell τ U → A → ℝ) {M : ℝ} (hM0 : 0≤M) + (hM : ∀ v a, |F v a|≤M) (P : Finset (I × s)) (a : A) : + |extension ell pivot τ s U F P a|≤M := by + classical + unfold extension + split_ifs + · exact hM _ _ + · simpa using hM0 + +end +end UniformSparsestCut.CellInterface + +namespace UniformSparsestCut.CellInterface +open Filter Set +open scoped Topology BigOperators +noncomputable section +variable {E : Type u6} {I : Type u7} {A : Type u8} [NormedAddCommGroup E] [NormedSpace ℝ E] + [Fintype I] [DecidableEq I] + +omit [DecidableEq I] in +lemma mem_pattern_at (ell : I → E →L[ℝ] ℝ) (pivot : I → ℝ) (hp : ∀ i, pivot i≠0) + {τ : ℝ} (hτ : 0<τ) (s : Finset ℤ) {x : E} (i : I) + (hr : ∀ k : ℤ, ell i x≠(k:ℝ)*τ) (k : s) : + (i,k)∈pattern ell pivot τ s x ↔ if 0 lt_of_le_of_ne h (Ne.symm (hr k.val)),le_of_lt⟩ + +omit [DecidableEq I] in +lemma mem_weakPattern_at (ell : I → E →L[ℝ] ℝ) (pivot : I → ℝ) (hp : ∀ i, pivot i≠0) + (τ : ℝ) (s : Finset ℤ) (x : E) (i : I) (k : s) (hr : ell i x≠(k.val:ℝ)*τ) : + (i,k)∈weakPattern ell pivot τ s x ↔ (i,k)∈pattern ell pivot τ s x := by + simp only [weakPattern,pattern,Finset.mem_filter,Finset.mem_univ,true_and] + exact ⟨fun h => lt_of_le_of_ne h (div_ne_zero (sub_ne_zero.mpr hr) (hp i)), le_of_lt⟩ + +omit [DecidableEq I] in +lemma boundary_pattern (ell : I → E →L[ℝ] ℝ) (pivot : I → ℝ) (hp : ∀ i, pivot i≠0) + {τ : ℝ} (hτ : 0<τ) (s : Finset ℤ) {x : E} (i : I) (k : ℤ) + (heq : ell i x=(k:ℝ)*τ) (l : s) : + ((i,l)∈pattern ell pivot τ s x ↔ if 00) : + ∃ vp vm : LabelVertex ell τ U, + vp.val i=k ∧ vm.val i=k-1 ∧ (∀ j, j≠i → vp.val j=vm.val j) ∧ + (if 0 (ho j hj).1.trans (ho j hj).2.symm),?_⟩ + have hpp := extension_eq ell pivot hp hτ s U hb F xp hxp hrp + have hpm := extension_eq ell pivot hp hτ s U hb F xm hxm hrm + have hotherp (j : I) (hj : j≠i) (l : s) : + ((j,l)∈pattern ell pivot τ s x ↔ (j,l)∈pattern ell pivot τ s xp) ∧ + ((j,l)∈pattern ell pivot τ s x ↔ (j,l)∈pattern ell pivot τ s xm) := by + rw [mem_pattern_at ell pivot hp hτ s j (hother j hj), + mem_pattern ell pivot hp hτ s hrp,mem_pattern ell pivot hp hτ s hrm] + change (_ ↔ if _ then ⌊ell j xp/τ⌋<_ else _≤⌊ell j xp/τ⌋) ∧ _ + simp only [(ho j hj).1,(ho j hj).2,label] + trivial + by_cases hpi : 00) : + ∑ a, |extension ell pivot τ s U F (weakPattern ell pivot τ s x) a- + extension ell pivot τ s U F (pattern ell pivot τ s x) a|≤J := by + obtain ⟨vp,vm,hvp,hvm,ho,htr⟩ := interface_extension_traces ell pivot hp hτ s hU hb F hx i k heq hother v hv + have hbnd := hF vp vm i (by rw [hvp,hvm]; omega) ho + by_cases hpi : 0 linarith + +omit [InnerProductSpace ℝ E] in +lemma position_error (x y x' y' : E) {R : ℝ} (hx : ‖x-x'‖≤R) (hy : ‖y-y'‖≤R) : + |‖x-y‖-‖x'-y'‖|≤2*R := by + have he : (x-y)-(x'-y')=(x-x')-(y-y') := by abel + calc + _ ≤ ‖(x-y)-(x'-y')‖ := abs_norm_sub_norm_le _ _ + _ = ‖(x-x')-(y-y')‖ := by rw [he] + _ ≤ ‖x-x'‖+‖y-y'‖ := norm_sub_le _ _ + _ ≤ _ := by linarith + +lemma rounded_distance_error (g : κ → E) {q ε a b A R T : ℝ} + (hq : 0≤q) (hε : 0≤ε) (ha : 0 nlinarith + +omit [InnerProductSpace ℝ E] [Fintype ι] in + +lemma global_angle {H : Type u4} [NormedAddCommGroup H] [InnerProductSpace ℝ H] + (P : ι → H) (θ : ι → E) {c e : ℝ} (hc : 0≤c) (_he : 0≤e) + (hd : ∀ v w, |‖P v-P w‖^2-c*‖θ v-θ w‖|≤e) (v z y : ι) : + -(3*e/2) ≤ inner ℝ (P v-P z) (P y-P z) := by + have h1 := abs_le.mp (hd v z) + have h2 := abs_le.mp (hd y z) + have h3 := abs_le.mp (hd v y) + have htri : ‖θ v-θ y‖≤‖θ v-θ z‖+‖θ y-θ z‖ := by + have := norm_add_le (θ v-θ z) (θ z-θ y) + rw [sub_add_sub_cancel,norm_sub_rev (θ z) (θ y)] at this + exact this + have hm := mul_le_mul_of_nonneg_left htri hc + have hid : ‖P v-P z‖^2+‖P y-P z‖^2-‖P v-P y‖^2 = + 2*inner ℝ (P v-P z) (P y-P z) := by + have he : P v-P y=(P v-P z)-(P y-P z) := by abel + rw [he,norm_sub_sq_real (P v-P z) (P y-P z)]; ring + nlinarith + +end UniformSparsestCut.ChartAngles + +namespace UniformSparsestCut.ChartAngles +open MeasureTheory Set +open scoped BigOperators RealInnerProductSpace +variable {m N S : ℕ} +local notation "E" => EuclideanSpace ℝ (Fin m) +local notation "F" => EuclideanSpace ℝ (Fin N) +lemma segment_norm_le {X : Type u5} {Y : Type u6} [NormedAddCommGroup X] [NormedSpace ℝ X] + [NormedAddCommGroup Y] [NormedSpace ℝ Y] (L : X →L[ℝ] Y) + (x x' : X) {R t : ℝ} (hx : ‖L x‖≤R) (hx' : ‖L x'‖≤R) (ht : t∈Icc (0:ℝ) 1) : + ‖L (x+t • (x'-x))‖≤R := by + have he : x+t • (x'-x)=(1-t) • x+t • x' := by module + rw [he,map_add,map_smul,map_smul] + calc + _ ≤ ‖(1-t) • L x‖+‖t • L x'‖ := norm_add_le _ _ + _ = (1-t)*‖L x‖+t*‖L x'‖ := by rw [norm_smul,norm_smul,Real.norm_eq_abs,Real.norm_eq_abs,abs_of_nonneg (sub_nonneg.mpr ht.2),abs_of_nonneg ht.1] + _ ≤ (1-t)*R+t*R := add_le_add (mul_le_mul_of_nonneg_left hx (sub_nonneg.mpr ht.2)) (mul_le_mul_of_nonneg_left hx' ht.1) + _ = R := by ring + +lemma local_profile (g : Fin S → Fin N → E) (B : Fin S → F →L[ℝ] E) + {q k ε a b T R γ : ℝ} (hq : 0 q⁻¹ • g s i)) (B s) x‖≤R) + (hrx' : ‖ChartKernel.residual (FrameCharts.chart (fun i => q⁻¹ • g s i)) (B s) x'‖≤R) + (hry : ‖ChartKernel.residual (FrameCharts.chart (fun i => q⁻¹ • g t i)) (B t) y‖≤R) : + |Profile.kernel (fun j : Fin S × Fin N => g j.1 j.2) q ε a b + (B s x') (B t y) (ChartKernel.alpha g B q k ε s x') (ChartKernel.alpha g B q k ε t y)- + Profile.kernel (fun j : Fin S × Fin N => g j.1 j.2) q ε a b + (B s x) (B t y) (ChartKernel.alpha g B q k ε s x) (ChartKernel.alpha g B q k ε t y)| ≤ + ((k+q*γ*(4*k)+ε*((S:ℝ)*N)*(9*k/ε)*(k/ε*R))*Real.log (b/a)+ + (ε*((S:ℝ)*N)*(2*q)*(4*k)*(1+(k/ε*R)^2+2*(k/ε*R)))/a)* + (∑ i, |x' i-x i|) := by + let H : ℝ := ∑ i : Fin N, |x' i-x i| + let A : ℝ := k/ε*R + let C : ℝ := k+q*γ*(4*k)+ε*((S:ℝ)*N)*(9*k/ε)*A + let D : ℝ := ε*((S:ℝ)*N)*(2*q)*(4*k)*(1+A^2+2*A) + have hH : 0≤H := Finset.sum_nonneg (fun _ _ => abs_nonneg _) + have hA : 0≤A := by dsimp [A]; positivity + have hD : 0≤D := by dsimp [D]; positivity + have hθ (z : ℝ) (hz : z∈Icc (0:ℝ) 1) : ‖B s (x+z • (x'-x))‖≤T := segment_norm_le (B s) x x' hx hx' hz + have hα (z : ℝ) (hz : z∈Icc (0:ℝ) 1) (j : Fin S × Fin N) : + |ChartKernel.alpha g B q k ε s (x+z • (x'-x)) j|≤A := + ChartKernel.alpha_norm_bound g B hk hε s _ (segment_norm_le _ x x' hrx hrx' hz) j + have hβ (j : Fin S × Fin N) : |ChartKernel.alpha g B q k ε t y j|≤A := + ChartKernel.alpha_norm_bound g B hk hε t y hry j + have hv : ‖B s (x'-x)‖≤(4*k)*H := by + simpa only [PiLp.sub_apply,H] using ChartKernel.norm_linear_le_l1 (B s) (by positivity : 0≤4*k) (hB s) (x'-x) + have hd (z : ℝ) (hz : z∈Icc (0:ℝ) 1) (σ : ℝ) (hσ : σ∈Icc a b) : + |Profile.differential (fun j : Fin S × Fin N => g j.1 j.2) q ε σ + (B s x+z • B s (x'-x)) (B t y) (B s (x'-x)) + (fun j => ChartKernel.alpha g B q k ε s x j+z*ChartKernel.alpha g B q k ε s (x'-x) j) + (ChartKernel.alpha g B q k ε t y) (ChartKernel.alpha g B q k ε s (x'-x))| ≤ + (C*H)/σ+(D*H)/σ^2 := by + have hp : 0<σ := ha.trans_le hσ.1 + have he : B s x+z • B s (x'-x)=B s (x+z • (x'-x)) := by simp + have hw : ‖(σ⁻¹:ℝ) • (B t y-B s (x+z • (x'-x)))‖≤2*T/a := by + rw [norm_smul,Real.norm_eq_abs,abs_of_pos (inv_pos.mpr hp),← div_eq_inv_mul] + calc + _ ≤ (2*T)/σ := div_le_div_of_nonneg_right + ((norm_sub_le _ _).trans (by linarith [hθ z hz])) hp.le + _ ≤ (2*T)/a := div_le_div_of_nonneg_left (by positivity) ha hσ.1 + have hfreq := hf s ((σ⁻¹:ℝ) • (B t y-B s (x+z • (x'-x)))) hw + have hf' : ‖Real.exp (-‖(σ⁻¹:ℝ) • (B t y-B s (x+z • (x'-x)))‖^2/2) • + ((σ⁻¹:ℝ) • (B t y-B s (x+z • (x'-x))))- + ((Fintype.card (Fin N):ℝ)⁻¹) • ∑ i, Real.sin (inner ℝ (g s i) (B t y-B s (x+z • (x'-x)))/σ) • g s i‖≤γ := by + simpa only [real_inner_smul_right,div_eq_inv_mul,Fintype.card_fin] using hfreq + rw [he,← ChartKernel.alpha_linear] + have hb := MetricKernel.full_differential_bound g s (B s (x+z • (x'-x))) (B t y) + (B s (x'-x)) (fun i => (x'-x) i) (ChartKernel.alpha g B q k ε s (x+z • (x'-x))) + (ChartKernel.alpha g B q k ε t y) hq hε hp (by simpa using hkq) + (by positivity : 0≤2*q) hA (by positivity : 0≤4*k) hH (by positivity : 0≤9*k/ε) hγ hg hv + (by simp only [PiLp.sub_apply,H]; exact le_rfl) (hα z hz) hβ + (fun j => ChartKernel.alpha_derivative_bound g B hq hk hk1 hε s (x'-x) + (by simp only [PiLp.sub_apply,H]; exact le_rfl) (hg s) (hB s) j) hf' + convert! hb using 1 ; simp only [C,D,Fintype.card_fin,A] + have hl := Profile.kernel_segment_bound (fun j : Fin S × Fin N => g j.1 j.2) + ha hab (mul_nonneg hD hH) (B s x) (B t y) (B s (x'-x)) + (ChartKernel.alpha g B q k ε s x) (ChartKernel.alpha g B q k ε t y) + (ChartKernel.alpha g B q k ε s (x'-x)) hd + have heθ : B s x+B s (x'-x)=B s x' := by rw [map_sub]; abel + have heα : (fun j => ChartKernel.alpha g B q k ε s x j+ChartKernel.alpha g B q k ε s (x'-x) j)= + ChartKernel.alpha g B q k ε s x' := by + have := ChartKernel.alpha_linear g B q k ε s x (x'-x) 1 + simpa only [one_smul,one_mul,add_sub_cancel] using this.symm + rw [heθ,heα] at hl + convert hl using 1 ; dsimp [C,D,A,H] ; ring + +end UniformSparsestCut.ChartAngles + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/ChartKernel.lean b/lean/OAI/Combinatorics/SparsestCut/ChartKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..517135c841d1ed49586b66f999b319a02c55083b --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/ChartKernel.lean @@ -0,0 +1,98 @@ +import OAI.Combinatorics.SparsestCut.MetricKernel + +namespace OAI + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.ChartKernel +open MeasureTheory Set +open scoped BigOperators RealInnerProductSpace +variable {m N S : ℕ} +local notation "E" => EuclideanSpace ℝ (Fin m) +local notation "F" => EuclideanSpace ℝ (Fin N) + +def residual (J : E →L[ℝ] F) (B : F →L[ℝ] E) : F →L[ℝ] F := + ContinuousLinearMap.id ℝ F-J.comp B + +def alpha (g : Fin S → Fin N → E) (B : Fin S → F →L[ℝ] E) + (q k ε : ℝ) (s : Fin S) (x : F) (j : Fin S × Fin N) : ℝ := + if j.1=s then k/ε*(x j.2-inner ℝ (g j.1 j.2) (B s x)/q) else 0 + +lemma norm_linear_le_l1 (B : F →L[ℝ] E) {V : ℝ} (_hV : 0 ≤ V) + (hB : ∀ i, ‖B (EuclideanSpace.single i 1)‖ ≤ V) (x : F) : + ‖B x‖ ≤ V*∑ i, |x i| := by + have he : x = ∑ i : Fin N, x i • EuclideanSpace.single i 1 := by + apply PiLp.ext + intro j + simp [ Pi.single_apply] + conv_lhs => rw [he, map_sum] + calc + _ ≤ ∑ i : Fin N, ‖B (x i • EuclideanSpace.single i 1)‖ := norm_sum_le _ _ + _ ≤ ∑ i : Fin N, |x i| * V := by + apply Finset.sum_le_sum + intro i _ + rw [map_smul, norm_smul,Real.norm_eq_abs] + exact mul_le_mul_of_nonneg_left (hB i) (abs_nonneg _) + _ = V*∑ i : Fin N, |x i| := by rw [← Finset.sum_mul]; ring + +lemma alpha_linear (g : Fin S → Fin N → E) (B : Fin S → F →L[ℝ] E) + (q k ε : ℝ) (s : Fin S) (x h : F) (t : ℝ) : + alpha g B q k ε s (x+t • h) = fun j => alpha g B q k ε s x j+t*alpha g B q k ε s h j := by + funext j + simp only [alpha, map_add, map_smul, inner_add_right, real_inner_smul_right, + PiLp.add_apply, PiLp.smul_apply, smul_eq_mul] + by_cases hj : j.1=s <;> simp only [hj, ite_true,ite_false] <;> ring + +lemma alpha_norm_bound (g : Fin S → Fin N → E) (B : Fin S → F →L[ℝ] E) + {q k ε R : ℝ} (hk : 0 ≤ k) (hε : 0 < ε) (s : Fin S) (x : F) + (hx : ‖residual (FrameCharts.chart (fun i => q⁻¹ • g s i)) (B s) x‖ ≤ R) + (j : Fin S × Fin N) : |alpha g B q k ε s x j| ≤ k/ε*R := by + have hR : 0 ≤ R := (norm_nonneg _).trans hx + by_cases hj : j.1=s + · simp only [alpha,hj,ite_true,abs_mul,abs_of_nonneg (div_nonneg hk hε.le)] + apply mul_le_mul_of_nonneg_left _ (div_nonneg hk hε.le) + have hc := PiLp.norm_apply_le (p := (2:ENNReal)) + (residual (FrameCharts.chart (fun i => q⁻¹ • g s i)) (B s) x) j.2 + have he : residual (FrameCharts.chart (fun i => q⁻¹ • g s i)) (B s) x j.2 = + x j.2-inner ℝ (g s j.2) (B s x)/q := by + simp [residual,FrameCharts.chart_apply,real_inner_smul_left,div_eq_inv_mul] + simpa only [he,Real.norm_eq_abs] using hc.trans hx + · simp only [alpha,hj,ite_false,abs_zero] + positivity + +lemma alpha_derivative_bound (g : Fin S → Fin N → E) (B : Fin S → F →L[ℝ] E) + {q k ε H : ℝ} (hq : 0 < q) (hk : 0 ≤ k) (hk1 : k ≤ 1) (hε : 0 < ε) + (s : Fin S) (h : F) (hH : ∑ i, |h i| ≤ H) + (hg : ∀ i, ‖g s i‖ ≤ 2*q) (hB : ∀ i, ‖B s (EuclideanSpace.single i 1)‖ ≤ 4*k) + (j : Fin S × Fin N) : |alpha g B q k ε s h j| ≤ (9*k/ε)*H := by + have hv := norm_linear_le_l1 (B s) (by positivity : 0 ≤ 4*k) hB h + have hv' : ‖B s h‖ ≤ 4*k*H := hv.trans (mul_le_mul_of_nonneg_left hH (by positivity)) + have hH0 : 0 ≤ H := (Finset.sum_nonneg (fun _ _ => abs_nonneg _)).trans hH + have hh (i : Fin N) : |h i| ≤ H := (Finset.single_le_sum (fun _ _ => abs_nonneg _) (Finset.mem_univ i)).trans hH + by_cases hj : j.1=s + · simp only [alpha,hj,ite_true,abs_mul,abs_of_nonneg (div_nonneg hk hε.le)] + have hip : |inner ℝ (g s j.2) (B s h)/q| ≤ 8*k*H := by + rw [abs_div,abs_of_pos hq] + apply (div_le_iff₀ hq).mpr + calc + _ ≤ ‖g s j.2‖*‖B s h‖ := abs_real_inner_le_norm _ _ + _ ≤ (2*q)*(4*k*H) := mul_le_mul (hg _) hv' (norm_nonneg _) (by positivity) + _ = _ := by ring + have hb : |h j.2-inner ℝ (g s j.2) (B s h)/q| ≤ 9*H := by + refine (abs_sub _ _).trans ?_ + have := mul_le_mul_of_nonneg_right hk1 hH0 + linarith [hh j.2,hip] + calc + _ ≤ (k/ε)*(9*H) := mul_le_mul_of_nonneg_left hb (div_nonneg hk hε.le) + _ = _ := by ring + · simp only [alpha,hj,ite_false,abs_zero] + positivity + +end UniformSparsestCut.ChartKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/ChartLinear.lean b/lean/OAI/Combinatorics/SparsestCut/ChartLinear.lean new file mode 100644 index 0000000000000000000000000000000000000000..624df2a01f4e7a6ac02668a3c7bef806e5cc3df3 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/ChartLinear.lean @@ -0,0 +1,202 @@ +import OAI.Combinatorics.SparsestCut.PivotFamily + +namespace OAI + +universe u1 u2 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.ChartLinear +variable {E : Type u1} {F : Type u2} [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [NormedAddCommGroup F] [InnerProductSpace ℝ F] [FiniteDimensional ℝ E] + [FiniteDimensional ℝ F] + +lemma gram_injective (J : E →L[ℝ] F) {a : ℝ} (ha : 0 < a) + (hl : ∀ x, a * ‖x‖^2 ≤ ‖J x‖^2) : Function.Injective (J.adjoint.comp J) := by + apply LinearMap.ker_eq_bot.mp + apply LinearMap.ker_eq_bot'.mpr + intro x hx + have hh : ‖J x‖^2 = 0 := by + have := congrArg (fun z => inner ℝ x z) hx + change inner ℝ x (J.adjoint (J x)) = inner ℝ x 0 at this + simpa only [J.adjoint_inner_right, real_inner_self_eq_norm_sq, inner_zero_right] using this + have hn : ‖x‖^2 = 0 := by nlinarith [hl x, sq_nonneg ‖x‖] + exact norm_eq_zero.mp (sq_eq_zero_iff.mp hn) + +noncomputable def gramEquiv (J : E →L[ℝ] F) {a : ℝ} (ha : 0 < a) + (hl : ∀ x, a * ‖x‖^2 ≤ ‖J x‖^2) : E ≃L[ℝ] E := + ContinuousLinearEquiv.ofBijective (J.adjoint.comp J) + (LinearMap.ker_eq_bot.mpr (gram_injective J ha hl)) + (LinearMap.range_eq_top.mpr (LinearMap.injective_iff_surjective.mp + (gram_injective J ha hl))) + +noncomputable def pseudoInverse (J : E →L[ℝ] F) {a : ℝ} (ha : 0 < a) + (hl : ∀ x, a * ‖x‖^2 ≤ ‖J x‖^2) : F →L[ℝ] E := + (gramEquiv J ha hl).symm.toContinuousLinearMap.comp J.adjoint + +lemma pseudoInverse_comp (J : E →L[ℝ] F) {a : ℝ} (ha : 0 < a) + (hl : ∀ x, a * ‖x‖^2 ≤ ‖J x‖^2) : (pseudoInverse J ha hl).comp J = ContinuousLinearMap.id ℝ E := by + ext x + exact (gramEquiv J ha hl).symm_apply_apply x + +lemma gramInverse_norm (J : E →L[ℝ] F) {a : ℝ} (ha : 0 < a) + (hl : ∀ x, a * ‖x‖^2 ≤ ‖J x‖^2) (y : E) : + ‖(gramEquiv J ha hl).symm y‖ ≤ ‖y‖/a := by + let x := (gramEquiv J ha hl).symm y + have hx : J.adjoint (J x) = y := (gramEquiv J ha hl).apply_symm_apply y + have hb := hl x + have he : ‖J x‖^2 = inner ℝ x y := by rw [← hx, J.adjoint_inner_right, real_inner_self_eq_norm_sq] + rw [he] at hb + have hc := real_inner_le_norm x y + by_cases hz : ‖x‖ = 0 + · simpa [x, hz] using (div_nonneg (norm_nonneg y) ha.le) + · have hp : 0 < ‖x‖ := lt_of_le_of_ne (norm_nonneg _) (Ne.symm hz) + change ‖x‖ ≤ ‖y‖/a + apply (le_div_iff₀ ha).mpr + nlinarith + +lemma pseudoInverse_equation (J : E →L[ℝ] F) {a : ℝ} (ha : 0 < a) + (hl : ∀ x, a * ‖x‖^2 ≤ ‖J x‖^2) (y : F) : + J.adjoint (J (pseudoInverse J ha hl y)) = J.adjoint y := + (gramEquiv J ha hl).apply_symm_apply _ + +lemma residual_orthogonal (J : E →L[ℝ] F) {a : ℝ} (ha : 0 < a) + (hl : ∀ x, a * ‖x‖^2 ≤ ‖J x‖^2) (y : F) (x : E) : + inner ℝ (J x) (y - J (pseudoInverse J ha hl y)) = 0 := by + rw [← J.adjoint_inner_right] + simp [pseudoInverse_equation J ha hl y] + +lemma residual_pythagoras (J : E →L[ℝ] F) {a : ℝ} (ha : 0 < a) + (hl : ∀ x, a * ‖x‖^2 ≤ ‖J x‖^2) (y : F) : + ‖J (pseudoInverse J ha hl y)‖^2 + ‖y-J (pseudoInverse J ha hl y)‖^2 = ‖y‖^2 := by + have h := norm_add_sq_real (J (pseudoInverse J ha hl y)) (y - J (pseudoInverse J ha hl y)) + rw [residual_orthogonal] at h + simpa using h.symm + +lemma pseudoInverse_norm (J : E →L[ℝ] F) {a : ℝ} (ha : 0 < a) + (hl : ∀ x, a * ‖x‖^2 ≤ ‖J x‖^2) (y : F) : + ‖pseudoInverse J ha hl y‖ ≤ ‖y‖ / Real.sqrt a := by + have hr := residual_pythagoras J ha hl y + have hb := hl (pseudoInverse J ha hl y) + have hs := Real.sq_sqrt ha.le + apply (le_div_iff₀ (Real.sqrt_pos.2 ha)).mpr + nlinarith [sq_nonneg ‖y-J (pseudoInverse J ha hl y)‖, + norm_nonneg (pseudoInverse J ha hl y), norm_nonneg y, Real.sqrt_nonneg a] + +lemma residual_norm (J : E →L[ℝ] F) {a : ℝ} (ha : 0 < a) + (hl : ∀ x, a * ‖x‖^2 ≤ ‖J x‖^2) (y : F) : + ‖y-J (pseudoInverse J ha hl y)‖ ≤ ‖y‖ := by + have h := residual_pythagoras J ha hl y + nlinarith [norm_nonneg y, norm_nonneg (y-J (pseudoInverse J ha hl y)), + sq_nonneg ‖J (pseudoInverse J ha hl y)‖] + +lemma pseudoInverse_column (J : E →L[ℝ] F) {a : ℝ} (ha : 0 < a) + (hl : ∀ x, a * ‖x‖^2 ≤ ‖J x‖^2) (y : F) : + ‖pseudoInverse J ha hl y‖ ≤ ‖J.adjoint y‖/a := + gramInverse_norm J ha hl _ + +end UniformSparsestCut.ChartLinear + +namespace UniformSparsestCut.FrameCharts +open scoped RealInnerProductSpace BigOperators +variable {m N : ℕ} +local notation "E" => EuclideanSpace ℝ (Fin m) +local notation "F" => EuclideanSpace ℝ (Fin N) + +def chart (u : Fin N → E) : E →L[ℝ] F := + (EuclideanSpace.equiv (Fin N) ℝ).symm.toContinuousLinearMap.comp + (ContinuousLinearMap.pi (fun i => innerSL ℝ (u i))) + +@[simp] lemma chart_apply (u : Fin N → E) (x : E) (i : Fin N) : + chart u x i = inner ℝ (u i) x := rfl + +lemma chart_energy (u : Fin N → E) (x : E) : + ‖chart u x‖^2 = ∑ i, (inner ℝ (u i) x)^2 := by + rw [EuclideanSpace.norm_sq_eq] + simp [chart_apply, Real.norm_eq_abs, sq_abs] + +lemma chart_adjoint_single (u : Fin N → E) (i : Fin N) : + (chart u).adjoint (EuclideanSpace.single i 1) = u i := by + apply ext_inner_right ℝ + intro x + rw [(chart u).adjoint_inner_left] + change inner ℝ (EuclideanSpace.single i 1) (chart u x) = inner ℝ (u i) x + rw [EuclideanSpace.inner_single_left] + simp + +lemma extend_covariance (g : Fin N → E) (hN : 0 < N) (a b : ℝ) + (hc : ∀ v : E, ‖v‖ = 1 → a ≤ (∑ i, (inner ℝ v (g i))^2)/(N : ℝ) ∧ + (∑ i, (inner ℝ v (g i))^2)/(N : ℝ) ≤ b) (x : E) : + a*(N : ℝ)*‖x‖^2 ≤ ∑ i, (inner ℝ (g i) x)^2 ∧ + (∑ i, (inner ℝ (g i) x)^2) ≤ b*(N : ℝ)*‖x‖^2 := by + have hn : (0 : ℝ) < N := by exact_mod_cast hN + by_cases hx : x = 0 + · simp [hx] + have hx0 : 0 < ‖x‖ := norm_pos_iff.mpr hx + let v : E := ‖x‖⁻¹ • x + have hv : ‖v‖ = 1 := by simp [v, norm_smul, hx0.ne'] + have he : (∑ i, (inner ℝ v (g i))^2) = ‖x‖⁻¹^2 * ∑ i, (inner ℝ (g i) x)^2 := by + simp only [v, real_inner_smul_left, mul_pow, Finset.mul_sum] + congr 1 + funext i + rw [real_inner_comm] + obtain ⟨hl,hu⟩ := hc v hv + rw [div_le_iff₀ hn] at hu + rw [le_div_iff₀ hn] at hl + rw [he] at hl hu + have hsq : 0 ≤ ‖x‖^2 := sq_nonneg _ + constructor + · have h := mul_le_mul_of_nonneg_right hl hsq + have hz : ‖x‖⁻¹^2*‖x‖^2 = 1 := by field_simp + calc + _ ≤ _ := h + _ = _ := by rw [mul_right_comm, hz, one_mul] + · have h := mul_le_mul_of_nonneg_right hu hsq + have hz : ‖x‖⁻¹^2*‖x‖^2 = 1 := by field_simp + calc + _ = _ := by rw [mul_right_comm, hz, one_mul] + _ ≤ _ := h + +lemma normalized_energy (g : Fin N → E) (_hm : 0 < m) (x : E) : + ‖chart (fun i => (Real.sqrt m)⁻¹ • g i) x‖^2 = + (∑ i, (inner ℝ (g i) x)^2)/(m : ℝ) := by + rw [chart_energy] + simp only [real_inner_smul_left, mul_pow, ← Finset.mul_sum] + rw [inv_pow, Real.sq_sqrt (Nat.cast_nonneg m), div_eq_inv_mul] + +lemma normalized_bounds (g : Fin N → E) (hm : 0 < m) (hN : 0 < N) + (hc : ∀ v : E, ‖v‖ = 1 → 1/2 ≤ (∑ i, (inner ℝ v (g i))^2)/(N : ℝ) ∧ + (∑ i, (inner ℝ v (g i))^2)/(N : ℝ) ≤ 2) (x : E) : + ((N : ℝ)/(2*m))*‖x‖^2 ≤ ‖chart (fun i => (Real.sqrt m)⁻¹ • g i) x‖^2 ∧ + ‖chart (fun i => (Real.sqrt m)⁻¹ • g i) x‖^2 ≤ ((2*N : ℝ)/m)*‖x‖^2 := by + have hm0 : (0 : ℝ) < m := by exact_mod_cast hm + obtain ⟨hl,hu⟩ := extend_covariance g hN (1/2) 2 hc x + rw [normalized_energy g hm x] + constructor + · apply (le_div_iff₀ hm0).mpr + calc + _ = (1/2:ℝ)*N*‖x‖^2 := by field_simp + _ ≤ _ := hl + · apply (div_le_iff₀ hm0).mpr + calc + _ ≤ (2:ℝ)*N*‖x‖^2 := hu + _ = _ := by field_simp + +lemma normalized_norms (g : Fin N → E) (hm : 0 < m) + (hg : ∀ i, Real.sqrt m/2 ≤ ‖g i‖ ∧ ‖g i‖ ≤ 2*Real.sqrt m) (i : Fin N) : + 1/2 ≤ ‖(Real.sqrt m)⁻¹ • g i‖ ∧ ‖(Real.sqrt m)⁻¹ • g i‖ ≤ 2 := by + have hm0 : (0 : ℝ) < m := by exact_mod_cast hm + have hs : 0 < Real.sqrt m := Real.sqrt_pos.mpr hm0 + rw [norm_smul, Real.norm_eq_abs, abs_of_pos (inv_pos.mpr hs), ← div_eq_inv_mul] + constructor + · exact (le_div_iff₀ hs).mpr (by linarith [(hg i).1]) + · exact (div_le_iff₀ hs).mpr (hg i).2 + +end UniformSparsestCut.FrameCharts + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/ChartMetric.lean b/lean/OAI/Combinatorics/SparsestCut/ChartMetric.lean new file mode 100644 index 0000000000000000000000000000000000000000..291fd323bc21536a5f58cff203c4ac05b5714cbf --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/ChartMetric.lean @@ -0,0 +1,178 @@ +import OAI.Combinatorics.SparsestCut.TriangleRepair + +namespace OAI + +universe u1 u2 u3 u4 u5 u6 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.ChartMetric +open scoped BigOperators RealInnerProductSpace +open TriangleRepair +noncomputable section +variable {ι : Type u1} {C : Type u2} {J : Type u3} {E : Type u4} {H : Type u5} [Fintype ι] [Fintype C] [Fintype J] [DecidableEq C] + [NormedAddCommGroup E] [InnerProductSpace ℝ E] + [NormedAddCommGroup H] [InnerProductSpace ℝ H] + +lemma neg_min_eq (a b : ℝ) : -min a b=max (-a) (-b) := by + rcases le_total a b with h|h + · rw [min_eq_left h,max_eq_left (neg_le_neg h)] + · rw [min_eq_right h,max_eq_right (neg_le_neg h)] + +omit [Fintype ι] [Fintype C] [InnerProductSpace ℝ H] in +lemma capped_angle (c : ι → C) (h : ι → H) {r : ℝ} (P : ι → E) + (hg : ∀ v z y, -r≤ inner ℝ (P v-P z) (P y-P z)) + (hl : ∀ v z y, c v=c z → |inner ℝ (P v-P z) (P y-P z)|≤‖h v-h z‖^2) : + ∀ v y z, -min (cappedDistance c h r v z) (cappedDistance c h r y z)≤ + inner ℝ (P v-P z) (P y-P z) := by + intro v y z + have h1 : -cappedDistance c h r v z≤ inner ℝ (P v-P z) (P y-P z) := by + by_cases hc : c v=c z + · have hh := (abs_le.mp (hl v z y hc)).1 + simp only [cappedDistance,hc,ite_true,neg_min_eq] + exact max_le (hg v z y) hh + · simpa only [cappedDistance,hc,ite_false] using hg v z y + have h2 : -cappedDistance c h r y z≤ inner ℝ (P v-P z) (P y-P z) := by + by_cases hc : c y=c z + · have hh := (abs_le.mp (hl y z v hc)).1 + rw [real_inner_comm] at hh + simp only [cappedDistance,hc,ite_true,neg_min_eq] + exact max_le (hg v z y) hh + · simpa only [cappedDistance,hc,ite_false] using hg v z y + rw [neg_min_eq] + exact max_le h1 h2 + +omit [InnerProductSpace ℝ H] [Fintype C] in + +lemma repair_from_angles (c : ι → C) (x : ι → J → ℝ) {L r : ℝ} (hL : 0≤L) (hr : 0 L) (fun _ => hL) + have hloc (v z y : ι) (hc : c v=c z) : |inner ℝ (P v-P z) (P y-P z)|≤‖h v-h z‖^2 := by + rw [hh v z hc]; exact hl v z y hc + obtain ⟨Q,Z,hQ,hZ,htri,hint,hcap,hsmall,hzero⟩ := triangle_repair c h ht hr P (capped_angle c h P hg hloc) + refine ⟨Z,htri,?_,?_,?_⟩ + · intro v w + rw [hZ] + calc + _ ≤ |‖P v-P w‖^2-q*‖θ v-θ w‖|+|‖Q v-Q w‖^2| := by + convert abs_add_le (‖P v-P w‖^2-q*‖θ v-θ w‖) (‖Q v-Q w‖^2) using 1 + congr 1 + ring + _ ≤ e+8*r := add_le_add (hm v w) (by simpa only [abs_sq] using hcap v w) + · intro v w hc hpos hbound + have hqr := hsmall v w hc (by rwa [hh v w hc]) (by rwa [hh v w hc]) + rw [hh v w hc] at hqr + have hp := hl v w v hc + rw [real_inner_self_eq_norm_sq,abs_of_nonneg (sq_nonneg _)] at hp + rw [hZ] + nlinarith + · intro v w hc hz + have hq := hzero v w hc (by rwa [hh v w hc]) + have hp := hl v w v hc + rw [hz,real_inner_self_eq_norm_sq,abs_of_nonneg (sq_nonneg _)] at hp + have hzsq : ‖Z v-Z w‖^2=0 := by rw [hZ,hq,sub_self,norm_zero]; nlinarith [sq_nonneg ‖P v-P w‖] + exact sub_eq_zero.mp (norm_eq_zero.mp (sq_eq_zero_iff.mp hzsq)) + +end +end UniformSparsestCut.ChartMetric + +namespace UniformSparsestCut.GramMetric +open scoped BigOperators RealInnerProductSpace +noncomputable section +variable {m N S : ℕ} {V : Type u6} [Fintype V] +local notation "E" => EuclideanSpace ℝ (Fin m) +local notation "F" => EuclideanSpace ℝ (Fin N) + +def localCost (N S : ℕ) (q k ε a b R γ : ℝ) : ℝ := + 2*((k+q*γ*(4*k)+ε*((S:ℝ)*N)*(9*k/ε)*(k/ε*R))*Real.log (b/a)+ + (ε*((S:ℝ)*N)*(2*q)*(4*k)*(1+(k/ε*R)^2+2*(k/ε*R)))/a) + +def macroCost (N S : ℕ) (q k ε a b R T Rpos : ℝ) : ℝ := + q*(2*a+(2*T)^2/b)+4*ε*((S:ℝ)*N)*Real.log (b/a)+ + 4*(ε*((S:ℝ)*N)*((k/ε*R)^2+2*(k/ε*R))*Real.log (b/a))+2*KernelApprox.cstar*q*Rpos + +lemma localCost_nonneg {q k ε a b R γ : ℝ} (hq : 0≤q) (hk : 0≤k) + (hε : 0<ε) (ha : 0 q⁻¹ • g (c v) i)) (B (c v)) (x v)‖≤R) + (hpos : ∀ v, ‖B (c v) (x v)-θ v‖≤Rpos) + (he : 0≤ macroCost N S q k ε a b R T Rpos) (hr : 0 g j.1 j.2 + let Θ : V → E := fun v => B (c v) (x v) + let α : V → Fin S × Fin N → ℝ := fun v => ChartKernel.alpha g B q k ε (c v) (x v) + obtain ⟨P,hP⟩ := CommonKernel.gram_realization G Θ α hq.le hε.le ha hab + have hPK (v w : V) : inner ℝ (P v) (P w)=Profile.kernel G q ε a b (Θ v) (Θ w) (α v) (α w) := by + rw [hP,MetricKernel.gram_eq_kernel G Θ α q ε ha hab] + have hPD (v w : V) : ‖P v-P w‖^2=ChartAngles.distance G q ε a b (Θ v) (Θ w) (α v) (α w) := by + rw [norm_sub_sq_real] + simp only [← real_inner_self_eq_norm_sq,hPK,ChartAngles.distance] + ring + have hα (v : V) (j : Fin S × Fin N) : |α v j|≤k/ε*R := + ChartKernel.alpha_norm_bound g B hk hε (c v) (x v) (hrx v) j + have hd (v w : V) : |‖P v-P w‖^2-KernelApprox.cstar*q*‖θ v-θ w‖|≤ macroCost N S q k ε a b R T Rpos := by + rw [hPD,norm_sub_rev (θ v) (θ w)] + have hh := ChartAngles.rounded_distance_error (T := 2*T) G hq.le hε.le ha hab + (mul_nonneg (div_nonneg hk hε.le) hR) (Θ v) (Θ w) (θ v) (θ w) (α v) (α w) + (hα v) (hα w) (hpos v) (hpos w) ((norm_sub_le _ _).trans (by dsimp only [Θ]; linarith [hx v,hx w])) + simpa only [Fintype.card_prod,Fintype.card_fin,Nat.cast_mul,macroCost] using hh + have hlocal (v z y : V) (hc : c v=c z) : + |inner ℝ (P v-P z) (P y-P z)|≤localCost N S q k ε a b R γ*(∑ i, |x v i-x z i|) := by + have hb (w : V) := ChartAngles.local_profile g B hq hk hk1 hε ha hab hT hR hγ hkq hg hB hf + (c z) (c w) (x z) (x v) (x w) (hx z) (by simpa only [← hc] using hx v) (hx w) + (hrx z) (by simpa only [← hc] using hrx v) (hrx w) + have hy := hb y + have hz := hb z + rw [inner_sub_left,inner_sub_right,inner_sub_right] + simp only [hPK,Θ,α,G,hc] at hy hz ⊢ + have hy' := abs_le.mp hy + have hz' := abs_le.mp hz + rw [abs_le] + unfold localCost + constructor <;> linarith + apply ChartMetric.repair_from_angles c (fun v i => x v i) + (localCost_nonneg hq.le hk hε ha hab hR hγ) hr P θ hd ?_ hlocal + intro v z y + exact (neg_le_neg her).trans (ChartAngles.global_angle P θ + (mul_nonneg KernelApprox.cstar_pos.le hq.le) he hd v z y) + +end +end UniformSparsestCut.GramMetric + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/CommonKernel.lean b/lean/OAI/Combinatorics/SparsestCut/CommonKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..5e496a5b8d9af6206ce73d37996a48aa16887a97 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/CommonKernel.lean @@ -0,0 +1,128 @@ +import OAI.Combinatorics.SparsestCut.KernelApprox + +namespace OAI + +universe u1 u2 u3 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.CommonKernel +open MeasureTheory Set +open scoped RealInnerProductSpace BigOperators Matrix + +variable {ι : Type u1} [Fintype ι] + +lemma integral_posSemidef (K : ℝ → Matrix ι ι ℝ) {a b : ℝ} (hab : a ≤ b) + (hK : ∀ t ∈ Icc a b, (K t).PosSemidef) + (hi : ∀ i j, IntervalIntegrable (fun t => K t i j) volume a b) : + Matrix.PosSemidef (fun i j => ∫ t in a..b, K t i j) := by + apply Matrix.PosSemidef.of_dotProduct_mulVec_nonneg + · apply Matrix.IsHermitian.ext + intro i j + simp only [star_trivial] + apply intervalIntegral.integral_congr + intro t ht + simpa using (hK t (by simpa [uIcc_of_le hab] using ht)).isHermitian.apply i j + · intro c + have h : 0 ≤ ∫ t in a..b, star c ⬝ᵥ (K t *ᵥ c) := + intervalIntegral.integral_nonneg hab (fun t ht => (hK t ht).dotProduct_mulVec_nonneg c) + simp only [dotProduct, Matrix.mulVec, Pi.star_apply, star_trivial] at h ⊢ + have hrow (i : ι) : IntervalIntegrable (fun t => ∑ j, K t i j*c j) volume a b := by + convert IntervalIntegrable.sum Finset.univ (fun j _ => (hi i j).mul_const (c j)) using 1 + funext t; simp only [Finset.sum_apply] + rw [intervalIntegral.integral_finsetSum (fun i _ => (hrow i).const_mul (c i))] at h + simp_rw [intervalIntegral.integral_const_mul, + intervalIntegral.integral_finsetSum (fun j _ => (hi _ j).mul_const (c j)), + intervalIntegral.integral_mul_const] at h + exact h + +def circle (t q : ℝ) : EuclideanSpace ℝ (Fin 2) := + WithLp.toLp 2 ![Real.cos t-q*Real.sin t, Real.sin t+q*Real.cos t] + +lemma circle_inner (t v q p : ℝ) : + inner ℝ (circle t q) (circle v p) = + (1+q*p)*Real.cos (v-t)+(q-p)*Real.sin (v-t) := by + simp [circle, PiLp.inner_apply, Fin.sum_univ_two, Real.cos_sub, Real.sin_sub] + + ring + +lemma circle_self (t q : ℝ) : ‖circle t q‖^2 = 1+q^2 := by + rw [← real_inner_self_eq_norm_sq, circle_inner] + simp [pow_two] + +variable {E : Type u2} [NormedAddCommGroup E] [InnerProductSpace ℝ E] +variable {κ : Type u3} [Fintype κ] + +def gram (g : κ → E) (θ : ι → E) (α : ι → κ → ℝ) (M ε a b : ℝ) : Matrix ι ι ℝ := + fun v w => M*(∫ σ in a..b, Real.exp (-‖θ v-θ w‖^2/(2*σ^2))) + + ε*∑ k, ∫ σ in a..b, + inner ℝ (circle (inner ℝ (g k) (θ v)/σ) (α v k)) + (circle (inner ℝ (g k) (θ w)/σ) (α w k)) / σ + +omit [Fintype ι] [InnerProductSpace ℝ E] in +lemma gaussian_integrable (θ : ι → E) {a b : ℝ} (ha : 0 < a) (hab : a ≤ b) (v w : ι) : + IntervalIntegrable (fun σ => Real.exp (-‖θ v-θ w‖^2/(2*σ^2))) volume a b := by + apply ContinuousOn.intervalIntegrable + rw [uIcc_of_le hab] + apply Real.continuous_exp.comp_continuousOn + apply continuousOn_const.div (by fun_prop) + intro σ hσ + have hp : 0 < σ := ha.trans_le hσ.1 + positivity + +omit [Fintype ι] [Fintype κ] in +lemma circle_integrable (g : κ → E) (θ : ι → E) (α : ι → κ → ℝ) + {a b : ℝ} (ha : 0 < a) (hab : a ≤ b) (v w : ι) (k : κ) : + IntervalIntegrable (fun σ => inner ℝ (circle (inner ℝ (g k) (θ v)/σ) (α v k)) + (circle (inner ℝ (g k) (θ w)/σ) (α w k))/σ) volume a b := by + apply ContinuousOn.intervalIntegrable + rw [uIcc_of_le hab] + have hne : ∀ σ ∈ Icc a b, σ ≠ 0 := fun σ hσ => (ha.trans_le hσ.1).ne' + have h1 : ContinuousOn (fun σ : ℝ => inner ℝ (g k) (θ v)/σ) (Icc a b) := + continuousOn_const.div continuousOn_id hne + have h2 : ContinuousOn (fun σ : ℝ => inner ℝ (g k) (θ w)/σ) (Icc a b) := + continuousOn_const.div continuousOn_id hne + simp only [circle_inner] + exact (((continuousOn_const.mul (Real.continuous_cos.comp_continuousOn (h2.sub h1))).add + (continuousOn_const.mul (Real.continuous_sin.comp_continuousOn (h2.sub h1)))).div continuousOn_id hne) + +lemma gram_posSemidef (g : κ → E) (θ : ι → E) (α : ι → κ → ℝ) + {M ε a b : ℝ} (hM : 0 ≤ M) (hε : 0 ≤ ε) (ha : 0 < a) (hab : a ≤ b) : + (gram g θ α M ε a b).PosSemidef := by + have hG := integral_posSemidef + (fun σ v w => Real.exp (-‖θ v-θ w‖^2/(2*σ^2))) hab + (fun σ hσ => TriangleRepair.gaussian_posSemidef θ (by have := ha.trans_le hσ.1; positivity)) + (gaussian_integrable θ ha hab) + have hC (k : κ) := integral_posSemidef + (fun σ v w => inner ℝ (circle (inner ℝ (g k) (θ v)/σ) (α v k)) + (circle (inner ℝ (g k) (θ w)/σ) (α w k))/σ) hab + (fun σ hσ => by + have h := (TriangleRepair.gram_posSemidef + (fun v => circle (inner ℝ (g k) (θ v)/σ) (α v k))).smul + (inv_nonneg.mpr (ha.trans_le hσ.1).le) + change Matrix.PosSemidef (fun v w => σ⁻¹ * + inner ℝ (circle (inner ℝ (g k) (θ v)/σ) (α v k)) + (circle (inner ℝ (g k) (θ w)/σ) (α w k))) at h + simpa only [div_eq_inv_mul] using h) + (fun v w => circle_integrable g θ α ha hab v w k) + have hS := TriangleRepair.sum_posSemidef Finset.univ _ (fun k _ => hC k) + convert (hG.smul hM).add (hS.smul hε) using 1 + ext v w + change M * _ + ε * (∑ k, _) = M * _ + ε * ((∑ k : κ, (_ : Matrix ι ι ℝ)) v w) + congr 2 + symm + exact Matrix.sum_apply v w Finset.univ _ + +lemma gram_realization (g : κ → E) (θ : ι → E) (α : ι → κ → ℝ) + {M ε a b : ℝ} (hM : 0 ≤ M) (hε : 0 ≤ ε) (ha : 0 < a) (hab : a ≤ b) : + ∃ P : ι → EuclideanSpace ℝ ι, ∀ v w, inner ℝ (P v) (P w) = gram g θ α M ε a b v w := + TriangleRepair.exists_gram (gram_posSemidef g θ α hM hε ha hab) + +end UniformSparsestCut.CommonKernel + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/ConcreteCells.lean b/lean/OAI/Combinatorics/SparsestCut/ConcreteCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..4abdea331042499651c92b41322a7fcc2f1b406b --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/ConcreteCells.lean @@ -0,0 +1,156 @@ +import OAI.Combinatorics.SparsestCut.EuclideanCells + +namespace OAI + +universe u1 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.ConcreteCells +open MeasureTheory Set Filter CoordinateSplit EuclideanCells +open scoped BigOperators RealInnerProductSpace +noncomputable section +variable {m N S : ℕ} {A : Type u1} [Fintype A] +local notation "E" => EuclideanSpace ℝ (Fin (m+1)) +local notation "Z" => EuclideanSpace ℝ (Fin m) + +def domain : Set (ℝ × Z) := split.symm ⁻¹' RoundedCharts.cube 2 + +def labels (τ : ℝ) : Finset ℤ := Finset.Icc (-⌈4*Real.sqrt (m+1:ℕ)/τ+1⌉) ⌈4*Real.sqrt (m+1:ℕ)/τ+1⌉ + +lemma domain_open : IsOpen (domain (m := m)) := by + apply IsOpen.preimage split.symm.continuous + change IsOpen {θ : E | ∀ j, |θ j|<2} + simp only [ofPred_forall] + apply isOpen_iInter_of_finite + intro j + exact isOpen_lt (by fun_prop) continuous_const + +lemma ell_eq (u : Fin N → E) (hu : ∀ i, u i 0≠0) (x : ℝ × Z) (i : Fin N) : + ProductSlice.ell (B u) (pivot u) i x=inner ℝ (u i) (split.symm x) := by + have h := normalized_form (u i) (hu i) (split.symm x) + simp only [ContinuousLinearEquiv.apply_symm_apply] at h + change pivot u i*ProductSlice.form (B u i) x=_ + change u i 0*(x.1-slope (u i) x.2)=_ + rw [← h] + field_simp [hu i] + +lemma regular_eq (u : Fin N → E) (hu : ∀ i, u i 0≠0) (τ : ℝ) (x : ℝ × Z) : + CellInterface.regular (ProductSlice.ell (B u) (pivot u)) τ x ↔ + RoundedCharts.regular u τ (split.symm x) := by + simp only [CellInterface.regular,RoundedCharts.regular,ell_eq u hu] +lemma label_eq (u : Fin N → E) (hu : ∀ i, u i 0≠0) (τ : ℝ) (x : ℝ × Z) : + CellInterface.label (ProductSlice.ell (B u) (pivot u)) τ x = + RoundedCharts.integerLabel u τ (split.symm x) := by + ext i + simp only [CellInterface.label,RoundedCharts.integerLabel,ell_eq u hu] + +lemma labels_bound (u : Fin N → E) (hu : ∀ i, u i 0≠0) {τ : ℝ} (hτ : 0<τ) + (hn : ∀ i, ‖u i‖≤2) (x : ℝ × Z) (hx : x∈domain) + (_hr : CellInterface.regular (ProductSlice.ell (B u) (pivot u)) τ x) (i : Fin N) : + CellInterface.label (ProductSlice.ell (B u) (pivot u)) τ x i∈labels (m := m) τ := by + rw [label_eq u hu] + have hb := (RoundedCharts.integerLabel_bound u hτ hn hx i).trans + (Int.le_ceil (4*Real.sqrt (m+1:ℕ)/τ+1)) + apply Finset.mem_Icc.mpr + constructor + · exact_mod_cast (abs_le.mp hb).1 + · exact_mod_cast (abs_le.mp hb).2 + +def mapVertex (u : Fin S → Fin N → E) (hu : ∀ s i, u s i 0≠0) (τ : ℝ) (s : Fin S) + (v : CellInterface.LabelVertex (ProductSlice.ell (B (u s)) (pivot (u s))) τ domain) : RoundedCharts.Vertex u τ := + ⟨(s,v.val),by + obtain ⟨x,hx,hr,hl⟩ := v.property + refine ⟨split.symm x,hx,(regular_eq (u s) (hu s) τ x).mp hr,?_⟩ + exact (label_eq (u s) (hu s) τ x).symm.trans hl⟩ + +def function (u : Fin S → Fin N → E) (hu : ∀ s i, u s i 0≠0) (τ : ℝ) + (F : RoundedCharts.Vertex u τ → A → ℝ) (s : Fin S) (a : A) : E → ℝ := + chartFunction (u s) τ (labels (m := m) τ) domain (fun v => F (mapVertex u hu τ s v)) a + +omit [Fintype A] in +lemma function_eq (u : Fin S → Fin N → E) (hu : ∀ s i, u s i 0≠0) {τ : ℝ} + (hτ : 0<τ) (hn : ∀ s i, ‖u s i‖≤2) (F : RoundedCharts.Vertex u τ → A → ℝ) + (s : Fin S) (x : E) (hx : x∈RoundedCharts.cube 2) (hr : RoundedCharts.regular (u s) τ x) (a : A) : + function u hu τ F s a x=F ⟨(s,RoundedCharts.integerLabel (u s) τ x),x,hx,hr,rfl⟩ a := by + have hx' : split x∈domain := by simpa only [domain,mem_preimage,ContinuousLinearEquiv.symm_apply_apply] using hx + have hr' : CellInterface.regular (ProductSlice.ell (B (u s)) (pivot (u s))) τ (split x) := by + rw [regular_eq (u s) (hu s)] + simpa only [ContinuousLinearEquiv.symm_apply_apply] using hr + rw [function,chartFunction_eq (u s) (hu s) hτ _ _ (labels_bound (u s) (hu s) hτ (hn s)) _ x hx' hr'] + congr 1 + apply Subtype.ext + change (s,CellInterface.label (ProductSlice.ell (B (u s)) (pivot (u s))) τ (split x))=(s,RoundedCharts.integerLabel (u s) τ x) + congr 1 + simpa only [ContinuousLinearEquiv.symm_apply_apply] using label_eq (u s) (hu s) τ (split x) + +omit [Fintype A] in +lemma function_measurable (u : Fin S → Fin N → E) (hu : ∀ s i, u s i 0≠0) (τ : ℝ) + (F : RoundedCharts.Vertex u τ → A → ℝ) (s : Fin S) (a : A) : Measurable (function u hu τ F s a) := + chartFunction_measurable _ _ _ _ _ _ +omit [Fintype A] in +lemma function_bounded (u : Fin S → Fin N → E) (hu : ∀ s i, u s i 0≠0) (τ : ℝ) + (F : RoundedCharts.Vertex u τ → A → ℝ) {M : ℝ} (hM : 0≤M) (hF : ∀ v a, |F v a|≤M) + (s : Fin S) (a : A) (x : E) : |function u hu τ F s a x|≤M := by + exact CellInterface.extension_bounded (ProductSlice.ell (B (u s)) (pivot (u s))) (pivot (u s)) τ (labels (m := m) τ) domain (fun v => F (mapVertex u hu τ s v)) hM (fun v a => hF _ a) _ a +omit [Fintype A] in +lemma function_integrable (u : Fin S → Fin N → E) (hu : ∀ s i, u s i 0≠0) (τ : ℝ) + (F : RoundedCharts.Vertex u τ → A → ℝ) {M : ℝ} (hM : 0≤M) (hF : ∀ v a, |F v a|≤M) + (s : Fin S) (a : A) : LocallyIntegrable (function u hu τ F s a) := + chartFunction_integrable _ _ _ _ _ hM (fun _v a => hF _ a) a + +lemma support_domain {lam : ℝ} (hlam : 0 ?_) j + · change |θ 0-t|<2 + exact (abs_sub _ _).trans_lt (by linarith [hθ 0]) + · change |θ i.succ-z i|<2 + exact (abs_sub _ _).trans_lt (by linarith [hθ i.succ,hz' i]) + +lemma normal_coefficients (u : Fin S → Fin N → E) (hu : ∀ s i, u s i 0≠0) + (hnp : ∀ s i j, i≠j → ∀ t : ℝ, u s i≠t • u s j) (hn : ∀ s i, ‖u s i‖≤2) + {τ lam : ℝ} (hτ : 0<τ) (hlam : 0 F (mapVertex u hu τ s v)) + hM hJ (fun v a => hbound _ a) + (fun vp vm i hi hj => hF _ _ i rfl hi hj) θ (support_domain hlam hlam1 θ hθ) (hsmall s) + +lemma regular_sub (u : Fin N → E) (hu : ∀ i, u i 0≠0) (τ : ℝ) (θ : E) : + ∀ᵐ z : E, RoundedCharts.regular u τ (θ-z) := by + have hh := RoundedCharts.ae_regular u τ (fun i h => hu i (by rw [h]; rfl)) + have hmp := (measurePreserving_add_left volume θ).comp (Measure.measurePreserving_neg (volume : Measure E)) + simpa only [Function.comp_apply, sub_eq_add_neg] using hmp.quasiMeasurePreserving.ae hh + +end +end UniformSparsestCut.ConcreteCells + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/ContractionAverage.lean b/lean/OAI/Combinatorics/SparsestCut/ContractionAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..b6f5e40fd5713ab7b2cfb885002be33f634a6b76 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/ContractionAverage.lean @@ -0,0 +1,91 @@ +import OAI.Combinatorics.SparsestCut.CubeTransfer + +namespace OAI + +universe u1 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.SourceContraction +open MeasureTheory +open scoped BigOperators RealInnerProductSpace +open SourceParameters SourceCharts SourceMetric +noncomputable section +variable {m : ℕ} +local notation "d" => (m+1:ℕ) +local notation "E" => EuclideanSpace ℝ (Fin d) +local notation "μ" => (CubePoincare.cube (m:=d)) +lemma integral_bound (f : PivotFamily.PFamily d) (hm : 3000 ≤ d) (hl : 1≤Real.log d) (hH : H ≤ d) + (Z : V f → EuclideanSpace ℝ (V f)) + (hmac : ∀ v w, |‖Z v-Z w‖^2-KernelApprox.cstar*Real.sqrt d* + ‖B f (NeZero.pos d) v.val.1 (RoundedCharts.coordinate (u f) (p d 2000) v)- + B f (NeZero.pos d) w.val.1 (RoundedCharts.coordinate (u f) (p d 2000) w)‖|≤err (m:=d)+8*p d 8) + (hlocal : ∀ v w, v.val.1=w.val.1 → (∑ i, |RoundedCharts.coordinate (u f) (p d 2000) v i- + RoundedCharts.coordinate (u f) (p d 2000) w i|)=p d 2000 → + ‖Z v-Z w‖^2≤50000000*p d 2000*p d 5*(Real.log d)^2) + {A : Type u1} [Fintype A] (F : V f → A → ℝ) + (hcon : ∀ v w, (∑ a, |F v a-F w a|)≤‖Z v-Z w‖^2) + (s0 : Fin (d^3)) : + (∫ z : E × E, ∑ a, |ConcreteCells.function (u f) (fun s i => + abs_pos.mp ((show 0<1/((d:ℝ)^30*Real.sqrt d) by positivity).trans + (u_pivot f (Nat.succ_pos m) s i 0))) (p d 2000) F s0 a z.1- + ConcreteCells.function (u f) (fun s i => + abs_pos.mp ((show 0<1/((d:ℝ)^30*Real.sqrt d) by positivity).trans + (u_pivot f (Nat.succ_pos m) s i 0))) (p d 2000) F s0 a z.2| ∂(μ).prod μ)≤C*weight d := by + classical + have hm0 := Nat.succ_pos m + have hm1 : 1 ≤ d := by omega + have hx : (1:ℝ) ≤ d := by exact_mod_cast hm1 + have hx0 : (0:ℝ) Finset.sum_nonneg (fun a _ => abs_nonneg _)) + have hbound (v : V f) (a : A) : |F v a|≤M := by + exact (Finset.single_le_sum (fun a _ => abs_nonneg (F v a)) (Finset.mem_univ a)).trans + (Finset.single_le_sum (fun v _ => Finset.sum_nonneg (fun a _ => abs_nonneg (F v a))) (Finset.mem_univ v)) + have hclose : ∀ s t x (hx : x∈RoundedCharts.cube 2) + (hs : RoundedCharts.regular (u f s) (p d 2000) x) (ht : RoundedCharts.regular (u f t) (p d 2000) x), + (∑ a, |F (ContractionCore.vertex (u f) (p d 2000) s x hx hs) a- + F (ContractionCore.vertex (u f) (p d 2000) t x hx ht) a|)≤C₀*p d 8 := by + intro s t x hx hs ht + have hh := (abs_le.mp (macro_bound f hm Z hmac s t x x hx hx hs ht)).2 + simp only [sub_self,norm_zero,mul_zero,sub_zero] at hh + exact (hcon _ _).trans hh + have hmacro : ∀ s x y (hx : x∈RoundedCharts.cube 2) (hy : y∈RoundedCharts.cube 2) + (hs : RoundedCharts.regular (u f s) (p d 2000) x) (ht : RoundedCharts.regular (u f s) (p d 2000) y), + (∑ a, |F (ContractionCore.vertex (u f) (p d 2000) s x hx hs) a- + F (ContractionCore.vertex (u f) (p d 2000) s y hy ht) a|)≤KernelApprox.cstar*Real.sqrt d*‖x-y‖+C₀*p d 8 := by + intro s x y hx hy hs ht + have hh := (abs_le.mp (macro_bound f hm Z hmac s s x y hx hy hs ht)).2 + exact (hcon _ _).trans (by simpa only [ContractionCore.vertex,SourceMetric.vertex,add_comm] using (sub_le_iff_le_add.mp hh)) + have hjump : ∀ (vp vm : V f) (i : Fin (d^6)), vp.val.1=vm.val.1 → vp.val.2 i=vm.val.2 i+1 → + (∀ j, j≠i → vp.val.2 j=vm.val.2 j) → (∑ a, |F vp a-F vm a|)≤50000000*p d 2000*p d 5*(Real.log d)^2 := by + intro vp vm i hc hi hj + exact (hcon vp vm).trans (hlocal vp vm hc (one_step f vp vm i hi hj)) + have h := ContractionAverage.average (u f) hu0 (u_nonparallel f hm0) (fun s i => (u_norm f hm0 s i).2) + hτ hlam hlam1 (by positivity : 0≤11*Real.sqrt (Real.log d)/Real.sqrt d) + (by unfold p; positivity : 0≤50000000*p d 2000*p d 5*(Real.log d)^2) + (mul_nonneg KernelApprox.cstar_pos.le (Real.sqrt_nonneg _)) + F hM hbound hclose hmacro hjump (fun s i => small f hm1 hH s i 0) (good_dual f hm0) s0 + exact h.trans (contraction_numeric hm1 hl) +end +end UniformSparsestCut.SourceContraction + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/ContractionBounds.lean b/lean/OAI/Combinatorics/SparsestCut/ContractionBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..6e6c98f96e810d287fc78827235a2ccc0acd9f08 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/ContractionBounds.lean @@ -0,0 +1,212 @@ +import OAI.Combinatorics.SparsestCut.Mollifier + +namespace OAI + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.KernelGeometry +open MeasureTheory Set ProductMollifier +open scoped BigOperators Topology +noncomputable section +variable {m : ℕ} +local notation "E" => EuclideanSpace ℝ (Fin m) +def κ (lam : ℝ) : E → ℝ := kernel (density lam) +def L (lam : ℝ) : ℝ := lam⁻¹*(∫ t, |deriv rho t|) +lemma smooth (lam : ℝ) : ContDiff ℝ (⊤:ℕ∞) (κ (m := m) lam) := + kernel_smooth _ (density_smooth _) +lemma compact {lam : ℝ} (hlam : 0 (density_support hlam hx).le) +lemma nonneg {lam : ℝ} (hlam : 0≤lam) (z : E) : 0≤κ lam z := + kernel_nonneg (density_nonneg hlam) z +lemma integral_one {lam : ℝ} (hlam : 0 abs_nonneg _)) +lemma support_coord {lam : ℝ} (hlam : 0 (support_coord hlam h j).le) hc) hz +lemma shifted_mem {lam : ℝ} (hlam : 0 (support_coord hlam hz j).le) +lemma partial_integrable {lam : ℝ} (hlam : 0 |fderiv ℝ (κ lam) z (EuclideanSpace.single j 1)|) := by + have hc := (smooth (m := m) lam).continuous_fderiv (by simp) + exact ((hc.clm_apply continuous_const).integrable_of_hasCompactSupport + ((compact (m := m) hlam).fderiv_apply ℝ (EuclideanSpace.single j 1))).abs +lemma partial_integral {lam : ℝ} (hlam : 0 ((density_smooth lam).differentiable (by simp) t).hasDerivAt) + (density_nonneg hlam.le) (density_integral hlam),density_deriv_integral hlam] + rfl +end +end UniformSparsestCut.KernelGeometry + +namespace UniformSparsestCut.SourceContraction +open scoped BigOperators RealInnerProductSpace +open SourceParameters SourceCharts SourceMetric +open MeasureTheory +noncomputable section +def H : ℝ := ∫ t, |deriv ProductMollifier.rho t| +lemma H_nonneg : 0≤H := integral_nonneg (fun _ => abs_nonneg _) +def weight (m : ℕ) : ℝ := Real.sqrt m*(Real.log m)^2*Real.sqrt (Real.log m) +def C : ℝ := 2*(KernelApprox.cstar+C₀)+Real.pi*(1100000000+C₀*H)+1 +lemma C_pos : 0 EuclideanSpace ℝ (Fin m) +include hm +lemma good_dual (D : StrongDual ℝ E) : + ∃ good : Finset (Fin (m^3)), ((m^3:ℕ):ℝ)/2≤good.card ∧ + ∀ s∈good, ∀ i, |D (u f s i)|≤(11*Real.sqrt (Real.log m)/Real.sqrt m)*‖D‖ := by + classical + by_cases hz : D=0 + · refine ⟨Finset.univ,?_,?_⟩ + · simp only [Finset.card_univ,Fintype.card_fin]; linarith [show (0:ℝ)≤((m^3:ℕ):ℝ) by positivity] + · intro s hs i; simp [hz] + let w : E := (InnerProductSpace.toDual ℝ E).symm D + have hwn : ‖w‖=‖D‖ := (InnerProductSpace.toDual ℝ E).symm.norm_map D + have hw0 : 0<‖w‖ := by rw [hwn]; exact norm_pos_iff.mpr hz + let v : E := ‖w‖⁻¹ • w + have hv : ‖v‖=1 := by simp [v,norm_smul,hw0.ne'] + have hw : w=‖w‖ • v := by simp [v,smul_smul,hw0.ne'] + let Q := 11*Real.sqrt (Real.log m) + let good : Finset (Fin (m^3)) := Finset.univ.filter (fun s => f.g s∉Directions.projectionBad Q v) + have hb := f.good v hv + have hcard : Directions.badCount (Directions.projectionBad Q v) f.g+good.card=m^3 := by + simpa only [Directions.badCount,good,Finset.card_univ,Fintype.card_fin] using + (Finset.card_filter_add_card_filter_not (s := (Finset.univ : Finset (Fin (m^3)))) (fun s => f.g s∈Directions.projectionBad Q v)) + refine ⟨good,?_,?_⟩ + · have hc : ((Directions.badCount (Directions.projectionBad Q v) f.g):ℝ)+(good.card:ℝ)=((m^3:ℕ):ℝ) := by exact_mod_cast hcard + change ((Directions.badCount (Directions.projectionBad Q v) f.g):ℝ)≤((m^3:ℕ):ℝ)/2 at hb + linarith + · intro s hs i + have hp : |inner ℝ v (f.g s i)|≤Q := by + by_contra h + exact (Finset.mem_filter.mp hs).2 ⟨i,lt_of_not_ge h⟩ + have hq : 0 rw [hw] + rw [real_inner_smul_left,real_inner_smul_right,abs_mul,abs_mul, + abs_of_nonneg (norm_nonneg _),abs_of_pos (inv_pos.mpr hq)] + ring + rw [he] + calc + _ ≤ ‖w‖*(Real.sqrt m)⁻¹*Q := mul_le_mul_of_nonneg_left hp (by positivity) + _ = _ := by rw [hwn]; unfold Q; ring +end +end UniformSparsestCut.SourceCharts + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/ContractionCore.lean b/lean/OAI/Combinatorics/SparsestCut/ContractionCore.lean new file mode 100644 index 0000000000000000000000000000000000000000..73ef8c4ca38c2e18c3d485125ecfd604020783dd --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/ContractionCore.lean @@ -0,0 +1,106 @@ +import OAI.Combinatorics.SparsestCut.GradientBudget + +namespace OAI + +universe u1 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.ContractionCore +open MeasureTheory Set Filter +open scoped BigOperators RealInnerProductSpace +noncomputable section +variable {m N S : ℕ} {A : Type u1} [Fintype A] +local notation "E" => EuclideanSpace ℝ (Fin (m+1)) + +def vertex (u : Fin S → Fin N → E) (τ : ℝ) (s : Fin S) (x : E) + (hx : x∈RoundedCharts.cube 2) (hr : RoundedCharts.regular (u s) τ x) : RoundedCharts.Vertex u τ := + ⟨(s,RoundedCharts.integerLabel (u s) τ x),x,hx,hr,rfl⟩ + +lemma chart_mismatch (u : Fin S → Fin N → E) (hu : ∀ s i, u s i 0≠0) + {τ lam R : ℝ} (hτ : 0<τ) (hlam : 0 ConcreteCells.function_integrable u hu τ F hM hbound s a) + (fun a => ConcreteCells.function_integrable u hu τ F hM hbound t a) x + (KernelGeometry.partial_integrable hlam) (KernelGeometry.partial_integral hlam) + filter_upwards [ConcreteCells.regular_sub (u s) (hu s) τ x, + ConcreteCells.regular_sub (u t) (hu t) τ x] with z hzs hzt + rintro ⟨j,hj⟩ + have hmem : x-z∈RoundedCharts.cube 2 := KernelGeometry.derivative_shifted_mem hlam hlam1 x hx hj + simp_rw [ConcreteCells.function_eq u hu hτ hn F s (x-z) hmem hzs, + ConcreteCells.function_eq u hu hτ hn F t (x-z) hmem hzt] + exact hclose s t (x-z) hmem hzs hzt + +lemma smoothing_error (u : Fin S → Fin N → E) (hu : ∀ s i, u s i 0≠0) + {τ lam G R : ℝ} (hτ : 0<τ) (hlam : 0 ConcreteCells.function_integrable u hu τ F hM hbound s a) x + filter_upwards [ConcreteCells.regular_sub (u s) (hu s) τ x] with z hzr hz + have hxU : x∈RoundedCharts.cube 2 := fun j => (hx j).trans_lt (by norm_num) + have hmem : x-z∈RoundedCharts.cube 2 := KernelGeometry.shifted_mem hlam hlam1 x hx (subset_closure hz) + simp_rw [ConcreteCells.function_eq u hu hτ hn F s (x-z) hmem hzr, + ConcreteCells.function_eq u hu hτ hn F s x hxU hr] + have h := hmacro s (x-z) x hmem hxU hzr hr + have hnz : ‖x-z-x‖=‖z‖ := by rw [sub_sub_cancel_left,norm_neg] + rw [hnz] at h + exact h.trans (add_le_add (mul_le_mul_of_nonneg_left (KernelGeometry.norm_bound hlam hz) hG) le_rfl) + +lemma gradient_bound (u : Fin S → Fin N → E) (hu : ∀ s i, u s i 0≠0) + (hnp : ∀ s i j, i≠j → ∀ t : ℝ, u s i≠t • u s j) (hn : ∀ s i, ‖u s i‖≤2) + {τ lam δ R J : ℝ} (hτ : 0<τ) (hlam : 0 hβ s i) + _ = _ := by simp + · intro s + exact chart_mismatch u hu hτ hlam hlam1 hn F hM hbound hclose s s0 x hx + · simpa only [Fintype.card_fin] using Nat.zero_lt_of_lt s0.isLt + +end +end UniformSparsestCut.ContractionCore + +end + +end OAI diff --git a/lean/OAI/Combinatorics/SparsestCut/CoordinateSplit.lean b/lean/OAI/Combinatorics/SparsestCut/CoordinateSplit.lean new file mode 100644 index 0000000000000000000000000000000000000000..c65b1fb19b10038f4565cff42fec37e33e4560b9 --- /dev/null +++ b/lean/OAI/Combinatorics/SparsestCut/CoordinateSplit.lean @@ -0,0 +1,99 @@ +import OAI.Combinatorics.SparsestCut.Smoothing + +namespace OAI + +universe u1 + +open scoped BigOperators Topology NNReal RealInnerProductSpace InnerProductSpace Matrix ContDiff ENNReal +open MeasureTheory ProbabilityTheory Set Filter Matrix + +noncomputable section + +namespace UniformSparsestCut.CoordinateSplit +variable {m : ℕ} +local notation "E" => EuclideanSpace ℝ (Fin (m+1)) +local notation "Z" => EuclideanSpace ℝ (Fin m) + +def splitLinear : E ≃ₗ[ℝ] ℝ × Z where + toFun x := (x 0, WithLp.toLp 2 (fun j => x j.succ)) + invFun p := WithLp.toLp 2 (Fin.cons p.1 (fun j => p.2 j)) + left_inv x := by ext i; refine Fin.cases ?_ (fun j => ?_) i <;> simp + right_inv p := by ext <;> simp + map_add' x y := by ext <;> simp + map_smul' t x := by ext <;> simp + +def split : E ≃L[ℝ] ℝ × Z := splitLinear.toContinuousLinearEquiv +@[simp] lemma split_apply (x : E) : split x=(x 0,WithLp.toLp 2 (fun j => x j.succ)) := rfl +@[simp] lemma split_symm_apply (p : ℝ × Z) : split.symm p=WithLp.toLp 2 (Fin.cons p.1 (fun j => p.2 j)) := rfl + +def splitMeasurable : E ≃ᵐ ℝ × Z := split.toHomeomorph.toMeasurableEquiv + +lemma preserving : MeasurePreserving (split (m := m)) volume volume := by + have h₁ := MeasurePreserving.symm (MeasurableEquiv.toLp 2 (Fin (m+1) → ℝ)) + (PiLp.volume_preserving_toLp (Fin (m+1))) + have h₂ := volume_preserving_piFinSuccAbove (fun _ : Fin (m+1) => ℝ) 0 + have h₃ : MeasurePreserving (Prod.map (id : ℝ → ℝ) (WithLp.toLp 2 : (Fin m → ℝ) → Z)) volume volume := + (MeasurePreserving.id (volume : Measure ℝ)).prod (PiLp.volume_preserving_toLp (Fin m)) + have heq : (split (m := m) : E → ℝ × Z) = Prod.map (id : ℝ → ℝ) (WithLp.toLp 2) ∘ + (MeasurableEquiv.piFinSuccAbove (fun _ : Fin (m+1) => ℝ) 0) ∘ + (MeasurableEquiv.toLp 2 (Fin (m+1) → ℝ)).symm := by + ext x <;> + simp [split,splitLinear,MeasurableEquiv.piFinSuccAbove_apply,Fin.tail] + rw [heq] + exact h₃.comp (h₂.comp h₁) + +lemma integral_split (f : ℝ × Z → ℝ) : (∫ x : E, f (split x))=∫ p, f p := + preserving.integral_comp splitMeasurable.measurableEmbedding f + +lemma convolution_split (φ : E → ℝ) (f : (ℝ × Z) → ℝ) + (θ : E) : + convolution φ (f ∘ split) (ContinuousLinearMap.mul ℝ ℝ) volume θ = + convolution (φ ∘ split.symm) f (ContinuousLinearMap.mul ℝ ℝ) volume (split θ) := by + change (∫ x : E, φ x*f (split (θ-x))) = + ∫ p : ℝ × Z, φ (split.symm p)*f (split θ-p) + rw [← integral_split] + congr 1 + ext x + simp only [ContinuousLinearEquiv.symm_apply_apply,map_sub] + +lemma derivative_transport (h : (ℝ × Z) → ℝ) (D : (ℝ × Z) →L[ℝ] ℝ) + (θ : E) (hd : HasFDerivAt h D (split θ)) : + HasFDerivAt (h ∘ split) (D.comp split.toContinuousLinearMap) θ := + hd.comp θ split.hasFDerivAt + +def rest (u : E) : Z →L[ℝ] ℝ := + (InnerProductSpace.toDual ℝ E u).comp + (split.symm.toContinuousLinearMap.comp (ContinuousLinearMap.inr ℝ ℝ Z)) +def slope (u : E) : Z →L[ℝ] ℝ := -(u 0)⁻¹ • rest u +lemma rest_apply (u : E) (z : Z) : rest u z=∑ j, u j.succ*z j := by + simp [rest,PiLp.inner_apply,Fin.sum_univ_succ,mul_comm] +lemma inner_formula (u x : E) : inner ℝ u x=u 0*(split x).1+rest u (split x).2 := by + simp [rest_apply,PiLp.inner_apply,Fin.sum_univ_succ] + congr 1 + · ring + · apply Finset.sum_congr rfl; intro j _; ring +lemma normalized_form (u : E) (hu : u 0≠0) (x : E) : + inner ℝ u x/(u 0)=(split x).1-slope u (split x).2 := by + rw [inner_formula] + simp only [slope,_root_.smul_apply,smul_eq_mul] + field_simp + ring +lemma slope_injective {I : Type u1} (u : I → E) (hu : ∀ i, u i 0≠0) + (hn : ∀ i j, i≠j → ∀ t : ℝ, u i≠t • u j) : Function.Injective (fun i => slope (u i)) := by + intro i j he + by_contra hij + apply hn i j hij (u i 0/u j 0) + apply (InnerProductSpace.toDual ℝ E).injective + ext x + have hh := congrArg (fun L : Z →L[ℝ] ℝ => L (split x).2) he + simp only [slope,_root_.smul_apply,smul_eq_mul] at hh + change inner ℝ (u i) x=inner ℝ ((u i 0/u j 0) • u j) x + rw [real_inner_smul_left] + rw [inner_formula (u i),inner_formula (u j)] + field_simp [hu i,hu j] at hh ⊢ + nlinarith +end UniformSparsestCut.CoordinateSplit + +end + +end OAI