File size: 2,575 Bytes
4a56cd6 | 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 | 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
|