introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
2.58 kB
import Mathlib
import OAI.Computability.VertexCover.Encoding.BinaryEncoding
namespace OAI
section
namespace VertexCover
def ThreeSAT (input : List Bool) : Prop :=
βˆƒ formula, UniqueGames.BinaryEncoding.decodeFormula input = some formula ∧
formula.Satisfiable
structure ExplicitGraph where
n : β„•
edges : List (Fin n Γ— Fin n)
increasing : βˆ€ e ∈ edges, e.1 < e.2
nodup : edges.Nodup
namespace ExplicitGraph
def Cover (G : ExplicitGraph) (S : Finset (Fin G.n)) : Prop :=
βˆ€ e ∈ G.edges, e.1 ∈ S ∨ e.2 ∈ S
instance (G : ExplicitGraph) (S : Finset (Fin G.n)) : Decidable (G.Cover S) :=
inferInstanceAs (Decidable (βˆ€ e ∈ G.edges, e.1 ∈ S ∨ e.2 ∈ S))
noncomputable def coverNumber (G : ExplicitGraph) : β„• :=
Nat.find (show βˆƒ k : β„•, βˆƒ S : Finset (Fin G.n), G.Cover S ∧ S.card = k from
⟨G.n, Finset.univ, by simp [Cover], by simp⟩)
def bits (G : ExplicitGraph) : List Bool :=
let names := [G.n] ++ List.range G.n ++ [G.edges.length] ++
G.edges.flatMap (fun e => [e.1.val, e.2.val])
names.flatMap UniqueGames.BinaryEncoding.nameBits
end ExplicitGraph
def FiniteAlphabet (M : Turing.FinTM2) : Prop := βˆ€ k, Finite (M.Ξ“ k)
structure GapReduction (m : β„•) where
construct : List Bool β†’ ExplicitGraph
computation : Turing.TM2ComputableInPolyTime (id : List Bool β†’ List Bool)
ExplicitGraph.bits construct
finiteAlphabet : FiniteAlphabet computation.tm
completeness : βˆ€ input, ThreeSAT input β†’
((construct input).coverNumber : ℝ) <
(1 / 2 + 1 / (m : ℝ)) * (construct input).n
soundness : βˆ€ input, Β¬ ThreeSAT input β†’
(1 - 1 / (m : ℝ)) * (construct input).n <
((construct input).coverNumber : ℝ)
def natListBits (L : List β„•) : List Bool :=
(L.length :: L).flatMap UniqueGames.BinaryEncoding.nameBits
structure Approximation (Ξ± : ℝ) where
run : ExplicitGraph β†’ List β„•
computation : Turing.TM2ComputableInPolyTime ExplicitGraph.bits natListBits run
finiteAlphabet : FiniteAlphabet computation.tm
nodup : βˆ€ G, (run G).Nodup
vertices : βˆ€ G, βˆ€ v ∈ run G, v < G.n
covers : βˆ€ G, βˆ€ e ∈ G.edges, e.1.val ∈ run G ∨ e.2.val ∈ run G
quality : βˆ€ G, ((run G).length : ℝ) ≀ Ξ± * (G.coverNumber : ℝ)
structure ThreeSATDecision where
run : List Bool β†’ Bool
computation : Turing.TM2ComputableInPolyTime (id : List Bool β†’ List Bool)
(fun b : Bool => [b]) run
finiteAlphabet : FiniteAlphabet computation.tm
correct : βˆ€ input, run input = true ↔ ThreeSAT input
end VertexCover
end
end OAI