Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ Changes on `develop` after v0.4.0; the next release version is undecided.
proved correct for the actual Kan extensions in all three cases. A failure
refutes the predicate at that radius; it is not a distance bound. See
[rank erosion](docs/math/rank-erosion.md#a-certified-finite-test).
- Compute the incidence lists of graph-PL input by execution
(`HeightGraph.incidence?`): from a Boolean adjacency function and rational
vertex heights, the sorted distinct levels, one cell per level component and
per crossing edge, and the spanning edges of each gap with their endpoint
cells, parallel entries retained. Component labels are proved to decide
reachability in the actual induced level graphs; invalid adjacency is
rejected. The comparison with `graphPLReebData` and the Reeb quotient is not
included. See
[executable incidence extraction](docs/math/mapper.md#executable-incidence-extraction).

## v0.4.0

Expand Down
1 change: 1 addition & 0 deletions TDA/Mapper.lean
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ import TDA.Mapper.GraphPLReebMapPair
import TDA.Mapper.GraphPLReebMergeFold
import TDA.Mapper.RefinementHomologyMapPair
import TDA.Mapper.MapperReebConstructible
import TDA.Mapper.GraphPLIncidence
1 change: 1 addition & 0 deletions TDA/Mapper/Examples.lean
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ import TDA.Mapper.GraphPLReebMapPairExamples
import TDA.Mapper.GraphPLReebMergeFoldExamples
import TDA.Mapper.RefinementHomologyMapPairExamples
import TDA.Mapper.MapperReebConstructibleExamples
import TDA.Mapper.GraphPLIncidenceExamples
564 changes: 564 additions & 0 deletions TDA/Mapper/GraphPLIncidence.lean

Large diffs are not rendered by default.

134 changes: 134 additions & 0 deletions TDA/Mapper/GraphPLIncidenceExamples.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import TDA.Mapper.GraphPLIncidence
import Mathlib.Data.Fin.VecNotation

/-!
# Executed graph-PL incidence extraction

Each fixture states the complete value of `HeightGraph.incidence?`.

* `empty`: no vertex; the dummy level `0`, no cell and no edge.
* `single`, `apart`: one vertex; two isolated vertices at different heights.
* `flat`: a horizontal edge; one level, one component, no spanning edge.
* `vee`: two vertices of the same height that are not joined at their level, both joined to a
lower vertex.
* `crossing`: an edge crossing an intermediate level that carries an isolated vertex.
* `diamond`: a cycle.
* `triangle`: two distinct edges over one gap with the same two endpoint cells; both entries are
present.
* `bent`: a level component of three vertices whose least index is not adjacent to all of them,
so that one propagation round does not suffice; its label equality is transferred to
reachability in the actual induced level graph.
* `oneWay`, `loop`: invalid adjacency, reported as `none`.
-/

set_option autoImplicit false

namespace TDA.Mapper.GraphPL.GraphPLIncidenceExamples

open HeightGraph

/-- Symmetric adjacency on vertex numbers from a list of edges. -/
def edgeAdj {N : ℕ} (E : List (ℕ × ℕ)) (u w : Fin N) : Bool :=
E.contains (u.1, w.1) || E.contains (w.1, u.1)

/-- No vertex. -/
def empty : HeightGraph 0 := ⟨fun _ _ => false, fun i => i.elim0⟩

theorem empty_incidence : empty.incidence? = some ⟨[0], [[]], []⟩ := by decide +kernel

/-- One vertex. -/
def single : HeightGraph 1 := ⟨fun _ _ => false, fun _ => 3⟩

theorem single_incidence : single.incidence? = some ⟨[3], [[.inl 0]], []⟩ := by decide +kernel

/-- Two isolated vertices at different heights. -/
def apart : HeightGraph 2 := ⟨fun _ _ => false, ![0, 1]⟩

theorem apart_incidence : apart.incidence? = some ⟨[0, 1], [[.inl 0], [.inl 1]], [[]]⟩ := by
decide +kernel

/-- A horizontal edge. -/
def flat : HeightGraph 2 := ⟨edgeAdj [(0, 1)], ![0, 0]⟩

theorem flat_incidence : flat.incidence? = some ⟨[0], [[.inl 0]], []⟩ := by decide +kernel

/-- Vertices `0` and `1` at height `1`, not joined; both joined to vertex `2` at height `0`. -/
def vee : HeightGraph 3 := ⟨edgeAdj [(0, 2), (1, 2)], ![1, 1, 0]⟩

theorem vee_incidence :
vee.incidence? = some ⟨[0, 1], [[.inl 2], [.inl 0, .inl 1]],
[[((2, 0), .inl 2, .inl 0), ((2, 1), .inl 2, .inl 1)]]⟩ := by
decide +kernel

/-- An edge from height `0` to height `2`, and an isolated vertex at height `1`. -/
def crossing : HeightGraph 3 := ⟨edgeAdj [(0, 1)], ![0, 2, 1]⟩

theorem crossing_incidence :
crossing.incidence? = some ⟨[0, 1, 2], [[.inl 0], [.inl 2, .inr (0, 1)], [.inl 1]],
[[((0, 1), .inl 0, .inr (0, 1))], [((0, 1), .inr (0, 1), .inl 1)]]⟩ := by
decide +kernel

/-- A four-cycle with heights `0, 1, 1, 2`. -/
def diamond : HeightGraph 4 := ⟨edgeAdj [(0, 1), (0, 2), (1, 3), (2, 3)], ![0, 1, 1, 2]⟩

theorem diamond_incidence :
diamond.incidence? = some ⟨[0, 1, 2], [[.inl 0], [.inl 1, .inl 2], [.inl 3]],
[[((0, 1), .inl 0, .inl 1), ((0, 2), .inl 0, .inl 2)],
[((1, 3), .inl 1, .inl 3), ((2, 3), .inl 2, .inl 3)]]⟩ := by
decide +kernel

/-- A triangle with one vertex at height `0` and a horizontal edge at height `1`. -/
def triangle : HeightGraph 3 := ⟨edgeAdj [(0, 1), (0, 2), (1, 2)], ![0, 1, 1]⟩

theorem triangle_incidence :
triangle.incidence? = some ⟨[0, 1], [[.inl 0], [.inl 1]],
[[((0, 1), .inl 0, .inl 1), ((0, 2), .inl 0, .inl 1)]]⟩ := by
decide +kernel

/-- Both edges of the triangle over the gap are listed. -/
theorem triangle_edgeList :
triangle.edgeList 0 1 = [((0, 1), .inl 0, .inl 1), ((0, 2), .inl 0, .inl 1)] := by
decide +kernel

/-- The two listed edges have the same two endpoint cells. -/
theorem triangle_parallel :
(triangle.edgeList 0 1).map Prod.snd = [(.inl 0, .inl 1), (.inl 0, .inl 1)] := by
decide +kernel

/-- Vertices `0, 1, 2` at height `0` joined as the path `0 — 2 — 1`, and vertex `3` above. -/
def bent : HeightGraph 4 := ⟨edgeAdj [(0, 2), (2, 1), (1, 3)], ![0, 0, 0, 5]⟩

theorem bent_valid : bent.Valid := by decide +kernel

theorem bent_incidence :
bent.incidence? = some ⟨[0, 5], [[.inl 0], [.inl 3]], [[((1, 3), .inl 0, .inl 3)]]⟩ := by
decide +kernel

/-- One propagation round leaves vertex `1` with its own label. -/
theorem bent_one_round : (bent.relax (Vector.ofFn id)).toList = [0, 1, 0, 3] := by decide +kernel

theorem bent_labels : bent.labels.toList = [0, 0, 0, 3] := by decide +kernel

theorem bent_height_zero : bent.height 0 = 0 := by decide +kernel

theorem bent_height_one : bent.height 1 = 0 := by decide +kernel

/-- Vertices `0` and `1` are joined in the actual graph induced on the height-`0` vertices. -/
theorem bent_reachable :
((bent.graph bent_valid).induce {v | bent.realHeight v = ((0 : ℚ) : ℝ)}).Reachable
⟨0, bent.realHeight_eq_iff.2 bent_height_zero⟩
⟨1, bent.realHeight_eq_iff.2 bent_height_one⟩ :=
(bent.label_eq_label_iff_reachable bent_valid bent_height_zero bent_height_one).1
(by decide +kernel)

/-- An asymmetric adjacency. -/
def oneWay : HeightGraph 2 := ⟨fun u w => decide (u.1 = 0 ∧ w.1 = 1), ![0, 1]⟩

theorem oneWay_incidence : oneWay.incidence? = none := by decide +kernel

/-- A loop. -/
def loop : HeightGraph 1 := ⟨fun _ _ => true, ![0]⟩

theorem loop_incidence : loop.incidence? = none := by decide +kernel

end TDA.Mapper.GraphPL.GraphPLIncidenceExamples
2 changes: 1 addition & 1 deletion docs/api.md

Large diffs are not rendered by default.

61 changes: 61 additions & 0 deletions docs/math/mapper.md
Original file line number Diff line number Diff line change
Expand Up @@ -1482,6 +1482,67 @@ quotient although its realization endpoints differ. R5 is
`c4_isIso_intervalComponentComparison`. R6 is the negative control
`path3_reebQuotient_not_iso_S02`: the covering hypothesis cannot be dropped.

### Executable incidence extraction

`TDA.Mapper.GraphPLIncidence` computes the lists underlying the finite Reeb data
from finite input. A `HeightGraph N` is a Boolean adjacency function on `Fin N`
with rational vertex heights. `HeightGraph.Valid` asks for symmetry and an empty
diagonal; it is decidable, and invalid input is rejected, not repaired
(`incidence?` returns `none`). For valid input `graph` is the simple graph and
`realHeight` the real-valued height.

* `levels` lists the distinct heights in increasing order (`levels_pairwise`,
`mem_levels`); with no vertex it is the single dummy level `0`.
`criticalValues` is this list as a `CriticalValues`, and it covers the vertex
heights (`coversVertexHeights`).
* `label v` is the least vertex index in the component of `v` in the graph
induced on the vertices of the height of `v`. It is computed by `N` rounds of
minimum-label propagation along horizontal edges, which suffice because a
path in a graph on `N` vertices has fewer than `N` edges.
`label_eq_label_iff_reachable` states that two vertices of height `c` have
equal labels exactly when they are joined in the graph induced on
`{v | realHeight v = c}`, the vertex set of the level components above, and
`componentEquiv` is the bijection between the label fixed points of height
`c` and those components.
* `cellList c` lists the label fixed points of height `c` and, as ordered pairs
(lower endpoint, upper endpoint), the edges crossing `c` (`mem_cellList_inl`,
`mem_cellList_inr`, `nodup_cellList`).
* `edgeList p q` lists, as ordered pairs, the edges whose height interval
contains `[p, q]`, each once and each with its two endpoint cells: the label
of the endpoint when the endpoint lies on the level, and the edge itself as a
crossing cell otherwise (`mem_edgeList`, `nodup_edgeList`). Two edges with
the same endpoint cells are two entries. For `p < q` both endpoint cells are
listed cells of the two levels (`leftEnd_mem_cellList`,
`rightEnd_mem_cellList`).

`incidence` collects the cell lists over all levels and the edge lists over all
gaps between consecutive levels (`incidence_cells_getElem?`,
`incidence_edges_getElem?`). The representative of a component is the least
index by construction of this implementation; statements about components
should go through reachability.

The executable definitions use lists, vectors, finite indices and rational
comparison, with no quotient representative and no real-number comparison.
Counting an evaluation of the adjacency or the height, a rational comparison
and an index comparison as one unit, `incidence` costs `O(N³)` units for the
label propagation and `O(L N²)` for the cells and edges of `L` levels; the bit
cost of rational arithmetic is separate, and these counts are documented, not
proved. The statement forms `label`, `cellList` and `edgeList` recompute the
label vector at each call.

This module does not build `FiniteReebData` from the lists and does not compare
them with `graphPLReebData` or with the Reeb quotient; no Mapper extraction is
provided. These are elementary library results, not attributed to a source.

The fixtures state the complete value of `incidence?` for no vertex, one
vertex, two isolated vertices, a horizontal edge, two unjoined vertices of one
height, an edge crossing a level that carries an isolated vertex, and a
four-cycle. `triangle_edgeList` and `triangle_parallel` show two edges over one
gap with the same endpoint cells, both listed. In `bent` one propagation round
leaves a wrong label (`bent_one_round`, `bent_labels`), and `bent_reachable`
transfers the label equality to the actual induced level graph. An asymmetric
adjacency and a loop return `none`.

### The graph-PL realization as a constructible ℝ-space

Let `V : Type u`, let `G : SimpleGraph V`, and let `h : V → ℝ`. For (A),
Expand Down
93 changes: 93 additions & 0 deletions scripts/print_axioms/Mapper.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1429,3 +1429,96 @@ import TDA
#print axioms TDA.Mapper.MapperReebConstructibleExamples.empty_input_wide_member_error_zero
#print axioms TDA.Mapper.MapperReebConstructibleExamples.empty_labels_not_cover
#print axioms TDA.Mapper.MapperReebConstructibleExamples.empty_labels_error_top
#print axioms TDA.Mapper.GraphPL.HeightGraph
#print axioms TDA.Mapper.GraphPL.HeightGraph.Cell
#print axioms TDA.Mapper.GraphPL.HeightGraph.Incidence
#print axioms TDA.Mapper.GraphPL.HeightGraph.Valid
#print axioms TDA.Mapper.GraphPL.HeightGraph.instDecidableValid
#print axioms TDA.Mapper.GraphPL.HeightGraph.graph
#print axioms TDA.Mapper.GraphPL.HeightGraph.instDecidableRelGraphAdj
#print axioms TDA.Mapper.GraphPL.HeightGraph.graph_adj
#print axioms TDA.Mapper.GraphPL.HeightGraph.realHeight
#print axioms TDA.Mapper.GraphPL.HeightGraph.realHeight_eq_iff
#print axioms TDA.Mapper.GraphPL.HeightGraph.levels
#print axioms TDA.Mapper.GraphPL.HeightGraph.levels_pairwise
#print axioms TDA.Mapper.GraphPL.HeightGraph.mem_levels
#print axioms TDA.Mapper.GraphPL.HeightGraph.levels_ne_nil
#print axioms TDA.Mapper.GraphPL.HeightGraph.levels_of_eq_zero
#print axioms TDA.Mapper.GraphPL.HeightGraph.gapCount
#print axioms TDA.Mapper.GraphPL.HeightGraph.length_levels
#print axioms TDA.Mapper.GraphPL.HeightGraph.level
#print axioms TDA.Mapper.GraphPL.HeightGraph.level_strictMono
#print axioms TDA.Mapper.GraphPL.HeightGraph.level_mem_levels
#print axioms TDA.Mapper.GraphPL.HeightGraph.exists_level_eq
#print axioms TDA.Mapper.GraphPL.HeightGraph.range_level
#print axioms TDA.Mapper.GraphPL.HeightGraph.criticalValues
#print axioms TDA.Mapper.GraphPL.HeightGraph.criticalValues_value
#print axioms TDA.Mapper.GraphPL.HeightGraph.coversVertexHeights
#print axioms TDA.Mapper.GraphPL.HeightGraph.horizontal
#print axioms TDA.Mapper.GraphPL.HeightGraph.relax
#print axioms TDA.Mapper.GraphPL.HeightGraph.labels
#print axioms TDA.Mapper.GraphPL.HeightGraph.label
#print axioms TDA.Mapper.GraphPL.HeightGraph.label_le
#print axioms TDA.Mapper.GraphPL.HeightGraph.height_label
#print axioms TDA.Mapper.GraphPL.HeightGraph.label_label
#print axioms TDA.Mapper.GraphPL.HeightGraph.label_eq_label_iff_reachable
#print axioms TDA.Mapper.GraphPL.HeightGraph.componentEquiv
#print axioms TDA.Mapper.GraphPL.HeightGraph.componentEquiv_apply
#print axioms TDA.Mapper.GraphPL.HeightGraph.componentEquiv_symm_mk
#print axioms TDA.Mapper.GraphPL.HeightGraph.vertexPairs
#print axioms TDA.Mapper.GraphPL.HeightGraph.cellsWith
#print axioms TDA.Mapper.GraphPL.HeightGraph.leftEndWith
#print axioms TDA.Mapper.GraphPL.HeightGraph.rightEndWith
#print axioms TDA.Mapper.GraphPL.HeightGraph.edgesWith
#print axioms TDA.Mapper.GraphPL.HeightGraph.cellList
#print axioms TDA.Mapper.GraphPL.HeightGraph.leftEnd
#print axioms TDA.Mapper.GraphPL.HeightGraph.rightEnd
#print axioms TDA.Mapper.GraphPL.HeightGraph.edgeList
#print axioms TDA.Mapper.GraphPL.HeightGraph.incidence
#print axioms TDA.Mapper.GraphPL.HeightGraph.incidence?
#print axioms TDA.Mapper.GraphPL.HeightGraph.incidence_levels
#print axioms TDA.Mapper.GraphPL.HeightGraph.incidence_cells
#print axioms TDA.Mapper.GraphPL.HeightGraph.incidence_edges
#print axioms TDA.Mapper.GraphPL.HeightGraph.incidence?_eq_some_iff
#print axioms TDA.Mapper.GraphPL.HeightGraph.incidence?_eq_none_iff
#print axioms TDA.Mapper.GraphPL.HeightGraph.levels_getElem?
#print axioms TDA.Mapper.GraphPL.HeightGraph.incidence_cells_getElem?
#print axioms TDA.Mapper.GraphPL.HeightGraph.incidence_edges_getElem?
#print axioms TDA.Mapper.GraphPL.HeightGraph.mem_cellList_inl
#print axioms TDA.Mapper.GraphPL.HeightGraph.mem_cellList_inr
#print axioms TDA.Mapper.GraphPL.HeightGraph.nodup_cellList
#print axioms TDA.Mapper.GraphPL.HeightGraph.mem_edgeList
#print axioms TDA.Mapper.GraphPL.HeightGraph.nodup_edgeList
#print axioms TDA.Mapper.GraphPL.HeightGraph.leftEnd_mem_cellList
#print axioms TDA.Mapper.GraphPL.HeightGraph.rightEnd_mem_cellList
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.edgeAdj
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.empty
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.empty_incidence
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.single
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.single_incidence
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.apart
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.apart_incidence
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.flat
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.flat_incidence
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.vee
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.vee_incidence
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.crossing
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.crossing_incidence
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.diamond
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.diamond_incidence
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.triangle
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.triangle_incidence
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.triangle_edgeList
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.triangle_parallel
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.bent
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.bent_valid
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.bent_incidence
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.bent_one_round
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.bent_labels
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.bent_height_zero
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.bent_height_one
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.bent_reachable
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.oneWay
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.oneWay_incidence
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.loop
#print axioms TDA.Mapper.GraphPL.GraphPLIncidenceExamples.loop_incidence
Loading