Graphs given by vertex and edge lists #
The graph problems (IndependentSet, Clique, VertexCover, KColoring, the Hamiltonian
problems, GraphIsomorphism, …) take a graph (Cslib.Complexity.Graph) as a list of declared
vertices, possibly with repetitions, and a list of edges, encoded in binary
(Cslib.Complexity.encGraph). Its mathematical reading is a Mathlib simple graph on ℕ
(Cslib.Complexity.Graph.toSimpleGraph), or the simple graph induced on the subtype of declared
vertices (Cslib.Complexity.Graph.induced): two distinct vertices are adjacent when an edge joins
them in either direction.
This module holds the tools these problems share:
- adjacency is tested in polynomial time (
Cslib.Complexity.Graph.adjBool); - a vertex subset problem with a pairwise condition, such as independent set or clique, is
verified by selecting distinct declared vertices with a certificate mask
(
Cslib.Complexity.Graph.verifySubset, an instance ofCslib.Complexity.subsetVerifier); - the distinct declared vertices (
Cslib.Complexity.Graph.distinctVertices) are listed in polynomial time by selecting every first occurrence (Cslib.Complexity.selectDistinct), and their positions enumerate the declared vertices (Cslib.Complexity.Graph.vertexEquiv); - explicit verifiers with fixed certificate lengths write numbers in unary blocks of a certificate
(
Cslib.Complexity.unaryBlocks): each number, at mostm, gets its own block ofmbits, and it is read back by counting the set bits of its block (Cslib.Complexity.countP_unaryBlocks); - a vertex ordering problem, such as Hamiltonian path/cycle, TSP or graph isomorphism, is verified
by decoding a list of vertices from unary blocks of a certificate
(
Cslib.Complexity.Graph.decodeVertexList) and checking that it lists every vertex of the target list without repetitions (Cslib.Complexity.Graph.enumeratesBool,Cslib.Complexity.Graph.verifyOrdering).
Main definitions #
Cslib.Complexity.Graph,Cslib.Complexity.encGraph,Cslib.Complexity.Graph.toSimpleGraph,Cslib.Complexity.Graph.induced.Cslib.Complexity.Graph.adjBool: executable adjacency.Cslib.Complexity.Graph.verifySubset: the verifier of a vertex subset problem.Cslib.Complexity.Graph.distinctVertices,Cslib.Complexity.Graph.vertexEquiv: the declared vertices without repetitions and their enumeration by positions.Cslib.Complexity.unaryBlocks: numbers written in unary blocks of a certificate.Cslib.Complexity.Graph.enumeratesBool,Cslib.Complexity.Graph.decodeVertexList,Cslib.Complexity.Graph.verifyOrdering: verifying orderings of a vertex list.
Main results #
Cslib.Complexity.Graph.toSimpleGraph_adj,Cslib.Complexity.Graph.induced_adj,Cslib.Complexity.Graph.adjBool_eq_true_iff: adjacency.Cslib.Complexity.Graph.computableInPolyTime_adjBool,Cslib.Complexity.Graph.computableInPolyTime_adjBool_comp: testing adjacency is polynomial-time.Cslib.Complexity.Graph.isVerifier_verifySubset,Cslib.Complexity.Graph.computableInPolyTime_verifySubset: the subset verifier is a polynomial-time verifier.Cslib.Complexity.Graph.length_vertices_le_encGraph,Cslib.Complexity.Graph.length_vertices_add_length_edges_le_encGraph: a graph lists no more vertices, or vertices and edges, than the length of its encoding.Cslib.Complexity.countP_unaryBlocks: counting the set bits of a block reads its number.Cslib.Complexity.Graph.exists_decodeVertexList_eq,Cslib.Complexity.Graph.isVerifier_verifyOrdering,Cslib.Complexity.Graph.computableInPolyTime_verifyOrdering: the ordering verifier is a polynomial-time verifier with quadratic certificate length.
References #
Instances For
The simple graph of an edge list: two distinct vertices are adjacent when an edge joins them, in either direction.
Instances For
Adjacency in the simple graph of an edge list: two distinct vertices joined by an edge in
either direction. It is not a simp lemma, so that the adjacency stays folded until a proof
unfolds it.
Declared vertices #
The declared vertices of G without repetitions, in the order of their first occurrences.
Instances For
The distinct declared vertices are the declared vertices.
The distinct declared vertices are listed without repetitions.
The distinct declared vertices are as many as the elements of the vertex list.
A graph has no more distinct vertices than the length of its encoding.
Positions in G.distinctVertices enumerate the declared vertices.
Instances For
Listing the distinct vertices is polynomial-time.
Subset verification on encoded graphs #
Executable adjacency test on an edge list: two distinct vertices are adjacent when an edge joins them in either direction.
Instances For
Testing adjacency in an encoded graph is polynomial-time.
Testing adjacency between computed vertices of a computed graph is polynomial-time. This is
Cslib.Complexity.Graph.computableInPolyTime_adjBool in the compositional form that fun_prop
uses.
Verify a cardinality-m vertex subset problem with pairwise relation rel: select distinct
declared vertices from G.vertices by the certificate mask, compare the selected count with m in
binary, and test rel on all distinct selected pairs.
Instances For
verifySubset is a polynomial-length verifier for any graph subset problem whose pairwise
relation agrees with rel on distinct vertices.
verifySubset is computable in polynomial time whenever the pairwise test rel is.
Unary blocks #
Counting the set bits of block a of unaryBlocks m N f reads f a, when f a fits in the
block and the block fits in the certificate.
Ordering verification #
Executable test that p lists every vertex of V exactly once and nothing else.
Instances For
enumeratesBool V p holds exactly when p lists the members of V without repetition.
The list of vertices described by a certificate w, for a vertex list V of length m: w
is read as blocks of m bits, one for each distinct vertex of V, and the block numbered a
names the entry of V whose position is its number of set bits, or 0 if there is none.
Instances For
Verify a vertex ordering problem: decode a list of vertices from the certificate
(decodeVertexList), check that it lists every vertex of V x exactly once, and test it with
check.
Instances For
verifyOrdering verifies the existence of an ordering of the vertices satisfying P, with
certificates of length n ^ 2 for instances of encoded length n, as long as check decides
P and the vertex list is not longer than the encoded instance.
Testing whether a list lists every vertex of another exactly once is polynomial-time.
Decoding a list of vertices from a certificate is polynomial-time.
verifyOrdering is polynomial-time whenever the vertex list and the test check are.