File size: 9,503 Bytes
92416a2 | 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 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | import Std
import OAI.Computability.UniqueGames.Machines.MachineSubroutineLemmas
namespace OAI
section
/-!
Bit-length bounds for the concrete unique-game serialization. Every stored
constraint occurrence and every entry of its forward permutation table is
encoded. These are output-size bounds, not machine running-time bounds.
-/
namespace UniqueGamesTheorem.Reduction.GameEncodingSize
open Foundations.Target Foundations.Complexity
/-- The full table has `q` labels, each with unary encoding length at most `q+1`.
The conservative bound remains valid when the alphabet is empty. -/
theorem tableBits_length_le {q : Nat} (table : PermutationTable q) :
(encodeWords (tableWords table)).length ≤ q * (q + 1) := by
have h := encodeWords_length_le (tableWords table) q (by
intro value hvalue
obtain ⟨label, _, hlabel⟩ := List.mem_map.mp hvalue
rw [← hlabel]
exact Nat.le_of_lt label.isLt)
simpa only [tableWords_length] using h
/-- Both endpoint words use at most `n` bits, and the entire forward table is
retained. A constraint itself supplies the endpoint bounds, even for small `n`. -/
theorem constraintBits_length_le {n q : Nat} (constraint : Constraint n q) :
(encodeWords (constraintWords constraint)).length ≤ 2 * n + q * (q + 1) := by
have hs := constraint.source.isLt
have ht := constraint.target.isLt
have hp := tableBits_length_le constraint.permutation
simp only [constraintWords, encodeWords_append, List.length_append,
encodeWords, encodeWord_length, List.length_nil]
omega
/-- Each occurrence contributes its own complete encoding; no deduplication
or implicit edge weights enter the bound. The empty list is also covered. -/
theorem constraintsBits_length_le {n q : Nat} (constraints : List (Constraint n q)) :
(encodeWords (constraints.flatMap constraintWords)).length ≤
constraints.length * (2 * n + q * (q + 1)) := by
induction constraints with
| nil => simp [encodeWords]
| cons constraint constraints ih =>
have hc := constraintBits_length_le constraint
simp only [List.flatMap_cons, encodeWords_append, List.length_append,
List.length_cons, Nat.add_mul, Nat.one_mul]
omega
/-- Exact header accounting plus a bound on every serialized occurrence.
No lower bound on the alphabet or vertex count is assumed. -/
theorem gameBits_length_le {q : Nat} (g : Instance q) :
(gameBits g).length ≤
g.vertices + q + g.constraints.length + 3 +
g.constraints.length * (2 * g.vertices + q * (q + 1)) := by
have h := constraintsBits_length_le g.constraints
simp only [gameBits, gameWords, encodeWords_append, List.length_append,
encodeWords, encodeWord_length, List.length_nil]
omega
end UniqueGamesTheorem.Reduction.GameEncodingSize
end
section
namespace UniqueGamesTheorem.Reduction.Incidence
structure Triple where
first : Bool
second : Bool
third : Bool
deriving DecidableEq
def parity (a : Triple) : Bool := (a.first.xor a.second).xor a.third
def matchingSlots (a b : Triple) : Nat :=
(if a.first = b.first then 1 else 0) +
(if a.second = b.second then 1 else 0) +
(if a.third = b.third then 1 else 0)
/-- Invalid Alice answers lose in every slot. -/
def acceptedSlots (a b : Triple) (rhs : Bool) : Nat :=
if parity a = rhs then matchingSlots a b else 0
def failedEquation (b : Triple) (rhs : Bool) : Nat :=
if parity b = rhs then 0 else 1
/-- Copy a satisfying Bob triple; otherwise flip its first bit. -/
def bestResponse (b : Triple) (rhs : Bool) : Triple :=
if parity b = rhs then b else { b with first := !b.first }
theorem local_count_bound (a b : Triple) (rhs : Bool) :
acceptedSlots a b rhs + failedEquation b rhs ≤ 3 := by
rcases a with ⟨a₁, a₂, a₃⟩
rcases b with ⟨b₁, b₂, b₃⟩
cases a₁ <;> cases a₂ <;> cases a₃ <;>
cases b₁ <;> cases b₂ <;> cases b₃ <;> cases rhs <;> decide
theorem best_response_exact (b : Triple) (rhs : Bool) :
acceptedSlots (bestResponse b rhs) b rhs + failedEquation b rhs = 3 := by
rcases b with ⟨b₁, b₂, b₃⟩
cases b₁ <;> cases b₂ <;> cases b₃ <;> cases rhs <;> decide
universe variableUniverse indexUniverse
structure Equation (Variable : Type variableUniverse) where
first : Variable
second : Variable
third : Variable
rhs : Bool
variable {Variable : Type variableUniverse} {Index : Type indexUniverse}
inductive Slot where
| first
| second
| third
deriving DecidableEq
def nameAt (e : Equation Variable) : Slot → Variable
| .first => e.first
| .second => e.second
| .third => e.third
def bitAt (a : Triple) : Slot → Bool
| .first => a.first
| .second => a.second
| .third => a.third
/-- A predicate of the actual questions and answers, with no hidden slot input. -/
def questionPredicate (e : Equation Variable) (name : Variable)
(alice : Triple) (bob : Bool) : Prop :=
parity alice = e.rhs ∧
((e.first = name ∧ alice.first = bob) ∨
(e.second = name ∧ alice.second = bob) ∨
(e.third = name ∧ alice.third = bob))
/-- Cloning supplies exactly the distinctness needed to recover a slot from its name. -/
theorem question_predicate_at_slot (e : Equation Variable)
(distinct₁₂ : e.first ≠ e.second) (distinct₁₃ : e.first ≠ e.third)
(distinct₂₃ : e.second ≠ e.third) (alice : Triple) (bob : Bool) (slot : Slot) :
questionPredicate e (nameAt e slot) alice bob ↔
parity alice = e.rhs ∧ bitAt alice slot = bob := by
cases slot <;>
simp [questionPredicate, nameAt, bitAt, distinct₁₂, distinct₁₃, distinct₂₃,
Ne.symm distinct₁₂, Ne.symm distinct₁₃, Ne.symm distinct₂₃]
/-- Bob receives only a variable name: the strategy has no occurrence input. -/
def bobTriple (g : Variable → Bool) (e : Equation Variable) : Triple :=
⟨g e.first, g e.second, g e.third⟩
/-- An occurrence index supplies Alice's full question and its equation. -/
def acceptedCount (equations : Index → Equation Variable)
(g : Variable → Bool) (alice : Index → Triple) : List Index → Nat
| [] => 0
| i :: rest =>
acceptedSlots (alice i) (bobTriple g (equations i)) (equations i).rhs +
acceptedCount equations g alice rest
def failureCount (equations : Index → Equation Variable)
(g : Variable → Bool) : List Index → Nat
| [] => 0
| i :: rest =>
failedEquation (bobTriple g (equations i)) (equations i).rhs +
failureCount equations g rest
theorem total_count_bound (equations : Index → Equation Variable)
(g : Variable → Bool) (alice : Index → Triple) (occurrences : List Index) :
acceptedCount equations g alice occurrences + failureCount equations g occurrences ≤
3 * occurrences.length := by
induction occurrences with
| nil => simp [acceptedCount, failureCount]
| cons i rest ih =>
have h := local_count_bound (alice i) (bobTriple g (equations i)) (equations i).rhs
simp only [acceptedCount, failureCount, List.length_cons]
omega
def optimalAlice (equations : Index → Equation Variable) (g : Variable → Bool)
(i : Index) : Triple :=
bestResponse (bobTriple g (equations i)) (equations i).rhs
theorem optimal_alice_exact (equations : Index → Equation Variable)
(g : Variable → Bool) (occurrences : List Index) :
acceptedCount equations g (optimalAlice equations g) occurrences +
failureCount equations g occurrences = 3 * occurrences.length := by
induction occurrences with
| nil => simp [acceptedCount, failureCount]
| cons i rest ih =>
have h := best_response_exact (bobTriple g (equations i)) (equations i).rhs
simp only [acceptedCount, failureCount, List.length_cons, optimalAlice]
omega
/-- Exact finite-count form of `max_Alice Pr[accept | Bob = g] = 1 - u(g)/3`. -/
theorem fixed_bob_optimum (equations : Index → Equation Variable)
(g : Variable → Bool) (occurrences : List Index) :
∃ alice : Index → Triple,
acceptedCount equations g alice occurrences + failureCount equations g occurrences =
3 * occurrences.length ∧
∀ other : Index → Triple,
acceptedCount equations g other occurrences ≤
acceptedCount equations g alice occurrences := by
refine ⟨optimalAlice equations g, optimal_alice_exact equations g occurrences, ?_⟩
intro other
have h := total_count_bound equations g other occurrences
have heq := optimal_alice_exact equations g occurrences
omega
theorem soundness_191_over_192 (equations : Index → Equation Variable)
(g : Variable → Bool) (alice : Index → Triple) (occurrences : List Index)
(source_gap : occurrences.length ≤ 64 * failureCount equations g occurrences) :
64 * acceptedCount equations g alice occurrences ≤ 191 * occurrences.length := by
have h := total_count_bound equations g alice occurrences
omega
/-- The same bound holds for every deterministic pair when every Bob assignment has the gap. -/
theorem game_soundness_191_over_192 (equations : Index → Equation Variable)
(occurrences : List Index)
(source_gap : ∀ g : Variable → Bool,
occurrences.length ≤ 64 * failureCount equations g occurrences) :
∀ (g : Variable → Bool) (alice : Index → Triple),
64 * acceptedCount equations g alice occurrences ≤ 191 * occurrences.length := by
intro g alice
exact soundness_191_over_192 equations g alice occurrences (source_gap g)
end UniqueGamesTheorem.Reduction.Incidence
end
end OAI
|