File size: 5,663 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 | import Mathlib
import OAI.Computability.VertexCover.Machines.NatLog
import OAI.Computability.VertexCover.Machines.LoopFrom
import OAI.Computability.VertexCover.Machines.Round
import OAI.Computability.VertexCover.Machines.TableCodeBound
import OAI.Computability.VertexCover.Machines.InitialCorrect
namespace OAI
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
section
namespace VertexCover.Machine
open UniqueGames.Foundations
open PCP
theorem Iterate.run_source {α : Type} (f : α → α) (n : ℕ) (a : α) :
Iterate.run f n a = AmplificationIteration.run f n a := by
have commute (k : ℕ) (a : α) :
AmplificationIteration.run f k (f a) = f (AmplificationIteration.run f k a) := by
induction k with
| zero => rfl
| succ k ih => exact congrArg f ih
induction n generalizing a with
| zero => rfl
| succ n ih => exact (ih (f a)).trans (commute n a)
namespace IterationMachine
open TableMachine
abbrev State := ℕ × GraphTables.Table
abbrev enc : State → List Bool := prodBits natBits tableCode
def initial (F : Target.Formula) : State :=
(TableIteration.iterationCount F,RawInitialTables.table F)
def result (H : RoundTables.BaseTable) (F : Target.Formula) : State :=
(0,TableIteration.outputTable H F)
noncomputable def sizePolynomial : Polynomial ℕ :=
let s := (2*Polynomial.X)^TableIteration.polynomialDegree*Polynomial.X
2*Polynomial.X+1+TableMachine.lengthPolynomial.comp s
theorem size_bound (H : RoundTables.BaseTable) (F : Target.Formula) (k l : ℕ)
(h : k+l=TableIteration.iterationCount F) :
(enc (l,Iterate.run (RoundTables.build H) k (RawInitialTables.table F))).length ≤
sizePolynomial.eval (enc (initial F)).length := by
let s := RoundTables.size (RoundTables.initial F)
let N := (enc (initial F)).length
have hsN : s ≤ N := by
have hs := TableMachine.size_le_code (RawInitialTables.table F)
simp only [N,initial,pairBits_length,natBits_length]
exact hs.trans (Nat.le_add_left _ _)
have hlN : l ≤ N := by
simp only [N,initial,pairBits_length,natBits_length]
omega
have hk : k ≤ AmplificationIteration.rounds s := by
change k ≤ TableIteration.iterationCount F
omega
have hp := (Nat.pow_le_pow_right RoundTables.sizeFactor_positive hk).trans
(AmplificationIteration.blowup_rounds_le (RoundTables.size_positive (RoundTables.initial F))
TableIteration.sizeFactor_le_power)
have ht := (TableIteration.run_size H k (RoundTables.initial F)).trans (Nat.mul_le_mul_right s hp)
have htN := ht.trans (Nat.mul_le_mul
(Nat.pow_le_pow_left (Nat.mul_le_mul_left 2 hsN) _) hsN)
have hm : (Iterate.run (RoundTables.build H) k (RawInitialTables.table F)).vertices+
(Iterate.run (RoundTables.build H) k (RawInitialTables.table F)).darts ≤
(2*N)^TableIteration.polynomialDegree*N := by
rw [Iterate.run_source]
change (TableIteration.runTables H k (RawInitialTables.table F)).vertices+
(TableIteration.runTables H k (RawInitialTables.table F)).darts ≤ _
have hv : (TableIteration.run H k (RoundTables.initial F)).val =
TableIteration.runTables H k (RawInitialTables.table F) := TableIteration.run_val H k _
rw [← hv]
exact htN
have hb := (TableMachine.codeLength_le_eval _).trans
(Complexity.MachineComposition.natPolynomial_eval_mono _ hm)
calc
_ = 2*l+1+(tableCode (Iterate.run (RoundTables.build H) k (RawInitialTables.table F))).length := by
simpa only [natBits_length] using pairBits_length (natBits l) (tableCode (Iterate.run (RoundTables.build H) k (RawInitialTables.table F)))
_ ≤ 2*N+1+TableMachine.lengthPolynomial.eval ((2*N)^TableIteration.polynomialDegree*N) :=
Nat.add_le_add (by omega) hb
_ = sizePolynomial.eval N := by
simp only [sizePolynomial,Polynomial.eval_add,Polynomial.eval_mul,Polynomial.eval_ofNat,
Polynomial.eval_X,Polynomial.eval_one,Polynomial.eval_comp,Polynomial.eval_pow]
noncomputable def initialPoly : Poly FormulaParser.targetCode enc initial := by
let T := InitialTable.initialPoly
let s := ((T.comp TableMachine.verticesPoly).pair (T.comp TableMachine.dartsPoly)).comp Poly.natAdd
let n := (s.comp Poly.natLog2).comp Poly.natSucc
exact (n.pair T).congr (fun _ => rfl)
noncomputable def loopPoly (H : RoundTables.BaseTable) :
Poly (fun F => enc (initial F)) enc (result H) :=
Poly.loopFrom (Iterate.bodyPoly (RoundTables.build H) tableCode (RoundMachine.poly H))
initial (result H) sizePolynomial (Polynomial.X+1) (by
intro F
refine ⟨TableIteration.iterationCount F+1,?_,?_⟩
· simp only [Polynomial.eval_add,Polynomial.eval_X,Polynomial.eval_one,initial,
prodBits,pairBits_length,natBits_length]
omega
· have h := Iterate.bounded (RoundTables.build H) tableCode (TableIteration.iterationCount F)
(RawInitialTables.table F) _ (size_bound H F)
simpa only [Iterate.run_source,initial,result,TableIteration.outputTable,TableIteration.runTables] using h)
noncomputable def poly (H : RoundTables.BaseTable) :
Poly FormulaParser.targetCode tableCode (TableIteration.outputTable H) :=
((Poly.initializeLoop initialPoly (loopPoly H)).comp (Poly.snd natBits tableCode)).congr (fun _ => rfl)
end IterationMachine
end VertexCover.Machine
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end OAI
|