Skip to content

feat(persistence): execute the Rips simplex list of an integer distance table (#1009) - #1010

Merged
t-uda merged 1 commit into
developfrom
ccr-eb669e62-a5kqoa
Nov 20, 2026
Merged

t-uda merged 1 commit into
developfrom
ccr-eb669e62-a5kqoa

Conversation

@t-uda

@t-uda t-uda commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1009

Summary

First unit of #922: the executable half. An integer distance table on the labels Fin N is validated as a metric and turned into the complete Rips simplex list in the format of FiniteInput.

  • New module TDA/Persistence/Reduction/RipsInput.lean: DistanceTable N with a decidable Valid (nonnegative entries, symmetry, zero diagonal, positive distance between distinct labels, every triangle inequality); the integer diameter; the enumeration faceLists; the executed list ripsInput, ordered by grade, then cardinality, then lexicographically in the increasing label lists; ripsInput? and ripsRun, which return none for an invalid table. Nothing is repaired and no metric certificate is supplied by the caller.
  • ripsInput_valid proves the five conditions of the existing FiniteInput.Valid, for every table. mem_ripsInput, ripsInput_pairwise, nodup_faces_ripsInput and length_ripsInput describe the entries, their order and their number 2 ^ N - 1.
  • For a valid table, metric is the metric on the labels, cast_diameter identifies the integer diameter with Rips.diameter, complex_ripsInput identifies the represented complex with the image of Rips.fullComplex (Fin N), and gradeFilter_ripsFace identifies the grade read by FiniteInput.gradeFilter with the value of Rips.filter.
  • ripsRun returns the occurrence records of the existing reduction on the list and does not validate the list again (ripsRun_eq_bind_run).
  • New module TDA/Persistence/Reduction/RipsInputExamples.lean, routed through TDA/Persistence/Examples.lean: the complete value of ripsInput? for no label, one label, two labels, a tied table, a line and its relabelling, and the four-cycle (15 entries); ripsRun for no label, one label and two labels; five kinds of invalid table returning none; the grade of a diagonal of the four-cycle transferred to the actual Rips.filter.
  • Not provided by this unit: the equality of the diagram of the executed records with the Rips diagram, any comparison of homology, and the four-cycle H₁ consumer. These are the following units of [Metric computation] Generate certified Rips simplex input from integer distances #922.
  • Cost, documented and not proved: the list costs O(N² 2 ^ N) label and integer operations; the cost of the existing reduction is separate, not bounded here and at least quadratic in the number of faces.
  • Docs: docs/api.md, a new section in docs/math/finite-ph-computation.md, and a CHANGELOG.md Unreleased entry.
  • Carried-over documentation fix from the review of the previous PR, in docs/math/mapper.md, subsection "Executable incidence extraction": extractReebDataIso is now said to compose graphPLExtractIso with the inverse of reebDataIso, and the sentence on the validation cost comes before the clause saying the counts are documented, not proved.

Branch lifecycle

Ordinary develop topic based on f726ed2ff9304852411d2907021d3a0ef8ed5123, target develop, squash merge. Target scope: metric computation under #922 / #227. Release version: undecided. Propagation: N/A.

Public declarations added / changed

Added in TDA.Persistence.Reduction (all in the contract of #1009):

  • DistanceTable, DistanceTable.Valid, DistanceTable.instDecidableValid, DistanceTable.metric, metric_dist
  • diameter, diameter_le_iff, diameter_nonneg, dist_le_diameter, diameter_mono, diameter_singleton, cast_diameter
  • faceLists, mem_faceLists, nodup_faceLists
  • entry, entries, ripsInput, ripsInput?, ripsRun
  • ripsInput?_eq_some_iff, ripsInput?_eq_none_iff, ripsRun_eq_some_iff, ripsRun_eq_none_iff
  • mem_ripsInput, mem_faces_ripsInput, mk_mem_ripsInput, ripsInput_pairwise, nodup_faces_ripsInput, length_ripsInput
  • ripsInput_valid, ripsRun_eq_bind_run
  • mem_complex_ripsInput, complex_ripsInput, ripsFace, ripsFace_val, ripsFace_bijective, gradeFilter_ripsFace_eq_diameter, gradeFilter_ripsFace

Added in TDA.Persistence.Reduction.RipsInputExamples: the fixtures empty, single, pair, pairInput, edgeMatrix, tied, line, relabelled, fourCycle, diagonal, oneWay, merged, shortcut, loop, negative and their checked statements (43 declarations).

Nothing beyond the contract was added to the library module: its public declarations are exactly those of the contract block, and its helpers are private. No listed statement changed. No existing public declaration changed. All 82 new public declarations are pinned by appending to scripts/print_axioms/Persistence.lean.

Source ↔ Lean correspondence

Library-derived; no external source. Governing specification #922, statement contract #1009. The statements of the contract were checked before admission by an independent read-only reviewer, who elaborated the contract block against the base and proved or argued each statement independently; the record is in the Admission section of #1009. The Lean signatures in this PR are those of the contract. Added after that review: only the fixture names and statements of the examples module, which follow the fixture list of the Acceptance section; as the reviewer advised, the examples do not evaluate the relation of ripsInput_pairwise in the kernel and check the order through the complete value of each list.

Conventions: the labels 0, …, N - 1 are transported into the vertex type ℕ of FiniteInput by Fin.valEmbedding, and no metric on ℕ is introduced. diameter folds over all ordered pairs with seed 0, as Rips.diameter does. Nonnegativity is redundant in Valid and kept because #922 lists it.

Validation

  • Evaluated head 4e2a7412faedb415cb70ae2d0bd216c9bb230074, base f726ed2ff9304852411d2907021d3a0ef8ed5123.
  • Local scripts/check.sh on the tree of this head: CHECK OK.
    • AXIOM AUDIT OK — 13795 declaration(s) (base 13713)
    • PRIVATE AUDIT — 10559 (base 10536)
    • COVERAGE OK — 11079 public theorems, all pinned (base 11024)
  • Pre-push gate (scripts/check.sh --incremental): green; the push was made without bypassing it.
  • Hosted check for this head: success — https://github.com/uda-lab/tda-lib/actions/runs/44724913333/job/136249757023 (conclusion read from the check run of head 4e2a7412faedb415cb70ae2d0bd216c9bb230074; its log was not re-read for the counts, which are those of the local run above).
  • Not run: documentation generation; any performance measurement beyond the interpreter timings recorded in [Metric computation] Executable Rips simplex list from an integer distance table (#922, part 1) #1009. The examples check the executed lists in the kernel on small tables only; ripsRun is kernel-checked up to two labels, and the four-cycle occurrence records are not checked in this unit.

Remaining sorry / custom-axiom footprint

None.

Independent review evidence

…ce table (#1009)

Add TDA.Persistence.Reduction.RipsInput: DistanceTable with a decidable Valid,
the integer diameter, the executed list ripsInput in the FiniteInput format
(ordered by grade, cardinality and label order), ripsInput? and ripsRun, which
return none for an invalid table. The list satisfies FiniteInput.Valid for
every table; for a valid table its faces and grades are identified with
Rips.fullComplex and Rips.filter of the table metric. The diagram comparison
is not part of this unit (#922, part 1).

Fixtures in RipsInputExamples, pins appended, docs/api.md,
docs/math/finite-ph-computation.md and CHANGELOG.md updated. Two carried-over
wording fixes in docs/math/mapper.md.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RfoZqCRSgoUin4otWc6fXL
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T11:08:39.721902Z 4e2a741 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

t-uda commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Reviewed-by: claude-opus read-only reviewer (session distinct from the implementer)

Reviewed head: 4e2a7412faedb415cb70ae2d0bd216c9bb230074 (base develop f726ed2ff9304852411d2907021d3a0ef8ed5123), against the contract of #1009 (part 1 of #922).

Verdict: pass with non-substantive notes. No substantive findings.

Findings

  1. Non-substantive (docs/api.md wording). "TDA.Persistence.Reduction.RipsInput executes the complete Rips simplex list" names the module in the same form as a declaration, and no declaration has that name. Suggest "the module TDA.Persistence.Reduction.RipsInput executes …".
  2. Non-substantive (docs/math/finite-ph-computation.md wording). "ripsInput_valid proves the five conditions of Valid for the list". Here Valid could be read as DistanceTable.Valid, which the same section has just introduced. Suggest FiniteInput.Valid.
  3. Non-substantive (informational, fixture). The negative table [[0, -1], [-1, 0]] breaks separation as well as nonnegativity. No table can break nonnegativity alone, because nonnegativity follows from symmetry, the zero diagonal and the triangle inequality, as the docs say. No change is needed; a short note in the docstring would be optional.
  4. Process note (not a code finding). When I reviewed, the hosted check for this head was still in_progress (build had succeeded). The merge gate still needs check to succeed on this head.

What I checked

  • Contract conformance. I wrote a scratch file with one example per contract item, each closed by the library declaration, and it elaborates. Every signature in the [Metric computation] Executable Rips simplex list from an integer distance table (#922, part 1) #1009 block matches exactly, and these definitions match the stated bodies by rfl: Valid, diameter, faceLists, entry, entries, ripsInput, ripsInput?, ripsRun, ripsFace. metric is @[instance_reducible] noncomputable def and is not an instance. There are no extra hypotheses. The library module has 39 public declarations, exactly the contract block; all 13 helpers are private.
  • Mathematics. I read every proof. ripsInput_valid holds for every table by monotonicity of the max-fold, and its coface-before-face case is ruled out using ripsInput_pairwise together with diameter_mono. ripsRun_eq_bind_run goes through the existing run_eq_some_iff. complex_ripsInput and gradeFilter_ripsFace are stated about the actual FiniteInput.complex and gradeFilter, and the actual Rips.fullComplex and Rips.filter (D.metric hD). None of the statements is vacuous: the fixture fourCycle_diagonal instantiates the grade law. Running #print axioms on the key declarations gives only propext, Classical.choice, Quot.sound; instDecidableValid and faceLists depend on no axioms.
  • Hygiene. The new files contain no sorry, admit, native_decide, axiom or heartbeat options. I re-elaborated both new files with lake env lean and got no warnings. The aggregators only gain one import line each. The pins diff has no removed lines; it appends 82 lines, which match the 82 public declarations of the two new files one for one.
  • Fixtures. I checked the values by hand for pair (including pair_ripsRun, degree 0 from 0 to 3 plus an essential class), line, relabelled (swap of labels 0 and 1, and the same grade sequence), tied and fourCycle: the edges in lex order {0,1},{0,3},{1,2},{2,3} at 1, then the diagonals, the four triangles and the tetrahedron at 2. I also ran #eval on two tables of my own: a 4-point line (15 entries, order correct) and an isosceles triangle, where ripsRun gives two finite H₀ bars (to 1 and to 5) and one essential bar. The fixtures cover every item of [Metric computation] Executable Rips simplex list from an integer distance table (#922, part 1) #1009's acceptance list, including the five invalid kinds for both ripsInput? and ripsRun.
  • Documentation. Neither the module docstring, the new finite-ph-computation.md section, api.md nor CHANGELOG.md claims that the executed diagram equals the Rips diagram; each says that this is left to later units. outputDiagram_eq_of_same_graded_complex and outputDiagram_eq_dgm exist and are cited correctly. The anchor #rips-input-from-an-integer-distance-table matches the new heading. The cost statements match [Metric computation] Executable Rips simplex list from an integer distance table (#922, part 1) #1009 and are marked as not proved. The two mapper.md fixes are correct: extractReebDataIso is graphPLExtractIso … ≪≫ (X.reebDataIso hX).symm, and the validation-cost sentence now comes before "documented, not proved".
  • API quality. The integer diameter is a deliberate ℤ counterpart of Rips.diameter, linked to it by cast_diameter; it is not an unjustified duplicate.

Not done

I did not run lake build, scripts/check.sh or doc-gen4. For the axiom audit and coverage I relied on the gate output in the PR body and on my own pin diff, and I did not measure performance. I did not read the implementer's scratch files.


Generated by Claude Code

@t-uda
t-uda merged commit 8bc0262 into develop Nov 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants