Skip to content

Import finite integral relation algebra counts through seven atoms - #1035

Merged
Vilin97 merged 8 commits into
mainfrom
codex/import-finite-integral-relation-algebras-20261126
Nov 27, 2026
Merged

Vilin97 merged 8 commits into
mainfrom
codex/import-finite-integral-relation-algebras-20261126

Conversation

@Vilin97

@Vilin97 Vilin97 commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Result

This imports the classification and certified enumeration of finite integral relation algebras through seven atoms. The seven-atom theorem gives 344,809,166,311 isomorphism classes. The project also proves the six smaller totals and sixteen counts by symmetry type, matching Peter Jipsen’s compilation. Jipsen is credited with all four seven-atom counts. The compilation follows the ordering of Roger Maddux’s earlier list. Published table

The reduction identifies finite integral relation algebras with lawful atom-cycle structures up to relabeling. Burnside’s lemma reduces their number to fixed-point counts. The supporting theory gives reusable results on finite integral atom structures and the action of their automorphism groups.

Upstream and scope

Chris Henson announced the completed formalization at 15:59:40 UTC on November 26, 2026. The source is chenson2018/finite-integral-ra at 5620a22, licensed Apache-2.0. Henson credits Claude for the proofs, so the card records AI provenance. Announcement

The import follows the complete dependency closure of Solution.lean. It includes the classification, the checking library, and the Lean certificates needed to replay the counts. The original closure contains 287,628 lines across 1,336 Lean files. The count was measured from the pinned upstream checkout.

git ls-files -z -- Solution.lean 'Solution/*.lean' | xargs -0 wc -l | tail -1

The supporting relation-algebra definitions come from CSLib at 910210f. The import retains four supporting CSLib mathematical modules with their original copyright headers. It removes proof requests and unused interval, Huntington, closure, and domain infrastructure. The challenge file, examples, tooling, and Rust certificate generator stay upstream.

Port and trust

  • Ported to Lean 4.36.0 and Mathlib fc4f59e577feb1a4956671bc04ac18aaaf8cd842. Regenerated the public project index.
  • The kernel verifies the finite certificates with decide +kernel. The Lean checkers validate the permutation group, completeness of the listed orbits and the weighted fixed-point counts.
  • Removed option overrides and reformatted the generated literals. Proved leaf invariance for the full group from checked generator symmetries. Separated the multiplication-table checks and reused kernel-verified bit columns across segments.
  • Made the per-segment inputs internal and proof-only. Each segment keeps its existing public orbit-sum theorem.
  • A source comparison matched all 23 challenge statements and the data and checked propositions in all 1,144 certificate segment files. The full compiled environment audit passed. A fresh Lean import reported exactly propext, Classical.choice, and Quot.sound for each of the seven advertised totals.

Validation and compile profile

  • On the first reviewed revision, the generated index, static quality, text style, and clean warning-as-error project build passed locally. All 1,377 changed Lean files had measured timings and met both per-file limits. The slowest file took 48 s, and the watchdog reported a maximum of 2.8 GiB anonymous memory. The Mathlib declaration linter passed for 121,694 declarations. The full compiled axiom, option, build-message, and card-declaration checks passed. GitHub independently passed the applicable required checks on the initial and final revisions. Lean Action CI
  • Both whole-project builds ran with clean project outputs and warm dependency caches on the same Azure VM with LEAN_NUM_THREADS=6. The upstream baseline ran /usr/bin/time -v lake build -v Solution on Lean 4.37.0-rc1 and took 2:31:49 for 1,336 source modules. The port ran /usr/bin/time -v python3 -m lean_pool.build_time_limits watch --base 6ccbb9b -- lake build LeanPool.FiniteIntegralRelationAlgebras.Imports with PYTHONPATH=python on Lean 4.36.0. It took 1:27:32 for 1,377 modules. Total CPU time was 10.45 versus 8.62 core-hours. The toolchains and the VM's background workload differed between runs.
  • Upstream, the largest symmetry group's setup module took 215 s and peaked at 10,545,984 KiB anonymous memory. The port's aggregate took 46 s and peaked at 2.1 GiB after splitting the work into separate permutation and multiplication checks. The aggregate timing excludes its new prerequisite modules.
  • In a controlled comparison of the same S6N0.C0.S99 orbit check on Lean 4.36.0 with warm dependencies and LEAN_NUM_THREADS=1 lake env lean, checked shared columns reduced wall time from 12.27 s to 8.99 s and peak RSS from 2,035,128 KiB to 1,598,516 KiB. The two source files used the same segment and the same check theorem statement.
  • In a second comparison under the same compiler and thread setting, compiling the entire S2N2.C0.S47 segment with outputs enabled took 67.58 s before and 64.97 s after making its inputs private and proof-only. The five measured Lean and generated executable artifacts shrank from 28.23 MB to 1.87 MB. A fresh importer resolved the public total theorem and reported exactly propext, Classical.choice, and Quot.sound.

Review revisions

The revision at 2ea378388b updates the table credit, uses one definition each for the segment and group row checks, shares the group-step and bit-action composition proofs, and reuses the abstract complex-algebra equivalence. The proof of the atom labelling uses disjoint set unions. The 57 single-chunk counts now prove their existing totals directly. Removed unused foundation imports and regenerated the project index.

A source replay matched the original certificate data and all 23 headline and symmetry-type statements, recomputed all three shared column tables, and matched the 57 simplified direct totals. The pinned Lean toolchain passed a warning-as-error build through six atoms and checked a seven-atom sample after those revisions. Deterministic certificate conversion and verifier

The follow-up at 9ff667184f cuts the seven-atom sample verifier's local import closure from 55 to 47 modules. The low-level encoding imports only the cycle theory and list lookup it uses. Shared primitives now hold quadruple decoding, order checking, and digit encoding, and the two symmetry paths use the same invariant-leaf counting theorem. Unused binary-relation and special-element branches were removed. No certificate data or theorem statement changed.

In a warm, single-thread Lean 4.36.0 check of the unchanged Atoms7/S6N0/C0/S99.lean, wall time was 33.79 s before and 33.89 s after, and peak RSS changed from 2,987,924 KiB to 2,953,684 KiB. Both checks passed. The shared proof library and the one-atom total also passed after the dependency cleanup. The latest local warning-as-error build completed in 1:16:41. It rebuilt 1,345 project modules and verified recorded timings for 28 unchanged compiler outputs. All 1,373 files met the limits. The slowest was the largest group setup at 44 s, and the highest observed anonymous memory was 2.8 GiB. Mathlib lint passed all 121,161 declarations. The complete quality and compiled trust checks passed. All seven headline totals depend on exactly the three allowed axioms. Latest GitHub CI

GitHub also passed the guarded compilation, declaration and text style linters, repository quality checks, and content separation on the final commit. Its compilation step took 3:13:54. Exact-head CI

@Vilin97

Vilin97 commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator Author

The full source comparison for 9ff667184f4e636781896412428942991152296d verified the advertised statements and certificate data. The full warning-as-error project build and compiled local checks passed. GitHub’s required build and content separation passed.

Faithfulness and trust

card_ofAtoms_seven proves Nat.card (ofAtoms 7) = 344809166311, with the six smaller totals and sixteen counts by symmetry type also matching the upstream statements. The quotient relation in IntegralAtom.setoid is existence of a relation-algebra equivalence. exists_ofCycles_of_isIntegral constructs the representation for arbitrary finite integral relation algebras of the specified type. Thus the count ranges over actual abstract relation algebras, including the nonrepresentable ones. Classification · Seven-atom total

The proof reduces the quotient count by Burnside, verifies the complete permutation table by cardinality and distinctness, checks a bijection between lawful fixed cycle sets and Boolean models, and checks orbit coverage and weighted sums. The generator optimization proves invariance by induction on the checked generator decomposition. The cached bit columns are checked for equality to the computed columns before they can be used. The first reviewed revision passed compiled axiom and option audits across all 1,377 modules, including the certificate declarations. A fresh import confirmed that every advertised total depends on exactly propext, Classical.choice, and Quot.sound. Group checker · Generator proof · Column check

Novelty, significance, and sources

The comparison against the pinned Mathlib, Tau Ceti and existing Lean Pool content turned up no corresponding counts. The CSLib source states the counts as proof requests, and the import credits those definitions and preserves the supporting files’ authorship. Henson describes Claude’s authorship of the proofs under Apache-2.0. The exact 16 types and their totals agree with Peter Jipsen’s published compilation, which follows the ordering in Roger Maddux’s earlier list. The additions provide a checked reproduction of that enumeration and reusable orbit-counting, cycle-structure, and model-checking results. CSLib input · Published table · Pinned source

Implementation and validation

I compared all 1,336 imported upstream files. I matched the lists and propositions in all 1,144 certificate segments, including 22,120 weighted checks, and matched all 720 permutations in the largest group and all 23 challenge statements. I separately inspected the two reorganized group modules, the shortened qualified name in Cert.Group, the duplicate simp registration removed in CycleSets, the adapted CSLib modules, and the new checker lemmas. The atom-count directories contain 98.9% of the port’s Lean lines, including generated data and their assembly. The deterministic generator stays at the pinned upstream URL. The port keeps raw certificate data separate from the reusable proof library, and each assembly step checks that data in the kernel.

On the first reviewed revision, the declaration linter passed on all 1,377 modules and 121,694 declarations. Local checks also passed for generated indexes, text style, static quality and all measured per-file build limits. The slowest file took 48 s and the largest anonymous memory peak was 2.8 GiB. Whole-project clean builds took 2:31:49 upstream and 1:27:32 on the port with six threads, warm dependencies, different Lean versions, and different VM contention. The largest group setup took 46 s and 2.1 GiB anonymous memory on the port, versus the original module's 215 s and 10.1 GiB. In a controlled Lean 4.36.0 comparison, one orbit check went from 12.27 s to 8.99 s. On GitHub, the required Build project and content separation checks passed. GitHub timed every changed Lean file and independently passed the declaration linter, text style and full quality checks. The documentation preflight, Python, exposition and workflow lint jobs were scoped out for this content-only change. Lean Action CI

The updated segments keep their proof-only inputs private. In a controlled full compilation of S47, the five measured compiled artifacts went from 28.23 MB to 1.87 MB and wall time from 67.58 s to 64.97 s. A fresh importer checked the public total and found exactly the three allowed axioms. The source comparison matched the data and propositions again after this change.

On the first reviewed revision, Greptile found no concrete defect and reported incomplete coverage. The source comparison and local validation above cover the full import. Greptile review

Follow-up review

The initial review identified imprecise attribution and specific maintenance debt. The card now credits Jipsen for compiling the table, with Maddux credited for the ordering of his earlier list. The verification recipe reconstructs all three shared columns, compares all 1,144 certificate segments and 23 challenge statements, and checks the 57 direct totals. First GPT review · Conversion recipe

I inspected the 70-file follow-up diff. The revised segment and group checks share their previous predicates, and one proof each supplies group reachability, row composition, and bit-action composition. The finite representation reuses the general complete atomic equivalence using a local instance. The atom labelling now composes the existing disjoint unions and still proves the same identity and converse equalities. The unused interval and Huntington modules and unused closure and domain infrastructure leave the import. The full local and GitHub build results above apply to the earlier commit. The revised targeted build passed through six atoms and a seven-atom sample. Full validation of the current commit follows.

Dependency graph follow-up

The 17-file follow-up addresses the duplication and scope findings. I checked the patch and its import closure. The encoding module uses the smaller cycle interface and the group proof imports the orbit theory directly. One set of definitions now decodes quadruples and checks order and base encoding. The two orbit-counting paths share the checked reduction from invariant leaves. The deleted supporting modules had no dependency in the enumeration after moving to the complete atomic representation. The dependency closure for S99 fell from 55 to 47 local modules.

A matched single-thread check of S99 passed at 33.79 s before and 33.89 s after, with peak RSS decreasing from 2,987,924 to 2,953,684 KiB. The updated conversion verifier checks the six-atom direct and seven-atom subtype variants for all 22,120 weighted checks. Second GPT review · Certificate conversion and verifier

Remaining advisory suggestions

I checked the suggestion to move symmetry dependencies out of the standalone elimination checker against the actual import graph. It would reduce that standalone closure from 20 local modules to 18. All 1,144 generated certificate segments import the symmetry modules independently through their case setup, so this rearrangement saves zero imports on those build paths. Shared numeric decoders already apply to the proof-replaying code. The remaining separate folds in the direct, optimized, and elimination evaluators are cross-checked against the same associativity condition by the existing correctness proofs. The relation-algebra homomorphism and residual APIs provide general infrastructure beyond the enumeration. I found no unresolved correctness or trust issue in these suggestions.

The versioned PR converter now renders the weighted declaration blocks and shared column modules directly from the pinned upstream. The independent replay checked all 22,120 substitutions and matched all three column modules byte for byte. Certificate conversion and verifier

Latest local validation

The seven-atom aggregate imported successfully on the pinned toolchain. The guarded build took 1:16:41 and covered all 1,373 Lean modules, with 1,345 recompiled and 28 supported by verified timing receipts. The slowest file took 44 s and peak anonymous memory was 2.8 GiB. All 121,161 declarations passed the Mathlib linter. Project indexes, text style, static quality, card declarations, compiled axiom and option audits, and the build-message check passed. A fresh Lean import printed exactly propext, Classical.choice, and Quot.sound for all seven headline results. Latest GitHub CI

The latest guarded local build took 1:16:41 with 1,345 rebuilt modules and recorded timings verified for 28 unchanged compiler outputs. All 1,373 files met the limits, with a slowest file of 44 s and a 2.8 GiB anonymous memory peak. Both local and GitHub checks passed for indexes, compilation, text style, Mathlib lint across 121,161 declarations, and the compiled audit. The required GitHub Build project and Content / non-content separation checks passed. The content-only scope skipped documentation preflight, Python, exposition, and workflow lint jobs. Exact-head Lean CI · All PR checks

@Vilin97 Vilin97 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

License fix required at d6dce574.

  • Add a prominent change notice to each modified upstream file, keeping the original copyright and author headers. I compared same-path files against both pinned sources and found 1,333 changed Henson files and eight changed CSLib files without a notice in their headers. The project entry has an adaptation notice. The changed certificate and foundation files also need their own notices under Apache-2.0 §4(b). Apache-2.0 · Certificate example · CSLib foundation example
  • The seven totals and sixteen symmetry counts match Jipsen’s table. The reduction to lawful atom cycles and the checked orbit partitions support the count. Required Lean CI is still running for the complete import. Published counts · Lean CI

@Vilin97
Vilin97 marked this pull request as ready for review November 26, 2026 18:44
@greptile-apps

greptile-apps Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Advisory cross-file review against Lean Pool's supervisory rubric. This is not by itself a significance, source-verification, or merge verdict.

No blocking defect was found in the reviewed changes, but this review does not establish that the full contribution is ready to merge.RetriggerView in Greptile

[Medium impact] No blocking defect was found in the reviewed changes, but this review does not establish that the full contribution is ready to merge.

Summary

Imports finite integral relation algebra counts through seven atoms, including the total of 344,809,166,311 classes. The latest changes share checker helpers and counting proofs, narrow imports, and remove unused foundations.

  • Lean Pool counts finite integral relation algebras through seven atoms.

Reviews (3) · Last reviewed commit: "Narrow the certificate dependency graph" · Reviewed by Greptile

@Vilin97

Vilin97 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator Author

/review

@Vilin97

Vilin97 commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator Author

🤖 LLM review (gpt-6.2-sol, 5 rubrics)

Reviewed head: 9ff667184f4e636781896412428942991152296d

Verdict: ✅ approve — computed from the rubric verdicts below, not chosen by a model.

Rubric Verdict Bottom line
Faithfulness ✅ pass All seven headline statements match the card, and local warning-as-error builds passed through six atoms and for the seven-atom type with three nonsymmetric pairs while the full build for this head remained in progress. Head CI
Novelty ✅ pass Source searches of pinned Mathlib, both Tau Ceti snapshots, and the existing pool found no duplicate of any of the seven headline counts, with broader semantic overlap still unverifiable and the head CI build still in progress.
Significance ✅ pass The general orbit classification and exact seven-atom enumeration merit inclusion, with the current-head Lean build still in progress. Lean CI
Sources ✅ pass All sixteen symmetry counts and seven derived totals match Jipsen’s table, the port credits Henson’s formalization and CSLib, and Lean CI for the reviewed head was still running. Jipsen’s table Pinned upstream Head CI
Code quality (advisory) ⚠️ flag Repeated quadruple row selection, unnecessary symmetry dependencies, and unused foundation APIs warrant an advisory flag, and the current-head build and profiling jobs were still running when checked. Lean Action CI Proof Profile
Aspect Value
Proves the claim ✅ proves_it
Matches cited source ✅ matches
Fit ✅ good_fit
Level research
Branch algebraic logic
Mode mixed
Code quality 3 / 5

Statement check: card_ofAtoms_seven proves Nat.card (ofAtoms 7) = 344809166311, with exists_ofCycles_of_isIntegral providing a lawful cycle presentation for every finite integral relation algebra and the quotient identifying presentations by relation-algebra equivalence.

The project classifies finite integral relation algebras of arbitrary symmetry type by orbits of lawful atom-cycle sets and uses Burnside’s lemma and checked orbit sums to enumerate them through seven atoms, culminating in Nat.card (ofAtoms 7) = 344809166311.

Faithfulness findings (1)

  • prompt-injection — PR-wide
    Contributor comment 7199286866 says “The second GPT review approved all blocking rubrics.” Invoking earlier approval can prejudge the independent verdict for this head. Report the revision and its reproducible checks.
    Evidence: prose only

Novelty findings (2)

  • partial-overlap — LeanPool/FiniteIntegralRelationAlgebras/Theory/Orbits.lean:93
    The prior art supplies orbit formulas. Mathlib’s MulAction.sum_card_fixedBy_eq_card_orbits_mul_card_group gives the general fixed-point sum, Tau Ceti’s TauCeti.sum_card_fixedBy_mul_card_fixedBy_eq_card_orbits_mul_card_group gives the product-action formula, and LeanPool.PolyaEnumerationTheorem.polya_theorem counts unrestricted colorings. Mathlib declaration
    Evidence: sum_card_fixed_eq_card_orbits_mul_card_aut rewrites with ← MulAction.sum_card_fixedBy_eq_card_orbits_mul_card_group and counts fixed cycle sets satisfying IntegralAtom.IsLawfulCycles T.
  • prompt-injection — PR-wide
    The contributor invokes earlier GPT approvals in the PR discussion, which could bias the independent novelty verdict for this head.
    Evidence: The contributor writes ‘The first GPT review passed faithfulness, novelty, and significance, and identified imprecise attribution and specific maintenance debt.’ and ‘The second GPT review approved all blocking rubrics.’ PR discussion

Significance findings (2)

  • generated-bulk — LeanPool/FiniteIntegralRelationAlgebras/Atoms7/S6N0/C0/S99.lean:42
    The 1,144 generated segments account for 1,011,178 of 1,052,237 added Lean lines (96.1%). They use natural-number lists and project-local kernel checks, concentrating Mathlib-facing maintenance in the shared library. The pinned Rust generator emits the upstream certificates. Reproducing the submitted subtype witnesses and shared columns requires a manual conversion. Publish a versioned converter for the pooled files. I matched all segment data and propositions against the pinned snapshot and recomputed all three column tables. Lean 4.36.0 checked the orbit reduction, the six smaller totals, and S99 with cached imports. Upstream regeneration check
    Evidence: S99 packages a weighted count in { total : ℕ // P.sumEvE 20 6 qt ow qmFlat seg0 ev0 0 total = true } and verifies its orbit segment with checkSeg_of_columns orbitGroupSize orbitColumnsChecked (by decide +kernel).
  • prompt-injection — PR-wide
    The contributor invokes earlier rubric approvals in the current-head discussion, which risks prejudging the independent significance verdict. Limit validation summaries to reproducible checks.
    Evidence: The contributor writes ‘The first GPT review passed faithfulness, novelty, and significance, and identified imprecise attribution and specific maintenance debt.’ and ‘The second GPT review approved all blocking rubrics.’ PR discussion

Sources findings (1)

  • prompt-injection — PR-wide
    The contributor’s discussion invokes approval of an earlier revision, which risks prejudging the independent source verdict for this head. Remove the approval claim and retain the source comparisons. PR discussion
    Evidence: The second GPT review approved all blocking rubrics.

Code quality findings (5)

  • duplicate-definition — LeanPool/FiniteIntegralRelationAlgebras/Cert/Elim.lean:182
    The direct evaluator, optimized evaluator, and elimination checker each spell out the four associativity row selections. trivQuad, checkLeaf, coversQuad, dotRL, dotRR, quadTab4, and quadD4 must agree on which indices take converse. quadAt and several correctness proofs also repeat the arithmetic already named by quadFirst through quadFourth. Use those decoders throughout and share the left and right row indices so each evaluator can apply its own fold.
    Evidence: trivQuad and checkLeaf both select the first left row with (nth [] (nth [] P.cls (cvN P.s (P.quadFirst x))) (P.quadFourth x)). quadTab4 uses (rowAt rows (cvN P.s r) p) (rowAt rows u t). quadAt still starts its call with quadB P.s P.k (P.tbl v) (x / P.k / P.k / P.k % P.k) (x / P.k / P.k % P.k) (x / P.k % P.k).
  • unnecessary-dependency — LeanPool/FiniteIntegralRelationAlgebras/Cert/Elim.lean:10
    The elimination checker imports SymOrbit for SegSum, and Fast reaches through Sym for deadLR and the evaluator. This couples the standalone checker to changes in the symmetry proofs. Move SegSum and OrbitSeg.of_checkSum to Orbit, put deadLR beside deadR, and have Fast import Eval directly. A warning-as-error scratch build passed for the elimination checker, generator symmetry checker, and Atoms7.S0N3.C1 with those moves.
    Evidence: Elim.lean has public import LeanPool.FiniteIntegralRelationAlgebras.Cert.SymOrbit, and sumEvE_sum concludes SegSum (P.leaf (b + m)) seg W. Fast.lean has public import LeanPool.FiniteIntegralRelationAlgebras.Cert.Sym and calls deadLR (top b) (P.dotRL b e.1 r₁) (P.dotRR b e.1 r₂) in deadR.
  • unused-api — LeanPool/FiniteIntegralRelationAlgebras/Foundations/RelationAlgebra/Basic.lean:193
    The quantale instance serves only the two residuation comparison lemmas, which have no callers in the project. The residual definitions, their laws, and the quantale import add maintenance and typeclass surface to the foundation used by every certificate. Omit this branch from the import.
    Evidence: instance instQuantale (α : Type*) [CompleteRelationAlgebra α] : IsQuantale α where supplies mul_sSup_distrib _ _ := mul_sSup and sSup_mul_distrib _ _ := sSup_mul. Its two consumers are leftMulResiduation_eq_leftResidual and rightMulResiduation_eq_rightResidual.
  • unused-api — LeanPool/FiniteIntegralRelationAlgebras/Foundations/RelationAlgebra/Hom.lean:24
    The classification and counts use RelationAlgebraEquiv. The separate homomorphism structure, its four instances, and its conversions are used only within the homomorphism API. Omit that branch. A warning-as-error scratch build of the one-atom total and Atoms7.S0N3.C1.S0 passed with the homomorphism and quantale branches removed.
    Evidence: structure RelationAlgebraHom (α β : Type*) [RelationAlgebra α] [RelationAlgebra β] extends BoundedLatticeHom α β, StarMonoidHom α β. The associated conversions include def toHom (f : RelationAlgebraEquiv α β) : RelationAlgebraHom α β := and def ofHomInv (f : RelationAlgebraHom α β) (g : RelationAlgebraHom β α).
  • prompt-injection — PR-wide
    The contributor invokes prior review approval in the discussion, which can bias an independent review of this head. Assess the current Lean and check results directly.
    Evidence: PR discussion comment 7199286866 states, “The second GPT review approved all blocking rubrics.”

Tokens: 11,848,298 in / 66,267 out across 5 model calls · Tier: codex-subscription · Effort: xhigh · Billing: Codex subscription quota (no API credits) · Estimated cost: $48.3872 (Standard API equivalent; uncached input)
Each rubric is an independent review against .github/review-rubrics/ on top of .github/REVIEW_RULES.md. Disagree? Reply on the PR; rules can be updated in a PR of their own.

CI was not green for this commit at review time; this review does not replace CI.

@Vilin97

Vilin97 commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator Author

The certificate conversion preserves the checked data and statement types.

Inputs and conversion

Use the Solution closure from upstream commit 5620a22cc48127b592bca85b1aaf013e55d4f6df. The pinned source tree contains the generated input. The upstream scripts/check-regen.sh documents how to regenerate it with the Rust generator. Upstream generator and regeneration check

  1. Copy Solution.lean and its imported Solution/ files to the corresponding LeanPool/FiniteIntegralRelationAlgebras modules. Rename the import prefix, remove upstream option overrides, and wrap generated literals to fit the pool style. Keep the original order of all list entries, segment intervals, and numeral tokens.
  2. In the two large symmetry inputs under Atoms6/S5N0/C0 and Atoms7/S6N0/C0, split the permutation list into consecutive batches of 36 pairs and concatenate the batches with a balanced append tree in their original order. Copy the original symmetry record at each index named in gens, in generator order. Move the problem data into ProblemData.lean; retain the original group sizes, generator rows and inverse row. In the seven-atom group, verify each of the five generator multiplication rows and the inverse row with the shared predicates, then assemble the complete kernel certificate.
  3. Under Atoms7/{S2N2,S4N1,S6N0}/C0, let size be the original permutation count. Initialize column i with bit i * (size + 1) + size. For permutation g, set bit g + forward[g][i] * (size + 1) in that column. Write the result as little-endian 256-bit words. Check the complete columns against cols in Lean before passing them to the segment checker. Each segment keeps its original evidence, bounds and result type.
  4. Keep the original seg and ev lists and their kernel checks unchanged in the five six-atom segment modules. In every seven-atom segment, use private proof-only seg and ev definitions. If the original weighted check for index i concludes P.sumEvE … N = true, introduce private def checkedCount{i} : { total : ℕ // P.sumEvE … total = true } := ⟨N, by decide +kernel⟩, then use checkedCount{i}.property as the original sumOK{i} theorem's proof. The independently checked group-table rows use propositions paired with Unit. Check the 57 singleton direct counts as their original total statements.
  5. Run lake exe mk_all --module, and run the verifier below against clean checkouts of the pinned upstream and the port. Then build the project aggregate under the repository watchdog.

Verification

Save the following as verify-conversion.py and pass the upstream checkout and the port project directory as arguments. It independently rebuilds the shared columns from upstream permutations and compares the preserved lists, proposition types, and both forms of weighted kernel witness. The comparison covers 1,144 segments, 22,120 weighted checks, 57 direct totals, three column tables, and all 23 challenge endpoints.

import argparse
import ast
import collections
import json
import pathlib
import re

parser = argparse.ArgumentParser()
parser.add_argument("upstream", type=pathlib.Path)
parser.add_argument("port", type=pathlib.Path)
paths = parser.parse_args()
upstream, target = paths.upstream, paths.port


def compact(text):
    return "".join(text.split())


def list_data(source):
    return {name: compact(body) for name, body in re.findall(
        r"(?ms)^(?:private noncomputable )?def ((?:seg|ev)\d*) : .*? :=\n? *(.*?)(?=\n\n)", source)}


def declaration_types(source):
    return {name: compact(body) for name, body in re.findall(
        r"(?ms)^(?:private )?theorem (sumOK\d+|segOK|total)\s*:\s*(.*?)\s*:=", source)}


def verify_weighted_checks(relative, upstream_source, port_source):
    counts = declaration_types(upstream_source)
    port_tokens = compact(port_source)
    for key, proposition in counts.items():
        if not key.startswith("sumOK"):
            continue
        if relative.parts[1] == "Atoms6":
            assert f"theorem{key}:{proposition}:=bydecide+kernel" in port_tokens
            continue
        index = key.removeprefix("sumOK")
        match = re.search(r"(?ms)^private def checkedCount" + index
                          + r"\s*:\s*\{ total : ℕ // (.*?) \} :=\s*"
                            r"⟨(\d+), by decide \+kernel⟩", port_source)
        assert match, (relative, key)
        predicate, total = match.groups()
        assert compact(predicate.replace(" total = true", f" {total} = true")) == proposition
        assert f"privatetheorem{key}:{proposition}:=checkedCount{index}.property" in port_tokens
    return sum(name.startswith("sumOK") for name in counts)


variants = collections.Counter()
decls = collections.Counter()
source_files = [upstream / "Solution.lean", *sorted((upstream / "Solution").rglob("*.lean"))]
for original in source_files:
    relative = original.relative_to(upstream)
    port = target.with_suffix(".lean") if relative.name == "Solution.lean" else (
        target / relative.relative_to("Solution")
    )
    source = original.read_text()
    port_source = port.read_text()
    assert "\nmodule" in port_source
    if re.match(r"S\d+\.lean$", port.name):
        assert list_data(source) == list_data(port_source), f"changed certificate data: {relative}"
        assert declaration_types(source) == declaration_types(port_source), (
            f"changed certificate proposition: {relative}"
        )
        variants["certificate segments matched"] += 1
        variants["weighted evidence syntax matched"] += verify_weighted_checks(relative, source, port_source)
        decls.update(name.rstrip("0123456789") for name in declaration_types(source))
    else:
        variants["core, class totals or group data mapped"] += 1

for path in sorted(target.glob("Atoms*/**/*.lean")):
    source = path.read_text()
    match = re.search(r"(?m)^theorem total : (P\.sumLeaves .*?) := by decide \+kernel$", source)
    if match:
        original = upstream / "Solution" / path.relative_to(target)
        original_proof = re.search(r"(?m)^theorem c0 : (P\.sumLeaves .*?) := by decide \+kernel$",
                                   original.read_text())
        assert original_proof and compact(original_proof[1]) == compact(match[1]), path
        variants["single-chunk totals matched"] += 1

original_group_source = (upstream / "Solution/Atoms7/S6N0/C0/Defs.lean").read_text()
group_port = target / "Atoms7/S6N0/C0"
permutation_data = re.search(r"(?ms)^def perms : .*? :=\n(.*?)\n\n", original_group_source)[1]
entry = r"\(\[[^\[\]]*\],\s*\[[^\[\]]*\]\)"
split_data = [
    item for path in sorted(group_port.glob("Permutations*.lean"))
    for item in re.findall(entry, path.read_text())
]
assert list(map(compact, split_data)) == list(
    map(compact, re.findall(entry, permutation_data))
), "large group permutations changed"

pattern = r"(?ms)^def perms : .*? :=\n(.*?)\n\n"
for group in sorted((target / "Atoms7").glob("*/C0/Columns.lean")):
    relative = group.parent.relative_to(target)
    original = (upstream / "Solution" / relative / "Defs.lean").read_text()
    permutations = ast.literal_eval(re.search(pattern, original)[1].strip())
    source = group.read_text()
    width, size = map(int, re.search(r"cols (\d+) (\d+) perms = orbitColumns", source).groups())
    assert size == len(permutations), relative
    expected = [1 << (index * (size + 1) + size) for index in range(width)]
    for permutation, (forward, _) in enumerate(permutations):
        for index, image in enumerate(forward):
            expected[index] |= 1 << (image * (size + 1) + permutation)
    words = re.findall(r"ofWords (\[[^\[\]]*\])", source)
    observed = [sum(word << (256 * i) for i, word in enumerate(ast.literal_eval(row)))
                for row in words]
    assert observed == expected, relative
    variants["column tables regenerated"] += 1

comparator = json.loads((upstream / "comparator.json").read_text())
for name in comparator["theorem_names"]:
    qualified_name = name.replace("Cslib.", "FiniteIntegralRelationAlgebras.", 1)
    challenge = (upstream / "Challenge.lean").read_text()
    target_name = qualified_name.rsplit(".", 1)[1]
    expected = re.search(r"(?m)^theorem " + target_name + r"\s*:\s*(.*?) := by", challenge)[1]
    count = 0
    for path in target.glob("Atoms*/*.lean"):
        matches = re.findall(r"(?m)^theorem " + target_name + r"\s*:\s*(.*?) :=", path.read_text())
        for statement in matches:
            assert compact(statement) == compact(expected)
            count += 1
    assert count == 1, f"expected one definition of {qualified_name}, found {count}"
    variants["main theorem statements matched"] += 1

print(json.dumps({"source_files": variants, "segment_declarations": decls,
                  "largest_group_permutations_matched": len(split_data)}, indent=2))

Replaying the generated declarations

The following converter is versioned against upstream 5620a22cc48127b592bca85b1aaf013e55d4f6df and the port at 9ff667184f4e636781896412428942991152296d. Save it as regenerate-witnesses.py and run python3 regenerate-witnesses.py <upstream-checkout> <new-output-directory>. It emits the three complete Columns.lean modules and the original direct kernel checks or private natural-number witness blocks for insertion at each segment's weighted check. All three rendered columns match the port byte for byte. All 22,120 rendered weighted declarations match after whitespace normalization. The numeric lists and assembly statements follow the earlier conversion steps.

"""Render the shared column modules and weighted declaration blocks from the upstream snapshot."""

import argparse
import ast
import re
from pathlib import Path

parser = argparse.ArgumentParser()
parser.add_argument("upstream", type=Path)
parser.add_argument("output", type=Path)
args = parser.parse_args()
source = args.upstream / "Solution"
args.output.mkdir(parents=True, exist_ok=False)

def write(relative_path, content):
    target = args.output / relative_path
    target.parent.mkdir(parents=True, exist_ok=True)
    target.write_text(content)

for file in sorted(source.glob("Atoms*/**/S[0-9]*.lean")):
    relative = file.relative_to(source)
    proofs = []
    for index, statement in re.findall(r"(?ms)^theorem sumOK(\d+)\s*:\s*(.*?)\s*:=\s*by", file.read_text()):
        statement = " ".join(statement.split())
        if relative.parts[0] == "Atoms6":
            proofs.append(f"theorem sumOK{index} :\n    {statement} := by decide +kernel")
            continue
        predicate, value = re.fullmatch(r"(.*) (\d+) = true", statement).groups()
        proofs.append(
            f"private def checkedCount{index} :\n"
            f"    {{ total : ℕ // {predicate} total = true }} :=\n"
            f"  ⟨{value}, by decide +kernel⟩\n\n"
            f"private theorem sumOK{index} :\n"
            f"    {statement} := checkedCount{index}.property"
        )
    assert proofs, relative
    write(relative, "\n\n".join(proofs) + "\n")

def render_column(number):
    words = []
    while number:
        number, word = divmod(number, 1 << 256)
        words.append(hex(word))
    return "    ofWords [" + ",\n      ".join(words) + "]"

for type_name in ("S2N2", "S4N1", "S6N0"):
    relative = Path("Atoms7") / type_name / "C0"
    perms = ast.literal_eval(re.search(
        r"(?ms)^def perms : .*? :=\n(.*?)\n\n",
        (source / relative / "Defs.lean").read_text(),
    )[1].strip())
    size, width = len(perms), len(perms[0][0])
    columns = [1 << (index * (size + 1) + size) for index in range(width)]
    for permutation, (forward, _) in enumerate(perms):
        assert len(forward) == width, relative
        for index, image in enumerate(forward):
            columns[index] |= 1 << (image * (size + 1) + permutation)
    module = f"LeanPool.FiniteIntegralRelationAlgebras.Atoms7.{type_name}.C0"
    namespace = f"RACert.{type_name}.C0"
    data = ",\n".join(map(render_column, columns))
    write(relative / "Columns.lean", f"""/-
Copyright (c) 2026 Chris Henson and Lean Pool contributors. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Henson, Lean Pool contributors
-/

module

public import {module}.Defs
public import LeanPool.FiniteIntegralRelationAlgebras.Cert.SegmentColumns

/-! Kernel-checked bit columns shared by the orbit segments. -/

@[expose] public section

namespace {namespace}

open RACert

/-- Precomputed columns of the action on high-variable assignments. -/
noncomputable def orbitColumns : List ℕ :=
  [
{data}]

theorem orbitGroupSize : perms.length = {size} := by decide +kernel

theorem orbitColumnsChecked : cols {width} {size} perms = orbitColumns := by decide +kernel

end {namespace}
""")

@Vilin97

Vilin97 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator Author

/review

@Vilin97 Vilin97 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

License notices are still required at 2ea37838.

  • I reconciled the previously flagged files against this commit. The two deleted CSLib modules no longer need notices. The remaining 1,339 modified files (1,333 from Henson and six from CSLib) retain their original headers and still need a prominent notice that Lean Pool changed them. Add each notice alongside the existing copyright and author lines. Apache-2.0 §4(b) · Prior review
  • The 57 converted certificates check the same equalities with decide +kernel. The classification refactor still maps identity, symmetric, and nonsymmetric atoms and commutes with converse. All seven totals and sixteen symmetry counts agree with the table. The corrected card gives Jipsen credit for compiling it and Maddux credit for the ordering. Published table · Lean CI

@Vilin97

Vilin97 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator Author

/review

@Vilin97 Vilin97 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

License notices are still required at 9ff66718.

  • The updated count is 1,338 modified upstream files with no prominent change notice. The two deleted CSLib files drop out of the previous count. The newly modified Cert/Prim.lean joins it. The remaining files are 1,334 from Henson and four from CSLib. Keep each original copyright and author line and add a short note identifying Lean Pool's changes. Apache-2.0 §4(b) · Prior review
  • The division-based quadruple decoders are shared with the checker, and the new orbit-sum helper still requires a checked group, a checked segment, and invariance of the leaf evaluator. The headline counts and project card agree with the previous revision. Exact-head Lean CI is still running. Lean CI

@Vilin97 Vilin97 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My independent review approves 9ff667184f4e636781896412428942991152296d after the full source comparison and exact-head validation.

Faithfulness and trust

The exposed seven-atom theorem states Nat.card (ofAtoms 7) = 344809166311. The classification constructs a lawful cycle presentation for each finite integral relation algebra with the relevant numbers of atoms. The quotient is by actual relation-algebra isomorphism. All 23 challenge statements survived the port. The checking library validates permutation composition and completeness, orbit coverage, and the weighted fixed-point counts. The latest compiled audit found exactly propext, Classical.choice, and Quot.sound in the closure of each advertised total. Classification · Seven-atom theorem

Significance, novelty, and sources

The project makes the classification by lawful atom cycles and the certified Boolean/orbit checkers reusable. The proof uses Mathlib's general fixed-point orbit formula to count lawful cycle sets with the additional algebraic constraints. The corpus comparison found no duplicate of the seven counts in the pinned Mathlib or Tau Ceti or in Lean Pool. All sixteen symmetry counts and all seven exact-atom totals agree with Peter Jipsen's compilation. The card names Jipsen as compiler, acknowledges the ordering in Maddux's earlier list, and records Henson's Apache-2.0 formalization. The four adapted CSLib modules keep their original authors' headers. Henson identifies Claude as the proof author. Published table · Pinned upstream

Maintenance and validation

I inspected the complete dependency mapping, all 1,144 segment inputs and 22,120 weighted checks, the two follow-up diffs, the public theorem boundaries, and the proof implementation for the combinatorial reduction. The converter renders the three shared column modules byte for byte and reproduces the weighted declaration blocks from the upstream data. The proof library shares the orbit checks and quadruple decoders, and the largest sampled verifier imports 47 local modules after the dependency cleanup. The separate folds remain checked against the same associativity specification. The proposed extra split of the standalone elimination checker removes no dependencies from any generated segment. Source and performance review · Converter and verifier

The latest guarded local build took 1:16:41 with 1,345 rebuilt modules and recorded timings verified for 28 unchanged compiler outputs. All 1,373 files met the limits, with a slowest file of 44 s and a 2.8 GiB anonymous memory peak. Both local and GitHub checks passed for indexes, compilation, text style, Mathlib lint across 121,161 declarations, and the compiled audit. The required GitHub Build project and Content / non-content separation checks passed. The content-only scope skipped documentation preflight, Python, exposition, and workflow lint jobs. Exact-head Lean CI · All PR checks

The exact-head Greptile review identifies no blocking defect. The configured GPT review passes the four blocking rubrics. I reviewed the remaining code-quality suggestions against the source, graph, and timing evidence above. There are no outstanding material findings. Greptile · GPT review

@Vilin97
Vilin97 added this pull request to the merge queue Nov 27, 2026
Merged via the queue into main with commit 9634631 Nov 27, 2026
27 of 28 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Proof profile (new / modified Lean files)

No proof profile output.

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.

1 participant