cfahlgren1/math / lean /OAI /Combinatorics /IndependentSets /Machines /MachineLazyTableRuntime.lean
cfahlgren1's picture
download
raw
5.92 kB
import Mathlib
import OAI.Combinatorics.IndependentSets.Machines.Remaining2
namespace OAI
namespace IndependentSetsGames.Foundations.Complexity.MachineLazyTableRuntime
open Turing PCP
open MachineLazyTable (Tape Label State)
def rawProgram (d : Nat) (positive : 0 < d) :
MachineCanonicalOutput.Program Tape (Label d) (State d) where
input := .input
output := .output
main := .split .copyFirst
initial := MachineLazyTable.clean d positive
code := MachineLazyTable.program d positive
theorem sourceMachine_eq (d : Nat) (positive : 0 < d) :
MachineCanonicalOutput.sourceMachine (rawProgram d positive) =
MachineLazyTable.machine d positive := rfl
def cleanupTapes : List Tape :=
[.input, .source, .vertices, .darts, .fuel, .vertex, .reverse,
.tail, .old, .relation, .scratch, .divided, .quotient, .newReverse, .rowBuffer]
theorem cleanup_complete (d : Nat) (positive : 0 < d) (k : Tape) :
k ∈ cleanupTapes ↔ k ≠ (rawProgram d positive).output := by
cases k <;> simp [cleanupTapes, rawProgram]
def terminalRun (d : Nat) (positive : 0 < d) (a : PortTables.Input d) :
MachineCanonicalOutput.TerminalRun (rawProgram d positive) (PortTables.inputBits a)
(PortTables.inputBits (PreprocessingStageMaps.lazy d a))
((MachineLazyTable.timePolynomial d).eval (PortTables.inputBits a).length) where
state := MachineLazyTable.clean d positive
tapes := MachineLazyTable.finalTapes (PortTables.inputBits a)
(PortTables.inputBits (PreprocessingStageMaps.lazy d a))
execution := MachineLazyTable.machineInTime a.2 positive
output_eq := rfl
noncomputable def computableInPolyTime (d : Nat) (positive : 0 < d) :
TM2ComputableInPolyTime (PortTables.inputBits (ports := d))
(PortTables.inputBits (ports := 2 * d)) (PreprocessingStageMaps.lazy d) :=
MachineCanonicalOutput.computableInPolyTime (rawProgram d positive) cleanupTapes
(cleanup_complete d positive) PortTables.inputBits PortTables.inputBits
(PreprocessingStageMaps.lazy d) (MachineLazyTable.timePolynomial d) (terminalRun d positive)
theorem finite_alphabet (d : Nat) (positive : 0 < d) :
∀ k, Finite ((computableInPolyTime d positive).tm.Γ k) :=
MachineCanonicalOutput.computableInPolyTime_finite_alphabet (rawProgram d positive) cleanupTapes
(cleanup_complete d positive) PortTables.inputBits PortTables.inputBits
(PreprocessingStageMaps.lazy d) (MachineLazyTable.timePolynomial d) (terminalRun d positive)
end IndependentSetsGames.Foundations.Complexity.MachineLazyTableRuntime
namespace IndependentSetsGames.Foundations.PCP.PreprocessingFinishRuntime
open Turing IndependentSetsGames.Foundations.Complexity
open PreprocessingRegularTables
def finish (H : PreprocessingTables.BaseTable) (d : Nat) (input : PortTables.Input d) :
PortTables.Input (2 * (d + internalDegree)) :=
PreprocessingStageMaps.lazy (d + internalDegree)
(PreprocessingStageMaps.paddedOverlay H d input)
theorem output_eq_finish (H : PreprocessingTables.BaseTable) (t : GraphTables.Table) :
PreprocessingTables.output H t =
finish H (internalDegree + 1) (PreprocessingStageMaps.regular H t) := rfl
theorem finish_degree_positive (d : Nat) (hd : 0 < d) : 0 < d + internalDegree :=
hd.trans_le (Nat.le_add_right d internalDegree)
noncomputable def computableInPolyTime (H : PreprocessingTables.BaseTable)
(d : Nat) (hd : 0 < d) :
TM2ComputableInPolyTime (PortTables.inputBits (ports := d))
(PortTables.inputBits (ports := 2 * (d + internalDegree))) (finish H d) := by
change TM2ComputableInPolyTime _ _
(fun input => PreprocessingStageMaps.lazy (d + internalDegree)
(PreprocessingStageMaps.paddedOverlay H d input))
exact MachineSequential.composeBits (MachinePaddedOverlayRuntime.computableInPolyTime H d hd)
(MachineLazyTableRuntime.computableInPolyTime (d + internalDegree)
(finish_degree_positive d hd))
theorem finite_alphabet (H : PreprocessingTables.BaseTable) (d : Nat) (hd : 0 < d) :
MachineFiniteAlphabet.FiniteAlphabet (computableInPolyTime H d hd).tm :=
MachineFiniteAlphabet.composeBits
(MachinePaddedOverlayRuntime.computableInPolyTime H d hd)
(MachineLazyTableRuntime.computableInPolyTime (d + internalDegree)
(finish_degree_positive d hd))
(MachinePaddedOverlayRuntime.finite_alphabet H d hd)
(MachineLazyTableRuntime.finite_alphabet (d + internalDegree)
(finish_degree_positive d hd))
end IndependentSetsGames.Foundations.PCP.PreprocessingFinishRuntime
namespace IndependentSetsGames.Foundations.PCP.PreprocessingRuntime
open Turing IndependentSetsGames.Foundations.Complexity
open PreprocessingRegularTables
noncomputable def tablePolynomialTime (H : PreprocessingTables.BaseTable) :
TM2ComputableInPolyTime GraphTables.tableBits
(PortTables.inputBits (ports := PreprocessingTables.degree))
(PreprocessingTables.output H) := by
change TM2ComputableInPolyTime GraphTables.tableBits
(PortTables.inputBits (ports := 2 * ((internalDegree + 1) + internalDegree)))
(fun t => PreprocessingFinishRuntime.finish H (internalDegree + 1)
(PreprocessingStageMaps.regular H t))
exact MachineSequential.composeBits
(MachineRegularTableRuntime.computableInPolyTime H)
(PreprocessingFinishRuntime.computableInPolyTime H (internalDegree + 1)
(Nat.succ_pos internalDegree))
theorem finiteAlphabet (H : PreprocessingTables.BaseTable) :
MachineFiniteAlphabet.FiniteAlphabet (tablePolynomialTime H).tm :=
MachineFiniteAlphabet.composeBits
(MachineRegularTableRuntime.computableInPolyTime H)
(PreprocessingFinishRuntime.computableInPolyTime H (internalDegree + 1)
(Nat.succ_pos internalDegree))
(MachineRegularTableRuntime.finite_alphabet H)
(PreprocessingFinishRuntime.finite_alphabet H (internalDegree + 1)
(Nat.succ_pos internalDegree))
end IndependentSetsGames.Foundations.PCP.PreprocessingRuntime
end OAI

Xet Storage Details

Size:
5.92 kB
·
Xet hash:
8afe6d849881c8ff53b6af5d0a5f8b2a96de383d1150495b0ba2558a227da602

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