File size: 3,072 Bytes
4a56cd6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | import Mathlib.Data.Finset.Card
import Mathlib.Data.Fintype.BigOperators
import Mathlib.Algebra.Order.BigOperators.Group.Finset
import Mathlib.Data.Fintype.Card
namespace OAI
/-! Finite type counts, hierarchy separation and tensor execution bounds. -/
open scoped BigOperators
namespace MatrixMultiplication.FiniteCover
variable {Ξ© M G : Type*}
theorem exists_avoiding [Fintype Ξ©] [DecidableEq Ξ©] [DecidableEq M]
(s : Finset M) (bad : M β Finset Ξ©) (t : β)
(hbad : β m β s, (bad m).card β€ t)
(hbudget : s.card * t < Fintype.card Ξ©) :
β Ο : Ξ©, β m β s, Ο β bad m := by
classical
have hcard : (s.biUnion bad).card β€ s.card * t := by
calc
(s.biUnion bad).card β€ β m β s, (bad m).card := Finset.card_biUnion_le
_ β€ β _m β s, t := Finset.sum_le_sum fun m hm => hbad m hm
_ = s.card * t := by simp
by_contra hn
have hsub : (Finset.univ : Finset Ξ©) β s.biUnion bad := by
intro Ο hΟ
by_contra hout
apply hn
refine β¨Ο, ?_β©
intro m hm hmem
exact hout (Finset.mem_biUnion.mpr β¨m, hm, hmemβ©)
have := Finset.card_le_card hsub
simp only [Finset.card_univ] at this
exact (not_lt_of_ge (this.trans hcard)) hbudget
def avoidingWords [Fintype G] [DecidableEq G] (bad : Finset G) (L : β) :
Finset (Fin L β G) := Finset.univ.filter fun f => β i, f i β bad
theorem card_avoidingWords [Fintype G] [DecidableEq G] (bad : Finset G) (L : β) :
(avoidingWords bad L).card = bad.card ^ L := by
classical
let e : {f : Fin L β G // f β avoidingWords bad L} β (Fin L β {g // g β bad}) :=
{ toFun := fun f i => β¨f.1 i, (Finset.mem_filter.mp f.2).2 iβ©
invFun := fun f => β¨fun i => (f i).1, by simp [avoidingWords]β©
left_inv := by intro f; rfl
right_inv := by intro f; rfl }
calc
(avoidingWords bad L).card = Fintype.card {f : Fin L β G // f β avoidingWords bad L} := by simp
_ = Fintype.card (Fin L β {g // g β bad}) := Fintype.card_congr e
_ = bad.card ^ L := by simp
theorem exists_cover [Fintype G] [DecidableEq G] [DecidableEq M]
(s : Finset M) (good : G β M β Prop) [β g, DecidablePred (good g)]
(t L : β)
(hbad : β m β s, (Finset.univ.filter fun g => Β¬good g m).card β€ t)
(hbudget : s.card * t ^ L < Fintype.card G ^ L) :
β f : Fin L β G, β m β s, β i, good (f i) m := by
classical
let bad : M β Finset G := fun m => Finset.univ.filter fun g => Β¬good g m
have hb : β m β s, (avoidingWords (bad m) L).card β€ t ^ L := by
intro m hm
rw [card_avoidingWords]
exact Nat.pow_le_pow_left (hbad m hm) L
obtain β¨f, hfβ© := exists_avoiding s (fun m => avoidingWords (bad m) L) (t ^ L) hb
(by simpa using hbudget)
refine β¨f, ?_β©
intro m hm
by_contra hn
apply hf m hm
simp only [avoidingWords, Finset.mem_filter, Finset.mem_univ, true_and]
intro i
simp only [bad, Finset.mem_filter, Finset.mem_univ, true_and]
exact fun hi => hn β¨i, hiβ©
end MatrixMultiplication.FiniteCover
end OAI
|