File size: 2,748 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
import Mathlib

namespace OAI

namespace LargeIndependentSets

structure Literal where
  name : β„•
  positive : Bool
  deriving DecidableEq

structure Formula where
  clauses : List (List Literal)
  width : βˆ€ C ∈ clauses, C.length ≀ 3

def Formula.Satisfiable (Ο† : Formula) : Prop :=
  βˆƒ assignment : β„• β†’ Bool, βˆ€ C ∈ Ο†.clauses,
    βˆƒ l ∈ C, assignment l.name = l.positive

/-- Binary framing: `true,b` for a payload bit and `false` as terminator. -/
def frame : List Bool β†’ List Bool
  | [] => [false]
  | b :: bs => true :: b :: frame bs

def nameBits (n : β„•) : List Bool := frame n.bits

def literalBits (l : Literal) : List Bool := l.positive :: nameBits l.name

def clauseBits (C : List Literal) : List Bool :=
  nameBits C.length ++ C.flatMap literalBits

def formulaBits (Ο† : Formula) : List Bool :=
  nameBits Ο†.clauses.length ++ Ο†.clauses.flatMap clauseBits

/-- A nonempty, finite, simple, undirected, unweighted graph. -/
structure Graph where
  vertices : β„•
  nonempty : 0 < vertices
  adj : Fin vertices β†’ Fin vertices β†’ Bool
  symm : βˆ€ u v, adj u v = adj v u
  loopless : βˆ€ u, adj u u = false

def Graph.Independent (G : Graph) (S : Finset (Fin G.vertices)) : Prop :=
  βˆ€ u ∈ S, βˆ€ v ∈ S, u β‰  v β†’ G.adj u v = false

instance (G : Graph) (S : Finset (Fin G.vertices)) : Decidable (G.Independent S) :=
  inferInstanceAs (Decidable (βˆ€ u ∈ S, βˆ€ v ∈ S, u β‰  v β†’ G.adj u v = false))

def Graph.independenceNumber (G : Graph) : β„• :=
  ((Finset.univ : Finset (Fin G.vertices)).powerset.filter G.Independent).sup Finset.card

def Graph.ThreeColorable (G : Graph) : Prop :=
  βˆƒ color : Fin G.vertices β†’ Fin 3,
    βˆ€ u v, G.adj u v = true β†’ color u β‰  color v

/-- Full explicit adjacency matrix, row-major, with binary vertex count. -/
def graphBits (G : Graph) : List Bool :=
  nameBits G.vertices ++ (List.finRange G.vertices).flatMap
    (fun u => (List.finRange G.vertices).map (G.adj u))

open scoped Classical
noncomputable section

/-- Polynomial-time graph reduction with a real independence-ratio threshold. -/
structure RealGraphReduction (Ξ΄ : ℝ) where
  reduce : List Bool β†’ Graph
  computation : Turing.TM2ComputableInPolyTime (id : List Bool β†’ List Bool) graphBits reduce
  finiteAlphabets : βˆ€ k : computation.tm.K, Finite (computation.tm.Ξ“ k)
  outputBound : Polynomial β„•
  outputSize : βˆ€ b, (graphBits (reduce b)).length ≀ outputBound.eval b.length
  completeness : βˆ€ Ο† : Formula, Ο†.Satisfiable β†’ (reduce (formulaBits Ο†)).ThreeColorable
  soundness : βˆ€ Ο† : Formula, ¬φ.Satisfiable β†’
    ((reduce (formulaBits Ο†)).independenceNumber : ℝ) <
      Ξ΄ * (reduce (formulaBits Ο†)).vertices

end
end LargeIndependentSets

end OAI