File size: 3,072 Bytes
f18e7de
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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