import Mathlib import OAI.Combinatorics.IndependentSets.Reduction.GraphReduction import OAI.Combinatorics.IndependentSets.Reduction.ClampCube import OAI.Combinatorics.IndependentSets.PCP.FinalCNF import OAI.Combinatorics.IndependentSets.Reduction.MapEquiv import OAI.Combinatorics.IndependentSets.Machines.ProfileMachine import OAI.Combinatorics.IndependentSets.Encoding.PortTableEncoding import OAI.Combinatorics.IndependentSets.Machines.MachineLazyTableRuntime import OAI.Combinatorics.IndependentSets.Machines.PCPGapMachine import OAI.Combinatorics.IndependentSets.Machines.TargetLCMachine import OAI.Combinatorics.IndependentSets.Geometry.GeometryOutput namespace OAI namespace LargeIndependentSets open IndependentSetsGames.Foundations open scoped Classical noncomputable section namespace CompleteReduction open PCP Hastad.SourceContexts Hastad.SourceGame open Complexity def gapInput (H : RoundTables.BaseTable) (b : List Bool) : TargetLC.Input := ⟨TableIteration.gapMap H (BinaryNormalize.normalize b),TableIteration.gapMap_nonempty H _⟩ def gapView (H : RoundTables.BaseTable) : Turing.TM2ComputableInPolyTime (id : List Bool → List Bool) (fun F : TargetLC.Input => Complexity.formulaBits F.val) (gapInput H) where tm := (BinaryNormalize.gapCertificate H).tm inputAlphabet := (BinaryNormalize.gapCertificate H).inputAlphabet outputAlphabet := (BinaryNormalize.gapCertificate H).outputAlphabet time := (BinaryNormalize.gapCertificate H).time outputsFun := (BinaryNormalize.gapCertificate H).outputsFun def lcComputer (H : RoundTables.BaseTable) (u : ℕ) : Turing.TM2ComputableInPolyTime (id : List Bool → List Bool) UniformLC.Table.bits (fun b => TargetLC.table u (gapInput H b)) := MachineSequential.composeBits (gapView H) (TargetLC.certificate u) lemma lcComputer_finiteAlphabet (H : RoundTables.BaseTable) (u : ℕ) : MachineFiniteAlphabet.FiniteAlphabet (lcComputer H u).tm := MachineFiniteAlphabet.composeBits (gapView H) (TargetLC.certificate u) (BinaryNormalize.gap_finiteAlphabet H) (TargetLC.finiteAlphabet u) def reduce (H : RoundTables.BaseTable) (p : SamplerParameters) (u q : ℕ) (hq : 0 TargetLC.table u (gapInput H b)) (g := GeometryNames.output (J u) (I u) p q hq) (lcComputer H u) (GeometryNames.graphComputer (J u) (I u) p q hq) lemma finiteAlphabet (H : RoundTables.BaseTable) (p : SamplerParameters) (u q : ℕ) (hq : 0 hF ((BinaryNormalize.satisfiable_iff F).mp h)) have hs := TargetLC.sound u (CompleteReduction.gapInput H (formulaBits F)) (hrep _ hg) have hout := (hp _ _ _ _ _ (TargetLC.table u (CompleteReduction.gapInput H (formulaBits F))).lc).2 hs exact (GeometryNames.outputRenaming (Hastad.SourceContexts.J u) (Hastad.SourceContexts.I u) p q hq (TargetLC.table u (CompleteReduction.gapInput H (formulaBits F)))).symm.strict_density hout end end LargeIndependentSets end OAI