openAI-math-dataset / lean /OAI /Computability /UniqueGames /PCP /AmplificationIteration.lean
roseking's picture
Add lean source and binary files (part 63)
760f90e verified
Raw History Blame Contribute Delete
4.38 kB
import Mathlib.Data.Nat.Log
import Mathlib.Basic.Real.Basic
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.Ring
namespace OAI
section
/-!
The finite iteration and size arithmetic for an amplification transformation.
The transformation itself must be supplied by the actual graph construction;
these theorems do not assert that such a transformation exists. In particular,
the polynomial size estimate below is not a machine runtime certificate.
-/
namespace UniqueGamesTheorem.Foundations.PCP.AmplificationIteration
def run {X : Type*} (step : X → X) : Nat → X → X
| 0, x => x
| n + 1, x => step (run step n x)
private theorem min_double_min (u cap : ℝ) (hc : 0 ≤ cap) :
min (2 * min u cap) cap = min (2 * u) cap := by
by_cases hu : u ≤ cap
· rw [min_eq_left hu]
· have hcu : cap ≤ u := le_of_not_ge hu
rw [min_eq_right hcu, min_eq_right (by linarith : cap ≤ 2 * cap),
min_eq_right (by linarith : cap ≤ 2 * u)]
theorem run_gap {X : Type*} (step : X → X) (gap : X → ℝ)
(cap : ℝ) (hc : 0 ≤ cap)
(amplifies : ∀ x, min (2 * gap x) cap ≤ gap (step x))
(n : Nat) (x : X) :
min (2 ^ n * gap x) cap ≤ gap (run step n x) := by
induction n with
| zero => simp [run]
| succ n ih =>
have hm : min (2 * min (2 ^ n * gap x) cap) cap ≤
min (2 * gap (run step n x)) cap :=
min_le_min (mul_le_mul_of_nonneg_left ih (by norm_num)) le_rfl
rw [min_double_min _ _ hc] at hm
have h := hm.trans (amplifies (run step n x))
simpa [run, pow_succ, mul_assoc, mul_left_comm, mul_comm] using h
theorem run_preserves {X : Type*} (step : X → X) (P : X → Prop)
(preserves : ∀ x, P x → P (step x)) (n : Nat) (x : X) (hx : P x) :
P (run step n x) := by
induction n with
| zero => exact hx
| succ n ih => exact preserves _ ih
theorem run_size {X : Type*} (step : X → X) (size : X → Nat) (C : Nat)
(blowup : ∀ x, size (step x) ≤ C * size x) (n : Nat) (x : X) :
size (run step n x) ≤ C ^ n * size x := by
induction n with
| zero => simp [run]
| succ n ih =>
have h := (blowup (run step n x)).trans (Nat.mul_le_mul_left C ih)
simpa [run, pow_succ, Nat.mul_assoc, Nat.mul_left_comm, Nat.mul_comm] using h
/-- A concrete logarithmic iteration count, including the zero input. -/
def rounds (n : Nat) : Nat := Nat.log2 n + 1
theorem rounds_large (n : Nat) : n < 2 ^ rounds n := by
simpa [rounds, Nat.log2_eq_log_two] using
(Nat.lt_pow_succ_log_self (by decide : 1 < 2) n)
theorem rounds_power_le {n : Nat} (hn : 0 < n) : 2 ^ rounds n ≤ 2 * n := by
have h := Nat.pow_log_le_self 2 (Nat.ne_of_gt hn)
simpa [rounds, Nat.log2_eq_log_two, pow_succ, Nat.mul_comm] using
(Nat.mul_le_mul_right 2 h)
/-- The constant blowup raised to the actual iteration count is polynomial in `n`. -/
theorem blowup_rounds_le {C degree n : Nat} (hn : 0 < n) (hC : C ≤ 2 ^ degree) :
C ^ rounds n ≤ (2 * n) ^ degree := by
calc
C ^ rounds n ≤ (2 ^ degree) ^ rounds n := Nat.pow_le_pow_left hC _
_ = (2 ^ rounds n) ^ degree := by
rw [← pow_mul, ← pow_mul, Nat.mul_comm degree (rounds n)]
_ ≤ (2 * n) ^ degree := Nat.pow_le_pow_left (rounds_power_le hn) _
theorem run_size_polynomial {X : Type*} (step : X → X) (size : X → Nat)
{C degree n : Nat} (hn : 0 < n) (hC : C ≤ 2 ^ degree)
(blowup : ∀ x, size (step x) ≤ C * size x) (x : X) :
size (run step (rounds n) x) ≤ (2 * n) ^ degree * size x :=
(run_size step size C blowup (rounds n) x).trans
(Nat.mul_le_mul_right _ (blowup_rounds_le hn hC))
/-- An inverse-size initial gap reaches the fixed threshold after the concrete loop. -/
theorem run_reaches_cap {X : Type*} (step : X → X) (gap : X → ℝ)
(cap : ℝ) (hc : 0 ≤ cap) (hc1 : cap ≤ 1)
(amplifies : ∀ x, min (2 * gap x) cap ≤ gap (step x))
(n : Nat) (x : X) (hg : 0 ≤ gap x) (hstart : 1 ≤ (n : ℝ) * gap x) :
cap ≤ gap (run step (rounds n) x) := by
have hp : (n : ℝ) ≤ (2 : ℝ) ^ rounds n := by
exact_mod_cast (Nat.le_of_lt (rounds_large n))
have hcap : cap ≤ (2 : ℝ) ^ rounds n * gap x :=
hc1.trans (hstart.trans (mul_le_mul_of_nonneg_right hp hg))
have h := run_gap step gap cap hc amplifies (rounds n) x
rwa [min_eq_right hcap] at h
end UniqueGamesTheorem.Foundations.PCP.AmplificationIteration
end
end OAI