Documentation

CslibFrontier.Algorithms.Reachability.DoubleCounting

Double-counting certificates for bounded reachability #

This is the branch semantics of Figure 1 in the March 31, 1999 version of Reinhardt and Allender, Making Nondeterminism Unambiguous, Section 2, proof of Theorem 2.2. The edges are unweighted, and a scan in a fixed order makes one choice per vertex: skip it or supply an actual walk of at most k edges. The transcript is indexed by vertex so that permuting scan order cannot introduce spurious ambiguity. Walks are vertex lists in a directed relation, with no padding steps.

The supplied count must equal the size of the breadth-first round, and the supplied sum must equal the sum of its shortest distances. The count forces the scan to cover the round, and the sum forces each supplied walk to be shortest. Thus a successful transcript determines membership even for a vertex outside the round. Its uniqueness is equivalent to uniqueness of the shortest walk at every vertex of the round.

Main results #

This certificate model does not encode machine choice bits or certify the resources of a machine generating the transcript.

noncomputable def Cslib.DoubleCounting.distance {α : Type u_1} (r : α → α → Prop) (s v : α) :

The least number of edges in a walk from s to v, with zero used outside the reachable set. Only distances of vertices in the current round enter the sum.

theorem Cslib.DoubleCounting.distance_spec {α : Type u_1} {r : α → α → Prop} {s v : α} {k : ℕ} (h : v ∈ Relation.reachableWithin r s k) :

A reached vertex has a walk whose length is its distance, bounded by the round index.

noncomputable def Cslib.DoubleCounting.round {α : Type u_1} [Fintype α] (r : α → α → Prop) (s : α) (k : ℕ) :

The breadth-first round as a finite set of vertices.

@[simp]
theorem Cslib.DoubleCounting.mem_round {α : Type u_1} {r : α → α → Prop} {s v : α} {k : ℕ} [Fintype α] :

The finite round contains exactly the vertices reachable within the given number of steps.

@[reducible, inline]

A scan transcript chooses either no walk or a list of vertices for each vertex.

noncomputable def Cslib.DoubleCounting.selected {α : Type u_1} [Fintype α] (w : Transcript α) :

Vertices for which the scan guessed a walk.

@[simp]
theorem Cslib.DoubleCounting.mem_selected {α : Type u_1} {v : α} [Fintype α] {w : Transcript α} :
v ∈ selected w ↔ ∃ (p : List α), w v = some p

The scan selected a vertex precisely when its transcript includes a walk for it.

def Cslib.DoubleCounting.guessedLength {α : Type u_1} (w : Transcript α) (v : α) :

Number of edges guessed for a vertex. A skipped vertex contributes zero.

The two registers checked at the end of a scan.

  • count : ℕ

    Number of selected vertices.

  • lengthSum : ℕ

    Sum of the lengths of the chosen walks.

noncomputable def Cslib.DoubleCounting.expected {α : Type u_1} [Fintype α] (r : α → α → Prop) (s : α) (k : ℕ) :

Expected count and distance sum, supplied to the scan.

theorem Cslib.DoubleCounting.expected_bounds {α : Type u_1} {r : α → α → Prop} {s : α} {k : ℕ} [Fintype α] :

The exact tally uses at most one count and at most k edges per vertex.

noncomputable def Cslib.DoubleCounting.observed {α : Type u_1} [Fintype α] (w : Transcript α) :

Terminal count and length sum of the chosen walks.

The final test compares the two registers with their expected values.

theorem Cslib.DoubleCounting.Tally.matches_iff (actual expected : Tally) :
actual.matches expected = true ↔ actual.count = expected.count ∧ actual.lengthSum = expected.lengthSum

The Boolean test checks both equalities.

def Cslib.DoubleCounting.Passes {α : Type u_1} [Fintype α] (r : α → α → Prop) (s : α) (k : ℕ) (w : Transcript α) :

The scan's terminal checks, using the correct count and distance sum as inputs. The chain condition also checks the initial and final vertices of each guess.

theorem Cslib.DoubleCounting.passes_iff {α : Type u_1} {r : α → α → Prop} {s : α} {k : ℕ} [Fintype α] {w : Transcript α} :
Passes r s k w ↔ (∀ v ∈ round r s k, ∃ (p : List α), w v = some p ∧ List.IsChainFromTo r p s v ∧ p.length = distance r s v + 1) ∧ ∀ v ∉ round r s k, w v = none

Exactly the successful transcripts choose a shortest walk at every vertex of the round and skip every other vertex. This also determines the Boolean answer for any queried vertex.

theorem Cslib.DoubleCounting.isSome_iff {α : Type u_1} {r : α → α → Prop} {s v : α} {k : ℕ} [Fintype α] {w : Transcript α} (hw : Passes r s k w) :

A successful scan returns true exactly for vertices in the breadth-first round.

theorem Cslib.DoubleCounting.exists_passes {α : Type u_1} {r : α → α → Prop} {s : α} {k : ℕ} [Fintype α] :
∃ (w : Transcript α), Passes r s k w

The correct count and sum always admit a successful scan, even when shortest walks tie.

theorem Cslib.DoubleCounting.existsUnique_passes_iff {α : Type u_1} {r : α → α → Prop} {s : α} {k : ℕ} [Fintype α] :
(∃! w : Transcript α, Passes r s k w) ↔ ∀ v ∈ round r s k, ∃! p : List α, List.IsChainFromTo r p s v ∧ p.length = distance r s v + 1

With exact counts, Figure 1 has exactly one successful transcript if and only if each round vertex has exactly one shortest walk from the source.

theorem Cslib.DoubleCounting.round_zero {α : Type u_2} [Fintype α] (r : α → α → Prop) (s : α) :
round r s 0 = {s}

At radius zero, only the source is reachable.

theorem Cslib.DoubleCounting.expected_zero {α : Type u_2} [Fintype α] (r : α → α → Prop) (s : α) :
expected r s 0 = { count := 1, lengthSum := 0 }

The initial tally counts the source, at distance zero.

theorem Cslib.DoubleCounting.existsUnique_passes_zero {α : Type u_2} [Fintype α] (r : α → α → Prop) (s : α) :
∃! w : Transcript α, Passes r s 0 w

The only successful radius-zero transcript selects the singleton walk at the source.

theorem Cslib.DoubleCounting.existsUnique_passes_reindex {α : Type u_2} {β : Type u_3} [Fintype α] [Fintype β] (index : α ≃ β) (r : α → α → Prop) (s : α) (k : ℕ) :
(∃! t : Transcript α, Passes r s k t) ↔ ∃! t : Transcript β, Passes (fun (u v : β) => r (index.symm u) (index.symm v)) (index s) k t

Relabeling the graph preserves the existence of a unique passing transcript. In particular, a finite carrier can be indexed by consecutive vertex IDs.