File size: 8,607 Bytes
e320e82 | 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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | import Mathlib
import OAI.Combinatorics.IndependentSets.Expansion.PoweringTables
namespace OAI
namespace IndependentSetsGames.Foundations.PCP.PoweringTableSemantics
open PoweringWalks PoweringLabels PoweringAddresses PoweringEnumeration PoweringTables
abbrev RawLabeling (vertices d n : Nat) :=
Fin vertices → PaddedLabel (Fin d) (n + 1) (Fin 64)
abbrev EncodedLabeling (vertices d n : Nat) :=
Fin vertices → Fin (labelCount d n)
def encodeLabeling {vertices : Nat} (d n : Nat) (labels : RawLabeling vertices d n) :
EncodedLabeling vertices d n :=
fun v => encodeLabel d (n + 1) 64 (labels v)
def decodeLabeling {vertices : Nat} (d n : Nat) (labels : EncodedLabeling vertices d n) :
RawLabeling vertices d n :=
fun v => decodeLabel d (n + 1) 64 (labels v)
@[simp] theorem decodeLabeling_encodeLabeling {vertices : Nat} (d n : Nat)
(labels : RawLabeling vertices d n) :
decodeLabeling d n (encodeLabeling d n labels) = labels := by
funext v
exact decodeLabel_encodeLabel d (n + 1) 64 (labels v)
@[simp] theorem encodeLabeling_decodeLabeling {vertices : Nat} (d n : Nat)
(labels : EncodedLabeling vertices d n) :
encodeLabeling d n (decodeLabeling d n labels) = labels := by
funext v
exact encodeLabel_decodeLabel d (n + 1) 64 (labels v)
theorem edgeSatisfied_encoded {vertices d : Nat} (input : PortTables.Table vertices d)
(n : Nat) (labels : RawLabeling vertices d n)
(e : PoweringTest.Dart (Fin vertices) (Fin d) n) :
(GenericGraphTables.semantics (table input n)).edgeSatisfied
(encodeLabeling (vertices := vertices) d n labels) (encodeDart vertices d n e) =
(mathematicalGraph input n).edgeSatisfied labels e := by
rw [semantics_table]
unfold encodeLabeling encodeLabel encodeDart
exact
GenericGraphTables.enumeratedGraph_edgeSatisfied (mathematicalGraph input n)
(Equiv.refl _) (dartEquiv vertices d n) (paddedLabelEquiv d (n + 1) 64) labels e
theorem edgeSatisfied_decoded {vertices d : Nat} (input : PortTables.Table vertices d)
(n : Nat) (labels : EncodedLabeling vertices d n) (i : Fin (dartCount vertices d n)) :
(GenericGraphTables.semantics (table input n)).edgeSatisfied labels i =
(mathematicalGraph input n).edgeSatisfied (decodeLabeling d n labels)
(decodeDart vertices d n i) := by
simpa only [encodeLabeling_decodeLabeling d n labels,
encodeDart_decodeDart vertices d n i] using
edgeSatisfied_encoded input n (decodeLabeling d n labels) (decodeDart vertices d n i)
theorem edgeSatisfied_eq_path {vertices d : Nat} (input : PortTables.Table vertices d)
(n : Nat) (labels : EncodedLabeling vertices d n) (direction : Bool)
(w : Walk (Fin vertices) (Fin d) (n + 1)) :
(GenericGraphTables.semantics (table input n)).edgeSatisfied labels
(encodeDart vertices d n (direction, w)) =
PoweringTest.pathAccepts (PortTables.portGraph input) (PortTables.accepts input) n
(finitePortSelector (PortTables.portGraph input) (n + 1)) w
(decodeLabeling d n labels w.1)
(decodeLabeling d n labels (endpoint (PortTables.portGraph input) w)) := by
rw [edgeSatisfied_decoded input n labels (encodeDart vertices d n (direction, w)),
decodeDart_encodeDart vertices d n (direction, w)]
exact PoweringTest.poweredGraph_edgeSatisfied (PortTables.portGraph input)
(PortTables.accepts input) n (finitePortSelector (PortTables.portGraph input) (n + 1))
(decodeLabeling d n labels) direction w
theorem rejectionCount_encoded {vertices d : Nat} (input : PortTables.Table vertices d)
(n : Nat) (labels : RawLabeling vertices d n) :
(GenericGraphTables.semantics (table input n)).rejectionCount
(encodeLabeling (vertices := vertices) d n labels) =
(mathematicalGraph input n).rejectionCount labels := by
rw [semantics_table]
unfold encodeLabeling encodeLabel
exact
GenericGraphTables.enumeratedGraph_rejectionCount (mathematicalGraph input n)
(Equiv.refl _) (dartEquiv vertices d n) (paddedLabelEquiv d (n + 1) 64) labels
theorem rejectionCount_decoded {vertices d : Nat} (input : PortTables.Table vertices d)
(n : Nat) (labels : EncodedLabeling vertices d n) :
(GenericGraphTables.semantics (table input n)).rejectionCount labels =
(mathematicalGraph input n).rejectionCount (decodeLabeling d n labels) := by
simpa only [encodeLabeling_decodeLabeling d n labels] using
rejectionCount_encoded input n (decodeLabeling d n labels)
theorem card_darts_eq_table {vertices d : Nat} (input : PortTables.Table vertices d)
(n : Nat) :
Fintype.card (PoweringTest.Dart (Fin vertices) (Fin d) n) = (table input n).darts := by
change Fintype.card (PoweringTest.Dart (Fin vertices) (Fin d) n) =
2 * vertices * d ^ (n + 1)
simpa only [Fintype.card_fin] using Fintype.card_congr (dartEquiv vertices d n)
theorem satisfiable_iff {vertices d : Nat} (input : PortTables.Table vertices d) (n : Nat) :
(GenericGraphTables.semantics (table input n)).Satisfiable ↔
(mathematicalGraph input n).Satisfiable := by
constructor
· rintro ⟨labels, satisfies⟩
refine ⟨decodeLabeling d n labels, ?_⟩
intro e
have h := edgeSatisfied_encoded input n (decodeLabeling d n labels) e
rw [encodeLabeling_decodeLabeling (vertices := vertices) d n labels] at h
exact h.symm.trans (satisfies (encodeDart vertices d n e))
· rintro ⟨labels, satisfies⟩
refine ⟨encodeLabeling d n labels, ?_⟩
intro i
have h := edgeSatisfied_encoded input n labels (decodeDart vertices d n i)
rw [encodeDart_decodeDart vertices d n i] at h
exact h.trans (satisfies (decodeDart vertices d n i))
theorem preserves_satisfiability {vertices d : Nat} (input : PortTables.Table vertices d)
(n : Nat) (h : (PortTables.baseGraph input).Satisfiable) :
(GenericGraphTables.semantics (table input n)).Satisfiable := by
apply (satisfiable_iff input n).mpr
exact PoweringTest.preserves_satisfiability (PortTables.portGraph input)
(PortTables.accepts input) (PortTables.accepts_rotation input) n
(finitePortSelector (PortTables.portGraph input) (n + 1)) h
theorem path_rejection_mean_eq_table_fraction {vertices d : Nat}
(input : PortTables.Table vertices d) (n : Nat) (labels : EncodedLabeling vertices d n) :
SpectralReturn.mean (fun w : Walk (Fin vertices) (Fin d) (n + 1) =>
PoweringMoment.bit
(PoweringTest.pathAccepts (PortTables.portGraph input) (PortTables.accepts input) n
(finitePortSelector (PortTables.portGraph input) (n + 1)) w
(decodeLabeling d n labels w.1)
(decodeLabeling d n labels (endpoint (PortTables.portGraph input) w)) = false)) =
((GenericGraphTables.semantics (table input n)).rejectionCount labels : ℝ) /
((table input n).darts : ℝ) := by
rw [rejectionCount_decoded input n labels, ← card_darts_eq_table input n]
exact PoweringCounting.path_rejection_mean_eq_count (PortTables.portGraph input)
(PortTables.accepts input) n (finitePortSelector (PortTables.portGraph input) (n + 1))
(decodeLabeling d n labels)
theorem uniform_count_gap_iff {vertices d : Nat} (input : PortTables.Table vertices d)
(n : Nat) (epsilon : ℝ) :
(∀ labels : EncodedLabeling vertices d n,
epsilon * ((table input n).darts : ℝ) ≤
((GenericGraphTables.semantics (table input n)).rejectionCount labels : ℝ)) ↔
(∀ labels : RawLabeling vertices d n,
epsilon * (Fintype.card (PoweringTest.Dart (Fin vertices) (Fin d) n) : ℝ) ≤
((mathematicalGraph input n).rejectionCount labels : ℝ)) := by
constructor
· intro h labels
have hlabels := h (encodeLabeling d n labels)
rw [rejectionCount_encoded input n labels, ← card_darts_eq_table input n] at hlabels
exact hlabels
· intro h labels
rw [rejectionCount_decoded input n labels]
have hlabels := h (decodeLabeling d n labels)
rw [card_darts_eq_table input n] at hlabels
exact hlabels
theorem uniform_count_gap {vertices d : Nat} (input : PortTables.Table vertices d)
(n : Nat) (epsilon : ℝ)
(hgap : ∀ labels : RawLabeling vertices d n,
epsilon * (Fintype.card (PoweringTest.Dart (Fin vertices) (Fin d) n) : ℝ) ≤
((mathematicalGraph input n).rejectionCount labels : ℝ)) :
∀ labels : EncodedLabeling vertices d n,
epsilon * ((table input n).darts : ℝ) ≤
((GenericGraphTables.semantics (table input n)).rejectionCount labels : ℝ) :=
(uniform_count_gap_iff input n epsilon).mpr hgap
end IndependentSetsGames.Foundations.PCP.PoweringTableSemantics
end OAI
|