Repository navigation
refactor(ExactTriangle): a Triangle n record for vertex triples - #5104
Queued
SamuelSchlesinger wants to merge 2 commits into
Queued
SamuelSchlesinger wants to merge 2 commits into
SamuelSchlesinger wants to merge 2 commits into
Conversation
Vertex triples in the Exact Triangle hashing and witness modules were bare `Fin n × Fin n × Fin n` tuples, read as `weightSum … t.1 t.2.1 t.2.2`. They are now a `Triangle n` structure with fields `a b c`, deriving `DecidableEq` and `Fintype`. `Triangle.equivProd` relates it to the product. `Triangle.card` (`= n ^ 3`) and `Triangle.sum_eq` (an iterated sum over the three parts) replace the `Fintype.card_prod`/`Fintype.sum_prod_type` steps in the counting proofs. `countZeroMod`, `IsFalsePositive`, `falsePositiveCount`, `zeroCount`, `card_falsePositive_primes_le`, `IsSearchAnswer`, `runScans` and `card_le_falsePositiveCount_of_distinct_scans` take or return `Triangle n`. `scanOf` and `signedBitInstances` bind their tuple components by name. The counted values, step bounds and word layouts are unchanged, and the test `decide`s still evaluate through the derived instance. Projection-chain baseline: Hashing 10 -> 0, Lopsided 3 -> 0, Witnesses 2 -> 0. Part of #4823 (item 2).
The census PR leaves baseline decreases to the pruning PR (chains 15 -> 0 here) to avoid adjacent-edit queue ejections.
Collaborator
Author
|
Agent review (Jetski alg-layering session b0e92563-9d10-45d2-b8f8-98b2e8157147), head bf501f1: APPROVE. Reviewed locally before opening, per the CI-throughput rule. I reviewed ec52e7d, then the bf501f1 delta: the baseline edit is reverted, and the Fin 0
This is agent review, not human approval. |
SamuelSchlesinger
added this pull request to the merge queue
Nov 13, 2026
Any commits made after this event will not be merged.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Vertex triples in the Exact Triangle hashing and witness modules were bare
Fin n × Fin n × Fin ntuples, read asweightSum … t.1 t.2.1 t.2.2. This PR replaces them with aTriangle nrecord (fieldsa b c, derivingDecidableEqandFintype). That is item 2 of #4823.Before migrating, I checked whether the counting proofs stay clean with the record, as #4823 asked. They do:
Triangle.equivProdrelates the record to the product.Triangle.card : Fintype.card (Triangle n) = n ^ 3andTriangle.sum_eq(a sum over triangles is an iterated sum over the three parts) replace the repeatedFintype.card_prod/Fintype.sum_prod_typesteps insum_falsePositiveCount_leandfalsePositiveCount_add_zeroCount_eq_sum_coeff.decides still evaluate through the derived instance.IsSearchAnswer,runScans,card_falsePositive_primes_leandcard_le_falsePositiveCount_of_distinct_scansalso take or returnTriangle nnow, so search results and counts use the same type. Only the type of the triple changes; the counted values, step bounds and word layouts are unchanged. The WordRAM readbacks usecountZeroMod/falsePositiveCountas opaque numbers and build unchanged.scanOfandsignedBitInstancesnow bind their tuple components by name. Projection chains in these modules go from 15 to 0 (Hashing 10, Lopsided 3, Witnesses 2); the baseline is left to the pruning PR.There are no compatibility aliases. One test proof changes:
simpno longer finds emptiness forFin 0triangles on its own, so thezeroCountexample atFin 0is nowdecide.This PR is infrastructure and readability work, not new mathematics. Part of #4823.
Validation:
lake build --wfail --iofailon the 3 changed modules, all 167 downstream library modules (10 leaves) and the 34 affected tests.lake linton the 3 modules,lake exe lint-style,mk_all --check,check_hygiene --check-simp, both ratchets,check_changed_files --source-only, the manual checker andcheck_docs --config-only.parallel_defs --theorems --no-build-check: no duplicates among the 14 examined (built modules only).merge-treeis clean against main and the open PRs that touch these files.Manuals: Operator's Manual, no edit; the Exact Triangle chapter doesn't name these declarations. Agent Operator's Manual, no edit; no workflow change.
AI disclosure: written by the Jetski worker
clients(session 2a1d23e9). Agent review isn't human review.