Download data/lean/OAI/Computability/DirectedFeedback/Model.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 3.94 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/DirectedFeedback/Model.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/DirectedFeedback/Model.lean
-
curl -L -o Model.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/DirectedFeedback/Model.lean
3.94 kB
| 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 | |