File size: 3,939 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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | import Mathlib
namespace OAI
namespace DirectedFeedback
/-- Unary self-delimiting natural numbers. Outputs are explicit, not succinct. -/
def natBits (n : β) : List Bool := List.replicate n true ++ [false]
/-- The explicit framing used for an input and its NP certificate. -/
def pairBits (p : List Bool Γ List Bool) : List Bool :=
natBits p.1.length ++ p.1 ++ p.2
/-- Finitely many stacks and control states are already part of `FinTM2`.
This additionally excludes infinite stack alphabets. -/
def FiniteAlphabet (M : Turing.FinTM2) : Prop := β k, Finite (M.Ξ k)
/-- Polynomially bounded certificates checked by an actual deterministic
finite-alphabet machine, on the explicitly encoded input/certificate pair. -/
structure NPVerifier where
witnessBound : Polynomial β
verify : (List Bool Γ List Bool) β Bool
computation : Turing.TM2ComputableInPolyTime pairBits (fun b : Bool => [b]) verify
finiteAlphabet : FiniteAlphabet computation.tm
def NPVerifier.Accepts (V : NPVerifier) (input : List Bool) : Prop :=
β witness : List Bool, witness.length β€ V.witnessBound.eval input.length β§
V.verify (input, witness) = true
/-- NP is defined independently of SAT or any hardness assertion. -/
def InNP (language : List Bool β Prop) : Prop :=
β V : NPVerifier, β input, language input β V.Accepts input
/-- Finite loopless digraph. Opposite arcs are permitted. Every arc is listed
explicitly. No symmetric closure or undirected-cycle convention is used. -/
structure Digraph where
n : β
arcs : List (Fin n Γ Fin n)
loopless : β e β arcs, e.1 β e.2
nodup : arcs.Nodup
namespace Digraph
/-- An actual simple directed cycle of positive length. A cyclic enumeration
of `r + 1` distinct vertices supplies every successive arc, including the
closing arc. A 2-cycle is allowed; looplessness rules out length 1. -/
def IsCycle (G : Digraph) {r : β} (c : Fin (r + 1) β Fin G.n) : Prop :=
Function.Injective c β§ β i, (c i, c (i + 1)) β G.arcs
/-- A feedback set intersects EVERY actual directed cycle. -/
def Feedback (G : Digraph) (F : Finset (Fin G.n)) : Prop :=
β (r : β) (c : Fin (r + 1) β Fin G.n), G.IsCycle c β β i, c i β F
/-- Minimum number of vertices of a feedback set. No weights or auxiliary
cost oracle appear in this definition. -/
noncomputable def dfvs (G : Digraph) : β := by
classical
exact Nat.find (show β k : β, β F : Finset (Fin G.n), G.Feedback F β§ F.card = k from
β¨G.n, Finset.univ, by
intro r c _
exact β¨0, Finset.mem_univ _β©, by simpβ©)
/-- Full explicit vertex and arc serialization, including isolated vertices. -/
def bits (G : Digraph) : List Bool :=
([G.n] ++ List.range G.n ++ [G.arcs.length] ++
G.arcs.flatMap (fun e => [e.1.val, e.2.val])).flatMap natBits
end Digraph
/-- Output includes a strictly positive integer threshold. -/
structure GapInstance where
graph : Digraph
k : β
k_pos : 0 < k
def GapInstance.bits (I : GapInstance) : List Bool :=
natBits I.k ++ I.graph.bits
/-- A strict YES/NO gap reduction implemented by a finite-alphabet machine
with polynomial runtime in the raw input bit length. -/
structure GapReduction (A : β) (language : List Bool β Prop) where
construct : List Bool β GapInstance
computation : Turing.TM2ComputableInPolyTime (id : List Bool β List Bool)
GapInstance.bits construct
finiteAlphabet : FiniteAlphabet computation.tm
completeness : β input, language input β
(construct input).graph.dfvs β€ (construct input).k
soundness : β input, Β¬ language input β
A * ((construct input).k : β) < ((construct input).graph.dfvs : β)
/-- Constant-factor directed feedback vertex set hardness for all NP languages. -/
def MainStatement : Prop :=
β A : β, 1 β€ A β β language : List Bool β Prop,
InNP language β Nonempty (GapReduction A language)
end DirectedFeedback
end OAI
|