Lax47.Complexity
Executable graph encodings and triangle-free approximation
concepts/Lax47/Complexity.lean · lax-47
No public endorsements yet.
Loading review…
Sign in with ORCIDConcept map
Definition
Graphs are finite Boolean adjacency matrices with symmetry and looplessness certificates. Their machine word is the vertex count followed by the complete row-major matrix, with Booleans encoded by and . An approximation is a function certified polynomial-time by the Lax51 finite-Turing model; its returned independent set is decoded from that certified function.
Lean source view on GitHub
| 1 | import Lax47.Machine |
| 2 | import Mathlib.Analysis.SpecialFunctions.Pow.Real |
| 3 | import Mathlib.Combinatorics.SimpleGraph.Clique |
| 4 | import Mathlib.Data.Finset.Card |
| 5 | |
| 6 | /-! |
| 7 | --- |
| 8 | title: Executable graph encodings and triangle-free approximation |
| 9 | type: definition |
| 10 | --- |
| 11 | Graphs are finite Boolean adjacency matrices with symmetry and looplessness |
| 12 | certificates. Their machine word is the vertex count followed by the complete |
| 13 | row-major matrix, with Booleans encoded by and . An approximation is a |
| 14 | function certified polynomial-time by the Lax51 finite-Turing model; its |
| 15 | returned independent set is decoded from that certified function. |
| 16 | -/ |
| 17 | |
| 18 | set_option autoImplicit false |
| 19 | |
| 20 | namespace Lax47.Complexity |
| 21 | |
| 22 | open Lax47.Machine |
| 23 | |
| 24 | export Lax47.Machine |
| 25 | (BitString Language RandomSeed PolytimeProgram NPVerifier BPPAlgorithm |
| 26 | InNP InBPP NPSubsetBPP polynomialBound pairBits) |
| 27 | |
| 28 | /-- An executable simple graph on the labeled vertex set . -/ |
| 29 | structure GraphCode (n : ℕ) where |
| 30 | adjacent : Fin n → Fin n → Bool |
| 31 | loopless : ∀ vertex, adjacent vertex vertex = false |
| 32 | symmetric : ∀ left right, adjacent left right = adjacent right left |
| 33 | |
| 34 | /-- The mathematical simple graph represented by a Boolean adjacency matrix. -/ |
| 35 | def GraphCode.graph {n : ℕ} (code : GraphCode n) : SimpleGraph (Fin n) where |
| 36 | Adj left right := code.adjacent left right = true |
| 37 | symm left right h := by |
| 38 | change code.adjacent right left = true |
| 39 | rw [← code.symmetric] |
| 40 | exact h |
| 41 | loopless := ⟨fun vertex ↦ by |
| 42 | simp [code.loopless]⟩ |
| 43 | |
| 44 | /-- Vertex count followed by the row-major adjacency matrix. -/ |
| 45 | def GraphCode.bits {n : ℕ} (code : GraphCode n) : BitString := |
| 46 | n :: List.ofFn fun rank : Fin (n * n) ↦ |
| 47 | let vertex := finProdFinEquiv.symm rank |
| 48 | bitWord (code.adjacent vertex.1 vertex.2) |
| 49 | |
| 50 | /-- Decode the first output bits as a vertex set. -/ |
| 51 | def decodeVertexSet (n : ℕ) (bits : BitString) : Finset (Fin n) := |
| 52 | Finset.univ.filter fun vertex ↦ bits[vertex.1]? = some 1 |
| 53 | |
| 54 | /-- A polynomial-time executable approximation for triangle-free Max Independent Set. -/ |
| 55 | structure TriangleFreeMISApproximation (ε : ℝ) where |
| 56 | program : PolytimeProgram |
| 57 | correctness : ∀ (n : ℕ) (code : GraphCode n), |
| 58 | code.graph.CliqueFree 3 → |
| 59 | let set := decodeVertexSet n (program.output code.bits) |
| 60 | code.graph.IsIndepSet set ∧ |
| 61 | (code.graph.indepNum : ℝ) ≤ |
| 62 | Real.rpow n ((1 : ℝ) / 2 - ε) * set.card |
| 63 | |
| 64 | end Lax47.Complexity |
| 65 |
Community review
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above; your ORCID profile must share a public name.
0 comments