cfahlgren1/math / lean /OAI /Computability /UniqueGames /PCP /AlphabetReductionLemmas.lean
cfahlgren1's picture
download
raw
19.2 kB
import Mathlib.Data.Finset.Max
import Mathlib.Data.Fintype.Card
import Mathlib.Data.Fintype.Pi
import Mathlib.Basic.Real.Basic
import Mathlib.Tactic.NormNum
import OAI.Computability.UniqueGames.PCP.AssignmentTester
import OAI.Computability.UniqueGames.PCP.CodeComposition
namespace OAI
section
/-!
The explicit assignment tester applied to the encoded satisfying pairs of an
actual finite edge predicate. The resulting soundness loss is independent of
the alphabet size. Uniform padding of the finite sample space and assembly of
the global incidence graph are separate constructions.
-/
noncomputable section
namespace UniqueGamesTheorem.Foundations.PCP.AlphabetReduction
open UniqueGamesTheorem.Foundations.Hastad
open CodeComposition
variable {A : Type*} [Fintype A] [DecidableEq A] [Nonempty A]
abbrev LegalPair (accepts : A → A → Bool) :=
{p : A × A // accepts p.1 p.2 = true}
abbrev InputCoordinate (A : Type*) := Bool × Cube A
def pairEncoding (accepts : A → A → Bool) (p : LegalPair accepts) :
InputCoordinate A → Bool :=
pairWord (codeword p.1.1) (codeword p.1.2)
def edgeTesterReject (accepts : A → A → Bool) (left right : Cube A → Bool)
(F : Cube (LegalPair accepts) → Bool) : ℝ :=
AssignmentTester.explicitTesterReject (pairEncoding accepts) (pairWord left right) F
theorem rejected_edge_tester_bound (accepts : A → A → Bool)
(left right : Cube A → Bool)
(F : Cube (LegalPair accepts) → Bool)
(hbad : accepts (nearest left) (nearest right) = false) :
1 / 2048 ≤ edgeTesterReject accepts left right F := by
have hfar (p : LegalPair accepts) :
(1 / 8 : ℝ) ≤ AssignmentTester.distance (pairWord left right) (pairEncoding accepts p) := by
have h := rejected_pair_far accepts left right hbad p.1.1 p.1.2 p.2
convert h using 1
rfl
have h := AssignmentTester.explicit_proximity_soundness (pairEncoding accepts)
(pairWord left right) F (δ := 1 / 8) (by norm_num) (by norm_num) hfar
norm_num at h
exact h
omit [Nonempty A] in
theorem honest_edge_tester (accepts : A → A → Bool) (a b : A)
(hab : accepts a b = true) :
edgeTesterReject accepts (codeword a) (codeword b)
(fun f => f ⟨(a, b), hab⟩) = 0 := by
unfold edgeTesterReject
rw [AssignmentTester.explicitTesterReject_eq]
exact AssignmentTester.tester_perfect_completeness
(pairEncoding accepts) ⟨(a, b), hab⟩
end UniqueGamesTheorem.Foundations.PCP.AlphabetReduction
end
end
section
namespace UniqueGamesTheorem.Foundations.PCP
structure ConstraintGraph (V E A : Type*) where
reverse : E ≃ E
reverse_involutive : Function.Involutive reverse
tail : E → V
accepts : E → A → A → Bool
reverse_accepts : ∀ e a b, accepts (reverse e) b a = accepts e a b
namespace ConstraintGraph
variable {V E A : Type*}
def head (G : ConstraintGraph V E A) (e : E) : V := G.tail (G.reverse e)
@[simp] theorem head_reverse (G : ConstraintGraph V E A) (e : E) :
G.head (G.reverse e) = G.tail e := by
simp only [head, G.reverse_involutive e]
def edgeSatisfied (G : ConstraintGraph V E A) (labeling : V → A) (e : E) : Bool :=
G.accepts e (labeling (G.tail e)) (labeling (G.head e))
@[simp] theorem edgeSatisfied_reverse (G : ConstraintGraph V E A)
(labeling : V → A) (e : E) :
G.edgeSatisfied labeling (G.reverse e) = G.edgeSatisfied labeling e := by
simpa only [edgeSatisfied, head, G.reverse_involutive e] using
G.reverse_accepts e (labeling (G.tail e)) (labeling (G.tail (G.reverse e)))
def Satisfiable (G : ConstraintGraph V E A) : Prop :=
∃ labeling : V → A, ∀ e, G.edgeSatisfied labeling e = true
def rejectedDarts [Fintype E] (G : ConstraintGraph V E A) (labeling : V → A) :
Finset E := Finset.univ.filter (fun e => G.edgeSatisfied labeling e = false)
def rejectionCount [Fintype E] (G : ConstraintGraph V E A) (labeling : V → A) : Nat :=
(G.rejectedDarts labeling).card
theorem mem_rejectedDarts [Fintype E] (G : ConstraintGraph V E A)
(labeling : V → A) (e : E) :
e ∈ G.rejectedDarts labeling ↔ G.edgeSatisfied labeling e = false := by
simp [rejectedDarts]
theorem rejectionCount_le [Fintype E] (G : ConstraintGraph V E A)
(labeling : V → A) : G.rejectionCount labeling ≤ Fintype.card E := by
exact Finset.card_le_card (Finset.filter_subset _ _)
theorem rejected_exists_of_not_satisfiable (G : ConstraintGraph V E A)
(unsat : ¬ G.Satisfiable) (labeling : V → A) :
∃ e, G.edgeSatisfied labeling e = false := by
classical
by_contra none
apply unsat
refine ⟨labeling, fun e => ?_⟩
have notFalse : G.edgeSatisfied labeling e ≠ false := by
intro h
exact none ⟨e, h⟩
cases h : G.edgeSatisfied labeling e <;> simp_all
theorem rejectionCount_positive [Fintype E] (G : ConstraintGraph V E A)
(unsat : ¬ G.Satisfiable) (labeling : V → A) :
1 ≤ G.rejectionCount labeling := by
obtain ⟨e, he⟩ := G.rejected_exists_of_not_satisfiable unsat labeling
exact Finset.one_le_card.mpr ⟨e, (G.mem_rejectedDarts labeling e).mpr he⟩
end ConstraintGraph
end UniqueGamesTheorem.Foundations.PCP
end
section
noncomputable section
namespace UniqueGamesTheorem.Foundations.PCP.ConstraintGraph
variable {V E A : Type*}
section Minimum
variable [Fintype V] [Fintype E] [Fintype A] [Nonempty A]
def rejectionCounts (G : ConstraintGraph V E A) : Finset Nat := by
classical
exact Finset.univ.image G.rejectionCount
theorem rejectionCounts_nonempty (G : ConstraintGraph V E A) :
G.rejectionCounts.Nonempty := by
classical
exact Finset.univ_nonempty.image G.rejectionCount
def minimumRejections (G : ConstraintGraph V E A) : Nat :=
G.rejectionCounts.min' G.rejectionCounts_nonempty
theorem minimumRejections_le (G : ConstraintGraph V E A) (labeling : V → A) :
G.minimumRejections ≤ G.rejectionCount labeling := by
classical
exact Finset.min'_le _ _ (Finset.mem_image.mpr ⟨labeling, Finset.mem_univ _, rfl⟩)
theorem exists_minimizer (G : ConstraintGraph V E A) :
∃ labeling : V → A, G.rejectionCount labeling = G.minimumRejections := by
classical
have h := Finset.min'_mem G.rejectionCounts G.rejectionCounts_nonempty
obtain ⟨labeling, _, heq⟩ := Finset.mem_image.mp h
exact ⟨labeling, heq⟩
theorem le_minimumRejections_iff (G : ConstraintGraph V E A) (bound : Nat) :
bound ≤ G.minimumRejections ↔ ∀ labeling : V → A, bound ≤ G.rejectionCount labeling := by
constructor
· intro h labeling
exact h.trans (G.minimumRejections_le labeling)
· intro h
obtain ⟨labeling, heq⟩ := G.exists_minimizer
rw [← heq]
exact h labeling
theorem minimumRejections_le_card (G : ConstraintGraph V E A) :
G.minimumRejections ≤ Fintype.card E := by
obtain ⟨labeling, heq⟩ := G.exists_minimizer
rw [← heq]
exact G.rejectionCount_le labeling
omit [Fintype V] [Fintype A] [Nonempty A] in
theorem rejectionCount_eq_zero_iff (G : ConstraintGraph V E A) (labeling : V → A) :
G.rejectionCount labeling = 0 ↔ ∀ e, G.edgeSatisfied labeling e = true := by
classical
constructor
· intro h e
have hempty : G.rejectedDarts labeling = ∅ := Finset.card_eq_zero.mp h
cases he : G.edgeSatisfied labeling e with
| false =>
have hm := (G.mem_rejectedDarts labeling e).mpr he
rw [hempty] at hm
simp at hm
| true => rfl
· intro h
simp [rejectionCount, rejectedDarts, h]
theorem minimumRejections_eq_zero_iff (G : ConstraintGraph V E A) :
G.minimumRejections = 0 ↔ G.Satisfiable := by
constructor
· intro h
obtain ⟨labeling, heq⟩ := G.exists_minimizer
exact ⟨labeling, (G.rejectionCount_eq_zero_iff labeling).mp (heq.trans h)⟩
· rintro ⟨labeling, h⟩
have hc := (G.rejectionCount_eq_zero_iff labeling).mpr h
exact Nat.eq_zero_of_le_zero (hc ▸ G.minimumRejections_le labeling)
def gap (G : ConstraintGraph V E A) : ℝ :=
(G.minimumRejections : ℝ) / Fintype.card E
theorem gap_nonnegative (G : ConstraintGraph V E A) : 0 ≤ G.gap :=
div_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _)
theorem gap_le_one [Nonempty E] (G : ConstraintGraph V E A) : G.gap ≤ 1 := by
have he : (0 : ℝ) < Fintype.card E := by exact_mod_cast Fintype.card_pos
apply (div_le_iff₀ he).mpr
simpa only [one_mul] using (Nat.cast_le.mpr G.minimumRejections_le_card :
(G.minimumRejections : ℝ) ≤ (Fintype.card E : ℝ))
theorem gap_eq_zero_iff [Nonempty E] (G : ConstraintGraph V E A) :
G.gap = 0 ↔ G.Satisfiable := by
have he : (Fintype.card E : ℝ) ≠ 0 := by exact_mod_cast Fintype.card_ne_zero
simp only [gap, div_eq_zero_iff, he, or_false, Nat.cast_eq_zero]
exact G.minimumRejections_eq_zero_iff
/-- A lower bound on the actual minimum is exactly the universal count bound. -/
theorem le_gap_iff [Nonempty E] (G : ConstraintGraph V E A) (ε : ℝ) :
ε ≤ G.gap ↔ ∀ labeling : V → A,
ε * Fintype.card E ≤ (G.rejectionCount labeling : ℝ) := by
have he : (0 : ℝ) < Fintype.card E := by exact_mod_cast Fintype.card_pos
change ε ≤ (G.minimumRejections : ℝ) / Fintype.card E ↔ _
rw [le_div_iff₀ he]
constructor
· intro h labeling
exact h.trans (Nat.cast_le.mpr (G.minimumRejections_le labeling))
· intro h
obtain ⟨labeling, heq⟩ := G.exists_minimizer
simpa only [heq] using h labeling
theorem inverse_card_le_gap_of_unsatisfiable [Nonempty E]
(G : ConstraintGraph V E A) (unsat : ¬ G.Satisfiable) :
1 / (Fintype.card E : ℝ) ≤ G.gap := by
apply (G.le_gap_iff _).mpr
intro labeling
have he : (Fintype.card E : ℝ) ≠ 0 := by exact_mod_cast Fintype.card_ne_zero
have hc : (1 : ℝ) ≤ (G.rejectionCount labeling : ℝ) := by
exact_mod_cast G.rejectionCount_positive unsat labeling
simpa only [div_mul_cancel₀ _ he] using hc
end Minimum
section Reindex
variable {W D B : Type*}
/-- Explicit changes of vertex, dart, and label coordinates. -/
def reindex (G : ConstraintGraph V E A) (vertices : V ≃ W) (darts : E ≃ D)
(labels : A ≃ B) : ConstraintGraph W D B where
reverse := darts.symm.trans (G.reverse.trans darts)
reverse_involutive := by
intro d
change darts (G.reverse (darts.symm (darts (G.reverse (darts.symm d))))) = d
rw [darts.symm_apply_apply, G.reverse_involutive, darts.apply_symm_apply]
tail := fun d => vertices (G.tail (darts.symm d))
accepts := fun d a b => G.accepts (darts.symm d) (labels.symm a) (labels.symm b)
reverse_accepts := by
intro d a b
simpa only [Equiv.trans_apply, darts.symm_apply_apply] using
G.reverse_accepts (darts.symm d) (labels.symm a) (labels.symm b)
def labelingEquiv (vertices : V ≃ W) (labels : A ≃ B) : (V → A) ≃ (W → B) where
toFun := fun labeling w => labels (labeling (vertices.symm w))
invFun := fun labeling v => labels.symm (labeling (vertices v))
left_inv := by intro labeling; funext v; simp
right_inv := by intro labeling; funext w; simp
theorem reindex_edgeSatisfied (G : ConstraintGraph V E A)
(vertices : V ≃ W) (darts : E ≃ D) (labels : A ≃ B)
(labeling : V → A) (e : E) :
(G.reindex vertices darts labels).edgeSatisfied (labelingEquiv vertices labels labeling)
(darts e) = G.edgeSatisfied labeling e := by
simp [reindex, labelingEquiv, edgeSatisfied, head, Equiv.trans_apply]
theorem reindex_rejectionCount [Fintype E] [Fintype D] (G : ConstraintGraph V E A)
(vertices : V ≃ W) (darts : E ≃ D) (labels : A ≃ B) (labeling : V → A) :
(G.reindex vertices darts labels).rejectionCount (labelingEquiv vertices labels labeling) =
G.rejectionCount labeling := by
classical
unfold rejectionCount
symm
apply Finset.card_bij (fun e _ => darts e)
· intro e he
rw [mem_rejectedDarts, reindex_edgeSatisfied]
exact (G.mem_rejectedDarts labeling e).mp he
· intro e _ f _ h
exact darts.injective h
· intro d hd
refine ⟨darts.symm d, ?_, darts.apply_symm_apply d⟩
rw [mem_rejectedDarts]
rw [← reindex_edgeSatisfied G vertices darts labels labeling (darts.symm d)]
rw [darts.apply_symm_apply]
exact (mem_rejectedDarts _ _ _).mp hd
variable [Fintype V] [Fintype E] [Fintype A] [Nonempty A]
[Fintype W] [Fintype D] [Fintype B] [Nonempty B]
omit [Nonempty A] [Nonempty B] in
theorem rejectionCounts_reindex (G : ConstraintGraph V E A)
(vertices : V ≃ W) (darts : E ≃ D) (labels : A ≃ B) :
(G.reindex vertices darts labels).rejectionCounts = G.rejectionCounts := by
classical
ext n
simp only [rejectionCounts, Finset.mem_image, Finset.mem_univ, true_and]
constructor
· rintro ⟨labeling, hn⟩
refine ⟨(labelingEquiv vertices labels).symm labeling, ?_⟩
rw [← reindex_rejectionCount G vertices darts labels,
Equiv.apply_symm_apply]
exact hn
· rintro ⟨labeling, hn⟩
refine ⟨labelingEquiv vertices labels labeling, ?_⟩
rw [reindex_rejectionCount]
exact hn
theorem minimumRejections_reindex (G : ConstraintGraph V E A)
(vertices : V ≃ W) (darts : E ≃ D) (labels : A ≃ B) :
(G.reindex vertices darts labels).minimumRejections = G.minimumRejections := by
unfold minimumRejections
simp only [rejectionCounts_reindex]
theorem gap_reindex (G : ConstraintGraph V E A)
(vertices : V ≃ W) (darts : E ≃ D) (labels : A ≃ B) :
(G.reindex vertices darts labels).gap = G.gap := by
unfold gap
rw [minimumRejections_reindex, Fintype.card_congr darts]
theorem satisfiable_reindex (G : ConstraintGraph V E A)
(vertices : V ≃ W) (darts : E ≃ D) (labels : A ≃ B) :
(G.reindex vertices darts labels).Satisfiable ↔ G.Satisfiable := by
rw [← minimumRejections_eq_zero_iff, minimumRejections_reindex,
minimumRejections_eq_zero_iff]
end Reindex
end UniqueGamesTheorem.Foundations.PCP.ConstraintGraph
end
end
section
/-!
A stable type of finite graphs over one fixed alphabet. Vertex and dart types,
their finite enumeration and equality data, and the actual constraint graph
are stored together. The gap is computed from that graph's actual finite
labeling minimum. This mathematical bundle is not a serialized machine input;
no finite numbering is chosen here.
-/
noncomputable section
namespace UniqueGamesTheorem.Foundations.PCP.FiniteGraph
/-- Graphs of different finite sizes inhabit one fixed type for iteration. -/
structure Bundle (A : Type) where
Vertex : Type
Dart : Type
vertexFintype : Fintype Vertex
dartFintype : Fintype Dart
vertexDecidableEq : DecidableEq Vertex
dartDecidableEq : DecidableEq Dart
dartNonempty : Nonempty Dart
graph : ConstraintGraph Vertex Dart A
namespace Bundle
variable {A : Type}
instance instFintypeVertex (G : Bundle A) : Fintype G.Vertex := G.vertexFintype
instance instFintypeDart (G : Bundle A) : Fintype G.Dart := G.dartFintype
instance instDecidableEqVertex (G : Bundle A) : DecidableEq G.Vertex := G.vertexDecidableEq
instance instDecidableEqDart (G : Bundle A) : DecidableEq G.Dart := G.dartDecidableEq
instance instNonemptyDart (G : Bundle A) : Nonempty G.Dart := G.dartNonempty
/-- A dart supplies a vertex through the actual tail map. -/
instance instNonemptyVertex (G : Bundle A) : Nonempty G.Vertex := by
obtain ⟨d⟩ := G.dartNonempty
exact ⟨G.graph.tail d⟩
def ofGraph {V E : Type} [Fintype V] [Fintype E]
[DecidableEq V] [DecidableEq E] [Nonempty E]
(G : ConstraintGraph V E A) : Bundle A where
Vertex := V
Dart := E
vertexFintype := inferInstance
dartFintype := inferInstance
vertexDecidableEq := inferInstance
dartDecidableEq := inferInstance
dartNonempty := inferInstance
graph := G
def size (G : Bundle A) : Nat := Fintype.card G.Vertex + Fintype.card G.Dart
def Satisfiable (G : Bundle A) : Prop := G.graph.Satisfiable
def rejectionCount (G : Bundle A) (labeling : G.Vertex → A) : Nat :=
G.graph.rejectionCount labeling
theorem size_positive (G : Bundle A) : 0 < G.size :=
lt_of_lt_of_le (Fintype.card_pos : 0 < Fintype.card G.Dart) (Nat.le_add_left _ _)
theorem dartCard_le_size (G : Bundle A) : Fintype.card G.Dart ≤ G.size :=
Nat.le_add_left _ _
@[simp] theorem ofGraph_graph {V E : Type} [Fintype V] [Fintype E]
[DecidableEq V] [DecidableEq E] [Nonempty E] (G : ConstraintGraph V E A) :
(ofGraph G).graph = G := rfl
@[simp] theorem ofGraph_size {V E : Type} [Fintype V] [Fintype E]
[DecidableEq V] [DecidableEq E] [Nonempty E] (G : ConstraintGraph V E A) :
(ofGraph G).size = Fintype.card V + Fintype.card E := rfl
@[simp] theorem ofGraph_satisfiable {V E : Type} [Fintype V] [Fintype E]
[DecidableEq V] [DecidableEq E] [Nonempty E] (G : ConstraintGraph V E A) :
(ofGraph G).Satisfiable ↔ G.Satisfiable := Iff.rfl
@[simp] theorem ofGraph_rejectionCount {V E : Type} [Fintype V] [Fintype E]
[DecidableEq V] [DecidableEq E] [Nonempty E]
(G : ConstraintGraph V E A) (labeling : V → A) :
(ofGraph G).rejectionCount labeling = G.rejectionCount labeling := rfl
section Gap
variable [Fintype A] [Nonempty A]
def minimumRejections (G : Bundle A) : Nat := G.graph.minimumRejections
def gap (G : Bundle A) : ℝ := G.graph.gap
theorem exists_minimizer (G : Bundle A) :
∃ labeling : G.Vertex → A, G.rejectionCount labeling = G.minimumRejections :=
G.graph.exists_minimizer
theorem gap_nonnegative (G : Bundle A) : 0 ≤ G.gap := G.graph.gap_nonnegative
theorem gap_le_one (G : Bundle A) : G.gap ≤ 1 := G.graph.gap_le_one
theorem gap_eq_zero_iff (G : Bundle A) : G.gap = 0 ↔ G.Satisfiable :=
G.graph.gap_eq_zero_iff
theorem le_gap_iff (G : Bundle A) (ε : ℝ) :
ε ≤ G.gap ↔ ∀ labeling : G.Vertex → A,
ε * Fintype.card G.Dart ≤ (G.rejectionCount labeling : ℝ) :=
G.graph.le_gap_iff ε
theorem inverse_card_le_gap_of_unsatisfiable (G : Bundle A) (unsat : ¬ G.Satisfiable) :
1 / (Fintype.card G.Dart : ℝ) ≤ G.gap :=
G.graph.inverse_card_le_gap_of_unsatisfiable unsat
theorem one_le_dartCard_mul_gap (G : Bundle A) (unsat : ¬ G.Satisfiable) :
1 ≤ (Fintype.card G.Dart : ℝ) * G.gap := by
have he : (0 : ℝ) < Fintype.card G.Dart := by exact_mod_cast Fintype.card_pos
have h := (div_le_iff₀ he).mp (G.inverse_card_le_gap_of_unsatisfiable unsat)
simpa only [mul_comm] using h
/-- The actual total graph size supplies the initial inverse-size gap. -/
theorem one_le_size_mul_gap (G : Bundle A) (unsat : ¬ G.Satisfiable) :
1 ≤ (G.size : ℝ) * G.gap := by
have hsize : (Fintype.card G.Dart : ℝ) ≤ (G.size : ℝ) := by
exact_mod_cast G.dartCard_le_size
exact (G.one_le_dartCard_mul_gap unsat).trans
(mul_le_mul_of_nonneg_right hsize G.gap_nonnegative)
@[simp] theorem ofGraph_minimumRejections {V E : Type} [Fintype V] [Fintype E]
[DecidableEq V] [DecidableEq E] [Nonempty E] (G : ConstraintGraph V E A) :
(ofGraph G).minimumRejections = G.minimumRejections := rfl
@[simp] theorem ofGraph_gap {V E : Type} [Fintype V] [Fintype E]
[DecidableEq V] [DecidableEq E] [Nonempty E] (G : ConstraintGraph V E A) :
(ofGraph G).gap = G.gap := rfl
end Gap
end Bundle
end UniqueGamesTheorem.Foundations.PCP.FiniteGraph
end
end
end OAI

Xet Storage Details

Size:
19.2 kB
·
Xet hash:
3bfa5dc73cdd4c997cc086cc12c82cd9c63c5d9e718f01a654ed24c8f091cabd

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.