duckSMILES GitHub ↗
On this page

Molecular descriptor verification

DuckSMILES exposes the workbench's complete 291-column molecular profile to DuckDB. The extension executes the existing Rust implementation. The offline Lean 4.19 executable checks its serialized results with the independently computed reference. The catalog IDs, order, absolute and relative tolerances come from the repository's descriptor catalog. Per-column reference, evaluator, tolerance and test coverage appear in coverage.csv.

SELECT mol_descriptor_catalog_json();
SELECT mol_descriptor_values_json('CCO');

Lean computes all 291 output coordinates from prepared observations. An unknown catalog ID fails the run. The observation file carries the molecular graph, atom and bond perception, atomic contributions, periodic-table masses and the separately prepared QED and BCUT graphs. RDKit 2026.03.6 prepares these inputs. The main graph preserves explicit hydrogen vertices. Lean computes Labute areas from radii and bonds and EState from graph distances and valence inputs, and initializes Morgan hashes from graph atom properties. It computes the eight QED components from the QED graph, atom masses, TPSA and Crippen contributions. The independent numerical oracle runs on fresh molecules during integration testing.

For the 85 functional groups Lean evaluates the compiled SMARTS, including recursive queries, and counts distinct sorted vertex sets with a cap of 1000. The kernel proves soundness and completeness of the enumerator for its predicates, correctness of anchored recursive queries and membership and uniqueness of the resulting images. It also proves that every duplicate-free enumeration of those images gives the same capped count. A regeneration check pins the compiled queries to the published SMARTS. A separate fixture covers all 85 with positive examples across 98 molecules.

For the 24 native summaries, the kernel proves that reordering the supplied atom, bond, component and ring attributes leaves all 24 outputs unchanged. For the 50 heavy-graph indices, the verifier checks shortest-path certificates before using graph distances. Every accepted finite distance has a walk witness and is a lower bound for every walk to that vertex. A vertex marked unreachable admits no walk. Any two accepted tables on the same graph agree on all finite distances and on which vertices are reachable. The kernel proves which reachable vertex pairs enter the reductions, and equates the total and closed walk counts with explicit walk multiplicities. It also checks exact characteristic-polynomial trace divisions, bin boundaries and the partition of a perceived ring class.

The coverage table names the applicable result for each column. Rust and the Lean verifier use separate molecular preparation paths. For example, RDKit prepares C |$label$| so Lean returns all 291 columns, while the Rust descriptor API marks that CXSMILES input unsupported. A theorem about their outputs on arbitrary SMILES would need a shared input domain. On that domain, correspondence of the parsed graphs and chemical perception, the remaining atomic models, binary64 reductions and Rust execution still need proof. The integration suite checks the actual serialized Rust and SQL results on its recorded finite corpus.

SQL NULL represents an invalid, unsupported or missing molecular input. A JSON null inside a profile represents one undefined descriptor. For defined numbers the absolute difference must be at most the larger of the absolute tolerance and relative tolerance times the absolute reference. Lean compares serialized decimal values by integer scaling. It rejects the wrong number of rows or columns and changed input order. The kernel checks equivalence to the declared integer comparison, presence agreement, full-coordinate coverage and invariance of element counts under atom-list permutation. Molecular perception, floating-point algorithms, serialization and the Rust binary have finite differential-test coverage. Materials composition and viscosity APIs are documented separately in MATERIALS.md.

Comparison with registered RDKit functions

The column inventory covers all 291 names. The observed differences record the two input preparation policies and the independent chain controls. On the 226 nonempty, parsable inputs, Lean compared 49,042 outputs from all 217 registered default 2D scalars using the catalog tolerances. Of these, 48,980 were finite, 60 were nonfinite and two SPS calls raised ZeroDivisionError on hydrogen-only inputs. All values agreed after mapping undefined results to descriptor null. The other 24 graph summaries used public RDKit molecular properties; the extra 50 used independent formulas on RDKit graphs. Separately, the empty SMILES parses to a zero-atom RDKit molecule, and DuckSMILES returns SQL NULL.

The audit runs each registered function on a fresh copy of the molecule. Lean compares the returned numbers or nulls and records the ID of every mismatching coordinate. The measured agreement is conditional on preprocessing, inputs, registered version and tolerances.

Reproduce

From this directory with the pinned Lean toolchain on PATH:

lake build
lake env lean Tests.lean
uv run --python 3.13 --with rdkit==2026.3.6 python generate_fragments.py --check
uv run --python 3.13 --with rdkit==2026.3.6 python check_fragments.py
uv run --python 3.13 --with rdkit==2026.3.6 python reference.py CCO > /tmp/obs.json
.lake/build/bin/descriptor_check reference ../../tasks/descriptors/phase1-catalog.json /tmp/obs.json
(cd ../.. && cargo rustc --locked --release -p ducksmiles_smiles --lib --crate-type cdylib)
uv run --python 3.13 --with rdkit==2026.3.6 python integration.py ../../target/release/libducksmiles_smiles.so

To reproduce both RDKit input policies and the chain controls, run uv run --python 3.13 --with rdkit==2026.3.6 python compare_rdkit.py --output /tmp/rdkit-audit --library /path/to/libducksmiles_smiles.so. The output includes a per-descriptor CSV and the individual differences.

On macOS use the .dylib artifact. If the bundled linker generates an executable the system loader rejects, build with LEAN_CC=/usr/bin/clang and LIBRARY_PATH="$(lean --print-prefix)/lib" and set MACOSX_DEPLOYMENT_TARGET to the installed SDK's supported macOS version. For SQL integration add --with duckdb==1.5.5 to uv and pass --extension /path/to/ducksmiles.duckdb_extension built for that exact DuckDB ABI. Add --coverage coverage.csv --timings timings-m1.csv to write per-column results and the six timed trials. Pass --extended to check the 228-input corpus used in CI and in the coverage table. Timings and mutation controls use the smaller batch of eight valid and two rejected inputs. Five independent mutations exercise error detection. These controls supplement the project's larger existing reference comparisons.

Timing

The historical 0.7.1 pipeline trials time a native Rust FFI batch, a SQL query including result conversion, and a fresh Lean process reading the earlier oracle-backed observation format and rendering JSON. Those paths include different work. The count trials use the same prepared atom labels and query order in both languages, excluding input parsing, I/O and process startup. Both programs check the same checksum. Run lake build bench_counts then uv run --python 3.13 --with rdkit==2026.3.6 python bench_counts.py on the target host.

Browse all 291 descriptors