Computing decompositions from a given 2-sequence
Lax528502.DecompositionAlgorithms · concepts/Lax528502/DecompositionAlgorithms.lean · lax-528502
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
A graph with a given -sequence comes with a numbering of its vertices. A branch-decomposition algorithm returns its tree in that numbering. A tree-decomposition algorithm also chooses a numbering of the bags and writes the tree and its bags. A time bound of instructions applies at every word width large enough to address .
Concept map
Lean source view on GitHub
| 1 | import Lax528502.ContractionInput |
| 2 | import Lax528502.GraphProblems |
| 3 | import Lax528502.MimWidth |
| 4 | import Lax528502.TreeIndependence |
| 5 | import Lax759944.RamPolytime |
| 6 | import Lax808846.Ram |
| 7 | |
| 8 | /-! |
| 9 | --- |
| 10 | title: Computing decompositions from a given 2-sequence |
| 11 | type: definition |
| 12 | --- |
| 13 | A graph with a given -sequence comes with a numbering of its vertices. |
| 14 | A branch-decomposition algorithm returns its tree in that numbering. A |
| 15 | tree-decomposition algorithm also chooses a numbering of the bags and writes |
| 16 | the tree and its bags. A time bound of instructions applies at every word |
| 17 | width large enough to address . |
| 18 | -/ |
| 19 | |
| 20 | namespace Lax528502.DecompositionAlgorithms |
| 21 | |
| 22 | open Lax183560 Lax228581.TwinWidth Lax228581.Treewidth |
| 23 | open Lax759944.RamPolytime Lax808846.Ram |
| 24 | |
| 25 | /-- A finite graph, its vertex numbering, and a witnessing contraction sequence. -/ |
| 26 | structure GraphWithTwoSequence where |
| 27 | Vertex : Type |
| 28 | [finiteVertices : Fintype Vertex] |
| 29 | [decidableVertices : DecidableEq Vertex] |
| 30 | n : ℕ |
| 31 | order : Fin n ≃ Vertex |
| 32 | graph : SimpleGraph Vertex |
| 33 | sequence : PartitionSequence graph 2 |
| 34 | |
| 35 | attribute [instance] GraphWithTwoSequence.finiteVertices GraphWithTwoSequence.decidableVertices |
| 36 | |
| 37 | /-- Present a graph and its supplied sequence in the given vertex order. -/ |
| 38 | def GraphWithTwoSequence.of {V : Type} [Fintype V] [DecidableEq V] {n : ℕ} |
| 39 | (order : Fin n ≃ V) (G : SimpleGraph V) (S : PartitionSequence G 2) : GraphWithTwoSequence := |
| 40 | { Vertex := V, n := n, order := order, graph := G, sequence := S } |
| 41 | |
| 42 | /-- A numbered graph and its sequence on the RAM input. -/ |
| 43 | noncomputable def GraphWithTwoSequence.input (I : GraphWithTwoSequence) : List ℕ := |
| 44 | ContractionInput.encode I.order I.graph I.sequence |
| 45 | |
| 46 | /-- A word-RAM algorithm with a verified polynomial running time. -/ |
| 47 | structure PolynomialTimeAlgorithm where |
| 48 | run : List ℕ → List ℕ |
| 49 | polynomialTime : RamPolytime run |
| 50 | |
| 51 | /-- Return the indicated branch tree, using the vertex numbers of the input. -/ |
| 52 | def PolynomialTimeAlgorithm.OutputsBranchDecomposition (algorithm : PolynomialTimeAlgorithm) |
| 53 | (I : GraphWithTwoSequence) (T : Option (BranchDecompositions.BinaryTree I.Vertex)) : Prop := |
| 54 | algorithm.run I.input = MimWidth.encode I.order T |
| 55 | |
| 56 | /-- Return the same tree and bags at every word width that can address the |
| 57 | instruction budget. The output includes the complete tree and bag incidence matrices. -/ |
| 58 | def OutputsTreeDecompositionWithin (program : Program) (I : GraphWithTwoSequence) (t : ℕ) |
| 59 | (D : TreeDecomposition I.graph) (budget : ℕ) : Prop := |
| 60 | ∃ (m : ℕ) (nodes : Fin m ≃ D.Node), ∀ w : ℕ, budget < 2 ^ w → |
| 61 | ∃ steps ≤ budget, RunsTo w program (ContractionInput.tape (t :: I.input)) |
| 62 | (TreeIndependence.encode I.order D nodes) steps |
| 63 | |
| 64 | /-- Decide the proposition with a single Boolean answer on the given input. -/ |
| 65 | def PolynomialTimeAlgorithm.Decides (algorithm : PolynomialTimeAlgorithm) |
| 66 | (input : List ℕ) (proposition : Prop) : Prop := |
| 67 | ∃ answer : Bool, algorithm.run input = [answer.toNat] ∧ (answer = true ↔ proposition) |
| 68 | |
| 69 | /-- Return an optimal vertex set for the requested problem or report infeasibility. -/ |
| 70 | def PolynomialTimeAlgorithm.FindsOptimum (algorithm : PolynomialTimeAlgorithm) |
| 71 | {n : ℕ} (problem : GraphProblems.Problem n) (G : SimpleGraph (Fin n)) |
| 72 | (graphInput : List ℕ) : Prop := |
| 73 | problem.Answer G (algorithm.run (GraphProblems.input graphInput problem)) |
| 74 | |
| 75 | /-- A graph already numbered by the vertices of its contraction sequence. -/ |
| 76 | noncomputable def numberedSequenceInput {n : ℕ} {G : SimpleGraph (Fin n)} |
| 77 | (sequence : PartitionSequence G 2) : List ℕ := |
| 78 | ContractionInput.encode (Equiv.refl _) G sequence |
| 79 | |
| 80 | /-- A guarantee on every input whose graph and computed branch decomposition |
| 81 | have the stated width. Auxiliary problem data may follow the graph. -/ |
| 82 | def GivenBranchDecomposition (width : ℕ) (branch : PolynomialTimeAlgorithm) |
| 83 | (guarantee : ∀ {n : ℕ}, SimpleGraph (Fin n) → List ℕ → Prop) : Prop := |
| 84 | ∀ (x : List ℕ) (n : ℕ) (G : SimpleGraph (Fin n)) (T : Option (BranchDecompositions.BinaryTree (Fin n))), |
| 85 | (ContractionInput.graph (Equiv.refl _) G).IsPrefix x → |
| 86 | branch.run x = MimWidth.encode (Equiv.refl _) T → |
| 87 | MimWidth.IsBranchDecompositionOfWidthAtMost G T width → guarantee G x |
| 88 | |
| 89 | end Lax528502.DecompositionAlgorithms |
| 90 |
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments